[gcc r15-7943] tree-optimization/119166 - ICE with --param vect-force-slp=0
https://gcc.gnu.org/g:c39b0d4faedd432c85ba5c737ebe9d41aad7dca1 commit r15-7943-gc39b0d4faedd432c85ba5c737ebe9d41aad7dca1 Author: Richard Biener Date: Tue Mar 11 08:29:05 2025 +0100 tree-optimization/119166 - ICE with --param vect-force-slp=0 The following fixes a missing guard on slp_node in get_load_store_type. PR tree-optimization/119166 * tree-vect-stmts.cc (get_load_store_type): Guard SLP tree access. Diff: --- gcc/tree-vect-stmts.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index 743631f94488..f894787f7bfb 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -2708,7 +2708,7 @@ get_load_store_type (vec_info *vinfo, stmt_vec_info stmt_info, such only the first load in the group is aligned, the rest are not. Because of this the permutes may break the alignment requirements that have been set, and as such we should for now, reject them. */ - if (SLP_TREE_LOAD_PERMUTATION (slp_node).exists ()) + if (slp_node && SLP_TREE_LOAD_PERMUTATION (slp_node).exists ()) { if (dump_enabled_p ()) dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
[gcc r15-7945] s390: Deprecate ESA/390 support
https://gcc.gnu.org/g:3b1bd1fdcd241dd1e5b706b6937400d74ca43146 commit r15-7945-g3b1bd1fdcd241dd1e5b706b6937400d74ca43146 Author: Stefan Schulze Frielinghaus Date: Tue Mar 11 09:28:06 2025 +0100 s390: Deprecate ESA/390 support Deprecate support for the ESA/390 architecture which will be eventually removed, and encourage the usage of the z/Architecture instead. Furthermore, default for -m31 to -mzarch whereas previously we defaulted to -mesa. gcc/ChangeLog: * config.gcc: Fail in case of option --with-mode=esa. * config/s390/s390.cc (s390_option_override_internal): Default to z/Architecture mode. * config/s390/s390.h (DRIVER_SELF_SPECS): Ditto. * config/s390/s390.opt: Emit a warning for option -mesa. * doc/invoke.texi: Document the change. gcc/testsuite/ChangeLog: * gcc.target/s390/20020926-1.c: Deal with deprecation warning. * gcc.target/s390/dwarfregtable-1.c: Ditto. * gcc.target/s390/fp2int1.c: Ditto. * gcc.target/s390/pr10.c: Ditto. * gcc.target/s390/pr106355-3.c: Ditto. * gcc.target/s390/pr61078.c: Ditto. * gcc.target/s390/target-attribute/tattr-m31-10.c: Ditto. * gcc.target/s390/target-attribute/tattr-m31-12.c: Ditto. * gcc.target/s390/target-attribute/tattr-m31-14.c: Ditto. * gcc.target/s390/target-attribute/tattr-m31-18.c: Ditto. * gcc.target/s390/target-attribute/tattr-m31-2.c: Ditto. * gcc.target/s390/target-attribute/tattr-m31-20.c: Ditto. * gcc.target/s390/target-attribute/tattr-m31-22.c: Ditto. * gcc.target/s390/target-attribute/tattr-m31-24.c: Ditto. * gcc.target/s390/target-attribute/tattr-m31-26.c: Ditto. * gcc.target/s390/target-attribute/tattr-m31-28.c: Ditto. * gcc.target/s390/target-attribute/tattr-m31-30.c: Ditto. * gcc.target/s390/target-attribute/tattr-m31-32.c: Ditto. * gcc.target/s390/target-attribute/tattr-m31-4.c: Ditto. * gcc.target/s390/target-attribute/tattr-m31-6.c: Ditto. * gcc.target/s390/target-attribute/tattr-m31-8.c: Ditto. Diff: --- gcc/config.gcc| 6 +- gcc/config/s390/s390.cc | 7 +-- gcc/config/s390/s390.h| 2 +- gcc/config/s390/s390.opt | 2 +- gcc/doc/invoke.texi | 6 +- gcc/testsuite/gcc.target/s390/20020926-1.c| 1 + gcc/testsuite/gcc.target/s390/dwarfregtable-1.c | 1 + gcc/testsuite/gcc.target/s390/fp2int1.c | 1 + gcc/testsuite/gcc.target/s390/pr10.c | 1 + gcc/testsuite/gcc.target/s390/pr106355-3.c| 1 + gcc/testsuite/gcc.target/s390/pr61078.c | 1 + gcc/testsuite/gcc.target/s390/target-attribute/tattr-m31-10.c | 1 + gcc/testsuite/gcc.target/s390/target-attribute/tattr-m31-12.c | 1 + gcc/testsuite/gcc.target/s390/target-attribute/tattr-m31-14.c | 1 + gcc/testsuite/gcc.target/s390/target-attribute/tattr-m31-18.c | 1 + gcc/testsuite/gcc.target/s390/target-attribute/tattr-m31-2.c | 1 + gcc/testsuite/gcc.target/s390/target-attribute/tattr-m31-20.c | 1 + gcc/testsuite/gcc.target/s390/target-attribute/tattr-m31-22.c | 1 + gcc/testsuite/gcc.target/s390/target-attribute/tattr-m31-24.c | 1 + gcc/testsuite/gcc.target/s390/target-attribute/tattr-m31-26.c | 1 + gcc/testsuite/gcc.target/s390/target-attribute/tattr-m31-28.c | 1 + gcc/testsuite/gcc.target/s390/target-attribute/tattr-m31-30.c | 1 + gcc/testsuite/gcc.target/s390/target-attribute/tattr-m31-32.c | 1 + gcc/testsuite/gcc.target/s390/target-attribute/tattr-m31-4.c | 1 + gcc/testsuite/gcc.target/s390/target-attribute/tattr-m31-6.c | 1 + gcc/testsuite/gcc.target/s390/target-attribute/tattr-m31-8.c | 1 + 26 files changed, 34 insertions(+), 10 deletions(-) diff --git a/gcc/config.gcc b/gcc/config.gcc index a518e976b82e..c4816e26f82f 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -5768,9 +5768,13 @@ case "${target}" in done case ${with_mode} in - "" | esa | zarch) + "" | zarch) # OK ;; + esa) + echo "Support for ESA/390 is deprecated; use z/Architecture instead." 1>&2 + exit 1 + ;; *) echo "Unknown architecture mode used in --with-mode=$with_mode." 1>&2 exit 1 diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc index 2f516967e7b1..645aedba67f0 100644 --- a/gcc/config/s390/s390.cc +++ b/gcc/config/s390/s390.cc @@ -162
[gcc r15-7952] Fixup gcobol driver handling of -print-* options
https://gcc.gnu.org/g:c20e24f8e7318bb50fa0dab98012d9c2f3dbf55b commit r15-7952-gc20e24f8e7318bb50fa0dab98012d9c2f3dbf55b Author: Richard Biener Date: Tue Mar 11 11:29:51 2025 +0100 Fixup gcobol driver handling of -print-* options We are not supposed to diagnose missing input files. gcc/cobol/ * gcobolspec.cc (lang_specific_driver): For OPT_print_* do not error on no input files. Diff: --- gcc/cobol/gcobolspec.cc | 12 1 file changed, 12 insertions(+) diff --git a/gcc/cobol/gcobolspec.cc b/gcc/cobol/gcobolspec.cc index 20ca757fa871..f3f9c327cd0a 100644 --- a/gcc/cobol/gcobolspec.cc +++ b/gcc/cobol/gcobolspec.cc @@ -406,6 +406,18 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, n_mains += 1; break; + case OPT_print_search_dirs: + case OPT_print_file_name_: + case OPT_print_prog_name_: + case OPT_print_multi_lib: + case OPT_print_multi_directory: + case OPT_print_sysroot: + case OPT_print_multi_os_directory: + case OPT_print_multiarch: + case OPT_print_sysroot_headers_suffix: + no_files_error = false; + break; + case OPT_v: no_files_error = false; verbose = true;
[gcc r13-9422] ipa-sra: Avoid clashes with ipa-cp when pulling accesses across calls (PR 118243)
https://gcc.gnu.org/g:ceb689d5b697886c2255a43ee61b7352242c9683 commit r13-9422-gceb689d5b697886c2255a43ee61b7352242c9683 Author: Martin Jambor Date: Tue Mar 11 16:49:40 2025 +0100 ipa-sra: Avoid clashes with ipa-cp when pulling accesses across calls (PR 118243) Among other things, IPA-SRA checks whether splitting out a bit of an aggregate or something passed by reference would lead into a clash with an already known IPA-CP constant a way which would cause problems later on. Unfortunately the test is done only in adjust_parameter_descriptions and is missing when accesses are propagated from callees to callers, which leads to miscompilation reported as PR 118243 (where the callee is a function created by ipa-split). The matter is then further complicated by the fact that we consider complex numbers as scalars even though they can be modified piecemeal (IPA-CP can detect and propagate the pieces separately too) which then confuses the parameter manipulation machinery furter. This patch simply adds the missing check to avoid the IPA-SRA transform in these cases too, which should be suitable for backporting to all affected release branches. It is a bit of a shame as in the PR testcase we do propagate both components of the complex number in question and the transformation phase could recover. I have some prototype patches in this direction but that is something for (a) stage 1. gcc/ChangeLog: 2025-02-10 Martin Jambor PR ipa/118243 * ipa-sra.cc (pull_accesses_from_callee): New parameters caller_ipcp_ts and param_idx. Check that scalar pulled accesses would not clash with a known IPA-CP aggregate constant. (param_splitting_across_edge): Pass IPA-CP transformation summary and caller parameter index to pull_accesses_from_callee. gcc/testsuite/ChangeLog: 2025-02-10 Martin Jambor PR ipa/118243 * g++.dg/ipa/pr118243.C: New test. (cherry picked from commit 0bffcd469e68d68ba9c724f515651deff8494b82) Diff: --- gcc/ipa-sra.cc | 38 +-- gcc/testsuite/g++.dg/ipa/pr118243.C | 40 + 2 files changed, 68 insertions(+), 10 deletions(-) diff --git a/gcc/ipa-sra.cc b/gcc/ipa-sra.cc index a3db19b7a6fb..288b61e4fb4f 100644 --- a/gcc/ipa-sra.cc +++ b/gcc/ipa-sra.cc @@ -3579,15 +3579,19 @@ enum acc_prop_kind {ACC_PROP_DONT, ACC_PROP_COPY, ACC_PROP_CERTAIN}; /* Attempt to propagate all definite accesses from ARG_DESC to PARAM_DESC, (which belongs to CALLER) if they would not violate some constraint there. - If successful, return NULL, otherwise return the string reason for failure - (which can be written to the dump file). DELTA_OFFSET is the known offset - of the actual argument withing the formal parameter (so of ARG_DESCS within - PARAM_DESCS), ARG_SIZE is the size of the actual argument or zero, if not - known. In case of success, set *CHANGE_P to true if propagation actually - changed anything. */ + CALLER_IPCP_TS describes the caller, PARAM_IDX is the index of the parameter + described by PARAM_DESC. If successful, return NULL, otherwise return the + string reason for failure (which can be written to the dump file). + DELTA_OFFSET is the known offset of the actual argument withing the formal + parameter (so of ARG_DESCS within PARAM_DESCS), ARG_SIZE is the size of the + actual argument or zero, if not known. In case of success, set *CHANGE_P to + true if propagation actually changed anything. */ static const char * -pull_accesses_from_callee (cgraph_node *caller, isra_param_desc *param_desc, +pull_accesses_from_callee (cgraph_node *caller, + ipcp_transformation *caller_ipcp_ts, + int param_idx, + isra_param_desc *param_desc, isra_param_desc *arg_desc, unsigned delta_offset, unsigned arg_size, bool *change_p) @@ -3612,6 +3616,17 @@ pull_accesses_from_callee (cgraph_node *caller, isra_param_desc *param_desc, continue; unsigned offset = argacc->unit_offset + delta_offset; + + if (caller_ipcp_ts && !AGGREGATE_TYPE_P (argacc->type)) + { + ipa_argagg_value_list avl (caller_ipcp_ts); + tree value = avl.get_value (param_idx, offset); + if (value && ((tree_to_uhwi (TYPE_SIZE (TREE_TYPE (value))) +/ BITS_PER_UNIT) + != argacc->unit_size)) + return " propagated access would conflict with an IPA-CP constant"; + } + /* Given that accesses are initially stored according to increasing offset and decreasing size in case of equal offsets, the following searches could
[gcc r12-10987] Fix folding of BIT_NOT_EXPR for POLY_INT_CST [PR118976]
https://gcc.gnu.org/g:587b370c8492aadaab14c57e242c66778cc78891 commit r12-10987-g587b370c8492aadaab14c57e242c66778cc78891 Author: Richard Sandiford Date: Tue Mar 11 15:51:55 2025 + Fix folding of BIT_NOT_EXPR for POLY_INT_CST [PR118976] There was an embarrassing typo in the folding of BIT_NOT_EXPR for POLY_INT_CSTs: it used - rather than ~ on the poly_int. Not sure how that happened, but it might have been due to the way that ~x is implemented as -1 - x internally. gcc/ PR tree-optimization/118976 * fold-const.cc (const_unop): Use ~ rather than - for BIT_NOT_EXPR. * config/aarch64/aarch64.cc (aarch64_test_sve_folding): New function. (aarch64_run_selftests): Run it. (cherry picked from commit 78380fd7f743e23dfdf013d68a2f0347e1511550) Diff: --- gcc/config/aarch64/aarch64.cc | 11 +++ gcc/fold-const.cc | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index be0d958dcf6b..72d737d62228 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -27541,6 +27541,16 @@ aarch64_test_fractional_cost () ASSERT_EQ (cf (1, 2).as_double (), 0.5); } +/* Test SVE arithmetic folding. */ + +static void +aarch64_test_sve_folding () +{ + tree res = fold_unary (BIT_NOT_EXPR, ssizetype, +ssize_int (poly_int64 (1, 1))); + ASSERT_TRUE (operand_equal_p (res, ssize_int (poly_int64 (-2, -1; +} + /* Run all target-specific selftests. */ static void @@ -27548,6 +27558,7 @@ aarch64_run_selftests (void) { aarch64_test_loading_full_dump (); aarch64_test_fractional_cost (); + aarch64_test_sve_folding (); } } // namespace selftest diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc index d81a71c41a17..391f11095408 100644 --- a/gcc/fold-const.cc +++ b/gcc/fold-const.cc @@ -1802,7 +1802,7 @@ const_unop (enum tree_code code, tree type, tree arg0) if (TREE_CODE (arg0) == INTEGER_CST) return fold_not_const (arg0, type); else if (POLY_INT_CST_P (arg0)) - return wide_int_to_tree (type, -poly_int_cst_value (arg0)); + return wide_int_to_tree (type, ~poly_int_cst_value (arg0)); /* Perform BIT_NOT_EXPR on each element individually. */ else if (TREE_CODE (arg0) == VECTOR_CST) {
[gcc r15-7935] Update cpplib de.po
https://gcc.gnu.org/g:ace0f23b533b3e1dc79daeb523c99db3417dc9f9 commit r15-7935-gace0f23b533b3e1dc79daeb523c99db3417dc9f9 Author: Joseph Myers Date: Mon Mar 10 23:31:38 2025 + Update cpplib de.po * de.po: Update. Diff: --- libcpp/po/de.po | 856 +++- 1 file changed, 344 insertions(+), 512 deletions(-) diff --git a/libcpp/po/de.po b/libcpp/po/de.po index d171d3dc5d26..4f10107f17c5 100644 --- a/libcpp/po/de.po +++ b/libcpp/po/de.po @@ -5,14 +5,14 @@ # Roland Stigge , 2003-2008, 2010, 2012-2013. # Mario Blättermann , 2014-2016. # Philipp Thomas , 2016. -# Roland Illig , 2017-2024. +# Roland Illig , 2017-2025. # msgid "" msgstr "" -"Project-Id-Version: cpplib 14.1-b20240218\n" +"Project-Id-Version: cpplib 15-b20250216\n" "Report-Msgid-Bugs-To: https://gcc.gnu.org/bugs/\n"; "POT-Creation-Date: 2025-02-14 22:50+\n" -"PO-Revision-Date: 2024-02-21 23:55+0100\n" +"PO-Revision-Date: 2025-03-10 22:32+0100\n" "Last-Translator: Roland Illig \n" "Language-Team: German \n" "Language: de\n" @@ -20,7 +20,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Bugs: Report translation errors to the Language-Team address.\n" -"X-Generator: Poedit 3.4.2\n" +"X-Generator: Poedit 3.5\n" #: charset.cc:759 #, gcc-internal-format, gfc-internal-format @@ -37,10 +37,9 @@ msgid "no iconv implementation, cannot convert from %s to %s" msgstr "keine Implementation für iconv, es kann nicht von %s nach %s konvertiert werden" #: charset.cc:870 -#, fuzzy, gcc-internal-format -#| msgid "character 0x%lx is not in the basic source character set\n" +#, gcc-internal-format msgid "character 0x%lx is not in the basic source character set" -msgstr "Zeichen 0x%lx ist nicht im regulären Quellzeichensatz\n" +msgstr "Zeichen 0x%lx ist nicht im regulären Quellzeichensatz" #: charset.cc:887 charset.cc:2639 msgid "converting to execution character set" @@ -56,22 +55,19 @@ msgid "universal character names are only valid in C++ and C99" msgstr "universelle Zeichennamen sind nur in C++ und C99 gültig" #: charset.cc:1553 -#, fuzzy, gcc-internal-format -#| msgid "C99's universal character names are incompatible with C90" +#, gcc-internal-format msgid "C99%'s universal character names are incompatible with C90" msgstr "Die universellen Zeichennamen von C99 sind mit C90 nicht kompatibel" #: charset.cc:1556 -#, fuzzy, gcc-internal-format -#| msgid "the meaning of '\\%c' is different in traditional C" +#, gcc-internal-format msgid "the meaning of %<\\%c%> is different in traditional C" msgstr "die Bedeutung von »\\%c« ist in traditionellem C anders" #: charset.cc:1595 -#, fuzzy, gcc-internal-format -#| msgid "'\\N' not followed by '{'" +#, gcc-internal-format msgid "%<\\N%> not followed by %<{%>" -msgstr "»\\N« ohne folgendes »{«" +msgstr "%<\\N%> ohne folgendes %<{%>" #: charset.cc:1625 msgid "empty named universal character escape sequence; treating it as separate tokens" @@ -86,40 +82,34 @@ msgid "named universal character escapes are only valid in C++23" msgstr "Escapesequenzen für benannte universelle Zeichen sind erst ab C++23 gültig" #: charset.cc:1659 -#, fuzzy, gcc-internal-format -#| msgid "\\N{%.*s} is not a valid universal character; treating it as separate tokens" +#, gcc-internal-format msgid "%<\\N{%.*s}%> is not a valid universal character; treating it as separate tokens" -msgstr "»\\N{%.*s}« ist kein gültiges universelles Zeichen; wird als separate Tokens interpretiert" +msgstr "%<\\N{%.*s}%> ist kein gültiges universelles Zeichen; wird als separate Tokens interpretiert" #: charset.cc:1665 -#, fuzzy, gcc-internal-format -#| msgid "\\N{%.*s} is not a valid universal character" +#, gcc-internal-format msgid "%<\\N{%.*s}%> is not a valid universal character" -msgstr "»\\N{%.*s}« ist kein gültiges universelles Zeichen" +msgstr "%<\\N{%.*s}%> ist kein gültiges universelles Zeichen" #: charset.cc:1675 -#, fuzzy, gcc-internal-format -#| msgid "did you mean \\N{%s}?" +#, gcc-internal-format msgid "did you mean %<\\N{%s}%>?" -msgstr "meinten Sie \\N{%s}?" +msgstr "meinten Sie %<\\N{%s}%>?" #: charset.cc:1693 -#, fuzzy, gcc-internal-format -#| msgid "'\\N{' not terminated with '}' after %.*s; treating it as separate tokens" +#, gcc-internal-format msgid "%<\\N{%> not terminated with %<}%> after %.*s; treating it as separate tokens" -msgstr "»\\N{« ohne dazugehöriges »}« nach %.*s; wird als separate Tokens interpretiert" +msgstr "%<\\N{%> ohne dazugehöriges %<}%> nach %.*s; wird als separate Tokens interpretiert" #: charset.cc:1702 -#, fuzzy, gcc-internal-format -#| msgid "'\\N{' not terminated with '}' after %.*s" +#, gcc-internal-format msgid "%<\\N{%> not terminated with %<}%> after %.*s" -msgstr "»\\N{« ohne dazugehöriges »}« nach %.*s" +msgstr "%<\\N{%> ohne dazugehöriges %<}%> nach %.*s" #: charset.cc:1710 -#, fuzzy, gcc-internal-format -#| ms
[gcc r12-10985] aarch64: Fix caller saves of VNx2QI [PR116238]
https://gcc.gnu.org/g:8643edbb888b4325d81393cebc5bacf9cb22d202 commit r12-10985-g8643edbb888b4325d81393cebc5bacf9cb22d202 Author: Richard Sandiford Date: Tue Mar 11 15:51:54 2025 + aarch64: Fix caller saves of VNx2QI [PR116238] The testcase contains a VNx2QImode pseudo that is live across a call and that cannot be allocated a call-preserved register. LRA quite reasonably tried to save it before the call and restore it afterwards. Unfortunately, the target told it to do that in SImode, even though punning between SImode and VNx2QImode is disallowed by both TARGET_CAN_CHANGE_MODE_CLASS and TARGET_MODES_TIEABLE_P. The natural class to use for SImode is GENERAL_REGS, so this led to an unsalvageable situation in which we had: (set (subreg:VNx2QI (reg:SI A) 0) (reg:VNx2QI B)) where A needed GENERAL_REGS and B needed FP_REGS. We therefore ended up in a reload loop. The hooks above should ensure that this situation can never occur for incoming subregs. It only happened here because the target explicitly forced it. The decision to use SImode for modes smaller than 4 bytes dates back to the beginning of the port, before 16-bit floating-point modes existed. I'm not sure whether promoting to SImode really makes sense for any FPR, but that's a separate performance/QoI discussion. For now, this patch just disallows using SImode when it is wrong for correctness reasons, since that should be safer to backport. gcc/ PR testsuite/116238 * config/aarch64/aarch64.cc (aarch64_hard_regno_caller_save_mode): Only return SImode if we can convert to and from it. gcc/testsuite/ PR testsuite/116238 * gcc.target/aarch64/sve/pr116238.c: New test. (cherry picked from commit ec9d6d45191f639482344362d048294e74587ca3) Diff: --- gcc/config/aarch64/aarch64.cc | 7 --- gcc/testsuite/gcc.target/aarch64/sve/pr116238.c | 13 + 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index cd2f4053a1a0..be0d958dcf6b 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -4229,10 +4229,11 @@ aarch64_hard_regno_caller_save_mode (unsigned regno, unsigned, unnecessarily significant. */ if (PR_REGNUM_P (regno)) return mode; - if (known_ge (GET_MODE_SIZE (mode), 4)) -return mode; - else + if (known_lt (GET_MODE_SIZE (mode), 4) + && REG_CAN_CHANGE_MODE_P (regno, mode, SImode) + && REG_CAN_CHANGE_MODE_P (regno, SImode, mode)) return SImode; + return mode; } /* Return true if I's bits are consecutive ones from the MSB. */ diff --git a/gcc/testsuite/gcc.target/aarch64/sve/pr116238.c b/gcc/testsuite/gcc.target/aarch64/sve/pr116238.c new file mode 100644 index ..fe66b198107f --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/sve/pr116238.c @@ -0,0 +1,13 @@ +/* { dg-additional-options "-O2 -msve-vector-bits=128" } */ + +void foo(); +typedef unsigned char v2qi __attribute__((vector_size(2))); +void f(v2qi *ptr) +{ + v2qi x = *ptr; + asm volatile ("" :: "w" (x)); + asm volatile ("" ::: "d8", "d9", "d10", "d11", "d12", "d13", "d14", "d15"); + foo(); + asm volatile ("" :: "w" (x)); + *ptr = x; +}
[gcc r15-7961] Fix a pasto in ao_compare::compare_ao_refs
https://gcc.gnu.org/g:dc47161c1f32c3f27d1157ba0de9d98ea1b7fc82 commit r15-7961-gdc47161c1f32c3f27d1157ba0de9d98ea1b7fc82 Author: Martin Jambor Date: Tue Mar 11 14:52:44 2025 +0100 Fix a pasto in ao_compare::compare_ao_refs When reading the function ao_compare::compare_ao_refs I came accross what I believe to ba a copy-and-paste error which this patch fixes. gcc/ChangeLog: 2025-03-10 Martin Jambor * tree-ssa-alias.cc (ao_compare::compare_ao_refs): Fix a copy-and-paste error. Diff: --- gcc/tree-ssa-alias.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/tree-ssa-alias.cc b/gcc/tree-ssa-alias.cc index 2489aa6b8087..e93d5187d509 100644 --- a/gcc/tree-ssa-alias.cc +++ b/gcc/tree-ssa-alias.cc @@ -4355,12 +4355,13 @@ ao_compare::compare_ao_refs (ao_ref *ref1, ao_ref *ref2, c1 = p1, nskipped1 = i; i++; } + i = 0; for (tree p2 = ref2->ref; handled_component_p (p2); p2 = TREE_OPERAND (p2, 0)) { if (component_ref_to_zero_sized_trailing_array_p (p2)) end_struct_ref2 = p2; if (ends_tbaa_access_path_p (p2)) - c2 = p2, nskipped1 = i; + c2 = p2, nskipped2 = i; i++; }
[gcc r15-7963] aarch64: Generalise tbz_2.c
https://gcc.gnu.org/g:456924e078c0312f9a0f07aa829ab2b6fdcf237c commit r15-7963-g456924e078c0312f9a0f07aa829ab2b6fdcf237c Author: Richard Sandiford Date: Tue Mar 11 15:39:00 2025 + aarch64: Generalise tbz_2.c For many functions in tbz_2.c, it doesn't matter whether the code tests a 32-bit or a 64-bit register. g6-g8 have started testing 32-bit registers, but the others could in future too. gcc/testsuite/ * gcc.target/aarch64/tbz_2.c: Accept both 32-bit and 64-bit registers. Diff: --- gcc/testsuite/gcc.target/aarch64/tbz_2.c | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gcc/testsuite/gcc.target/aarch64/tbz_2.c b/gcc/testsuite/gcc.target/aarch64/tbz_2.c index 8ca69e9b0c40..8d41e58eab53 100644 --- a/gcc/testsuite/gcc.target/aarch64/tbz_2.c +++ b/gcc/testsuite/gcc.target/aarch64/tbz_2.c @@ -20,7 +20,7 @@ void g1(int x) /* ** g2: -** tbnzx0, 0, .L[0-9]+ +** tbnz[wx]0, 0, .L[0-9]+ ** ret ** ... */ @@ -32,7 +32,7 @@ void g2(int x) /* ** g3: -** tbnzx0, 3, .L[0-9]+ +** tbnz[wx]0, 3, .L[0-9]+ ** ret ** ... */ @@ -44,7 +44,7 @@ void g3(int x) /* ** g4: -** tbnzw0, #31, .L[0-9]+ +** tbnz[wx]0, #31, .L[0-9]+ ** ret ** ... */ @@ -56,7 +56,7 @@ void g4(int x) /* ** g5: -** tst w0, 255 +** tst [wx]0, 255 ** bne .L[0-9]+ ** ret ** ... @@ -69,7 +69,7 @@ void g5(char x) /* ** g6: -** tbnzx0, 0, .L[0-9]+ +** tbnz[wx]0, 0, .L[0-9]+ ** ret ** ... */ @@ -81,7 +81,7 @@ void g6(char x) /* ** g7: -** tst x0, 3 +** tst [wx]0, 3 ** bne .L[0-9]+ ** ret ** ... @@ -94,7 +94,7 @@ void g7(char x) /* ** g8: -** tbnzx0, 7, .L[0-9]+ +** tbnz[wx]0, 7, .L[0-9]+ ** ret ** ... */ @@ -106,7 +106,7 @@ void g8(char x) /* ** g9: -** tbnzw0, 0, .L[0-9]+ +** tbnz[wx]0, 0, .L[0-9]+ ** ret ** ... */ @@ -118,7 +118,7 @@ void g9(bool x) /* ** g10: -** tbnzw0, 0, .L[0-9]+ +** tbnz[wx]0, 0, .L[0-9]+ ** ret ** ... */
[gcc r15-7959] contrib: Add cobol to bug_components.
https://gcc.gnu.org/g:1a9f6c1e95fff745e54bbb75f1f8ca36ede81f3d commit r15-7959-g1a9f6c1e95fff745e54bbb75f1f8ca36ede81f3d Author: Jakub Jelinek Date: Tue Mar 11 14:30:50 2025 +0100 contrib: Add cobol to bug_components. Without this we can't commit anything refering to cobol/NN PRs. 2025-03-11 Jakub Jelinek * gcc-changelog/git_commit.py (bug_components): Add cobol. Diff: --- contrib/gcc-changelog/git_commit.py | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/gcc-changelog/git_commit.py b/contrib/gcc-changelog/git_commit.py index fda5cf597263..5645f80ebb9b 100755 --- a/contrib/gcc-changelog/git_commit.py +++ b/contrib/gcc-changelog/git_commit.py @@ -93,6 +93,7 @@ bug_components = { 'bootstrap', 'c', 'c++', +'cobol', 'd', 'debug', 'demangler',
[gcc r15-7962] s390: fix delegitimization of addresses
https://gcc.gnu.org/g:4001281d69e9f8e01d2183f0e931e15ec4a522eb commit r15-7962-g4001281d69e9f8e01d2183f0e931e15ec4a522eb Author: Juergen Christ Date: Mon Mar 10 10:03:36 2025 +0100 s390: fix delegitimization of addresses In legitimize_pic_address we create a (const (unspec ... UNSPEC_GOTENT)) in the GOT offset might be >= 4k. However, the s390_delegitimize_address does not contain a case for this scenario. gcc/ChangeLog: * config/s390/s390.cc (s390_delegitimize_address): Add missing case. gcc/testsuite/ChangeLog: * gcc.target/s390/delegitimize-1.c: New test. Signed-off-by: Juergen Christ Diff: --- gcc/config/s390/s390.cc| 15 +++ gcc/testsuite/gcc.target/s390/delegitimize-1.c | 22 ++ 2 files changed, 37 insertions(+) diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc index 645aedba67f0..d4e849b12de6 100644 --- a/gcc/config/s390/s390.cc +++ b/gcc/config/s390/s390.cc @@ -8238,6 +8238,21 @@ s390_delegitimize_address (rtx orig_x) return plus_constant (Pmode, XVECEXP (y, 0, 0), offset); } + if (GET_CODE (x) == CONST) +{ + /* Extract the symbol ref from: +(const:DI (unspec:DI [(symbol_ref:DI ("foo"))] + UNSPEC_PLT/GOTENT)) */ + + y = XEXP (x, 0); + if (GET_CODE (y) == UNSPEC + && (XINT (y, 1) == UNSPEC_GOTENT + || XINT (y, 1) == UNSPEC_PLT31)) + return XVECEXP (y, 0, 0); + else + return orig_x; +} + if (GET_CODE (x) != MEM) return orig_x; diff --git a/gcc/testsuite/gcc.target/s390/delegitimize-1.c b/gcc/testsuite/gcc.target/s390/delegitimize-1.c new file mode 100644 index ..5c49565db2f4 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/delegitimize-1.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-m64 -fPIC -O2 -g -fdump-rtl-final-details" } */ + +struct sk_buff { + struct { +struct { + struct { +int inner_ipproto; + }; +}; + }; +}; +void skb_udp_tunnel_segment(struct sk_buff *skb); +const int *inet_offloads[42], *inet6_offloads[42]; +_Bool skb_udp_tunnel_segment_is_ipv6; +void skb_udp_tunnel_segment(struct sk_buff *skb) { + const int **offloads = + skb_udp_tunnel_segment_is_ipv6 ? inet6_offloads : inet_offloads; + *(volatile typeof(_Generic(0, default : 0)) *)&offloads[skb->inner_ipproto]; +} + +/* { dg-final { scan-rtl-dump-not "Failed to expand as dwarf:" "final" } } */
[gcc r15-7960] cobol: Fix up libgcobol configure [PR119216]
https://gcc.gnu.org/g:09c2a0ab94e1e731433eb2687ad16a9c79617e14 commit r15-7960-g09c2a0ab94e1e731433eb2687ad16a9c79617e14 Author: Jakub Jelinek Date: Tue Mar 11 14:34:01 2025 +0100 cobol: Fix up libgcobol configure [PR119216] Sorry, seems I've screwed up the earlier libgcobol/configure.tgt change. Looking in more detail, the way e.g. libsanitizer/configure.tgt works is that it is sourced twice, once at toplevel and there it just sets UNSUPPORTED=1 for fully unsupported triplets, and then inside of libsanitizer/configure where it decides to include or not include the various sublibraries depending on the *_SUPPORTED flags. So, the following patch attempts to do the same for libgcobol as well. The BIULD_LIBGCOBOL automake conditional was unused, this patch guards it on LIBGCOBOL_SUPPORTED as well and guards with it toolexeclib_LTLIBRARIES = libgcobol.la Also, AM_CFLAGS has been changed to AM_CXXFLAGS as there are just C++ sources in the library. 2025-03-11 Jakub Jelinek PR cobol/119216 * configure.ac: Check for UNSUPPORTED set by libgcobol/configure.tgt rather than LIBGCOBOL_SUPPORTED. * configure: Regenerate. libgcobol/ * configure.tgt: On fully unsupported targets set UNSUPPORTED=1. * configure.ac: Add AC_CHECK_SIZEOF([void *]), source in configure.tgt and set BUILD_LIBGCOBOL also based on LIBGCOBOL_SUPPORTED. * Makefile.am (toolexeclib_LTLIBRARIES): Conditionalize on BUILD_LIBGCOBOL. (AM_CFLAGS): Rename to ... (AM_CXXFLAGS): ... this. (%.lo: %.cc): Use $(AM_CXXFLAGS) rather than $(AM_CFLAGS). * configure: Regenerate. * Makefile.in: Regenerate. Diff: --- configure | 2 +- configure.ac| 2 +- libgcobol/Makefile.am | 6 +- libgcobol/Makefile.in | 9 +- libgcobol/configure | 229 ++-- libgcobol/configure.ac | 10 ++- libgcobol/configure.tgt | 3 + 7 files changed, 245 insertions(+), 16 deletions(-) diff --git a/configure b/configure index 4666c86c5f09..59a2a29e8799 100755 --- a/configure +++ b/configure @@ -3546,7 +3546,7 @@ if test -d ${srcdir}/libgcobol; then $as_echo_n "checking for libgcobol support... " >&6; } if (srcdir=${srcdir}/libgcobol; \ . ${srcdir}/configure.tgt; \ - test "$LIBGCOBOL_SUPPORTED" != "yes") + test -n "$UNSUPPORTED") then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } diff --git a/configure.ac b/configure.ac index a1b3604dd812..8967423ccdcf 100644 --- a/configure.ac +++ b/configure.ac @@ -768,7 +768,7 @@ if test -d ${srcdir}/libgcobol; then AC_MSG_CHECKING([for libgcobol support]) if (srcdir=${srcdir}/libgcobol; \ . ${srcdir}/configure.tgt; \ - test "$LIBGCOBOL_SUPPORTED" != "yes") + test -n "$UNSUPPORTED") then AC_MSG_RESULT([no]) noconfigdirs="$noconfigdirs target-libgcobol" diff --git a/libgcobol/Makefile.am b/libgcobol/Makefile.am index 7f21fdc24c9a..bee294e0c9de 100644 --- a/libgcobol/Makefile.am +++ b/libgcobol/Makefile.am @@ -22,7 +22,9 @@ AUTOMAKE_OPTIONS = 1.8 foreign ACLOCAL_AMFLAGS = -I .. -I ../config +if BUILD_LIBGCOBOL toolexeclib_LTLIBRARIES = libgcobol.la +endif ## ## 2.2.12 Automatic Dependency Tracking @@ -48,10 +50,10 @@ libgcobol_la_LINK = $(LIBTOOL) --mode=link --tag=CXX $(CXX) \ WARN_CFLAGS = -W -Wall -Wwrite-strings # not defined: DEFS, MAX_ERRORS, LTLDFLAGS -ALL_CFLAGS = -I. -I$(srcdir) $(AM_CPPFLAGS) $(DEFS)\ +ALL_CXXFLAGS = -I. -I$(srcdir) $(AM_CPPFLAGS) $(DEFS) \ $(XCFLAGS) $(AM_CXXFLAGS) $(WARN_CFLAGS) $(MAX_ERRORS) \ -DIN_GCC -DIN_TARGET_LIBS -fno-strict-aliasing %.lo: %.cc $(LIBTOOL) --mode=compile --tag=CXX $(CXX) -c \ - -o $@ $(INCLUDES) $(ALL_CFLAGS) $< + -o $@ $(INCLUDES) $(ALL_CXXFLAGS) $< diff --git a/libgcobol/Makefile.in b/libgcobol/Makefile.in index ddd8cbe89413..c93e9246e378 100644 --- a/libgcobol/Makefile.in +++ b/libgcobol/Makefile.in @@ -168,6 +168,7 @@ libgcobol_la_LIBADD = am_libgcobol_la_OBJECTS = charmaps.lo constants.lo gfileio.lo gmath.lo \ intrinsic.lo io.lo libgcobol.lo valconv.lo libgcobol_la_OBJECTS = $(am_libgcobol_la_OBJECTS) +@BUILD_LIBGCOBOL_TRUE@am_libgcobol_la_rpath = -rpath $(toolexeclibdir) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -402,7 +403,7 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = 1.8 foreign ACLOCAL_AMFLAGS = -I .. -I ../config -toolexeclib_LTLIBRARIES = libgcobol.la +@BUILD_LIBGCOBOL_TRUE@toolexeclib_LTLIBRARIES = libgcobol.la libgcobol_la_SOURCES = \ charmaps.cc
[gcc r15-7964] Abstract interfaces and dummy arguments are not global.
https://gcc.gnu.org/g:64a551f730564af58c83d2748436c9d90543fe1a commit r15-7964-g64a551f730564af58c83d2748436c9d90543fe1a Author: Thomas Koenig Date: Tue Mar 11 17:40:57 2025 +0100 Abstract interfaces and dummy arguments are not global. The attached patch makes sure that procedures from abstract interfaces and dummy arguments are not put into the global symbol table, and are not checked against global symbols. gcc/fortran/ChangeLog: PR fortran/119078 * frontend-passes.cc (check_against_globals): Do not check for abstract interfaces or dummy arguments. * resolve.cc (gfc_verify_binding_labels): Adjust comment. Do not put abstract interfaces or dummy argument into global namespace. gcc/testsuite/ChangeLog: PR fortran/119078 * gfortran.dg/interface_58.f90: New test. Diff: --- gcc/fortran/frontend-passes.cc | 3 ++- gcc/fortran/resolve.cc | 6 +++-- gcc/testsuite/gfortran.dg/interface_58.f90 | 38 ++ 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/gcc/fortran/frontend-passes.cc b/gcc/fortran/frontend-passes.cc index 20bf6e127ffc..ef9c80147cc4 100644 --- a/gcc/fortran/frontend-passes.cc +++ b/gcc/fortran/frontend-passes.cc @@ -5799,7 +5799,8 @@ check_against_globals (gfc_symbol *sym) char buf [200]; if (sym->attr.if_source != IFSRC_IFBODY || sym->attr.flavor != FL_PROCEDURE - || sym->attr.generic || sym->error) + || sym->attr.generic || sym->error || sym->attr.abstract + || sym->attr.dummy) return; if (sym->binding_label) diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index eda31ba8adc3..027c99335d15 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -13883,7 +13883,8 @@ gfc_verify_DTIO_procedures (gfc_symbol *sym) /* Verify that any binding labels used in a given namespace do not collide with the names or binding labels of any global symbols. Multiple INTERFACE - for the same procedure are permitted. */ + for the same procedure are permitted. Abstract interfaces and dummy + arguments are not checked. */ static void gfc_verify_binding_labels (gfc_symbol *sym) @@ -13892,7 +13893,8 @@ gfc_verify_binding_labels (gfc_symbol *sym) const char *module; if (!sym || !sym->attr.is_bind_c || sym->attr.is_iso_c - || sym->attr.flavor == FL_DERIVED || !sym->binding_label) + || sym->attr.flavor == FL_DERIVED || !sym->binding_label + || sym->attr.abstract || sym->attr.dummy) return; gsym = gfc_find_case_gsymbol (gfc_gsym_root, sym->binding_label); diff --git a/gcc/testsuite/gfortran.dg/interface_58.f90 b/gcc/testsuite/gfortran.dg/interface_58.f90 new file mode 100644 index ..52f3651567fa --- /dev/null +++ b/gcc/testsuite/gfortran.dg/interface_58.f90 @@ -0,0 +1,38 @@ +! { dg-do compile } +! PR 119078 - there should be no warning for dummy arguments +! or abstract interfaces. +module x + implicit none + abstract interface + subroutine foo() bind(c) + end subroutine foo + end interface + interface + subroutine baz() bind(c) ! { dg-warning "wrong number of arguments" } + end subroutine baz + end interface +contains + subroutine tescht(bar) bind(c) +interface + subroutine bar() bind(c) + end subroutine bar +end interface + end subroutine tescht + subroutine t2(bar) bind(c) +procedure(foo) :: bar + end subroutine t2 +end module x + +subroutine foo(a) + real :: a +end subroutine foo + +subroutine bar(b) + real :: b +end subroutine bar + +subroutine baz(a) bind(c) ! { dg-warning "wrong number of arguments" } + use iso_c_binding, only : c_int + integer(c_int) :: a +end subroutine baz +
[gcc r15-7965] aarch64: XFAIL pred-not-gen-[14].c [PR118956]
https://gcc.gnu.org/g:09205680054ca6dd7cf3bb96ef08f15006d89cff commit r15-7965-g09205680054ca6dd7cf3bb96ef08f15006d89cff Author: Richard Sandiford Date: Tue Mar 11 16:46:21 2025 + aarch64: XFAIL pred-not-gen-[14].c [PR118956] gcc.target/aarch64/sve/pred-not-gen-[14].c started failing after r15-268-g9dbff9c05520a74e, but we didn't look at it in time for GCC 15. This patch marks the failures as expected for now. We should revisit for GCC 16. See the PR for some discussion about what a GCC 16 fix might look like. gcc/testusite/ PR target/118956 * gcc.target/aarch64/sve/pred-not-gen-1.c: Add XFAILs. * gcc.target/aarch64/sve/pred-not-gen-4.c: Likewise. Diff: --- gcc/testsuite/gcc.target/aarch64/sve/pred-not-gen-1.c | 4 ++-- gcc/testsuite/gcc.target/aarch64/sve/pred-not-gen-4.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gcc/testsuite/gcc.target/aarch64/sve/pred-not-gen-1.c b/gcc/testsuite/gcc.target/aarch64/sve/pred-not-gen-1.c index c9a8b82c48ac..a7d2795ebe23 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/pred-not-gen-1.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/pred-not-gen-1.c @@ -19,6 +19,6 @@ void f10(double * restrict z, double * restrict w, double * restrict x, double * } } -/* { dg-final { scan-assembler-not {\tbic\t} } } */ -/* { dg-final { scan-assembler-times {\tnot\tp[0-9]+\.b, p[0-9]+/z, p[0-9]+\.b\n} 1 } } */ +/* { dg-final { scan-assembler-not {\tbic\t} { xfail *-*-* } } } */ +/* { dg-final { scan-assembler-times {\tnot\tp[0-9]+\.b, p[0-9]+/z, p[0-9]+\.b\n} 1 { xfail *-*-* } } } */ /* { dg-final { scan-assembler-times {\tfcmgt\tp[0-9]+\.d, p[0-9]+/z, z[0-9]+\.d, #0} 1 } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/sve/pred-not-gen-4.c b/gcc/testsuite/gcc.target/aarch64/sve/pred-not-gen-4.c index 1845bd3f0f70..20cbd7550b7e 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/pred-not-gen-4.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/pred-not-gen-4.c @@ -8,6 +8,6 @@ void f13(double * restrict z, double * restrict w, double * restrict x, double * } } -/* { dg-final { scan-assembler-not {\tbic\t} } } */ -/* { dg-final { scan-assembler-times {\tnot\tp[0-9]+\.b, p[0-9]+/z, p[0-9]+\.b\n} 1 } } */ +/* { dg-final { scan-assembler-not {\tbic\t} { xfail *-*-* } } } */ +/* { dg-final { scan-assembler-times {\tnot\tp[0-9]+\.b, p[0-9]+/z, p[0-9]+\.b\n} 1 { xfail *-*-* } } } */ /* { dg-final { scan-assembler-times {\tfcmuo\tp[0-9]+\.d, p[0-9]+/z, z[0-9]+\.d, z[0-9]+\.d} 1 } } */
[gcc r15-7944] s390: Implement TARGET_INSN_COST [PR115835]
https://gcc.gnu.org/g:229f4f040485c0c05cfb707b30c9b983ed1f95d3 commit r15-7944-g229f4f040485c0c05cfb707b30c9b983ed1f95d3 Author: Stefan Schulze Frielinghaus Date: Tue Mar 11 08:59:15 2025 +0100 s390: Implement TARGET_INSN_COST [PR115835] Currently insn_cost() only considers the source part of a SET. Implement TARGET_INSN_COST in order to also take the destination into account. This may make a difference in case of a MEM where the address is a SYMBOL_REF. Fixes testsuite/gcc.target/s390/section-anchors.c. gcc/ChangeLog: PR target/115835 * config/s390/s390.cc (s390_insn_cost): Implement. (TARGET_INSN_COST): Define. Diff: --- gcc/config/s390/s390.cc | 22 ++ 1 file changed, 22 insertions(+) diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc index 29aef501fdd2..2f516967e7b1 100644 --- a/gcc/config/s390/s390.cc +++ b/gcc/config/s390/s390.cc @@ -3900,6 +3900,26 @@ s390_memory_move_cost (machine_mode mode ATTRIBUTE_UNUSED, return 2; } +/* Implement TARGET_INSN_COST. */ + +static int +s390_insn_cost (rtx_insn *insn, bool speed) +{ + /* For stores also consider the destination. Penalize if the address + contains a SYMBOL_REF since this has to be fixed up by reload. */ + rtx pat = single_set (insn); + if (pat && MEM_P (SET_DEST (pat))) +{ + rtx mem = SET_DEST (pat); + rtx addr = XEXP (mem, 0); + int penalty = contains_symbol_ref_p (addr) ? COSTS_N_INSNS (1) : 0; + int src_cost = set_src_cost (SET_SRC (pat), GET_MODE (mem), speed); + src_cost = src_cost > 0 ? src_cost : COSTS_N_INSNS (1); + return penalty + src_cost; +} + return pattern_cost (PATTERN (insn), speed); +} + /* Compute a (partial) cost for rtx X. Return true if the complete cost has been computed, and false if subexpressions should be scanned. In either case, *TOTAL contains the cost result. The @@ -18355,6 +18375,8 @@ s390_c_mode_for_floating_type (enum tree_index ti) #undef TARGET_CANNOT_COPY_INSN_P #define TARGET_CANNOT_COPY_INSN_P s390_cannot_copy_insn_p +#undef TARGET_INSN_COST +#define TARGET_INSN_COST s390_insn_cost #undef TARGET_RTX_COSTS #define TARGET_RTX_COSTS s390_rtx_costs #undef TARGET_ADDRESS_COST
[gcc r15-7953] One more libgcobol/configure.tgt tweak
https://gcc.gnu.org/g:35ba44f5eca80679e2d61fcb0169a182df9bd073 commit r15-7953-g35ba44f5eca80679e2d61fcb0169a182df9bd073 Author: Jakub Jelinek Date: Tue Mar 11 11:48:35 2025 +0100 One more libgcobol/configure.tgt tweak On Tue, Mar 11, 2025 at 10:45:09AM +0100, Andreas Schwab wrote: > I think that makes the x32 match obsolete. You're right. I've already committed the patch, so here is incremental one. 2025-03-11 Jakub Jelinek * configure.tgt: Remove x86_64-*-linux*x32 special case. Diff: --- libgcobol/configure.tgt | 3 --- 1 file changed, 3 deletions(-) diff --git a/libgcobol/configure.tgt b/libgcobol/configure.tgt index fe6f3dad396f..892934584d6b 100644 --- a/libgcobol/configure.tgt +++ b/libgcobol/configure.tgt @@ -34,9 +34,6 @@ case "${target}" in LIBGCOBOL_SUPPORTED=yes fi ;; -x86_64-*-linux*x32) - LIBGCOBOL_SUPPORTED=no - ;; x86_64-*-linux* | i?86-*-linux*) if test x$ac_cv_sizeof_void_p = x8; then LIBGCOBOL_SUPPORTED=yes
[gcc r15-7948] Make libgcobol/configure.tgt more similar to other libraries
https://gcc.gnu.org/g:8e1efc3c864928e3447880caceddb6fa0d45bc46 commit r15-7948-g8e1efc3c864928e3447880caceddb6fa0d45bc46 Author: Jakub Jelinek Date: Tue Mar 11 11:05:13 2025 +0100 Make libgcobol/configure.tgt more similar to other libraries When we know libgcobol is unsupported on 32-bit arches, we should just say so in configure.tgt, the same way as on other targets. 2025-03-11 Jakub Jelinek * configure.tgt: Only set LIBGCOBOL_SUPPORTED for lp64 multilibs of powerpc64le-*-linux* and x86_64-*-linux*. Handle i?86-*-linux* the same as x86_64-*-linux*. Diff: --- libgcobol/configure.tgt | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libgcobol/configure.tgt b/libgcobol/configure.tgt index a64539c919fa..fe6f3dad396f 100644 --- a/libgcobol/configure.tgt +++ b/libgcobol/configure.tgt @@ -30,12 +30,16 @@ case "${target}" in LIBGCOBOL_SUPPORTED=yes ;; powerpc64le-*-linux*) - LIBGCOBOL_SUPPORTED=yes + if test x$ac_cv_sizeof_void_p = x8; then + LIBGCOBOL_SUPPORTED=yes + fi ;; x86_64-*-linux*x32) LIBGCOBOL_SUPPORTED=no ;; -x86_64-*-linux*) - LIBGCOBOL_SUPPORTED=yes +x86_64-*-linux* | i?86-*-linux*) + if test x$ac_cv_sizeof_void_p = x8; then + LIBGCOBOL_SUPPORTED=yes + fi ;; esac
[gcc r15-7951] configure, Darwin: Require explicit selection of COBOL.
https://gcc.gnu.org/g:6a3f9f30d93c376a8a5e98be888da14923b85e63 commit r15-7951-g6a3f9f30d93c376a8a5e98be888da14923b85e63 Author: Iain Sandoe Date: Tue Mar 11 09:56:18 2025 + configure, Darwin: Require explicit selection of COBOL. By defult, Darwin does not have sufficient tools to build COBOL so we do not want to include it in --enable-languages=all since this will break regular testing of all supported languages. However, we do want to be able to build it on demand (where the build system has sufficiently new tools) and so do not want to disable it permanently. ChangeLog: * configure: Regenerate. * configure.ac: Do not build COBOL on Darwin by default, even for --enable-languages=all. Signed-off-by: Iain Sandoe Diff: --- configure| 7 +-- configure.ac | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 2a91458effc0..4666c86c5f09 100755 --- a/configure +++ b/configure @@ -3585,11 +3585,14 @@ case ,${enable_languages}, in ;; *) case "${target}" in + *-*-darwin*) +unsupported_languages="$unsupported_languages cobol" +;; x86_64-*-*|aarch64-*-*) ;; *-*-*) - unsupported_languages="$unsupported_languages cobol" - ;; +unsupported_languages="$unsupported_languages cobol" +;; esac case "${host}" in x86_64-*-*|aarch64-*-*) diff --git a/configure.ac b/configure.ac index 414578566faf..a1b3604dd812 100644 --- a/configure.ac +++ b/configure.ac @@ -805,6 +805,9 @@ case ,${enable_languages}, in ;; *) case "${target}" in + *-*-darwin*) +unsupported_languages="$unsupported_languages cobol" +;; x86_64-*-*|aarch64-*-*) ;; *-*-*)
[gcc r15-7954] arm: testsuite: fix arm_neon_h checks with conflicting cpu/arch
https://gcc.gnu.org/g:1b7a05770833eb210783ec8babd0027ec237d191 commit r15-7954-g1b7a05770833eb210783ec8babd0027ec237d191 Author: Richard Earnshaw Date: Tue Mar 11 10:48:54 2025 + arm: testsuite: fix arm_neon_h checks with conflicting cpu/arch GCC will complain if the -mcpu flag specifies a different architecture to that specified in -march, but if the floating-point ABI is "soft", then differences in the floating-point architecture features are ignored. However, the arm_libc_fp_abi checks whether we change the FP ABI by adding -mfloat-abi=hard/softfp to override the defaults. If that fails it won't add anything. Unfortunately arm_neon_h_ok wasn't correctly checking whether the libc check had worked and just assumed that it would always add something to enable FP. That's insufficient and we need to consider this failure. We simply mark tests as unsupported in this case. gcc/testsuite/ChangeLog: * lib/target-supports.exp (check_effective_target_arm_neon_h_ok_nocache): Return zero if check_effective_target_arm_libc_fp_abi_ok reports failure. Diff: --- gcc/testsuite/lib/target-supports.exp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index a184ef37ccb4..c456f7d2c6fa 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -5167,7 +5167,8 @@ proc add_options_for_arm_libc_fp_abi { flags } { proc check_effective_target_arm_neon_h_ok_nocache { } { # none-arm or thumb1 cannot support neon, so there's no point in # looking further. -if { [istarget arm*-*-*] } { +if { [istarget arm*-*-*] +&& [check_effective_target_arm_libc_fp_abi_ok]} { global et_arm_neon_h_flags set base_flags [add_options_for_arm_libc_fp_abi ""] foreach flags {"" "-mfpu=auto" "-marm" "-marm -mfpu=auto" \
[gcc r15-7957] i386: Verify that argument registers are spilled properly
https://gcc.gnu.org/g:06440e726acfa9c9695a07dc524a832a53057ad6 commit r15-7957-g06440e726acfa9c9695a07dc524a832a53057ad6 Author: H.J. Lu Date: Sun Mar 9 07:00:23 2025 -0700 i386: Verify that argument registers are spilled properly While working on a local x86 patch, which passed the GCC testsuite, I got a compiler error: In function ‘paravirt_read_msr’, inlined from ‘perf_ibs_handle_irq’ at arch/x86/events/amd/ibs.c:1055:2: ./arch/x86/include/asm/paravirt_types.h:397:17: error: ‘asm’ operand has impossible constraints or there are not enough registers 397 | asm volatile(ALTERNATIVE(PARAVIRT_CALL, ALT_CALL_INSTR, \ | ^~~ when building x86-64 Linux kernel. RDI, RSI, RDX and RCX registers are used to pass arguments in 64-bit mode. EAX, EDX and ECX registers are used to pass arguments in 32-bit mode. But there is no coverage in the GCC testsuite. Add tests to verify that argument registers are spilled properly. PR target/119171 * gcc.target/i386/pr119171-1.c: New test. * gcc.target/i386/pr119171-2.c: Likewise. Signed-off-by: H.J. Lu Diff: --- gcc/testsuite/gcc.target/i386/pr119171-1.c | 14 ++ gcc/testsuite/gcc.target/i386/pr119171-2.c | 13 + 2 files changed, 27 insertions(+) diff --git a/gcc/testsuite/gcc.target/i386/pr119171-1.c b/gcc/testsuite/gcc.target/i386/pr119171-1.c new file mode 100644 index ..a017e6e215f4 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr119171-1.c @@ -0,0 +1,14 @@ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O2" } */ + +extern long a1, a2, a3, a4; +extern void foo (void *, void *, void *, void *); +void +bar (void *rdi, void *rsi, void *rdx, void *rcx) +{ + asm ("" : "=D"(a1) : "D"(0)); + asm ("" : "=S"(a2) : "S"(0)); + asm ("" : "=d"(a3) : "d"(0)); + asm ("" : "=c"(a4) : "c"(0)); + foo (rdi, rsi, rdx, rcx); +} diff --git a/gcc/testsuite/gcc.target/i386/pr119171-2.c b/gcc/testsuite/gcc.target/i386/pr119171-2.c new file mode 100644 index ..5c209f9aed07 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr119171-2.c @@ -0,0 +1,13 @@ +/* { dg-do compile { target ia32 } } */ +/* { dg-options "-O2 -mregparm=3" } */ + +extern long a1, a2, a3; +extern void foo (void *, void *, void *); +void +bar (void *eax, void *edx, void *ecx) +{ + asm ("" : "=a"(a1) : "a"(0)); + asm ("" : "=d"(a2) : "d"(0)); + asm ("" : "=c"(a3) : "c"(0)); + foo (eax, edx, ecx); +}
[gcc r15-7946] complex: Don't DCE unused COMPLEX_EXPRs for -O0 [PR119190]
https://gcc.gnu.org/g:e1da6283a1cbd5db474c0f7e5cca9b9876768199 commit r15-7946-ge1da6283a1cbd5db474c0f7e5cca9b9876768199 Author: Jakub Jelinek Date: Tue Mar 11 10:57:30 2025 +0100 complex: Don't DCE unused COMPLEX_EXPRs for -O0 [PR119190] The PR116463 r15-3128 change regressed the following testcase at -O0. While for -O1+ we can do -fvar-tracking-assignments, for -O0 we don't (partly because it is compile time expensive and partly because at -O0 most of the vars live most of their lifetime in memory slots), so if we DCE some statements, it can mean that DW_AT_location for some vars won't be available or even it won't be possible to put a breakpoint at some particular line in the source. We normally perform dce just in the subpasses of pass_local_optimization_passes or pass_all_optimizations or pass_all_optimizations_g, so don't do that at all for -O0. So the complex change is an exception. And it was described as a way to help forwprop and reassoc, neither applies to -O0. This regresses PR119120 again though, I'll post a patch for that momentarily. 2025-03-11 Jakub Jelinek PR debug/119190 * tree-complex.cc (update_complex_assignment, tree_lower_complex): Perform simple dce on dce_worklist only if optimize. * gfortran.dg/guality/pr119190.f90: New test. Diff: --- gcc/testsuite/gfortran.dg/guality/pr119190.f90 | 13 + gcc/tree-complex.cc| 13 + 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/gcc/testsuite/gfortran.dg/guality/pr119190.f90 b/gcc/testsuite/gfortran.dg/guality/pr119190.f90 new file mode 100644 index ..00ed67ea1e21 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/guality/pr119190.f90 @@ -0,0 +1,13 @@ +! PR debug/119190 +! { dg-do run } +! { dg-options "-g" } + +program foo + integer :: ia, ib + complex :: ci + ia = 1 + ib = 2 + ci = cmplx(ia, ib) + print *, ia + print *, ib ! { dg-final { gdb-test 12 "ci" "(1,2)" } } +end program diff --git a/gcc/tree-complex.cc b/gcc/tree-complex.cc index f54e7e3e443d..8a812d4bf9b0 100644 --- a/gcc/tree-complex.cc +++ b/gcc/tree-complex.cc @@ -735,7 +735,8 @@ update_complex_assignment (gimple_stmt_iterator *gsi, tree r, tree i) update_stmt (stmt); if (maybe_clean_or_replace_eh_stmt (old_stmt, stmt)) bitmap_set_bit (need_eh_cleanup, gimple_bb (stmt)->index); - bitmap_set_bit (dce_worklist, SSA_NAME_VERSION (gimple_assign_lhs (stmt))); + if (optimize) +bitmap_set_bit (dce_worklist, SSA_NAME_VERSION (gimple_assign_lhs (stmt))); update_complex_components (gsi, gsi_stmt (*gsi), r, i); } @@ -1967,7 +1968,8 @@ tree_lower_complex (void) complex_propagate.ssa_propagate (); need_eh_cleanup = BITMAP_ALLOC (NULL); - dce_worklist = BITMAP_ALLOC (NULL); + if (optimize) +dce_worklist = BITMAP_ALLOC (NULL); complex_variable_components = new int_tree_htab_type (10); @@ -2014,8 +2016,11 @@ tree_lower_complex (void) gsi_commit_edge_inserts (); - simple_dce_from_worklist (dce_worklist, need_eh_cleanup); - BITMAP_FREE (dce_worklist); + if (optimize) +{ + simple_dce_from_worklist (dce_worklist, need_eh_cleanup); + BITMAP_FREE (dce_worklist); +} unsigned todo = gimple_purge_all_dead_eh_edges (need_eh_cleanup) ? TODO_cleanup_cfg : 0;
[gcc r15-7947] tree: Improve skip_simple_arithmetic [PR119183]
https://gcc.gnu.org/g:20e5aa9cc1519f871cce25dbfdc149d9d60da779 commit r15-7947-g20e5aa9cc1519f871cce25dbfdc149d9d60da779 Author: Jakub Jelinek Date: Tue Mar 11 11:01:55 2025 +0100 tree: Improve skip_simple_arithmetic [PR119183] The following testcase takes very long time to compile, because skip_simple_arithmetic decides to first call tree_invariant_p on the second argument (and indirectly recurse there). I think before canonicalization of operands for commutative binary expressions (and for non-commutative ones always) it is pretty common that the first operand is a constant, something which tree_invariant_p handles immediately, so the following patch special cases that; I've added there a tree_invariant_p call too after the checks, while it is not really needed currently, tree_invariant_p has the same checks, I wanted to be prepared in case tree_invariant_p changes. But if you think I should avoid it, I can drop it too. This is just a partial fix, I think one can certainly construct a testcase which will still have horrible compile time complexity (but I've tried and haven't managed to do so), so perhaps we should just limit the recursion depth through skip_simple_arithmetic/tree_invariant_p with some defaulted argument. 2025-03-11 Jakub Jelinek PR c/119183 * tree.cc (skip_simple_arithmetic): If first operand of binary expr is TREE_CONSTANT or TREE_READONLY with no side-effects, call tree_invariant_p on that operand first instead of on the second. * gcc.dg/pr119183.c: New test. Diff: --- gcc/testsuite/gcc.dg/pr119183.c | 12 gcc/tree.cc | 14 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.dg/pr119183.c b/gcc/testsuite/gcc.dg/pr119183.c new file mode 100644 index ..a98d77907731 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr119183.c @@ -0,0 +1,12 @@ +/* PR c/119183 */ +/* { dg-do compile } */ + +int foo (void); +#define A(x) (1.0f * (1.0f * (1.0f * (1.0f * (1.0f * (1.0f * (1.0f * (1.0f * (x) + +float +bar (float r) +{ + r += A (A (A (A (A (A (A (A (foo (); + return r; +} diff --git a/gcc/tree.cc b/gcc/tree.cc index a35b4dbe6557..eccfcc89da40 100644 --- a/gcc/tree.cc +++ b/gcc/tree.cc @@ -4105,7 +4105,19 @@ skip_simple_arithmetic (tree expr) expr = TREE_OPERAND (expr, 0); else if (BINARY_CLASS_P (expr)) { - if (tree_invariant_p (TREE_OPERAND (expr, 1))) + /* Before commutative binary operands are canonicalized, +it is quite common to have constants in the first operand. +Check for that common case first so that we don't walk +large expressions with tree_invariant_p unnecessarily. +This can still have terrible compile time complexity, +we should limit the depth of the tree_invariant_p and +skip_simple_arithmetic recursion. */ + if ((TREE_CONSTANT (TREE_OPERAND (expr, 0)) + || (TREE_READONLY (TREE_OPERAND (expr, 0)) + && !TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 0 + && tree_invariant_p (TREE_OPERAND (expr, 0))) + expr = TREE_OPERAND (expr, 1); + else if (tree_invariant_p (TREE_OPERAND (expr, 1))) expr = TREE_OPERAND (expr, 0); else if (tree_invariant_p (TREE_OPERAND (expr, 0))) expr = TREE_OPERAND (expr, 1);
[gcc r15-7949] cobol: Use *.cc suffix for bison/flex generated C++ files
https://gcc.gnu.org/g:3f717f9565c5c40bcaa1e0b5419fe5bf65ad7f1c commit r15-7949-g3f717f9565c5c40bcaa1e0b5419fe5bf65ad7f1c Author: Jakub Jelinek Date: Tue Mar 11 11:07:15 2025 +0100 cobol: Use *.cc suffix for bison/flex generated C++ files In GCC 12 we've switched to using *.cc suffixes for C++ sources in GCC sources, including generated files, instead of using *.c suffixes and compiling them as C++ anyway (that was the case since we've switched GCC to C++ in GCC 4.8). I've noticed gcc/cobol has 3 generated files still with c extension despite clearly having C++ code in it and being compiled as C++. 2025-03-11 Jakub Jelinek * Make-lang.in (cobol/parse.c, cobol/cdf.c, cobol/scan.c): Remove. (cobol/parse.cc, cobol/cdf.cc, cobol/scan.cc): New goals. (cobol/cdf.o): Depend on cobol/cdf.cc rather than cobol/cdf.c. (cobol/parse.o): Depend on cobol/parse.cc rather than cobol/parse.c. (cobol/scan.o): Depend on cobol/scan.cc rather than cobol/scan.c, on cobol/cdf.cc rather than cobol/cdf.c and on cobol/parse.cc rather than cobol/parse.c. (cobol.srcextra): Depend on cobol/parse.cc cobol/cdf.cc cobol/scan.cc rather than cobol/parse.c cobol/cdf.c cobol/scan.c. Diff: --- gcc/cobol/Make-lang.in | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/gcc/cobol/Make-lang.in b/gcc/cobol/Make-lang.in index 8cc837eabf39..1d98c25342a9 100644 --- a/gcc/cobol/Make-lang.in +++ b/gcc/cobol/Make-lang.in @@ -150,12 +150,12 @@ gcobol$(exeext): \ # First, files needed for parsing: -cobol/parse.c: cobol/parse.y +cobol/parse.cc: cobol/parse.y $(BISON) -o $@ $(YFLAGS)\ --defines=cobol/parse.h \ --report-file=cobol/parser.out $< -cobol/cdf.c: cobol/cdf.y +cobol/cdf.cc: cobol/cdf.y $(BISON) -o $@ $(YFLAGS) \ --defines=cobol/cdf.h --report-file=cobol/cdf.out $< @@ -163,7 +163,7 @@ cobol/cdf.c: cobol/cdf.y # in Flex manual. We suppress those messages, as a convenience. FLEX_WARNING = warning, dangerous trailing context -cobol/scan.c: cobol/scan.l +cobol/scan.cc: cobol/scan.l $(FLEX) -o$@ $(LFLAGS) $< >$@~ 2>&1 awk '! /$(FLEX_WARNING)/ {print > "/dev/stderr"; nerr++} \ END {print "$(FLEX):", NR, "messages" > "/dev/stderr"; \ @@ -179,9 +179,9 @@ cobol/scan.c: cobol/scan.l # The below lists of include files for the the generated files is # postprocessed: the files are one per line, used "realpath # --relative-to=$PWD" to rationalize them, and sorted. We include -# parse.c in the list for scan.o because that's the one make(1) knows about. +# parse.cc in the list for scan.o because that's the one make(1) knows about. -cobol/cdf.o: cobol/cdf.c \ +cobol/cdf.o: cobol/cdf.cc \ $(srcdir)/cobol/cbldiag.h \ $(srcdir)/cobol/cdfval.h\ $(srcdir)/cobol/copybook.h \ @@ -192,7 +192,7 @@ cobol/cdf.o: cobol/cdf.c\ $(srcdir)/../libgcobol/ec.h \ $(srcdir)/../libgcobol/exceptl.h -cobol/parse.o: cobol/parse.c \ +cobol/parse.o: cobol/parse.cc \ $(srcdir)/cobol/cbldiag.h \ $(srcdir)/cobol/cdfval.h\ $(srcdir)/cobol/cobol-system.h \ @@ -217,7 +217,7 @@ cobol/parse.o: cobol/parse.c\ auto-host.h \ config.h -cobol/scan.o: cobol/scan.c \ +cobol/scan.o: cobol/scan.cc\ $(srcdir)/cobol/cbldiag.h \ $(srcdir)/cobol/cdfval.h\ $(srcdir)/cobol/cobol-system.h \ @@ -243,8 +243,8 @@ cobol/scan.o: cobol/scan.c \ $(srcdir)/../libgcobol/io.h \ auto-host.h \ config.h\ - cobol/cdf.c \ - cobol/parse.c + cobol/cdf.cc\ + cobol/parse.cc # # The src targets are executed if @@ -260,7 +260,7 @@ cobol/scan.o: cobol/scan.c \ # not require Bison. Release tarballs always include Flex/Bison # output, and do not require those tools to be installed. # -cobol.srcextra: cobol/parse.c cobol/cdf.c cobol/scan.c +cobol.srcextra: cobol/parse.cc cobol/cdf.cc cobol/scan.cc ln -f $^ cobol/parse.h cobol/cdf.h $(srcdir)/cobol/
[gcc r15-7950] cobol: Fix --enable-link-serialization build
https://gcc.gnu.org/g:8e8546d1260fca932b0bfaaa7e200ecaeae46c48 commit r15-7950-g8e8546d1260fca932b0bfaaa7e200ecaeae46c48 Author: Jakub Jelinek Date: Tue Mar 11 11:08:27 2025 +0100 cobol: Fix --enable-link-serialization build --enable-link-serialization relies on each FE participating properly, setting .serial, depending on $(.prev) and printing progress. The configure option is mainly for LTO bootstraps when we don't want to link all the FEs at once because that can consume too much memory. The comment changes are unrelated, just something I've spotted while working on this. .exe is a Windows suffix, so either we shouldn't talk about suffixes in the comments or use there $(exeext) as well to make it clear that it is dependent on the host/build. 2025-03-11 Jakub Jelinek * Make-lang.in: Remove .exe extension from comments. (cobol.serial): Set to cobol1$(exeext). (cobol1$(exeext)): Depend on $(cobol.prev). Add LINK_PROGRESS calls before/after the link command. Diff: --- gcc/cobol/Make-lang.in | 15 +-- 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/gcc/cobol/Make-lang.in b/gcc/cobol/Make-lang.in index 1d98c25342a9..a4e005ac2bd2 100644 --- a/gcc/cobol/Make-lang.in +++ b/gcc/cobol/Make-lang.in @@ -38,6 +38,7 @@ gcobol_INSTALL_NAME := $(shell echo gcobol|sed '$(program_transform_name)') gcobol_TARGET_INSTALL_NAME := $(target_noncanonical)-$(shell echo gcobol|sed '$(program_transform_name)') cobol: cobol1$(exeext) +cobol.serial = cobol1$(exeext) .PHONY: cobol BINCLUDE ?= ./gcc @@ -67,7 +68,7 @@ YFLAGS = -Werror -Wmidrule-values -Wno-yacc \ LFLAGS = -d -Ca # -# These are the object files for creating the cobol1.exe compiler: +# These are the object files for creating the cobol1 compiler: # cobol1_OBJS =\ cobol/cdf.o\ @@ -112,7 +113,7 @@ cobol/charmaps.o: cobol/charmaps.cc $(LIB_SOURCE_H) cobol/valconv.o: cobol/valconv.cc $(LIB_SOURCE_H) # -# These are the object files for creating the gcobol.exe "driver" +# These are the object files for creating the gcobol "driver" # GCOBOL_D_OBJS = $(GCC_OBJS) cobol/gcobolspec.o @@ -133,7 +134,7 @@ cobol_OBJS = \ CFLAGS-cobol/gcobolspec.o += $(DRIVER_DEFINES) # -# This controls the build of the gcobol.exe "driver" +# This controls the build of the gcobol "driver" # gcobol$(exeext): \ $(GCOBOL_D_OBJS) \ @@ -145,7 +146,7 @@ gcobol$(exeext): \ $(EXTRA_GCC_LIBS) $(LIBS) # -# These control the build of the cobol1.exe source-to-GENERIC converter +# These control the build of the cobol1 source-to-GENERIC converter # # First, files needed for parsing: @@ -264,11 +265,13 @@ cobol.srcextra: cobol/parse.cc cobol/cdf.cc cobol/scan.cc ln -f $^ cobol/parse.h cobol/cdf.h $(srcdir)/cobol/ -# And the cobol1.exe front end +# And the cobol1 front end -cobol1$(exeext): $(cobol1_OBJS)$(BACKEND) $(LIBDEPS) attribs.o +cobol1$(exeext): $(cobol1_OBJS) $(BACKEND) $(LIBDEPS) attribs.o $(cobol.prev) + @$(call LINK_PROGRESS,$(INDEX.cobol),start) +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) attribs.o -o $@ \ $(cobol1_OBJS) $(BACKEND) $(LIBS) $(BACKENDLIBS) + @$(call LINK_PROGRESS,$(INDEX.cobol),end) # FIXME cobol.all.cross:
[gcc r15-7956] dwarf2out: Fix up DW_AT_language for COBOL
https://gcc.gnu.org/g:86eb3fb520b2a2026f6816ab51b88180b85d6882 commit r15-7956-g86eb3fb520b2a2026f6816ab51b88180b85d6882 Author: Jakub Jelinek Date: Tue Mar 11 12:06:28 2025 +0100 dwarf2out: Fix up DW_AT_language for COBOL Seems the LANG_HOOKS_NAME change for COBOL broke debug info, in particular instead of DW_LANG_Cobol85 it is now DW_LANG_C. 2025-03-11 Jakub Jelinek * dwarf2out.cc (gen_compile_unit_die): Use DW_LANG_Cobol85 if language_string is "GCC COBOL" rather than "Cobol". Diff: --- gcc/dwarf2out.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc index 42f72c1b89dd..e1c353258891 100644 --- a/gcc/dwarf2out.cc +++ b/gcc/dwarf2out.cc @@ -25448,7 +25448,7 @@ gen_compile_unit_die (const char *filename) } else if (strcmp (language_string, "GNU F77") == 0) language = DW_LANG_Fortran77; - else if (strcmp (language_string, "Cobol") == 0) + else if (strcmp (language_string, "GCC COBOL") == 0) language = DW_LANG_Cobol85; else if (strcmp (language_string, "GNU Modula-2") == 0) language = DW_LANG_Modula2;
[gcc r15-7958] cobol: libgcobol/Makefile.am cleanups
https://gcc.gnu.org/g:30efe7c5a0c46179672ce5d80d3c4c3143635dbc commit r15-7958-g30efe7c5a0c46179672ce5d80d3c4c3143635dbc Author: Jakub Jelinek Date: Tue Mar 11 14:25:19 2025 +0100 cobol: libgcobol/Makefile.am cleanups Looking at libgcobol.la, I see a lot of cruft, stuff that just shouldn't be there because automake generates it otherwise right, but also stuff using undefined variables etc. libgcobol.{a,so*} seems to build and install the same as before. Note, I stull see DT_RUNPATH in the installed libgcobol.so.1 before/after this patch and I'd prefer not to see it, not seeing it in other libraries like libstdc++.so.6 etc. Dunno if that is because of the dependency on libstdc++ (but e.g. libstdc++ has dependency on libgcc_s and doesn't do that). 2025-03-11 Jakub Jelinek * Makefile.am: Remove tons of VAR = @VAR@ style lines. (libgcobol.la): Remove. (libgcobol_la_LFLAGS): Remove. (all): Remove. (.PHONY): Remove. (install): Remove. (%.lo: %.c): Remove. (doc): Remove. (install-html install-pdf install-info): Remove. * Makefile.in: Regenerate. Diff: --- libgcobol/Makefile.am | 95 --- libgcobol/Makefile.in | 56 +++--- 2 files changed, 5 insertions(+), 146 deletions(-) diff --git a/libgcobol/Makefile.am b/libgcobol/Makefile.am index 31040320ec38..7f21fdc24c9a 100644 --- a/libgcobol/Makefile.am +++ b/libgcobol/Makefile.am @@ -24,15 +24,6 @@ ACLOCAL_AMFLAGS = -I .. -I ../config toolexeclib_LTLIBRARIES = libgcobol.la -libgcobol.la: $(libgcobol_la_OBJECTS)\ - $(libgcobol_la_DEPENDENCIES)\ - $(EXTRA_libgcobol_la_DEPENDENCIES) - $(AM_V_GEN)$(libgcobol_la_LINK) \ - -rpath $(libdir)/../lib64 \ - $(libgcobol_la_OBJECTS) \ - $(libgcobol_la_LIBADD) $(LIBS) - - ## ## 2.2.12 Automatic Dependency Tracking ## Automake generates code for automatic dependency tracking by default @@ -47,72 +38,6 @@ libgcobol_la_SOURCES = \ libgcobol.cc\ valconv.cc -# -# configure varables -# - -# Automatic -AM_CFLAGS = @CFLAGS@ -configure_input = @configure_input@ -AM_CPPFLAGS = @CPPFLAGS@ -AM_CXXFLAGS = @CXXFLAGS@ -DEFS = @DEFS@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -ERLCFLAGS = @ERLCFLAGS@ -FCFLAGS = @FCFLAGS@ -FFLAGS = @FFLAGS@ -AM_LDFLAGS = @LDFLAGS@ -LIBS = @LIBS@ -OBJCFLAGS = @OBJCFLAGS@ -OBJCXXFLAGS = @OBJCXXFLAGS@ -GOFLAGS = @GOFLAGS@ -builddir = @builddir@ -abs_builddir = @abs_builddir@ -top_builddir = @top_builddir@ -top_build_prefix = @top_build_prefix@ -abs_top_builddir = @abs_top_builddir@ -## srcdir see: overrides -abs_srcdir = @abs_srcdir@ -top_srcdir = @top_srcdir@ -abs_top_srcdir = @abs_top_srcdir@ - -# Installation -bindir = @bindir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -sysconfdir = @sysconfdir@ - -# Overrides and custom - -CC = @CC@ -CXX = @CXX@ -AR = @AR@ -AS = @AS@ -RANLIB = @RANLIB@ -LIBGCOBOL_VERSION = @LIBGCOBOL_VERSION@ -VERSION_SUFFIX = @VERSION_SUFFIX@ -LIBTOOL = @LIBTOOL@ $(LIBTOOLFLAGS) - -libgcobol_la_LFLAGS = -lstdc++ libgcobol_la_LINK = $(LIBTOOL) --mode=link --tag=CXX $(CXX)\ -o libgcobol$(libsuffix).la \ -Wc,-shared-libgcc \ @@ -120,16 +45,6 @@ libgcobol_la_LINK = $(LIBTOOL) --mode=link --tag=CXX $(CXX) \ -lstdc++\ $(LTLDFLAGS) -# The 'all' rule must be the first one so that it is executed if -# nothing is specified on the command-line. -all: $(LIBGCOBOL_LA) - -.PHONY: install install-html install-pdf install-info - -###include $(top_srcdir)/../multilib.am -install: libgcobol$(libsuffix).la - $(LIBTOOL) --mode=install $(INSTALL) $^ $(DESTDIR)$(libdir)/../lib64 - WARN_CFLAGS = -W -Wall -Wwrite-strings # not defined: DEFS, MAX_ERRORS, LTLDFLAGS @@ -137,16 +52,6 @@ ALL_CFLAGS = -I. -I$(srcdir) $(AM_CPPFLAGS) $(DEFS) \ $(XCFLAGS) $(AM_CXXFLAGS) $(WARN_CFLAGS) $(MAX_ERRORS) \ -DIN_GCC -DIN_TARGET_LIBS -fno-strict-aliasing -%.lo: %.c - $(LIBTOOL) --mode=compile $(CC) -c \ - -o $@ $(ALL_CFLAGS) $(INCLUDES) $< - %.lo: %.cc $(LIBTOOL) --mode=compile --tag=CXX $(CXX) -c \
[gcc r15-7929] Add ChangeLog locations for gcc/cobol and libgcobol
https://gcc.gnu.org/g:7d2bf92c44f278721f29c24c510929b2a1ab9895 commit r15-7929-g7d2bf92c44f278721f29c24c510929b2a1ab9895 Author: Jakub Jelinek Date: Mon Mar 10 15:45:52 2025 +0100 Add ChangeLog locations for gcc/cobol and libgcobol * gcc-changelog/git_commit.py (default_changelog_locations): Add gcc/cobol and libgcobol entries. Diff: --- contrib/gcc-changelog/git_commit.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contrib/gcc-changelog/git_commit.py b/contrib/gcc-changelog/git_commit.py index 5c0596c2627d..fda5cf597263 100755 --- a/contrib/gcc-changelog/git_commit.py +++ b/contrib/gcc-changelog/git_commit.py @@ -38,6 +38,7 @@ default_changelog_locations = { 'gcc/c', 'gcc/c-family', 'gcc', +'gcc/cobol', 'gcc/cp', 'gcc/d', 'gcc/fortran', @@ -66,6 +67,7 @@ default_changelog_locations = { 'libgcc', 'libgcc/config/avr/libf7', 'libgcc/config/libbid', +'libgcobol', 'libgfortran', 'libgm2', 'libgomp',
[gcc(refs/users/rguenth/heads/cobol)] Update update_web_docs_git for cobol
https://gcc.gnu.org/g:b7de2a002baf3cbdb42e0fdb14175637fb7c449a commit b7de2a002baf3cbdb42e0fdb14175637fb7c449a Author: James K. Lowden Date: Mon Mar 10 16:01:57 2025 +0100 Update update_web_docs_git for cobol maintainer-scripts/ * update_web_docs_git: Add libgcobol module and cobol language. Diff: --- maintainer-scripts/update_web_docs_git | 29 + 1 file changed, 29 insertions(+) diff --git a/maintainer-scripts/update_web_docs_git b/maintainer-scripts/update_web_docs_git index 8ff34f86f65d..8b3f9ba9ae85 100755 --- a/maintainer-scripts/update_web_docs_git +++ b/maintainer-scripts/update_web_docs_git @@ -143,6 +143,7 @@ rm -rf gcc/.git # not .texi files (Makefile, .rst and .png), and the jit docs use # include directives to pull in content from jit/jit-common.h and # Similar considerations apply for libgdiagnostics. +# Preserve the cobol man pages, which are converted to HTML and PDF. find gcc -type f \( -name '*.texi' \ -o -path gcc/gcc/doc/install.texi2html \ -o -path gcc/gcc/doc/include/texinfo.tex \ @@ -155,6 +156,7 @@ find gcc -type f \( -name '*.texi' \ -o -path "gcc/gcc/testsuite/jit.dg/*" \ -o -path "gcc/gcc/doc/libgdiagnostics/*" \ -o -path "gcc/gcc/testsuite/libgdiagnostics.dg/*" \ + -o -path "gcc/gcc/cobol/gcobol*[13]" \ -o -print0 \) | xargs -0 rm -f # Build a tarball of the sources. @@ -200,6 +202,33 @@ for file in $MANUALS; do fi done +# +# The COBOL FE maintains man pages. Convert them to HTML and PDF. +# +mdoc2pdf_html() { +input="$1" +d="${input%/*}" +pdf="$d/$2" +html="$d/$3" +groff -mdoc -T pdf "$input" > "${pdf}~" +mv "${pdf}~" "${pdf}" +mandoc -T html "$filename" > "${html}~" +mv "${html}~" "${html}" +} + +find . -name gcobol.[13] | +while read filename +do +case ${filename##*.} in +1) +mdoc2pdf_html "$filename" gcobol.pdf gcobol.html +;; +3) +mdoc2pdf_html "$filename" gcobol_io.pdf gcobol_io.html +;; +esac +done + # jit and libgdiagnostics are a special-case, using Sphinx rather than texinfo. # Specifically, they need Sphinx 3.0 or later. #
[gcc r15-7882] arm: Handle fixed PIC register in require_pic_register (PR target/115485)
https://gcc.gnu.org/g:b1d0ac28de643e7c810e407a0668737131cdcc00 commit r15-7882-gb1d0ac28de643e7c810e407a0668737131cdcc00 Author: Christophe Lyon Date: Mon Mar 3 11:12:18 2025 + arm: Handle fixed PIC register in require_pic_register (PR target/115485) Commit r9-4307-g89d7557202d25a forgot to accept a fixed PIC register when extending the assert in require_pic_register. arm_pic_register can be set explicitly by the user (e.g. -mpic-register=r9) or implicitly as the default value with -fpic/-fPIC/-fPIE and -mno-pic-data-is-text-relative -mlong-calls, and we want to use/accept it when recording cfun->machine->pic_reg as used to be the case. PR target/115485 gcc/ * config/arm/arm.cc (require_pic_register): Fix typos in comment. Handle fixed arm_pic_register. gcc/testsuite/ * g++.target/arm/pr115485.C: New test. Diff: --- gcc/config/arm/arm.cc | 5 +++-- gcc/testsuite/g++.target/arm/pr115485.C | 16 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc index 00499a26bae1..670f487bcce3 100644 --- a/gcc/config/arm/arm.cc +++ b/gcc/config/arm/arm.cc @@ -8086,8 +8086,8 @@ legitimate_pic_operand_p (rtx x) /* Record that the current function needs a PIC register. If PIC_REG is null, a new pseudo is allocated as PIC register, otherwise PIC_REG is used. In - both case cfun->machine->pic_reg is initialized if we have not already done - so. COMPUTE_NOW decide whether and where to set the PIC register. If true, + both cases cfun->machine->pic_reg is initialized if we have not already done + so. COMPUTE_NOW decides whether and where to set the PIC register. If true, PIC register is reloaded in the current position of the instruction stream irregardless of whether it was loaded before. Otherwise, it is only loaded if not already done so (crtl->uses_pic_offset_table is null). Note that @@ -8107,6 +8107,7 @@ require_pic_register (rtx pic_reg, bool compute_now) if (!crtl->uses_pic_offset_table || compute_now) { gcc_assert (can_create_pseudo_p () + || (arm_pic_register != INVALID_REGNUM) || (pic_reg != NULL_RTX && REG_P (pic_reg) && GET_MODE (pic_reg) == Pmode)); diff --git a/gcc/testsuite/g++.target/arm/pr115485.C b/gcc/testsuite/g++.target/arm/pr115485.C new file mode 100644 index ..491b48c726a1 --- /dev/null +++ b/gcc/testsuite/g++.target/arm/pr115485.C @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-fPIE -mno-pic-data-is-text-relative -mlong-calls -ffunction-sections" } */ + +struct c1 { + virtual void func1() = 0; +}; +struct c2 { + virtual ~c2() {} +}; +struct c3 : c2, c1 { + void func1() override; + void func3(); +}; +void c3::func1() { + func3(); +}
[gcc r15-7922] libgcc: Formatting fixes for unwind-dw2-btree.h
https://gcc.gnu.org/g:9fe5106ea92218380ea2a7166417565f79fe680d commit r15-7922-g9fe5106ea92218380ea2a7166417565f79fe680d Author: Jakub Jelinek Date: Mon Mar 10 09:33:55 2025 +0100 libgcc: Formatting fixes for unwind-dw2-btree.h Studying unwind-dw2-btree.h was really hard for me because the formatting is wrong or weird in many ways all around the code and that kept distracting my attention. That includes all kinds of things, including wrong indentation, using {} around single statement substatements, excessive use of ()s around some parts of expressions which don't increase code clarity, no space after dot in comments, some comments not starting with capital letters, some not ending with dot, adding {} around some parts of code without any obvious reason (and when it isn't done in a similar neighboring function) or ( at the end of line without any reason. The following patch fixes the formatting issues I found, no functional changes. 2025-03-10 Jakub Jelinek * unwind-dw2-btree.h: Formatting fixes. Diff: --- libgcc/unwind-dw2-btree.h | 227 +- 1 file changed, 105 insertions(+), 122 deletions(-) diff --git a/libgcc/unwind-dw2-btree.h b/libgcc/unwind-dw2-btree.h index 6ea238ac2686..33d71409db3e 100644 --- a/libgcc/unwind-dw2-btree.h +++ b/libgcc/unwind-dw2-btree.h @@ -31,12 +31,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // Common logic for version locks. struct version_lock { - // The lock itself. The lowest bit indicates an exclusive lock, - // the second bit indicates waiting threads. All other bits are + // The lock itself. The lowest bit indicates an exclusive lock, + // the second bit indicates waiting threads. All other bits are // used as counter to recognize changes. // Overflows are okay here, we must only prevent overflow to the // same value within one lock_optimistic/validate - // range. Even on 32 bit platforms that would require 1 billion + // range. Even on 32 bit platforms that would require 1 billion // frame registrations within the time span of a few assembler // instructions. uintptr_type version_lock; @@ -60,10 +60,10 @@ version_lock_initialize_locked_exclusive (struct version_lock *vl) static inline bool version_lock_try_lock_exclusive (struct version_lock *vl) { - uintptr_type state = __atomic_load_n (&(vl->version_lock), __ATOMIC_SEQ_CST); + uintptr_type state = __atomic_load_n (&vl->version_lock, __ATOMIC_SEQ_CST); if (state & 1) return false; - return __atomic_compare_exchange_n (&(vl->version_lock), &state, state | 1, + return __atomic_compare_exchange_n (&vl->version_lock, &state, state | 1, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } @@ -78,10 +78,10 @@ restart: // We should virtually never get contention here, as frame // changes are rare. - uintptr_type state = __atomic_load_n (&(vl->version_lock), __ATOMIC_SEQ_CST); + uintptr_type state = __atomic_load_n (&vl->version_lock, __ATOMIC_SEQ_CST); if (!(state & 1)) { - if (__atomic_compare_exchange_n (&(vl->version_lock), &state, state | 1, + if (__atomic_compare_exchange_n (&vl->version_lock, &state, state | 1, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) return; @@ -90,13 +90,13 @@ restart: // We did get contention, wait properly. #ifdef __GTHREAD_HAS_COND __gthread_mutex_lock (&version_lock_mutex); - state = __atomic_load_n (&(vl->version_lock), __ATOMIC_SEQ_CST); + state = __atomic_load_n (&vl->version_lock, __ATOMIC_SEQ_CST); while (true) { // Check if the lock is still held. if (!(state & 1)) { - if (__atomic_compare_exchange_n (&(vl->version_lock), &state, + if (__atomic_compare_exchange_n (&vl->version_lock, &state, state | 1, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) { @@ -104,15 +104,13 @@ restart: return; } else - { - continue; - } + continue; } // Register waiting thread. if (!(state & 2)) { - if (!__atomic_compare_exchange_n (&(vl->version_lock), &state, + if (!__atomic_compare_exchange_n (&vl->version_lock, &state, state | 2, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) continue; @@ -120,7 +118,7 @@ restart: // And sleep. __gthread_cond_wait (&version_lock_cond, &version_lock_mutex); - state = __atomic_load_n (&(vl->version_lock), __ATOMIC_SEQ_CST); + state = __atomic_load_n (&vl->version_lock, __ATOMIC_SEQ_CST);
[gcc r15-7955] middle-end/119204 - ICE with strcspn folding
https://gcc.gnu.org/g:68932eeb38f66fbc0c3cf4b77ff7dde8a408f2e4 commit r15-7955-g68932eeb38f66fbc0c3cf4b77ff7dde8a408f2e4 Author: Richard Biener Date: Tue Mar 11 08:40:44 2025 +0100 middle-end/119204 - ICE with strcspn folding The following makes sure to convert the folded expression to the original expression type. PR middle-end/119204 * builtins.cc (fold_builtin_strcspn): Preserve the original expression type. * gcc.dg/pr119204.c: New testcase. Diff: --- gcc/builtins.cc | 5 +++-- gcc/testsuite/gcc.dg/pr119204.c | 13 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/gcc/builtins.cc b/gcc/builtins.cc index c8841032f039..02556e6615ad 100644 --- a/gcc/builtins.cc +++ b/gcc/builtins.cc @@ -11360,7 +11360,7 @@ fold_builtin_strcspn (location_t loc, tree expr, tree s1, tree s2) { /* Evaluate and ignore argument s2 in case it has side-effects. */ - return omit_one_operand_loc (loc, size_type_node, + return omit_one_operand_loc (loc, TREE_TYPE (expr), size_zero_node, s2); } @@ -11375,7 +11375,8 @@ fold_builtin_strcspn (location_t loc, tree expr, tree s1, tree s2) if (!fn) return NULL_TREE; - return build_call_expr_loc (loc, fn, 1, s1); + return fold_convert_loc (loc, TREE_TYPE (expr), + build_call_expr_loc (loc, fn, 1, s1)); } return NULL_TREE; } diff --git a/gcc/testsuite/gcc.dg/pr119204.c b/gcc/testsuite/gcc.dg/pr119204.c new file mode 100644 index ..ecbd8dd1c22a --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr119204.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-w" } */ + +extern void abort(void); +extern long long strcspn(const char *, const char *); + +void main_test(void) { + const char *const s1 = "hello world"; + char dst[64], *d2; + + if (strcspn(++d2 + 5, "") != 5 || d2 != dst + 1) +abort(); +}
[gcc r14-11389] LoongArch: Fix incorrect reorder of __lsx_vldx and __lasx_xvldx [PR119084]
https://gcc.gnu.org/g:43d777078387ab2c4aabe526f6ee0ff13055e0b6 commit r14-11389-g43d777078387ab2c4aabe526f6ee0ff13055e0b6 Author: Xi Ruoyao Date: Sun Mar 2 19:02:50 2025 +0800 LoongArch: Fix incorrect reorder of __lsx_vldx and __lasx_xvldx [PR119084] They could be incorrectly reordered with store instructions like st.b because the RTL expression does not have a memory_operand or a (mem) expression. The incorrect reorder has been observed in openh264 LTO build. Expand them to a (mem) expression instead of unspec to fix the issue. Closes: https://github.com/cisco/openh264/issues/3857 (cherry picked from commit 4856292f7a680ec478e7607f1b71781996d7d542) Edited to remove the loongarch.cc change which is not needed for gcc-14 branch. gcc/ChangeLog: PR target/119084 * config/loongarch/lasx.md (UNSPEC_LASX_XVLDX): Remove. (lasx_xvldx): Remove. * config/loongarch/lsx.md (UNSPEC_LSX_VLDX): Remove. (lsx_vldx): Remove. * config/loongarch/simd.md (QIVEC): New define_mode_iterator. (_vldx): New define_expand. gcc/testsuite/ChangeLog: PR target/119084 * gcc.target/loongarch/pr119084.c: New test. Diff: --- gcc/config/loongarch/lasx.md | 13 - gcc/config/loongarch/lsx.md | 13 - gcc/config/loongarch/simd.md | 10 ++ gcc/testsuite/gcc.target/loongarch/pr119084.c | 24 4 files changed, 34 insertions(+), 26 deletions(-) diff --git a/gcc/config/loongarch/lasx.md b/gcc/config/loongarch/lasx.md index 94bbd0c26bbc..fe32194e8119 100644 --- a/gcc/config/loongarch/lasx.md +++ b/gcc/config/loongarch/lasx.md @@ -155,7 +155,6 @@ UNSPEC_LASX_XVSSRLRN UNSPEC_LASX_XVEXTL_QU_DU UNSPEC_LASX_XVLDI - UNSPEC_LASX_XVLDX UNSPEC_LASX_XVSTX UNSPEC_LASX_VECINIT_MERGE UNSPEC_LASX_VEC_SET_INTERNAL @@ -4679,18 +4678,6 @@ [(set_attr "type" "simd_load") (set_attr "mode" "V4DI")]) -(define_insn "lasx_xvldx" - [(set (match_operand:V32QI 0 "register_operand" "=f") - (unspec:V32QI [(match_operand:DI 1 "register_operand" "r") - (match_operand:DI 2 "reg_or_0_operand" "rJ")] - UNSPEC_LASX_XVLDX))] - "ISA_HAS_LASX" -{ - return "xvldx\t%u0,%1,%z2"; -} - [(set_attr "type" "simd_load") - (set_attr "mode" "V32QI")]) - (define_insn "lasx_xvstx" [(set (mem:V32QI (plus:DI (match_operand:DI 1 "register_operand" "r") (match_operand:DI 2 "reg_or_0_operand" "rJ"))) diff --git a/gcc/config/loongarch/lsx.md b/gcc/config/loongarch/lsx.md index 5ee5845e84b0..67ba8e8ad5d7 100644 --- a/gcc/config/loongarch/lsx.md +++ b/gcc/config/loongarch/lsx.md @@ -100,7 +100,6 @@ UNSPEC_LSX_VSSRLRN UNSPEC_LSX_VLDI UNSPEC_LSX_VSHUF_B - UNSPEC_LSX_VLDX UNSPEC_LSX_VSTX UNSPEC_LSX_VEXTL_QU_DU UNSPEC_LSX_VSETEQZ_V @@ -3070,18 +3069,6 @@ [(set_attr "type" "simd_shf") (set_attr "mode" "V16QI")]) -(define_insn "lsx_vldx" - [(set (match_operand:V16QI 0 "register_operand" "=f") - (unspec:V16QI [(match_operand:DI 1 "register_operand" "r") - (match_operand:DI 2 "reg_or_0_operand" "rJ")] - UNSPEC_LSX_VLDX))] - "ISA_HAS_LSX" -{ - return "vldx\t%w0,%1,%z2"; -} - [(set_attr "type" "simd_load") - (set_attr "mode" "V16QI")]) - (define_insn "lsx_vstx" [(set (mem:V16QI (plus:DI (match_operand:DI 1 "register_operand" "r") (match_operand:DI 2 "reg_or_0_operand" "rJ"))) diff --git a/gcc/config/loongarch/simd.md b/gcc/config/loongarch/simd.md index 00ff2823a4e2..691e71956362 100644 --- a/gcc/config/loongarch/simd.md +++ b/gcc/config/loongarch/simd.md @@ -113,6 +113,16 @@ ;; instruction here so we can avoid duplicating logics. ;; === +;; REG + REG load + +(define_mode_iterator QIVEC [(V16QI "ISA_HAS_LSX") (V32QI "ISA_HAS_LASX")]) +(define_expand "_vldx" + [(set (match_operand:QIVEC 0 "register_operand" "=f") + (mem:QIVEC (plus:DI (match_operand:DI 1 "register_operand") + (match_operand:DI 2 "register_operand"] + "TARGET_64BIT") + + ;; ;; FP vector rounding instructions ;; diff --git a/gcc/testsuite/gcc.target/loongarch/pr119084.c b/gcc/testsuite/gcc.target/loongarch/pr119084.c new file mode 100644 index ..b5943303851b --- /dev/null +++ b/gcc/testsuite/gcc.target/loongarch/pr119084.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -mlsx" } */ +/* { dg-require-effective-target loongarch_sx_hw } */ + +typedef signed char V16QI __attribute__ ((vector_size (16))); +static char x[128]; + +__attribute__ ((noipa)) int +noopt (int x) +{ + return x; +} + +int +main (void) +{ + int t = noopt (32); + + x[32] = 1; + + V16QI y = __builtin_lsx_vldx (x, t);
[gcc r12-10986] aarch64: Fix folding of degenerate svwhilele case [PR117045]
https://gcc.gnu.org/g:4f61ae081d694d3a1e99b45680f3af25ab17e3a8 commit r12-10986-g4f61ae081d694d3a1e99b45680f3af25ab17e3a8 Author: Richard Sandiford Date: Tue Mar 11 15:51:54 2025 + aarch64: Fix folding of degenerate svwhilele case [PR117045] The svwhilele folder mishandled the degenerate case in which the second argument is the maximum integer. In that case, the result is all-true regardless of the first parameter: If the second scalar operand is equal to the maximum signed integer value then a condition which includes an equality test can never fail and the result will be an all-true predicate. This is because the conceptual "increment the first operand by 1 after each element" is done modulo the range of the operand. The GCC code was instead treating it as infinite precision. whilele_5.c even had a test for the incorrect behaviour. The easiest fix seemed to be to handle that case specially before doing constant folding. This also copes with variable first operands. gcc/ PR target/116999 PR target/117045 * config/aarch64/aarch64-sve-builtins-base.cc (svwhilelx_impl::fold): Check for WHILELTs of the minimum value and WHILELEs of the maximum value. Fold them to all-false and all-true respectively. gcc/testsuite/ PR target/116999 PR target/117045 * gcc.target/aarch64/sve/acle/general/whilele_5.c: Fix bogus expected result. * gcc.target/aarch64/sve/acle/general/whilele_11.c: New test. * gcc.target/aarch64/sve/acle/general/whilele_12.c: Likewise. (cherry picked from commit 50e7c51b0a0e9dc1d93f829016ae743b4f2e5070) Diff: --- gcc/config/aarch64/aarch64-sve-builtins-base.cc| 11 ++- .../aarch64/sve/acle/general/whilele_11.c | 31 .../aarch64/sve/acle/general/whilele_12.c | 34 ++ .../aarch64/sve/acle/general/whilele_5.c | 2 +- 4 files changed, 76 insertions(+), 2 deletions(-) diff --git a/gcc/config/aarch64/aarch64-sve-builtins-base.cc b/gcc/config/aarch64/aarch64-sve-builtins-base.cc index f96cb3ccc7bf..a3fc474f92ed 100644 --- a/gcc/config/aarch64/aarch64-sve-builtins-base.cc +++ b/gcc/config/aarch64/aarch64-sve-builtins-base.cc @@ -2412,7 +2412,9 @@ public: : while_comparison (unspec_for_sint, unspec_for_uint), m_eq_p (eq_p) {} - /* Try to fold a call by treating its arguments as constants of type T. */ + /* Try to fold a call by treating its arguments as constants of type T. + We have already filtered out the degenerate cases of X .LT. MIN + and X .LE. MAX. */ template gimple * fold_type (gimple_folder &f) const @@ -2465,6 +2467,13 @@ public: gimple * fold (gimple_folder &f) const OVERRIDE { +/* Filter out cases where the condition is always true or always false. */ +tree arg1 = gimple_call_arg (f.call, 1); +if (!m_eq_p && operand_equal_p (arg1, TYPE_MIN_VALUE (TREE_TYPE (arg1 + return f.fold_to_pfalse (); +if (m_eq_p && operand_equal_p (arg1, TYPE_MAX_VALUE (TREE_TYPE (arg1 + return f.fold_to_ptrue (); + if (f.type_suffix (1).unsigned_p) return fold_type (f); else diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general/whilele_11.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/whilele_11.c new file mode 100644 index ..2be9dc5c5347 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/whilele_11.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +#include +#include + +svbool_t +f1 (volatile int32_t *ptr) +{ + return svwhilelt_b8_s32 (*ptr, INT32_MIN); +} + +svbool_t +f2 (volatile uint32_t *ptr) +{ + return svwhilelt_b16_u32 (*ptr, 0); +} + +svbool_t +f3 (volatile int64_t *ptr) +{ + return svwhilelt_b32_s64 (*ptr, INT64_MIN); +} + +svbool_t +f4 (volatile uint64_t *ptr) +{ + return svwhilelt_b64_u64 (*ptr, 0); +} + +/* { dg-final { scan-assembler-times {\tpfalse\tp[0-9]+\.b\n} 4 } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general/whilele_12.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/whilele_12.c new file mode 100644 index ..713065c31453 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/whilele_12.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +#include +#include + +svbool_t +f1 (volatile int32_t *ptr) +{ + return svwhilele_b8_s32 (*ptr, INT32_MAX); +} + +svbool_t +f2 (volatile uint32_t *ptr) +{ + return svwhilele_b16_u32 (*ptr, UINT32_MAX); +} + +svbool_t +f3 (volatile int64_t *ptr) +{ + return svwhilele_b32_s64 (*ptr, INT64_MAX); +} + +svbool_t +f4 (volatile uint64_t *ptr) +{ + return svwhilele_b64_u64 (*ptr, UINT64_MAX); +} + +/* { dg-final { scan-assembler {\tptrue\tp[0-9]+\.b(?:, all)\n} } } */ +/* { dg-final { scan-a
[gcc r15-7928] Add empty ChangeLog files for GCC COBOL.
https://gcc.gnu.org/g:c664055622f67db7a89258962d846f02361c9b6d commit r15-7928-gc664055622f67db7a89258962d846f02361c9b6d Author: Jakub Jelinek Date: Mon Mar 10 15:38:54 2025 +0100 Add empty ChangeLog files for GCC COBOL. Diff: --- gcc/cobol/ChangeLog | 6 ++ libgcobol/ChangeLog | 6 ++ 2 files changed, 12 insertions(+) diff --git a/gcc/cobol/ChangeLog b/gcc/cobol/ChangeLog new file mode 100644 index ..501b0062a9c4 --- /dev/null +++ b/gcc/cobol/ChangeLog @@ -0,0 +1,6 @@ + +Copyright (C) 2025 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. diff --git a/libgcobol/ChangeLog b/libgcobol/ChangeLog new file mode 100644 index ..501b0062a9c4 --- /dev/null +++ b/libgcobol/ChangeLog @@ -0,0 +1,6 @@ + +Copyright (C) 2025 Free Software Foundation, Inc. + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved.
[gcc r15-7932] [PR114991][IRA]: Improve reg equiv invariant calculation
https://gcc.gnu.org/g:e355fe414aa3aaf215c7dd9dd789ce217a1b458c commit r15-7932-ge355fe414aa3aaf215c7dd9dd789ce217a1b458c Author: Vladimir N. Makarov Date: Mon Mar 10 16:26:59 2025 -0400 [PR114991][IRA]: Improve reg equiv invariant calculation In PR test case IRA preferred to allocate hard reg to a pseudo instead of its equivalence. This resulted in allocating caller-saved hard reg and generating save/restore insns in the function prologue/epilogue. The equivalence is an invariant (stack pointer plus offset) and the pseudo is used mostly as memory address. This happened as there was no simplification of insn after the invariant substitution. The patch adds the necessary code. gcc/ChangeLog: PR target/114991 * ira-costs.cc (equiv_can_be_consumed_p): Add new argument invariant_p. Add code for dealing with the invariant. (calculate_equiv_gains): Don't consider init insns. Pass the new argument to equiv_can_be_consumed_p. Don't treat invariant as memory. gcc/testsuite/ChangeLog: PR target/114991 * gcc.target/aarch64/pr114991.c: New test. Diff: --- gcc/ira-costs.cc| 38 + gcc/testsuite/gcc.target/aarch64/pr114991.c | 15 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/gcc/ira-costs.cc b/gcc/ira-costs.cc index a404e9f2690f..b568c7d03267 100644 --- a/gcc/ira-costs.cc +++ b/gcc/ira-costs.cc @@ -1788,11 +1788,27 @@ validate_autoinc_and_mem_addr_p (rtx x) MEM_ADDR_SPACE (x))); } -/* Check that reg REGNO can be changed by TO in INSN. Return true in case the - result insn would be valid one. */ +/* Check that reg REGNO in INSN can be changed by TO (which is an invariant + equiv when INVARIANT_P is true). Return true in case the result insn would + be valid one. */ static bool -equiv_can_be_consumed_p (int regno, rtx to, rtx_insn *insn) +equiv_can_be_consumed_p (int regno, rtx to, rtx_insn *insn, bool invariant_p) { + if (invariant_p) +{ + /* We use more expensive code for the invariant because we need to +simplify the result insn as the invariant can be arithmetic rtx +inserted into another arithmetic rtx. */ + rtx pat = PATTERN (insn); + int code = INSN_CODE (insn); + PATTERN (insn) = copy_rtx (pat); + PATTERN (insn) + = simplify_replace_rtx (PATTERN (insn), regno_reg_rtx[regno], to); + bool res = !insn_invalid_p (insn, false); + PATTERN (insn) = pat; + INSN_CODE (insn) = code; + return res; +} validate_replace_src_group (regno_reg_rtx[regno], to, insn); /* We can change register to equivalent memory in autoinc rtl. Some code including verify_changes assumes that autoinc contains only a register. @@ -1910,6 +1926,14 @@ calculate_equiv_gains (void) || !get_equiv_regno (PATTERN (insn), regno, subreg) || !bitmap_bit_p (&equiv_pseudos, regno)) continue; + + rtx_insn_list *x; + for (x = ira_reg_equiv[regno].init_insns; x != NULL; x = x->next ()) + if (insn == x->insn ()) + break; + if (x != NULL) + continue; /* skip equiv init insn */ + rtx subst = ira_reg_equiv[regno].memory; if (subst == NULL) @@ -1919,13 +1943,17 @@ calculate_equiv_gains (void) ira_assert (subst != NULL); mode = PSEUDO_REGNO_MODE (regno); ira_init_register_move_cost_if_necessary (mode); - bool consumed_p = equiv_can_be_consumed_p (regno, subst, insn); + bool consumed_p + = equiv_can_be_consumed_p (regno, subst, insn, + subst == ira_reg_equiv[regno].invariant); rclass = pref[COST_INDEX (regno)]; if (MEM_P (subst) /* If it is a change of constant into double for example, the result constant probably will be placed in memory. */ - || (subreg != NULL_RTX && !INTEGRAL_MODE_P (GET_MODE (subreg + || (ira_reg_equiv[regno].invariant == NULL + && subreg != NULL_RTX + && !INTEGRAL_MODE_P (GET_MODE (subreg cost = ira_memory_move_cost[mode][rclass][1] + (consumed_p ? 0 : 1); else if (consumed_p) continue; diff --git a/gcc/testsuite/gcc.target/aarch64/pr114991.c b/gcc/testsuite/gcc.target/aarch64/pr114991.c new file mode 100644 index ..d3c7bd131ddc --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr114991.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-shrink-wrap" } */ + +typedef struct { int arr[16]; } S; + +void g (S *); +void h (S); +void f(int x) +{ + S s; + g (&s); + h (s); +} + +/* { dg-final { scan-assembler-not "\[ \t\]?str\[ \t\]x" } } */
[gcc r15-7933] aarch64: Avoid unnecessary use of 2-input TBLs [PR115258]
https://gcc.gnu.org/g:31dcf941ac78c4b1b01dc4b2ce9809f0209153b8 commit r15-7933-g31dcf941ac78c4b1b01dc4b2ce9809f0209153b8 Author: Richard Sandiford Date: Mon Mar 10 20:29:52 2025 + aarch64: Avoid unnecessary use of 2-input TBLs [PR115258] When using TBL for (say) a V4SI permutation, the aarch64 port first asks target-independent code to lower to a V16QI permutation. Then, during code generation, an input like: (reg:V4SI R) gets converted to: (subreg:V16QI (reg:V4SI R) 0) aarch64_vectorize_vec_perm_const had: d.op0 = op0 ? force_reg (op_mode, op0) : NULL_RTX; if (op0 == op1) d.op1 = d.op0; else d.op1 = op1 ? force_reg (op_mode, op1) : NULL_RTX; But subregs (unlike regs) are not shared, so the op0 == op1 check always failed for this case. We'd then force each subreg into a fresh register, meaning that during the later: aarch64_expand_vec_perm_1 (d->target, d->op0, d->op1, sel); there is no way for aarch64_expand_vec_perm_1 to realise that d->op0 and d->op1 are the same value. It would therefore generate a two-input TBL in the testcase, even though a single-input TBL is enough. I'm not sure forcing subregs to a fresh regiter is a good idea -- it caused problems for copysign & co. -- but that's not something to fiddle with during stage 4. Using op0 == op1 for rtx equality is independently wrong, so we might as well just fix that for now. The patch gets rid of extra MOVs that are a regression from GCC 14. The testcase is based on one from Kugan, itself based on TSVC. gcc/ PR target/115258 * config/aarch64/aarch64.cc (aarch64_vectorize_vec_perm_const): Use d.one_vector_p to decide whether op1 should be a copy of op0. gcc/testsuite/ PR target/115258 * gcc.target/aarch64/pr115258_2.c: New test. Co-authored-by: Kugan Vivekanandarajah Diff: --- gcc/config/aarch64/aarch64.cc | 4 ++-- gcc/testsuite/gcc.target/aarch64/pr115258_2.c | 17 + 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index 9bea8ce88f9f..36b65df50c57 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -26851,8 +26851,8 @@ aarch64_vectorize_vec_perm_const (machine_mode vmode, machine_mode op_mode, d.op_vec_flags = aarch64_classify_vector_mode (d.op_mode); d.target = target; d.op0 = op0 ? force_reg (op_mode, op0) : NULL_RTX; - if (op0 == op1) -d.op1 = d.op0; + if (op0 && d.one_vector_p) +d.op1 = copy_rtx (d.op0); else d.op1 = op1 ? force_reg (op_mode, op1) : NULL_RTX; d.testing_p = !target; diff --git a/gcc/testsuite/gcc.target/aarch64/pr115258_2.c b/gcc/testsuite/gcc.target/aarch64/pr115258_2.c new file mode 100644 index ..065e1bb9e7a9 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr115258_2.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast -mcpu=neoverse-v2" } */ + +extern __attribute__((aligned(64))) float a[32000], b[32000]; +int dummy(float[32000], float[32000], float); + +void s1112() { + + for (int nl = 0; nl < 10 * 3; nl++) { +for (int i = 32000 - 1; i >= 0; i--) { + a[i] = b[i] + (float)1.; +} +dummy(a, b, 0.); + } +} + +/* { dg-final { scan-assembler-not {\tmov\tv[0-9]+\.16b,} } } */
[gcc r15-7966] Fortran: reject SAVE of a COMMON in a BLOCK construct [PR119199]
https://gcc.gnu.org/g:5e9f71254a5276cfca1769a5d490f6416a823b8d commit r15-7966-g5e9f71254a5276cfca1769a5d490f6416a823b8d Author: Harald Anlauf Date: Mon Mar 10 22:24:27 2025 +0100 Fortran: reject SAVE of a COMMON in a BLOCK construct [PR119199] PR fortran/119199 gcc/fortran/ChangeLog: * decl.cc (gfc_match_save): Reject SAVE statement of a COMMON block when in a BLOCK construct. * trans-common.cc (translate_common): Avoid NULL pointer dereference. gcc/testsuite/ChangeLog: * gfortran.dg/common_30.f90: New test. * gfortran.dg/common_31.f90: New test. Diff: --- gcc/fortran/decl.cc | 9 + gcc/fortran/trans-common.cc | 2 +- gcc/testsuite/gfortran.dg/common_30.f90 | 10 ++ gcc/testsuite/gfortran.dg/common_31.f90 | 15 +++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc index 5a46658651aa..feb454ea5b36 100644 --- a/gcc/fortran/decl.cc +++ b/gcc/fortran/decl.cc @@ -9795,6 +9795,15 @@ gfc_match_save (void) if (m == MATCH_NO) goto syntax; + /* F2023:C1108: A SAVE statement in a BLOCK construct shall contain a +saved-entity-list that does not specify a common-block-name. */ + if (gfc_current_state () == COMP_BLOCK) + { + gfc_error ("SAVE of COMMON block %qs at %C is not allowed " +"in a BLOCK construct", n); + return MATCH_ERROR; + } + c = gfc_get_common (n, 0); c->saved = 1; diff --git a/gcc/fortran/trans-common.cc b/gcc/fortran/trans-common.cc index 70b45174f84a..2db50da20dd0 100644 --- a/gcc/fortran/trans-common.cc +++ b/gcc/fortran/trans-common.cc @@ -1218,7 +1218,7 @@ translate_common (gfc_common_head *common, gfc_symbol *var_list) align = 1; saw_equiv = false; - if (var_list->attr.omp_allocate) + if (var_list && var_list->attr.omp_allocate) gfc_error ("Sorry, !$OMP allocate for COMMON block variable %qs at %L " "not supported", common->name, &common->where); diff --git a/gcc/testsuite/gfortran.dg/common_30.f90 b/gcc/testsuite/gfortran.dg/common_30.f90 new file mode 100644 index ..77a86348f4a7 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/common_30.f90 @@ -0,0 +1,10 @@ +! { dg-do compile } +! PR fortran/119199 +! +! One cannot SAVE an undefined COMMON block +! +! Contributed by David Binderman + +program main + save /argmnt1/ ! { dg-error "does not exist" } +end diff --git a/gcc/testsuite/gfortran.dg/common_31.f90 b/gcc/testsuite/gfortran.dg/common_31.f90 new file mode 100644 index ..b60f46d7d5a5 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/common_31.f90 @@ -0,0 +1,15 @@ +! { dg-do compile } +! PR fortran/119199 - reject SAVE of a COMMON in a BLOCK construct +! +! F2023:C1108: A SAVE statement in a BLOCK construct shall contain a +! saved-entity-list that does not specify a common-block-name. +! +! Contributed by David Binderman + +program main + real r + common /argmnt2/ r + block +save /argmnt2/ ! { dg-error "not allowed in a BLOCK construct" } + end block +end
[gcc r15-7969] contrib: Clean up outdated parts of gcc-git-customization.sh
https://gcc.gnu.org/g:34bc3118d961c459a6bc986077826b3580e2100d commit r15-7969-g34bc3118d961c459a6bc986077826b3580e2100d Author: Jonathan Wakely Date: Thu Mar 6 20:28:07 2025 + contrib: Clean up outdated parts of gcc-git-customization.sh It's very unlikely that anybody is still using the old remotes/$user Git repo setup and still needs this script to be able to migrate it to the remotes/users/$user structure. Simplify the script by removing those parts. This fixes an error that gets displayed in some circumstances: fatal: no such section: remote.me contrib/ChangeLog: * gcc-git-customization.sh: Delete outdated commands for migrating from very old git setups. Diff: --- contrib/gcc-git-customization.sh | 46 1 file changed, 46 deletions(-) diff --git a/contrib/gcc-git-customization.sh b/contrib/gcc-git-customization.sh index 54bd35ea1aab..e58220fb3426 100755 --- a/contrib/gcc-git-customization.sh +++ b/contrib/gcc-git-customization.sh @@ -156,45 +156,7 @@ if [ "x$dohook" = xyes ]; then fi fi -# Scan the existing settings to see if there are any we need to rewrite. -vendors=$(git config --get-all "remote.${upstream}.fetch" "refs/vendors/" | sed 's:.*refs/vendors/\([^/][^/]*\)/.*:\1:' | sort | uniq) url=$(git config --get "remote.${upstream}.url") -pushurl=$(git config --get "remote.${upstream}.pushurl") -for v in $vendors -do -echo "Migrating vendor \"$v\" to new remote \"vendors/$v\"" -git config --unset-all "remote.${upstream}.fetch" "refs/vendors/$v/" -git config --unset-all "remote.${upstream}.push" "refs/vendors/$v/" -git config "remote.vendors/${v}.url" "${url}" -if [ "x$pushurl" != "x" ] -then - git config "remote.vendors/${v}.pushurl" "${pushurl}" -fi -git config --add "remote.vendors/${v}.fetch" "+refs/vendors/$v/heads/*:refs/remotes/vendors/${v}/*" -git config --add "remote.vendors/${v}.fetch" "+refs/vendors/$v/tags/*:refs/tags/vendors/${v}/*" -done - -# Convert the remote 'pfx' to users/pfx to avoid problems with ambiguous refs -# on user branches -old_remote=$(git config --get "remote.${old_pfx}.url") -if [ -n "${old_remote}" ] -then -echo "Migrating remote \"${old_pfx}\" to new remote \"users/${new_pfx}\"" -# Create a dummy fetch rule that will cause the subsequent prune to remove the old remote refs. -git config --replace-all "remote.${old_pfx}.fetch" "+refs/empty/*:refs/remotes/${old_pfx}/*" -# Remove any remotes -git remote prune ${old_pfx} -git config --remove-section "remote.${old_pfx}" -for br in $(git branch --list "${old_pfx}/*") -do - old_remote=$(git config --get "branch.${br}.remote") - if [ "${old_remote}" = "${old_pfx}" ] - then - git config "branch.${br}.remote" "users/${new_pfx}" - fi -done -fi - echo "Setting up tracking for personal namespace $remote_id in remotes/users/${new_pfx}" git config "remote.users/${new_pfx}.url" "${url}" if [ "x$pushurl" != "x" ] @@ -205,12 +167,4 @@ git config --replace-all "remote.users/${new_pfx}.fetch" "+refs/users/${remote_i git config --replace-all "remote.users/${new_pfx}.fetch" "+refs/users/${remote_id}/tags/*:refs/tags/users/${new_pfx}/*" "refs/users/${remote_id}/tags/" git config --replace-all "remote.users/${new_pfx}.push" "refs/heads/${new_pfx}/*:refs/users/${remote_id}/heads/*" "refs/users/${remote_id}" -if [ "$old_pfx" != "$new_pfx" -a "$old_pfx" != "${upstream}" ] -then -git config --remove-section "remote.${old_pfx}" -fi - -git config --unset-all "remote.${upstream}.fetch" "refs/users/${remote_id}/" -git config --unset-all "remote.${upstream}.push" "refs/users/${remote_id}/" - git fetch "users/${new_pfx}"
[gcc r15-7970] doc: Fix minor grammar nit in -ftrivial-auto-var-init docs
https://gcc.gnu.org/g:f695d0392ffc82298d55474cd3025aec26db04ec commit r15-7970-gf695d0392ffc82298d55474cd3025aec26db04ec Author: Jonathan Wakely Date: Mon Mar 10 13:48:15 2025 + doc: Fix minor grammar nit in -ftrivial-auto-var-init docs gcc/ChangeLog: * doc/extend.texi (Common Variable Attributes): Fix grammar in final sentence of -ftrivial-auto-var-init description. Diff: --- gcc/doc/extend.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 6797efc0bb40..bae3fba6b2b6 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -8490,7 +8490,7 @@ to be excluded from such automatic initialization in order to reduce runtime overhead. This attribute has no effect when the option @code{-ftrivial-auto-var-init} -does not present. +is not present. @cindex @code{vector_size} variable attribute @item vector_size (@var{bytes})
[gcc r15-7971] OpenMP/C: Store location in cp_parser_omp_var_list for kind=0 [PR118579]
https://gcc.gnu.org/g:f74ed83e287dbaa20e9649df6cda631ee461ecf5 commit r15-7971-gf74ed83e287dbaa20e9649df6cda631ee461ecf5 Author: Sandra Loosemore Date: Tue Mar 11 16:36:22 2025 + OpenMP/C: Store location in cp_parser_omp_var_list for kind=0 [PR118579] This patch is the C equivalent of commit r15-6512-gcf94ba812ca496 for C++, to improve the location information for individual items in an OpenMP variable list. gcc/c/ChangeLog PR c/118579 * c-parser.cc (c_parser_omp_variable_list): Capture location information when KIND is OMP_CLAUSE_ERROR. (c_parser_oacc_data_clause_deviceptr): Use the improved location for diagnostics, and remove the FIXME. (c_finish_omp_declare_variant): Likewise. (c_parser_omp_threadprivate): Likewise. gcc/testsuite/ChangeLog PR c/118579 * c-c++-common/gomp/pr118579.c: New testcase. Diff: --- gcc/c/c-parser.cc | 36 -- gcc/testsuite/c-c++-common/gomp/pr118579.c | 25 + 2 files changed, 39 insertions(+), 22 deletions(-) diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index 7672e06fdd0d..911e7edd4811 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -16282,8 +16282,9 @@ c_parser_oacc_wait_list (c_parser *parser, location_t clause_loc, tree list) decl in OMP_CLAUSE_DECL and add the node to the head of the list. If KIND is nonzero, CLAUSE_LOC is the location of the clause. - If KIND is zero, create a TREE_LIST with the decl in TREE_PURPOSE; - return the list created. + If KIND is zero (= OMP_CLAUSE_ERROR), create a TREE_LIST with the decl + in TREE_PURPOSE and the location in TREE_VALUE (accessible using + EXPR_LOCATION); return the list created. The optional ALLOW_DEREF argument is true if list items can use the deref (->) operator. */ @@ -16312,6 +16313,7 @@ c_parser_omp_variable_list (c_parser *parser, while (1) { tree t = NULL_TREE; + location_t tloc = c_parser_peek_token (parser)->location; if (kind == OMP_CLAUSE_DEPEND || kind == OMP_CLAUSE_AFFINITY) { @@ -16512,7 +16514,7 @@ c_parser_omp_variable_list (c_parser *parser, if (t == error_mark_node) ; - else if (kind != 0) + else if (kind != 0) /* kind != OMP_CLAUSE_ERROR */ { switch (kind) { @@ -16686,8 +16688,8 @@ c_parser_omp_variable_list (c_parser *parser, list = u; } } - else - list = tree_cons (t, NULL_TREE, list); + else /* kind == OMP_CLAUSE_ERROR */ + list = tree_cons (t, build_empty_stmt (tloc), list); if (kind == OMP_CLAUSE_DEPEND || kind == OMP_CLAUSE_AFFINITY) { @@ -16847,7 +16849,6 @@ c_parser_oacc_data_clause (c_parser *parser, pragma_omp_clause c_kind, static tree c_parser_oacc_data_clause_deviceptr (c_parser *parser, tree list) { - location_t loc = c_parser_peek_token (parser)->location; tree vars, t; /* Can't use OMP_CLAUSE_MAP here (that is, can't use the generic @@ -16857,12 +16858,7 @@ c_parser_oacc_data_clause_deviceptr (c_parser *parser, tree list) for (t = vars; t && t; t = TREE_CHAIN (t)) { tree v = TREE_PURPOSE (t); - - /* FIXME diagnostics: Ideally we should keep individual -locations for all the variables in the var list to make the -following errors more precise. Perhaps -c_parser_omp_var_list_parens() should construct a list of -locations to go along with the var list. */ + location_t loc = EXPR_LOCATION (TREE_VALUE (t)); if (!VAR_P (v) && TREE_CODE (v) != PARM_DECL) error_at (loc, "%qD is not a variable", v); @@ -27031,6 +27027,7 @@ c_finish_omp_declare_variant (c_parser *parser, tree fndecl, tree parms) for (tree c = list; c != NULL_TREE; c = TREE_CHAIN (c)) { tree decl = TREE_PURPOSE (c); + location_t arg_loc = EXPR_LOCATION (TREE_VALUE (c)); int idx; for (arg = parms, idx = 0; arg != NULL; arg = TREE_CHAIN (arg), idx++) @@ -27038,14 +27035,15 @@ c_finish_omp_declare_variant (c_parser *parser, tree fndecl, tree parms) break; if (arg == NULL_TREE) { - error_at (loc, "%qD is not a function argument", + error_at (arg_loc, + "%qD is not a function argument", decl); goto fail; } if (adjust_args_list.contains (arg)) { - // TODO fix location - error_at (loc, "%qD is specif
[gcc r15-7884] aarch64: add support for partial modes to last extractions [PR118464]
https://gcc.gnu.org/g:9798ba2c6b4cccb17277a9d5fc04d285bf48f742 commit r15-7884-g9798ba2c6b4cccb17277a9d5fc04d285bf48f742 Author: Tamar Christina Date: Fri Mar 7 13:32:11 2025 + aarch64: add support for partial modes to last extractions [PR118464] The last extraction instructions work full both full and partial SVE vectors, however we currrently only define them for FULL vectors. Early break code for VLA now however requires partial vector support, which relies on extract_last support. I have not added any new testcases as they overlap with the existing Early break tests which now fail without this. gcc/ChangeLog: PR tree-optimization/118464 PR tree-optimization/116855 * config/aarch64/aarch64-sve.md (@extract__, @fold_extract__, @aarch64_fold_extract_vector__): Change SVE_FULL to SVE_ALL. * config/aarch64/iterators.md (vccore): Add more partial types. Diff: --- gcc/config/aarch64/aarch64-sve.md | 24 gcc/config/aarch64/iterators.md | 6 +- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/gcc/config/aarch64/aarch64-sve.md b/gcc/config/aarch64/aarch64-sve.md index a93bc463a909..3dbd65986ec7 100644 --- a/gcc/config/aarch64/aarch64-sve.md +++ b/gcc/config/aarch64/aarch64-sve.md @@ -3107,12 +3107,12 @@ [(set (match_operand: 0 "register_operand") (unspec: [(match_operand: 1 "register_operand") - (match_operand:SVE_FULL 2 "register_operand")] + (match_operand:SVE_ALL 2 "register_operand")] LAST))] "TARGET_SVE" {@ [ cons: =0 , 1 , 2 ] - [ ?r , Upl , w ] last\t%0, %1, %2. - [ w, Upl , w ] last\t%0, %1, %2. + [ ?r , Upl , w ] last\t%0, %1, %2. + [ w, Upl , w ] last\t%0, %1, %2. } ) @@ -8899,26 +8899,26 @@ (unspec: [(match_operand: 1 "register_operand") (match_operand: 2 "register_operand") - (match_operand:SVE_FULL 3 "register_operand")] + (match_operand:SVE_ALL 3 "register_operand")] CLAST))] "TARGET_SVE" {@ [ cons: =0 , 1 , 2 , 3 ] - [ ?r , 0 , Upl , w ] clast\t%0, %2, %0, %3. - [ w, 0 , Upl , w ] clast\t%0, %2, %0, %3. + [ ?r , 0 , Upl , w ] clast\t%0, %2, %0, %3. + [ w, 0 , Upl , w ] clast\t%0, %2, %0, %3. } ) (define_insn "@aarch64_fold_extract_vector__" - [(set (match_operand:SVE_FULL 0 "register_operand") - (unspec:SVE_FULL - [(match_operand:SVE_FULL 1 "register_operand") + [(set (match_operand:SVE_ALL 0 "register_operand") + (unspec:SVE_ALL + [(match_operand:SVE_ALL 1 "register_operand") (match_operand: 2 "register_operand") - (match_operand:SVE_FULL 3 "register_operand")] + (match_operand:SVE_ALL 3 "register_operand")] CLAST))] "TARGET_SVE" {@ [ cons: =0 , 1 , 2 , 3 ] - [ w, 0 , Upl , w ] clast\t%0., %2, %0., %3. - [ ?&w , w , Upl , w ] movprfx\t%0, %1\;clast\t%0., %2, %0., %3. + [ w, 0 , Upl , w ] clast\t%0., %2, %0., %3. + [ ?&w , w , Upl , w ] movprfx\t%0, %1\;clast\t%0., %2, %0., %3. } ) diff --git a/gcc/config/aarch64/iterators.md b/gcc/config/aarch64/iterators.md index 5bfd6e7d362a..146453b05168 100644 --- a/gcc/config/aarch64/iterators.md +++ b/gcc/config/aarch64/iterators.md @@ -2025,8 +2025,12 @@ ;; Like vwcore, but for the container mode rather than the element mode. (define_mode_attr vccore [(VNx16QI "w") (VNx8QI "w") (VNx4QI "w") (VNx2QI "x") (VNx8HI "w") (VNx4HI "w") (VNx2HI "x") + (VNx8HF "w") (VNx4HF "w") (VNx2HF "x") + (VNx8BF "w") (VNx4BF "w") (VNx2BF "x") (VNx4SI "w") (VNx2SI "x") - (VNx2DI "x")]) + (VNx4SF "w") (VNx2SF "x") + (VNx2DI "x") + (VNx2DF "x")]) ;; Double vector types for ALLX. (define_mode_attr Vallxd [(QI "8b") (HI "4h") (SI "2s")])
[gcc r15-7967] testsuite: Improve builtin-bswap-5.c
https://gcc.gnu.org/g:b3becb17b82cb3ffdb19b0301031b22a486501b0 commit r15-7967-gb3becb17b82cb3ffdb19b0301031b22a486501b0 Author: Oscar Gustafsson Date: Tue Mar 11 17:19:25 2025 + testsuite: Improve builtin-bswap-5.c gcc/testsuite/ChangeLog * gcc.dg/builtin-bswap-5.c: Improve test vector to avoid nibble swaps passing. Diff: --- gcc/testsuite/gcc.dg/builtin-bswap-5.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gcc/testsuite/gcc.dg/builtin-bswap-5.c b/gcc/testsuite/gcc.dg/builtin-bswap-5.c index b29931e4e10d..2ba6c31194fc 100644 --- a/gcc/testsuite/gcc.dg/builtin-bswap-5.c +++ b/gcc/testsuite/gcc.dg/builtin-bswap-5.c @@ -6,13 +6,13 @@ main (void) /* Test constant folding. */ extern void link_error (void); - if (__builtin_bswap16(0xaabb) != 0xbbaa) + if (__builtin_bswap16(0xabcd) != 0xcdab) link_error (); - if (__builtin_bswap32(0xaabbccdd) != 0xddccbbaa) + if (__builtin_bswap32(0x89abcdef) != 0xefcdab89) link_error (); - if (__builtin_bswap64(0x1122334455667788ULL) != 0x8877665544332211ULL) + if (__builtin_bswap64(0x0123456789abcdefULL) != 0xefcdab8967452301ULL) link_error (); return 0;
[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] Correction régression alloc_comp_assign_12 etc
https://gcc.gnu.org/g:082e1db6d4ff0765771796d8648b800323c09239 commit 082e1db6d4ff0765771796d8648b800323c09239 Author: Mikael Morin Date: Thu Mar 6 19:32:28 2025 +0100 Correction régression alloc_comp_assign_12 etc Diff: --- gcc/fortran/trans-array.cc | 18 ++ 1 file changed, 18 insertions(+) diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index 0fb22ac1655a..a19ac2d9513f 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -5702,6 +5702,24 @@ gfc_conv_ss_descriptor (stmtblock_t * block, gfc_ss * ss, int base) gfc_conv_expr_lhs (&se, ss_info->expr); gfc_add_block_to_block (block, &se.pre); info->descriptor = se.expr; + if (TREE_CODE (info->descriptor) == INDIRECT_REF) +{ + tree ptr = TREE_OPERAND (info->descriptor, 0); + ptr = gfc_evaluate_now (ptr, block); + TREE_OPERAND (info->descriptor, 0) = ptr; +} + else if (TREE_CODE (info->descriptor) == COMPONENT_REF) +{ + tree parent_ref = TREE_OPERAND (info->descriptor, 0); + tree parent_ptr_type = build_pointer_type (TREE_TYPE (parent_ref)); + tree ptr = fold_build1_loc (input_location, ADDR_EXPR, + parent_ptr_type, parent_ref); + ptr = gfc_evaluate_now (ptr, block); + tree deref = fold_build1_loc (input_location, INDIRECT_REF, + TREE_TYPE (parent_ref), + ptr); + TREE_OPERAND (info->descriptor, 0) = deref; +} ss_info->string_length = se.string_length; ss_info->class_container = se.class_container;
[gcc r15-7968] d: Fix regression returning from function with invariants [PR119139]
https://gcc.gnu.org/g:81582ca6cb692098c1bda7995aec46c6cbfbfcb3 commit r15-7968-g81582ca6cb692098c1bda7995aec46c6cbfbfcb3 Author: Iain Buclaw Date: Tue Mar 11 17:56:18 2025 +0100 d: Fix regression returning from function with invariants [PR119139] An optimization was added in GDC-12 which sets the TREE_READONLY flag on all local variables with the storage class `const' assigned. For some reason, const is also being added by the front-end to `__result' variables in non-virtual functions, which ends up getting wrong code by the gimplify pass promoting the local to static storage. A bug has been raised upstream, as this looks like an error in the AST. For now, turn off setting TREE_READONLY on all result variables. PR d/119139 gcc/d/ChangeLog: * decl.cc (get_symbol_decl): Don't set TREE_READONLY for __result declarations. gcc/testsuite/ChangeLog: * gdc.dg/pr119139.d: New test. Diff: --- gcc/d/decl.cc | 2 +- gcc/testsuite/gdc.dg/pr119139.d | 24 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc index 88dc5251bdaf..1bad1866763f 100644 --- a/gcc/d/decl.cc +++ b/gcc/d/decl.cc @@ -1323,7 +1323,7 @@ get_symbol_decl (Declaration *decl) /* `const` applies to data that cannot be changed by the const reference to that data. It may, however, be changed by another reference to that same data. */ - if (vd->isConst () && !vd->isDataseg ()) + if (vd->isConst () && !vd->isResult () && !vd->isDataseg ()) TREE_READONLY (decl->csym) = 1; } diff --git a/gcc/testsuite/gdc.dg/pr119139.d b/gcc/testsuite/gdc.dg/pr119139.d new file mode 100644 index ..dc42c411e390 --- /dev/null +++ b/gcc/testsuite/gdc.dg/pr119139.d @@ -0,0 +1,24 @@ +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119139 +// { dg-do compile } +// { dg-options "-fdump-tree-gimple" } +string toString() +{ +return "1"; +} + +struct B +{ +ulong n; + +invariant{} + +string str() +{ +if (n == 0) +{ +return "0"; +} +return toString(); +} +} +// { dg-final { scan-tree-dump-not "static const struct __result =" "gimple" } }
[gcc r15-7972] MAINTAINERS: Add myself
https://gcc.gnu.org/g:bc6bbdb2cbc3ace1fbc8db6cc8976f5d8680809b commit r15-7972-gbc6bbdb2cbc3ace1fbc8db6cc8976f5d8680809b Author: Bob Dubner Date: Tue Mar 11 14:59:30 2025 -0400 MAINTAINERS: Add myself ChangeLog: * MAINTAINERS: Add myself. Diff: --- MAINTAINERS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 84c0a6b892bb..34e2f9f53b74 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -162,6 +162,7 @@ Ada front end Arnaud Charlet Ada front end Eric Botcazou Ada front end Marc Poulhiès Ada front end Pierre-Marie de Rodat +COBOL front end Robert Dubner c++ Jason Merrill c++ Nathan Sidwell D front end Iain Buclaw @@ -276,6 +277,7 @@ check in changes outside of the parts of the compiler they maintain. arm port (MVE) Christophe Lyon callgraph Martin Jambor C front end Marek Polacek +COBOL front end Robert Dubner CTF, BTFIndu Bhagat CTF, BTF, bpf port David Faust dataflowPaolo Bonzini @@ -445,6 +447,7 @@ Dimitar Dimitrovdimitar Benoit Dupont de Dinechin bd3 Lehua Ding - Ulrich Drepper drepper +Robert Dubner rdubner François Dumont fdumont Zdenek Dvorak rakdver Michael Eager eager
[gcc r14-11401] d: Fix regression returning from function with invariants [PR119139]
https://gcc.gnu.org/g:af69315f84778dc1455d2a06d355a67ad8b9241e commit r14-11401-gaf69315f84778dc1455d2a06d355a67ad8b9241e Author: Iain Buclaw Date: Tue Mar 11 17:56:18 2025 +0100 d: Fix regression returning from function with invariants [PR119139] An optimization was added in GDC-12 which sets the TREE_READONLY flag on all local variables with the storage class `const' assigned. For some reason, const is also being added by the front-end to `__result' variables in non-virtual functions, which ends up getting wrong code by the gimplify pass promoting the local to static storage. A bug has been raised upstream, as this looks like an error in the AST. For now, turn off setting TREE_READONLY on all result variables. PR d/119139 gcc/d/ChangeLog: * decl.cc (get_symbol_decl): Don't set TREE_READONLY for __result declarations. gcc/testsuite/ChangeLog: * gdc.dg/pr119139.d: New test. (cherry picked from commit 81582ca6cb692098c1bda7995aec46c6cbfbfcb3) Diff: --- gcc/d/decl.cc | 2 +- gcc/testsuite/gdc.dg/pr119139.d | 24 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc index 0a87c85ae2e5..7cc203ac8429 100644 --- a/gcc/d/decl.cc +++ b/gcc/d/decl.cc @@ -1325,7 +1325,7 @@ get_symbol_decl (Declaration *decl) /* `const` applies to data that cannot be changed by the const reference to that data. It may, however, be changed by another reference to that same data. */ - if (vd->isConst () && !vd->isDataseg ()) + if (vd->isConst () && !vd->isResult () && !vd->isDataseg ()) TREE_READONLY (decl->csym) = 1; } diff --git a/gcc/testsuite/gdc.dg/pr119139.d b/gcc/testsuite/gdc.dg/pr119139.d new file mode 100644 index ..dc42c411e390 --- /dev/null +++ b/gcc/testsuite/gdc.dg/pr119139.d @@ -0,0 +1,24 @@ +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119139 +// { dg-do compile } +// { dg-options "-fdump-tree-gimple" } +string toString() +{ +return "1"; +} + +struct B +{ +ulong n; + +invariant{} + +string str() +{ +if (n == 0) +{ +return "0"; +} +return toString(); +} +} +// { dg-final { scan-tree-dump-not "static const struct __result =" "gimple" } }
[gcc r12-10988] d: Fix regression returning from function with invariants [PR119139]
https://gcc.gnu.org/g:8d8eb5327f44472e8769807a6e632e2e0d445bb9 commit r12-10988-g8d8eb5327f44472e8769807a6e632e2e0d445bb9 Author: Iain Buclaw Date: Tue Mar 11 17:56:18 2025 +0100 d: Fix regression returning from function with invariants [PR119139] An optimization was added in GDC-12 which sets the TREE_READONLY flag on all local variables with the storage class `const' assigned. For some reason, const is also being added by the front-end to `__result' variables in non-virtual functions, which ends up getting wrong code by the gimplify pass promoting the local to static storage. A bug has been raised upstream, as this looks like an error in the AST. For now, turn off setting TREE_READONLY on all result variables. PR d/119139 gcc/d/ChangeLog: * decl.cc (get_symbol_decl): Don't set TREE_READONLY for __result declarations. gcc/testsuite/ChangeLog: * gdc.dg/pr119139.d: New test. (cherry picked from commit 81582ca6cb692098c1bda7995aec46c6cbfbfcb3) Diff: --- gcc/d/decl.cc | 2 +- gcc/testsuite/gdc.dg/pr119139.d | 24 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc index 6c2705d9864f..00eac62d7a3b 100644 --- a/gcc/d/decl.cc +++ b/gcc/d/decl.cc @@ -1300,7 +1300,7 @@ get_symbol_decl (Declaration *decl) /* `const` applies to data that cannot be changed by the const reference to that data. It may, however, be changed by another reference to that same data. */ - if (vd->isConst () && !vd->isDataseg ()) + if (vd->isConst () && !vd->isResult () && !vd->isDataseg ()) TREE_READONLY (decl->csym) = 1; } diff --git a/gcc/testsuite/gdc.dg/pr119139.d b/gcc/testsuite/gdc.dg/pr119139.d new file mode 100644 index ..dc42c411e390 --- /dev/null +++ b/gcc/testsuite/gdc.dg/pr119139.d @@ -0,0 +1,24 @@ +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119139 +// { dg-do compile } +// { dg-options "-fdump-tree-gimple" } +string toString() +{ +return "1"; +} + +struct B +{ +ulong n; + +invariant{} + +string str() +{ +if (n == 0) +{ +return "0"; +} +return toString(); +} +} +// { dg-final { scan-tree-dump-not "static const struct __result =" "gimple" } }
[gcc(refs/users/meissner/heads/work195-bugs)] Merge commit 'refs/users/meissner/heads/work195-bugs' of git+ssh://gcc.gnu.org/git/gcc into me/work1
https://gcc.gnu.org/g:83fcbcc39e6c936d3ff8b17bde9b54aae486b32f commit 83fcbcc39e6c936d3ff8b17bde9b54aae486b32f Merge: 62edb33a3039 185756ac6ef9 Author: Michael Meissner Date: Sat Mar 8 21:37:41 2025 -0500 Merge commit 'refs/users/meissner/heads/work195-bugs' of git+ssh://gcc.gnu.org/git/gcc into me/work195-bugs Diff:
[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] Initialisations variables statiques et amélioration constructeurs
https://gcc.gnu.org/g:de6fad016bb72189ebce2032a485d006ff926a79 commit de6fad016bb72189ebce2032a485d006ff926a79 Author: Mikael Morin Date: Wed Mar 5 18:44:00 2025 +0100 Initialisations variables statiques et amélioration constructeurs Diff: --- gcc/cgraphunit.cc | 173 -- 1 file changed, 156 insertions(+), 17 deletions(-) diff --git a/gcc/cgraphunit.cc b/gcc/cgraphunit.cc index c52e6559fede..84bba681da85 100644 --- a/gcc/cgraphunit.cc +++ b/gcc/cgraphunit.cc @@ -2624,7 +2624,6 @@ class exec_context void add_variables (vec *variables); template void add_variables (vec *variables); - void execute (gimple *g); void execute_assign (gassign *g); void execute_call (gcall *g); data_storage *find_var (tree variable) const; @@ -2652,6 +2651,7 @@ public: const exec_context & root () const; int find (const data_storage &storage) const; data_storage *find_reachable_var (tree variable) const; + void execute (gimple *g); gimple * execute (basic_block bb); data_storage & get_storage (unsigned idx) const; context_printer & get_printer () const { return printer; } @@ -3742,11 +3742,21 @@ exec_context::evaluate (tree expr) const case ADDR_EXPR: { - data_storage *strg = find_reachable_var (TREE_OPERAND (expr, 0)); - gcc_assert (strg != nullptr); - storage_address address (strg->get_ref (), 0); + tree decl = TREE_OPERAND (expr, 0); data_value result (TREE_TYPE (expr)); - result.set_address (address); + if (TREE_CODE (decl) == FUNCTION_DECL) + { + // Unimplemented, set to NULL and hope that it won't be used. + wide_int zero = wi::zero (result.get_bitwidth ()); + result.set_cst (zero); + } + else + { + data_storage *strg = find_reachable_var (TREE_OPERAND (expr, 0)); + gcc_assert (strg != nullptr); + storage_address address (strg->get_ref (), 0); + result.set_address (address); + } return result; } @@ -3791,31 +3801,52 @@ data_value exec_context::evaluate_constructor (tree cstr) const { unsigned bit_width; - gcc_assert (TREE_CODE (TREE_TYPE (cstr)) == VECTOR_TYPE); + gcc_assert (TREE_CODE (TREE_TYPE (cstr)) == VECTOR_TYPE + || TREE_CODE (TREE_TYPE (cstr)) == ARRAY_TYPE + || TREE_CODE (TREE_TYPE (cstr)) == RECORD_TYPE); + gcc_assert (get_constant_type_size (TREE_TYPE (cstr), bit_width)); data_value result(bit_width); + if (CONSTRUCTOR_NELTS (cstr) == 0) +{ + wide_int zero = wi::zero (bit_width); + result.set_cst (zero); + return result; +} + unsigned i; tree idx, elt; FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (cstr), i, idx, elt) { data_value val = evaluate (elt); - gcc_assert (idx == NULL_TREE); - //gcc_assert (TREE_CODE (idx) == INTEGER_CST); - //wide_int wi_idx = wi::to_wide (idx); + wide_int offset; + if (idx != NULL_TREE + && TREE_CODE (idx) == FIELD_DECL) + offset = wi::to_wide (bit_position (idx)); + else + { + wide_int wi_idx; + if (idx == NULL_TREE) + wi_idx = wi::uhwi (i, HOST_BITS_PER_WIDE_INT); + else + wi_idx = wi::to_wide (idx); + + unsigned elt_size; + gcc_assert (get_constant_type_size (TREE_TYPE (elt), elt_size)); - unsigned elt_size; - gcc_assert (get_constant_type_size (TREE_TYPE (elt), elt_size)); - gcc_assert (elt_size == HOST_BITS_PER_PTR); + wide_int max_idx = wi::uhwi (bit_width / elt_size, + wi_idx.get_precision ()); + gcc_assert (wi::ltu_p (wi_idx, max_idx)); + offset = wi_idx * elt_size; + } - //wide_int offset = wi_idx * elt_size; - //gcc_assert (wi::fits_uhwi_p (offset)); - gcc_assert (i < bit_width / HOST_BITS_PER_PTR); - unsigned offset = i * elt_size; + gcc_assert (wi::fits_uhwi_p (offset) + && wi::ltu_p (offset, UINT_MAX)); - result.set_at (val, offset); + result.set_at (val, offset.to_uhwi ()); } return result; @@ -4348,6 +4379,15 @@ execute (void) builder.add_decls (&static_vars); exec_context root_context = builder.build (alloc_mem, printer); + tree *varp = nullptr; + unsigned i = 0; + FOR_EACH_VEC_ELT (static_vars, i, varp) +{ + tree var = *varp; + gassign *tmp_assign = gimple_build_assign (var, DECL_INITIAL (var)); + root_context.execute (tmp_assign); +} + struct function *main = find_main (); gcc_assert (main != nullptr); vec args{}; @@ -6369,6 +6409,105 @@ exec_context_evaluate_constructor_tests () ASSERT_NE (addr2_bis, nullptr); data_storage &strg2 = addr2_bis->storage.get (); ASSERT_PRED1 (strg2.matches, b); + + + tree a2i = build_array_type_nelts (integer_type_node, 2); + + exec_context ctx2 = context_builder ().
[gcc r15-7927] c++/modules: Handle exposures of TU-local types in uninstantiated member templates
https://gcc.gnu.org/g:65febfb25544f089e7459219b6c095f0b8eff879 commit r15-7927-g65febfb25544f089e7459219b6c095f0b8eff879 Author: Nathaniel Shead Date: Fri Jan 31 23:53:35 2025 +1100 c++/modules: Handle exposures of TU-local types in uninstantiated member templates Previously, 'is_tu_local_entity' wouldn't detect the exposure of the (in practice) TU-local lambda in the following example, unless instantiated: struct S { template static inline decltype([]{}) x = {}; }; This is for two reasons. Firstly, when traversing the TYPE_FIELDS of S we only see the TEMPLATE_DECL, and never end up building a dependency on its DECL_TEMPLATE_RESULT (due to not being instantiated). This patch fixes this by stripping any templates before checking for unnamed types. The second reason is that we currently assume all class-scope entities are not TU-local. Despite this being unambiguous in the standard, this is not actually true in our implementation just yet, due to issues with mangling lambdas in some circumstances. Allowing these lambdas to be exported can cause issues in importers with apparently conflicting declarations, so this patch treats them as TU-local as well. After these changes, we now get double diagnostics from the two ways that we can see the above lambda being exposed, via 'S' (through TYPE_FIELDS) or via 'S::x'. To workaround this we hide diagnostics from the first case, so we only get errors from 'S::x' which will be closer to the point the offending lambda is declared. gcc/cp/ChangeLog: * module.cc (trees_out::has_tu_local_dep): Also look at the TI_TEMPLATE if we don't find a dep for a decl. (depset::hash::is_tu_local_entity): Handle unnamed template types, treat lambdas specially. (is_exposure_of_member_type): New function. (depset::hash::add_dependency): Use it. (depset::hash::finalize_dependencies): Likewise. gcc/testsuite/ChangeLog: * g++.dg/modules/internal-10.C: New test. Signed-off-by: Nathaniel Shead Reviewed-by: Jason Merrill Diff: --- gcc/cp/module.cc | 72 +- gcc/testsuite/g++.dg/modules/internal-10.C | 25 +++ 2 files changed, 87 insertions(+), 10 deletions(-) diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 8b0f42951c24..97c3549093c9 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -9632,6 +9632,15 @@ trees_out::has_tu_local_dep (tree decl) const decl = TYPE_NAME (DECL_CONTEXT (decl)); depset *dep = dep_hash->find_dependency (decl); + if (!dep) +{ + /* This might be the DECL_TEMPLATE_RESULT of a TEMPLATE_DECL +which we found was TU-local and gave up early. */ + int use_tpl = -1; + if (tree ti = node_template_info (decl, use_tpl)) + dep = dep_hash->find_dependency (TI_TEMPLATE (ti)); +} + return dep && dep->is_tu_local (); } @@ -13504,19 +13513,31 @@ depset::hash::is_tu_local_entity (tree decl, bool explain/*=false*/) We consider types with names for linkage purposes as having names, since these aren't really TU-local. */ - if (TREE_CODE (decl) == TYPE_DECL + tree inner = STRIP_TEMPLATE (decl); + if (inner + && TREE_CODE (inner) == TYPE_DECL && TYPE_ANON_P (type) - && !DECL_SELF_REFERENCE_P (decl) + && !DECL_SELF_REFERENCE_P (inner) /* An enum with an enumerator name for linkage. */ && !(UNSCOPED_ENUM_P (type) && TYPE_VALUES (type))) { tree main_decl = TYPE_MAIN_DECL (type); - if (!DECL_CLASS_SCOPE_P (main_decl) - && !decl_function_context (main_decl) - /* LAMBDA_EXPR_EXTRA_SCOPE will be set for lambdas defined in -contexts where they would not be TU-local. */ - && !(LAMBDA_TYPE_P (type) - && LAMBDA_TYPE_EXTRA_SCOPE (type))) + if (LAMBDA_TYPE_P (type)) + { + /* A lambda expression is, in practice, TU-local iff it has no +mangling scope. This currently doesn't line up exactly with +the standard's definition due to some ABI issues, but it's +pretty close, and avoids other issues down the line. */ + if (!LAMBDA_TYPE_EXTRA_SCOPE (type)) + { + if (explain) + inform (loc, "%qT has no name and cannot be differentiated " + "from similar lambdas in other TUs", type); + return true; + } + } + else if (!DECL_CLASS_SCOPE_P (main_decl) + && !decl_function_context (main_decl)) { if (explain) inform (loc, "%qT has no name and is not defined within a class, " @@ -13820,6 +13841,35 @@ depset::hash::make_dependency (tree decl, entity_kind ek) return dep; } +/* Whether REF is an exposure of
[gcc r15-7975] cobol: Regenerate libgcobol/config.h.h
https://gcc.gnu.org/g:799ed87bcf6b5bede87311717adac5fb88fd7722 commit r15-7975-g799ed87bcf6b5bede87311717adac5fb88fd7722 Author: Jakub Jelinek Date: Tue Mar 11 22:47:26 2025 +0100 cobol: Regenerate libgcobol/config.h.h I forgot to regenerate config.h.in when changing configure.ac. 2025-03-11 Jakub Jelinek * config.h.in: Regenerate. Diff: --- libgcobol/config.h.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libgcobol/config.h.in b/libgcobol/config.h.in index c9095ff89063..39b20448078a 100644 --- a/libgcobol/config.h.in +++ b/libgcobol/config.h.in @@ -61,6 +61,9 @@ /* Define to the version of this package. */ #undef PACKAGE_VERSION +/* The size of `void *', as computed by sizeof. */ +#undef SIZEOF_VOID_P + /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS
[gcc r15-7923] LoongArch: Fix ICE when trying to recognize bitwise + alsl.w pair [PR119127]
https://gcc.gnu.org/g:c7d493baf13f1f144f2c4bc375383b6ce5d88a76 commit r15-7923-gc7d493baf13f1f144f2c4bc375383b6ce5d88a76 Author: Xi Ruoyao Date: Fri Mar 7 12:49:54 2025 +0800 LoongArch: Fix ICE when trying to recognize bitwise + alsl.w pair [PR119127] When we call loongarch_reassoc_shift_bitwise for _alsl_reversesi_extend, the mask is in DImode but we are trying to operate it in SImode, causing an ICE. To fix the issue sign-extend the mask into the mode we want. And also specially handle the case the mask is extended into -1 to avoid a miss-optimization. gcc/ChangeLog: PR target/119127 * config/loongarch/loongarch.cc (loongarch_reassoc_shift_bitwise): Sign extend mask to mode, specially handle the case it's extended to -1. * config/loongarch/loongarch.md (loongarch_reassoc_shift_bitwise): Update the comment for the special case. Diff: --- gcc/config/loongarch/loongarch.cc | 22 +++--- gcc/config/loongarch/loongarch.md | 6 ++ gcc/testsuite/gcc.target/loongarch/pr119127.c | 14 ++ 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc index 68f5d8584765..01f048664b55 100644 --- a/gcc/config/loongarch/loongarch.cc +++ b/gcc/config/loongarch/loongarch.cc @@ -4575,8 +4575,22 @@ loongarch_reassoc_shift_bitwise (bool is_and, rtx shamt, rtx mask, if (ctz_hwi (INTVAL (mask)) < INTVAL (shamt)) return NULL_RTX; + /* When trying alsl.w, deliberately ignore the high bits. */ + mask = gen_int_mode (UINTVAL (mask), mode); + rtx new_mask = simplify_const_binary_operation (LSHIFTRT, mode, mask, shamt); + + /* Do an arithmetic shift for checking ins_zero_bitmask_operand or -1: + ashiftrt (0x, 2) is 0x6000 which is an + ins_zero_bitmask_operand, but lshiftrt will produce + 0x3fff6000. */ + rtx new_mask_1 = simplify_const_binary_operation (ASHIFTRT, mode, mask, + shamt); + + if (is_and && const_m1_operand (new_mask_1, mode)) +return new_mask_1; + if (const_uns_arith_operand (new_mask, mode)) return new_mask; @@ -4586,13 +4600,7 @@ loongarch_reassoc_shift_bitwise (bool is_and, rtx shamt, rtx mask, if (low_bitmask_operand (new_mask, mode)) return new_mask; - /* Do an arithmetic shift for checking ins_zero_bitmask_operand: - ashiftrt (0x, 2) is 0x6000 which is an - ins_zero_bitmask_operand, but lshiftrt will produce - 0x3fff6000. */ - new_mask = simplify_const_binary_operation (ASHIFTRT, mode, mask, - shamt); - return ins_zero_bitmask_operand (new_mask, mode) ? new_mask : NULL_RTX; + return ins_zero_bitmask_operand (new_mask_1, mode) ? new_mask_1 : NULL_RTX; } /* Implement TARGET_CONSTANT_ALIGNMENT. */ diff --git a/gcc/config/loongarch/loongarch.md b/gcc/config/loongarch/loongarch.md index 90c475ef0c0a..f7005dee5b61 100644 --- a/gcc/config/loongarch/loongarch.md +++ b/gcc/config/loongarch/loongarch.md @@ -3200,10 +3200,8 @@ emit_insn (gen_di3 (operands[0], operands[1], operands[3])); else { - /* Hmm would we really reach here? If we reach here we'd have - a miss-optimization in the generic code (as it should have - optimized this to alslsi3_extend_subreg). But let's be safe - than sorry. */ + /* We can end up here with things like: + x:DI = sign_extend(a:SI + ((b:DI << 2) & 0xfffc)#0) */ gcc_checking_assert (); emit_move_insn (operands[0], operands[1]); } diff --git a/gcc/testsuite/gcc.target/loongarch/pr119127.c b/gcc/testsuite/gcc.target/loongarch/pr119127.c new file mode 100644 index ..4e253beb0f44 --- /dev/null +++ b/gcc/testsuite/gcc.target/loongarch/pr119127.c @@ -0,0 +1,14 @@ +/* PR target/119127: ICE caused by operating DImode const in SImode */ +/* { dg-do compile } */ +/* { dg-options "-O2 -march=loongarch64 -mabi=lp64d" } */ + +int x; +struct Type { + unsigned SubclassData : 24; +} y; + +void +test (void) +{ + x = y.SubclassData * 37; +}
[gcc r15-7977] Revert "[rtl-optimization/117467] Avoid unnecessarily marking things live in ext-dce"
https://gcc.gnu.org/g:9cebf1234b88e55a04071bd55c9ec4e22c0899e6 commit r15-7977-g9cebf1234b88e55a04071bd55c9ec4e22c0899e6 Author: Jeff Law Date: Tue Mar 11 18:01:33 2025 -0600 Revert "[rtl-optimization/117467] Avoid unnecessarily marking things live in ext-dce" This reverts commit 4ed07a11ee2845c2085a3cd5cff043209a452441. Diff: --- gcc/ext-dce.cc | 12 1 file changed, 12 deletions(-) diff --git a/gcc/ext-dce.cc b/gcc/ext-dce.cc index 35ddda00cdb6..a03439501419 100644 --- a/gcc/ext-dce.cc +++ b/gcc/ext-dce.cc @@ -643,18 +643,6 @@ ext_dce_process_uses (rtx_insn *insn, rtx obj, /* The code of the RHS of a SET. */ enum rtx_code code = GET_CODE (src); - /* If we break the main loop below, then we will continue processing -sub-components of this RTX, including the SET_DEST. - -That is not necessary if the SET_DEST is a REG. We can just bump the -iterator to the next element to skip handling the SET_DEST. - -We can probably do this for ZERO_EXTRACT, STRICT_LOW_PART and SUBREG -destinations as well. But I want to rewrite all this code and keep -this fix conservative given we're deep into the gcc-15 release cycle. */ - if (REG_P (dst)) - iter.next (); - /* ?!? How much of this should mirror SET handling, potentially being shared? */ if (SUBREG_P (dst) && SUBREG_BYTE (dst).is_constant ())
[gcc r14-11403] arm: testsuite: improve guard checks for arm_neon.h
https://gcc.gnu.org/g:f1dd3a17cf34d26f448bc2fd4f6c218c38140b08 commit r14-11403-gf1dd3a17cf34d26f448bc2fd4f6c218c38140b08 Author: Richard Earnshaw Date: Tue Mar 4 16:17:32 2025 + arm: testsuite: improve guard checks for arm_neon.h The header file arm_neon.h provides the Advanced SIMD intrinsics that are available on armv7 or later A & R profile cores. However, they are not compatible with M-profile and we also need to ensure that the FP instructions are enabled (with -mfloat-abi=softfp/hard). That leads to some complicated checking as arm_neon.h includes stdint.h and, at least on linux, that can require that the appropriate ABI bits/ headers are also installed. This patch adds a new check to target-supports.exp to establish the minimal set of option overrides needed to enable use of this header in a test. gcc/testsuite: * lib/target-supports.exp (check_effective_target_arm_neon_h_ok_nocache): New function. (check_effective_target_arm_neon_h_ok): Likewise. (add_options_for_arm_neon_h): Likewise. (check_effective_target_arm_libc_fp_abi_ok_nocache): Allow any Arm target, not just arm32. * gcc.target/arm/attr-neon-builtin-fail.c: Use it. * gcc.target/arm/attr-neon-builtin-fail2.c: Likewise. * gcc.target/arm/attr-neon-fp16.c: Likewise. * gcc.target/arm/attr-neon2.c: Likewise. (cherry picked from commit b7f5d9114801716924a67ea393f0c30ab793e505) Diff: --- .../gcc.target/arm/attr-neon-builtin-fail.c| 6 +-- .../gcc.target/arm/attr-neon-builtin-fail2.c | 5 +- gcc/testsuite/gcc.target/arm/attr-neon-fp16.c | 4 +- gcc/testsuite/gcc.target/arm/attr-neon2.c | 5 +- gcc/testsuite/lib/target-supports.exp | 53 +- 5 files changed, 60 insertions(+), 13 deletions(-) diff --git a/gcc/testsuite/gcc.target/arm/attr-neon-builtin-fail.c b/gcc/testsuite/gcc.target/arm/attr-neon-builtin-fail.c index fb6e0b9cd66a..645d708f0050 100644 --- a/gcc/testsuite/gcc.target/arm/attr-neon-builtin-fail.c +++ b/gcc/testsuite/gcc.target/arm/attr-neon-builtin-fail.c @@ -1,9 +1,8 @@ /* Check that calling a neon builtin from a function compiled with vfp fails. */ /* { dg-do compile } */ -/* { dg-require-effective-target arm_fp_ok } */ -/* { dg-require-effective-target arm_neon_ok } */ +/* { dg-require-effective-target arm_neon_h_ok } */ /* { dg-options "-O2" } */ -/* { dg-add-options arm_fp } */ +/* { dg-add-options arm_neon_h } */ #include @@ -15,4 +14,3 @@ foo (uint8x16_t *p) } /* { dg-error "inlining failed in call to 'always_inline'" "" { target *-*-* } 0 } */ - diff --git a/gcc/testsuite/gcc.target/arm/attr-neon-builtin-fail2.c b/gcc/testsuite/gcc.target/arm/attr-neon-builtin-fail2.c index 9cb5a2ebb905..ed0c4634b772 100644 --- a/gcc/testsuite/gcc.target/arm/attr-neon-builtin-fail2.c +++ b/gcc/testsuite/gcc.target/arm/attr-neon-builtin-fail2.c @@ -1,8 +1,8 @@ /* Check that calling a neon builtin from a function compiled with vfp fails. */ /* { dg-do compile } */ -/* { dg-require-effective-target arm_vfp_ok } */ +/* { dg-require-effective-target arm_neon_h_ok } */ /* { dg-options "-O2" } */ -/* { dg-add-options arm_vfp } */ +/* { dg-add-options arm_neon_h } */ extern __simd64_int8_t a, b; @@ -13,4 +13,3 @@ foo (__simd128_int16_t *p) *p = (__simd128_int16_t)__builtin_neon_vaddlsv8qi (a, b); /* { dg-error "You must enable NEON instructions .*" } */ } - diff --git a/gcc/testsuite/gcc.target/arm/attr-neon-fp16.c b/gcc/testsuite/gcc.target/arm/attr-neon-fp16.c index d7b75645bc45..a5982604f9ed 100644 --- a/gcc/testsuite/gcc.target/arm/attr-neon-fp16.c +++ b/gcc/testsuite/gcc.target/arm/attr-neon-fp16.c @@ -1,8 +1,8 @@ /* { dg-do compile } */ /* { dg-skip-if "-mpure-code supports M-profile only and without Neon" { *-*-* } { "-mpure-code" } } */ -/* { dg-require-effective-target arm_fp_ok } */ +/* { dg-require-effective-target arm_neon_h_ok } */ /* { dg-options "-mfp16-format=ieee" } */ -/* { dg-add-options arm_fp } */ +/* { dg-add-options arm_neon_h } */ #include "arm_neon.h" diff --git a/gcc/testsuite/gcc.target/arm/attr-neon2.c b/gcc/testsuite/gcc.target/arm/attr-neon2.c index a7a72dac379d..c0f7667c2dcd 100644 --- a/gcc/testsuite/gcc.target/arm/attr-neon2.c +++ b/gcc/testsuite/gcc.target/arm/attr-neon2.c @@ -1,8 +1,7 @@ /* { dg-do compile } */ -/* { dg-require-effective-target arm_neon_ok } */ -/* { dg-require-effective-target arm_fp_ok } */ +/* { dg-require-effective-target arm_neon_h_ok } */ /* { dg-options "-Ofast" } */ -/* { dg-add-options arm_fp } */ +/* { dg-add-options arm_neon_h } */ /* Reset fpu to a value compatible with the next pragmas. */ #pragma GCC target ("fpu=vfp") diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index f8856846f02d..112ff52bec19 100644 --- a/gcc/testsuite/
[gcc r14-11404] arm: testsuite: fix arm_neon_h checks with conflicting cpu/arch
https://gcc.gnu.org/g:de08b13018a13970475a4936265673b21dccb691 commit r14-11404-gde08b13018a13970475a4936265673b21dccb691 Author: Richard Earnshaw Date: Tue Mar 11 10:48:54 2025 + arm: testsuite: fix arm_neon_h checks with conflicting cpu/arch GCC will complain if the -mcpu flag specifies a different architecture to that specified in -march, but if the floating-point ABI is "soft", then differences in the floating-point architecture features are ignored. However, the arm_libc_fp_abi checks whether we change the FP ABI by adding -mfloat-abi=hard/softfp to override the defaults. If that fails it won't add anything. Unfortunately arm_neon_h_ok wasn't correctly checking whether the libc check had worked and just assumed that it would always add something to enable FP. That's insufficient and we need to consider this failure. We simply mark tests as unsupported in this case. gcc/testsuite/ChangeLog: * lib/target-supports.exp (check_effective_target_arm_neon_h_ok_nocache): Return zero if check_effective_target_arm_libc_fp_abi_ok reports failure. (cherry picked from commit 1b7a05770833eb210783ec8babd0027ec237d191) Diff: --- gcc/testsuite/lib/target-supports.exp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 112ff52bec19..e9f9bb06f3be 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -4794,7 +4794,8 @@ proc add_options_for_arm_libc_fp_abi { flags } { proc check_effective_target_arm_neon_h_ok_nocache { } { # none-arm or thumb1 cannot support neon, so there's no point in # looking further. -if { [istarget arm*-*-*] } { +if { [istarget arm*-*-*] +&& [check_effective_target_arm_libc_fp_abi_ok]} { global et_arm_neon_h_flags set base_flags [add_options_for_arm_libc_fp_abi ""] foreach flags {"" "-mfpu=auto" "-marm" "-marm -mfpu=auto" \
[gcc r15-7976] c: Don't emit -Wunterminated-string-initialization warning for multi-dimensional nonstring array ini
https://gcc.gnu.org/g:afb46540d3921e96c4cd7ba8fa2c8b0901759455 commit r15-7976-gafb46540d3921e96c4cd7ba8fa2c8b0901759455 Author: Jakub Jelinek Date: Tue Mar 11 23:08:38 2025 +0100 c: Don't emit -Wunterminated-string-initialization warning for multi-dimensional nonstring array initializers [PR117178] My/Kees' earlier patches adjusted -Wunterminated-string-initialization warning so that it doesn't warn about initializers of nonstring decls and that nonstring attribute is allowed on multi-dimensional arrays. Unfortunately as this testcase shows, we still warn about initializers of multi-dimensional array nonstring decls. The problem is that in that case field passed to output_init_element is actually INTEGER_CST, index into the array. For RECORD_OR_UNION_TYPE_P (constructor_type) field is a FIELD_DECL which we want to use, but otherwise (in arrays) IMHO we want to use constructor_fields (which is the innermost FIELD_DECL whose part is being initialized), or - if that is NULL - constructor_decl, the whole decl being initialized with multi-dimensional array type. 2025-03-11 Jakub Jelinek PR c/117178 * c-typeck.cc (output_init_element): Pass field to digest_init only for record/union types, otherwise pass constructor_fields if non-NULL and constructor_decl if constructor_fields is NULL. * gcc.dg/Wunterminated-string-initialization-2.c: New test. Diff: --- gcc/c/c-typeck.cc | 6 +- .../gcc.dg/Wunterminated-string-initialization-2.c | 120 + 2 files changed, 125 insertions(+), 1 deletion(-) diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index bc51cc2693bf..11fa98d86ee8 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -11419,7 +11419,11 @@ output_init_element (location_t loc, tree value, tree origtype, if (!require_constexpr_value || !npc || TREE_CODE (constructor_type) != POINTER_TYPE) -new_value = digest_init (loc, field, type, new_value, origtype, npc, +new_value = digest_init (loc, +RECORD_OR_UNION_TYPE_P (constructor_type) +? field : constructor_fields +? constructor_fields : constructor_decl, +type, new_value, origtype, npc, int_const_expr, arith_const_expr, strict_string, require_constant_value, require_constexpr_value); if (new_value == error_mark_node) diff --git a/gcc/testsuite/gcc.dg/Wunterminated-string-initialization-2.c b/gcc/testsuite/gcc.dg/Wunterminated-string-initialization-2.c new file mode 100644 index ..73186a74decf --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wunterminated-string-initialization-2.c @@ -0,0 +1,120 @@ +/* PR c/117178 */ +/* { dg-do compile } */ +/* { dg-options "-Wunterminated-string-initialization" } */ + +const char a[][4] __attribute__((nonstring)) = { + "ABCD", + "EFGH", + "IJK", + "LMNO" +}; +const char b[][2][2] __attribute__((nonstring)) = { + { "PQ", +"R" }, + { "S", +"TU" } +}; +struct S { int c; char d[3][5] __attribute__((nonstring)); int e; } f = { + 0, + { "abcde", +"defg", +"hijkl" }, + 1 +}; +struct T { int g; char h[3][2][2] __attribute__((nonstring)); int i; } j = { + 0, + { { "m", + "no" }, +{ "pq", + "r" }, +{ "s", + "tu" } }, + 1 +}; +const char k[][4] = { + "ABCD", /* { dg-warning "initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute \\\(5 chars into 4 available\\\)" } */ + "EFGH", /* { dg-warning "initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute \\\(5 chars into 4 available\\\)" } */ + "IJK", + "LMNO" /* { dg-warning "initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute \\\(5 chars into 4 available\\\)" } */ +}; +const char l[][2][2] = { + { "PQ", /* { dg-warning "initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute \\\(3 chars into 2 available\\\)" } */ +"R" }, + { "S", +"TU" } /* { dg-warning "initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute \\\(3 chars into 2 available\\\)" } */ +}; +struct U { int m; char n[3][5]; int o; } p = { + 0, + { "abcde", /* { dg-warning "initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute \\\(6 chars into 5 available\\\)" } */ +"defg", +"hijkl" }, /* { dg-warning "initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute \\\(6 chars into 5 available\\\)" } */ + 1 +}; +struct V { int q; char r[3][2][2]; int s; }
[gcc r15-7979] preprocessor: Fix up diagnostic typo in convert_oct [PR119202]
https://gcc.gnu.org/g:2fa031afe4ea78f490f06e487c48089d7376827c commit r15-7979-g2fa031afe4ea78f490f06e487c48089d7376827c Author: Jakub Jelinek Date: Wed Mar 12 07:46:25 2025 +0100 preprocessor: Fix up diagnostic typo in convert_oct [PR119202] In r15-4286 I've introduced a typo, part of the change was - cpp_error (pfile, CPP_DL_ERROR, "'\\o' not followed by '{'"); + cpp_error (pfile, CPP_DL_ERROR, "%<\\o%> not followed by %<}%>"); which turned { into }. This patch fixes it back. 2025-03-12 Jakub Jelinek PR preprocessor/119202 * charset.cc (convert_oct): Fix up typo in diagnostics about \o not followed by {. Diff: --- libcpp/charset.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcpp/charset.cc b/libcpp/charset.cc index 98a58a054196..e3accf8e9a58 100644 --- a/libcpp/charset.cc +++ b/libcpp/charset.cc @@ -2244,7 +2244,7 @@ convert_oct (cpp_reader *pfile, const uchar *from, const uchar *limit, from++; extend_char_range (&char_range, loc_reader); if (from == limit || *from != '{') - cpp_error (pfile, CPP_DL_ERROR, "%<\\o%> not followed by %<}%>"); + cpp_error (pfile, CPP_DL_ERROR, "%<\\o%> not followed by %<{%>"); else { from++;
[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] Utilisation d'un seul objet heap_memory global
https://gcc.gnu.org/g:9962948fa720820cb2a22b74253c425d3d108062 commit 9962948fa720820cb2a22b74253c425d3d108062 Author: Mikael Morin Date: Tue Mar 4 18:40:22 2025 +0100 Utilisation d'un seul objet heap_memory global Diff: --- gcc/cgraphunit.cc | 513 ++ 1 file changed, 364 insertions(+), 149 deletions(-) diff --git a/gcc/cgraphunit.cc b/gcc/cgraphunit.cc index dfeb89ab8194..a97fbec407c6 100644 --- a/gcc/cgraphunit.cc +++ b/gcc/cgraphunit.cc @@ -2371,14 +2371,34 @@ enum value_type }; +enum storage_type +{ + STRG_VARIABLE, + STRG_ALLOC +}; + +class heap_memory; + struct storage_ref { - const exec_context & context; + enum storage_type type; + union u +{ + u (const exec_context & ctx) : var_context (&ctx) {} + u (const heap_memory & m) : alloc_mem (&m) {} + const exec_context * var_context; + const heap_memory * alloc_mem; +} + u; unsigned storage_index; storage_ref (const exec_context & ctx, unsigned idx) -: context (ctx), storage_index (idx) +: type (STRG_VARIABLE), u (ctx), storage_index (idx) + {} + storage_ref (const heap_memory & mem, unsigned idx) +: type (STRG_ALLOC), u (mem), storage_index (idx) {} + storage_ref (const storage_ref & other) = default; data_storage & get () const; }; @@ -2388,8 +2408,8 @@ struct storage_address storage_ref storage; unsigned offset; - storage_address (const exec_context & ctx, unsigned idx, unsigned off) -: storage (ctx, idx), offset (off) + storage_address (const storage_ref & ref, unsigned off) +: storage (ref), offset (off) {} }; @@ -2408,6 +2428,7 @@ namespace selftest void exec_context_evaluate_binary_tests (); void exec_context_execute_assign_tests (); void exec_context_execute_call_tests (); + void exec_context_allocate_tests (); } @@ -2461,57 +2482,54 @@ public: }; -enum storage_type -{ - STRG_VARIABLE, - STRG_ALLOC -}; +class heap_memory; +class context_printer; class data_storage { - const exec_context & context; const storage_type type; data_value value; union u { - u (tree t) : variable (t) {} - u (unsigned alloc_idx, unsigned alloc_amount) - : allocated (alloc_idx, alloc_amount) + u (const exec_context & ctx, tree t) : variable (ctx, t) {} + u (const heap_memory & mem, unsigned alloc_idx, unsigned alloc_amount) + : allocated (mem, alloc_idx, alloc_amount) {} //~u () {} struct v { - v (tree t) : decl (t) {} + v (const exec_context & ctx, tree t) : context (ctx), decl (t) {} + const exec_context & context; const tree decl; } variable; const struct a { - a (unsigned alloc_idx, unsigned alloc_amount) - : index (alloc_idx), amount_bits (alloc_amount) + a (const heap_memory & mem, unsigned alloc_idx, unsigned alloc_amount) + : alloc_mem (mem), index (alloc_idx), amount_bits (alloc_amount) {} - unsigned index; - unsigned amount_bits; + const heap_memory & alloc_mem; + const unsigned index; + const unsigned amount_bits; } allocated; } u; public: - data_storage (const exec_context &ctx, tree decl) -: context (ctx), type (STRG_VARIABLE), value (TREE_TYPE (decl)), -u (decl) + data_storage (const exec_context & ctx, tree decl) +: type (STRG_VARIABLE), value (TREE_TYPE (decl)), +u (ctx, decl) {} - data_storage (const exec_context &ctx, unsigned alloc_index, unsigned alloc_amount) -: context (ctx), type (STRG_ALLOC), value (alloc_amount), -u (alloc_index, alloc_amount) + data_storage (const heap_memory & mem, unsigned alloc_index, unsigned alloc_amount) +: type (STRG_ALLOC), value (alloc_amount), +u (mem, alloc_index, alloc_amount) {} storage_type get_type () const { return type; } - const exec_context & get_context () const { return context; } tree get_variable () const; bool matches (tree var) const @@ -2524,7 +2542,8 @@ public: data_storage & operator= (const data_storage& other) = default; void set (const data_value & val) { return value.set (val); } void set_at (const data_value & val, unsigned offset) { return value.set_at (val, offset); } - void print (pretty_printer & pp) const; + void print (context_printer & printer) const; + storage_ref get_ref () const; }; @@ -2542,6 +2561,7 @@ class context_printer public: context_printer (); context_printer (dump_flags_t f); + pretty_printer & get_pretty_printer () const { return const_cast (pp); } void begin_stmt (gimple *); void print (tree); void print_newline (); @@ -2559,15 +2579,30 @@ public: static data_value -execute (struct function *func, exec_context *caller, +execute (struct function *func, exec_context &caller, context_printer & printer, vec * args); + +class heap_me
[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] Ajout support TARGET_MEM_REF
https://gcc.gnu.org/g:decef7c0572b6bea75f461cb89355db51f04c3c7 commit decef7c0572b6bea75f461cb89355db51f04c3c7 Author: Mikael Morin Date: Tue Mar 4 21:00:06 2025 +0100 Ajout support TARGET_MEM_REF Diff: --- gcc/cgraphunit.cc | 271 -- 1 file changed, 264 insertions(+), 7 deletions(-) diff --git a/gcc/cgraphunit.cc b/gcc/cgraphunit.cc index a97fbec407c6..f29e9aa846b8 100644 --- a/gcc/cgraphunit.cc +++ b/gcc/cgraphunit.cc @@ -3366,6 +3366,9 @@ data_value::get_at (unsigned offset, unsigned width) const result.set_address (*get_address_at (offset)); break; +case VAL_UNDEFINED: + break; + default: gcc_unreachable (); } @@ -3675,6 +3678,7 @@ exec_context::evaluate (tree expr) const break; case MEM_REF: +case TARGET_MEM_REF: { tree ptr = TREE_OPERAND (expr, 0); data_value val_ptr = evaluate (ptr); @@ -3686,7 +3690,7 @@ exec_context::evaluate (tree expr) const tree offset_bytes = TREE_OPERAND (expr, 1); data_value val_off = evaluate (offset_bytes); gcc_assert (val_off.classify () == VAL_CONSTANT); - wide_int wi_off = val_off.get_cst () * CHAR_BIT; + wide_int wi_off = val_off.get_cst (); gcc_assert (wi::fits_uhwi_p (wi_off)); unsigned offset = wi_off.to_uhwi (); @@ -3694,7 +3698,24 @@ exec_context::evaluate (tree expr) const if (!get_constant_type_size (TREE_TYPE (expr), bit_width)) gcc_unreachable (); - return storage_value.get_at (offset, bit_width); + if (code == TARGET_MEM_REF) + { + tree index = TREE_OPERAND (expr, 2); + data_value val_idx = evaluate (index); + gcc_assert (val_idx.classify () == VAL_CONSTANT); + wide_int wi_idx = val_idx.get_cst (); + + tree step = TREE_OPERAND (expr, 3); + data_value val_step = evaluate (step); + gcc_assert (val_step.classify () == VAL_CONSTANT); + wide_int wi_step = val_step.get_cst (); + + wide_int additional_off = wi_idx * wi_step; + gcc_assert (wi::fits_uhwi_p (additional_off)); + offset += additional_off.to_uhwi (); + } + + return storage_value.get_at (offset * CHAR_BIT, bit_width); } break; @@ -3852,7 +3873,8 @@ void exec_context::decompose_ref (tree data_ref, data_storage * & storage, int & offset) const { offset = -1; - switch (TREE_CODE (data_ref)) + enum tree_code code = TREE_CODE (data_ref); + switch (code) { case VAR_DECL: case SSA_NAME: @@ -3908,6 +3930,7 @@ exec_context::decompose_ref (tree data_ref, data_storage * & storage, int & offs break; case MEM_REF: +case TARGET_MEM_REF: { tree var = TREE_OPERAND (data_ref, 0); data_value addr = evaluate (var); @@ -3920,6 +3943,24 @@ exec_context::decompose_ref (tree data_ref, data_storage * & storage, int & offs wide_int wi_off = off_val.get_cst (); gcc_assert (wi::fits_uhwi_p (wi_off)); unsigned HOST_WIDE_INT uhwi_off = wi_off.to_uhwi (); + + if (code == TARGET_MEM_REF) + { + tree index = TREE_OPERAND (data_ref, 2); + data_value idx_val = evaluate (index); + gcc_assert (idx_val.classify () == VAL_CONSTANT); + wide_int wi_idx = idx_val.get_cst (); + + tree step = TREE_OPERAND (data_ref, 3); + data_value step_val = evaluate (step); + gcc_assert (step_val.classify () == VAL_CONSTANT); + wide_int wi_step = step_val.get_cst (); + + wide_int additional_off = wi_idx * wi_step; + gcc_assert (wi::fits_uhwi_p (additional_off)); + uhwi_off += additional_off.to_uhwi (); + } + gcc_assert (uhwi_off <= UINT_MAX / CHAR_BIT); offset = uhwi_off * CHAR_BIT; } @@ -3937,10 +3978,6 @@ void exec_context::execute_assign (gassign *g) { tree lhs = gimple_assign_lhs (g); - gcc_assert (TREE_CODE (lhs) == MEM_REF - || TREE_CODE (lhs) == SSA_NAME - || TREE_CODE (lhs) == VAR_DECL - || TREE_CODE (lhs) == COMPONENT_REF); tree lhs_type = TREE_TYPE (lhs); data_value value (lhs_type); @@ -5933,6 +5970,112 @@ exec_context_evaluate_tests () wide_int wi_val6 = eval6.get_cst (); ASSERT_PRED1 (wi::fits_shwi_p, wi_val6); ASSERT_EQ (wi_val6.to_shwi (), 8); + + + tree c29 = build_array_type_nelts (char_type_node, 29); + tree a29 = create_var (c29, "a29"); + tree ssa8 = make_node (SSA_NAME); + TREE_TYPE (ssa8) = size_type_node; + tree ssa9 = make_node (SSA_NAME); + TREE_TYPE (ssa9) = size_type_node; + + vec decls8{}; + decls8.safe_push (a29); + decls8.safe_push (ssa8); + decls8.safe_push (ssa9); + + context_builder builder8; + builder8.add_decls (&decls8); + exec_context ctx8 = builder8.build (mem, printer); + + data_storage * strg29 = ctx8.find_reachable_var (a29); + gcc_ass
[gcc r13-9423] d: Fix regression returning from function with invariants [PR119139]
https://gcc.gnu.org/g:2b37c9973967230b01dc5e38770fb3ec84610555 commit r13-9423-g2b37c9973967230b01dc5e38770fb3ec84610555 Author: Iain Buclaw Date: Tue Mar 11 17:56:18 2025 +0100 d: Fix regression returning from function with invariants [PR119139] An optimization was added in GDC-12 which sets the TREE_READONLY flag on all local variables with the storage class `const' assigned. For some reason, const is also being added by the front-end to `__result' variables in non-virtual functions, which ends up getting wrong code by the gimplify pass promoting the local to static storage. A bug has been raised upstream, as this looks like an error in the AST. For now, turn off setting TREE_READONLY on all result variables. PR d/119139 gcc/d/ChangeLog: * decl.cc (get_symbol_decl): Don't set TREE_READONLY for __result declarations. gcc/testsuite/ChangeLog: * gdc.dg/pr119139.d: New test. (cherry picked from commit 81582ca6cb692098c1bda7995aec46c6cbfbfcb3) Diff: --- gcc/d/decl.cc | 2 +- gcc/testsuite/gdc.dg/pr119139.d | 24 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc index 84274b3f3c31..deba3335a6a8 100644 --- a/gcc/d/decl.cc +++ b/gcc/d/decl.cc @@ -1313,7 +1313,7 @@ get_symbol_decl (Declaration *decl) /* `const` applies to data that cannot be changed by the const reference to that data. It may, however, be changed by another reference to that same data. */ - if (vd->isConst () && !vd->isDataseg ()) + if (vd->isConst () && !vd->isResult () && !vd->isDataseg ()) TREE_READONLY (decl->csym) = 1; } diff --git a/gcc/testsuite/gdc.dg/pr119139.d b/gcc/testsuite/gdc.dg/pr119139.d new file mode 100644 index ..dc42c411e390 --- /dev/null +++ b/gcc/testsuite/gdc.dg/pr119139.d @@ -0,0 +1,24 @@ +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119139 +// { dg-do compile } +// { dg-options "-fdump-tree-gimple" } +string toString() +{ +return "1"; +} + +struct B +{ +ulong n; + +invariant{} + +string str() +{ +if (n == 0) +{ +return "0"; +} +return toString(); +} +} +// { dg-final { scan-tree-dump-not "static const struct __result =" "gimple" } }
[gcc r15-7974] aarch64: Fix DFP constants [PR119131]
https://gcc.gnu.org/g:0bbdffc5d4f723f6a41b713519b156ea46ce5fc8 commit r15-7974-g0bbdffc5d4f723f6a41b713519b156ea46ce5fc8 Author: Andrew Pinski Date: Mon Mar 10 23:10:01 2025 -0700 aarch64: Fix DFP constants [PR119131] After r15-6660-g45d306a835cb3f865, in some cases DFP constants would cause an ICE. This is due to do a mismatch of a few things. The predicate of the move uses aarch64_valid_fp_move to say if the constant is valid or not. But after reload/LRA when can_create_pseudo_p returns false; aarch64_valid_fp_move would return false for constants that were valid for the constraints of the instruction. A strictor predicate compared to the constraint is wrong. In this case `Uvi` is the constraint while aarch64_valid_fp_move allows it via aarch64_can_const_movi_rtx_p for !DECIMAL_FLOAT_MODE_P, there is no such check for DECIMAL_FLOAT_MODE_P. The fix is to remove the check !DECIMAL_FLOAT_MODE_P in aarch64_valid_fp_move and in the define_expand. As now the predicate allows a superset of what is allowed by the constraints. aarch64_float_const_representable_p should be rejecting DFP modes as they can't be used with instructions like `mov s0, 1.0`. Changes since v1: * v2: Add check to aarch64_float_const_representable_p for DFP. Built and tested on aarch64-linux-gnu with no regressions. PR target/119131 gcc/ChangeLog: * config/aarch64/aarch64.cc (aarch64_valid_fp_move): Remove check for !DECIMAL_FLOAT_MODE_P. (aarch64_float_const_representable_p): Reject decimal floating modes. * config/aarch64/aarch64.md (mov): Likewise. gcc/testsuite/ChangeLog: * gcc.dg/torture/pr119131-1.c: New test. Signed-off-by: Andrew Pinski Diff: --- gcc/config/aarch64/aarch64.cc | 21 +++-- gcc/config/aarch64/aarch64.md | 3 +-- gcc/testsuite/gcc.dg/torture/pr119131-1.c | 31 +++ 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index 36b65df50c57..41054b54b383 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -11328,17 +11328,14 @@ aarch64_valid_fp_move (rtx dst, rtx src, machine_mode mode) if (MEM_P (src)) return true; - if (!DECIMAL_FLOAT_MODE_P (mode)) -{ - if (aarch64_can_const_movi_rtx_p (src, mode) - || aarch64_float_const_representable_p (src) - || aarch64_float_const_zero_rtx_p (src)) - return true; + if (aarch64_can_const_movi_rtx_p (src, mode) + || aarch64_float_const_representable_p (src) + || aarch64_float_const_zero_rtx_p (src)) +return true; - /* Block FP immediates which are split during expand. */ - if (aarch64_float_const_rtx_p (src)) - return false; -} + /* Block FP immediates which are split during expand. */ + if (aarch64_float_const_rtx_p (src)) +return false; return can_create_pseudo_p (); } @@ -25611,6 +25608,10 @@ aarch64_float_const_representable_p (rtx x) { x = unwrap_const_vec_duplicate (x); machine_mode mode = GET_MODE (x); + + if (DECIMAL_FLOAT_MODE_P (mode)) +return false; + if (!CONST_DOUBLE_P (x)) return false; diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md index 03188a64ab17..031e621c98a1 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -1762,8 +1762,7 @@ && aarch64_float_const_zero_rtx_p (operands[1]))) operands[1] = force_reg (mode, operands[1]); -if (!DECIMAL_FLOAT_MODE_P (mode) - && GET_CODE (operands[1]) == CONST_DOUBLE +if (GET_CODE (operands[1]) == CONST_DOUBLE && can_create_pseudo_p () && !aarch64_can_const_movi_rtx_p (operands[1], mode) && !aarch64_float_const_representable_p (operands[1]) diff --git a/gcc/testsuite/gcc.dg/torture/pr119131-1.c b/gcc/testsuite/gcc.dg/torture/pr119131-1.c new file mode 100644 index ..c62f702f98c1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr119131-1.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target dfp } */ +/* PR target/119131 */ + +typedef __attribute__((__vector_size__ (64))) char C; +typedef __attribute__((__vector_size__ (64))) _Decimal32 D; +int a, b; +_Decimal32 f; +C e; +C c; + +void +foo (D d) +{ + d -= *(_Decimal32 *) __builtin_memset (&f, 0, 4); + b += a; + if (a) +b /= 0; /* { dg-warning "division by zero" } */ + c = (C) d + e; +} + +void +foo1 (D d) +{ + __builtin_memset (&f, 0, 4); + d -= *(_Decimal32 *)&f; + b += a; + if (a) +b /= 0;/* { dg-warning "division by zero" } */ + c = (C) d + e; +}
[gcc r15-7973] c++: constexpr caching deleted pointer [PR119162]
https://gcc.gnu.org/g:17ef5cad94d3f8f5fb1d8b749adf04c9d775ab9c commit r15-7973-g17ef5cad94d3f8f5fb1d8b749adf04c9d775ab9c Author: Jason Merrill Date: Mon Mar 10 14:10:52 2025 -0400 c++: constexpr caching deleted pointer [PR119162] In this testcase, we pass the checks for mismatched new/delete because the pointer is deleted before it is returned. And then a subsequent evaluation uses the cached value, but the deleted heap var isn't in ctx->global->heap_vars anymore, so cxx_eval_outermost_constant_expr doesn't run find_heap_var_refs, and ends up with garbage. Fixed by not caching a reference to deleted. I considered rejecting such a reference immediately as non-constant, but I don't think that's valid; an invalid pointer value isn't UB until we try to do something with it or it winds up in the final result of constant evaluation. I also considered not caching other heap references (i.e. using find_heap_var_refs instead of adding find_deleted_heap_var), which would include heap pointers passed in from the caller, but those don't have the same heap_vars problem. We might want cxx_eval_outermost_constant_expr to prune constexpr_call entries that refer to objects created during the evaluation, but that applies to local variables and temporaries just as much as heap "variables". PR c++/119162 gcc/cp/ChangeLog: * constexpr.cc (find_deleted_heap_var): New. (cxx_eval_call_expression): Don't cache a reference to heap_deleted. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/constexpr-new26.C: New test. Diff: --- gcc/cp/constexpr.cc | 25 +++-- gcc/testsuite/g++.dg/cpp2a/constexpr-new26.C | 17 + 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc index 381e5e294bdd..76a9176a8917 100644 --- a/gcc/cp/constexpr.cc +++ b/gcc/cp/constexpr.cc @@ -1124,8 +1124,9 @@ struct GTY((for_user)) constexpr_call { tree bindings; /* Result of the call. NULL means the call is being evaluated. - error_mark_node means that the evaluation was erroneous; - otherwise, the actuall value of the call. */ + error_mark_node means that the evaluation was erroneous or otherwise + uncacheable (e.g. because it depends on the caller). + Otherwise, the actual value of the call. */ tree result; /* The hash of this call; we remember it here to avoid having to recalculate it when expanding the hash table. */ @@ -1520,6 +1521,7 @@ static tree cxx_eval_bare_aggregate (const constexpr_ctx *, tree, static tree cxx_fold_indirect_ref (const constexpr_ctx *, location_t, tree, tree, bool * = NULL); static tree find_heap_var_refs (tree *, int *, void *); +static tree find_deleted_heap_var (tree *, int *, void *); /* Attempt to evaluate T which represents a call to a builtin function. We assume here that all builtin functions evaluate to scalar types @@ -3414,6 +3416,11 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, cacheable = false; break; } + /* And don't cache a ref to a deleted heap variable (119162). */ + if (cacheable + && (cp_walk_tree_without_duplicates + (&result, find_deleted_heap_var, NULL))) + cacheable = false; } /* Rewrite all occurrences of the function's RESULT_DECL with the @@ -8965,6 +8972,20 @@ find_heap_var_refs (tree *tp, int *walk_subtrees, void */*data*/) return NULL_TREE; } +/* Look for deleted heap variables in the expression *TP. */ + +static tree +find_deleted_heap_var (tree *tp, int *walk_subtrees, void */*data*/) +{ + if (VAR_P (*tp) + && DECL_NAME (*tp) == heap_deleted_identifier) +return *tp; + + if (TYPE_P (*tp)) +*walk_subtrees = 0; + return NULL_TREE; +} + /* Find immediate function decls in *TP if any. */ static tree diff --git a/gcc/testsuite/g++.dg/cpp2a/constexpr-new26.C b/gcc/testsuite/g++.dg/cpp2a/constexpr-new26.C new file mode 100644 index ..c82bd43205f4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/constexpr-new26.C @@ -0,0 +1,17 @@ +// PR c++/119162 +// { dg-do compile { target c++20 } } + +constexpr int * +f7 () +{ + int *p = new int (2);// { dg-error "is not a constant expression because it refers to a result of" } + delete p; + return p; +} + +void +g () +{ + constexpr auto v7 = f7 (); +} +
[gcc r14-11398] Fortran: ICE in gfc_conv_expr_present w. defined assignment [PR118640]
https://gcc.gnu.org/g:5cb69a5e4f136dd92c2182d6744aff2c12291a4f commit r14-11398-g5cb69a5e4f136dd92c2182d6744aff2c12291a4f Author: Paul Thomas Date: Mon Jan 27 09:55:26 2025 + Fortran: ICE in gfc_conv_expr_present w. defined assignment [PR118640] 2025-01-27 Paul Thomas gcc/fortran PR fortran/118640 * resolve.cc (generate_component_assignments): Make sure that the rhs temporary does not pick up the optional attribute from the lhs. gcc/testsuite/ PR fortran/118640 * gfortran.dg/pr118640.f90: New test. (cherry picked from commit 3600b1ff14a459e84bb40bdfea7cd8d2ffd73d8d) Diff: --- gcc/fortran/resolve.cc | 5 + gcc/testsuite/gfortran.dg/pr118640.f90 | 38 ++ 2 files changed, 43 insertions(+) diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 71cb3d758016..7df879bf1585 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -12159,7 +12159,12 @@ generate_component_assignments (gfc_code **code, gfc_namespace *ns) tmp_expr = get_temp_from_expr ((*code)->expr1, ns); if (tmp_expr->symtree->n.sym->attr.pointer) { + /* Use allocate on assignment for the sake of simplicity. The +temporary must not take on the optional attribute. Assume +that the assignment is guarded by a PRESENT condition if the +lhs is optional. */ tmp_expr->symtree->n.sym->attr.pointer = 0; + tmp_expr->symtree->n.sym->attr.optional = 0; tmp_expr->symtree->n.sym->attr.allocatable = 1; } this_code = build_assignment (EXEC_ASSIGN, diff --git a/gcc/testsuite/gfortran.dg/pr118640.f90 b/gcc/testsuite/gfortran.dg/pr118640.f90 new file mode 100644 index ..8f74dbff0679 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr118640.f90 @@ -0,0 +1,38 @@ +! { dg-do compile } +! +! Check the fix for an ICE in gfc_conv_expr_present, which resulted from +! the rhs temporary picking up the optional attribute from the lhs in a +! defined assignment. +! +! Contributed by Jakub Jelenik +! +module foo + type t1 + contains +procedure bar +generic :: assignment(=) => bar + end type + type t2 +type(t1) m + end type +contains + subroutine bar (x, y) +intent(in) y +class(t1), intent(out) :: x + end subroutine +end module +subroutine baz (x, y) + use foo + integer y + type(t2), pointer, optional :: x + interface +function qux (x) + use foo + integer x + type(t2) qux +end function + end interface + if (present (x)) then +x = qux (y) ! ICE was here + end if +end subroutine