[gcc r14-10051] Revert "RISC-V: Support highest overlap for wv instructions"
https://gcc.gnu.org/g:f5447eae72f11d9bfbb403183fd282918c0445c6 commit r14-10051-gf5447eae72f11d9bfbb403183fd282918c0445c6 Author: Pan Li Date: Sat Apr 20 09:42:57 2024 +0800 Revert "RISC-V: Support highest overlap for wv instructions" This reverts commit 7e854b58084c131fceca9e8fa9dcc7469972e69d. Diff: --- gcc/config/riscv/vector.md | 88 ++-- .../gcc.target/riscv/rvv/base/pr112431-39.c| 158 - .../gcc.target/riscv/rvv/base/pr112431-40.c| 94 .../gcc.target/riscv/rvv/base/pr112431-41.c| 62 4 files changed, 42 insertions(+), 360 deletions(-) diff --git a/gcc/config/riscv/vector.md b/gcc/config/riscv/vector.md index 8298a72b771..8a727e2ea41 100644 --- a/gcc/config/riscv/vector.md +++ b/gcc/config/riscv/vector.md @@ -3842,48 +3842,46 @@ (set_attr "group_overlap" "W21,W21,W21,W21,W42,W42,W42,W42,W84,W84,W84,W84,none,none")]) (define_insn "@pred_single_widen_sub" - [(set (match_operand:VWEXTI 0 "register_operand" "=vd, vr, vd, vr, vd, vr, vd, vr, vd, vr, vd, vr, ?, ?") + [(set (match_operand:VWEXTI 0 "register_operand" "=,") (if_then_else:VWEXTI (unspec: - [(match_operand: 1 "vector_mask_operand" " vm,Wc1, vm,Wc1, vm,Wc1, vm,Wc1, vm,Wc1, vm,Wc1,vmWc1,vmWc1") -(match_operand 5 "vector_length_operand" " rK, rK, rK, rK, rK, rK, rK, rK, rK, rK, rK, rK, rK, rK") -(match_operand 6 "const_int_operand" " i, i, i, i, i, i, i, i, i, i, i, i,i,i") -(match_operand 7 "const_int_operand" " i, i, i, i, i, i, i, i, i, i, i, i,i,i") -(match_operand 8 "const_int_operand" " i, i, i, i, i, i, i, i, i, i, i, i,i,i") + [(match_operand: 1 "vector_mask_operand" "vmWc1,vmWc1") +(match_operand 5 "vector_length_operand" " rK, rK") +(match_operand 6 "const_int_operand" "i, i") +(match_operand 7 "const_int_operand" "i, i") +(match_operand 8 "const_int_operand" "i, i") (reg:SI VL_REGNUM) (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE) (minus:VWEXTI - (match_operand:VWEXTI 3 "register_operand" " vr, vr, vr, vr, vr, vr, vr, vr, vr, vr, vr, vr, vr, vr") + (match_operand:VWEXTI 3 "register_operand" " vr, vr") (any_extend:VWEXTI - (match_operand: 4 "register_operand" "W21,W21,W21,W21,W42,W42,W42,W42,W84,W84,W84,W84, vr, vr"))) - (match_operand:VWEXTI 2 "vector_merge_operand" " vu, vu, 0, 0, vu, vu, 0, 0, vu, vu, 0, 0, vu,0")))] + (match_operand: 4 "register_operand" " vr, vr"))) + (match_operand:VWEXTI 2 "vector_merge_operand" " vu, 0")))] "TARGET_VECTOR" "vwsub.wv\t%0,%3,%4%p1" [(set_attr "type" "viwalu") - (set_attr "mode" "") - (set_attr "group_overlap" "W21,W21,W21,W21,W42,W42,W42,W42,W84,W84,W84,W84,none,none")]) + (set_attr "mode" "")]) (define_insn "@pred_single_widen_add" - [(set (match_operand:VWEXTI 0 "register_operand" "=vd, vr, vd, vr, vd, vr, vd, vr, vd, vr, vd, vr, ?, ?") + [(set (match_operand:VWEXTI 0 "register_operand" "=,") (if_then_else:VWEXTI (unspec: - [(match_operand: 1 "vector_mask_operand" " vm,Wc1, vm,Wc1, vm,Wc1, vm,Wc1, vm,Wc1, vm,Wc1,vmWc1,vmWc1") -(match_operand 5 "vector_length_operand" " rK, rK, rK, rK, rK, rK, rK, rK, rK, rK, rK, rK, rK, rK") -(match_operand 6 "const_int_operand" " i, i, i, i, i, i, i, i, i, i, i, i,i,i") -(match_operand 7 "const_int_operand" " i, i, i, i, i, i, i, i, i, i, i, i,i,i") -(match_operand 8 "const_int_operand" " i, i, i, i, i, i, i, i, i, i, i, i,i,i") + [(match_operand: 1 "vector_mask_operand" "vmWc1,vmWc1") +(match_operand 5 "vector_length_operand" " rK, rK") +(match_operand 6 "const_int_operand" "i, i") +(match_operand 7 "const_int_operand" "i, i") +(match_operand 8 "const_int_operand" "i, i") (reg:SI VL_REGNUM) (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE) (plus:VWEXTI (any_extend:VWEXTI - (match_operand: 4 "register_operand" "W21,W21,W21,W21,W42,W42,W42,W42,W84,W84,W84,W84, vr, vr")) - (match_operand:VWEXTI 3 "register_operand" " vr, vr, vr, vr, vr, vr, vr,
[gcc r14-10050] RISC-V: Add xfail test case for wv insn register overlap
https://gcc.gnu.org/g:9f10005dbc9b660465ec4a9640bcbdcc1e5171c3 commit r14-10050-g9f10005dbc9b660465ec4a9640bcbdcc1e5171c3 Author: Pan Li Date: Sat Apr 20 09:02:39 2024 +0800 RISC-V: Add xfail test case for wv insn register overlap We reverted below patch for wv insn overlap, add the related wv insn test and mark it as xfail. And we will remove the xfail after we support the register overlap in GCC-15. b3b2799b872 RISC-V: Support one more overlap for wv instructions gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/base/pr112431-42.c: New test. Signed-off-by: Pan Li Diff: --- .../gcc.target/riscv/rvv/base/pr112431-42.c| 30 ++ 1 file changed, 30 insertions(+) diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/pr112431-42.c b/gcc/testsuite/gcc.target/riscv/rvv/base/pr112431-42.c new file mode 100644 index 000..fa5dac58a20 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/pr112431-42.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ffast-math" } */ + +#include + +int64_t +reduc_plus_int (int *__restrict a, int n) +{ + int64_t r = 0; + for (int i = 0; i < n; ++i) +r += a[i]; + return r; +} + +double +reduc_plus_float (float *__restrict a, int n) +{ + double r = 0; + for (int i = 0; i < n; ++i) +r += a[i]; + return r; +} + +/* { dg-final { scan-assembler-not {vmv1r} { xfail riscv*-*-* } } } */ +/* { dg-final { scan-assembler-not {vmv2r} } } */ +/* { dg-final { scan-assembler-not {vmv4r} } } */ +/* { dg-final { scan-assembler-not {vmv8r} } } */ +/* { dg-final { scan-assembler-not {csrr} } } */ +/* { dg-final { scan-assembler-times {vwadd\.wv} 1 } } */ +/* { dg-final { scan-assembler-times {vfwadd\.wv} 1 } } */
[gcc r14-10049] Revert "RISC-V: Support one more overlap for wv instructions"
https://gcc.gnu.org/g:0cbeafe26513954b0aea3293d2f82d4863f10f1d commit r14-10049-g0cbeafe26513954b0aea3293d2f82d4863f10f1d Author: Pan Li Date: Sat Apr 20 08:29:38 2024 +0800 Revert "RISC-V: Support one more overlap for wv instructions" This reverts commit b3b2799b872bc4c1944629af9dfc8472c8ca5fe6. Diff: --- gcc/config/riscv/riscv.md | 14 ++-- gcc/config/riscv/vector.md | 84 +++--- .../gcc.target/riscv/rvv/base/pr112431-42.c| 30 3 files changed, 46 insertions(+), 82 deletions(-) diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md index c2b4323c53a..f0928398698 100644 --- a/gcc/config/riscv/riscv.md +++ b/gcc/config/riscv/riscv.md @@ -541,7 +541,7 @@ ;; Widening instructions have group-overlap constraints. Those are only ;; valid for certain register-group sizes. This attribute marks the ;; alternatives not matching the required register-group size as disabled. -(define_attr "group_overlap" "none,W21,W42,W84,W43,W86,W87,W0" +(define_attr "group_overlap" "none,W21,W42,W84,W43,W86,W87" (const_string "none")) (define_attr "group_overlap_valid" "no,yes" @@ -562,9 +562,9 @@ ;; According to RVV ISA: ;; The destination EEW is greater than the source EEW, the source EMUL is at least 1, - ;; and the overlap is in the highest-numbered part of the destination register group - ;; (e.g., when LMUL=8, vzext.vf4 v0, v6 is legal, but a source of v0, v2, or v4 is not). - ;; So the source operand should have LMUL >= 1. +;; and the overlap is in the highest-numbered part of the destination register group +;; (e.g., when LMUL=8, vzext.vf4 v0, v6 is legal, but a source of v0, v2, or v4 is not). +;; So the source operand should have LMUL >= 1. (and (eq_attr "group_overlap" "W43") (match_test "riscv_get_v_regno_alignment (GET_MODE (operands[0])) != 4 && riscv_get_v_regno_alignment (GET_MODE (operands[3])) >= 1")) @@ -574,12 +574,6 @@ (match_test "riscv_get_v_regno_alignment (GET_MODE (operands[0])) != 8 && riscv_get_v_regno_alignment (GET_MODE (operands[3])) >= 1")) (const_string "no") - - ;; W21 supports highest-number overlap for source LMUL = 1. - ;; For 'wv' variant, we can also allow wide source operand overlaps dest operand. - (and (eq_attr "group_overlap" "W0") - (match_test "riscv_get_v_regno_alignment (GET_MODE (operands[0])) > 1")) -(const_string "no") ] (const_string "yes"))) diff --git a/gcc/config/riscv/vector.md b/gcc/config/riscv/vector.md index 8b1c24c5d79..8298a72b771 100644 --- a/gcc/config/riscv/vector.md +++ b/gcc/config/riscv/vector.md @@ -3842,48 +3842,48 @@ (set_attr "group_overlap" "W21,W21,W21,W21,W42,W42,W42,W42,W84,W84,W84,W84,none,none")]) (define_insn "@pred_single_widen_sub" - [(set (match_operand:VWEXTI 0 "register_operand" "=vd, vr, vd, vr, vd, vr, vd, vr, vd, vr, vd, vr, , , ?, ?") + [(set (match_operand:VWEXTI 0 "register_operand" "=vd, vr, vd, vr, vd, vr, vd, vr, vd, vr, vd, vr, ?, ?") (if_then_else:VWEXTI (unspec: - [(match_operand: 1 "vector_mask_operand" " vm,Wc1, vm,Wc1, vm,Wc1, vm,Wc1, vm,Wc1, vm,Wc1,vmWc1,vmWc1,vmWc1,vmWc1") -(match_operand 5 "vector_length_operand" " rK, rK, rK, rK, rK, rK, rK, rK, rK, rK, rK, rK, rK, rK, rK, rK") -(match_operand 6 "const_int_operand" " i, i, i, i, i, i, i, i, i, i, i, i,i,i,i,i") -(match_operand 7 "const_int_operand" " i, i, i, i, i, i, i, i, i, i, i, i,i,i,i,i") -(match_operand 8 "const_int_operand" " i, i, i, i, i, i, i, i, i, i, i, i,i,i,i,i") + [(match_operand: 1 "vector_mask_operand" " vm,Wc1, vm,Wc1, vm,Wc1, vm,Wc1, vm,Wc1, vm,Wc1,vmWc1,vmWc1") +(match_operand 5 "vector_length_operand" " rK, rK, rK, rK, rK, rK, rK, rK, rK, rK, rK, rK, rK, rK") +(match_operand 6 "const_int_operand" " i, i, i, i, i, i, i, i, i, i, i, i,i,i") +(match_operand 7 "const_int_operand" " i, i, i, i, i, i, i, i, i, i, i, i,i,i") +(match_operand 8 "const_int_operand" " i, i, i, i, i, i, i, i, i, i, i, i,i,i") (reg:SI VL_REGNUM) (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE) (minus:VWEXTI - (match_operand:VWEXTI 3 "register_operand" " vr, vr, vr, vr, vr, vr, vr, vr, vr, vr, vr, vr,0,0, vr, vr") + (match_operand:VWEXTI 3 "register_operand" "
[gcc r14-10047] i386: Fix up *avx2_eq3 constraints [PR114783]
https://gcc.gnu.org/g:c23db3ebb65ba357155be85ef56d037403eaee36 commit r14-10047-gc23db3ebb65ba357155be85ef56d037403eaee36 Author: Jakub Jelinek Date: Sat Apr 20 00:13:49 2024 +0200 i386: Fix up *avx2_eq3 constraints [PR114783] The r14-4456 change (part of APX EGPR support) seems to have mistakenly changed in the @@ -16831,7 +16831,7 @@ (define_insn "*avx2_eq3" [(set (match_operand:VI_256 0 "register_operand" "=x") (eq:VI_256 (match_operand:VI_256 1 "nonimmediate_operand" "%x") - (match_operand:VI_256 2 "nonimmediate_operand" "xm")))] + (match_operand:VI_256 2 "nonimmediate_operand" "jm")))] "TARGET_AVX2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))" "vpcmpeq\t{%2, %1, %0|%0, %1, %2}" [(set_attr "type" "ssecmp") hunk the xm constraint to jm, while in many other spots it changed correctly xm to xjm. The instruction doesn't require the last operand to be in memory, it can handle 3 256-bit registers just fine, just it is a VEX only encoded instruction and so can't allow APX EGPR regs in the memory operand. The following patch fixes it, so that we don't force one of the == operands into memory all the time. 2024-04-20 Jakub Jelinek PR target/114783 * config/i386/sse.md (*avx2_eq3): Change last operand's constraint from "jm" to "xjm". * gcc.target/i386/avx2-pr114783.c: New test. Diff: --- gcc/config/i386/sse.md| 2 +- gcc/testsuite/gcc.target/i386/avx2-pr114783.c | 12 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md index 5bb49823f9a..1bf50726e83 100644 --- a/gcc/config/i386/sse.md +++ b/gcc/config/i386/sse.md @@ -17029,7 +17029,7 @@ [(set (match_operand:VI_256 0 "register_operand" "=x") (eq:VI_256 (match_operand:VI_256 1 "nonimmediate_operand" "%x") - (match_operand:VI_256 2 "nonimmediate_operand" "jm")))] + (match_operand:VI_256 2 "nonimmediate_operand" "xjm")))] "TARGET_AVX2 && !(MEM_P (operands[1]) && MEM_P (operands[2]))" "vpcmpeq\t{%2, %1, %0|%0, %1, %2}" [(set_attr "type" "ssecmp") diff --git a/gcc/testsuite/gcc.target/i386/avx2-pr114783.c b/gcc/testsuite/gcc.target/i386/avx2-pr114783.c new file mode 100644 index 000..bc4dc3005fc --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx2-pr114783.c @@ -0,0 +1,12 @@ +/* PR target/114783 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx2 -mno-avx512f -masm=att" } */ +/* { dg-final { scan-assembler "vpcmpeqd\[ \\t\]+%ymm\[01\], %ymm\[01\], %ymm0" } } */ + +typedef int V __attribute__((vector_size (32))); + +V +foo (V x, V y) +{ + return x == y; +}
[gcc r14-10046] c-family: Allow arguments with NULLPTR_TYPE as sentinels [PR114780]
https://gcc.gnu.org/g:2afdecccbaf5c5b1c7a235509b37092540906c02 commit r14-10046-g2afdecccbaf5c5b1c7a235509b37092540906c02 Author: Jakub Jelinek Date: Sat Apr 20 00:12:36 2024 +0200 c-family: Allow arguments with NULLPTR_TYPE as sentinels [PR114780] While in C++ the ellipsis argument conversions include "An argument that has type cv std::nullptr_t is converted to type void*" in C23 a nullptr_t argument is not promoted in any way, but va_arg description says: "the type of the next argument is nullptr_t and type is a pointer type that has the same representation and alignment requirements as a pointer to a character type." So, while in C++ check_function_sentinel will never see NULLPTR_TYPE, for C23 it can see that and currently we incorrectly warn about those. The only question is whether we should warn on any argument with nullptr_t type or just about nullptr (nullptr_t argument with integer_zerop value). Through undefined behavior guess one could pass non-NULL pointer that way, say by union { void *p; nullptr_t q; } u; u.p = and pass u.q to ..., but valid code should always pass something that will read as (char *) 0 when read using va_arg (ap, char *), so I think it is better not to warn rather than warn in those cases. Note, clang seems to pass (void *)0 rather than expression of nullptr_t type to ellipsis in C23 mode as if it did the C++ ellipsis argument conversions, in that case guess not warning about that would be even safer, but what GCC does I think follows the spec more closely, even when in a valid program one shouldn't be able to observe the difference. 2024-04-20 Jakub Jelinek PR c/114780 * c-common.cc (check_function_sentinel): Allow as sentinel any argument of NULLPTR_TYPE. * gcc.dg/format/sentinel-2.c: New test. Diff: --- gcc/c-family/c-common.cc | 1 + gcc/testsuite/gcc.dg/format/sentinel-2.c | 21 + 2 files changed, 22 insertions(+) diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc index 6fa8243b02b..01e3d247fc2 100644 --- a/gcc/c-family/c-common.cc +++ b/gcc/c-family/c-common.cc @@ -5783,6 +5783,7 @@ check_function_sentinel (const_tree fntype, int nargs, tree *argarray) sentinel = fold_for_warn (argarray[nargs - 1 - pos]); if ((!POINTER_TYPE_P (TREE_TYPE (sentinel)) || !integer_zerop (sentinel)) + && TREE_CODE (TREE_TYPE (sentinel)) != NULLPTR_TYPE /* Although __null (in C++) is only an integer we allow it nevertheless, as we are guaranteed that it's exactly as wide as a pointer, and we don't want to force diff --git a/gcc/testsuite/gcc.dg/format/sentinel-2.c b/gcc/testsuite/gcc.dg/format/sentinel-2.c new file mode 100644 index 000..4c29f6fb818 --- /dev/null +++ b/gcc/testsuite/gcc.dg/format/sentinel-2.c @@ -0,0 +1,21 @@ +/* PR c/114780 */ +/* { dg-do compile } */ +/* { dg-options "-std=c23 -Wformat" } */ + +#include + +[[gnu::sentinel]] void foo (int, ...); +[[gnu::sentinel]] void bar (...); + +void +baz (nullptr_t p) +{ + foo (1, 2, nullptr); + foo (3, 4, 5, p); + bar (nullptr); + bar (p); + foo (6, 7, 0); // { dg-warning "missing sentinel in function call" } + bar (0); // { dg-warning "missing sentinel in function call" } + foo (8, 9, NULL); + bar (NULL); +}
[gcc r14-10045] c: Fix ICE with -g and -std=c23 related to incomplete types [PR114361]
https://gcc.gnu.org/g:a39983bf58d3097c472252f6989d19b60909dd9a commit r14-10045-ga39983bf58d3097c472252f6989d19b60909dd9a Author: Jakub Jelinek Date: Sat Apr 20 00:05:21 2024 +0200 c: Fix ICE with -g and -std=c23 related to incomplete types [PR114361] We did not update TYPE_CANONICAL for incomplete variants when completing a structure. We now set for flag_isoc23 TYPE_STRUCTURAL_EQUALITY_P for incomplete structure and union types and then update TYPE_CANONICAL later, though update it only for the variants and derived pointer types which can be easily discovered. Other derived types created while the type was still incomplete will remain TYPE_STRUCTURAL_EQUALITY_P. See PR114574 for discussion. 2024-04-20 Martin Uecker Jakub Jelinek PR lto/114574 PR c/114361 gcc/c/ * c-decl.cc (shadow_tag_warned): For flag_isoc23 and code not ENUMERAL_TYPE use SET_TYPE_STRUCTURAL_EQUALITY. (parser_xref_tag): Likewise. (start_struct): For flag_isoc23 use SET_TYPE_STRUCTURAL_EQUALITY. (c_update_type_canonical): New function. (finish_struct): Put NULL as second == operand rather than first. Assert TYPE_STRUCTURAL_EQUALITY_P. Call c_update_type_canonical. * c-typeck.cc (composite_type_internal): Use SET_TYPE_STRUCTURAL_EQUALITY. Formatting fix. gcc/testsuite/ * gcc.dg/pr114574-1.c: New test. * gcc.dg/pr114574-2.c: New test. * gcc.dg/pr114361.c: New test. * gcc.dg/c23-tag-incomplete-1.c: New test. * gcc.dg/c23-tag-incomplete-2.c: New test. Diff: --- gcc/c/c-decl.cc | 49 - gcc/c/c-typeck.cc | 4 ++- gcc/testsuite/gcc.dg/c23-tag-incomplete-1.c | 11 +++ gcc/testsuite/gcc.dg/c23-tag-incomplete-2.c | 11 +++ gcc/testsuite/gcc.dg/pr114361.c | 10 ++ gcc/testsuite/gcc.dg/pr114574-1.c | 7 + gcc/testsuite/gcc.dg/pr114574-2.c | 7 + 7 files changed, 97 insertions(+), 2 deletions(-) diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc index 345090dae38..52af8f32998 100644 --- a/gcc/c/c-decl.cc +++ b/gcc/c/c-decl.cc @@ -5051,6 +5051,8 @@ shadow_tag_warned (const struct c_declspecs *declspecs, int warned) if (t == NULL_TREE) { t = make_node (code); + if (flag_isoc23 && code != ENUMERAL_TYPE) + SET_TYPE_STRUCTURAL_EQUALITY (t); pushtag (input_location, name, t); } } @@ -8809,6 +8811,8 @@ parser_xref_tag (location_t loc, enum tree_code code, tree name, the forward-reference will be altered into a real type. */ ref = make_node (code); + if (flag_isoc23 && code != ENUMERAL_TYPE) +SET_TYPE_STRUCTURAL_EQUALITY (ref); if (code == ENUMERAL_TYPE) { /* Give the type a default layout like unsigned int @@ -8910,6 +8914,8 @@ start_struct (location_t loc, enum tree_code code, tree name, if (ref == NULL_TREE || TREE_CODE (ref) != code) { ref = make_node (code); + if (flag_isoc23) + SET_TYPE_STRUCTURAL_EQUALITY (ref); pushtag (loc, name, ref); } @@ -9347,6 +9353,45 @@ is_flexible_array_member_p (bool is_last_field, return false; } +/* Recompute TYPE_CANONICAL for variants of the type including qualified + versions of the type and related pointer types after an aggregate type + has been finalized. + Will not update array types, pointers to array types, function + types and other derived types created while the type was still + incomplete, those will remain TYPE_STRUCTURAL_EQUALITY_P. */ + +static void +c_update_type_canonical (tree t) +{ + for (tree x = TYPE_MAIN_VARIANT (t); x; x = TYPE_NEXT_VARIANT (x)) +{ + if (x != t && TYPE_STRUCTURAL_EQUALITY_P (x)) + { + if (TYPE_QUALS (x) == TYPE_QUALS (t)) + TYPE_CANONICAL (x) = TYPE_CANONICAL (t); + else if (TYPE_CANONICAL (t) != t + || check_qualified_type (x, t, TYPE_QUALS (x))) + TYPE_CANONICAL (x) + = build_qualified_type (TYPE_CANONICAL (t), TYPE_QUALS (x)); + else + TYPE_CANONICAL (x) = x; + } + else if (x != t) + continue; + for (tree p = TYPE_POINTER_TO (x); p; p = TYPE_NEXT_PTR_TO (p)) + { + if (!TYPE_STRUCTURAL_EQUALITY_P (p)) + continue; + if (TYPE_CANONICAL (x) != x || TYPE_REF_CAN_ALIAS_ALL (p)) + TYPE_CANONICAL (p) + = build_pointer_type_for_mode (TYPE_CANONICAL (x), TYPE_MODE (p), +false); + else + TYPE_CANONICAL (p) = p; + c_update_type_canonical (p); + } +} +} /* Fill in the fields of a RECORD_TYPE or UNION_TYPE node,
[gcc r14-10044] libstdc++: Simplify constraints on <=> for std::reference_wrapper
https://gcc.gnu.org/g:d86472a6f041ccf3d1be0cf6bb15d1e0ad8f6dbe commit r14-10044-gd86472a6f041ccf3d1be0cf6bb15d1e0ad8f6dbe Author: Jonathan Wakely Date: Fri Apr 19 17:42:04 2024 +0100 libstdc++: Simplify constraints on <=> for std::reference_wrapper Instead of constraining these overloads in terms of synth-three-way we can just check that the value_type is less-than-comparable, which is what synth-three-way's constraints check. The reason that I implemented these with constraints has now been filed as LWG 4071, so add a comment about that too. libstdc++-v3/ChangeLog: * include/bits/refwrap.h (operator<=>): Simplify constraints. Diff: --- libstdc++-v3/include/bits/refwrap.h | 16 +++- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/libstdc++-v3/include/bits/refwrap.h b/libstdc++-v3/include/bits/refwrap.h index fd1cc2b63e6..71ec2b297b7 100644 --- a/libstdc++-v3/include/bits/refwrap.h +++ b/libstdc++-v3/include/bits/refwrap.h @@ -384,23 +384,29 @@ _GLIBCXX_MEM_FN_TRAITS(&& noexcept, false_type, true_type) && requires { { __x.get() == __y.get() } -> convertible_to; } { return __x.get() == __y.get(); } + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 4071. reference_wrapper comparisons are not SFINAE-friendly + [[nodiscard]] friend constexpr auto - operator<=>(reference_wrapper __x, reference_wrapper<_Tp> __y) - requires requires { __detail::__synth3way(__x.get(), __y.get()); } + operator<=>(reference_wrapper __x, reference_wrapper __y) + requires requires (const _Tp __t) { + { __t < __t } -> __detail::__boolean_testable; + } { return __detail::__synth3way(__x.get(), __y.get()); } [[nodiscard]] friend constexpr auto operator<=>(reference_wrapper __x, const _Tp& __y) - requires requires { __detail::__synth3way(__x.get(), __y); } + requires requires { { __y < __y } -> __detail::__boolean_testable; } { return __detail::__synth3way(__x.get(), __y); } [[nodiscard]] friend constexpr auto operator<=>(reference_wrapper __x, reference_wrapper __y) - requires (!is_const_v<_Tp>) - && requires { __detail::__synth3way(__x.get(), __y.get()); } + requires (!is_const_v<_Tp>) && requires (const _Tp __t) { + { __t < __t } -> __detail::__boolean_testable; + } { return __detail::__synth3way(__x.get(), __y.get()); } #endif };
[gcc r14-10043] libstdc++: Support link chains in std::chrono::tzdb::locate_zone [PR114770]
https://gcc.gnu.org/g:eed7fb1b2fe72150cd6af10dd3b8f7fc4f0a4da1 commit r14-10043-geed7fb1b2fe72150cd6af10dd3b8f7fc4f0a4da1 Author: Jonathan Wakely Date: Thu Apr 18 12:14:41 2024 +0100 libstdc++: Support link chains in std::chrono::tzdb::locate_zone [PR114770] Since 2022 the TZif format defined in the zic(8) man page has said that links can refer to other links, rather than only referring to a zone. This isn't supported by the C++20 spec, which assumes that the target() for a chrono::time_zone_link always names a chrono::time_zone, not another chrono::time_zone_link. This hasn't been a problem until now, because there are no entries in the tzdata file that chain links together. However, Debian Sid has changed the target of the Asia/Chungking link from the Asia/Shanghai zone to the Asia/Chongqing link, creating a link chain. The libstdc++ code is unable to handle this, so chrono::locate_zone("Asia/Chungking") will fail with the tzdata.zi file from Debian Sid. It seems likely that the C++ spec will need a change to allow link chains, so that the original structure of the IANA database can be fully represented by chrono::tzdb. The alternative would be for chrono::tzdb to flatten all chains when loading the data, so that a link's target is always a zone, but this means throwing away information present in the tzdata.zi input file. In anticipation of a change to the spec, this commit adds support for chained links to libstdc++. When a name is found to be a link, we try to find its target in the list of zones as before, but now if the target isn't the name of a zone we don't fail. Instead we look for another link with that name, and keep doing that until we reach the end of the chain of links, and then look up the last target as a zone. This new logic would get stuck in a loop if the tzdata.zi file is buggy and defines a link chain that contains a cycle, e.g. two links that refer to each other. To deal with that unlikely case, we use the tortoise and hare algorithm to detect cycles in link chains, and throw an exception if we detect a cycle. Cycles in links should never happen, and it is expected that link chains will be short (if they occur at all) and so the code is optimized for short chains without cycles. Longer chains (four or more links) and cycles will do more work, but won't fail to resolve a chain or get stuck in a loop. The new test file checks various forms of broken links and cycles. Also add a new check in the testsuite that every element in the get_tzdb().zones and get_tzdb().links sequences can be successfully found using locate_zone. libstdc++-v3/ChangeLog: PR libstdc++/114770 * src/c++20/tzdb.cc (do_locate_zone): Support links that have another link as their target. * testsuite/std/time/tzdb/1.cc: Check that all zones and links can be found by locate_zone. * testsuite/std/time/tzdb/links.cc: New test. Diff: --- libstdc++-v3/src/c++20/tzdb.cc| 57 ++- libstdc++-v3/testsuite/std/time/tzdb/1.cc | 12 ++ libstdc++-v3/testsuite/std/time/tzdb/links.cc | 215 ++ 3 files changed, 280 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/src/c++20/tzdb.cc b/libstdc++-v3/src/c++20/tzdb.cc index 639d1c440ba..c7c7cc9deee 100644 --- a/libstdc++-v3/src/c++20/tzdb.cc +++ b/libstdc++-v3/src/c++20/tzdb.cc @@ -1599,7 +1599,7 @@ namespace std::chrono const time_zone* do_locate_zone(const vector& zones, const vector& links, - string_view tz_name) noexcept + string_view tz_name) { // Lambda mangling changed between -fabi-version=2 and -fabi-version=18 auto search = [](const Vec& v, string_view name) { @@ -1610,13 +1610,62 @@ namespace std::chrono return ptr; }; + // Search zones first. if (auto tz = search(zones, tz_name)) return tz; + // Search links second. if (auto tz_l = search(links, tz_name)) - return search(zones, tz_l->target()); + { + // Handle the common case of a link that has a zone as the target. + if (auto tz = search(zones, tz_l->target())) [[likely]] + return tz; + + // Either tz_l->target() doesn't exist, or we have a chain of links. + // Use Floyd's cycle-finding algorithm to avoid infinite loops, + // at the cost of extra lookups. In the common case we expect a + // chain of links to be short so the loop won't run many times. + // In particular, the duplicate lookups to move the tortoise + // never happen unless the chain has four or more links. + // When a chain contains a cycle we do multiple duplicate lookups, + // but that case should never
[gcc r14-10042] Update gcc sv.po
https://gcc.gnu.org/g:e8f0540f23762ca155fe9ed70d6adb864be096b5 commit r14-10042-ge8f0540f23762ca155fe9ed70d6adb864be096b5 Author: Joseph Myers Date: Fri Apr 19 20:02:56 2024 + Update gcc sv.po * sv.po: Update. Diff: --- gcc/po/sv.po | 785 +++ 1 file changed, 195 insertions(+), 590 deletions(-) diff --git a/gcc/po/sv.po b/gcc/po/sv.po index d8a55cf55d3..32e63d610ac 100644 --- a/gcc/po/sv.po +++ b/gcc/po/sv.po @@ -32,7 +32,7 @@ msgstr "" "Project-Id-Version: gcc 14.1-b20240218\n" "Report-Msgid-Bugs-To: https://gcc.gnu.org/bugs/\n; "POT-Creation-Date: 2024-02-16 21:35+\n" -"PO-Revision-Date: 2024-04-02 09:51+0200\n" +"PO-Revision-Date: 2024-04-10 22:53+0200\n" "Last-Translator: Göran Uddeborg \n" "Language-Team: Swedish \n" "Language: sv\n" @@ -62421,10 +62421,9 @@ msgid "%<#pragma omp assumes%> may only be used at file or namespace scope" msgstr "%<#pragma omp assumes%> kan endast användas med fil- eller namnrymdsräckvidd" #: cp/parser.cc:51053 -#, fuzzy, gcc-internal-format -#| msgid "%<#pragma GCC ivdep%> must be inside a function" +#, gcc-internal-format msgid "%<#pragma GCC %s%> must be inside a function" -msgstr "%<#pragma GCC ivdep%> måste vara inuti en funktion" +msgstr "%<#pragma GCC %s%> måste vara inuti en funktion" #: cp/parser.cc:51195 #, gcc-internal-format @@ -63989,16 +63988,14 @@ msgid " since %q+#D declared in base class" msgstr " eftersom %q+#D är deklarerad i basklassen" #: cp/search.cc:2281 -#, fuzzy, gcc-internal-format -#| msgid "virtual function %q+D overriding final function" +#, gcc-internal-format msgid "explicit object member function overrides virtual function" -msgstr "virtuell funktion %q+D åsidosätter slutlig funktion" +msgstr "en explicit objektmedlemsfunktion åsidosätter en virtuell funktion" #: cp/search.cc:2284 -#, fuzzy, gcc-internal-format -#| msgid "resolver indirect function declared here" +#, gcc-internal-format msgid "virtual function declared here" -msgstr "upplösning av indirekt funktion deklarerad här" +msgstr "den virtuella funktionen deklarerad här" #: cp/semantics.cc:1109 #, gcc-internal-format @@ -64081,22 +64078,19 @@ msgid "arguments to destructor are not allowed" msgstr "argument till destruerare är inte tillåtet" #: cp/semantics.cc:3175 -#, fuzzy, gcc-internal-format -#| msgid "% is unavailable for static member functions" +#, gcc-internal-format msgid "% is unavailable for explicit object member functions" -msgstr "% är inte tillgängligt i en statisk medlemsfunktion" +msgstr "% är inte tillgängligt i explicita objektmedlemsfunktioner" #: cp/semantics.cc:3187 -#, fuzzy, gcc-internal-format -#| msgid "use the apostrophe directive %qs instead" +#, gcc-internal-format msgid "use explicit object parameter %qs instead" -msgstr "använd apostrofdirektivet %qs istället" +msgstr "använd en explicit objektparameter %qs istället" #: cp/semantics.cc:3191 -#, fuzzy, gcc-internal-format -#| msgid "invalid template non-type parameter" +#, gcc-internal-format msgid "name the explicit object parameter" -msgstr "ogiltig mallparameter som inte är en typ" +msgstr "namnge den explicita objektdparametern" #: cp/semantics.cc:3196 #, gcc-internal-format @@ -64255,10 +64249,9 @@ msgid "%qT is not an enumeration type" msgstr "%qT är inte ett uppräkningstyp" #: cp/semantics.cc:4650 -#, fuzzy, gcc-internal-format -#| msgid "requested alignment is not an integer constant" +#, gcc-internal-format msgid "%<__type_pack_element%> index is not an integral constant" -msgstr "begärd minnesjustering är inte en heltalskonstant" +msgstr "indexet till %<__type_pack_element%> är inte en heltalskonstant" #: cp/semantics.cc:4656 #, gcc-internal-format @@ -64266,10 +64259,9 @@ msgid "%<__type_pack_element%> index is negative" msgstr "indexet till %<__type_pack_element%> är negativt" #: cp/semantics.cc:4662 -#, fuzzy, gcc-internal-format -#| msgid "Reference statement index out of range" +#, gcc-internal-format msgid "%<__type_pack_element%> index is out of range" -msgstr "Referenssatsindex utanför intervallet" +msgstr "indexet till %<__type_pack_element%> är utanför intervallet" #. Parameter packs can only be used in templates #: cp/semantics.cc:4785 @@ -64303,10 +64295,9 @@ msgid "% within non-standard-layout type %qT is conditionally-support msgstr "% inom icke-standardlayouttypen %qT är villkorligt stött" #: cp/semantics.cc:6046 -#, fuzzy, gcc-internal-format -#| msgid "constructor priorities are not supported" +#, gcc-internal-format msgid "pointer-to-member mapping %qE not supported" -msgstr "konstruerarprioriteter stödjs ej" +msgstr "pekar-till-medlems-avbildningen %qE stödjs ej" #: cp/semantics.cc:6240 #, gcc-internal-format @@ -64590,10 +64581,9 @@ msgid "% message % must be implicitly convertible to %< msgstr "meddelandet % till % måste vara implicit konverterbart till %" #: cp/semantics.cc:11592 -#, fuzzy,
[gcc r14-10041] internal-fn: Fix up expand_arith_overflow [PR114753]
https://gcc.gnu.org/g:33bf8e5385099c2963f278bff38e4f917eddf1d8 commit r14-10041-g33bf8e5385099c2963f278bff38e4f917eddf1d8 Author: Jakub Jelinek Date: Fri Apr 19 18:15:39 2024 +0200 internal-fn: Fix up expand_arith_overflow [PR114753] During backporting I've noticed I've missed one return spot for the restoration of the original flag_trapv flag value. 2024-04-19 Jakub Jelinek PR middle-end/114753 * internal-fn.cc (expand_arith_overflow): Add one missing restore of flag_trapv before return. Diff: --- gcc/internal-fn.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/internal-fn.cc b/gcc/internal-fn.cc index c7c5222a169..2c764441cde 100644 --- a/gcc/internal-fn.cc +++ b/gcc/internal-fn.cc @@ -2793,6 +2793,7 @@ expand_arith_overflow (enum tree_code code, gimple *stmt) case PLUS_EXPR: expand_addsub_overflow (loc, code, lhs, arg0, arg1, unsr_p, unsr_p, unsr_p, false, NULL); + flag_trapv = save_flag_trapv; return; case MULT_EXPR: expand_mul_overflow (loc, lhs, arg0, arg1, unsr_p,
[gcc r13-8620] ipa: Force args obtined through pass-through maps to the expected type (PR 113964)
https://gcc.gnu.org/g:5c3238b0d55ec13a2430aa606e2bfed9432e97ac commit r13-8620-g5c3238b0d55ec13a2430aa606e2bfed9432e97ac Author: Martin Jambor Date: Fri Apr 19 16:48:12 2024 +0200 ipa: Force args obtined through pass-through maps to the expected type (PR 113964) Interactions of IPA-CP and IPA-SRA on the same data is a rather big source of issues, I'm afraid. PR 113964 is a situation where IPA-CP propagates an unsigned short in a union parameter into a function which itself calls a different function which has a same union parameter and both these union parameters are split with IPA-SRA. The leaf function however uses a signed short member of the union. In the calling function, we get the unsigned constant as the replacement for the union and it is then passed in the call without any type compatibility checks. Apparently on riscv64 it matters whether the parameter is signed or unsigned short and so the leaf function can see different values. Fixed by using useless_type_conversion_p at the appropriate place and if it fails, use force_value_to type as elsewhere in similar situations. gcc/ChangeLog: 2024-04-04 Martin Jambor PR ipa/113964 * ipa-param-manipulation.cc (ipa_param_adjustments::modify_call): Force values obtined through pass-through maps to the expected split type. gcc/testsuite/ChangeLog: 2024-04-04 Patrick O'Neill Martin Jambor PR ipa/113964 * gcc.dg/ipa/pr114247.c: New test. (cherry picked from commit 8cd0d29270d4ed86c69b80c08de66dcb6c1e22fe) Diff: --- gcc/ipa-param-manipulation.cc | 6 ++ gcc/testsuite/gcc.dg/ipa/pr114247.c | 31 +++ 2 files changed, 37 insertions(+) diff --git a/gcc/ipa-param-manipulation.cc b/gcc/ipa-param-manipulation.cc index e4f626ae95e..729d5e8e688 100644 --- a/gcc/ipa-param-manipulation.cc +++ b/gcc/ipa-param-manipulation.cc @@ -738,6 +738,12 @@ ipa_param_adjustments::modify_call (cgraph_edge *cs, } if (repl) { + if (!useless_type_conversion_p(apm->type, repl->typed.type)) + { + repl = force_value_to_type (apm->type, repl); + repl = force_gimple_operand_gsi (, repl, + true, NULL, true, GSI_SAME_STMT); + } vargs.quick_push (repl); continue; } diff --git a/gcc/testsuite/gcc.dg/ipa/pr114247.c b/gcc/testsuite/gcc.dg/ipa/pr114247.c new file mode 100644 index 000..60aa2bc0122 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/pr114247.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fsigned-char -fno-strict-aliasing -fwrapv" } */ + +union a { + unsigned short b; + int c; + signed short d; +}; +int e, f = 1, g; +long h; +const int **i; +void j(union a k, int l, unsigned m) { + const int *a[100]; + i = [0]; + h = k.d; +} +static int o(union a k) { + k.d = -1; + while (1) +if (f) + break; + j(k, g, e); + return 0; +} +int main() { + union a n = {1}; + o(n); + if (h != -1) +__builtin_abort(); + return 0; +}
[gcc r13-8619] ipa: Avoid duplicate replacements in IPA-SRA transformation phase
https://gcc.gnu.org/g:8a3784adf5cd873ca295a5a011d8623338ff3976 commit r13-8619-g8a3784adf5cd873ca295a5a011d8623338ff3976 Author: Martin Jambor Date: Fri Apr 19 16:48:12 2024 +0200 ipa: Avoid duplicate replacements in IPA-SRA transformation phase When the analysis part of IPA-SRA figures out that it would split out a scalar part of an aggregate which is known by IPA-CP to contain a known constant, it skips it knowing that the transformation part looks at IPA-CP aggregate results too and does the right thing (which can include doing the propagation in GIMPLE because that is the last moment the parameter exists). However, when IPA-SRA wants to split out a smaller aggregate out of an aggregate, which happens to be of the same size as a known scalar constant at the same offset, the transformation bit fails to recognize the situation, tries to do both splitting and constant propagation and in PR 111571 testcase creates a nonsensical call statement on which the call redirection then ICEs. Fixed by making sure we don't try to do two replacements of the same part of the same parameter. The look-up among replacements requires these are sorted and this patch just sorts them if they are not already sorted before each new look-up. The worst number of sortings that can happen is number of parameters which are both split and have aggregate constants times param_ipa_max_agg_items (default 16). I don't think complicating the source code to optimize for this unlikely case is worth it but if need be, it can of course be done. gcc/ChangeLog: 2024-03-15 Martin Jambor PR ipa/111571 * ipa-param-manipulation.cc (ipa_param_body_adjustments::common_initialization): Avoid creating duplicate replacement entries. gcc/testsuite/ChangeLog: 2024-03-15 Martin Jambor PR ipa/111571 * gcc.dg/ipa/pr111571.c: New test. (cherry picked from commit ca56b43105fc09021ec445f1978a17cd85ae5e0c) Diff: --- gcc/ipa-param-manipulation.cc | 16 gcc/testsuite/gcc.dg/ipa/pr111571.c | 29 + 2 files changed, 45 insertions(+) diff --git a/gcc/ipa-param-manipulation.cc b/gcc/ipa-param-manipulation.cc index 182f0c6741e..e4f626ae95e 100644 --- a/gcc/ipa-param-manipulation.cc +++ b/gcc/ipa-param-manipulation.cc @@ -1484,6 +1484,22 @@ ipa_param_body_adjustments::common_initialization (tree old_fndecl, replacement with a constant (for split aggregates passed by value). */ + if (split[parm_num]) + { + /* We must be careful not to add a duplicate +replacement. */ + sort_replacements (); + ipa_param_body_replacement *pbr + = lookup_replacement_1 (m_oparms[parm_num], + av.unit_offset); + if (pbr) + { + /* Otherwise IPA-SRA should have bailed out. */ + gcc_assert (AGGREGATE_TYPE_P (TREE_TYPE (pbr->repl))); + continue; + } + } + tree repl; if (av.by_ref) repl = av.value; diff --git a/gcc/testsuite/gcc.dg/ipa/pr111571.c b/gcc/testsuite/gcc.dg/ipa/pr111571.c new file mode 100644 index 000..2a4adc608db --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/pr111571.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +struct a { + int b; +}; +struct c { + long d; + struct a e; + long f; +}; +int g, h, i; +int j() {return 0;} +static void k(struct a l, int p) { + if (h) +g = 0; + for (; g; g = j()) +if (l.b) + break; +} +static void m(struct c l) { + k(l.e, l.f); + for (;; --i) +; +} +int main() { + struct c n = {10, 9}; + m(n); +}
[gcc r14-10040] middle-end: refactory vect_recog_absolute_difference to simplify flow [PR114769]
https://gcc.gnu.org/g:1216460e7023cd8ec49933866107417c70e933c9 commit r14-10040-g1216460e7023cd8ec49933866107417c70e933c9 Author: Tamar Christina Date: Fri Apr 19 15:22:13 2024 +0100 middle-end: refactory vect_recog_absolute_difference to simplify flow [PR114769] Hi All, As the reporter in PR114769 points out the control flow for the abd detection is hard to follow. This is because vect_recog_absolute_difference has two different ways it can return true. 1. It can return true when the widening operation is matched, in which case unprom is set, half_type is not NULL and diff_stmt is not set. 2. It can return true when the widening operation is not matched, but the stmt being checked is a minus. In this case unprom is not set, half_type is set to NULL and diff_stmt is set. This because to get to diff_stmt you have to dig through the abs statement and any possible promotions. This however leads to complicated uses of the function at the call sites as the exact semantic needs to be known to use it safely. vect_recog_absolute_difference has two callers: 1. vect_recog_sad_pattern where if you return true with unprom not set, then *half_type will be NULL. The call to vect_supportable_direct_optab_p will always reject it since there's no vector mode for NULL. Note that if looking at the dump files, the convention in the dump files have always been that we first indicate that a pattern could possibly be recognize and then check that it's supported. This change somewhat incorrectly makes the diagnostic message get printed for "invalid" patterns. 2. vect_recog_abd_pattern, where if half_type is NULL, it then uses diff_stmt to set them. This refactors the code, it now only has 1 success condition, and diff_stmt is always set to the minus statement in the abs if there is one. The function now only returns success if the widening minus is found, in which case unprom and half_type set. This then leaves it up to the caller to decide if they want to do anything with diff_stmt. Thanks, Tamar gcc/ChangeLog: PR tree-optimization/114769 * tree-vect-patterns.cc: (vect_recog_absolute_difference): Have only one success condition. (vect_recog_abd_pattern): Handle further checks if vect_recog_absolute_difference fails. Diff: --- gcc/tree-vect-patterns.cc | 43 --- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc index 4f491c6b833..87c2acff386 100644 --- a/gcc/tree-vect-patterns.cc +++ b/gcc/tree-vect-patterns.cc @@ -797,8 +797,7 @@ vect_split_statement (vec_info *vinfo, stmt_vec_info stmt2_info, tree new_rhs, HALF_TYPE and UNPROM will be set should the statement be found to be a widened operation. DIFF_STMT will be set to the MINUS_EXPR - statement that precedes the ABS_STMT unless vect_widened_op_tree - succeeds. + statement that precedes the ABS_STMT if it is a MINUS_EXPR.. */ static bool vect_recog_absolute_difference (vec_info *vinfo, gassign *abs_stmt, @@ -843,6 +842,12 @@ vect_recog_absolute_difference (vec_info *vinfo, gassign *abs_stmt, if (!diff_stmt_vinfo) return false; + gassign *diff = dyn_cast (STMT_VINFO_STMT (diff_stmt_vinfo)); + if (diff_stmt && diff + && gimple_assign_rhs_code (diff) == MINUS_EXPR + && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (abs_oprnd))) +*diff_stmt = diff; + /* FORNOW. Can continue analyzing the def-use chain when this stmt in a phi inside the loop (in case we are analyzing an outer-loop). */ if (vect_widened_op_tree (vinfo, diff_stmt_vinfo, @@ -850,17 +855,6 @@ vect_recog_absolute_difference (vec_info *vinfo, gassign *abs_stmt, false, 2, unprom, half_type)) return true; - /* Failed to find a widen operation so we check for a regular MINUS_EXPR. */ - gassign *diff = dyn_cast (STMT_VINFO_STMT (diff_stmt_vinfo)); - if (diff_stmt && diff - && gimple_assign_rhs_code (diff) == MINUS_EXPR - && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (abs_oprnd))) -{ - *diff_stmt = diff; - *half_type = NULL_TREE; - return true; -} - return false; } @@ -1499,27 +1493,22 @@ vect_recog_abd_pattern (vec_info *vinfo, tree out_type = TREE_TYPE (gimple_assign_lhs (last_stmt)); vect_unpromoted_value unprom[2]; - gassign *diff_stmt; - tree half_type; - if (!vect_recog_absolute_difference (vinfo, last_stmt, _type, + gassign *diff_stmt = NULL; + tree abd_in_type; + if (!vect_recog_absolute_difference (vinfo, last_stmt, _in_type, unprom, _stmt)) -return NULL; - - tree abd_in_type, abd_out_type; - - if
[gcc(refs/users/aoliva/heads/testme)] [testsuite] [arm] add effective target and options for pacbti tests
https://gcc.gnu.org/g:8895abceb69b6b8ecef7608923bc4a2849a9302b commit 8895abceb69b6b8ecef7608923bc4a2849a9302b Author: Alexandre Oliva Date: Tue Apr 16 01:26:27 2024 -0300 [testsuite] [arm] add effective target and options for pacbti tests arm pac and bti tests that use -march=armv8.1-m.main get an implicit -mthumb, that is incompatible with vxworks kernel mode. Declaring the requirement for a 8.1-m.main-compatible toolchain is enough to avoid those fails, because the toolchain feature test fails in kernel mode, but taking the -march options from the standardized arch tests, after testing for support for the corresponding effective target, makes it generally safer, and enables us to drop skip directives and extraneous option variants. for gcc/testsuite/ChangeLog * lib/target-supports.exp (v8_1m_main_mve_pacbti): New arm_arch. * gcc.target/arm/bti-1.c: Require arch, use its opts, drop skip. * gcc.target/arm/bti-2.c: Likewise. * gcc.target/arm/acle/pacbti-m-predef-11.c: Likewise. * gcc.target/arm/acle/pacbti-m-predef-12.c: Likewise. * gcc.target/arm/acle/pacbti-m-predef-7.c: Likewise. * g++.target/arm/pac-1.C: Likewise. Drop +mve. Diff: --- gcc/testsuite/g++.target/arm/pac-1.C | 5 +++-- gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-11.c | 4 ++-- gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-12.c | 5 +++-- gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-7.c | 5 +++-- gcc/testsuite/gcc.target/arm/bti-1.c | 5 +++-- gcc/testsuite/gcc.target/arm/bti-2.c | 5 +++-- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/gcc/testsuite/g++.target/arm/pac-1.C b/gcc/testsuite/g++.target/arm/pac-1.C index f671a27b048..ac15ae18197 100644 --- a/gcc/testsuite/g++.target/arm/pac-1.C +++ b/gcc/testsuite/g++.target/arm/pac-1.C @@ -1,7 +1,8 @@ /* Check that GCC does .save and .cfi_offset directives with RA_AUTH_CODE pseudo hard-register. */ /* { dg-do compile } */ -/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" "-mcpu=*" } } */ -/* { dg-options "-march=armv8.1-m.main+mve+pacbti -mbranch-protection=pac-ret -mthumb -mfloat-abi=hard -g -O0" } */ +/* { dg-require-effective-target arm_arch_v8_1m_main_pacbti_ok } */ +/* { dg-add-options arm_arch_v8_1m_main_pacbti } */ +/* { dg-additional-options "-mbranch-protection=pac-ret -mfloat-abi=hard -g -O0" } */ __attribute__((noinline)) void fn1 (int a, int b, int c) diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-11.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-11.c index 6a5ae92c567..c9c40f44027 100644 --- a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-11.c +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-11.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" "-mcpu=*" "-mfloat-abi=*" } } */ -/* { dg-options "-march=armv8.1-m.main+fp+pacbti" } */ +/* { dg-require-effective-target arm_arch_v8_1m_main_pacbti_ok } */ +/* { dg-add-options arm_arch_v8_1m_main_pacbti } */ #if (__ARM_FEATURE_BTI != 1) #error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be defined to 1." diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-12.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-12.c index db40b17c3b0..c26051347a2 100644 --- a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-12.c +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-12.c @@ -1,6 +1,7 @@ /* { dg-do compile } */ -/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" "-mcpu=*" } } */ -/* { dg-options "-march=armv8-m.main+fp -mfloat-abi=softfp" } */ +/* { dg-require-effective-target arm_arch_v8_1m_main_ok } */ +/* { dg-add-options arm_arch_v8_1m_main } */ +/* { dg-additional-options "-mfloat-abi=softfp" } */ #if defined (__ARM_FEATURE_BTI) #error "Feature test macro __ARM_FEATURE_BTI should not be defined." diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-7.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-7.c index 1b25907635e..92f500c1449 100644 --- a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-7.c +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-7.c @@ -1,6 +1,7 @@ /* { dg-do compile } */ -/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" "-mcpu=*" } } */ -/* { dg-additional-options "-march=armv8.1-m.main+pacbti+fp --save-temps -mfloat-abi=hard" } */ +/* { dg-require-effective-target arm_arch_v8_1m_main_pacbti_ok } */ +/* { dg-add-options arm_arch_v8_1m_main_pacbti } */ +/* { dg-additional-options "--save-temps -mfloat-abi=hard" } */ #if defined (__ARM_FEATURE_BTI_DEFAULT) #error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be undefined." diff --git a/gcc/testsuite/gcc.target/arm/bti-1.c b/gcc/testsuite/gcc.target/arm/bti-1.c index
[gcc/aoliva/heads/testme] [testsuite] [arm] add effective target and options for pacb
The branch 'aoliva/heads/testme' was updated to point to: 8895abceb69... [testsuite] [arm] add effective target and options for pacb It previously pointed to: 57d1c481239... [testsuite] [arm] add effective target and options for pacb Diff: !!! WARNING: THE FOLLOWING COMMITS ARE NO LONGER ACCESSIBLE (LOST): --- 57d1c48... [testsuite] [arm] add effective target and options for pacb Summary of changes (added commits): --- 8895abc... [testsuite] [arm] add effective target and options for pacb
[gcc/aoliva/heads/testme] [testsuite] [arm] add effective target and options for pacb
The branch 'aoliva/heads/testme' was updated to point to: 57d1c481239... [testsuite] [arm] add effective target and options for pacb It previously pointed to: 25268cdcc12... [testsuite] [arm] add effective target and options for pacb Diff: !!! WARNING: THE FOLLOWING COMMITS ARE NO LONGER ACCESSIBLE (LOST): --- 25268cd... [testsuite] [arm] add effective target and options for pacb Summary of changes (added commits): --- 57d1c48... [testsuite] [arm] add effective target and options for pacb
[gcc(refs/users/aoliva/heads/testme)] [testsuite] [arm] add effective target and options for pacbti tests
https://gcc.gnu.org/g:57d1c481239e2051ff13dfa38510611c4c2fcf51 commit 57d1c481239e2051ff13dfa38510611c4c2fcf51 Author: Alexandre Oliva Date: Tue Apr 16 01:26:27 2024 -0300 [testsuite] [arm] add effective target and options for pacbti tests arm pac and bti tests that use -march=armv8.1-m.main get an implicit -mthumb, that is incompatible with vxworks kernel mode. Declaring the requirement for a 8.1-m.main-compatible toolchain is enough to avoid those fails, because the toolchain feature test fails in kernel mode, but taking the -march options from the standardized arch tests, after testing for support for the corresponding effective target, makes it generally safer, and enables us to drop skip directives and extraneous option variants. for gcc/testsuite/ChangeLog * lib/target-supports.exp (v8_1m_main_mve_pacbti): New arm_arch. * gcc.target/arm/bti-1.c: Require arch, use its opts, drop skip. * gcc.target/arm/bti-2.c: Likewise. * gcc.target/arm/acle/pacbti-m-predef-11.c: Likewise. * gcc.target/arm/acle/pacbti-m-predef-12.c: Likewise. * gcc.target/arm/acle/pacbti-m-predef-7.c: Likewise. * g++.target/arm/pac-1.C: Likewise. Drop +mve. Diff: --- gcc/testsuite/g++.target/arm/pac-1.C | 5 +++-- gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-11.c | 4 ++-- gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-12.c | 5 +++-- gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-7.c | 5 +++-- gcc/testsuite/gcc.target/arm/bti-1.c | 5 +++-- gcc/testsuite/gcc.target/arm/bti-2.c | 5 +++-- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/gcc/testsuite/g++.target/arm/pac-1.C b/gcc/testsuite/g++.target/arm/pac-1.C index f671a27b048..2f898040046 100644 --- a/gcc/testsuite/g++.target/arm/pac-1.C +++ b/gcc/testsuite/g++.target/arm/pac-1.C @@ -1,7 +1,8 @@ /* Check that GCC does .save and .cfi_offset directives with RA_AUTH_CODE pseudo hard-register. */ /* { dg-do compile } */ -/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" "-mcpu=*" } } */ -/* { dg-options "-march=armv8.1-m.main+mve+pacbti -mbranch-protection=pac-ret -mthumb -mfloat-abi=hard -g -O0" } */ +/* { dg-require-effective-target arm_arch_v8_1m_main_pacbti_ok } */ +/* { dg-add-options arm_arch_v8_1m_main_pacbti } */ +/* { dg-options "-mbranch-protection=pac-ret -mfloat-abi=hard -g -O0" } */ __attribute__((noinline)) void fn1 (int a, int b, int c) diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-11.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-11.c index 6a5ae92c567..c9c40f44027 100644 --- a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-11.c +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-11.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" "-mcpu=*" "-mfloat-abi=*" } } */ -/* { dg-options "-march=armv8.1-m.main+fp+pacbti" } */ +/* { dg-require-effective-target arm_arch_v8_1m_main_pacbti_ok } */ +/* { dg-add-options arm_arch_v8_1m_main_pacbti } */ #if (__ARM_FEATURE_BTI != 1) #error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be defined to 1." diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-12.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-12.c index db40b17c3b0..c26051347a2 100644 --- a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-12.c +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-12.c @@ -1,6 +1,7 @@ /* { dg-do compile } */ -/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" "-mcpu=*" } } */ -/* { dg-options "-march=armv8-m.main+fp -mfloat-abi=softfp" } */ +/* { dg-require-effective-target arm_arch_v8_1m_main_ok } */ +/* { dg-add-options arm_arch_v8_1m_main } */ +/* { dg-additional-options "-mfloat-abi=softfp" } */ #if defined (__ARM_FEATURE_BTI) #error "Feature test macro __ARM_FEATURE_BTI should not be defined." diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-7.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-7.c index 1b25907635e..92f500c1449 100644 --- a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-7.c +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-7.c @@ -1,6 +1,7 @@ /* { dg-do compile } */ -/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" "-mcpu=*" } } */ -/* { dg-additional-options "-march=armv8.1-m.main+pacbti+fp --save-temps -mfloat-abi=hard" } */ +/* { dg-require-effective-target arm_arch_v8_1m_main_pacbti_ok } */ +/* { dg-add-options arm_arch_v8_1m_main_pacbti } */ +/* { dg-additional-options "--save-temps -mfloat-abi=hard" } */ #if defined (__ARM_FEATURE_BTI_DEFAULT) #error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be undefined." diff --git a/gcc/testsuite/gcc.target/arm/bti-1.c b/gcc/testsuite/gcc.target/arm/bti-1.c index
[gcc r12-10354] testsuite, objective-c++: Fix imported NSObjCRuntime.h.
https://gcc.gnu.org/g:f04f8734f792159d8bc001946fe4ca6f3503034f commit r12-10354-gf04f8734f792159d8bc001946fe4ca6f3503034f Author: Iain Sandoe Date: Fri Jun 23 15:29:14 2023 +0100 testsuite,objective-c++: Fix imported NSObjCRuntime.h. We have imported some headers from the GNUStep project to allow us to maintain the testsuite independent to changing versions of system headers. One of these headers has a macro that (now we have support for __has_feature) expands to a declaration that triggers a warning. These headers are considered part of the implementation so that, in this case, we can suppress the warning with the system_header pragma. Signed-off-by: Iain Sandoe gcc/testsuite/ChangeLog: * objc-obj-c++-shared/GNUStep/Foundation/NSObjCRuntime.h: Make this header use pragma system_header. (cherry picked from commit d83e0e3bc375a05844438d28c9a4ab24c5401eb9) Diff: --- gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObjCRuntime.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObjCRuntime.h b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObjCRuntime.h index 189af80436a..62556f9ac88 100644 --- a/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObjCRuntime.h +++ b/gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObjCRuntime.h @@ -29,6 +29,9 @@ #ifndef __NSObjCRuntime_h_GNUSTEP_BASE_INCLUDE #define __NSObjCRuntime_h_GNUSTEP_BASE_INCLUDE +/* Allow the elaborated enum use in _GS_NAMED_ENUM. */ +#pragma GCC system_header + #ifdef __cplusplus #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS 1
[gcc r12-10353] testsuite, Objective-C: Fix duplicate libobjc cases.
https://gcc.gnu.org/g:04dbdb7347a0b4846311cfce7665b49ea288433f commit r12-10353-g04dbdb7347a0b4846311cfce7665b49ea288433f Author: Iain Sandoe Date: Thu Jan 25 20:17:42 2024 + testsuite, Objective-C: Fix duplicate libobjc cases. Two of the encode testcases include '-lobjc' as their dg-options. Since the library is already appended as part of the generic testsuite handling, this means that two instances appear on the link line leading to spurious warnings from Darwin's new linker. gcc/testsuite/ChangeLog: * obj-c++.dg/encode-10.mm: Remove unneeded '-lobjc' option addition. * obj-c++.dg/encode-9.mm: Likewise. Signed-off-by: Iain Sandoe (cherry picked from commit 30d9e81c19d69e15b2e9c53e4377879cbf9b0b84) Diff: --- gcc/testsuite/obj-c++.dg/encode-10.mm | 1 - gcc/testsuite/obj-c++.dg/encode-9.mm | 1 - 2 files changed, 2 deletions(-) diff --git a/gcc/testsuite/obj-c++.dg/encode-10.mm b/gcc/testsuite/obj-c++.dg/encode-10.mm index 2b3af88dcb1..2477400b7f3 100644 --- a/gcc/testsuite/obj-c++.dg/encode-10.mm +++ b/gcc/testsuite/obj-c++.dg/encode-10.mm @@ -1,5 +1,4 @@ /* Test for @encode in templates. */ -/* { dg-options "-lobjc" } */ /* { dg-do run } */ #include #include diff --git a/gcc/testsuite/obj-c++.dg/encode-9.mm b/gcc/testsuite/obj-c++.dg/encode-9.mm index 6b064dfdc09..4fdb5fa50fb 100644 --- a/gcc/testsuite/obj-c++.dg/encode-9.mm +++ b/gcc/testsuite/obj-c++.dg/encode-9.mm @@ -1,5 +1,4 @@ /* Test than @encode is properly instantiated. */ -/* { dg-options "-lobjc" } */ /* { dg-do run } */ #include
[gcc r12-10352] Darwin: Handle the fPIE option specially.
https://gcc.gnu.org/g:30766064e4f88bca3909ecd9737eeb5f4d36be81 commit r12-10352-g30766064e4f88bca3909ecd9737eeb5f4d36be81 Author: Iain Sandoe Date: Wed Oct 25 15:28:52 2023 +0100 Darwin: Handle the fPIE option specially. For Darwin, PIE requires PIC codegen, but otherwise is only a link-time change. For almost all Darwin, we do not report __PIE__; the exception is 32bit X86 and from Darwin12 to 17 only (32 bit is no longer supported after Darwin17). gcc/ChangeLog: * config/darwin.cc (darwin_override_options): Handle fPIE. Signed-off-by: Iain Sandoe (cherry picked from commit da9e72f80f3358bd9586e11aaf03341c1f867318) Diff: --- gcc/config/darwin.cc | 15 +-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc index 129250a48fd..3cbdc97662d 100644 --- a/gcc/config/darwin.cc +++ b/gcc/config/darwin.cc @@ -3299,6 +3299,8 @@ darwin_override_options (void) { if (strverscmp (darwin_macosx_version_min, "10.14") >= 0) generating_for_darwin_version = 18; + else if (strverscmp (darwin_macosx_version_min, "10.8") >= 0) + generating_for_darwin_version = 12; else if (strverscmp (darwin_macosx_version_min, "10.7") >= 0) generating_for_darwin_version = 11; else if (strverscmp (darwin_macosx_version_min, "10.6") >= 0) @@ -3469,8 +3471,17 @@ darwin_override_options (void) && dwarf_debuginfo_p ()) flag_var_tracking_uninit = flag_var_tracking; - /* Final check on PCI options; for Darwin these are not dependent on the PIE - ones, although PIE does require PIC to support it. */ + if (OPTION_SET_P (flag_pie) && flag_pie) +{ + /* This is a little complicated, to match Xcode tools. +For Darwin, PIE requires PIC codegen, but otherwise is only a link- +time change. For almost all Darwin, we do not report __PIE__; the +exception is Darwin12-17 and for 32b only. */ + flag_pie = generating_for_darwin_version >= 12 && !TARGET_64BIT ? 2 : 0; + flag_pic = 2; /* We always set this. */ +} + + /* Final check on PIC options. */ if (MACHO_DYNAMIC_NO_PIC_P) { if (flag_pic)
[gcc r12-10351] Darwin: Correct handling of weak crts.
https://gcc.gnu.org/g:f1ef7143fba7e09ec10a60227ebb46eb5d6553f9 commit r12-10351-gf1ef7143fba7e09ec10a60227ebb46eb5d6553f9 Author: Iain Sandoe Date: Thu Mar 21 14:34:44 2024 + Darwin: Correct handling of weak crts. Backport part of 506e74f53a5 from trunk. We need the weak crts to be considered ahead of GCC target libraries (except libgcc_s) to avoid spurious dependencies on otherwise unused libs. gcc/ChangeLog: * config/darwin.h (LINK_COMMAND_SPEC_A): Handle weak crts before other objects. (REAL_LIBGCC_SPEC): Remove weak crts from here. (DARWIN_WEAK_CRTS): New. Signed-off-by: Iain Sandoe Diff: --- gcc/config/darwin.h | 37 ++--- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h index 0f17932440f..6b124601274 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -367,7 +367,9 @@ extern GTY(()) int darwin_ms_struct; %{e*} %{r} \ %{o*}%{!o:-o a.out} \ %{!r:%{!nostdlib:%{!nostartfiles:%S}}} \ -%{L*} %(link_libgcc) %o \ +%{L*} %(link_libgcc) \ +%{!r:%{!nostdlib:%{!nodefaultlibs: " DARWIN_WEAK_CRTS "}}} \ +%o \ %{!r:%{!nostdlib:%{!nodefaultlibs:\ %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} \ %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1): \ @@ -381,15 +383,15 @@ extern GTY(()) int darwin_ms_struct; %(link_ssp) \ %:version-compare(>< 10.6 10.7 mmacosx-version-min= -ld10-uwfef) \ %(link_gcc_c_sequence) \ - %{!nodefaultexport:%{dylib|dynamiclib|bundle: \ - %:version-compare(>= 10.11 asm_macosx_version_min= -U) \ - %:version-compare(>= 10.11 asm_macosx_version_min= ___emutls_get_address) \ - %:version-compare(>= 10.11 asm_macosx_version_min= -exported_symbol) \ - %:version-compare(>= 10.11 asm_macosx_version_min= ___emutls_get_address) \ - %:version-compare(>= 10.11 asm_macosx_version_min= -U) \ - %:version-compare(>= 10.11 asm_macosx_version_min= ___emutls_register_common) \ - %:version-compare(>= 10.11 asm_macosx_version_min= -exported_symbol) \ - %:version-compare(>= 10.11 asm_macosx_version_min= ___emutls_register_common) \ + %{!nodefaultexport: \ + %{%:version-compare(>= 10.11 asm_macosx_version_min= -U): \ + ___emutls_get_address -exported_symbol ___emutls_get_address \ + -U ___emutls_register_common \ + -exported_symbol ___emutls_register_common \ + -U ___gcc_nested_func_ptr_created \ + -exported_symbol ___gcc_nested_func_ptr_created \ + -U ___gcc_nested_func_ptr_deleted \ + -exported_symbol ___gcc_nested_func_ptr_deleted \ }} \ }}}\ %{!r:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} %{F*} "\ @@ -515,17 +517,22 @@ extern GTY(()) int darwin_ms_struct; #undef REAL_LIBGCC_SPEC #define REAL_LIBGCC_SPEC \ "%{static-libgcc|static: \ -%:version-compare(!> 10.6 mmacosx-version-min= -lgcc_eh) \ -%:version-compare(>= 10.6 mmacosx-version-min= -lemutls_w); \ +%:version-compare(!> 10.6 mmacosx-version-min= -lgcc_eh);\ shared-libgcc|fexceptions|fobjc-exceptions|fgnu-runtime: \ %:version-compare(!> 10.11 mmacosx-version-min= -lgcc_s.1.1) \ -%:version-compare(>= 10.11 mmacosx-version-min= -lemutls_w) \ %:version-compare(!> 10.3.9 mmacosx-version-min= -lgcc_eh) \ %:version-compare(>< 10.3.9 10.5 mmacosx-version-min= -lgcc_s.10.4) \ -%:version-compare(>< 10.5 10.6 mmacosx-version-min= -lgcc_s.10.5); \ - : -lemutls_w \ +%:version-compare(>< 10.5 10.6 mmacosx-version-min= -lgcc_s.10.5)\ } -lgcc " +#define DARWIN_WEAK_CRTS \ +"%{static-libgcc|static: \ + %:version-compare(>= 10.6 mmacosx-version-min= -lemutls_w) ; \ + shared-libgcc|fexceptions|fobjc-exceptions|fgnu-runtime: \ + %:version-compare(>= 10.11 mmacosx-version-min= -lemutls_w) ; \ + : -lemutls_w \ + }" + /* We specify crt0.o as -lcrt0.o so that ld will search the library path. */ #undef STARTFILE_SPEC
[gcc(refs/users/aoliva/heads/testme)] [testsuite] [arm] add effective target and options for pacbti tests
https://gcc.gnu.org/g:25268cdcc128d18ed7a873046896781d909b7840 commit 25268cdcc128d18ed7a873046896781d909b7840 Author: Alexandre Oliva Date: Tue Apr 16 01:26:27 2024 -0300 [testsuite] [arm] add effective target and options for pacbti tests arm pac and bti tests that use -march=armv8.1-m.main get an implicit -mthumb, that is incompatible with vxworks kernel mode. Declaring the requirement for a 8.1-m.main-compatible toolchain is enough to avoid those fails, because the toolchain feature test fails in kernel mode, but taking the -march options from the standardized arch tests, after testing for support for the corresponding effective target, makes it generally safer, and enables us to drop skip directives and extraneous option variants. for gcc/testsuite/ChangeLog * lib/target-supports.exp (v8_1m_main_mve_pacbti): New arm_arch. * g++.target/arm/pac-1.C: Require arch, use its opts, drop skip. * gcc.target/arm/acle/pacbti-m-predef-11.c: Likewise. * gcc.target/arm/acle/pacbti-m-predef-12.c: Likewise. * gcc.target/arm/acle/pacbti-m-predef-7.c: Likewise. * gcc.target/arm/bti-1.c: Likewise. * gcc.target/arm/bti-2.c: Likewise. Diff: --- gcc/testsuite/g++.target/arm/pac-1.C | 5 +++-- gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-11.c | 4 ++-- gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-12.c | 5 +++-- gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-7.c | 5 +++-- gcc/testsuite/gcc.target/arm/bti-1.c | 5 +++-- gcc/testsuite/gcc.target/arm/bti-2.c | 5 +++-- gcc/testsuite/lib/target-supports.exp | 2 ++ 7 files changed, 19 insertions(+), 12 deletions(-) diff --git a/gcc/testsuite/g++.target/arm/pac-1.C b/gcc/testsuite/g++.target/arm/pac-1.C index f671a27b048..4710fbecbac 100644 --- a/gcc/testsuite/g++.target/arm/pac-1.C +++ b/gcc/testsuite/g++.target/arm/pac-1.C @@ -1,7 +1,8 @@ /* Check that GCC does .save and .cfi_offset directives with RA_AUTH_CODE pseudo hard-register. */ /* { dg-do compile } */ -/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" "-mcpu=*" } } */ -/* { dg-options "-march=armv8.1-m.main+mve+pacbti -mbranch-protection=pac-ret -mthumb -mfloat-abi=hard -g -O0" } */ +/* { dg-require-effective-target arm_arch_v8_1m_main_pacbti_ok } */ +/* { dg-add-options arm_arch_v8_1m_main_mve_pacbti } */ +/* { dg-options "-mbranch-protection=pac-ret -mfloat-abi=hard -g -O0" } */ __attribute__((noinline)) void fn1 (int a, int b, int c) diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-11.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-11.c index 6a5ae92c567..c9c40f44027 100644 --- a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-11.c +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-11.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" "-mcpu=*" "-mfloat-abi=*" } } */ -/* { dg-options "-march=armv8.1-m.main+fp+pacbti" } */ +/* { dg-require-effective-target arm_arch_v8_1m_main_pacbti_ok } */ +/* { dg-add-options arm_arch_v8_1m_main_pacbti } */ #if (__ARM_FEATURE_BTI != 1) #error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be defined to 1." diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-12.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-12.c index db40b17c3b0..c26051347a2 100644 --- a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-12.c +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-12.c @@ -1,6 +1,7 @@ /* { dg-do compile } */ -/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" "-mcpu=*" } } */ -/* { dg-options "-march=armv8-m.main+fp -mfloat-abi=softfp" } */ +/* { dg-require-effective-target arm_arch_v8_1m_main_ok } */ +/* { dg-add-options arm_arch_v8_1m_main } */ +/* { dg-additional-options "-mfloat-abi=softfp" } */ #if defined (__ARM_FEATURE_BTI) #error "Feature test macro __ARM_FEATURE_BTI should not be defined." diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-7.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-7.c index 1b25907635e..92f500c1449 100644 --- a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-7.c +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-7.c @@ -1,6 +1,7 @@ /* { dg-do compile } */ -/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" "-mcpu=*" } } */ -/* { dg-additional-options "-march=armv8.1-m.main+pacbti+fp --save-temps -mfloat-abi=hard" } */ +/* { dg-require-effective-target arm_arch_v8_1m_main_pacbti_ok } */ +/* { dg-add-options arm_arch_v8_1m_main_pacbti } */ +/* { dg-additional-options "--save-temps -mfloat-abi=hard" } */ #if defined (__ARM_FEATURE_BTI_DEFAULT) #error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be undefined." diff --git a/gcc/testsuite/gcc.target/arm/bti-1.c
[gcc r12-10350] Objective-C, Darwin: Do not overalign CFStrings and Objective-C metadata.
https://gcc.gnu.org/g:877d87416656cbd8bf21676e6f54865583aa03c8 commit r12-10350-g877d87416656cbd8bf21676e6f54865583aa03c8 Author: Iain Sandoe Date: Thu Jan 25 20:11:09 2024 + Objective-C, Darwin: Do not overalign CFStrings and Objective-C metadata. We have reports of regressions in both Objective-C and Objective-C++ on Darwin23 (macOS 14). In some cases, these are linker warnings about the alignment of CFString constants; in other cases the built executables crash during runtime initialization. The underlying issue is the same in both cases; since the objects (CFStrings, Objective-C meta-data) are TU- local, we are choosing to increase their alignment for efficiency - to values greater than ABI alignment. However, although these objects are TU-local, they are also visible to the linker (since they are placed in specific named sections). In many cases the metadata can be regarded as tables of data, and thus it is expected that these sections can be concatenated from multiple TUs and the data treated as tabular. In order for this to work the data cannot be allowed to exceed ABI alignment - which leads to the crashes. For GCC-15+ it would be nice to find a more elegant solution to this issue (perhaps by adjusting the concept of binds-locally to exclude specific named sections) - but I do not want to do that in stage 4. The solution here is to force the alignment to be preserved as created by setting DECL_USER_ALIGN on the relevant objects. gcc/ChangeLog: * config/darwin.cc (darwin_build_constant_cfstring): Prevent over- alignment of CFString constants by setting DECL_USER_ALIGN. gcc/objc/ChangeLog: * objc-next-runtime-abi-02.cc (build_v2_address_table): Prevent over-alignment of Objective-C metadata by setting DECL_USER_ALIGN on relevant variables. (build_v2_protocol_list_address_table): Likewise. (generate_v2_protocol_list): Likewise. (generate_v2_meth_descriptor_table): Likewise. (generate_v2_meth_type_list): Likewise. (generate_v2_property_table): Likewise. (generate_v2_dispatch_table): Likewise. (generate_v2_ivars_list): Likewise. (generate_v2_class_structs): Likewise. (build_ehtype): Likewise. * objc-runtime-shared-support.cc (generate_strings): Likewise. Signed-off-by: Iain Sandoe (cherry picked from commit f74f840d35117bcaf995cee99fb2ab30c60f64f3) Diff: --- gcc/config/darwin.cc| 1 + gcc/objc/objc-next-runtime-abi-02.cc| 18 +++--- gcc/objc/objc-runtime-shared-support.cc | 4 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc index a11095716d8..129250a48fd 100644 --- a/gcc/config/darwin.cc +++ b/gcc/config/darwin.cc @@ -3859,6 +3859,7 @@ darwin_build_constant_cfstring (tree str) /* global namespace. */ DECL_CONTEXT (var) = NULL_TREE; DECL_INITIAL (var) = constructor; + DECL_USER_ALIGN (var) = 1; lang_hooks.decls.pushdecl (var); rest_of_decl_compilation (var, 1, 0); desc->ccf_str = var; diff --git a/gcc/objc/objc-next-runtime-abi-02.cc b/gcc/objc/objc-next-runtime-abi-02.cc index a9b3e32b92d..1dee05df769 100644 --- a/gcc/objc/objc-next-runtime-abi-02.cc +++ b/gcc/objc/objc-next-runtime-abi-02.cc @@ -2246,6 +2246,7 @@ build_v2_address_table (vec *src, const char *nam, tree attr) DECL_PRESERVE_P (decl) = 1; expr = objc_build_constructor (type, initlist); OBJCMETA (decl, objc_meta, attr); + DECL_USER_ALIGN (decl) = 1; finish_var_decl (decl, expr); } @@ -2320,8 +2321,9 @@ build_v2_protocol_list_address_table (void) decl = create_global_decl (objc_protocol_type, buf, /*is def=*/true); expr = convert (objc_protocol_type, build_fold_addr_expr (ref->refdecl)); OBJCMETA (decl, objc_meta, meta_label_protocollist); - finish_var_decl (decl, expr); DECL_PRESERVE_P (decl) = 1; + DECL_USER_ALIGN (decl) = 1; + finish_var_decl (decl, expr); } /* TODO: delete the vec. */ @@ -2399,6 +2401,7 @@ generate_v2_protocol_list (tree i_or_p, tree klass_ctxt) /* ObjC2 puts all these in the base section. */ OBJCMETA (refs_decl, objc_meta, meta_base); DECL_PRESERVE_P (refs_decl) = 1; + DECL_USER_ALIGN (refs_decl) = 1; finish_var_decl (refs_decl, objc_build_constructor (TREE_TYPE (refs_decl),initlist)); return refs_decl; @@ -2507,6 +2510,7 @@ generate_v2_meth_descriptor_table (tree chain, tree protocol, CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, initlist); /* Get into the right section. */ OBJCMETA (decl, objc_meta, attr); + DECL_USER_ALIGN (decl) = 1; finish_var_decl (decl, objc_build_constructor (method_list_template, v)); return decl; }
[gcc(refs/users/aoliva/heads/testme)] [libstdc++] introduce --disable-compat-libstdcxx-abi
https://gcc.gnu.org/g:4c6efa350d11a66674d85046cc7b7cbc69f6dbe1 commit 4c6efa350d11a66674d85046cc7b7cbc69f6dbe1 Author: Alexandre Oliva Date: Tue Apr 16 01:26:20 2024 -0300 [libstdc++] introduce --disable-compat-libstdcxx-abi A number of libstdc++ tests that implicitly instantiate __to_chars_i and also link floating_to_chars.o in fail on vxworks kernel mode. The platform doesn't support undefweak symbols (the kernel module loader fails to load modules containing them), and because creating such modules doesn't involve final linking, only -r linking. The vague-linkage weak defs with abi-v2 mangling that get discarded from floating_to_chars.o because the same comdat section is present in the main executable. But since the alternate mangling is not defined in the main executable, the weak definition decays to a weak undefined symbol in the partially-linked kernel module, and then the kernel module loader barfs. Since our vxworks toolchains have little use for the compat ABI symbols, I thought we could work around this problem by getting rid of them. Absent a configure option to control that, I added one. for libstdc++-v3/ChangeLog * acinclude.m4 (GLIBCXX_EXPORT_FLAGS): Split -Wabi=2... (GLIBCXX_ENABLE_WABI): ... here. Control it with newly added --disable-compat-libstdcxx-abi. * configure: Rebuilt. * doc/html/manual/configure.html: Document it. Diff: --- libstdc++-v3/acinclude.m4 | 26 ++- libstdc++-v3/configure | 49 +++-- libstdc++-v3/doc/html/manual/configure.html | 4 ++- libstdc++-v3/doc/xml/manual/configure.xml | 4 +++ 4 files changed, 72 insertions(+), 11 deletions(-) diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index 51a08bcc8b1..2dd5aa2af89 100644 --- a/libstdc++-v3/acinclude.m4 +++ b/libstdc++-v3/acinclude.m4 @@ -707,10 +707,34 @@ AC_DEFUN([GLIBCXX_EXPORT_FLAGS], [ # OPTIMIZE_CXXFLAGS = -O3 -fstrict-aliasing -fvtable-gc AC_SUBST(OPTIMIZE_CXXFLAGS) - WARN_FLAGS="-Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi=2" + WARN_FLAGS="-Wall -Wextra -Wwrite-strings -Wcast-qual" AC_SUBST(WARN_FLAGS) + + GLIBCXX_ENABLE_WABI ]) +dnl +dnl Enable -Wabi=2 if not overridden by --disable-compat-libstdcxx-abi. +dnl +AC_DEFUN([GLIBCXX_ENABLE_WABI], [ + # Default. + WARN_FLAGS_WABI=\ -Wabi=2 + AC_MSG_CHECKING([for --disable-compat-libstdcxx-abi-mangling]) + AC_ARG_ENABLE([compat-libstdcxx-abi-mangling], +AC_HELP_STRING([--disable-compat-libstdcxx-abi-mangling], + [Disable backward-compatibility mangling ABI symbols]), +[case "$enableval" in + yes) AC_MSG_RESULT(enabled$WARN_FLAGS_WABI) ;; + no) WARN_FLAGS_WABI= + AC_MSG_RESULT(disabled) ;; + *) AC_MSG_RESULT(unsupported) + AC_MSG_ERROR([Unsupported argument to enable/disable compat libstdc++ abi mangling]);; + esac], [ + AC_MSG_RESULT(defaulting to enabled$WARN_FLAGS_WABI) + ]) + + WARN_FLAGS="$WARN_FLAGS$WARN_FLAGS_WABI" +]) dnl dnl All installation directory information is determined here. diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index 21abaeb0778..af03d5f96f4 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -973,6 +973,7 @@ enable_cet with_gxx_include_dir enable_version_specific_runtime_libs with_toolexeclibdir +enable_compat_libstdcxx_abi_mangling with_gcc_major_version_only ' ac_precious_vars='build_alias @@ -1689,6 +1690,8 @@ Optional Features: --enable-version-specific-runtime-libs Specify that runtime libraries should be installed in a compiler-specific directory + --disable-compat-libstdcxx-abi-mangling + Disable backward-compatibility mangling ABI symbols Optional Packages: --with-PACKAGE[=ARG]use PACKAGE [ARG=yes] @@ -12280,7 +12283,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12283 "configure" +#line 12286 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12386,7 +12389,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12389 "configure" +#line 12392 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -16182,7 +16185,7 @@ $as_echo "$glibcxx_cv_atomic_long_long" >&6; } # Fake what AC_TRY_COMPILE does. cat > conftest.$ac_ext << EOF -#line 16185 "configure" +#line 16188 "configure" int main() { typedef bool atomic_type; @@ -16217,7 +16220,7 @@ $as_echo "$glibcxx_cv_atomic_bool" >&6; } rm -f conftest* cat > conftest.$ac_ext << EOF -#line 16220 "configure" +#line 16223 "configure" int main() { typedef short atomic_type; @@ -16252,7 +16255,7
[gcc/aoliva/heads/testbase] (49 commits) [vxworks] avoid mangling __STDC_VERSION_LIMITS_H__
The branch 'aoliva/heads/testbase' was updated to point to: 694fa3717a9... [vxworks] avoid mangling __STDC_VERSION_LIMITS_H__ It previously pointed to: 46d914d0e0b... LoongArch: Add indexes for some compilation options. Diff: Summary of changes (added commits): --- 694fa37... [vxworks] avoid mangling __STDC_VERSION_LIMITS_H__ (*) 85c187b... Daily bump. (*) e498ba9... Add nios2*-*-* to the list of obsolete targets (*) e243d0f... Fortran: Fix ICE and clear incorrect error messages [PR1147 (*) 7eecc08... [testsuite] [i386] add -msse2 to tests that require it (*) 0ea96af... [testsuite] [i386] work around fails with --enable-frame-po (*) 36d0038... [testsuite] [arm] accept empty init for bfloat16 (*) ce2dfc5... [c++] [testsuite] adjust contracts9.C for negative addresse (*) df92df0... [testsuite] [aarch64] Require fpic effective target. (*) 514c6b1... [testsuite] [i386] require fpic for pr111497.C (*) cc02ebf... [testsuite] xfail pr103798-2 in C++ on vxworks too [PR11370 (*) e965162... [testsuite] [analyzer] include sys/select.h if available (*) 8a11709... [testsuite] [analyzer] require fork where used (*) 5be4f20... [testsuite] [analyzer] skip access-mode: O_ACCMODE on vxwor (*) 76a1bcc... [testsuite] [analyzer] avoid vxworks libc mode_t (*) 5dfbc05... [testsuite] introduce strndup effective target (*) dcf0bd1... [libstdc++] [testsuite] disable SRA for compare_exchange_pa (*) 5b17817... [libstdc++] [testsuite] xfail double-prec from_chars for fl (*) da3504a... [libstdc++] define zoneinfo_dir_override on vxworks (*) a2f4be3... AArch64: remove reliance on register allocator for simd/gpr (*) 82d6d38... libgcc: Fix up __divmodbitint4 [PR114755] (*) 6c152c9... internal-fn: Temporarily disable flag_trapv during .{ADD,SU (*) 6e62ede... testsuite, rs6000: Fix builtins-6-p9-runnable.c for BE [PR1 (*) 58a0b19... rs6000: Fix bcd test case (*) 69576bc... Daily bump. (*) 7c2a9db... libstdc++: Implement "Printing blank lines with println" fo (*) 5705614... DOCUMENTATION_ROOT_URL vs. release branches [PR114738] (*) a9fefbf... libcpp: Regenerate aclocal.m4 and configure [PR 114748] (*) bf2b523... tree-optimization/114749 - reset partial vector decision fo (*) 420ece6... GCN: Enable effective-target 'vect_long_long' (*) 909c6fa... AVR: target/114752 - Fix ICE on inline asm const 64-bit flo (*) 3cfe94a... libstdc++: Add include guard to simd-internal header (*) 0fc7f3c... libstdc++: Avoid ill-formed types on ARM (*) 299d14a... asan: Don't instrument .ABNORMAL_DISPATCHER [PR114743] (*) 9c7cf5d... Daily bump. (*) eadd05d... PR modula2/114745: const cast causes ICE (*) f438acf... testsuite: Fix data check loop on vect-early-break_124-pr11 (*) 48024a9... Fortran: ALLOCATE of fixed-length CHARACTER with SOURCE/MOL (*) 4437482... libstdc++: Fix "extact" typos in comments (*) 8eddd87... Document that vector_size works with typedefs [PR92880] (*) f949481... tree-optimization/114736 - SLP DFS walk issue (*) 45a41ac... tree-optimization/114733 - neg induction fails for 1 elemen (*) a7578a0... OpenACC 2.7: Adjust acc_map_data/acc_unmap_data interaction (*) 274f6bb... Fix some comment nits (*) dc17e75... build: Use of cargo not yet supported here in Canadian cros (*) 3ebc789... build: Don't check for host-prefixed 'cargo' program (*) 79ff534... c++: Handle ARRAY_TYPE in check_bit_cast_type [PR114706] (*) 6e925ba... optimize Zicond conditional select cases. (*) c39dc5b... [strub] improve handling of indirected volatile parms [PR11 (*) (*) This commit already exists in another branch. Because the reference `refs/users/aoliva/heads/testbase' matches your hooks.email-new-commits-only configuration, no separate email is sent for this commit.
[gcc/aoliva/heads/testme] (50 commits) [testsuite] [arm] add effective target and options for pacb
The branch 'aoliva/heads/testme' was updated to point to: 25268cdcc12... [testsuite] [arm] add effective target and options for pacb It previously pointed to: e84f9abf5f1... [tree-prof] skip if errors were seen [PR113681] Diff: !!! WARNING: THE FOLLOWING COMMITS ARE NO LONGER ACCESSIBLE (LOST): --- e84f9ab... [tree-prof] skip if errors were seen [PR113681] d11ff38... [testsuite] [i386] add -msse2 to tests that require it d248480... [testsuite] [i386] work around fails with --enable-frame-po 221ab03... [testsuite] [arm] accept empty init for bfloat16 dbb7504... [libstdc++] [testsuite] disable SRA for compare_exchange_pa b2e888a... [testsuite] [arm] require arm_v8_1m_main for pacbti tests 0b08e8a... [testsuite] [i386] require fpic for pr111497.C 0e6e6eb... [libstdc++] introduce --disable-compat-libstdcxx-abi 2605981... [testsuite] xfail pr103798-2 in C++ on vxworks too [PR11370 4c377a9... [testsuite] [analyzer] include sys/select.h if available 830e318... [vxworks] avoid mangling __STDC_VERSION_LIMITS_H__ 9437abf... [testsuite] [analyzer] require fork where used b70fc19... [testsuite] [analyzer] skip access-mode: O_ACCMODE on vxwor 7be5dbe... [testsuite] [analyzer] avoid vxworks libc mode_t dcf1da0... [testsuite] introduce strndup effective target eaf15b1... [c++] [testsuite] adjust contracts9.C for negative addresse e7efbca... [libstdc++] [testsuite] xfail double-prec from_chars for fl 80122a3... [libstdc++] define zoneinfo_dir_override on vxworks c2a86f4... [testsuite] [aarch64] Require fpic effective target. Summary of changes (added commits): --- 25268cd... [testsuite] [arm] add effective target and options for pacb 4c6efa3... [libstdc++] introduce --disable-compat-libstdcxx-abi 694fa37... [vxworks] avoid mangling __STDC_VERSION_LIMITS_H__ (*) 85c187b... Daily bump. (*) e498ba9... Add nios2*-*-* to the list of obsolete targets (*) e243d0f... Fortran: Fix ICE and clear incorrect error messages [PR1147 (*) 7eecc08... [testsuite] [i386] add -msse2 to tests that require it (*) 0ea96af... [testsuite] [i386] work around fails with --enable-frame-po (*) 36d0038... [testsuite] [arm] accept empty init for bfloat16 (*) ce2dfc5... [c++] [testsuite] adjust contracts9.C for negative addresse (*) df92df0... [testsuite] [aarch64] Require fpic effective target. (*) 514c6b1... [testsuite] [i386] require fpic for pr111497.C (*) cc02ebf... [testsuite] xfail pr103798-2 in C++ on vxworks too [PR11370 (*) e965162... [testsuite] [analyzer] include sys/select.h if available (*) 8a11709... [testsuite] [analyzer] require fork where used (*) 5be4f20... [testsuite] [analyzer] skip access-mode: O_ACCMODE on vxwor (*) 76a1bcc... [testsuite] [analyzer] avoid vxworks libc mode_t (*) 5dfbc05... [testsuite] introduce strndup effective target (*) dcf0bd1... [libstdc++] [testsuite] disable SRA for compare_exchange_pa (*) 5b17817... [libstdc++] [testsuite] xfail double-prec from_chars for fl (*) da3504a... [libstdc++] define zoneinfo_dir_override on vxworks (*) a2f4be3... AArch64: remove reliance on register allocator for simd/gpr (*) 82d6d38... libgcc: Fix up __divmodbitint4 [PR114755] (*) 6c152c9... internal-fn: Temporarily disable flag_trapv during .{ADD,SU (*) 6e62ede... testsuite, rs6000: Fix builtins-6-p9-runnable.c for BE [PR1 (*) 58a0b19... rs6000: Fix bcd test case (*) 69576bc... Daily bump. (*) 7c2a9db... libstdc++: Implement "Printing blank lines with println" fo (*) 5705614... DOCUMENTATION_ROOT_URL vs. release branches [PR114738] (*) a9fefbf... libcpp: Regenerate aclocal.m4 and configure [PR 114748] (*) bf2b523... tree-optimization/114749 - reset partial vector decision fo (*) 420ece6... GCN: Enable effective-target 'vect_long_long' (*) 909c6fa... AVR: target/114752 - Fix ICE on inline asm const 64-bit flo (*) 3cfe94a... libstdc++: Add include guard to simd-internal header (*) 0fc7f3c... libstdc++: Avoid ill-formed types on ARM (*) 299d14a... asan: Don't instrument .ABNORMAL_DISPATCHER [PR114743] (*) 9c7cf5d... Daily bump. (*) eadd05d... PR modula2/114745: const cast causes ICE (*) f438acf... testsuite: Fix data check loop on vect-early-break_124-pr11 (*) 48024a9... Fortran: ALLOCATE of fixed-length CHARACTER with SOURCE/MOL (*) 4437482... libstdc++: Fix "extact" typos in comments (*) 8eddd87... Document that vector_size works with typedefs [PR92880] (*) f949481... tree-optimization/114736 - SLP DFS walk issue (*) 45a41ac... tree-optimization/114733 - neg induction fails for 1 elemen (*) a7578a0... OpenACC 2.7: Adjust acc_map_data/acc_unmap_data interaction (*) 274f6bb... Fix some comment nits (*) dc17e75... build: Use of cargo not yet supported here in Canadian cros (*) 3ebc789... build: Don't check for host-prefixed 'cargo' program (*) 79ff534... c++: Handle ARRAY_TYPE in
[gcc r12-10349] Darwin: Fix a typo in Objective-C meta-data.
https://gcc.gnu.org/g:3588c72322c0f54bf013366350e98d420570d2f5 commit r12-10349-g3588c72322c0f54bf013366350e98d420570d2f5 Author: Iain Sandoe Date: Mon Jan 8 16:17:04 2024 + Darwin: Fix a typo in Objective-C meta-data. We have a typo in the metadata for assigning NSStrings to a specific section for the V1 (32b) ABI. When that is fixed we should never see the case where the section needs to be deduced from the properties of the DECLs. gcc/ChangeLog: * config/darwin.cc (darwin_objc1_section): Use the correct meta-data version for constant strings. (machopic_select_section): Assert if we fail to handle CFString sections as Obejctive-C meta-data or drectly. Signed-off-by: Iain Sandoe (cherry picked from commit 8d26636f0da31e6c17b57ced52bfc61a45f23cee) Diff: --- gcc/config/darwin.cc | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc index 57af20052bc..a11095716d8 100644 --- a/gcc/config/darwin.cc +++ b/gcc/config/darwin.cc @@ -1599,7 +1599,7 @@ darwin_objc1_section (tree decl ATTRIBUTE_UNUSED, tree meta, section * base) else if (startswith (p, "V1_CEXT")) return darwin_sections[objc1_class_ext_section]; - else if (startswith (p, "V2_CSTR")) + else if (startswith (p, "V1_CSTR")) return darwin_sections[objc_constant_string_object_section]; return base; @@ -1743,7 +1743,7 @@ machopic_select_section (tree decl, return base_section; /* GNU runtime is happy with it all in one pot. */ } - /* b) Constant string objects. */ + /* b) Constructors for constant NSstring [but not CFString] objects. */ if (TREE_CODE (decl) == CONSTRUCTOR && TREE_TYPE (decl) && TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE @@ -1765,6 +1765,12 @@ machopic_select_section (tree decl, else return darwin_sections[objc_string_object_section]; } + else if (!strcmp (IDENTIFIER_POINTER (name), "__builtin_CFString")) + { + /* We should have handled __anon_cfstrings above. */ + gcc_checking_assert (0); + return darwin_sections[cfstring_constant_object_section]; + } else return base_section; }
[gcc r12-10348] Darwin: Fix constant CFString code-gen [PR105522].
https://gcc.gnu.org/g:b9ee0c8830592212678c402aed8a6b11ef8d2640 commit r12-10348-gb9ee0c8830592212678c402aed8a6b11ef8d2640 Author: Iain Sandoe Date: Sat Jan 6 10:52:38 2024 + Darwin: Fix constant CFString code-gen [PR105522]. Although this only fires for one of the Darwin sub-ports, it is latent elsewhere, it is also a regression c.f. the Darwin system compiler. In the code we imported from an earlier branch, CFString objects (which are constant aggregates) are constructed as CONST_DECLs. Although our current documentation suggests that these are reserved for enumeration values, in fact they are used elsewhere in the compiler for constants. This includes Objective-C where they are used to form NSString constants. In the particular case, we take the address of the constant and that triggers varasm.cc:decode_addr_constant, which does not currently support CONST_DECL. If there is a general intent to allow/encourage wider use of CONST_DECL, then we should fix decode_addr_constant to look through these and evaluate the initializer (a two-line patch, but I'm not suggesting it for stage-4). We also need to update the GCC internals documentation to allow for the additional uses. This patch is Darwin-local and fixes the problem by making the CFString constants into regular variable but TREE_CONSTANT+TREE_READONLY. I plan to back-port this to the open branches once it has baked a while on trunk. Since, for Darwin, the Objective-C default is to construct constant NSString objects as CFStrings; this will also cover the majority of cases there (this patch does not make any changes to Objective-C NSStrings). PR target/105522 gcc/ChangeLog: * config/darwin.cc (machopic_select_section): Handle C and C++ CFStrings. (darwin_rename_builtins): Move this out of the CFString code. (darwin_libc_has_function): Likewise. (darwin_build_constant_cfstring): Create an anonymous var to hold each CFString. * config/darwin.h (ASM_OUTPUT_LABELREF): Handle constant CFstrings. Signed-off-by: Iain Sandoe (cherry picked from commit aecc0d4ba73d0810334b351da1e67232cea450d3) Diff: --- gcc/config/darwin.cc| 100 +++- gcc/config/darwin.h | 2 + gcc/testsuite/gcc.dg/pr105522.c | 17 +++ 3 files changed, 76 insertions(+), 43 deletions(-) diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc index 926ba9dca62..57af20052bc 100644 --- a/gcc/config/darwin.cc +++ b/gcc/config/darwin.cc @@ -1692,7 +1692,16 @@ machopic_select_section (tree decl, base_section = darwin_sections[zobj_data_section]; } else if (ro) - base_section = darwin_sections[const_data_section]; + { + if (VAR_P (decl) && TREE_TYPE (decl) + && TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE + && DECL_NAME (decl) + && strncmp (IDENTIFIER_POINTER (DECL_NAME (decl)), + "__anon_cfstring", 15) == 0) + base_section = darwin_sections[cfstring_constant_object_section]; + else + base_section = darwin_sections[const_data_section]; + } else base_section = data_section; break; @@ -1756,8 +1765,6 @@ machopic_select_section (tree decl, else return darwin_sections[objc_string_object_section]; } - else if (!strcmp (IDENTIFIER_POINTER (name), "__builtin_CFString")) - return darwin_sections[cfstring_constant_object_section]; else return base_section; } @@ -3562,6 +3569,29 @@ darwin_patch_builtins (void) } #endif +void +darwin_rename_builtins (void) +{ +} + +/* Implementation for the TARGET_LIBC_HAS_FUNCTION hook. */ + +bool +darwin_libc_has_function (enum function_class fn_class, + tree type ATTRIBUTE_UNUSED) +{ + if (fn_class == function_sincos && darwin_macosx_version_min) +return (strverscmp (darwin_macosx_version_min, "10.9") >= 0); +#if DARWIN_PPC && SUPPORT_DARWIN_LEGACY + if (fn_class == function_c99_math_complex + || fn_class == function_c99_misc) +return (TARGET_64BIT + || (darwin_macosx_version_min && + strverscmp (darwin_macosx_version_min, "10.3") >= 0)); +#endif + return default_libc_has_function (fn_class, type); +} + /* CFStrings implementation. */ static GTY(()) tree cfstring_class_reference = NULL_TREE; static GTY(()) tree cfstring_type_node = NULL_TREE; @@ -3579,7 +3609,7 @@ typedef struct GTY ((for_user)) cfstring_descriptor { /* The string literal. */ tree literal; /* The resulting constant CFString. */ - tree constructor; + tree ccf_str; } cfstring_descriptor; struct cfstring_hasher : ggc_ptr_hash @@ -3654,7 +3684,7 @@
[gcc r12-10347] Objective-C, Darwin: Fix a regression in handling bad receivers.
https://gcc.gnu.org/g:2df70b6ef0caf2ad7d6770ad14f5511513b0b3f0 commit r12-10347-g2df70b6ef0caf2ad7d6770ad14f5511513b0b3f0 Author: Iain Sandoe Date: Sat Jan 6 19:21:40 2024 + Objective-C, Darwin: Fix a regression in handling bad receivers. This is seen on 32b hosts with a 64b multilib, and is an ICE when the build has checking enabled. The fix is to exit the routine early if the sender or receiver are already error_mark_node. gcc/objc/ChangeLog: * objc-next-runtime-abi-02.cc (build_v2_objc_method_fixup_call): Early exit for cases where the sender or receiver are known to be in error. Signed-off-by: Iain Sandoe (cherry picked from commit 846794ead2982fc85a3b1a83bbb831fa096b2b7c) Diff: --- gcc/objc/objc-next-runtime-abi-02.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gcc/objc/objc-next-runtime-abi-02.cc b/gcc/objc/objc-next-runtime-abi-02.cc index 9ea63b189c7..a9b3e32b92d 100644 --- a/gcc/objc/objc-next-runtime-abi-02.cc +++ b/gcc/objc/objc-next-runtime-abi-02.cc @@ -1657,6 +1657,8 @@ build_v2_objc_method_fixup_call (int super_flag, tree method_prototype, rcv_p = (super_flag ? objc_super_type : objc_object_type); lookup_object = build_c_cast (input_location, rcv_p, lookup_object); + if (sender == error_mark_node || lookup_object == error_mark_node) +return error_mark_node; /* Use SAVE_EXPR to avoid evaluating the receiver twice. */ lookup_object = save_expr (lookup_object);
[gcc r12-10346] testsuite, x86: Handle a broken assembler
https://gcc.gnu.org/g:390448a2873befde7fecb2828211ee585f46d212 commit r12-10346-g390448a2873befde7fecb2828211ee585f46d212 Author: Iain Sandoe Date: Sun Oct 29 07:19:53 2023 + testsuite, x86: Handle a broken assembler Earlier assembler support for complex fp16 on x86_64 Darwin is broken. This adds an additional test to the existing target-supports that fails for the broken assemblers but works for the newer, fixed, ones. gcc/testsuite/ChangeLog: * lib/target-supports.exp: Test an asm line that fails on broken Darwin assembler versions. (cherry picked from commit d65eb8a6bbeae7533dd41cb307b427f3f8585d9b) Diff: --- gcc/testsuite/lib/target-supports.exp | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 1eaa034f5f4..e0076ed8f69 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -9355,6 +9355,7 @@ proc check_effective_target_avx512fp16 { } { void foo (void) { asm volatile ("vmovw %edi, %xmm0"); + asm volatile ("vfcmulcph %xmm1, %xmm2, %xmm3{%k1}"); } } "-O2 -mavx512fp16" ] }
[gcc r12-10345] Darwin: Make metadata symbol lables linker-visible for GNU objc.
https://gcc.gnu.org/g:abaccd9474bd62c8a2385d008c80716c0411e9c8 commit r12-10345-gabaccd9474bd62c8a2385d008c80716c0411e9c8 Author: Iain Sandoe Date: Sat Sep 30 17:15:16 2023 +0100 Darwin: Make metadata symbol lables linker-visible for GNU objc. Now we have shifted to using the same relocation mechanism as clang for objective-c typeinfo the static linker needs to have a linker-visible symbol for metadata names (this is only needed for GNU objective C, for NeXT the names are in separate sections). gcc/ChangeLog: * config/darwin.h (darwin_label_is_anonymous_local_objc_name): Make metadata names linker-visibile for GNU objective C. Signed-off-by: Iain Sandoe (cherry picked from commit 2ae00adb326ed050bd67a67656b20a2cfe789626) Diff: --- gcc/config/darwin.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h index 7026d200d59..acfd4d402c6 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -853,7 +853,7 @@ int darwin_label_is_anonymous_local_objc_name (const char *name); else if (xname[0] == '+' || xname[0] == '-') \ fprintf (FILE, "\"%s\"", xname); \ else if (darwin_label_is_anonymous_local_objc_name (xname)) \ - fprintf (FILE, "L%s", xname); \ + fprintf (FILE, "%c%s", flag_next_runtime ? 'L' : 'l', xname);\ else if (xname[0] != '"' && name_needs_quotes (xname)) \ asm_fprintf (FILE, "\"%U%s\"", xname); \ else \
[gcc r14-10039] Enable 'gcc.dg/pr114768.c' for nvptx target [PR114768]
https://gcc.gnu.org/g:9451b6c0a941dc44ca6f14ff8565d74fe56cca59 commit r14-10039-g9451b6c0a941dc44ca6f14ff8565d74fe56cca59 Author: Thomas Schwinge Date: Fri Apr 19 12:32:03 2024 +0200 Enable 'gcc.dg/pr114768.c' for nvptx target [PR114768] Follow-up to commit 9f295847a9c32081bdd0fe908ffba58e830a24fb "rtlanal: Fix set_noop_p for volatile loads or stores [PR114768]": nvptx does behave in the exactly same way as expected; see 'diff' of before vs. after the 'gcc/rtlanal.cc' code changes: PASS: gcc.dg/pr114768.c (test for excess errors) [-FAIL:-]{+PASS:+} gcc.dg/pr114768.c scan-rtl-dump final "\\(mem/v:" --- 0/pr114768.c.347r.final 2024-04-19 11:34:34.577037596 +0200 +++ ./pr114768.c.347r.final 2024-04-19 12:08:00.118312524 +0200 @@ -13,15 +13,27 @@ ;; entry block defs1 [%stack] 2 [%frame] 3 [%args] ;; exit block uses 1 [%stack] 2 [%frame] ;; regs ever live -;; ref usage r1={1d,2u} r2={1d,2u} r3={1d,1u} -;;total ref usage 8{3d,5u,0e} in 1{1 regular + 0 call} insns. +;; ref usage r1={1d,3u} r2={1d,3u} r3={1d,2u} r22={1d,1u} r23={1d,2u} +;;total ref usage 16{5d,11u,0e} in 4{4 regular + 0 call} insns. (note 1 0 4 NOTE_INSN_DELETED) (note 4 1 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK) -(note 2 4 3 2 NOTE_INSN_DELETED) +(insn 2 4 3 2 (set (reg/v/f:DI 23 [ p ]) +(unspec:DI [ +(const_int 0 [0]) +] UNSPEC_ARG_REG)) "source-gcc/gcc/testsuite/gcc.dg/pr114768.c":8:1 14 {load_arg_regdi} + (nil)) (note 3 2 6 2 NOTE_INSN_FUNCTION_BEG) -(note 6 3 10 2 NOTE_INSN_DELETED) -(note 10 6 11 2 NOTE_INSN_EPILOGUE_BEG) -(jump_insn 11 10 12 2 (return) "source-gcc/gcc/testsuite/gcc.dg/pr114768.c":10:1 289 {return} +(insn 6 3 7 2 (set (reg:SI 22 [ _1 ]) +(mem/v:SI (reg/v/f:DI 23 [ p ]) [1 MEM[(volatile int *)p_3(D)]+0 S4 A32])) "source-gcc/gcc/testsuite/gcc.dg/pr114768.c":9:8 6 {*movsi_insn} + (nil)) +(insn 7 6 10 2 (set (mem:SI (reg/v/f:DI 23 [ p ]) [1 *p_3(D)+0 S4 A32]) +(reg:SI 22 [ _1 ])) "source-gcc/gcc/testsuite/gcc.dg/pr114768.c":9:6 6 {*movsi_insn} + (expr_list:REG_DEAD (reg/v/f:DI 23 [ p ]) +(expr_list:REG_DEAD (reg:SI 22 [ _1 ]) +(nil +(note 10 7 13 2 NOTE_INSN_EPILOGUE_BEG) +(note 13 10 11 3 [bb 3] NOTE_INSN_BASIC_BLOCK) +(jump_insn 11 13 12 3 (return) "source-gcc/gcc/testsuite/gcc.dg/pr114768.c":10:1 289 {return} (nil) -> return) (barrier 12 11 0) --- 0/pr114768.s2024-04-19 11:34:34.577037596 +0200 +++ ./pr114768.s2024-04-19 12:08:00.118312524 +0200 @@ -13,5 +13,10 @@ { .reg.u64 %ar0; ld.param.u64 %ar0, [%in_ar0]; + .reg.u32 %r22; + .reg.u64 %r23; + mov.u64 %r23, %ar0; + ld.u32 %r22, [%r23]; + st.u32 [%r23], %r22; ret; } PR testsuite/114768 gcc/testsuite/ * gcc.dg/pr114768.c: Enable for nvptx target. Diff: --- gcc/testsuite/gcc.dg/pr114768.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.dg/pr114768.c b/gcc/testsuite/gcc.dg/pr114768.c index 2075f0d6b82..ffe3b368638 100644 --- a/gcc/testsuite/gcc.dg/pr114768.c +++ b/gcc/testsuite/gcc.dg/pr114768.c @@ -1,7 +1,7 @@ /* PR rtl-optimization/114768 */ /* { dg-do compile } */ /* { dg-options "-O2 -fdump-rtl-final" } */ -/* { dg-final { scan-rtl-dump "\\\(mem/v:" "final" { target { ! { nvptx*-*-* } } } } } */ +/* { dg-final { scan-rtl-dump "\\\(mem/v:" "final" } } */ void foo (int *p)
[gcc r14-10038] bpf: remove huge memory waste with string allocation.
https://gcc.gnu.org/g:ede01dfd9dd85e03dea30402e773c62f0408adbe commit r14-10038-gede01dfd9dd85e03dea30402e773c62f0408adbe Author: Cupertino Miranda Date: Tue Apr 2 12:04:28 2024 +0100 bpf: remove huge memory waste with string allocation. The BPF backend was allocating an unnecessarily large string when constructing CO-RE relocations for enum types. This patch also verifies that those enumerators are valid for CO-RE, returning an error otherwise. gcc/ChangeLog: * config/bpf/core-builtins.cc (get_index_for_enum_value): Create function. (pack_enum_value): Check for enumerator and error out. (process_enum_value): Correct string allocation. Diff: --- gcc/config/bpf/core-builtins.cc | 57 +++-- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/gcc/config/bpf/core-builtins.cc b/gcc/config/bpf/core-builtins.cc index e03e986e2c1..829acea98f7 100644 --- a/gcc/config/bpf/core-builtins.cc +++ b/gcc/config/bpf/core-builtins.cc @@ -795,6 +795,23 @@ process_field_expr (struct cr_builtins *data) static GTY(()) hash_map *bpf_enum_mappings; tree enum_value_type = NULL_TREE; +static int +get_index_for_enum_value (tree type, tree expr) +{ + gcc_assert (TREE_CODE (expr) == CONST_DECL + && TREE_CODE (type) == ENUMERAL_TYPE); + + unsigned int index = 0; + for (tree l = TYPE_VALUES (type); l; l = TREE_CHAIN (l)) +{ + gcc_assert (index < (1 << 16)); + if (TREE_VALUE (l) == expr) + return index; + index++; +} + return -1; +} + /* Pack helper for the __builtin_preserve_enum_value. */ static struct cr_local @@ -846,6 +863,16 @@ pack_enum_value_fail: ret.reloc_data.default_value = integer_one_node; } + if (ret.fail == false ) +{ + int index = get_index_for_enum_value (type, tmp); + if (index == -1 || index >= (1 << 16)) + { + bpf_error ("enum value in CO-RE builtin cannot be represented"); + ret.fail = true; + } +} + ret.reloc_data.type = type; ret.reloc_data.kind = kind; return ret; @@ -864,25 +891,17 @@ process_enum_value (struct cr_builtins *data) struct cr_final ret = { NULL, type, data->kind }; - if (TREE_CODE (expr) == CONST_DECL - && TREE_CODE (type) == ENUMERAL_TYPE) -{ - unsigned int index = 0; - for (tree l = TYPE_VALUES (type); l; l = TREE_CHAIN (l)) - { - if (TREE_VALUE (l) == expr) - { - char *tmp = (char *) ggc_alloc_atomic ((index / 10) + 1); - sprintf (tmp, "%d", index); - ret.str = (const char *) tmp; - - break; - } - index++; - } -} - else -gcc_unreachable (); + gcc_assert (TREE_CODE (expr) == CONST_DECL + && TREE_CODE (type) == ENUMERAL_TYPE); + + int index = get_index_for_enum_value (type, expr); + gcc_assert (index != -1 && index < (1 << 16)); + + /* Index can only be a value up to 2^16. Should always fit + in 6 chars. */ + char tmp[6]; + sprintf (tmp, "%u", index); + ret.str = CONST_CAST (char *, ggc_strdup(tmp)); return ret; }
[gcc r14-10037] bpf: support more instructions to match CO-RE relocations
https://gcc.gnu.org/g:d7190d0b9a8e395f46b475e4d525f2b6a0ce4df4 commit r14-10037-gd7190d0b9a8e395f46b475e4d525f2b6a0ce4df4 Author: Cupertino Miranda Date: Wed Mar 20 19:06:47 2024 + bpf: support more instructions to match CO-RE relocations BPF supports multiple instructions to be CO-RE relocatable regardless of the position of the immediate field in the encoding. In particular, not only the MOV instruction allows a CO-RE relocation of its immediate operand, but the LD and ST instructions can have a CO-RE relocation happening to their offset immediate operand, even though those operands are encoded in different encoding bits. This patch moves matching from a more traditional matching of the UNSPEC_CORE_RELOC pattern within a define_insn to a match within the constraints of both immediates and address operands from more generic mov define_insn rule. gcc/Changelog: * config/bpf/bpf-protos.h (bpf_add_core_reloc): Renamed function to bpf_output_move. * config/bpf/bpf.cc (bpf_legitimate_address_p): Allow UNSPEC_CORE_RELOC to match an address. (bpf_insn_cost): Make UNSPEC_CORE_RELOC immediate moves expensive to prioritize loads and stores. (TARGET_INSN_COST): Add hook. (bpf_output_move): Wrapper to call bpf_output_core_reloc. (bpf_print_operand): Add support to print immediate operands specified with the UNSPEC_CORE_RELOC. (bpf_print_operand_address): Likewise, but to support UNSPEC_CORE_RELOC in addresses. (bpf_init_builtins): Flag BPF_BUILTIN_CORE_RELOC as NOTHROW. * config/bpf/bpf.md: Wrap patterns for MOV, LD and ST instruction with bpf_output_move call. (mov_reloc_core): Remove now spurious define_insn. * config/bpf/constraints.md: Added "c" and "C" constraints to match immediates represented with UNSPEC_CORE_RELOC. * config/bpf/core-builtins.cc (bpf_add_core_reloc): Remove (bpf_output_core_reloc): Add function to create the CO-RE relocations based on new matching rules. * config/bpf/core-builtins.h (bpf_output_core_reloc): Add prototype. * config/bpf/predicates.md (core_imm_operand) Add predicate. (mov_src_operand): Add match for core_imm_operand. gcc/testsuite/ChangeLog: * gcc.target/bpf/btfext-funcinfo.c: Updated to changes. * gcc.target/bpf/core-builtin-fieldinfo-const-elimination.c: Likewise. * gcc.target/bpf/core-builtin-fieldinfo-existence-1.c: Likewise. * gcc.target/bpf/core-builtin-fieldinfo-lshift-1-be.c: Likewise. * gcc.target/bpf/core-builtin-fieldinfo-lshift-1-le.c: Likewise. * gcc.target/bpf/core-builtin-fieldinfo-lshift-2.c: Likewise. * gcc.target/bpf/core-builtin-fieldinfo-offset-1.c: Likewise. * gcc.target/bpf/core-builtin-fieldinfo-rshift-1.c: Likewise. * gcc.target/bpf/core-builtin-fieldinfo-rshift-2.c: Likewise. * gcc.target/bpf/core-builtin-fieldinfo-sign-1.c: Likewise. * gcc.target/bpf/core-builtin-fieldinfo-sign-2.c: Likewise. * gcc.target/bpf/core-builtin-fieldinfo-size-1.c: Likewise. Diff: --- gcc/config/bpf/bpf-protos.h| 2 +- gcc/config/bpf/bpf.cc | 54 +++- gcc/config/bpf/bpf.md | 56 +++-- gcc/config/bpf/constraints.md | 20 ++ gcc/config/bpf/core-builtins.cc| 71 -- gcc/config/bpf/core-builtins.h | 2 + gcc/config/bpf/predicates.md | 7 ++- gcc/testsuite/gcc.target/bpf/btfext-funcinfo.c | 2 - .../bpf/core-builtin-fieldinfo-const-elimination.c | 2 +- .../bpf/core-builtin-fieldinfo-existence-1.c | 2 +- .../bpf/core-builtin-fieldinfo-lshift-1-be.c | 8 +-- .../bpf/core-builtin-fieldinfo-lshift-1-le.c | 8 +-- .../bpf/core-builtin-fieldinfo-lshift-2.c | 6 +- .../bpf/core-builtin-fieldinfo-offset-1.c | 12 ++-- .../bpf/core-builtin-fieldinfo-rshift-1.c | 8 +-- .../bpf/core-builtin-fieldinfo-rshift-2.c | 4 +- .../gcc.target/bpf/core-builtin-fieldinfo-sign-1.c | 4 +- .../gcc.target/bpf/core-builtin-fieldinfo-sign-2.c | 4 +- .../gcc.target/bpf/core-builtin-fieldinfo-size-1.c | 8 +-- 19 files changed, 189 insertions(+), 91 deletions(-) diff --git a/gcc/config/bpf/bpf-protos.h b/gcc/config/bpf/bpf-protos.h index ac0c2f4038f..b4866d34209 100644 --- a/gcc/config/bpf/bpf-protos.h +++ b/gcc/config/bpf/bpf-protos.h @@ -30,7 +30,7 @@ extern void bpf_print_operand_address (FILE *, rtx); extern void bpf_expand_prologue (void); extern void bpf_expand_epilogue (void); extern void
[gcc r14-10036] d: Fix ICE in build_deref, at d/d-codegen.cc:1650 [PR111650]
https://gcc.gnu.org/g:4d4929fe0654d51b52a2bf6e6188d7aad0bf17ac commit r14-10036-g4d4929fe0654d51b52a2bf6e6188d7aad0bf17ac Author: Iain Buclaw Date: Fri Apr 19 10:51:12 2024 +0200 d: Fix ICE in build_deref, at d/d-codegen.cc:1650 [PR111650] PR d/111650 gcc/d/ChangeLog: * decl.cc (get_fndecl_arguments): Move generation of frame type to ... (DeclVisitor::visit (FuncDeclaration *)): ... here, after the call to build_closure. gcc/testsuite/ChangeLog: * gdc.dg/pr111650.d: New test. Diff: --- gcc/d/decl.cc | 20 ++-- gcc/testsuite/gdc.dg/pr111650.d | 21 + 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc index 3b7627d3dfa..0a87c85ae2e 100644 --- a/gcc/d/decl.cc +++ b/gcc/d/decl.cc @@ -163,16 +163,6 @@ get_fndecl_arguments (FuncDeclaration *decl) tree parm_decl = get_symbol_decl (decl->vthis); DECL_ARTIFICIAL (parm_decl) = 1; TREE_READONLY (parm_decl) = 1; - - if (decl->vthis->type == Type::tvoidptr) - { - /* Replace generic pointer with back-end closure type -(this wins for gdb). */ - tree frame_type = FRAMEINFO_TYPE (get_frameinfo (decl)); - gcc_assert (frame_type != NULL_TREE); - TREE_TYPE (parm_decl) = build_pointer_type (frame_type); - } - param_list = chainon (param_list, parm_decl); } @@ -1072,6 +1062,16 @@ public: /* May change cfun->static_chain. */ build_closure (d); +/* Replace generic pointer with back-end closure type + (this wins for gdb). */ +if (d->vthis && d->vthis->type == Type::tvoidptr) + { + tree frame_type = FRAMEINFO_TYPE (get_frameinfo (d)); + gcc_assert (frame_type != NULL_TREE); + tree parm_decl = get_symbol_decl (d->vthis); + TREE_TYPE (parm_decl) = build_pointer_type (frame_type); + } + if (d->vresult) declare_local_var (d->vresult); diff --git a/gcc/testsuite/gdc.dg/pr111650.d b/gcc/testsuite/gdc.dg/pr111650.d new file mode 100644 index 000..4298a76d38f --- /dev/null +++ b/gcc/testsuite/gdc.dg/pr111650.d @@ -0,0 +1,21 @@ +// { dg-do compile } +ref V require(K, V)(ref V[K] aa, K key, lazy V value); + +struct Root +{ +ulong[3] f; +} + +Root[ulong] roots; + +Root getRoot(int fd, ulong rootID) +{ +return roots.require(rootID, +{ +Root result; +inoLookup(fd, () => result); +return result; +}()); +} + +void inoLookup(int, scope Root delegate()) { }
[gcc r14-10035] rtlanal: Fix set_noop_p for volatile loads or stores [PR114768]
https://gcc.gnu.org/g:9f295847a9c32081bdd0fe908ffba58e830a24fb commit r14-10035-g9f295847a9c32081bdd0fe908ffba58e830a24fb Author: Jakub Jelinek Date: Fri Apr 19 08:47:53 2024 +0200 rtlanal: Fix set_noop_p for volatile loads or stores [PR114768] On the following testcase, combine propagates the mem/v load into mem store with the same address and then removes it, because noop_move_p says it is a no-op move. If it was the other way around, i.e. mem/v store and mem load, or both would be mem/v, it would be kept. The problem is that rtx_equal_p never checks any kind of flags on the rtxes (and I think it would be quite dangerous to change it at this point), and set_noop_p checks side_effects_p on just one of the operands, not both. In the MEM <- MEM set, it only checks it on the destination, in store to ZERO_EXTRACT only checks it on the source. The following patch adds the missing side_effects_p checks. 2024-04-19 Jakub Jelinek PR rtl-optimization/114768 * rtlanal.cc (set_noop_p): Don't return true for MEM <- MEM sets if src has side-effects or for stores into ZERO_EXTRACT if ZERO_EXTRACT operand has side-effects. * gcc.dg/pr114768.c: New test. Diff: --- gcc/rtlanal.cc | 11 +++ gcc/testsuite/gcc.dg/pr114768.c | 10 ++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/gcc/rtlanal.cc b/gcc/rtlanal.cc index d38455bc559..4158a531bdd 100644 --- a/gcc/rtlanal.cc +++ b/gcc/rtlanal.cc @@ -1637,12 +1637,15 @@ set_noop_p (const_rtx set) return true; if (MEM_P (dst) && MEM_P (src)) -return rtx_equal_p (dst, src) && !side_effects_p (dst); +return (rtx_equal_p (dst, src) + && !side_effects_p (dst) + && !side_effects_p (src)); if (GET_CODE (dst) == ZERO_EXTRACT) -return rtx_equal_p (XEXP (dst, 0), src) - && !BITS_BIG_ENDIAN && XEXP (dst, 2) == const0_rtx - && !side_effects_p (src); +return (rtx_equal_p (XEXP (dst, 0), src) + && !BITS_BIG_ENDIAN && XEXP (dst, 2) == const0_rtx + && !side_effects_p (src) + && !side_effects_p (XEXP (dst, 0))); if (GET_CODE (dst) == STRICT_LOW_PART) dst = XEXP (dst, 0); diff --git a/gcc/testsuite/gcc.dg/pr114768.c b/gcc/testsuite/gcc.dg/pr114768.c new file mode 100644 index 000..2075f0d6b82 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr114768.c @@ -0,0 +1,10 @@ +/* PR rtl-optimization/114768 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-rtl-final" } */ +/* { dg-final { scan-rtl-dump "\\\(mem/v:" "final" { target { ! { nvptx*-*-* } } } } } */ + +void +foo (int *p) +{ + *p = *(volatile int *) p; +}
[gcc r14-10034] libgcc: Another __divmodbitint4 bug fix [PR114762]
https://gcc.gnu.org/g:36f4c8a9ac8f71fc21fcb169c7913e8fef30d15c commit r14-10034-g36f4c8a9ac8f71fc21fcb169c7913e8fef30d15c Author: Jakub Jelinek Date: Fri Apr 19 08:44:54 2024 +0200 libgcc: Another __divmodbitint4 bug fix [PR114762] The following testcase is miscompiled because the code to decrement vn on negative value with all ones in most significant limb (even partial) and 0 in most significant bit of the second most significant limb doesn't take into account the case where all bits below the most significant limb are zero. This has been a problem both in the version before yesterday's commit where it has been done only if un was one shorter than vn before this decrement, and is now problem even more often when it is done earlier. When we decrement vn in such case and negate it, we end up with all 0s in the v2 value, so have both the problems with UB on __builtin_clz* and the expectations of the algorithm that the divisor has most significant bit set after shifting, plus when the decremented vn is 1 it can SIGFPE on division by zero even when it is not division by zero etc. Other values shouldn't get 0 in the new most significant limb after negation, because the bitint_reduce_prec canonicalization should reduce prec if the second most significant limb is all ones and if that limb is all zeros, if at least one limb below it is non-zero, carry in will make it non-zero. The following patch fixes it by checking if at least one bit below the most significant limb is non-zero, in that case it decrements, otherwise it will do nothing (but e.g. for the un < vn case that also means the divisor is large enough that the result should be q 0 r u). 2024-04-18 Jakub Jelinek PR libgcc/114762 * libgcc2.c (__divmodbitint4): Perform the decrement on negative v with most significant limb all ones and the second least significant limb with most significant bit clear always, regardless of un < vn. * gcc.dg/torture/bitint-70.c: New test. Diff: --- gcc/testsuite/gcc.dg/torture/bitint-70.c | 22 ++ libgcc/libgcc2.c | 13 ++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/gcc/testsuite/gcc.dg/torture/bitint-70.c b/gcc/testsuite/gcc.dg/torture/bitint-70.c new file mode 100644 index 000..2d693bb5849 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/bitint-70.c @@ -0,0 +1,22 @@ +/* PR libgcc/114762 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=c23" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __BITINT_MAXWIDTH__ >= 255 +__attribute__((__noipa__)) signed _BitInt(255) +foo (signed _BitInt(255) a, signed _BitInt(65) b) +{ + return a / b; +} +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 255 + if (foo (1, -0xwb - 1wb)) +__builtin_abort (); +#endif +} diff --git a/libgcc/libgcc2.c b/libgcc/libgcc2.c index 120d071a168..3fcb85c5b92 100644 --- a/libgcc/libgcc2.c +++ b/libgcc/libgcc2.c @@ -1715,11 +1715,18 @@ __divmodbitint4 (UBILtype *q, SItype qprec, && vn > 1 && (Wtype) v[BITINT_END (1, vn - 2)] >= 0) { - vp = 0; - --vn; + /* Unless all bits below the most significant limb are zero. */ + SItype vn2; + for (vn2 = vn - 2; vn2 >= 0; --vn2) + if (v[BITINT_END (vn - 1 - vn2, vn2)]) + { + vp = 0; + --vn; #if __LIBGCC_BITINT_ORDER__ == __ORDER_BIG_ENDIAN__ - ++v; + ++v; #endif + break; + } } if (__builtin_expect (un < vn, 0)) {