[gcc r14-9780] Don't set full_profile in auto-profile [PR113765]
https://gcc.gnu.org/g:fe385c219994f6d5c1ffe00bcaf5a62c3d18caaf commit r14-9780-gfe385c219994f6d5c1ffe00bcaf5a62c3d18caaf Author: Eugene Rozenfeld Date: Tue Mar 26 16:28:08 2024 -0700 Don't set full_profile in auto-profile [PR113765] auto-profile currently doesn't guarantee that it will set probabilities on all edges because of zero basic block counts. Normally those edges just have probabilities set by the preceding profile_estimate pass but under -O0 profile_estimate pass doesn't run. The patch removes setting of full_profile to true in auto-profile. Tested on x86_64-pc-linux-gnu. gcc/ChangeLog: PR gcov-profile/113765 * auto-profile.cc (afdo_annotate_cfg): Don't set full_profile to true Diff: --- gcc/auto-profile.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/gcc/auto-profile.cc b/gcc/auto-profile.cc index e5407d32fbb..de59b94bcb3 100644 --- a/gcc/auto-profile.cc +++ b/gcc/auto-profile.cc @@ -1580,7 +1580,6 @@ afdo_annotate_cfg (const stmt_set &promoted_stmts) } update_max_bb_count (); profile_status_for_fn (cfun) = PROFILE_READ; - cfun->cfg->full_profile = true; if (flag_value_profile_transformations) { gimple_value_profile_transformations ();
[gcc r14-9778] Update gcc sv.po
https://gcc.gnu.org/g:f37555028717cb1454ee258afdf68aea1c7a50e9 commit r14-9778-gf37555028717cb1454ee258afdf68aea1c7a50e9 Author: Joseph Myers Date: Wed Apr 3 20:47:47 2024 + Update gcc sv.po * sv.po: Update. Diff: --- gcc/po/sv.po | 203 --- 1 file changed, 82 insertions(+), 121 deletions(-) diff --git a/gcc/po/sv.po b/gcc/po/sv.po index 514eb7c764a..d8a55cf55d3 100644 --- a/gcc/po/sv.po +++ b/gcc/po/sv.po @@ -32,7 +32,7 @@ msgstr "" "Project-Id-Version: gcc 14.1-b20240218\n" "Report-Msgid-Bugs-To: https://gcc.gnu.org/bugs/\n"; "POT-Creation-Date: 2024-02-16 21:35+\n" -"PO-Revision-Date: 2024-03-24 12:59+0100\n" +"PO-Revision-Date: 2024-04-02 09:51+0200\n" "Last-Translator: Göran Uddeborg \n" "Language-Team: Swedish \n" "Language: sv\n" @@ -54589,16 +54589,14 @@ msgid "import declared %q#D here" msgstr "importdeklarerad %q#D här" #: cp/decl.cc:2306 cp/decl.cc:16628 -#, fuzzy, gcc-internal-format -#| msgid "conflicting exporting declaration %qD" +#, gcc-internal-format msgid "conflicting exporting for declaration %qD" -msgstr "motstridande exporterande deklaration av %qD" +msgstr "motstridande exporterande för deklaration av %qD" #: cp/decl.cc:2308 cp/decl.cc:16630 -#, fuzzy, gcc-internal-format -#| msgid "previously declared here" +#, gcc-internal-format msgid "previously declared here without exporting" -msgstr "tidigare deklarerad här" +msgstr "tidigare deklarerad här utan att exporteras" #: cp/decl.cc:2335 #, gcc-internal-format @@ -54781,16 +54779,14 @@ msgid " enters % statement" msgstr " går in i %-sats" #: cp/decl.cc:3829 cp/decl.cc:4003 -#, fuzzy, gcc-internal-format -#| msgid "ISO C99 does not support %qE" +#, gcc-internal-format msgid " does not destroy %qD" -msgstr "ISO C99 stödjer inte %qE" +msgstr " förstör inte %qD" #: cp/decl.cc:3831 cp/decl.cc:3986 -#, fuzzy, gcc-internal-format -#| msgid "%s does not take any feature options" +#, gcc-internal-format msgid " does not clean up handled exception" -msgstr "%s tar inte några funktionsflaggor" +msgstr " städar inte upp det hanterade undantaget" #: cp/decl.cc:3922 #, gcc-internal-format @@ -55631,10 +55627,9 @@ msgid "constraints on a non-templated function" msgstr "begränsning av en funktion som inte är en mall" #: cp/decl.cc:10590 -#, fuzzy, gcc-internal-format -#| msgid "friend declaration not in class definition" +#, gcc-internal-format msgid "constrained non-template friend declaration must be a definition" -msgstr "vändeklaration är inte i klassdefinition" +msgstr "begränsad vändeklaration som inte är en mall måste vara en definition" #: cp/decl.cc:10597 #, gcc-internal-format @@ -55697,10 +55692,9 @@ msgid "static member function %qD cannot have cv-qualifier" msgstr "statisk medlemsfunktion %qD kan inte ha cv-kvalificerare" #: cp/decl.cc:10818 -#, fuzzy, gcc-internal-format -#| msgid "static member function %qD cannot have cv-qualifier" +#, gcc-internal-format msgid "explicit object member function %qD cannot have cv-qualifier" -msgstr "statisk medlemsfunktion %qD kan inte ha cv-kvalificerare" +msgstr "explicit objektmedlemsfunktion %qD kan inte ha cv-kvalificerare" #: cp/decl.cc:10823 #, gcc-internal-format @@ -55713,16 +55707,14 @@ msgid "static member function %qD cannot have ref-qualifier" msgstr "statisk medlemsfunktion %qD kan inte ha ref-kvalificerare" #: cp/decl.cc:10826 -#, fuzzy, gcc-internal-format -#| msgid "static member function %qD cannot have ref-qualifier" +#, gcc-internal-format msgid "explicit object member function %qD cannot have ref-qualifier" -msgstr "statisk medlemsfunktion %qD kan inte ha ref-kvalificerare" +msgstr "explicit objektmedlemsfunktion %qD kan inte ha ref-kvalificerare" #: cp/decl.cc:10832 cp/decl.cc:13715 cp/decl.cc:13725 cp/parser.cc:11972 -#, fuzzy, gcc-internal-format -#| msgid "template parameter %qD declared here" +#, gcc-internal-format msgid "explicit object parameter declared here" -msgstr "mallparametern %qD deklarerad här" +msgstr "explicit objektparameter deklarerad här" #: cp/decl.cc:10844 #, gcc-internal-format @@ -56304,31 +56296,27 @@ msgstr "onödiga parenteser i deklaration av %qs" #: cp/decl.cc:13277 #, gcc-internal-format msgid "remove parentheses" -msgstr "ta port parenteser" +msgstr "ta bort parenteser" #: cp/decl.cc:13345 -#, fuzzy, gcc-internal-format -#| msgid "alias template deduction only available with %<-std=c++20%> or %<-std=gnu++20%>" +#, gcc-internal-format msgid "explicit object member function only available with %<-std=c++23%> or %<-std=gnu++23%>" -msgstr "aliasmallhärledning är endast tillgängligt med %<-std=c++20%> eller %<-std=gnu++20%>" +msgstr "explicita objektmedlemsfunktioner är endast tillgängliga med %<-std=c++23%> eller %<-std=gnu++23%>" #: cp/decl.cc:13359 -#, fuzzy, gcc-internal-format -#| msgid "Function %qs at %L cannot have an initializer" +#, gcc-internal-format msgid "a function
[gcc r14-9777] Regenerate i386.opt.urls
https://gcc.gnu.org/g:5c749db15fab032df757b72e8114b89572783a20 commit r14-9777-g5c749db15fab032df757b72e8114b89572783a20 Author: Mark Wielaard Date: Wed Apr 3 17:35:25 2024 +0200 Regenerate i386.opt.urls LoongArch added an -mtls-dialect option, causing the similarly named option for i386 get renumbered. Fixes: b253b4695dda ("LoongArch: Add support for TLS descriptors.") gcc/ChangeLog: * config/i386/i386.opt.urls: Regenerate. Diff: --- gcc/config/i386/i386.opt.urls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/config/i386/i386.opt.urls b/gcc/config/i386/i386.opt.urls index fa821eba200..81c5bb9a927 100644 --- a/gcc/config/i386/i386.opt.urls +++ b/gcc/config/i386/i386.opt.urls @@ -128,7 +128,7 @@ mstackrealign UrlSuffix(gcc/x86-Options.html#index-mstackrealign) mtls-dialect= -UrlSuffix(gcc/x86-Options.html#index-mtls-dialect-1) +UrlSuffix(gcc/x86-Options.html#index-mtls-dialect-2) mtls-direct-seg-refs UrlSuffix(gcc/x86-Options.html#index-mtls-direct-seg-refs)
[gcc r14-9776] libgcc: Add missing HWCAP entries to aarch64/cpuinfo.c
https://gcc.gnu.org/g:8f9e92eec3230d2f1305d414984e89aaebdfe0c6 commit r14-9776-g8f9e92eec3230d2f1305d414984e89aaebdfe0c6 Author: Wilco Dijkstra Date: Wed Mar 27 16:06:13 2024 + libgcc: Add missing HWCAP entries to aarch64/cpuinfo.c A few HWCAP entries are missing from aarch64/cpuinfo.c. This results in build errors on older machines. libgcc/ * config/aarch64/cpuinfo.c: Add HWCAP_EVTSTRM, HWCAP_CRC32, HWCAP_CPUID, HWCAP_PACA and HWCAP_PACG. Diff: --- libgcc/config/aarch64/cpuinfo.c | 18 +++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/libgcc/config/aarch64/cpuinfo.c b/libgcc/config/aarch64/cpuinfo.c index 3c6fb8a575b..4b94fca8695 100644 --- a/libgcc/config/aarch64/cpuinfo.c +++ b/libgcc/config/aarch64/cpuinfo.c @@ -52,15 +52,15 @@ struct { #ifndef AT_HWCAP #define AT_HWCAP 16 #endif -#ifndef HWCAP_CPUID -#define HWCAP_CPUID (1 << 11) -#endif #ifndef HWCAP_FP #define HWCAP_FP (1 << 0) #endif #ifndef HWCAP_ASIMD #define HWCAP_ASIMD (1 << 1) #endif +#ifndef HWCAP_EVTSTRM +#define HWCAP_EVTSTRM (1 << 2) +#endif #ifndef HWCAP_AES #define HWCAP_AES (1 << 3) #endif @@ -73,6 +73,9 @@ struct { #ifndef HWCAP_SHA2 #define HWCAP_SHA2 (1 << 6) #endif +#ifndef HWCAP_CRC32 +#define HWCAP_CRC32 (1 << 7) +#endif #ifndef HWCAP_ATOMICS #define HWCAP_ATOMICS (1 << 8) #endif @@ -82,6 +85,9 @@ struct { #ifndef HWCAP_ASIMDHP #define HWCAP_ASIMDHP (1 << 10) #endif +#ifndef HWCAP_CPUID +#define HWCAP_CPUID (1 << 11) +#endif #ifndef HWCAP_ASIMDRDM #define HWCAP_ASIMDRDM (1 << 12) #endif @@ -133,6 +139,12 @@ struct { #ifndef HWCAP_SB #define HWCAP_SB (1 << 29) #endif +#ifndef HWCAP_PACA +#define HWCAP_PACA (1 << 30) +#endif +#ifndef HWCAP_PACG +#define HWCAP_PACG (1UL << 31) +#endif #ifndef HWCAP2_DCPODP #define HWCAP2_DCPODP (1 << 0)
[gcc r13-8577] libstdc++, Darwin: Handle a linker warning [PR112397].
https://gcc.gnu.org/g:ae11f0154116f4e5fa8769b1ea1600b1b1c22958 commit r13-8577-gae11f0154116f4e5fa8769b1ea1600b1b1c22958 Author: Iain Sandoe Date: Thu Feb 8 17:54:31 2024 + libstdc++, Darwin: Handle a linker warning [PR112397]. Darwin's linker warns when we make a direct branch to code that is in a weak definition (citing that if a different implementation of the weak function is chosen by the dynamic linker this would be an error). As the analysis in the PR shows, this can happen when we have hot/ cold partitioning and there is an error path that is primarily cold but makes use of epilogue code in the hot section. In this simple case, we can easily deduce that the code is in fact safe; however that is not something we can realistically implement in the linker. Since the user-replaceable allocators are implemented using weak definitions, this is a warning that is frequently flagged up in both the testsuite and end-user code. The chosen solution here is to suppress the hot/cold partitioning for these cases (it is unlikely to impact performance much c.f. the actual allocation). PR target/112397 libstdc++-v3/ChangeLog: * configure: Regenerate. * configure.ac: Detect if we are building for Darwin. * libsupc++/Makefile.am: If we are building for Darwin, then suppress hot/cold partitioning for the array allocators. * libsupc++/Makefile.in: Regenerated. Signed-off-by: Iain Sandoe Co-authored-by: Jonathan Wakely (cherry picked from commit 1609fdff16f17ead37666f6d0e801800ee3d04d2) Diff: --- libstdc++-v3/configure | 36 libstdc++-v3/configure.ac | 7 +++ libstdc++-v3/libsupc++/Makefile.am | 8 libstdc++-v3/libsupc++/Makefile.in | 6 ++ 4 files changed, 49 insertions(+), 8 deletions(-) diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index 53882c3f6b6..d35baaf7c6e 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -789,6 +789,8 @@ GLIBCXX_HOSTED_TRUE glibcxx_compiler_shared_flag glibcxx_compiler_pic_flag glibcxx_lt_pic_flag +OS_IS_DARWIN_FALSE +OS_IS_DARWIN_TRUE enable_static enable_shared lt_host_flags @@ -12187,7 +12189,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12190 "configure" +#line 12192 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12293,7 +12295,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12296 "configure" +#line 12298 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -15595,6 +15597,20 @@ esac +os_is_darwin=no +case ${host_os} in + darwin*) os_is_darwin=yes ;; + *) ;; +esac + if test x${os_is_darwin} = xyes; then + OS_IS_DARWIN_TRUE= + OS_IS_DARWIN_FALSE='#' +else + OS_IS_DARWIN_TRUE='#' + OS_IS_DARWIN_FALSE= +fi + + if test "$enable_vtable_verify" = yes; then predep_objects_CXX="${predep_objects_CXX} ${glibcxx_builddir}/../libgcc/vtv_start.o" postdep_objects_CXX="${postdep_objects_CXX} ${glibcxx_builddir}/../libgcc/vtv_end.o" @@ -16017,7 +16033,7 @@ $as_echo "$glibcxx_cv_atomic_long_long" >&6; } # Fake what AC_TRY_COMPILE does. cat > conftest.$ac_ext << EOF -#line 16020 "configure" +#line 16036 "configure" int main() { typedef bool atomic_type; @@ -16052,7 +16068,7 @@ $as_echo "$glibcxx_cv_atomic_bool" >&6; } rm -f conftest* cat > conftest.$ac_ext << EOF -#line 16055 "configure" +#line 16071 "configure" int main() { typedef short atomic_type; @@ -16087,7 +16103,7 @@ $as_echo "$glibcxx_cv_atomic_short" >&6; } rm -f conftest* cat > conftest.$ac_ext << EOF -#line 16090 "configure" +#line 16106 "configure" int main() { // NB: _Atomic_word not necessarily int. @@ -16123,7 +16139,7 @@ $as_echo "$glibcxx_cv_atomic_int" >&6; } rm -f conftest* cat > conftest.$ac_ext << EOF -#line 16126 "configure" +#line 16142 "configure" int main() { typedef long long atomic_type; @@ -16279,7 +16295,7 @@ $as_echo "mutex" >&6; } # unnecessary for this test. cat > conftest.$ac_ext << EOF -#line 16282 "configure" +#line 16298 "configure" int main() { _Decimal32 d1; @@ -16321,7 +16337,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu # unnecessary for this test. cat > conftest.$ac_ext << EOF -#line 16324 "configure" +#line 16340 "configure" template struct same { typedef T2 type; }; @@ -73293,6 +73309,10 @@ if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${OS_IS_DARWIN_TRUE}" && test -z "${OS_IS_DARWIN_FALSE}"; then
[gcc r13-8575] libstdc++, Darwin: Do not use dev/null as the file for executables.
https://gcc.gnu.org/g:6bcc8fd92c69a66d4a8531665225a75d81a9d146 commit r13-8575-g6bcc8fd92c69a66d4a8531665225a75d81a9d146 Author: Iain Sandoe Date: Tue Mar 19 10:40:50 2024 + libstdc++, Darwin: Do not use dev/null as the file for executables. Darwin has a separate debug linker, which is invoked when the command line contains source files and debug is enabled. Using /dev/null as the executable name does not, therefore, work when debug is enabled, since the debug linker does not accept /dev/null as a valid executable name. The leads to incorrectly UNSUPPORTED testcases because of the unintended error result from the test compilation. The solution here is to use a temporary file that is deleted at the end of the test (which is the mechanism used elsewhere) libstdc++-v3/ChangeLog: * testsuite/lib/libstdc++.exp (v3_target_compile): Instead of /dev/null, use a temporary file for test executables on Darwin. Signed-off-by: Iain Sandoe (cherry picked from commit e47330d0742c985fd8d5fe7089aa381d34967d61) Diff: --- libstdc++-v3/testsuite/lib/libstdc++.exp | 20 +++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp index 6c57cfab725..d85ff7521c2 100644 --- a/libstdc++-v3/testsuite/lib/libstdc++.exp +++ b/libstdc++-v3/testsuite/lib/libstdc++.exp @@ -507,11 +507,15 @@ proc v3_target_compile { source dest type options } { } } +# For Windows and Darwin we might want to create a temporary file. +# Note that it needs deleting. +set file_to_delete "" # Small adjustment for Windows hosts. if { $dest == "/dev/null" && [info exists ::env(OS)] && [string match "Windows*" $::env(OS)] } { if { $type == "executable" } { set dest "x.exe" + set file_to_delete ${dest} } else { # Windows uses special file named "nul" as a substitute for # /dev/null @@ -519,11 +523,25 @@ proc v3_target_compile { source dest type options } { } } +# Using /dev/null as the executable name does not work on Darwin when +# debug is enabled, since the debug linker does not accept /dev/null as +# a valid executable name. +if { $dest == "/dev/null" && [istarget *-*-darwin*] + && $type == "executable" } { + set dest dev-null-[pid].exe + set file_to_delete ${dest} +} + lappend options "compiler=$cxx_final" lappend options "timeout=[timeout_value]" set comp_output [target_compile $source $dest $type $options] - +if { $type == "executable" && $file_to_delete != "" } { + file delete $file_to_delete + if { [istarget *-*-darwin*] && [file exists $file_to_delete.dSYM] } { + file delete -force $file_to_delete.dSYM + } +} return $comp_output }
[gcc r13-8576] libstdc++: Sync the atomic_link_flags implementation with GCC.
https://gcc.gnu.org/g:5975807ae77896e6e67656f38304149a643816b9 commit r13-8576-g5975807ae77896e6e67656f38304149a643816b9 Author: Iain Sandoe Date: Mon Mar 18 09:57:33 2024 + libstdc++: Sync the atomic_link_flags implementation with GCC. For Darwin, in order to allow uninstalled testing, we need to provide a '-B' option pointing to each path containing an uninstalled library that we are using (these get appended to the embedded runpaths). This updates the version of the atomic_link_flags proc in the libstdc++ testsuite to do the same as the one in the GCC testsuite. libstdc++-v3/ChangeLog: * testsuite/lib/dg-options.exp (atomic_link_flags): Emit a -B option for the path to the uninstalled libatomic. Signed-off-by: Iain Sandoe (cherry picked from commit 71a44faa8a4f76d68356c66c6054e6c242df820f) Diff: --- libstdc++-v3/testsuite/lib/dg-options.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp b/libstdc++-v3/testsuite/lib/dg-options.exp index f7d5b05d6ed..427a251e789 100644 --- a/libstdc++-v3/testsuite/lib/dg-options.exp +++ b/libstdc++-v3/testsuite/lib/dg-options.exp @@ -314,7 +314,7 @@ proc atomic_link_flags { paths } { if { [file exists "${gccpath}/libatomic/.libs/libatomic.a"] || [file exists "${gccpath}/libatomic/.libs/libatomic.${shlib_ext}"] } { append flags " -B${gccpath}/libatomic/ " - append flags " -L${gccpath}/libatomic/.libs" + append flags " -B${gccpath}/libatomic/.libs" append ld_library_path ":${gccpath}/libatomic/.libs" } } else {
[gcc r13-8574] Testsuite, i386: Mark test as requiring ifunc
https://gcc.gnu.org/g:baec3b8ea17b82d2e4895fda50d94f74cf63100c commit r13-8574-gbaec3b8ea17b82d2e4895fda50d94f74cf63100c Author: Francois-Xavier Coudert Date: Mon Oct 30 15:41:10 2023 +0100 Testsuite, i386: Mark test as requiring ifunc Test is currently failing on x86_64-apple-darwin. gcc/testsuite/ChangeLog: * gcc.target/i386/pr105554.c: Require ifunc. (cherry picked from commit 7666d94db0684f04264712f3e3fdb542518960c5) Diff: --- gcc/testsuite/gcc.target/i386/pr105554.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/testsuite/gcc.target/i386/pr105554.c b/gcc/testsuite/gcc.target/i386/pr105554.c index 08e90bb3368..e9ef494270a 100644 --- a/gcc/testsuite/gcc.target/i386/pr105554.c +++ b/gcc/testsuite/gcc.target/i386/pr105554.c @@ -1,5 +1,6 @@ /* PR target/105554 */ /* { dg-do compile } */ +/* { dg-require-ifunc "" } */ /* { dg-options "-O2 -Wno-psabi -mno-sse3" } */ typedef long long v4di __attribute__((__vector_size__(32)));
[gcc r13-8573] Testsuite: restrict test to nonpic targets
https://gcc.gnu.org/g:44514fde12e2a8f75fca88fdd6ff7a0e678ac966 commit r13-8573-g44514fde12e2a8f75fca88fdd6ff7a0e678ac966 Author: Francois-Xavier Coudert Date: Mon Dec 11 09:26:23 2023 +0100 Testsuite: restrict test to nonpic targets The test is currently failing on x86_64-apple-darwin. gcc/testsuite/ChangeLog: PR testsuite/112297 * gcc.target/i386/pr100936.c: Require nonpic target. (cherry picked from commit 02f562484c17522d79a482ac702a5fa3c2dfdd10) Diff: --- gcc/testsuite/gcc.target/i386/pr100936.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/testsuite/gcc.target/i386/pr100936.c b/gcc/testsuite/gcc.target/i386/pr100936.c index c076cbb2405..af494946fcd 100644 --- a/gcc/testsuite/gcc.target/i386/pr100936.c +++ b/gcc/testsuite/gcc.target/i386/pr100936.c @@ -1,6 +1,7 @@ /* PR target/100936 */ /* { dg-do assemble } */ /* { dg-options "-O2" } */ +/* { dg-require-effective-target nonpic } */ __seg_gs int var;
[gcc r13-8572] libcc1: fix include
https://gcc.gnu.org/g:e95ab9e60ce1d9aa7751d79291133fd5af9209d7 commit r13-8572-ge95ab9e60ce1d9aa7751d79291133fd5af9209d7 Author: Francois-Xavier Coudert Date: Sat Mar 16 09:50:00 2024 +0100 libcc1: fix include Use INCLUDE_VECTOR before including system.h, instead of directly including , to avoid running into poisoned identifiers. Signed-off-by: Dimitry Andric PR middle-end/111632 libcc1/ChangeLog: * libcc1plugin.cc: Fix include. * libcp1plugin.cc: Fix include. (cherry picked from commit 5213047b1d50af63dfabb5e5649821a6cb157e33) Diff: --- libcc1/libcc1plugin.cc | 3 +-- libcc1/libcp1plugin.cc | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/libcc1/libcc1plugin.cc b/libcc1/libcc1plugin.cc index 7e0fecae145..44bcf56698e 100644 --- a/libcc1/libcc1plugin.cc +++ b/libcc1/libcc1plugin.cc @@ -32,6 +32,7 @@ #undef PACKAGE_VERSION #define INCLUDE_MEMORY +#define INCLUDE_VECTOR #include "gcc-plugin.h" #include "system.h" #include "coretypes.h" @@ -69,8 +70,6 @@ #include "gcc-c-interface.h" #include "context.hh" -#include - using namespace cc1_plugin; diff --git a/libcc1/libcp1plugin.cc b/libcc1/libcp1plugin.cc index 8d394c0cfdb..9586a2afdb4 100644 --- a/libcc1/libcp1plugin.cc +++ b/libcc1/libcp1plugin.cc @@ -33,6 +33,7 @@ #undef PACKAGE_VERSION #define INCLUDE_MEMORY +#define INCLUDE_VECTOR #include "gcc-plugin.h" #include "system.h" #include "coretypes.h" @@ -71,8 +72,6 @@ #include "rpc.hh" #include "context.hh" -#include - using namespace cc1_plugin;
[gcc r13-8571] Include safe-ctype.h after C++ standard headers, to avoid over-poisoning
https://gcc.gnu.org/g:68057560ff1fc0fb2df38c2f9627a20c9a8da5c5 commit r13-8571-g68057560ff1fc0fb2df38c2f9627a20c9a8da5c5 Author: Francois-Xavier Coudert Date: Thu Mar 7 14:36:03 2024 +0100 Include safe-ctype.h after C++ standard headers, to avoid over-poisoning When building gcc's C++ sources against recent libc++, the poisoning of the ctype macros due to including safe-ctype.h before including C++ standard headers such as , , etc, causes many compilation errors, similar to: In file included from /home/dim/src/gcc/master/gcc/gensupport.cc:23: In file included from /home/dim/src/gcc/master/gcc/system.h:233: In file included from /usr/include/c++/v1/vector:321: In file included from /usr/include/c++/v1/__format/formatter_bool.h:20: In file included from /usr/include/c++/v1/__format/formatter_integral.h:32: In file included from /usr/include/c++/v1/locale:202: /usr/include/c++/v1/__locale:546:5: error: '__abi_tag__' attribute only applies to structs, variables, functions, and namespaces 546 | _LIBCPP_INLINE_VISIBILITY | ^ /usr/include/c++/v1/__config:813:37: note: expanded from macro '_LIBCPP_INLINE_VISIBILITY' 813 | # define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI | ^ /usr/include/c++/v1/__config:792:26: note: expanded from macro '_LIBCPP_HIDE_FROM_ABI' 792 | __attribute__((__abi_tag__(_LIBCPP_TOSTRING( _LIBCPP_VERSIONED_IDENTIFIER | ^ In file included from /home/dim/src/gcc/master/gcc/gensupport.cc:23: In file included from /home/dim/src/gcc/master/gcc/system.h:233: In file included from /usr/include/c++/v1/vector:321: In file included from /usr/include/c++/v1/__format/formatter_bool.h:20: In file included from /usr/include/c++/v1/__format/formatter_integral.h:32: In file included from /usr/include/c++/v1/locale:202: /usr/include/c++/v1/__locale:547:37: error: expected ';' at end of declaration list 547 | char_type toupper(char_type __c) const | ^ /usr/include/c++/v1/__locale:553:48: error: too many arguments provided to function-like macro invocation 553 | const char_type* toupper(char_type* __low, const char_type* __high) const |^ /home/dim/src/gcc/master/gcc/../include/safe-ctype.h:146:9: note: macro 'toupper' defined here 146 | #define toupper(c) do_not_use_toupper_with_safe_ctype | ^ This is because libc++ uses different transitive includes than libstdc++, and some of those transitive includes pull in various ctype declarations (typically via ). There was already a special case for including before safe-ctype.h, so move the rest of the C++ standard header includes to the same location, to fix the problem. PR middle-end/111632 gcc/ChangeLog: * system.h: Include safe-ctype.h after C++ standard headers. Signed-off-by: Dimitry Andric (cherry picked from commit 9970b576b7e4ae337af1268395ff221348c4b34a) Diff: --- gcc/system.h | 39 ++- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/gcc/system.h b/gcc/system.h index 33e9d421115..03ab33ac960 100644 --- a/gcc/system.h +++ b/gcc/system.h @@ -194,27 +194,8 @@ extern int fprintf_unlocked (FILE *, const char *, ...); #undef fread_unlocked #undef fwrite_unlocked -/* Include before "safe-ctype.h" to avoid GCC poisoning - the ctype macros through safe-ctype.h */ - -#ifdef __cplusplus -#ifdef INCLUDE_STRING -# include -#endif -#endif - -/* There are an extraordinary number of issues with . - The last straw is that it varies with the locale. Use libiberty's - replacement instead. */ -#include "safe-ctype.h" - -#include - -#include - -#if !defined (errno) && defined (HAVE_DECL_ERRNO) && !HAVE_DECL_ERRNO -extern int errno; -#endif +/* Include C++ standard headers before "safe-ctype.h" to avoid GCC + poisoning the ctype macros through safe-ctype.h */ #ifdef __cplusplus #if defined (INCLUDE_ALGORITHM) || !defined (HAVE_SWAP_IN_UTILITY) @@ -229,6 +210,9 @@ extern int errno; #ifdef INCLUDE_SET # include #endif +#ifdef INCLUDE_STRING +# include +#endif #ifdef INCLUDE_VECTOR # include #endif @@ -245,6 +229,19 @@ extern int errno; # include #endif +/* There are an extraordinary number of issues with . + The last straw is that it varies with the locale. Use libiberty's + replacement instead. */ +#include "safe-ctype.h" + +#include + +#include + +#if !defined (errno) && defined (HAVE_DECL_ERRNO) && !HAVE_DECL_ERRNO +extern int errno; +#endif + /* Some of glibc's string inline
[gcc r14-9775] tree-profile: Disable indirect call profiling for IFUNC resolvers
https://gcc.gnu.org/g:cab32bacaea268ec062b1fb4fc662d90c9d1cfce commit r14-9775-gcab32bacaea268ec062b1fb4fc662d90c9d1cfce Author: H.J. Lu Date: Mon Feb 26 08:38:58 2024 -0800 tree-profile: Disable indirect call profiling for IFUNC resolvers We can't profile indirect calls to IFUNC resolvers nor their callees as it requires TLS which hasn't been set up yet when the dynamic linker is resolving IFUNC symbols. Add an IFUNC resolver caller marker to cgraph_node and set it if the function is called by an IFUNC resolver. Disable indirect call profiling for IFUNC resolvers and their callees. Tested with profiledbootstrap on Fedora 39/x86-64. gcc/ChangeLog: PR tree-optimization/114115 * cgraph.h (symtab_node): Add check_ifunc_callee_symtab_nodes. (cgraph_node): Add called_by_ifunc_resolver. * cgraphunit.cc (symbol_table::compile): Call symtab_node::check_ifunc_callee_symtab_nodes. * symtab.cc (check_ifunc_resolver): New. (ifunc_ref_map): Likewise. (is_caller_ifunc_resolver): Likewise. (symtab_node::check_ifunc_callee_symtab_nodes): Likewise. * tree-profile.cc (gimple_gen_ic_func_profiler): Disable indirect call profiling for IFUNC resolvers and their callees. gcc/testsuite/ChangeLog: PR tree-optimization/114115 * gcc.dg/pr114115.c: New test. Diff: --- gcc/cgraph.h| 6 +++ gcc/cgraphunit.cc | 2 + gcc/symtab.cc | 89 + gcc/testsuite/gcc.dg/pr114115.c | 24 +++ gcc/tree-profile.cc | 8 +++- 5 files changed, 128 insertions(+), 1 deletion(-) diff --git a/gcc/cgraph.h b/gcc/cgraph.h index 47f35e8078d..a8c3224802c 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -479,6 +479,9 @@ public: Return NULL if there's no such node. */ static symtab_node *get_for_asmname (const_tree asmname); + /* Check symbol table for callees of IFUNC resolvers. */ + static void check_ifunc_callee_symtab_nodes (void); + /* Verify symbol table for internal consistency. */ static DEBUG_FUNCTION void verify_symtab_nodes (void); @@ -896,6 +899,7 @@ struct GTY((tag ("SYMTAB_FUNCTION"))) cgraph_node : public symtab_node redefined_extern_inline (false), tm_may_enter_irr (false), ipcp_clone (false), declare_variant_alt (false), calls_declare_variant_alt (false), gc_candidate (false), + called_by_ifunc_resolver (false), m_uid (uid), m_summary_id (-1) {} @@ -1495,6 +1499,8 @@ struct GTY((tag ("SYMTAB_FUNCTION"))) cgraph_node : public symtab_node is set for local SIMD clones when they are created and cleared if the vectorizer uses them. */ unsigned gc_candidate : 1; + /* Set if the function is called by an IFUNC resolver. */ + unsigned called_by_ifunc_resolver : 1; private: /* Unique id of the node. */ diff --git a/gcc/cgraphunit.cc b/gcc/cgraphunit.cc index d200166f7e9..2bd0289ffba 100644 --- a/gcc/cgraphunit.cc +++ b/gcc/cgraphunit.cc @@ -2317,6 +2317,8 @@ symbol_table::compile (void) symtab_node::checking_verify_symtab_nodes (); + symtab_node::check_ifunc_callee_symtab_nodes (); + timevar_push (TV_CGRAPHOPT); if (pre_ipa_mem_report) dump_memory_report ("Memory consumption before IPA"); diff --git a/gcc/symtab.cc b/gcc/symtab.cc index 4c7e3c135ca..3256133891d 100644 --- a/gcc/symtab.cc +++ b/gcc/symtab.cc @@ -1369,6 +1369,95 @@ symtab_node::verify (void) timevar_pop (TV_CGRAPH_VERIFY); } +/* Return true and set *DATA to true if NODE is an ifunc resolver. */ + +static bool +check_ifunc_resolver (cgraph_node *node, void *data) +{ + if (node->ifunc_resolver) +{ + bool *is_ifunc_resolver = (bool *) data; + *is_ifunc_resolver = true; + return true; +} + return false; +} + +static auto_bitmap ifunc_ref_map; + +/* Return true if any caller of NODE is an ifunc resolver. */ + +static bool +is_caller_ifunc_resolver (cgraph_node *node) +{ + bool is_ifunc_resolver = false; + + for (cgraph_edge *e = node->callers; e; e = e->next_caller) +{ + /* Return true if caller is known to be an IFUNC resolver. */ + if (e->caller->called_by_ifunc_resolver) + return true; + + /* Check for recursive call. */ + if (e->caller == node) + continue; + + /* Skip if it has been visited. */ + unsigned int uid = e->caller->get_uid (); + if (bitmap_bit_p (ifunc_ref_map, uid)) + continue; + bitmap_set_bit (ifunc_ref_map, uid); + + if (is_caller_ifunc_resolver (e->caller)) + { + /* Return true if caller is an IFUNC resolver. */ + e->caller->called_by_ifunc_resolver = true; + return true; + } + + /* Check if caller's alias is an IFUNC resolver. */ + e->caller->call_for_symbol_and_aliases (c
[gcc r14-9774] lto-wrapper.cc: Add offload target name to 'offload_args' suffix
https://gcc.gnu.org/g:6f91cce9a314cd4bce16fe52a2ffbeb93d59320b commit r14-9774-g6f91cce9a314cd4bce16fe52a2ffbeb93d59320b Author: Tobias Burnus Date: Wed Apr 3 15:47:12 2024 +0200 lto-wrapper.cc: Add offload target name to 'offload_args' suffix lto-wrapper.cc's compile_offload_image calls mkoffload with an @./a.offload_args argument ('a.' in case of, e.g., 'a.out'). However, when generating code for both nvptx and gcn, they use the same name with -save-temps. Hence, this commit adds a + '.' before 'offload_args' in line with other offload-target-specific files. gcc/ChangeLog: * lto-wrapper.cc (compile_offload_image): Prefix 'offload_args' suffix by the target name. Diff: --- gcc/lto-wrapper.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/lto-wrapper.cc b/gcc/lto-wrapper.cc index ca53e4b462e..610594cdc2b 100644 --- a/gcc/lto-wrapper.cc +++ b/gcc/lto-wrapper.cc @@ -993,7 +993,8 @@ compile_offload_image (const char *target, const char *compiler_path, obstack_ptr_grow (&argv_obstack, NULL); argv = XOBFINISH (&argv_obstack, char **); - fork_execute (argv[0], argv, true, "offload_args"); + suffix = concat (target, ".offload_args", NULL); + fork_execute (argv[0], argv, true, suffix); obstack_free (&argv_obstack, NULL); free_array_of_ptrs ((void **) paths, n_paths);
[gcc r14-9773] libphobos, Darwin: Enable libphobos for most Darwin.
https://gcc.gnu.org/g:d60968de6961cef144a5cf8701ea0d3f4ea90f18 commit r14-9773-gd60968de6961cef144a5cf8701ea0d3f4ea90f18 Author: Iain Sandoe Date: Mon Apr 1 13:58:20 2024 +0100 libphobos, Darwin: Enable libphobos for most Darwin. Earlier Darwin systems can be made to work too - but they need non- standard 'binutils', so for now these must be enabled specifically. libphobos/ChangeLog: * configure.tgt: Enable libphobos for Darwin >= 12. Signed-off-by: Iain Sandoe Diff: --- libphobos/configure.tgt | 9 + 1 file changed, 9 insertions(+) diff --git a/libphobos/configure.tgt b/libphobos/configure.tgt index 13879380416..7159688 100644 --- a/libphobos/configure.tgt +++ b/libphobos/configure.tgt @@ -27,6 +27,9 @@ case "${target}" in *-*-dragonfly*) LIBPHOBOS_SUPPORTED=yes ;; + aarch64-*-darwin2*) + LIBPHOBOS_SUPPORTED=yes + ;; aarch64*-*-linux*) LIBPHOBOS_SUPPORTED=yes ;; @@ -58,6 +61,12 @@ case "${target}" in sparc*-*-solaris2.11*) LIBPHOBOS_SUPPORTED=yes ;; + *-*-darwin9* | *-*-darwin1[01]*) + LIBDRUNTIME_ONLY=yes + ;; + x86_64-*-darwin1[2-9]* | x86_64-*-darwin2* | i?86-*-darwin1[2-7]) + LIBPHOBOS_SUPPORTED=yes + ;; x86_64-*-freebsd* | i?86-*-freebsd*) LIBPHOBOS_SUPPORTED=yes ;;
[gcc r14-9772] GCN: install.texi update for Newlib change and LLVM 18 release
https://gcc.gnu.org/g:ce7cb109ff429bcdca03fccfc444b610c6cb528b commit r14-9772-gce7cb109ff429bcdca03fccfc444b610c6cb528b Author: Tobias Burnus Date: Wed Apr 3 14:16:41 2024 +0200 GCN: install.texi update for Newlib change and LLVM 18 release gcc/ChangeLog: * doc/install.texi (amdgcn-*-amdhsa): Update Newlib recommendation and update wording for LLVM 18 release. Diff: --- gcc/doc/install.texi | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi index 269fe7ec870..970b1a67e74 100644 --- a/gcc/doc/install.texi +++ b/gcc/doc/install.texi @@ -3944,7 +3944,9 @@ Instead of GNU Binutils, you will need to install LLVM 15, or later, and copy by specifying a @code{--with-multilib-list=} that does not list @code{gfx1100} and @code{gfx1103}. -Use Newlib (4.3.0 or newer; 4.4.0 or later is recommended). +Use Newlib (4.3.0 or newer; 4.4.0 contains some improvements and git commit +7dd4eb1db (2025-03-25, post-4.4.0) fixes device console output for GFX10 and +GFX11 devices). To run the binaries, install the HSA Runtime from the @uref{https://rocm.docs.amd.com/,,ROCm Platform}, and use @@ -3954,8 +3956,8 @@ on the GPU. To enable support for GCN3 Fiji devices (gfx803), GCC has to be configured with @option{--with-arch=@code{fiji}} or @option{--with-multilib-list=@code{fiji},...}. Note that support for Fiji -devices has been removed in ROCm 4.0 and support in LLVM is deprecated and will -be removed in LLVM 18. +devices has been removed in ROCm 4.0 and support in LLVM was deprecated and has +been removed in LLVM 18. @html
[gcc r14-9771] libstdc++: Reverse arguments in constraint for std::optional's <=> [PR104606]
https://gcc.gnu.org/g:7f65d8267fbfd19cf21a3dc71d27e989e75044a3 commit r14-9771-g7f65d8267fbfd19cf21a3dc71d27e989e75044a3 Author: Jonathan Wakely Date: Wed Mar 27 21:51:13 2024 + libstdc++: Reverse arguments in constraint for std::optional's <=> [PR104606] This is a workaround for a possible compiler bug that causes constraint recursion in the operator<=>(const optional&, const U&) overload. libstdc++-v3/ChangeLog: PR libstdc++/104606 * include/std/optional (operator<=>(const optional&, const U&)): Reverse order of three_way_comparable_with template arguments. * testsuite/20_util/optional/relops/104606.cc: New test. Diff: --- libstdc++-v3/include/std/optional | 2 +- .../testsuite/20_util/optional/relops/104606.cc| 18 ++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/include/std/optional b/libstdc++-v3/include/std/optional index 1e88e8b8880..3507c36a4d8 100644 --- a/libstdc++-v3/include/std/optional +++ b/libstdc++-v3/include/std/optional @@ -1430,7 +1430,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #ifdef __cpp_lib_three_way_comparison template requires (!__is_optional_v<_Up>) - && three_way_comparable_with<_Tp, _Up> + && three_way_comparable_with<_Up, _Tp> constexpr compare_three_way_result_t<_Tp, _Up> operator<=>(const optional<_Tp>& __x, const _Up& __v) { return bool(__x) ? *__x <=> __v : strong_ordering::less; } diff --git a/libstdc++-v3/testsuite/20_util/optional/relops/104606.cc b/libstdc++-v3/testsuite/20_util/optional/relops/104606.cc new file mode 100644 index 000..2b8df245219 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/optional/relops/104606.cc @@ -0,0 +1,18 @@ +// { dg-do compile { target c++17 } } + +// Bug 104606 comparison operator resolution with std::optional and -std=c++20 + +#include +#include +#include + +struct Value : std::variant> { }; + +struct Comparator { + template bool operator<=(const T &) { return true; } +}; + +std::optional o; +Comparator c; + +auto x = c <= o;
[gcc r13-8570] libstdc++: Destroy allocators in re-inserted container nodes [PR114401]
https://gcc.gnu.org/g:47ebdbe5bf71d9eb260359b6aceb5cb071d97acd commit r13-8570-g47ebdbe5bf71d9eb260359b6aceb5cb071d97acd Author: Jonathan Wakely Date: Thu Mar 21 13:25:15 2024 + libstdc++: Destroy allocators in re-inserted container nodes [PR114401] The allocator objects in container node handles were not being destroyed after the node was re-inserted into a container. They are stored in a union and so need to be explicitly destroyed when the node becomes empty. The containers were zeroing the node handle's pointer, which makes it empty, causing the handle's destructor to think there's nothing to clean up. Add a new member function to the node handle which destroys the allocator and zeros the pointer. Change the containers to call that instead of just changing the pointer manually. We can also remove the _M_empty member of the union which is not necessary. libstdc++-v3/ChangeLog: PR libstdc++/114401 * include/bits/hashtable.h (_Hashtable::_M_reinsert_node): Call release() on node handle instead of just zeroing its pointer. (_Hashtable::_M_reinsert_node_multi): Likewise. (_Hashtable::_M_merge_unique): Likewise. (_Hashtable::_M_merge_multi): Likewise. * include/bits/node_handle.h (_Node_handle_common::release()): New member function. (_Node_handle_common::_Optional_alloc::_M_empty): Remove unnecessary union member. (_Node_handle_common): Declare _Hashtable as a friend. * include/bits/stl_tree.h (_Rb_tree::_M_reinsert_node_unique): Call release() on node handle instead of just zeroing its pointer. (_Rb_tree::_M_reinsert_node_equal): Likewise. (_Rb_tree::_M_reinsert_node_hint_unique): Likewise. (_Rb_tree::_M_reinsert_node_hint_equal): Likewise. * testsuite/23_containers/multiset/modifiers/114401.cc: New test. * testsuite/23_containers/set/modifiers/114401.cc: New test. * testsuite/23_containers/unordered_multiset/modifiers/114401.cc: New test. * testsuite/23_containers/unordered_set/modifiers/114401.cc: New test. (cherry picked from commit c2e28df90a1640cebadef6c6c8ab5ea964071bb1) Diff: --- libstdc++-v3/include/bits/hashtable.h | 10 +- libstdc++-v3/include/bits/node_handle.h| 19 +++- libstdc++-v3/include/bits/stl_tree.h | 10 +- .../23_containers/multiset/modifiers/114401.cc | 125 .../23_containers/set/modifiers/114401.cc | 125 .../unordered_multiset/modifiers/114401.cc | 126 + .../unordered_set/modifiers/114401.cc | 126 + 7 files changed, 528 insertions(+), 13 deletions(-) diff --git a/libstdc++-v3/include/bits/hashtable.h b/libstdc++-v3/include/bits/hashtable.h index dd3e655866a..1b5d0a7f42f 100644 --- a/libstdc++-v3/include/bits/hashtable.h +++ b/libstdc++-v3/include/bits/hashtable.h @@ -996,7 +996,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // DR 1189. // reserve, if present, comes from _Rehash_base. -#if __cplusplus > 201402L +#if __cplusplus > 201404L /// Re-insert an extracted node into a container with unique keys. insert_return_type _M_reinsert_node(node_type&& __nh) @@ -1021,7 +1021,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { __ret.position = _M_insert_unique_node(__bkt, __code, __nh._M_ptr); - __nh._M_ptr = nullptr; + __nh.release(); __ret.inserted = true; } } @@ -1041,7 +1041,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION auto __code = this->_M_hash_code(__k); auto __ret = _M_insert_multi_node(__hint._M_cur, __code, __nh._M_ptr); - __nh._M_ptr = nullptr; + __nh.release(); return __ret; } @@ -1123,7 +1123,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { auto __nh = __src.extract(__pos); _M_insert_unique_node(__bkt, __code, __nh._M_ptr, __n_elt); - __nh._M_ptr = nullptr; + __nh.release(); __n_elt = 1; } else if (__n_elt != 1) @@ -1150,7 +1150,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION = _M_src_hash_code(__src.hash_function(), __k, *__pos._M_cur); auto __nh = __src.extract(__pos); __hint = _M_insert_multi_node(__hint, __code, __nh._M_ptr)._M_cur; - __nh._M_ptr = nullptr; + __nh.release(); } } #endif // C++17 diff --git a/libstdc++-v3/include/bits/node_handle.h b/libstdc++-v3/include/bits/node_handle.h index 8904a5ac496..79afa547ec4 100644 --- a/libstdc++-v3/include/bits/node_handle.h +++ b/libstdc++-v3/in
[gcc r13-8569] libstdc++: Constrain std::vector default constructor [PR113841]
https://gcc.gnu.org/g:87ec5b369eed205dfe6802afaaec3986b246ade9 commit r13-8569-g87ec5b369eed205dfe6802afaaec3986b246ade9 Author: Jonathan Wakely Date: Fri Feb 9 17:06:20 2024 + libstdc++: Constrain std::vector default constructor [PR113841] This is needed to avoid errors outside the immediate context when evaluating is_default_constructible_v> when A is not default constructible. To avoid diagnostic regressions for 23_containers/vector/48101_neg.cc we need to make the std::allocator partial specializations default constructible, which they probably should have been anyway. libstdc++-v3/ChangeLog: PR libstdc++/113841 * include/bits/allocator.h (allocator): Add default constructor to partial specializations for cv-qualified types. * include/bits/stl_vector.h (_Vector_impl::_Vector_impl()): Constrain so that it's only present if the allocator is default constructible. * include/bits/stl_bvector.h (_Bvector_impl::_Bvector_impl()): Likewise. * testsuite/23_containers/vector/cons/113841.cc: New test. (cherry picked from commit 142cc4c223d695e515ed2504501b91d8a7ac6eb8) Diff: --- libstdc++-v3/include/bits/allocator.h | 3 ++ libstdc++-v3/include/bits/stl_bvector.h| 3 ++ libstdc++-v3/include/bits/stl_vector.h | 3 ++ .../testsuite/23_containers/vector/cons/113841.cc | 34 ++ 4 files changed, 43 insertions(+) diff --git a/libstdc++-v3/include/bits/allocator.h b/libstdc++-v3/include/bits/allocator.h index abbd753d33d..27e47521fe0 100644 --- a/libstdc++-v3/include/bits/allocator.h +++ b/libstdc++-v3/include/bits/allocator.h @@ -256,6 +256,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { public: typedef _Tp value_type; + allocator() { } template allocator(const allocator<_Up>&) { } }; @@ -264,6 +265,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { public: typedef _Tp value_type; + allocator() { } template allocator(const allocator<_Up>&) { } }; @@ -272,6 +274,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { public: typedef _Tp value_type; + allocator() { } template allocator(const allocator<_Up>&) { } }; /// @endcond diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h index 8b54292e51b..e18de7c62aa 100644 --- a/libstdc++-v3/include/bits/stl_bvector.h +++ b/libstdc++-v3/include/bits/stl_bvector.h @@ -593,6 +593,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _GLIBCXX20_CONSTEXPR _Bvector_impl() _GLIBCXX_NOEXCEPT_IF( is_nothrow_default_constructible<_Bit_alloc_type>::value) +#if __cpp_concepts + requires is_default_constructible_v<_Bit_alloc_type> +#endif : _Bit_alloc_type() { } diff --git a/libstdc++-v3/include/bits/stl_vector.h b/libstdc++-v3/include/bits/stl_vector.h index acb29396d26..798e66d91ac 100644 --- a/libstdc++-v3/include/bits/stl_vector.h +++ b/libstdc++-v3/include/bits/stl_vector.h @@ -136,6 +136,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _GLIBCXX20_CONSTEXPR _Vector_impl() _GLIBCXX_NOEXCEPT_IF( is_nothrow_default_constructible<_Tp_alloc_type>::value) +#if __cpp_lib_concepts + requires is_default_constructible_v<_Tp_alloc_type> +#endif : _Tp_alloc_type() { } diff --git a/libstdc++-v3/testsuite/23_containers/vector/cons/113841.cc b/libstdc++-v3/testsuite/23_containers/vector/cons/113841.cc new file mode 100644 index 000..a7721d27f79 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/cons/113841.cc @@ -0,0 +1,34 @@ +// { dg-do compile { target c++20 } } + +#include + +template +struct Alloc +{ + using value_type = T; + + Alloc(int) { } // not default constructible + + template Alloc(const Alloc&) { } + + T* allocate(std::size_t n) { return std::allocator().allocate(n); } + void deallocate(T* p, std::size_t n) { std::allocator().deallocate(p, n); } +}; + +template struct wrap { T t; }; + +template void do_adl(T&) { } + +void test_pr113841() +{ + using test_type = std::vector>; + std::pair>* h = nullptr; + do_adl(h); +} + +void test_pr113841_bool() +{ + using test_type = std::vector>; + std::pair>* h = nullptr; + do_adl(h); +}
[gcc r13-8568] libstdc++: Begin lifetime of storage in std::vector [PR114367]
https://gcc.gnu.org/g:d8d71b19f0b1e28fd6d413a6874ec55c568865b0 commit r13-8568-gd8d71b19f0b1e28fd6d413a6874ec55c568865b0 Author: Jonathan Wakely Date: Mon Mar 18 13:00:17 2024 + libstdc++: Begin lifetime of storage in std::vector [PR114367] This doesn't cause a problem with GCC, but Clang correctly diagnoses a bug in the code. The objects in the allocated storage need to begin their lifetime before we start using them. This change uses the allocator's construct function instead of using std::construct_at directly, in order to support fancy pointers. libstdc++-v3/ChangeLog: PR libstdc++/114367 * include/bits/stl_bvector.h (_M_allocate): Use allocator's construct function to begin lifetime of words. (cherry picked from commit 16afbd9c9c4282d56062cef95e6eccfdcf3efe03) Diff: --- libstdc++-v3/include/bits/stl_bvector.h | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h index 64f04c1f4f5..8b54292e51b 100644 --- a/libstdc++-v3/include/bits/stl_bvector.h +++ b/libstdc++-v3/include/bits/stl_bvector.h @@ -674,13 +674,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _M_allocate(size_t __n) { _Bit_pointer __p = _Bit_alloc_traits::allocate(_M_impl, _S_nword(__n)); -#if __cpp_lib_is_constant_evaluated +#if __cpp_lib_is_constant_evaluated && __cpp_constexpr_dynamic_alloc if (std::is_constant_evaluated()) - { - __n = _S_nword(__n); - for (size_t __i = 0; __i < __n; ++__i) - __p[__i] = 0ul; - } + { + __n = _S_nword(__n); + for (size_t __i = 0; __i < __n; ++__i) + std::construct_at(std::to_address(__p) + __i); + } #endif return __p; }
[gcc r14-9770] GCN: Fix --with-arch= handling in mkoffload [PR111966]
https://gcc.gnu.org/g:b2460d621efe740bd95ad41afef6d806ec1bd9c7 commit r14-9770-gb2460d621efe740bd95ad41afef6d806ec1bd9c7 Author: Tobias Burnus Date: Wed Apr 3 12:37:39 2024 +0200 GCN: Fix --with-arch= handling in mkoffload [PR111966] The default -march= setting used in mkoffload did not reflect the modified default set by GCC's configure-time --with-arch=, causing issues when generating debug code. gcc/ChangeLog: PR other/111966 * config/gcn/mkoffload.cc (get_arch): New; moved -march= flag handling from ... (main): ... here; call it to handle --with-arch config option and -march= commandline. Diff: --- gcc/config/gcn/mkoffload.cc | 90 - 1 file changed, 72 insertions(+), 18 deletions(-) diff --git a/gcc/config/gcn/mkoffload.cc b/gcc/config/gcn/mkoffload.cc index 04356b86195..9a438de331a 100644 --- a/gcc/config/gcn/mkoffload.cc +++ b/gcc/config/gcn/mkoffload.cc @@ -35,6 +35,8 @@ #include "gomp-constants.h" #include "simple-object.h" #include "elf.h" +#include "configargs.h" /* For configure_default_options. */ +#include "multilib.h" /* For multilib_options. */ /* These probably won't (all) be in elf.h for a while. */ #undef EM_AMDGPU @@ -846,6 +848,62 @@ compile_native (const char *infile, const char *outfile, const char *compiler, obstack_free (&argv_obstack, NULL); } +static int +get_arch (const char *str, const char *with_arch_str) +{ + if (strcmp (str, "fiji") == 0) +return EF_AMDGPU_MACH_AMDGCN_GFX803; + else if (strcmp (str, "gfx900") == 0) +return EF_AMDGPU_MACH_AMDGCN_GFX900; + else if (strcmp (str, "gfx906") == 0) +return EF_AMDGPU_MACH_AMDGCN_GFX906; + else if (strcmp (str, "gfx908") == 0) +return EF_AMDGPU_MACH_AMDGCN_GFX908; + else if (strcmp (str, "gfx90a") == 0) +return EF_AMDGPU_MACH_AMDGCN_GFX90a; + else if (strcmp (str, "gfx1030") == 0) +return EF_AMDGPU_MACH_AMDGCN_GFX1030; + else if (strcmp (str, "gfx1036") == 0) +return EF_AMDGPU_MACH_AMDGCN_GFX1036; + else if (strcmp (str, "gfx1100") == 0) +return EF_AMDGPU_MACH_AMDGCN_GFX1100; + else if (strcmp (str, "gfx1103") == 0) +return EF_AMDGPU_MACH_AMDGCN_GFX1103; + + error ("unrecognized argument in option %<-march=%s%>", str); + + /* The suggestions are based on the configured multilib support; the compiler + itself might support more. */ + if (multilib_options[0] != '\0') +{ + /* Example: "march=gfx900/march=gfx906" */ + char *args = (char *) alloca (strlen (multilib_options)); + const char *p = multilib_options, *q = NULL; + args[0] = '\0'; + while (true) + { + p = strchr (p, '='); + if (!p) + break; + if (q) + strcat (args, ", "); + ++p; + q = strchr (p, '/'); + if (q) + strncat (args, p, q-p); + else + strcat (args, p); + } + inform (UNKNOWN_LOCATION, "valid arguments to %<-march=%> are: %s", args); +} + else if (with_arch_str) +inform (UNKNOWN_LOCATION, "valid argument to %<-march=%> is %qs", with_arch_str); + + exit (FATAL_EXIT_CODE); + + return 0; +} + int main (int argc, char **argv) { @@ -853,9 +911,21 @@ main (int argc, char **argv) FILE *out = stdout; FILE *cfile = stdout; const char *outname = 0; + const char *with_arch_str = NULL; progname = tool_name; + gcc_init_libintl (); diagnostic_initialize (global_dc, 0); + diagnostic_color_init (global_dc); + + for (size_t i = 0; i < ARRAY_SIZE (configure_default_options); i++) +if (configure_default_options[i].name != NULL + && strcmp (configure_default_options[i].name, "arch") == 0) + { + with_arch_str = configure_default_options[0].value; + elf_arch = get_arch (configure_default_options[0].value, NULL); + break; + } obstack_init (&files_to_cleanup); if (atexit (mkoffload_cleanup) != 0) @@ -961,24 +1031,8 @@ main (int argc, char **argv) else if (strcmp (argv[i], "-dumpbase") == 0 && i + 1 < argc) dumppfx = argv[++i]; - else if (strcmp (argv[i], "-march=fiji") == 0) - elf_arch = EF_AMDGPU_MACH_AMDGCN_GFX803; - else if (strcmp (argv[i], "-march=gfx900") == 0) - elf_arch = EF_AMDGPU_MACH_AMDGCN_GFX900; - else if (strcmp (argv[i], "-march=gfx906") == 0) - elf_arch = EF_AMDGPU_MACH_AMDGCN_GFX906; - else if (strcmp (argv[i], "-march=gfx908") == 0) - elf_arch = EF_AMDGPU_MACH_AMDGCN_GFX908; - else if (strcmp (argv[i], "-march=gfx90a") == 0) - elf_arch = EF_AMDGPU_MACH_AMDGCN_GFX90a; - else if (strcmp (argv[i], "-march=gfx1030") == 0) - elf_arch = EF_AMDGPU_MACH_AMDGCN_GFX1030; - else if (strcmp (argv[i], "-march=gfx1036") == 0) - elf_arch = EF_AMDGPU_MACH_AMDGCN_GFX1036; - else if (strcmp (argv[i], "-march=gfx1100") == 0) - elf_arch = EF_AMD
[gcc r14-9769] libquadmath: Don't assume the storage for __float128 arguments is aligned [PR114533]
https://gcc.gnu.org/g:8455d6f6cd43b7b143ab9ee19437452fceba9cc9 commit r14-9769-g8455d6f6cd43b7b143ab9ee19437452fceba9cc9 Author: Jakub Jelinek Date: Wed Apr 3 10:02:35 2024 +0200 libquadmath: Don't assume the storage for __float128 arguments is aligned [PR114533] With the register_printf_type/register_printf_modifier/register_printf_specifier APIs the C library is just told the size of the argument and is provided with a callback to fetch the argument from va_list using va_arg into C library provided memory. The C library isn't told what alignment requirement it has, but we were using direct load of a __float128 value from that memory which assumes __alignof (__float128) alignment. The following patch fixes that by using memcpy instead. I haven't been able to reproduce an actual crash, tried #include #include #include int main () { __float128 r; int prec = 20; int width = 46; char buf[128]; r = 2.0q; r = sqrtq (r); int n = quadmath_snprintf (buf, sizeof buf, "%+-#*.20Qe", width, r); if ((size_t) n < sizeof buf) printf ("%s\n", buf); /* Prints: +1.41421356237309504880e+00 */ quadmath_snprintf (buf, sizeof buf, "%Qa", r); if ((size_t) n < sizeof buf) printf ("%s\n", buf); /* Prints: 0x1.6a09e667f3bcc908b2fb1366ea96p+0 */ n = quadmath_snprintf (NULL, 0, "%+-#46.*Qe", prec, r); if (n > -1) { char *str = malloc (n + 1); if (str) { quadmath_snprintf (str, n + 1, "%+-#46.*Qe", prec, r); printf ("%s\n", str); /* Prints: +1.41421356237309504880e+00 */ } free (str); } printf ("%+-#*.20Qe\n", width, r); printf ("%Qa\n", r); printf ("%+-#46.*Qe\n", prec, r); printf ("%d %Qe %d %Qe %d %Qe\n", 1, r, 2, r, 3, r); return 0; } In any case, I think memcpy for loading from it is right. 2024-04-03 Simon Chopin Jakub Jelinek PR libquadmath/114533 * printf/printf_fp.c (__quadmath_printf_fp): Use memcpy to copy __float128 out of args. * printf/printf_fphex.c (__quadmath_printf_fphex): Likewise. Signed-off-by: Simon Chopin Diff: --- libquadmath/printf/printf_fp.c| 2 +- libquadmath/printf/printf_fphex.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libquadmath/printf/printf_fp.c b/libquadmath/printf/printf_fp.c index 8effcee88fa..9968aa5307c 100644 --- a/libquadmath/printf/printf_fp.c +++ b/libquadmath/printf/printf_fp.c @@ -363,7 +363,7 @@ __quadmath_printf_fp (struct __quadmath_printf_file *fp, /* Fetch the argument value. */ { - fpnum = **(const __float128 **) args[0]; + memcpy (&fpnum, *(const void *const *) args[0], sizeof (fpnum)); /* Check for special values: not a number or infinity. */ if (isnanq (fpnum)) diff --git a/libquadmath/printf/printf_fphex.c b/libquadmath/printf/printf_fphex.c index a40a6b00945..ddb413563c6 100644 --- a/libquadmath/printf/printf_fphex.c +++ b/libquadmath/printf/printf_fphex.c @@ -163,7 +163,8 @@ __quadmath_printf_fphex (struct __quadmath_printf_file *fp, /* Fetch the argument value. */ { - fpnum.value = **(const __float128 **) args[0]; + memcpy (&fpnum.value, *(const void *const *) args[0], + sizeof (fpnum.value)); /* Check for special values: not a number or infinity. */ if (isnanq (fpnum.value))
[gcc r14-9768] expr: Fix up emit_push_insn [PR114552]
https://gcc.gnu.org/g:03039744f368a24a452e4ea8d946e9c2cedaf1aa commit r14-9768-g03039744f368a24a452e4ea8d946e9c2cedaf1aa Author: Jakub Jelinek Date: Wed Apr 3 09:59:45 2024 +0200 expr: Fix up emit_push_insn [PR114552] r13-990 added optimizations in multiple spots to optimize during expansion storing of constant initializers into targets. In the load_register_parameters and expand_expr_real_1 cases, it checks it has a tree as the source and so knows we are reading that whole decl's value, so the code is fine as is, but in the emit_push_insn case it checks for a MEM from which something is pushed and checks for SYMBOL_REF as the MEM's address, but still assumes the whole object is copied, which as the following testcase shows might not always be the case. In the testcase, k is 6 bytes, then 2 bytes of padding, then another 4 bytes, while the emit_push_insn wants to store just the 6 bytes. The following patch simply verifies it is the whole initializer that is being stored, I think that is best thing to do so late in GCC 14 cycle as well for backporting. For GCC 15, perhaps the code could stop requiring it must be at offset zero, nor that the size is equal, but could use get_symbol_constant_value/fold_ctor_reference gimple-fold APIs to actually extract just part of the initializer if we e.g. push just some subset (of course, still verify that it is a subset). For sizes which are power of two bytes and we have some integer modes, we could use as type for fold_ctor_reference corresponding integral types, otherwise dunno, punt or use some structure (e.g. try to find one in the initializer?), whatever. But even in the other spots it could perhaps handle loading of COMPONENT_REFs or MEM_REFs from the .rodata vars. 2024-04-03 Jakub Jelinek PR middle-end/114552 * expr.cc (emit_push_insn): Only use store_constructor for immediate_const_ctor_p if int_expr_size matches size. * gcc.c-torture/execute/pr114552.c: New test. Diff: --- gcc/expr.cc| 9 ++--- gcc/testsuite/gcc.c-torture/execute/pr114552.c | 24 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/gcc/expr.cc b/gcc/expr.cc index 2918c469735..8a1875d7809 100644 --- a/gcc/expr.cc +++ b/gcc/expr.cc @@ -5466,6 +5466,7 @@ emit_push_insn (rtx x, machine_mode mode, tree type, rtx size, /* If source is a constant VAR_DECL with a simple constructor, store the constructor to the stack instead of moving it. */ const_tree decl; + HOST_WIDE_INT sz; if (partial == 0 && MEM_P (xinner) && SYMBOL_REF_P (XEXP (xinner, 0)) @@ -5473,9 +5474,11 @@ emit_push_insn (rtx x, machine_mode mode, tree type, rtx size, && VAR_P (decl) && TREE_READONLY (decl) && !TREE_SIDE_EFFECTS (decl) - && immediate_const_ctor_p (DECL_INITIAL (decl), 2)) - store_constructor (DECL_INITIAL (decl), target, 0, - int_expr_size (DECL_INITIAL (decl)), false); + && immediate_const_ctor_p (DECL_INITIAL (decl), 2) + && (sz = int_expr_size (DECL_INITIAL (decl))) > 0 + && CONST_INT_P (size) + && INTVAL (size) == sz) + store_constructor (DECL_INITIAL (decl), target, 0, sz, false); else emit_block_move (target, xinner, size, BLOCK_OP_CALL_PARM); } diff --git a/gcc/testsuite/gcc.c-torture/execute/pr114552.c b/gcc/testsuite/gcc.c-torture/execute/pr114552.c new file mode 100644 index 000..22cb4ee351f --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr114552.c @@ -0,0 +1,24 @@ +/* PR middle-end/114552 */ + +struct __attribute__((packed)) S { short b; int c; }; +struct T { struct S b; int e; }; +static const struct T k = { { 1, 0 }, 0 }; + +__attribute__((noinline)) void +foo (void) +{ + asm volatile ("" : : : "memory"); +} + +__attribute__((noinline)) void +bar (struct S n) +{ + foo (); +} + +int +main () +{ + bar (k.b); + return 0; +}