[gcc r14-10103] RISC-V: Add xfail test case for highpart overlap of vext.vf

2024-04-23 Thread Pan Li via Gcc-cvs
https://gcc.gnu.org/g:f952745943c2e9fbb2df32d2f2b037669d3fc50f

commit r14-10103-gf952745943c2e9fbb2df32d2f2b037669d3fc50f
Author: Pan Li 
Date:   Wed Apr 24 10:39:25 2024 +0800

RISC-V: Add xfail test case for highpart overlap of vext.vf

We reverted below patch for register group overlap, add the related
insn test and mark it as xfail.  And we will remove the xfail
after we support the register overlap in GCC-15.

62685890d88 RISC-V: Support highpart overlap for vext.vf

The below test suites are passed for this patch
* The rv64gcv fully regression test with isl build.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/unop_v_constraint-2.c: Adjust asm
check cond.
* gcc.target/riscv/rvv/base/pr112431-4.c: New test.
* gcc.target/riscv/rvv/base/pr112431-5.c: New test.
* gcc.target/riscv/rvv/base/pr112431-6.c: New test.

Signed-off-by: Pan Li 

Diff:
---
 .../gcc.target/riscv/rvv/base/pr112431-4.c | 104 +
 .../gcc.target/riscv/rvv/base/pr112431-5.c |  68 ++
 .../gcc.target/riscv/rvv/base/pr112431-6.c |  51 ++
 .../riscv/rvv/base/unop_v_constraint-2.c   |   2 +-
 4 files changed, 224 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/pr112431-4.c 
