Sam James writes: > This imports the following commits from GCC as of r15-1722-g7682d115402743: > ca2f7c84927f libiberty: Invoke D demangler when --format=auto > 94792057ad4a Fix up duplicated words mostly in comments, part 1 > 20e57660e64e libiberty: Fix error return value in pex_unix_exec_child [PR113957]. > 52ac4c6be866 [libiberty] remove TBAA violation in iterative_hash, improve code-gen > 53bb7145135c libiberty: Fix up libiberty_vprintf_buffer_size > 65388b28656d c++, demangle: Implement https://github.com/itanium-cxx-abi/cxx-abi/issues/148 non-proposal > --- ping. It might be nice for this to get in for binutils-2.43 branching given the UB fix for hashing. > libiberty/ChangeLog | 45 +++++++++++++++++ > libiberty/cplus-dem.c | 2 +- > libiberty/dyn-string.c | 2 +- > libiberty/functions.texi | 14 +++--- > libiberty/hashtab.c | 23 ++++----- > libiberty/pex-unix.c | 2 + > libiberty/regex.c | 2 +- > libiberty/testsuite/d-demangle-expected | 5 ++ > libiberty/vprintf-support.c | 65 ++++++++++++++++++++++--- > 9 files changed, 131 insertions(+), 29 deletions(-) > > diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog > index 884c8b70f87..cdcd4b3ced8 100644 > --- a/libiberty/ChangeLog > +++ b/libiberty/ChangeLog > @@ -1,3 +1,48 @@ > +2024-04-02 Tom Tromey > + > + * cplus-dem.c (cplus_demangle): Try the D demangler with > + "auto" format. > + * testsuite/d-demangle-expected: Add --format=auto test. > + > +2024-04-02 Jakub Jelinek > + > + * regex.c (byte_re_match_2_internal): Fix duplicated words in comment; > + next next -> next. > + * dyn-string.c (dyn_string_init): Fix duplicated words in comment; > + of of -> of. > + > +2024-02-19 Iain Sandoe > + > + PR other/113957 > + * pex-unix.c (pex_unix_exec_child): Set pid = -1 in the error > + paths, since that is used to signal an erroneous outcome for > + the routine. > + > +2024-02-15 Richard Biener > + > + * hashtab.c (iterative_hash): Remove TBAA violating handling > + of aligned little-endian case in favor of just keeping the > + aligned case special-cased. Use | for composing a larger word. > + > +2024-02-12 Jakub Jelinek > + > + * vprintf-support.c (libiberty_vprintf_buffer_size): Handle > + properly l, ll, z, t or on _WIN32 I64 modifiers for diouxX > + and L modifier for fFgGeE. > + > +2024-01-13 Jakub Jelinek > + > + * cp-demangle.c (FNQUAL_COMPONENT_CASE): Add case for > + DEMANGLE_COMPONENT_XOBJ_MEMBER_FUNCTION. > + (d_dump): Handle DEMANGLE_COMPONENT_XOBJ_MEMBER_FUNCTION. > + (d_nested_name): Parse H after N in nested name. > + (d_count_templates_scopes): Handle > + DEMANGLE_COMPONENT_XOBJ_MEMBER_FUNCTION. > + (d_print_mod): Likewise. > + (d_print_function_type): Likewise. > + * testsuite/demangle-expected: Add tests for explicit object > + member functions. > + > 2023-12-05 Jakub Jelinek > > * configure.ac (HAVE_X86_SHA1_HW_SUPPORT): Verify __get_cpuid and > diff --git a/libiberty/cplus-dem.c b/libiberty/cplus-dem.c > index 8b92946981f..ee9e84f5d6b 100644 > --- a/libiberty/cplus-dem.c > +++ b/libiberty/cplus-dem.c > @@ -186,7 +186,7 @@ cplus_demangle (const char *mangled, int options) > if (GNAT_DEMANGLING) > return ada_demangle (mangled, options); > > - if (DLANG_DEMANGLING) > + if (DLANG_DEMANGLING || AUTO_DEMANGLING) > { > ret = dlang_demangle (mangled, options); > if (ret) > diff --git a/libiberty/dyn-string.c b/libiberty/dyn-string.c > index ecd8c069984..5805c0b4ff8 100644 > --- a/libiberty/dyn-string.c > +++ b/libiberty/dyn-string.c > @@ -47,7 +47,7 @@ Boston, MA 02110-1301, USA. */ > > /* Performs in-place initialization of a dyn_string struct. This > function can be used with a dyn_string struct on the stack or > - embedded in another object. The contents of of the string itself > + embedded in another object. The contents of the string itself > are still dynamically allocated. The string initially is capable > of holding at least SPACE characeters, including the terminating > NUL. If SPACE is 0, it will silently be increated to 1. > diff --git a/libiberty/functions.texi b/libiberty/functions.texi > index 651b169b040..b56b02e0686 100644 > --- a/libiberty/functions.texi > +++ b/libiberty/functions.texi > @@ -165,7 +165,7 @@ not recommended. > > @end deftypefn > > -@c make-temp-file.c:108 > +@c make-temp-file.c:95 > @deftypefn Replacement const char* choose_tmpdir () > > Returns a pointer to a directory path suitable for creating temporary > @@ -192,7 +192,7 @@ Concatenate zero or more of strings and return the result in freshly > > @end deftypefn > > -@c argv.c:485 > +@c argv.c:495 > @deftypefn Extension int countargv (char * const *@var{argv}) > > Return the number of elements in @var{argv}. > @@ -257,7 +257,7 @@ symbolic name or message. > > @end deftypefn > > -@c argv.c:339 > +@c argv.c:352 > @deftypefn Extension void expandargv (int *@var{argcp}, char ***@var{argvp}) > > The @var{argcp} and @code{argvp} arguments are pointers to the usual > @@ -726,7 +726,7 @@ relative prefix can be found, return @code{NULL}. > > @end deftypefn > > -@c make-temp-file.c:185 > +@c make-temp-file.c:173 > @deftypefn Replacement char* make_temp_file (const char *@var{suffix}) > > Return a temporary file name (as a string) or @code{NULL} if unable to > @@ -1747,7 +1747,7 @@ that the converted value is unsigned. > @c strtoll.c:33 > @deftypefn Supplemental {long long int} strtoll (const char *@var{string}, @ > char **@var{endptr}, int @var{base}) > -@deftypefnx Supplemental {unsigned long long int} strtoul (@ > +@deftypefnx Supplemental {unsigned long long int} strtoull (@ > const char *@var{string}, char **@var{endptr}, int @var{base}) > > The @code{strtoll} function converts the string in @var{string} to a > @@ -1938,8 +1938,8 @@ does the return value. The third argument is unused in @libib{}. > @deftypefn Extension int writeargv (char * const *@var{argv}, FILE *@var{file}) > > Write each member of ARGV, handling all necessary quoting, to the file > -associated with FILE, separated by whitespace. Return 0 on success, > -non-zero if an error occurred while writing to FILE. > +named by FILE, separated by whitespace. Return 0 on success, non-zero > +if an error occurred while writing to FILE. > > @end deftypefn > > diff --git a/libiberty/hashtab.c b/libiberty/hashtab.c > index 48f28078114..e3a07256a30 100644 > --- a/libiberty/hashtab.c > +++ b/libiberty/hashtab.c > @@ -940,26 +940,23 @@ iterative_hash (const void *k_in /* the key */, > c = initval; /* the previous hash value */ > > /*---------------------------------------- handle most of the key */ > -#ifndef WORDS_BIGENDIAN > - /* On a little-endian machine, if the data is 4-byte aligned we can hash > - by word for better speed. This gives nondeterministic results on > - big-endian machines. */ > - if (sizeof (hashval_t) == 4 && (((size_t)k)&3) == 0) > - while (len >= 12) /* aligned */ > + /* Provide specialization for the aligned case for targets that cannot > + efficiently perform misaligned loads of a merged access. */ > + if ((((size_t)k)&3) == 0) > + while (len >= 12) > { > - a += *(hashval_t *)(k+0); > - b += *(hashval_t *)(k+4); > - c += *(hashval_t *)(k+8); > + a += (k[0] | ((hashval_t)k[1]<<8) | ((hashval_t)k[2]<<16) | ((hashval_t)k[3]<<24)); > + b += (k[4] | ((hashval_t)k[5]<<8) | ((hashval_t)k[6]<<16) | ((hashval_t)k[7]<<24)); > + c += (k[8] | ((hashval_t)k[9]<<8) | ((hashval_t)k[10]<<16)| ((hashval_t)k[11]<<24)); > mix(a,b,c); > k += 12; len -= 12; > } > else /* unaligned */ > -#endif > while (len >= 12) > { > - a += (k[0] +((hashval_t)k[1]<<8) +((hashval_t)k[2]<<16) +((hashval_t)k[3]<<24)); > - b += (k[4] +((hashval_t)k[5]<<8) +((hashval_t)k[6]<<16) +((hashval_t)k[7]<<24)); > - c += (k[8] +((hashval_t)k[9]<<8) +((hashval_t)k[10]<<16)+((hashval_t)k[11]<<24)); > + a += (k[0] | ((hashval_t)k[1]<<8) | ((hashval_t)k[2]<<16) | ((hashval_t)k[3]<<24)); > + b += (k[4] | ((hashval_t)k[5]<<8) | ((hashval_t)k[6]<<16) | ((hashval_t)k[7]<<24)); > + c += (k[8] | ((hashval_t)k[9]<<8) | ((hashval_t)k[10]<<16)| ((hashval_t)k[11]<<24)); > mix(a,b,c); > k += 12; len -= 12; > } > diff --git a/libiberty/pex-unix.c b/libiberty/pex-unix.c > index af98062a94c..f3a1cc95ada 100644 > --- a/libiberty/pex-unix.c > +++ b/libiberty/pex-unix.c > @@ -695,6 +695,7 @@ pex_unix_exec_child (struct pex_obj *obj ATTRIBUTE_UNUSED, > { > *err = ret; > *errmsg = "posix_spawnp"; > + pid = -1; /* The value of pid is unspecified on failure. */ > goto exit; > } > } > @@ -705,6 +706,7 @@ pex_unix_exec_child (struct pex_obj *obj ATTRIBUTE_UNUSED, > { > *err = ret; > *errmsg = "posix_spawn"; > + pid = -1; > goto exit; > } > } > diff --git a/libiberty/regex.c b/libiberty/regex.c > index 4841c5a08f9..67747e6ce5a 100644 > --- a/libiberty/regex.c > +++ b/libiberty/regex.c > @@ -5597,7 +5597,7 @@ byte_re_match_2_internal (struct re_pattern_buffer *bufp, > to resume scanning the pattern; the second one is where to resume > scanning the strings. If the latter is zero, the failure point is > a ``dummy''; if a failure happens and the failure point is a dummy, > - it gets discarded and the next next one is tried. */ > + it gets discarded and the next one is tried. */ > #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ > PREFIX(fail_stack_type) fail_stack; > #endif > diff --git a/libiberty/testsuite/d-demangle-expected b/libiberty/testsuite/d-demangle-expected > index 47b059c4298..cfbdf2a52cb 100644 > --- a/libiberty/testsuite/d-demangle-expected > +++ b/libiberty/testsuite/d-demangle-expected > @@ -1470,3 +1470,8 @@ demangle.anonymous > --format=dlang > _D8demangle9anonymous03fooZ > demangle.anonymous.foo > +# > +# Test that 'auto' works. > +--format=auto > +_D8demangle9anonymous03fooZ > +demangle.anonymous.foo > diff --git a/libiberty/vprintf-support.c b/libiberty/vprintf-support.c > index b590e5ab034..0543ec0554e 100644 > --- a/libiberty/vprintf-support.c > +++ b/libiberty/vprintf-support.c > @@ -56,6 +56,7 @@ libiberty_vprintf_buffer_size (const char *format, va_list args) > { > if (*p++ == '%') > { > + int prec = 0; > while (strchr ("-+ #0", *p)) > ++p; > if (*p == '*') > @@ -76,8 +77,43 @@ libiberty_vprintf_buffer_size (const char *format, va_list args) > else > total_width += strtoul (p, (char **) &p, 10); > } > - while (strchr ("hlL", *p)) > - ++p; > + do > + { > + switch (*p) > + { > + case 'h': > + ++p; > + continue; > + case 'l': > + case 'L': > + ++prec; > + ++p; > + continue; > + case 'z': > + prec = 3; > + ++p; > + continue; > + case 't': > + prec = 4; > + ++p; > + continue; > +#ifdef _WIN32 > + case 'I': > + if (p[1] == '6' && p[2] == '4') > + { > + prec = 2; > + p += 3; > + continue; > + } > + break; > +#endif > + default: > + break; > + } > + break; > + } > + while (1); > + > /* Should be big enough for any format specifier except %s and floats. */ > total_width += 30; > switch (*p) > @@ -88,6 +124,15 @@ libiberty_vprintf_buffer_size (const char *format, va_list args) > case 'u': > case 'x': > case 'X': > + switch (prec) > + { > + case 0: (void) va_arg (ap, int); break; > + case 1: (void) va_arg (ap, long int); break; > + case 2: (void) va_arg (ap, long long int); break; > + case 3: (void) va_arg (ap, size_t); break; > + case 4: (void) va_arg (ap, ptrdiff_t); break; > + } > + break; > case 'c': > (void) va_arg (ap, int); > break; > @@ -96,10 +141,18 @@ libiberty_vprintf_buffer_size (const char *format, va_list args) > case 'E': > case 'g': > case 'G': > - (void) va_arg (ap, double); > - /* Since an ieee double can have an exponent of 307, we'll > - make the buffer wide enough to cover the gross case. */ > - total_width += 307; > + if (!prec) > + { > + (void) va_arg (ap, double); > + /* Since an ieee double can have an exponent of 308, we'll > + make the buffer wide enough to cover the gross case. */ > + total_width += 308; > + } > + else > + { > + (void) va_arg (ap, long double); > + total_width += 4932; > + } > break; > case 's': > total_width += strlen (va_arg (ap, char *));