b/gcc/testsuite/gcc.target/riscv/rvv/base/pr112431-4.c
new file mode 100644
index 000..cecf796e10c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/base/pr112431-4.c
@@ -0,0 +1,104 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d -O3" } */
+
+#include "riscv_vector.h"
+
+size_t __attribute__ ((noinline))
+sumation (size_t sum0, size_t sum1, size_t sum2, size_t sum3, size_t sum4,
+ size_t sum5, size_t sum6, size_t sum7, size_t sum8, size_t sum9,
+ size_t sum10, size_t sum11, size_t sum12, size_t sum13, size_t sum14,
+ size_t sum15)
+{
+  return sum0 + sum1 + sum2 + sum3 + sum4 + sum5 + sum6 + sum7 + sum8 + sum9
++ sum10 + sum11 + sum12 + sum13 + sum14 + sum15;
+}
+
+size_t
+foo (char const *buf, size_t len)
+{
+  size_t sum = 0;
+  size_t vl = __riscv_vsetvlmax_e8m8 ();
+  size_t step = vl * 4;
+  const char *it = buf, *end = buf + len;
+  for (; it + step <= end;)
+{
+  vint8m1_t v0 = __riscv_vle8_v_i8m1 ((void *) it, vl);
+  it += vl;
+  vint8m1_t v1 = __riscv_vle8_v_i8m1 ((void *) it, vl);
+  it += vl;
+  vint8m1_t v2 = __riscv_vle8_v_i8m1 ((void *) it, vl);
+  it += vl;
+  vint8m1_t v3 = __riscv_vle8_v_i8m1 ((void *) it, vl);
+  it += vl;
+  vint8m1_t v4 = __riscv_vle8_v_i8m1 ((void *) it, vl);
+  it += vl;
+  vint8m1_t v5 = __riscv_vle8_v_i8m1 ((void *) it, vl);
+  it += vl;
+  vint8m1_t v6 = __riscv_vle8_v_i8m1 ((void *) it, vl);
+  it += vl;
+  vint8m1_t v7 = __riscv_vle8_v_i8m1 ((void *) it, vl);
+  it += vl;
+  vint8m1_t v8 = __riscv_vle8_v_i8m1 ((void *) it, vl);
+  it += vl;
+  vint8m1_t v9 = __riscv_vle8_v_i8m1 ((void *) it, vl);
+  it += vl;
+  vint8m1_t v10 = __riscv_vle8_v_i8m1 ((void *) it, vl);
+  it += vl;
+  vint8m1_t v11 = __riscv_vle8_v_i8m1 ((void *) it, vl);
+  it += vl;
+  vint8m1_t v12 = __riscv_vle8_v_i8m1 ((void *) it, vl);
+  it += vl;
+  vint8m1_t v13 = __riscv_vle8_v_i8m1 ((void *) it, vl);
+  it += vl;
+  vint8m1_t v14 = __riscv_vle8_v_i8m1 ((void *) it, vl);
+  it += vl;
+  vint8m1_t v15 = __riscv_vle8_v_i8m1 ((void *) it, vl);
+  it += vl;
+  
+  asm volatile("nop" ::: "memory");
+  vint16m2_t vw0 = __riscv_vsext_vf2_i16m2 (v0, vl);
+  vint16m2_t vw1 = __riscv_vsext_vf2_i16m2 (v1, vl);
+  vint16m2_t vw2 = __riscv_vsext_vf2_i16m2 (v2, vl);
+  vint16m2_t vw3 = __riscv_vsext_vf2_i16m2 (v3, vl);
+  vint16m2_t vw4 = __riscv_vsext_vf2_i16m2 (v4, vl);
+  vint16m2_t vw5 = __riscv_vsext_vf2_i16m2 (v5, vl);
+  vint16m2_t vw6 = __riscv_vsext_vf2_i16m2 (v6, vl);
+  vint16m2_t vw7 = __riscv_vsext_vf2_i16m2 (v7, vl);
+  vint16m2_t vw8 = __riscv_vsext_vf2_i16m2 (v8, vl);
+  vint16m2_t vw9 = __riscv_vsext_vf2_i16m2 (v9, vl);
+  vint16m2_t vw10 = __riscv_vsext_vf2_i16m2 (v10, vl);
+  vint16m2_t vw11 = __riscv_vsext_vf2_i16m2 (v11, vl);
+  vint16m2_t vw12 = __riscv_vsext_vf2_i16m2 (v12, vl);
+  vint16m2_t vw13 = __riscv_vsext_vf2_i16m2 (v13, vl);
+  vint16m2_t vw14 = __riscv_vsext_vf2_i16m2 (v14, vl);
+  vint16m2_t vw15 = __riscv_vsext_vf2_i16m2 (v15, vl);
+
+  asm volatile("nop" ::: "memory");
+  size_t sum0 = __riscv_vmv_x_s_i16m2_i16 (vw0);
+  size_t sum1 = __riscv_vmv_x_s_i16m2_i16 (vw1);
+  size_t sum2 = __riscv_vmv_x_s_i16m2_i16 (vw2);
+  size_t sum3 = __riscv_vmv_x_s_i16m2_i16 (vw3);
+  size_t sum4 = __riscv_vmv_x_s_i16m2_i16 (vw4);
+  size_t sum5 = __riscv_vmv_x_s_i16m2_i16 (vw5);
+  size_t sum6 = __riscv_vmv_x_s_i16m2_

[gcc r14-10102] Revert "RISC-V: Support highpart overlap for vext.vf"

2024-04-23 Thread Pan Li via Gcc-cvs
https://gcc.gnu.org/g:8bcefc2d5fb0d8f8f9671fd830132b4e655c44b4

commit r14-10102-g8bcefc2d5fb0d8f8f9671fd830132b4e655c44b4
Author: Pan Li 
Date:   Wed Apr 24 10:46:28 2024 +0800

Revert "RISC-V: Support highpart overlap for vext.vf"

This reverts commit 62685890d8861b72f812bfe171a20332df08bd49.

Diff:
---
 gcc/config/riscv/vector.md |  19 ++--
 .../gcc.target/riscv/rvv/base/pr112431-4.c | 104 -
 .../gcc.target/riscv/rvv/base/pr112431-5.c |  68 --
 .../gcc.target/riscv/rvv/base/pr112431-6.c |  51 --
 .../riscv/rvv/base/unop_v_constraint-2.c   |   2 +-
 5 files changed, 10 insertions(+), 234 deletions(-)

diff --git a/gcc/config/riscv/vector.md b/gcc/config/riscv/vector.md
index cb5174a5e91..6a4c0e6e10f 100644
--- a/gcc/config/riscv/vector.md
+++ b/gcc/config/riscv/vector.md
@@ -3730,24 +3730,23 @@
 
 ;; Vector Double-Widening Sign-extend and Zero-extend.
 (define_insn "@pred__vf2"
-  [(set (match_operand:VWEXTI 0 "register_operand" "=vr,   vr, 
  vr,   vr,  vr,vr, ?&vr, ?&vr")
+  [(set (match_operand:VWEXTI 0 "register_operand""=&vr,&vr")
(if_then_else:VWEXTI
  (unspec:
-   [(match_operand: 1 "vector_mask_operand" 
"vmWc1,vmWc1,vmWc1,vmWc1,vmWc1,vmWc1,vmWc1,vmWc1")
-(match_operand 4 "vector_length_operand""   rK,   rK,  
 rK,   rK,   rK,   rK,   rK,   rK")
-(match_operand 5 "const_int_operand""i,i,  
  i,i,i,i,i,i")
-(match_operand 6 "const_int_operand""i,i,  
  i,i,i,i,i,i")
-(match_operand 7 "const_int_operand""i,i,  
  i,i,i,i,i,i")
+   [(match_operand: 1 "vector_mask_operand" "vmWc1,vmWc1")
+(match_operand 4 "vector_length_operand""   rK,   rK")
+(match_operand 5 "const_int_operand""i,i")
+(match_operand 6 "const_int_operand""i,i")
+(match_operand 7 "const_int_operand""i,i")
 (reg:SI VL_REGNUM)
 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
  (any_extend:VWEXTI
-   (match_operand: 3 "register_operand" "  W21,  W21,  
W42,  W42,  W84,  W84,   vr,   vr"))
- (match_operand:VWEXTI 2 "vector_merge_operand" "   vu,0,  
 vu,0,   vu,0,   vu,0")))]
+   (match_operand: 3 "register_operand" "   vr,   vr"))
+ (match_operand:VWEXTI 2 "vector_merge_operand" "   vu,
0")))]
   "TARGET_VECTOR"
   "vext.vf2\t%0,%3%p1"
   [(set_attr "type" "vext")
-   (set_attr "mode" "")
-   (set_attr "vconstraint" "W21,W21,W42,W42,W84,W84,no,no")])
+   (set_attr "mode" "")])
 
 ;; Vector Quad-Widening Sign-extend and Zero-extend.
 (define_insn "@pred__vf4"
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/pr112431-4.c 
b/gcc/testsuite/gcc.target/riscv/rvv/base/pr112431-4.c
deleted file mode 100644
index 4cc6aa68b13..000
--- a/gcc/testsuite/gcc.target/riscv/rvv/base/pr112431-4.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/* { dg-do compile } */
-/* { dg-options "-march=rv64gcv -mabi=lp64d -O3" } */
-
-#include "riscv_vector.h"
-
-size_t __attribute__ ((noinline))
-sumation (size_t sum0, size_t sum1, size_t sum2, size_t sum3, size_t sum4,
- size_t sum5, size_t sum6, size_t sum7, size_t sum8, size_t sum9,
- size_t sum10, size_t sum11, size_t sum12, size_t sum13, size_t sum14,
- size_t sum15)
-{
-  return sum0 + sum1 + sum2 + sum3 + sum4 + sum5 + sum6 + sum7 + sum8 + sum9
-+ sum10 + sum11 + sum12 + sum13 + sum14 + sum15;
-}
-
-size_t
-foo (char const *buf, size_t len)
-{
-  size_t sum = 0;
-  size_t vl = __riscv_vsetvlmax_e8m8 ();
-  size_t step = vl * 4;
-  const char *it = buf, *end = buf + len;
-  for (; it + step <= end;)
-{
-  vint8m1_t v0 = __riscv_vle8_v_i8m1 ((void *) it, vl);
-  it += vl;
-  vint8m1_t v1 = __riscv_vle8_v_i8m1 ((void *) it, vl);
-  it += vl;
-  vint8m1_t v2 = __riscv_vle8_v_i8m1 ((void *) it, vl);
-  it += vl;
-  vint8m1_t v3 = __riscv_vle8_v_i8m1 ((void *) it, vl);
-  it += vl;
-  vint8m1_t v4 = __riscv_vle8_v_i8m1 ((void *) it, vl);
-  it += vl;
-  vint8m1_t v5 = __riscv_vle8_v_i8m1 ((void *) it, vl);
-  it += vl;
-  vint8m1_t v6 = __riscv_vle8_v_i8m1 ((void *) it, vl);
-  it += vl;
-  vint8m1_t v7 = __riscv_vle8_v_i8m1 ((void *) it, vl);
-  it += vl;
-  vint8m1_t v8 = __riscv_vle8_v_i8m1 ((void *) it, vl);
-  it += vl;
-  vint8m1_t v9 = __riscv_vle8_v_i8m1 ((void *) it, vl);
-  it += vl;
-  vint8m1_t v10 = __riscv_vle8_v_i8m1 ((void *) it, vl);
-  it += vl;
-  vint8m1_t v11 = __riscv_vle8_v_i8m1 ((void *) it, vl);
-  it += vl;
-  vint8m1_t v12 = __riscv_vle8_v_i8m1 ((void *) it, vl)

[gcc r14-10100] c++: Fix ICE with xobj parms and maybe incomplete decl-specifiers

2024-04-23 Thread Nathaniel Shead via Gcc-cvs
https://gcc.gnu.org/g:7318f1a389769ab540f414fcba743e90051d466b

commit r14-10100-g7318f1a389769ab540f414fcba743e90051d466b
Author: Nathaniel Shead 
Date:   Sat Apr 20 14:44:11 2024 +1000

c++: Fix ICE with xobj parms and maybe incomplete decl-specifiers

This fixes a null dereference issue when decl_specifiers.type is not yet
provided.

gcc/cp/ChangeLog:

* parser.cc (cp_parser_parameter_declaration): Check if
decl_specifiers.type is null.

gcc/testsuite/ChangeLog:

* g++.dg/cpp23/explicit-obj-basic7.C: New test.

Signed-off-by: Nathaniel Shead 

Diff:
---
 gcc/cp/parser.cc | 5 +++--
 gcc/testsuite/g++.dg/cpp23/explicit-obj-basic7.C | 9 +
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index c23758cf5cf..598380dda08 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -25780,8 +25780,9 @@ cp_parser_parameter_declaration (cp_parser *parser,
 }
 
   if (xobj_param_p
-  && (declarator ? declarator->parameter_pack_p
-: PACK_EXPANSION_P (decl_specifiers.type)))
+  && ((declarator && declarator->parameter_pack_p)
+ || (decl_specifiers.type
+ && PACK_EXPANSION_P (decl_specifiers.type
 {
   location_t xobj_param
= make_location (decl_specifiers.locations[ds_this],
diff --git a/gcc/testsuite/g++.dg/cpp23/explicit-obj-basic7.C 
b/gcc/testsuite/g++.dg/cpp23/explicit-obj-basic7.C
new file mode 100644
index 000..a474e97fc18
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp23/explicit-obj-basic7.C
@@ -0,0 +1,9 @@
+// { dg-do compile { target c++23 } }
+
+// Shouldn't ICE
+struct S {
+  void a(this long);
+  void b(this const long);
+  void c(this long unsigned);
+  void c(this signed);
+};


[gcc r14-10099] i386: Avoid =&r, r, r andn double-word alternative for ia32 [PR114810]

2024-04-23 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:628c2221d38715a64f828e3635317293d150e001

commit r14-10099-g628c2221d38715a64f828e3635317293d150e001
Author: Jakub Jelinek 
Date:   Tue Apr 23 23:30:27 2024 +0200

i386: Avoid =&r,r,r andn double-word alternative for ia32 [PR114810]

As discussed in the PR, on ia32 with its 8 GPRs, where 1 is always fixed
and other 2 often are as well having an alternative which needs 3
double-word registers is just too much for RA.
The following patch splits that alternative into two, one with o is used
even on ia32, but one with the 3x r is used just for -m64/-mx32.
Tried to reduce the testcase further, but it wasn't easily possible.

2024-04-23  Jakub Jelinek  

PR target/114810
* config/i386/i386.md (*andn3_doubleword_bmi): Split the 
=&r,r,ro
alternative into =&r,r,r enabled only for x64 and =&r,r,o.

* g++.target/i386/pr114810.C: New test.

Diff:
---
 gcc/config/i386/i386.md  |   9 +-
 gcc/testsuite/g++.target/i386/pr114810.C | 861 +++
 2 files changed, 866 insertions(+), 4 deletions(-)

diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index adab1ef9e04..80e64c603eb 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -12482,10 +12482,10 @@
 })
 
 (define_insn_and_split "*andn3_doubleword_bmi"
-  [(set (match_operand: 0 "register_operand" "=&r,r,r")
+  [(set (match_operand: 0 "register_operand" "=&r,&r,r,r")
(and:
- (not: (match_operand: 1 "register_operand" "r,0,r"))
- (match_operand: 2 "nonimmediate_operand" "ro,ro,0")))
+ (not: (match_operand: 1 "register_operand" "r,r,0,r"))
+ (match_operand: 2 "nonimmediate_operand" "r,o,ro,0")))
(clobber (reg:CC FLAGS_REG))]
   "TARGET_BMI"
   "#"
@@ -12496,7 +12496,8 @@
(parallel [(set (match_dup 3)
   (and:DWIH (not:DWIH (match_dup 4)) (match_dup 5)))
  (clobber (reg:CC FLAGS_REG))])]
-  "split_double_mode (mode, &operands[0], 3, &operands[0], 
&operands[3]);")
+  "split_double_mode (mode, &operands[0], 3, &operands[0], &operands[3]);"
+  [(set_attr "isa" "x64,*,*,*")])
 
 (define_insn_and_split "*andn3_doubleword"
   [(set (match_operand:DWI 0 "register_operand")
diff --git a/gcc/testsuite/g++.target/i386/pr114810.C 
b/gcc/testsuite/g++.target/i386/pr114810.C
new file mode 100644
index 000..a7b3643ca21
--- /dev/null
+++ b/gcc/testsuite/g++.target/i386/pr114810.C
@@ -0,0 +1,861 @@
+// PR target/114810
+// { dg-do compile { target { { { *-*-linux* } && ia32 } && c++17 } } }
+// { dg-options "-mstackrealign -O2 -mbmi -fno-exceptions -fno-plt 
-march=x86-64 -w" }
+// { dg-additional-options "-fpie" { target pie } }
+
+enum E1 { a, dp, b, jm, c, dq, d, mj, e, dr, f, jn, h, dt, j, nt, l, du, m, 
jo, n, dv, o, mk, p, dw, q, jp, s, dx, t, ol, u, dy, v, jq, w };
+enum dz { x, ml, y };
+struct ea { short g; } z, jr;
+long long aa;
+struct eb { ea ab; ea dp[]; };
+enum ac { };
+typedef enum { } nu;
+struct ad { ac k; };
+unsigned ec (long);
+struct ae;
+int js (ae);
+unsigned af ();
+struct ed;
+template < int ag > struct ee { using ah = ed[ag]; };
+template < int ag > struct array { typename ee < ag >::ah ai; ed & operator[] 
(int aj) { return ai[aj]; } };
+struct { void dp (...); } ak;
+void ef (int);
+template < typename al > struct jt { al & operator[] (short); };
+struct am { void operator= (bool); };
+struct an { am operator[] (unsigned); };
+template < typename, unsigned, unsigned >using eg = an;
+struct ao;
+struct ae { ae (ao *); };
+struct mm { mm (); mm (int); };
+enum ap { };
+enum eh { };
+bool aq, ju, ar, ei, nv, as, ej, at;
+struct jv
+{
+  jv (eh au):dp (au) {}
+  jv ();
+  operator eh ();
+  unsigned av ()
+  {
+aq = dp & 7;
+return dp * (aq ? : 4);
+  }
+  unsigned ek ()
+  {
+int aw;
+bool mn = dp & 7;
+aw = dp * (mn ? : 4);
+return aw + 3 >> 2;
+  }
+  eh dp;
+} ax, el, ay, jw, az, em, ba, om;
+struct ed
+{
+  ed ():bb (), dp () {}
+  int bc () { return bb; }
+  jv en () { return (eh) dp; }
+  unsigned ek ()
+  {
+jv bd;
+bd = (eh) dp;
+return bd.ek ();
+  }
+  ap jx ();
+  unsigned bb:24;
+  int dp:8;
+};
+struct be { short dp = 0; } bf, eo;
+struct bg
+{
+  bg ();
+  bg (ed r)
+  {
+dp.bh = r;
+if (r.bc ())
+  mo = true;
+else
+  bi = true;
+  }
+  static bg ep (int);
+  bg (be);
+  struct { ed bh; } dp;
+  union { char mo:1; char bi:1; short bj = 0; };
+} jy, bk, eq, bl, mp, bm, er;
+struct bn
+{
+  explicit bn (ed bo):bh (bo) {}
+  ed dp ();
+  ed bh;
+  be es;
+  char bj = 0;
+};
+struct bp
+{
+  eg < int, 6, 4 > dp;
+};
+jt < bg > bq;
+jt < bn > definitions;
+struct ao
+{
+  bp & br ();
+};
+enum jz:short;
+template < typename > using bs = ae;
+ao *et ();
+short bt, nw;
+struct bu
+{
+  int dp;
+};
+dz bv;
+unsigned eu;
+struct bw
+{
+  ac k;
+  unsigned dp;
+} *bx;
+bool ka ();
+struct by
+{
+  bool dp;
+};
+typedef enum
+{ bz, ev }

[gcc r14-10097] Fortran: check C_SIZEOF on additions from TS29113/F2018 [PR103496]

2024-04-23 Thread Harald Anlauf via Gcc-cvs
https://gcc.gnu.org/g:0bf94da59feab2c72a02c91df310a36d33dfd1f7

commit r14-10097-g0bf94da59feab2c72a02c91df310a36d33dfd1f7
Author: Harald Anlauf 
Date:   Tue Apr 23 20:21:43 2024 +0200

Fortran: check C_SIZEOF on additions from TS29113/F2018 [PR103496]

gcc/testsuite/ChangeLog:

PR fortran/103496
* gfortran.dg/c_sizeof_8.f90: New test.

Diff:
---
 gcc/testsuite/gfortran.dg/c_sizeof_8.f90 | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/gcc/testsuite/gfortran.dg/c_sizeof_8.f90 
b/gcc/testsuite/gfortran.dg/c_sizeof_8.f90
new file mode 100644
index 000..0ae284436d0
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/c_sizeof_8.f90
@@ -0,0 +1,23 @@
+! { dg-do run }
+!
+! PR fortran/103496
+!
+! Test that C_SIZEOF returns the expected results
+
+program pr103496
+  use iso_c_binding
+  implicit none
+  integer :: a(6)
+  integer, pointer :: p(:)
+
+  if (c_sizeof(a)   /= 6*4) stop 1
+  if (c_sizeof(a(1))/=   4) stop 2
+  if (c_sizeof(a(:))/= 6*4) stop 3
+  if (c_sizeof(a(2::2)) /= 3*4) stop 4
+
+  allocate(p(5))
+  if (c_sizeof(p)   /= 5*4) stop 5
+  if (c_sizeof(p(1))/=   4) stop 6
+  if (c_sizeof(p(:))/= 5*4) stop 7
+  if (c_sizeof(p(2::2)) /= 2*4) stop 8
+end


[gcc r14-10096] c++/modules: deduced return type merging [PR114795]

2024-04-23 Thread Patrick Palka via Gcc-cvs
https://gcc.gnu.org/g:4f9401d1a802325e5dfa2db841945e1a9c59a980

commit r14-10096-g4f9401d1a802325e5dfa2db841945e1a9c59a980
Author: Patrick Palka 
Date:   Tue Apr 23 14:01:22 2024 -0400

c++/modules: deduced return type merging [PR114795]

When merging an imported function template specialization with an
existing one, if the existing one has an undeduced return type and the
imported one's is already deduced, we need to propagate the deduced type
since once we install the imported definition we won't get a chance to
deduce it by normal means.

So this patch makes is_matching_decl propagate the deduced return
type alongside our propagation of the exception specification.
Another option would be to propagate it later when installing the
imported definition from read_function_def, but it seems preferable
to do it sooner rather than later.

PR c++/114795

gcc/cp/ChangeLog:

* module.cc (trees_in::is_matching_decl): Propagate deduced
function return type.

gcc/testsuite/ChangeLog:

* g++.dg/modules/auto-4_a.H: New test.
* g++.dg/modules/auto-4_b.C: New test.

Reviewed-by: Jason Merrill 

Diff:
---
 gcc/cp/module.cc|  9 +
 gcc/testsuite/g++.dg/modules/auto-4_a.H | 14 ++
 gcc/testsuite/g++.dg/modules/auto-4_b.C | 15 +++
 3 files changed, 38 insertions(+)

diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index d94d8ff4df9..c35e70b8cb8 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -11537,6 +11537,15 @@ trees_in::is_matching_decl (tree existing, tree decl, 
bool is_typedef)
   else if (!DEFERRED_NOEXCEPT_SPEC_P (d_spec)
   && !comp_except_specs (d_spec, e_spec, ce_type))
goto mismatch;
+
+  /* Similarly if EXISTING has an undeduced return type, but DECL's
+is already deduced.  */
+  if (undeduced_auto_decl (existing) && !undeduced_auto_decl (decl))
+   {
+ dump (dumper::MERGE)
+   && dump ("Propagating deduced return type to %N", existing);
+ TREE_TYPE (existing) = change_return_type (TREE_TYPE (d_type), 
e_type);
+   }
 }
   else if (is_typedef)
 {
diff --git a/gcc/testsuite/g++.dg/modules/auto-4_a.H 
b/gcc/testsuite/g++.dg/modules/auto-4_a.H
new file mode 100644
index 000..0f7cd262dfa
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/auto-4_a.H
@@ -0,0 +1,14 @@
+// PR c++/114795
+// { dg-additional-options "-fmodule-header" }
+// { dg-module-cmi {} }
+
+template
+struct A {
+  auto f() { return T(); }
+};
+
+template
+void g() {
+  A a;
+  a.f();
+}
diff --git a/gcc/testsuite/g++.dg/modules/auto-4_b.C 
b/gcc/testsuite/g++.dg/modules/auto-4_b.C
new file mode 100644
index 000..378684ef6d0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/auto-4_b.C
@@ -0,0 +1,15 @@
+// PR c++/114795
+// { dg-additional-options "-fmodules-ts -fno-module-lazy" }
+
+template
+struct A {
+  auto f() { return T(); }
+};
+
+A a;
+
+import "auto-4_a.H";
+
+int main() {
+  g(); // { dg-bogus "before deduction of 'auto'" "" { target *-*-* } 0 }
+}


[gcc r12-10390] tsan: Don't instrument non-generic AS accesses [PR111736]

2024-04-23 Thread Uros Bizjak via Gcc-cvs
https://gcc.gnu.org/g:48fd1c5791b47717dcd4fa5615bc07cf54e964a7

commit r12-10390-g48fd1c5791b47717dcd4fa5615bc07cf54e964a7
Author: Jakub Jelinek 
Date:   Tue Mar 26 11:06:15 2024 +0100

tsan: Don't instrument non-generic AS accesses [PR111736]

Similar to the asan and ubsan changes, we shouldn't instrument non-generic
address space accesses with tsan, because we just have library functions
which take address of the objects as generic address space pointers, so they
can't handle anything else.

2024-03-26  Jakub Jelinek  

PR sanitizer/111736
* tsan.cc (instrument_expr): Punt on non-generic address space
accesses.

* gcc.dg/tsan/pr111736.c: New test.

(cherry picked from commit 471967ab8b4c49338ba77defbe24b06cc51c0093)

Diff:
---
 gcc/testsuite/gcc.dg/tsan/pr111736.c | 17 +
 gcc/tsan.cc  |  3 +++
 2 files changed, 20 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/tsan/pr111736.c 
b/gcc/testsuite/gcc.dg/tsan/pr111736.c
new file mode 100644
index 000..34ab88b3d4f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tsan/pr111736.c
@@ -0,0 +1,17 @@
+/* PR sanitizer/111736 */
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-fsanitize=thread -fdump-tree-optimized -ffat-lto-objects" } 
*/
+/* { dg-final { scan-tree-dump-not "__tsan_read" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "__tsan_write" "optimized" } } */
+
+#ifdef __x86_64__
+#define SEG __seg_fs
+#else
+#define SEG __seg_gs
+#endif
+
+void
+foo (int SEG *p, int SEG *q)
+{
+  *q = *p;
+}
diff --git a/gcc/tsan.cc b/gcc/tsan.cc
index 02e8ac7cf79..2cdda561dbf 100644
--- a/gcc/tsan.cc
+++ b/gcc/tsan.cc
@@ -139,6 +139,9 @@ instrument_expr (gimple_stmt_iterator gsi, tree expr, bool 
is_write)
   if (TREE_READONLY (base) || (VAR_P (base) && DECL_HARD_REGISTER (base)))
 return false;
 
+  if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (TREE_TYPE (base
+return false;
+
   stmt = gsi_stmt (gsi);
   loc = gimple_location (stmt);
   rhs = is_vptr_store (stmt, expr, is_write);


[gcc r12-10388] tree-optimization/111736 - avoid address sanitizing of __seg_gs

2024-04-23 Thread Uros Bizjak via Gcc-cvs
https://gcc.gnu.org/g:e89b5ed62a5a06fb8918ffa1616f0f37c8d359c3

commit r12-10388-ge89b5ed62a5a06fb8918ffa1616f0f37c8d359c3
Author: Richard Biener 
Date:   Thu Mar 21 08:30:39 2024 +0100

tree-optimization/111736 - avoid address sanitizing of __seg_gs

The following more thoroughly avoids address sanitizing accesses
to non-generic address-spaces.

PR tree-optimization/111736
* asan.cc (instrument_derefs): Do not instrument accesses
to non-generic address-spaces.

* gcc.target/i386/pr111736.c: New testcase.

(cherry picked from commit 134ef2a8cac1a5cc718739bd7d3b3472947c80d6)

Diff:
---
 gcc/asan.cc  |  4 
 gcc/testsuite/gcc.target/i386/pr111736.c | 23 +++
 2 files changed, 27 insertions(+)

diff --git a/gcc/asan.cc b/gcc/asan.cc
index 0c5afa36cb8..24cf2b8376b 100644
--- a/gcc/asan.cc
+++ b/gcc/asan.cc
@@ -2712,6 +2712,10 @@ instrument_derefs (gimple_stmt_iterator *iter, tree t,
   if (VAR_P (inner) && DECL_HARD_REGISTER (inner))
 return;
 
+  /* Accesses to non-generic address-spaces should not be instrumented.  */
+  if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (TREE_TYPE (inner
+return;
+
   poly_int64 decl_size;
   if ((VAR_P (inner) || TREE_CODE (inner) == RESULT_DECL)
   && offset == NULL_TREE
diff --git a/gcc/testsuite/gcc.target/i386/pr111736.c 
b/gcc/testsuite/gcc.target/i386/pr111736.c
new file mode 100644
index 000..231fdd07e80
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr111736.c
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fsanitize=address" } */
+
+int __seg_gs m;
+
+int foo (void)
+{
+  return m;
+}
+
+extern int  __seg_gs n;
+
+int bar (void)
+{
+  return n;
+}
+
+int baz (int __seg_gs *o)
+{
+  return *o;
+}
+
+/* { dg-final { scan-assembler-not "asan_report_load" } } */


[gcc r12-10389] ubsan: Don't -fsanitize=null instrument __seg_fs/gs pointers [PR111736]

2024-04-23 Thread Uros Bizjak via Gcc-cvs
https://gcc.gnu.org/g:d6c62e4fb9a6d395599b7c78c831bace4bc7ff8f

commit r12-10389-gd6c62e4fb9a6d395599b7c78c831bace4bc7ff8f
Author: Jakub Jelinek 
Date:   Fri Mar 22 09:23:44 2024 +0100

ubsan: Don't -fsanitize=null instrument __seg_fs/gs pointers [PR111736]

On x86 and avr some address spaces allow 0 pointers (on avr actually
even generic as, but libsanitizer isn't ported to it and
I'm not convinced we should completely kill -fsanitize=null in that
case).
The following patch makes sure those aren't diagnosed for -fsanitize=null,
though they are still sanitized for -fsanitize=alignment.

2024-03-22  Jakub Jelinek  

PR sanitizer/111736
* ubsan.cc (ubsan_expand_null_ifn, instrument_mem_ref): Avoid
SANITIZE_NULL instrumentation for non-generic address spaces
for which targetm.addr_space.zero_address_valid (as) is true.

* gcc.dg/ubsan/pr111736.c: New test.

(cherry picked from commit ddd4a3ca87410886b039cc225907b4f6e650082e)

Diff:
---
 gcc/testsuite/gcc.dg/ubsan/pr111736.c | 23 +++
 gcc/ubsan.cc  | 19 +--
 2 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/ubsan/pr111736.c 
b/gcc/testsuite/gcc.dg/ubsan/pr111736.c
new file mode 100644
index 000..359b31828f0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ubsan/pr111736.c
@@ -0,0 +1,23 @@
+/* PR sanitizer/111736 */
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-fsanitize=null,alignment -fdump-tree-optimized 
-ffat-lto-objects" } */
+/* { dg-final { scan-tree-dump-times "__ubsan_handle_type_mismatch" 1 
"optimized" } } */
+/* { dg-final { scan-tree-dump-not "p_\[0-9]*.D. \[=!]= 0" "optimized" } } */
+
+#ifdef __x86_64__
+#define SEG __seg_fs
+#else
+#define SEG __seg_gs
+#endif
+
+int
+foo (int SEG *p, int *q)
+{
+  return *p;
+}
+
+__attribute__((no_sanitize("alignment"))) int
+bar (int SEG *p, int *q)
+{
+  return *p;
+}
diff --git a/gcc/ubsan.cc b/gcc/ubsan.cc
index 0f5b372b195..4d8e7cd86c5 100644
--- a/gcc/ubsan.cc
+++ b/gcc/ubsan.cc
@@ -49,6 +49,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-cfg.h"
 #include "gimple-fold.h"
 #include "varasm.h"
+#include "target.h"
 
 /* Map from a tree to a VAR_DECL tree.  */
 
@@ -784,6 +785,13 @@ ubsan_expand_null_ifn (gimple_stmt_iterator *gsip)
}
 }
   check_null = sanitize_flags_p (SANITIZE_NULL);
+  if (check_null && POINTER_TYPE_P (TREE_TYPE (ptr)))
+{
+  addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (ptr)));
+  if (!ADDR_SPACE_GENERIC_P (as)
+ && targetm.addr_space.zero_address_valid (as))
+   check_null = false;
+}
 
   if (check_align == NULL_TREE && !check_null)
 {
@@ -1375,8 +1383,15 @@ instrument_mem_ref (tree mem, tree base, 
gimple_stmt_iterator *iter,
   if (align <= 1)
align = 0;
 }
-  if (align == 0 && !sanitize_flags_p (SANITIZE_NULL))
-return;
+  if (align == 0)
+{
+  if (!sanitize_flags_p (SANITIZE_NULL))
+   return;
+  addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (base));
+  if (!ADDR_SPACE_GENERIC_P (as)
+ && targetm.addr_space.zero_address_valid (as))
+   return;
+}
   tree t = TREE_OPERAND (base, 0);
   if (!POINTER_TYPE_P (TREE_TYPE (t)))
 return;


[gcc r12-10387] sanitizer/111736 - skip ASAN for globals in alternate address-space

2024-04-23 Thread Uros Bizjak via Gcc-cvs
https://gcc.gnu.org/g:61d1962e7c3c32da6962d9cb20f6fd996501f3f2

commit r12-10387-g61d1962e7c3c32da6962d9cb20f6fd996501f3f2
Author: Richard Biener 
Date:   Tue Dec 5 14:00:43 2023 +0100

sanitizer/111736 - skip ASAN for globals in alternate address-space

PR sanitizer/111736
* asan.cc (asan_protect_global): Do not protect globals
in non-generic address-space.

(cherry picked from commit 7e40497805c0831596334fe474112f991276e11b)

Diff:
---
 gcc/asan.cc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/asan.cc b/gcc/asan.cc
index 72d1ef28be8..0c5afa36cb8 100644
--- a/gcc/asan.cc
+++ b/gcc/asan.cc
@@ -2251,6 +2251,8 @@ asan_protect_global (tree decl, bool 
ignore_decl_rtl_set_p)
   || (DECL_SECTION_NAME (decl) != NULL
  && !symtab_node::get (decl)->implicit_section
  && !section_sanitized_p (DECL_SECTION_NAME (decl)))
+  /* Don't protect variables in non-generic address-space.  */
+  || !ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (TREE_TYPE (decl)))
   || DECL_SIZE (decl) == 0
   || ASAN_RED_ZONE_SIZE * BITS_PER_UNIT > MAX_OFILE_ALIGNMENT
   || TREE_CODE (DECL_SIZE_UNIT (decl)) != INTEGER_CST


[gcc r14-10095] libbacktrace: test --compress-debug-sections=ARG for each ARG

2024-04-23 Thread Ian Lance Taylor via Gcc-cvs
https://gcc.gnu.org/g:d2f05fed44951001de3cb02c9193c687e9376170

commit r14-10095-gd2f05fed44951001de3cb02c9193c687e9376170
Author: Ian Lance Taylor 
Date:   Tue Apr 23 10:00:03 2024 -0700

libbacktrace: test --compress-debug-sections=ARG for each ARG

This should fix a testsuite problem with Solaris ld that supports zlib
but not zlib-gabi.

* configure.ac: Test --compress-debug-sections=zlib-gnu and
--compress-debug-sections=zlib-gabi separately, setting new
automake conditionals.
* Makefile.am (ctestg, ctestg_alloc): Only build if
HAVE_COMPRESSED_DEBUG_ZLIB_GNU.
(ctesta, ctesta_alloc): Only build if
HAVE_COMPRESSED_DEBUG_ZLIB_GABI.
(ctestzstd_alloc): New test if HAVE_COMPRESSED_DEBUG_ZSTD.
* configure, Makefile.in: Regenerate.

Diff:
---
 libbacktrace/Makefile.am  |  41 ++
 libbacktrace/Makefile.in  | 186 +++---
 libbacktrace/configure|  80 +++-
 libbacktrace/configure.ac |  23 --
 4 files changed, 214 insertions(+), 116 deletions(-)

diff --git a/libbacktrace/Makefile.am b/libbacktrace/Makefile.am
index 5677ecd8865..bed42c29329 100644
--- a/libbacktrace/Makefile.am
+++ b/libbacktrace/Makefile.am
@@ -493,19 +493,37 @@ endif HAVE_OBJCOPY_DEBUGLINK
  $<
$(OBJCOPY) --strip-all $< $@
 
-if HAVE_COMPRESSED_DEBUG
+if HAVE_COMPRESSED_DEBUG_ZLIB_GNU
 
 ctestg_SOURCES = btest.c testlib.c
 ctestg_CFLAGS = $(libbacktrace_TEST_CFLAGS)
 ctestg_LDFLAGS = -Wl,--compress-debug-sections=zlib-gnu 
$(libbacktrace_testing_ldflags)
 ctestg_LDADD = libbacktrace.la
 
+ctestg_alloc_SOURCES = $(ctestg_SOURCES)
+ctestg_alloc_CFLAGS = $(ctestg_CFLAGS)
+ctestg_alloc_LDFLAGS = $(ctestg_LDFLAGS) $(libbacktrace_testing_ldflags)
+ctestg_alloc_LDADD = libbacktrace_alloc.la
+
+BUILDTESTS += ctestg ctestg_alloc
+
+endif
+
+if HAVE_COMPRESSED_DEBUG_ZLIB_GABI
+
 ctesta_SOURCES = btest.c testlib.c
 ctesta_CFLAGS = $(libbacktrace_TEST_CFLAGS)
 ctesta_LDFLAGS = -Wl,--compress-debug-sections=zlib-gabi 
$(libbacktrace_testing_ldflags)
 ctesta_LDADD = libbacktrace.la
 
-BUILDTESTS += ctestg ctesta
+ctesta_alloc_SOURCES = $(ctesta_SOURCES)
+ctesta_alloc_CFLAGS = $(ctesta_CFLAGS)
+ctesta_alloc_LDFLAGS = $(ctesta_LDFLAGS) $(libbacktrace_testing_ldflags)
+ctesta_alloc_LDADD = libbacktrace_alloc.la
+
+BUILDTESTS += ctesta ctesta_alloc
+
+endif
 
 if HAVE_COMPRESSED_DEBUG_ZSTD
 
@@ -514,21 +532,12 @@ ctestzstd_CFLAGS = $(libbacktrace_TEST_CFLAGS)
 ctestzstd_LDFLAGS = -Wl,--compress-debug-sections=zstd 
$(libbacktrace_testing_ldflags)
 ctestzstd_LDADD = libbacktrace.la
 
-BUILDTESTS += ctestzstd
-
-endif
-
-ctestg_alloc_SOURCES = $(ctestg_SOURCES)
-ctestg_alloc_CFLAGS = $(ctestg_CFLAGS)
-ctestg_alloc_LDFLAGS = $(ctestg_LDFLAGS) $(libbacktrace_testing_ldflags)
-ctestg_alloc_LDADD = libbacktrace_alloc.la
-
-ctesta_alloc_SOURCES = $(ctesta_SOURCES)
-ctesta_alloc_CFLAGS = $(ctesta_CFLAGS)
-ctesta_alloc_LDFLAGS = $(ctesta_LDFLAGS) $(libbacktrace_testing_ldflags)
-ctesta_alloc_LDADD = libbacktrace_alloc.la
+ctestzstd_alloc_SOURCES = $(ctestzstd_SOURCES)
+ctestzstd_alloc_CFLAGS = $(ctestzstd_CFLAGS)
+ctestzstd_alloc_LDFLAGS = $(ctestzstd_LDFLAGS) $(libbacktrace_testing_ldflags)
+ctestzstd_alloc_LDADD = libbacktrace_alloc.la
 
-BUILDTESTS += ctestg_alloc ctesta_alloc
+BUILDTESTS += ctestzstd ctestzstd_alloc
 
 endif
 
diff --git a/libbacktrace/Makefile.in b/libbacktrace/Makefile.in
index 49852a21d37..0260ca81798 100644
--- a/libbacktrace/Makefile.in
+++ b/libbacktrace/Makefile.in
@@ -153,9 +153,9 @@ TESTS = $(am__append_4) $(MAKETESTS) $(am__EXEEXT_16)
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@@USE_DSYMUTIL_TRUE@ttest.dSYM \
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@@USE_DSYMUTIL_TRUE@ttest_alloc.dSYM
 @HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_22 = btest_gnudebuglink 
btest_gnudebuglinkfull
-@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__append_23 = ctestg ctesta
-@HAVE_COMPRESSED_DEBUG_TRUE@@HAVE_COMPRESSED_DEBUG_ZSTD_TRUE@@NATIVE_TRUE@am__append_24
 = ctestzstd
-@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__append_25 = ctestg_alloc 
ctesta_alloc
+@HAVE_COMPRESSED_DEBUG_ZLIB_GNU_TRUE@@NATIVE_TRUE@am__append_23 = ctestg 
ctestg_alloc
+@HAVE_COMPRESSED_DEBUG_ZLIB_GABI_TRUE@@NATIVE_TRUE@am__append_24 = ctesta 
ctesta_alloc
+@HAVE_COMPRESSED_DEBUG_ZSTD_TRUE@@NATIVE_TRUE@am__append_25 = ctestzstd 
ctestzstd_alloc
 @HAVE_DWARF5_TRUE@@NATIVE_TRUE@am__append_26 = dwarf5 dwarf5_alloc
 @HAVE_DWARF5_TRUE@@NATIVE_TRUE@@USE_DSYMUTIL_TRUE@am__append_27 =  \
 @HAVE_DWARF5_TRUE@@NATIVE_TRUE@@USE_DSYMUTIL_TRUE@ dwarf5.dSYM \
@@ -239,12 +239,12 @@ libbacktrace_noformat_la_OBJECTS =  \
 @NATIVE_TRUE@am__EXEEXT_8 = edtest$(EXEEXT) edtest_alloc$(EXEEXT)
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__EXEEXT_9 = ttest$(EXEEXT) \
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@   ttest_alloc$(EXEEXT)
-@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__EXEEXT_10 =  \
-@HAVE_COMPRESSED_DEBUG_TRUE@@N

[gcc r14-10094] testsuite: Adjust testsuite expectations for diagnostic spelling fixes

2024-04-23 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:0c8e99e5c32be9f2604f3c330814993f29818037

commit r14-10094-g0c8e99e5c32be9f2604f3c330814993f29818037
Author: Jakub Jelinek 
Date:   Tue Apr 23 17:39:48 2024 +0200

testsuite: Adjust testsuite expectations for diagnostic spelling fixes

The nullability-00.m* tests unfortunately check the exact spelling of
the diagnostics I've changed earlier today.

2024-04-23  Jakub Jelinek  

* objc.dg/attributes/nullability-00.m: Adjust expected diagnostic
spelling: recognised -> recognized.
* obj-c++.dg/attributes/nullability-00.mm: Likewise.

Diff:
---
 gcc/testsuite/obj-c++.dg/attributes/nullability-00.mm | 2 +-
 gcc/testsuite/objc.dg/attributes/nullability-00.m | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/obj-c++.dg/attributes/nullability-00.mm 
b/gcc/testsuite/obj-c++.dg/attributes/nullability-00.mm
index 957fca4e3ba..cb25cbd4c62 100644
--- a/gcc/testsuite/obj-c++.dg/attributes/nullability-00.mm
+++ b/gcc/testsuite/obj-c++.dg/attributes/nullability-00.mm
@@ -8,7 +8,7 @@ __attribute__((objc_nullability("unspecified"))) id b;
 __attribute__((objc_nullability("nullable"))) id c;
 __attribute__((objc_nullability("nonnull"))) id d;
 __attribute__((objc_nullability("resettable"))) id e;
-__attribute__((objc_nullability("nonsense"))) id e_3; /* { dg-error 
{'objc_nullability' attribute argument '"nonsense"' is not recognised} } */
+__attribute__((objc_nullability("nonsense"))) id e_3; /* { dg-error 
{'objc_nullability' attribute argument '"nonsense"' is not recognized} } */
 __attribute__((objc_nullability(noGoingToWork))) id e_4; /* { dg-error 
{'noGoingToWork' was not declared in this scope} } */
 
 @interface MyRoot
diff --git a/gcc/testsuite/objc.dg/attributes/nullability-00.m 
b/gcc/testsuite/objc.dg/attributes/nullability-00.m
index 81c0145f17b..2d7e22cf6f7 100644
--- a/gcc/testsuite/objc.dg/attributes/nullability-00.m
+++ b/gcc/testsuite/objc.dg/attributes/nullability-00.m
@@ -8,7 +8,7 @@ __attribute__((objc_nullability("unspecified"))) id b;
 __attribute__((objc_nullability("nullable"))) id c;
 __attribute__((objc_nullability("nonnull"))) id d;
 __attribute__((objc_nullability("resettable"))) id e;
-__attribute__((objc_nullability("nonsense"))) id e_3; /* { dg-error 
{'objc_nullability' attribute argument '"nonsense"' is not recognised} } */
+__attribute__((objc_nullability("nonsense"))) id e_3; /* { dg-error 
{'objc_nullability' attribute argument '"nonsense"' is not recognized} } */
 __attribute__((objc_nullability(noGoingToWork))) id e_4; /* { dg-error 
{'noGoingToWork' undeclared here} } */
 
 @interface MyRoot


[gcc r11-11347] testsuite,X86: Fix missing USER_LABEL_PREFIX cases.

2024-04-23 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:a428bc0c7a019328eefffd9eaa3153550c9a9384

commit r11-11347-ga428bc0c7a019328eefffd9eaa3153550c9a9384
Author: Iain Sandoe 
Date:   Fri Apr 15 15:51:22 2022 +0100

testsuite,X86: Fix missing USER_LABEL_PREFIX cases.

Yet another set of testcases that do not account for targets that
use __USER_LABEL_PREFIX__.

Signed-off-by: Iain Sandoe 

gcc/testsuite/ChangeLog:

* gcc.target/i386/memcpy-strategy-10.c: Account for
__USER_LABEL_PREFIX__.
* gcc.target/i386/memcpy-strategy-5.c: Likewise.
* gcc.target/i386/memset-strategy-5.c: Likewise.
* gcc.target/i386/memset-strategy-7.c: Likewise.

Diff:
---
 gcc/testsuite/gcc.target/i386/memcpy-strategy-10.c | 4 ++--
 gcc/testsuite/gcc.target/i386/memcpy-strategy-5.c  | 4 ++--
 gcc/testsuite/gcc.target/i386/memset-strategy-5.c  | 4 ++--
 gcc/testsuite/gcc.target/i386/memset-strategy-7.c  | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/gcc/testsuite/gcc.target/i386/memcpy-strategy-10.c 
b/gcc/testsuite/gcc.target/i386/memcpy-strategy-10.c
index 970aa741971..860fcc9f801 100644
--- a/gcc/testsuite/gcc.target/i386/memcpy-strategy-10.c
+++ b/gcc/testsuite/gcc.target/i386/memcpy-strategy-10.c
@@ -1,7 +1,7 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -march=skylake -mno-sse" } */
-/* { dg-final { scan-assembler "jmp\tmemcpy" { target { ! ia32 } } } } */
-/* { dg-final { scan-assembler "call\tmemcpy" { target ia32 } } } */
+/* { dg-final { scan-assembler "jmp\t_?memcpy" { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler "call\t_?memcpy" { target ia32 } } } */
 /* { dg-final { scan-assembler-not "rep movsb" } } */
 
 void
diff --git a/gcc/testsuite/gcc.target/i386/memcpy-strategy-5.c 
b/gcc/testsuite/gcc.target/i386/memcpy-strategy-5.c
index 83c333b551d..833e37fa325 100644
--- a/gcc/testsuite/gcc.target/i386/memcpy-strategy-5.c
+++ b/gcc/testsuite/gcc.target/i386/memcpy-strategy-5.c
@@ -1,7 +1,7 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -march=tigerlake -mno-sse" } */
-/* { dg-final { scan-assembler "jmp\tmemcpy" { target { ! ia32 } } } } */
-/* { dg-final { scan-assembler "call\tmemcpy" { target ia32 } } } */
+/* { dg-final { scan-assembler "jmp\t_?memcpy" { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler "call\t_?memcpy" { target ia32 } } } */
 /* { dg-final { scan-assembler-not "rep movsb" } } */
 
 void
diff --git a/gcc/testsuite/gcc.target/i386/memset-strategy-5.c 
b/gcc/testsuite/gcc.target/i386/memset-strategy-5.c
index dc1de8e79c2..73ce2df6060 100644
--- a/gcc/testsuite/gcc.target/i386/memset-strategy-5.c
+++ b/gcc/testsuite/gcc.target/i386/memset-strategy-5.c
@@ -1,7 +1,7 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -march=tigerlake -mno-sse" } */
-/* { dg-final { scan-assembler "jmp\tmemset" { target { ! ia32 } } } } */
-/* { dg-final { scan-assembler "call\tmemset" { target ia32 } } } */
+/* { dg-final { scan-assembler "jmp\t_?memset" { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler "call\t_?memset" { target ia32 } } } */
 /* { dg-final { scan-assembler-not "rep stosb" } } */
 
 void
diff --git a/gcc/testsuite/gcc.target/i386/memset-strategy-7.c 
b/gcc/testsuite/gcc.target/i386/memset-strategy-7.c
index 07c2816910c..653829e6fc7 100644
--- a/gcc/testsuite/gcc.target/i386/memset-strategy-7.c
+++ b/gcc/testsuite/gcc.target/i386/memset-strategy-7.c
@@ -1,7 +1,7 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -march=skylake -mno-sse" } */
-/* { dg-final { scan-assembler "jmp\tmemset" { target { ! ia32 } } } } */
-/* { dg-final { scan-assembler "call\tmemset" { target ia32 } } } */
+/* { dg-final { scan-assembler "jmp\t_?memset" { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler "call\t_?memset" { target ia32 } } } */
 /* { dg-final { scan-assembler-not "rep stosb" } } */
 
 void


[gcc r11-11346] add missing dg-require alias to gcc.dg/torture/pr100786.c

2024-04-23 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:1a2781ba50adf8b384f976553ac6fdeb533119b4

commit r11-11346-g1a2781ba50adf8b384f976553ac6fdeb533119b4
Author: Richard Biener 
Date:   Mon Mar 28 09:48:08 2022 +0200

add missing dg-require alias to gcc.dg/torture/pr100786.c

2022-03-28  Richard Biener  

* gcc.dg/torture/pr100786.c: Add dg-require alias.

(cherry picked from commit f6819b7fea38f2e5482c71aabab3d44a8bd7d904)

Diff:
---
 gcc/testsuite/gcc.dg/torture/pr100786.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/testsuite/gcc.dg/torture/pr100786.c 
b/gcc/testsuite/gcc.dg/torture/pr100786.c
index 42f4e485593..7c03b08d8cb 100644
--- a/gcc/testsuite/gcc.dg/torture/pr100786.c
+++ b/gcc/testsuite/gcc.dg/torture/pr100786.c
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-require-alias "" } */
 
 const double a = 0;
 extern int b __attribute__((alias("a")));


[gcc r11-11345] Darwin: Fix a type mismatch warning for a non-GCC bootstrap compiler.

2024-04-23 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:a73f2d80e909b67bbe3dc0abb48cf422810e1564

commit r11-11345-ga73f2d80e909b67bbe3dc0abb48cf422810e1564
Author: Iain Sandoe 
Date:   Fri Mar 4 12:39:03 2022 +

Darwin: Fix a type mismatch warning for a non-GCC bootstrap compiler.

DECL_MD_FUNCTION_CODE() returns an int, on one particular compiler the
code in darwin_fold_builtin() triggers a warning.

Fixed thus.

Signed-off-by: Iain Sandoe 

gcc/ChangeLog:

* config/darwin.c (darwin_fold_builtin): Make fcode an int to
avoid a mismatch with DECL_MD_FUNCTION_CODE().

(cherry picked from commit 25587472ccd223c861fe77cfeca4ba33c3f6cd99)

Diff:
---
 gcc/config/darwin.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index dedf84d6247..2371816e251 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -3620,7 +3620,7 @@ tree
 darwin_fold_builtin (tree fndecl, int n_args, tree *argp,
 bool ARG_UNUSED (ignore))
 {
-  unsigned int fcode = DECL_MD_FUNCTION_CODE (fndecl);
+  int fcode = DECL_MD_FUNCTION_CODE (fndecl);
 
   if (fcode == darwin_builtin_cfstring)
 {


[gcc r11-11344] libphobos, testsuite: Add prune clauses for two Darwin cases.

2024-04-23 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:4a0e4f68a39c19c27456c9925c9dc85a3617ebad

commit r11-11344-g4a0e4f68a39c19c27456c9925c9dc85a3617ebad
Author: Iain Sandoe 
Date:   Fri Nov 19 15:48:53 2021 +

libphobos, testsuite: Add prune clauses for two Darwin cases.

Depending on the permutation of CPU, OS version and shared/non-
shared library inclusion, we get can get two warnings from the
external tools (ld64, dsymutil) which are not actually GCC issues
but relate to the external tools.  These are alrrady pruned in
the main testsuite, this adds them to the library.

Signed-off-by: Iain Sandoe 

libphobos/ChangeLog:

* testsuite/lib/libphobos.exp: Prune warnings from external
tool bugs.

(cherry picked from commit 532fae74c3b1197023a765272892e12e123f0a56)

Diff:
---
 libphobos/testsuite/lib/libphobos.exp | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/libphobos/testsuite/lib/libphobos.exp 
b/libphobos/testsuite/lib/libphobos.exp
index 3be2092b12e..2af430a0e45 100644
--- a/libphobos/testsuite/lib/libphobos.exp
+++ b/libphobos/testsuite/lib/libphobos.exp
@@ -90,6 +90,13 @@ proc libphobos-dg-test { prog do_what extra_tool_flags } {
 }
 
 proc libphobos-dg-prune { system text } {
+
+# Ignore harmless warnings from Xcode.
+regsub -all "(^|\n)\[^\n\]*ld: warning: could not create compact unwind 
for\[^\n\]*" $text "" text
+
+# Ignore dsymutil warning (tool bug is actually linker)
+regsub -all "(^|\n)\[^\n\]*could not find object file symbol for 
symbol\[^\n\]*" $text "" text
+
 return $text
 }


[gcc r11-11343] configure, Darwin: Check ld64 support for -platform-version.

2024-04-23 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:4b263d5d06494774bc72f85b1206e1dc2c8fbd15

commit r11-11343-g4b263d5d06494774bc72f85b1206e1dc2c8fbd15
Author: Iain Sandoe 
Date:   Fri Nov 12 17:03:09 2021 +

configure, Darwin: Check ld64 support for -platform-version.

Newer versions of ld64 allow specifiying the OS target (e.g.
macos or ios) the version and the SDK version all in a single
command.  This checks the availability of the command for the
current toolchain.

Signed-off-by: Iain Sandoe 

gcc/ChangeLog:

* config.in: Regenerate.
* configure: Regenerate.
* configure.ac: Test ld64 for -platform-version support.

(cherry picked from commit d3cc82dc9cc2d4f1021fc5d4c1463c3a14fc6795)

Diff:
---
 gcc/config.in|  6 ++
 gcc/configure| 21 -
 gcc/configure.ac | 16 +++-
 3 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/gcc/config.in b/gcc/config.in
index 048bf52e8c2..982c453ca36 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -2207,6 +2207,12 @@
 #endif
 
 
+/* Define to 1 if ld64 supports '-platform_version'. */
+#ifndef USED_FOR_TARGET
+#undef LD64_HAS_PLATFORM_VERSION
+#endif
+
+
 /* Define to ld64 version. */
 #ifndef USED_FOR_TARGET
 #undef LD64_VERSION
diff --git a/gcc/configure b/gcc/configure
index 3a9d5e269d1..0b9c7451231 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -30698,6 +30698,7 @@ if test x"$ld64_flag" = x"yes"; then
 
   # Set defaults for possibly untestable items.
   gcc_cv_ld64_export_dynamic=0
+  gcc_cv_ld64_platform_version=0
 
   if test "$build" = "$host"; then
 darwin_try_test=1
@@ -30721,9 +30722,12 @@ $as_echo_n "checking ld64 specified version... " >&6; }
 gcc_cv_ld64_major=`echo "$gcc_cv_ld64_version" | sed -e 's/\..*//'`
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld64_major" >&5
 $as_echo "$gcc_cv_ld64_major" >&6; }
-   if test "$gcc_cv_ld64_major" -ge 236; then
+if test "$gcc_cv_ld64_major" -ge 236; then
   gcc_cv_ld64_export_dynamic=1
 fi
+if test "$gcc_cv_ld64_major" -ge 512; then
+  gcc_cv_ld64_platform_version=1
+fi
   elif test -x "$gcc_cv_ld" -a "$darwin_try_test" -eq 1; then
 # If the version was not specified, try to find it.
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker version" >&5
@@ -30742,6 +30746,15 @@ $as_echo_n "checking linker for -export_dynamic 
support... " >&6; }
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: 
$gcc_cv_ld64_export_dynamic" >&5
 $as_echo "$gcc_cv_ld64_export_dynamic" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking linker for 
-platform_version support" >&5
+$as_echo_n "checking linker for -platform_version support... " >&6; }
+gcc_cv_ld64_platform_version=1
+if $gcc_cv_ld -platform_version macos 10.5 0.0 < /dev/null 2>&1 | grep 
'unknown option' > /dev/null; then
+  gcc_cv_ld64_platform_version=0
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: 
$gcc_cv_ld64_platform_version" >&5
+$as_echo "$gcc_cv_ld64_platform_version" >&6; }
   fi
 
   if test x"${gcc_cv_ld64_version}" != x; then
@@ -30757,6 +30770,12 @@ cat >>confdefs.h <<_ACEOF
 #define LD64_HAS_EXPORT_DYNAMIC $gcc_cv_ld64_export_dynamic
 _ACEOF
 
+
+
+cat >>confdefs.h <<_ACEOF
+#define LD64_HAS_PLATFORM_VERSION $gcc_cv_ld64_platform_version
+_ACEOF
+
 fi
 
 if test x"$dsymutil_flag" = x"yes"; then
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 1e54494c535..2bf0e8a12b7 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -6351,6 +6351,7 @@ if test x"$ld64_flag" = x"yes"; then
 
   # Set defaults for possibly untestable items.
   gcc_cv_ld64_export_dynamic=0
+  gcc_cv_ld64_platform_version=0
 
   if test "$build" = "$host"; then
 darwin_try_test=1
@@ -6372,9 +6373,12 @@ if test x"$ld64_flag" = x"yes"; then
 AC_MSG_CHECKING(ld64 specified version)
 gcc_cv_ld64_major=`echo "$gcc_cv_ld64_version" | sed -e 's/\..*//'`
 AC_MSG_RESULT($gcc_cv_ld64_major)
-   if test "$gcc_cv_ld64_major" -ge 236; then
+if test "$gcc_cv_ld64_major" -ge 236; then
   gcc_cv_ld64_export_dynamic=1
 fi
+if test "$gcc_cv_ld64_major" -ge 512; then
+  gcc_cv_ld64_platform_version=1
+fi
   elif test -x "$gcc_cv_ld" -a "$darwin_try_test" -eq 1; then
 # If the version was not specified, try to find it.
 AC_MSG_CHECKING(linker version)
@@ -6389,6 +6393,13 @@ if test x"$ld64_flag" = x"yes"; then
   gcc_cv_ld64_export_dynamic=0
 fi
 AC_MSG_RESULT($gcc_cv_ld64_export_dynamic)
+
+AC_MSG_CHECKING(linker for -platform_version support)
+gcc_cv_ld64_platform_version=1
+if $gcc_cv_ld -platform_version macos 10.5 0.0 < /dev/null 2>&1 | grep 
'unknown option' > /dev/null; then
+  gcc_cv_ld64_platform_version=0
+fi
+AC_MSG_RESULT($gcc_cv_ld64_platform_version)
   fi
 
   if test x"${gcc_cv_ld64_version}" != x; then
@@ -6398,6 +6409,9 @@ if test x"$ld64_flag" = x"yes"; then
 
   AC_DEFINE_UNQU

[gcc r11-11342] testsuite, Darwin : Do not claim 'GAS' for cctools assembler.

2024-04-23 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:5568dda5a01cba6925b3fe5a2ae8a56caee539c5

commit r11-11342-g5568dda5a01cba6925b3fe5a2ae8a56caee539c5
Author: Iain Sandoe 
Date:   Mon Mar 15 21:38:31 2021 +

testsuite, Darwin : Do not claim 'GAS' for cctools assembler.

Although the cctools assembler is based of GNU GAS, it is from a
very old version (1.38) which does not support many of the features
that the target supports test is expecting.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp: Exclude cctools assembler based on
GAS 1.38.

(cherry picked from commit e42ea63bcc12e819c3e1066974a691988e86b724)

Diff:
---
 gcc/testsuite/lib/target-supports.exp | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index 63a5f5579be..876b972a433 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -9576,7 +9576,14 @@ proc check_effective_target_gas { } {
set status [remote_exec host "$gcc_as" "-v /dev/null"]
set as_output [lindex $status 1]
if { [ string first "GNU" $as_output ] >= 0 } {
-   set use_gas_saved 1
+   # Some Darwin versions have an assembler which is based on an old
+   # version of GAS (and reports GNU assembler in its -v output) but
+   # but doesn't support many of the modern GAS features.
+   if { [ string first "cctools" $as_output ] >= 0 } {
+   set use_gas_saved 0
+   } else {
+   set use_gas_saved 1
+   }
} else {
set use_gas_saved 0
}


[gcc r11-11341] Objective-C: Default flag_objc_sjlj_exceptions off for NeXT ABI >= 2.

2024-04-23 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:895bb1b2eb82e76d3bfc48bf35a0bbafae82d873

commit r11-11341-g895bb1b2eb82e76d3bfc48bf35a0bbafae82d873
Author: Matt Jacobson 
Date:   Thu Jul 29 09:57:23 2021 +0100

Objective-C: Default flag_objc_sjlj_exceptions off for NeXT ABI >= 2.

Signed-off-by: Matt Jacobson 

gcc/c-family/ChangeLog:

* c-opts.c (c_common_post_options): Default to
flag_objc_sjlj_exceptions = 1 only when flag_objc_abi < 2.

gcc/objc/ChangeLog:

* objc-next-runtime-abi-02.c
(objc_next_runtime_abi_02_init): Warn about and reset
flag_objc_sjlj_exceptions regardless of flag_objc_exceptions.
(next_runtime_02_initialize): Use a checking assert that
flag_objc_sjlj_exceptions is off.

(cherry picked from commit 798666392b512a585f0de2983a5d3423e960959e)

Diff:
---
 gcc/c-family/c-opts.c   | 4 ++--
 gcc/objc/objc-next-runtime-abi-02.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c
index 6f001e0bb6c..5bfa239ec0b 100644
--- a/gcc/c-family/c-opts.c
+++ b/gcc/c-family/c-opts.c
@@ -852,9 +852,9 @@ c_common_post_options (const char **pfilename)
   else if (!flag_gnu89_inline && !flag_isoc99)
 error ("%<-fno-gnu89-inline%> is only supported in GNU99 or C99 mode");
 
-  /* Default to ObjC sjlj exception handling if NeXT runtime.  */
+  /* Default to ObjC sjlj exception handling if NeXT runtime < v2.  */
   if (flag_objc_sjlj_exceptions < 0)
-flag_objc_sjlj_exceptions = flag_next_runtime;
+flag_objc_sjlj_exceptions = (flag_next_runtime && flag_objc_abi < 2);
   if (flag_objc_exceptions && !flag_objc_sjlj_exceptions)
 flag_exceptions = 1;
 
diff --git a/gcc/objc/objc-next-runtime-abi-02.c 
b/gcc/objc/objc-next-runtime-abi-02.c
index 2f18b04e34a..2a4f87cc726 100644
--- a/gcc/objc/objc-next-runtime-abi-02.c
+++ b/gcc/objc/objc-next-runtime-abi-02.c
@@ -245,7 +245,7 @@ objc_next_runtime_abi_02_init (objc_runtime_hooks *rthooks)
 {
   extern_names = ggc_cleared_vec_alloc (SIZEHASHTABLE);
 
-  if (flag_objc_exceptions && flag_objc_sjlj_exceptions)
+  if (flag_objc_sjlj_exceptions)
 {
   inform (UNKNOWN_LOCATION,
  "%<-fobjc-sjlj-exceptions%> is ignored for "
@@ -511,7 +511,7 @@ static void next_runtime_02_initialize (void)
   objc_getPropertyStruct_decl = NULL_TREE;
   objc_setPropertyStruct_decl = NULL_TREE;
 
-  gcc_assert (!flag_objc_sjlj_exceptions);
+  gcc_checking_assert (!flag_objc_sjlj_exceptions);
 
   /* Although we warn that fobjc-exceptions is required for exceptions
  code, we carry on and create it anyway.  */


[gcc r11-11340] Objective-C, NeXT runtime: Correct the default for fobjc-nilcheck.

2024-04-23 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:b907af1ce4966b662ae3d26afa24fa6c3ac468c9

commit r11-11340-gb907af1ce4966b662ae3d26afa24fa6c3ac468c9
Author: Iain Sandoe 
Date:   Sun Aug 15 12:52:30 2021 +0100

Objective-C, NeXT runtime: Correct the default for fobjc-nilcheck.

It is intended that the default for the NeXT runtime at ABI 2 is to
check for nil message receivers.  This updates this to match the
documented behaviour and to match the behaviour of the system tools.

Signed-off-by: Iain Sandoe 

gcc/objc/ChangeLog:

* objc-next-runtime-abi-02.c (objc_next_runtime_abi_02_init):
Default receiver nilchecks on.

(cherry picked from commit de0b250b2badb475f8c09f3cd2c57fd3f9127fe3)

Diff:
---
 gcc/objc/objc-next-runtime-abi-02.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/gcc/objc/objc-next-runtime-abi-02.c 
b/gcc/objc/objc-next-runtime-abi-02.c
index e99c048e3a1..2f18b04e34a 100644
--- a/gcc/objc/objc-next-runtime-abi-02.c
+++ b/gcc/objc/objc-next-runtime-abi-02.c
@@ -254,6 +254,10 @@ objc_next_runtime_abi_02_init (objc_runtime_hooks *rthooks)
   flag_objc_sjlj_exceptions = 0;
 }
 
+  /* NeXT ABI 2 is intended to default to checking for nil receivers.  */
+  if (! global_options_set.x_flag_objc_nilcheck)
+flag_objc_nilcheck = 1;
+
   rthooks->initialize = next_runtime_02_initialize;
   rthooks->default_constant_string_class_name = DEF_CONSTANT_STRING_CLASS_NAME;
   rthooks->tag_getclass = TAG_GETCLASS;


[gcc r11-11339] Objective-C: fix crash with -fobjc-nilcheck

2024-04-23 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:87431b4a81e9dc5988509399704a7352800c6a77

commit r11-11339-g87431b4a81e9dc5988509399704a7352800c6a77
Author: Iain Sandoe 
Date:   Sat Aug 14 12:27:55 2021 +0100

Objective-C: fix crash with -fobjc-nilcheck

When -fobjc-nilcheck is enabled, messages that result in a struct type 
should
yield a zero-initialized struct when sent to nil.  Currently, the frontend
crashes when it encounters this situation.  This patch fixes the crash by
generating the tree for the `{}` initializer.

Signed-off-by: Iain Sandoe 
Co-authored-by: Matt Jacobson  

PR objc/101666

gcc/objc/ChangeLog:

* objc-act.c (objc_build_constructor): Handle empty constructor
lists.
* objc-next-runtime-abi-02.c (build_v2_objc_method_fixup_call):
Handle nil receivers.
(build_v2_build_objc_method_call): Likewise.

gcc/testsuite/ChangeLog:

* obj-c++.dg/pr101666-0.mm: New test.
* obj-c++.dg/pr101666-1.mm: New test.
* obj-c++.dg/pr101666.inc: New.
* objc.dg/pr101666-0.m: New test.
* objc.dg/pr101666-1.m: New test.
* objc.dg/pr101666.inc: New.

(cherry picked from commit d2aa4e0b3b5053df8f5853d9ed29022ff0d3ecf6)

Diff:
---
 gcc/objc/objc-act.c| 16 +---
 gcc/objc/objc-next-runtime-abi-02.c| 22 +++---
 gcc/testsuite/obj-c++.dg/pr101666-0.mm |  7 +++
 gcc/testsuite/obj-c++.dg/pr101666-1.mm | 10 ++
 gcc/testsuite/obj-c++.dg/pr101666.inc  | 29 +
 gcc/testsuite/objc.dg/pr101666-0.m |  7 +++
 gcc/testsuite/objc.dg/pr101666-1.m | 10 ++
 gcc/testsuite/objc.dg/pr101666.inc | 29 +
 8 files changed, 108 insertions(+), 22 deletions(-)

diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index 1cbd586b8fb..536ec028dbd 100644
--- a/gcc/objc/objc-act.c
+++ b/gcc/objc/objc-act.c
@@ -3376,8 +3376,10 @@ objc_build_string_object (tree string)
   return addr;
 }
 
-/* Build a static constant CONSTRUCTOR
-   with type TYPE and elements ELTS.  */
+/* Build a static constant CONSTRUCTOR with type TYPE and elements ELTS.
+   We might be presented with a NULL for ELTS, which means 'empty ctor'
+   which will subsequently be converted into a zero initializer in the
+   middle end.  */
 
 tree
 objc_build_constructor (tree type, vec *elts)
@@ -3389,12 +3391,10 @@ objc_build_constructor (tree type, vec *elts)
   TREE_READONLY (constructor) = 1;
 
 #ifdef OBJCPLUS
-  /* Adjust for impedance mismatch.  We should figure out how to build
- CONSTRUCTORs that consistently please both the C and C++ gods.  */
-  if (!(*elts)[0].index)
+  /* If we know the initializer, then set the type to what C++ expects.  */
+  if (elts && !(*elts)[0].index)
 TREE_TYPE (constructor) = init_list_type_node;
 #endif
-
   return constructor;
 }
 
@@ -9663,7 +9663,9 @@ objc_gimplify_property_ref (tree *expr_p)
   call_exp = TREE_OPERAND (getter, 1);
 }
 #endif
-  gcc_assert (TREE_CODE (call_exp) == CALL_EXPR);
+  gcc_checking_assert ((flag_objc_nilcheck
+   && TREE_CODE (call_exp) == COND_EXPR)
+  || TREE_CODE (call_exp) == CALL_EXPR);
 
   *expr_p = call_exp;
 }
diff --git a/gcc/objc/objc-next-runtime-abi-02.c 
b/gcc/objc/objc-next-runtime-abi-02.c
index f1c858b2cd7..e99c048e3a1 100644
--- a/gcc/objc/objc-next-runtime-abi-02.c
+++ b/gcc/objc/objc-next-runtime-abi-02.c
@@ -1676,13 +1676,8 @@ build_v2_objc_method_fixup_call (int super_flag, tree 
method_prototype,
 
   if (TREE_CODE (ret_type) == RECORD_TYPE
  || TREE_CODE (ret_type) == UNION_TYPE)
-   {
- vec *rtt = NULL;
- /* ??? CHECKME. hmmm. think we need something more
-here.  */
- CONSTRUCTOR_APPEND_ELT (rtt, NULL_TREE, NULL_TREE);
- ftree = objc_build_constructor (ret_type, rtt);
-   }
+   /* An empty constructor is zero-filled by the middle end.  */
+   ftree = objc_build_constructor (ret_type, NULL);
   else
ftree = fold_convert (ret_type, integer_zero_node);
 
@@ -1695,11 +1690,11 @@ build_v2_objc_method_fixup_call (int super_flag, tree 
method_prototype,
ifexp, ret_val, ftree,
tf_warning_or_error);
 #else
- /* ??? CHECKME.   */
   ret_val = build_conditional_expr (input_location,
-   ifexp, 1,
+   ifexp, 0,
ret_val, NULL_TREE, input_location,
ftree, NULL_TREE, input_location);
+  ret_val = fold_convert (ret_type, ret_val);
 #endif
 }
   return ret_val;
@@ -1792,11 +1787,8 @@ build_v2_build_objc_method_call (int super, tree 
method_prototype,
   if (TREE_CODE (ret_type) == RECORD_T

[gcc r14-10093] Remove repeated information in -ftree-loop-distribute-patterns doc

2024-04-23 Thread Jan Hubicka via Gcc-cvs
https://gcc.gnu.org/g:6f0a646dd2fc59e9c9cde63718b36085f84a19ba

commit r14-10093-g6f0a646dd2fc59e9c9cde63718b36085f84a19ba
Author: Jan Hubicka 
Date:   Tue Apr 23 15:51:42 2024 +0200

Remove repeated information in -ftree-loop-distribute-patterns doc

We have:

   -ftree-loop-distribute-patterns
   Perform loop distribution of patterns that can be code generated 
with calls to a library.  This flag is enabled by default at -O2 and higher, 
and by -fprofile-use and -fauto-profile.

   This pass distributes the initialization loops and generates a 
call to memset zero.  For example, the loop

...

   and the initialization loop is transformed into a call to memset 
zero.  This flag is enabled by default at -O3.  It is also enabled by 
-fprofile-use and -fauto-profile.

Which mentions optimizatoin flags twice and the repeated mention is out of
date, since we enable this option at -O2 as well.

gcc/ChangeLog:

* doc/invoke.texi (-ftree-loop-distribute-patterns): Remove 
duplicated
sentence about optimization flags implying this.

Diff:
---
 gcc/doc/invoke.texi | 2 --
 1 file changed, 2 deletions(-)

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 2a35dc7ac75..27c31ab0c86 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -13852,8 +13852,6 @@ DO I = 1, N
 ENDDO
 @end smallexample
 and the initialization loop is transformed into a call to memset zero.
-This flag is enabled by default at @option{-O3}.
-It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
 
 @opindex floop-interchange
 @item -floop-interchange


[gcc r14-10092] Further spelling fixes in translatable strings

2024-04-23 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:f99409459270831685f043987f8d09b9510ccabe

commit r14-10092-gf99409459270831685f043987f8d09b9510ccabe
Author: Jakub Jelinek 
Date:   Tue Apr 23 14:51:26 2024 +0200

Further spelling fixes in translatable strings

This addresses the non-Oxford British English vs. US English spelling
nits in translatable strings.

I see various similar cases in m2 and rust FEs where they don't make it into
gcc.pot, guess those would be nice to get fixed too.

2024-04-23  Jakub Jelinek  

* config/darwin.opt (init): Spelling fix: initialiser -> 
initializer.
gcc/c-family/
* c-attribs.cc (handle_objc_nullability_attribute): Spelling fix:
recognised -> recognized.
gcc/m2/
* lang.opt (fdef=, fmod=): Spelling fix: recognise -> recognize.

Diff:
---
 gcc/c-family/c-attribs.cc | 2 +-
 gcc/config/darwin.opt | 2 +-
 gcc/m2/lang.opt   | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gcc/c-family/c-attribs.cc b/gcc/c-family/c-attribs.cc
index 40a0cf90295..04e39b41bdf 100644
--- a/gcc/c-family/c-attribs.cc
+++ b/gcc/c-family/c-attribs.cc
@@ -6244,7 +6244,7 @@ handle_objc_nullability_attribute (tree *node, tree name, 
tree args,
  || strcmp (TREE_STRING_POINTER (val), "resettable") == 0))
 *no_add_attrs = false; /* OK */
   else if (val != error_mark_node)
-error ("%qE attribute argument %qE is not recognised", name, val);
+error ("%qE attribute argument %qE is not recognized", name, val);
 
   return NULL_TREE;
 }
diff --git a/gcc/config/darwin.opt b/gcc/config/darwin.opt
index 119faf7b385..307a760629b 100644
--- a/gcc/config/darwin.opt
+++ b/gcc/config/darwin.opt
@@ -211,7 +211,7 @@ Driver RejectNegative Separate
 
 init
 Driver RejectNegative Separate
--init The symbol  will be used as the first 
initialiser for a dylib.
+-init The symbol  will be used as the first 
initializer for a dylib.
 
 install_name
 Driver RejectNegative Separate
diff --git a/gcc/m2/lang.opt b/gcc/m2/lang.opt
index 3ffaf151f4c..1c165317959 100644
--- a/gcc/m2/lang.opt
+++ b/gcc/m2/lang.opt
@@ -96,7 +96,7 @@ turn on tracing of procedure line numbers (internal switch)
 
 fdef=
 Modula-2 Joined
-recognise the specified suffix as a definition module filename
+recognize the specified suffix as a definition module filename
 
 fdump-system-exports
 Modula-2
@@ -172,7 +172,7 @@ compile all implementation modules and program module at 
once
 
 fmod=
 Modula-2 Joined
-recognise the specified suffix as implementation and module filenames
+recognize the specified suffix as implementation and module filenames
 
 fnil
 Modula-2
@@ -278,7 +278,7 @@ static-libgm2
 Driver
 Link the standard Modula-2 libraries statically in the compilation.
 
-; Here are C options that we also recognise, either within the compiler
+; Here are C options that we also recognize, either within the compiler
 ; or to build the preprocessor command lines.
 
 Wall


[gcc r14-10091] Spelling fixes for translatable strings

2024-04-23 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:4338ac149e270e7fc8a607779ce7f21cb8c640d6

commit r14-10091-g4338ac149e270e7fc8a607779ce7f21cb8c640d6
Author: Jakub Jelinek 
Date:   Tue Apr 23 14:50:27 2024 +0200

Spelling fixes for translatable strings

I've run aspell on gcc.pot (just quickly skimming, so pressing
I key hundreds of times and just stopping when I catch something that
looks like a misspelling).

I plan to commit this tomorrow as obvious unless somebody finds some
issues in it, you know, I'm not a native English speaker.
Yes, I know favour is valid UK spelling, but we spell the US way I think.
I've left some *ise* -> *ize* cases (recognise, initialise), those
had too many hits, though in translatable strings just 4, so maybe
worth changing too:
msgid "recognise the specified suffix as a definition module filename"
msgid "recognise the specified suffix as implementation and module 
filenames"
"initialiser for a dylib."
msgid "%qE attribute argument %qE is not recognised"

2024-04-23  Jakub Jelinek  

* config/epiphany/epiphany.opt (may-round-for-trunc): Spelling fix:
floatig -> floating.
* config/riscv/riscv.opt (mcsr-check): Spelling fix: CRS -> CSR.
* params.opt (-param=ipa-cp-profile-count-base=): Spelling fix:
frequncy -> frequency.
gcc/c-family/
* c.opt (Wstrict-flex-arrays): Spelling fix: inproper -> improper.
gcc/cp/
* parser.cc (cp_parser_using_declaration): Spelling fix: favour
-> favor.
gcc/m2/
* lang.opt (fuse-list=): Spelling fix: finalializations ->
finalizations.

Diff:
---
 gcc/c-family/c.opt   | 2 +-
 gcc/config/epiphany/epiphany.opt | 2 +-
 gcc/config/riscv/riscv.opt   | 2 +-
 gcc/cp/parser.cc | 2 +-
 gcc/m2/lang.opt  | 2 +-
 gcc/params.opt   | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 848c2fda203..403abc1f26e 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -1320,7 +1320,7 @@ C ObjC C++ ObjC++ LangEnabledBy(C ObjC C++ ObjC++,Wall, 
3, 0) IntegerRange(0, 3)
 
 Wstrict-flex-arrays
 C C++ Var(warn_strict_flex_arrays) Warning
-Warn about inproper usages of flexible array members
+Warn about improper usages of flexible array members
 according to the level of -fstrict-flex-arrays.
 
 Wstrict-null-sentinel
diff --git a/gcc/config/epiphany/epiphany.opt b/gcc/config/epiphany/epiphany.opt
index 563e7ef2233..6cffea81250 100644
--- a/gcc/config/epiphany/epiphany.opt
+++ b/gcc/config/epiphany/epiphany.opt
@@ -105,7 +105,7 @@ Enum(attr_fp_mode) String(int) Value(FP_MODE_INT)
 
 may-round-for-trunc
 Target Mask(MAY_ROUND_FOR_TRUNC)
-A floatig point to integer truncation may be replaced with rounding to save 
mode switching.
+A floating point to integer truncation may be replaced with rounding to save 
mode switching.
 
 mvect-double
 Target Mask(VECT_DOUBLE)
diff --git a/gcc/config/riscv/riscv.opt b/gcc/config/riscv/riscv.opt
index 8da0764eb4b..b14888e9816 100644
--- a/gcc/config/riscv/riscv.opt
+++ b/gcc/config/riscv/riscv.opt
@@ -152,7 +152,7 @@ required to materialize symbol addresses.
 
 mcsr-check
 Target Var(riscv_mcsr_check) Init(0)
-Enable the CSR checking for the ISA-dependent CRS and the read-only CSR.
+Enable the CSR checking for the ISA-dependent CSR and the read-only CSR.
 The ISA-dependent CSR are only valid when the specific ISA is set.  The
 read-only CSR can not be written by the CSR instructions.
 
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 50d3ad35b61..c23758cf5cf 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -22406,7 +22406,7 @@ cp_parser_using_declaration (cp_parser* parser,
   if (access_declaration_p && errorcount == oldcount)
 warning_at (diag_token->location, OPT_Wdeprecated,
"access declarations are deprecated "
-   "in favour of using-declarations; "
+   "in favor of using-declarations; "
"suggestion: add the % keyword");
 
   return true;
diff --git a/gcc/m2/lang.opt b/gcc/m2/lang.opt
index 206bd03d09f..3ffaf151f4c 100644
--- a/gcc/m2/lang.opt
+++ b/gcc/m2/lang.opt
@@ -260,7 +260,7 @@ optimize non var unbounded parameters by passing it by 
reference, providing it i
 
 fuse-list=
 Modula-2 Joined
-orders the initialization/finalializations for scaffold-static or force 
linking of modules if scaffold-dynamic
+orders the initialization/finalizations for scaffold-static or force linking 
of modules if scaffold-dynamic
 
 fversion
 Modula-2
diff --git a/gcc/params.opt b/gcc/params.opt
index 5eb045b2e6c..d34ef545bf0 100644
--- a/gcc/params.opt
+++ b/gcc/params.opt
@@ -263,7 +263,7 @@ Maximum size of a list of values associated with each 
parameter for interprocedu
 
 -param=ipa-cp-profile-count-base=
 Common Joined UInteger Var(param_ipa_cp_profile_count_base) Ini

[gcc r14-10090] s390: testsuite: Xfail forwprop-4{0,1}.c

2024-04-23 Thread Stefan Schulze Frielinghaus via Gcc-cvs
https://gcc.gnu.org/g:3d5699930fe6cfc595e5a920ab36a1bc065be534

commit r14-10090-g3d5699930fe6cfc595e5a920ab36a1bc065be534
Author: Stefan Schulze Frielinghaus 
Date:   Tue Apr 23 13:29:10 2024 +0200

s390: testsuite: Xfail forwprop-4{0,1}.c

The tests fail on s390 since can_vec_perm_const_p fails and therefore
the bit insert/ref survive which r14-3381-g27de9aa152141e aims for.
Strictly speaking, the tests only fail in case the target supports
vectors, i.e., for targets prior z13 or in case of -mesa the emulated
vector operations are optimized out.

Set to xfail and tracked by PR114802.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/forwprop-40.c: Xfail for s390.
* gcc.dg/tree-ssa/forwprop-41.c: Xfail for s390.
* lib/target-supports.exp: Add target check s390_mvx.

Diff:
---
 gcc/testsuite/gcc.dg/tree-ssa/forwprop-40.c |  4 ++--
 gcc/testsuite/gcc.dg/tree-ssa/forwprop-41.c |  4 ++--
 gcc/testsuite/lib/target-supports.exp   | 14 ++
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/forwprop-40.c 
b/gcc/testsuite/gcc.dg/tree-ssa/forwprop-40.c
index 7513497f552..0c5233a68f4 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/forwprop-40.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/forwprop-40.c
@@ -10,5 +10,5 @@ vector int g(vector int a)
   return a;
 }
 
-/* { dg-final { scan-tree-dump-times "BIT_INSERT_EXPR" 0 "optimized" } } */
-/* { dg-final { scan-tree-dump-times "BIT_FIELD_REF" 0 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "BIT_INSERT_EXPR" 0 "optimized" { xfail 
s390_mvx } } } Xfail: PR114802 */
+/* { dg-final { scan-tree-dump-times "BIT_FIELD_REF" 0 "optimized" { xfail 
s390_mvx } } } Xfail: PR114802 */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/forwprop-41.c 
b/gcc/testsuite/gcc.dg/tree-ssa/forwprop-41.c
index b1e75797a90..a1f08289dd6 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/forwprop-41.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/forwprop-41.c
@@ -11,6 +11,6 @@ vector int g(vector int a, int c)
   return a;
 }
 
-/* { dg-final { scan-tree-dump-times "BIT_INSERT_EXPR" 1 "optimized" } } */
-/* { dg-final { scan-tree-dump-times "BIT_FIELD_REF" 0 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "BIT_INSERT_EXPR" 1 "optimized" { xfail 
s390_mvx } } } Xfail PR114802 */
+/* { dg-final { scan-tree-dump-times "BIT_FIELD_REF" 0 "optimized" { xfail 
s390_mvx } } } Xfail PR114802 */
 /* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR" 0 "optimized" } } */
diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index 3a5713d9869..3a55b2a4159 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -12392,6 +12392,20 @@ proc check_effective_target_profile_update_atomic {} {
 } "-fprofile-update=atomic -fprofile-generate"]
 }
 
+# Return 1 if the target has a vector facility.
+proc check_effective_target_s390_mvx { } {
+if ![istarget s390*-*-*] then {
+   return 0;
+}
+
+return [check_no_compiler_messages_nocache s390_mvx assembly {
+   #if !defined __VX__
+   #error no vector facility.
+   #endif
+   int dummy;
+} [current_compiler_flags]]
+}
+
 # Return 1 if vector (va - vector add) instructions are understood by
 # the assembler and can be executed.  This also covers checking for
 # the VX kernel feature.  A kernel without that feature does not


[gcc r14-10089] Fortran: Check that the ICE does not reappear [PR102597]

2024-04-23 Thread Paul Thomas via Gcc-cvs
https://gcc.gnu.org/g:ca00bf02dcc37f9ff1028ca1d90e8b8d95d69683

commit r14-10089-gca00bf02dcc37f9ff1028ca1d90e8b8d95d69683
Author: Paul Thomas 
Date:   Tue Apr 23 10:22:48 2024 +0100

Fortran: Check that the ICE does not reappear [PR102597]

2024-04-23  Paul Thomas  

gcc/testsuite/
PR fortran/102597
* gfortran.dg/pr102597.f90: New test.

Diff:
---
 gcc/testsuite/gfortran.dg/pr102597.f90 | 9 +
 1 file changed, 9 insertions(+)

diff --git a/gcc/testsuite/gfortran.dg/pr102597.f90 
b/gcc/testsuite/gfortran.dg/pr102597.f90
new file mode 100644
index 000..c2d875f897a
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr102597.f90
@@ -0,0 +1,9 @@
+! { dg-do compile }
+! Check that PR102597 does not resurface. Regression caused ICE at associate
+! statement.
+! Contributed by Gerhard Steinmetz  
+program p
+   use iso_fortran_env
+   associate (y => (compiler_version)) ! { dg-error "is a procedure name" }
+   end associate
+end


[gcc r14-10088] tree-optimization/114799 - SLP and patterns

2024-04-23 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:18e8e55487238237f37f621668fdee316624981a

commit r14-10088-g18e8e55487238237f37f621668fdee316624981a
Author: Richard Biener 
Date:   Tue Apr 23 08:39:03 2024 +0200

tree-optimization/114799 - SLP and patterns

The following plugs a hole with computing whether a SLP node has any
pattern stmts which is important to know when we want to replace it
by a CTOR from external defs.

PR tree-optimization/114799
* tree-vect-slp.cc (vect_get_and_check_slp_defs): Properly
update ->any_pattern when swapping operands.

* gcc.dg/vect/bb-slp-pr114799.c: New testcase.

Diff:
---
 gcc/testsuite/gcc.dg/vect/bb-slp-pr114799.c | 16 
 gcc/tree-vect-slp.cc|  6 ++
 2 files changed, 22 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr114799.c 
b/gcc/testsuite/gcc.dg/vect/bb-slp-pr114799.c
new file mode 100644
index 000..70572fe703b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr114799.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-fno-tree-forwprop" } */
+
+unsigned long x;
+unsigned char y;
+
+void
+foo (void)
+{
+  unsigned long tt = y;
+  tt+=255;
+  unsigned short t1 = tt;
+  t1 = 254 - t1;
+  tt += ((unsigned long)t1);
+  x = tt;
+}
diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 30589e19a17..133606fa6f3 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -888,6 +888,12 @@ vect_get_and_check_slp_defs (vec_info *vinfo, unsigned 
char swap,
 (*oprnds_info)[i+1]->def_stmts[stmt_num]);
  std::swap ((*oprnds_info)[i]->ops[stmt_num],
 (*oprnds_info)[i+1]->ops[stmt_num]);
+ /* After swapping some operands we lost track whether an
+operand has any pattern defs so be conservative here.  */
+ if ((*oprnds_info)[i]->any_pattern
+ || (*oprnds_info)[i+1]->any_pattern)
+   (*oprnds_info)[i]->any_pattern
+ = (*oprnds_info)[i+1]->any_pattern = true;
  swapped = true;
  continue;
}


[gcc r14-10087] s390x: Fix vec_xl/vec_xst type aliasing [PR114676]

2024-04-23 Thread Andreas Krebbel via Gcc-cvs
https://gcc.gnu.org/g:42189f21b22c43ac8ab46edf5f6a7b4d99bc86a5

commit r14-10087-g42189f21b22c43ac8ab46edf5f6a7b4d99bc86a5
Author: Andreas Krebbel 
Date:   Tue Apr 23 10:05:46 2024 +0200

s390x: Fix vec_xl/vec_xst type aliasing [PR114676]

The requirements of the vec_xl/vec_xst intrinsincs wrt aliasing of the
pointer argument are not really documented.  As it turns out, users
are likely to get it wrong.  With this patch we let the pointer
argument alias everything in order to make it more robust for users.

gcc/ChangeLog:

PR target/114676
* config/s390/s390-c.cc (s390_expand_overloaded_builtin): Use a
MEM_REF with an addend of type ptr_type_node.

gcc/testsuite/ChangeLog:

PR target/114676
* gcc.target/s390/zvector/pr114676.c: New test.

Suggested-by: Jakub Jelinek 

Diff:
---
 gcc/config/s390/s390-c.cc| 16 +---
 gcc/testsuite/gcc.target/s390/zvector/pr114676.c | 19 +++
 2 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/gcc/config/s390/s390-c.cc b/gcc/config/s390/s390-c.cc
index 8d3d1a467a8..1bb6e810766 100644
--- a/gcc/config/s390/s390-c.cc
+++ b/gcc/config/s390/s390-c.cc
@@ -498,11 +498,11 @@ s390_expand_overloaded_builtin (location_t loc,
/* Build a vector type with the alignment of the source
   location in order to enable correct alignment hints to be
   generated for vl.  */
-   tree mem_type = build_aligned_type (return_type,
-   TYPE_ALIGN (TREE_TYPE (TREE_TYPE 
((*arglist)[1];
+   unsigned align = TYPE_ALIGN (TREE_TYPE (TREE_TYPE ((*arglist)[1])));
+   tree mem_type = build_aligned_type (return_type, align);
return build2 (MEM_REF, mem_type,
   fold_build_pointer_plus ((*arglist)[1], (*arglist)[0]),
-  build_int_cst (TREE_TYPE ((*arglist)[1]), 0));
+  build_int_cst (ptr_type_node, 0));
   }
 case S390_OVERLOADED_BUILTIN_s390_vec_xst:
 case S390_OVERLOADED_BUILTIN_s390_vec_xstd2:
@@ -511,11 +511,13 @@ s390_expand_overloaded_builtin (location_t loc,
/* Build a vector type with the alignment of the target
   location in order to enable correct alignment hints to be
   generated for vst.  */
-   tree mem_type = build_aligned_type (TREE_TYPE((*arglist)[0]),
-   TYPE_ALIGN (TREE_TYPE (TREE_TYPE 
((*arglist)[2];
+   unsigned align = TYPE_ALIGN (TREE_TYPE (TREE_TYPE ((*arglist)[2])));
+   tree mem_type = build_aligned_type (TREE_TYPE ((*arglist)[0]), align);
return build2 (MODIFY_EXPR, mem_type,
-  build1 (INDIRECT_REF, mem_type,
-  fold_build_pointer_plus ((*arglist)[2], 
(*arglist)[1])),
+  build2 (MEM_REF, mem_type,
+  fold_build_pointer_plus ((*arglist)[2],
+   (*arglist)[1]),
+  build_int_cst (ptr_type_node, 0)),
   (*arglist)[0]);
   }
 case S390_OVERLOADED_BUILTIN_s390_vec_load_pair:
diff --git a/gcc/testsuite/gcc.target/s390/zvector/pr114676.c 
b/gcc/testsuite/gcc.target/s390/zvector/pr114676.c
new file mode 100644
index 000..bdc66b2920a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/zvector/pr114676.c
@@ -0,0 +1,19 @@
+/* { dg-do run { target { s390*-*-* } } } */
+/* { dg-options "-O3 -mzarch -march=z14 -mzvector" } */
+
+#include 
+
+void __attribute__((noinline)) foo (int *mem)
+{
+  vec_xst ((vector float){ 1.0f, 2.0f, 3.0f, 4.0f }, 0, (float*)mem);
+}
+
+int
+main ()
+{
+  int m[4] = { 0 };
+  foo (m);
+  if (m[3] == 0)
+__builtin_abort ();
+  return 0;
+}