[gcc r14-9781] tree-optimization/114551 - loop splitting and undefined overflow

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

commit r14-9781-ge152177b362143465e2b9d721ea632cae3f13445
Author: Richard Biener 
Date:   Wed Apr 3 14:53:30 2024 +0200

tree-optimization/114551 - loop splitting and undefined overflow

When loop splitting hoists a guard computation it needs to make sure
that can be safely evaluated at this place when it was previously
only conditionally evaluated.  The following fixes this for the
case of undefined overflow.

PR tree-optimization/114551
* tree-ssa-loop-split.cc (split_loop): If the guard is
only conditionally evaluated rewrite computations with
possibly undefined overflow to unsigned arithmetic.

* gcc.dg/torture/pr114551.c: New testcase.

Diff:
---
 gcc/testsuite/gcc.dg/torture/pr114551.c | 18 ++
 gcc/tree-ssa-loop-split.cc  | 22 --
 2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/torture/pr114551.c 
b/gcc/testsuite/gcc.dg/torture/pr114551.c
new file mode 100644
index 000..13c15fbc3d9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr114551.c
@@ -0,0 +1,18 @@
+/* { dg-do run } */
+
+int a, b[4], c, d, e, f;
+int main()
+{
+  a--;
+  for (f = 3; f >= 0; f--)
+{
+  for (e = 0; e < 4; e++)
+   c = 0;
+  for (; c < 4; c++)
+   {
+ d = f && a > 0 && f > (2147483647 - a) ? 0 : b[f];
+ continue;
+   }
+}
+  return 0;
+}
diff --git a/gcc/tree-ssa-loop-split.cc b/gcc/tree-ssa-loop-split.cc
index c0bb1b71d17..a770ea371a2 100644
--- a/gcc/tree-ssa-loop-split.cc
+++ b/gcc/tree-ssa-loop-split.cc
@@ -653,8 +653,26 @@ split_loop (class loop *loop1)
gimple_seq stmts2;
border = force_gimple_operand (border, &stmts2, true, NULL_TREE);
if (stmts2)
- gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop1),
-   stmts2);
+ {
+   /* When the split condition is not always evaluated make sure
+  to rewrite it to defined overflow.  */
+   if (!dominated_by_p (CDI_DOMINATORS, exit1->src, bbs[i]))
+ {
+   gimple_stmt_iterator gsi;
+   gsi = gsi_start (stmts2);
+   while (!gsi_end_p (gsi))
+ {
+   gimple *stmt = gsi_stmt (gsi);
+   if (is_gimple_assign (stmt)
+   && arith_code_with_undefined_signed_overflow
+   (gimple_assign_rhs_code (stmt)))
+ rewrite_to_defined_overflow (&gsi);
+   gsi_next (&gsi);
+ }
+ }
+   gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop1),
+ stmts2);
+ }
tree cond = fold_build2 (guard_code, boolean_type_node,
 guard_init, border);
if (!initial_true)


[gcc r14-9782] [MAINTAINERS] Update my email address and step down as arm port maintainer

2024-04-04 Thread Kyrylo Tkachov via Gcc-cvs
https://gcc.gnu.org/g:f2ccfb2d0b2698e6b140e4d09e53b701a3193384

commit r14-9782-gf2ccfb2d0b2698e6b140e4d09e53b701a3193384
Author: Kyrylo Tkachov 
Date:   Thu Apr 4 09:12:28 2024 +0100

[MAINTAINERS] Update my email address and step down as arm port maintainer

* MAINTAINERS: Update my email details, remove myself as arm
maintainer.  Add myself to DCO section.

Diff:
---
 MAINTAINERS | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 8f64ee630b4..9a6c41afb12 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -52,7 +52,7 @@ docs, and the testsuite related to that.
 aarch64 port   Richard Earnshaw
 aarch64 port   Richard Sandiford   
 aarch64 port   Marcus Shawcroft
-aarch64 port   Kyrylo Tkachov  
+aarch64 port   Kyrylo Tkachov  
 alpha port Richard Henderson   
 amdgcn portJulian Brown
 amdgcn portAndrew Stubbs   
@@ -61,7 +61,6 @@ arc port  Claudiu Zissulescu  

 arm port   Nick Clifton
 arm port   Richard Earnshaw
 arm port   Ramana Radhakrishnan
-arm port   Kyrylo Tkachov  
 avr port   Denis Chertykov 
 bfin port  Jie Zhang   
 bpf port   Jose E. Marchesi
@@ -782,6 +781,7 @@ Nathaniel Shead 

 Nathan Sidwell 
 Edward Smith-Rowland   
 Fangrui Song   
+Kyrylo Tkachov 
 Petter Tomner  
 Martin Uecker  
 Jonathan Wakely


[gcc r14-9783] bitint: Handle m_bitfld_load cast in outer m_cast_conditional [PR114555]

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

commit r14-9783-g48530efdcccb154d3ed200246384edc162debc5d
Author: Jakub Jelinek 
Date:   Thu Apr 4 10:47:00 2024 +0200

bitint: Handle m_bitfld_load cast in outer m_cast_conditional [PR114555]

We ICE on the following testcase, because we use result of a PHI node
which is only conditional because of a m_cast_conditional on the outermost
loops PHI node argument and so is invalid SSA form.

The following patch fixes it like similar cases elsewhere by adding
needed intervening PHI(s).

2024-04-04  Jakub Jelinek  

PR tree-optimization/114555
* gimple-lower-bitint.cc (bitint_large_huge::handle_cast): For
m_bitfld_load and save_cast_conditional add any needed PHIs
and adjust t4 accordingly.

* gcc.dg/bitint-103.c: New test.
* gcc.dg/bitint-104.c: New test.

Diff:
---
 gcc/gimple-lower-bitint.cc| 20 +++-
 gcc/testsuite/gcc.dg/bitint-103.c | 16 
 gcc/testsuite/gcc.dg/bitint-104.c | 17 +
 3 files changed, 52 insertions(+), 1 deletion(-)

diff --git a/gcc/gimple-lower-bitint.cc b/gcc/gimple-lower-bitint.cc
index 40a1084afb3..1afd4de445a 100644
--- a/gcc/gimple-lower-bitint.cc
+++ b/gcc/gimple-lower-bitint.cc
@@ -1506,7 +1506,7 @@ bitint_large_huge::handle_cast (tree lhs_type, tree rhs1, 
tree idx)
  if (m_bitfld_load)
{
  tree t4;
- if (!save_first)
+ if (!save_first && !save_cast_conditional)
t4 = m_data[m_bitfld_load + 1];
  else
t4 = make_ssa_name (m_limb_type);
@@ -1519,6 +1519,24 @@ bitint_large_huge::handle_cast (tree lhs_type, tree 
rhs1, tree idx)
  if (edge_true_true)
add_phi_arg (phi, m_data[m_bitfld_load], edge_true_true,
 UNKNOWN_LOCATION);
+ if (save_cast_conditional)
+   for (basic_block bb = gsi_bb (m_gsi);;)
+ {
+   edge e1 = single_succ_edge (bb);
+   edge e2 = find_edge (e1->dest, m_bb), e3;
+   tree t5 = ((e2 && !save_first) ? m_data[m_bitfld_load + 1]
+  : make_ssa_name (m_limb_type));
+   phi = create_phi_node (t5, e1->dest);
+   edge_iterator ei;
+   FOR_EACH_EDGE (e3, ei, e1->dest->preds)
+ add_phi_arg (phi, (e3 == e1 ? t4
+: build_zero_cst (m_limb_type)),
+  e3, UNKNOWN_LOCATION);
+   t4 = t5;
+   if (e2)
+ break;
+   bb = e1->dest;
+ }
  m_data[m_bitfld_load] = t4;
  m_data[m_bitfld_load + 2] = t4;
  m_bitfld_load = 0;
diff --git a/gcc/testsuite/gcc.dg/bitint-103.c 
b/gcc/testsuite/gcc.dg/bitint-103.c
new file mode 100644
index 000..4d8104959a1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/bitint-103.c
@@ -0,0 +1,16 @@
+/* PR tree-optimization/114555 */
+/* { dg-do compile { target bitint } } */
+/* { dg-options "-std=c23 -O2" } */
+
+#if __BITINT_MAXWIDTH__ >= 1225
+struct S { _BitInt(512) : 98; _BitInt(1225) b : 509; } s;
+_BitInt(1225) a;
+#endif
+
+void
+foo (void)
+{
+#if __BITINT_MAXWIDTH__ >= 1225
+  a ^= (unsigned _BitInt(1025)) s.b;
+#endif
+}
diff --git a/gcc/testsuite/gcc.dg/bitint-104.c 
b/gcc/testsuite/gcc.dg/bitint-104.c
new file mode 100644
index 000..b4aac83137b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/bitint-104.c
@@ -0,0 +1,17 @@
+/* PR tree-optimization/114555 */
+/* { dg-do compile { target bitint } } */
+/* { dg-options "-std=c23 -O -fno-tree-forwprop" } */
+
+#if __BITINT_MAXWIDTH__ >= 4139
+struct S { _BitInt(31) : 6; _BitInt(513) b : 241; } s;
+_BitInt(4139) a;
+#endif
+
+void
+foo (void)
+{
+#if __BITINT_MAXWIDTH__ >= 4139
+  int i = 0;
+  a -= s.b << i;
+#endif
+}


[gcc r14-9784] fold-const: Handle NON_LVALUE_EXPR in native_encode_initializer [PR114537]

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

commit r14-9784-g1baec8deb014b8a7da58879a407a4c00cdeb5a09
Author: Jakub Jelinek 
Date:   Thu Apr 4 10:47:52 2024 +0200

fold-const: Handle NON_LVALUE_EXPR in native_encode_initializer [PR114537]

The following testcase is incorrectly rejected.  The problem is that
for bit-fields native_encode_initializer expects the corresponding
CONSTRUCTOR elt value must be INTEGER_CST, but that isn't the case
here, it is wrapped into NON_LVALUE_EXPR by maybe_wrap_with_location.
We could STRIP_ANY_LOCATION_WRAPPER as well, but as all we are looking for
is INTEGER_CST inside, just looking through NON_LVALUE_EXPR seems easier.

2024-04-04  Jakub Jelinek  

PR c++/114537
* fold-const.cc (native_encode_initializer): Look through
NON_LVALUE_EXPR if val is INTEGER_CST.

* g++.dg/cpp2a/bit-cast16.C: New test.

Diff:
---
 gcc/fold-const.cc   |  2 ++
 gcc/testsuite/g++.dg/cpp2a/bit-cast16.C | 16 
 2 files changed, 18 insertions(+)

diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc
index 8960e5289c0..7b268964acc 100644
--- a/gcc/fold-const.cc
+++ b/gcc/fold-const.cc
@@ -8601,6 +8601,8 @@ native_encode_initializer (tree init, unsigned char *ptr, 
int len,
  if (BYTES_BIG_ENDIAN != WORDS_BIG_ENDIAN)
return 0;
 
+ if (TREE_CODE (val) == NON_LVALUE_EXPR)
+   val = TREE_OPERAND (val, 0);
  if (TREE_CODE (val) != INTEGER_CST)
return 0;
 
diff --git a/gcc/testsuite/g++.dg/cpp2a/bit-cast16.C 
b/gcc/testsuite/g++.dg/cpp2a/bit-cast16.C
new file mode 100644
index 000..d298af67ef2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/bit-cast16.C
@@ -0,0 +1,16 @@
+// PR c++/114537
+// { dg-do compile { target c++20 } }
+
+namespace std {
+template
+constexpr T
+bit_cast (const F& f) noexcept
+{
+  return __builtin_bit_cast (T, f);
+}
+}
+
+struct A { signed char b : 1 = 0; signed char c : 7 = 0; };
+struct D { unsigned char e; };
+constexpr unsigned char f = std::bit_cast (A{}).e;
+static_assert (f == 0);


[gcc r14-9785] libgomp.texi: Update entries in OpenMP TR12 implementation status

2024-04-04 Thread Tobias Burnus via Gcc-cvs
https://gcc.gnu.org/g:1c89d1b9dc8c4957a4ec3674f691595641fd279b

commit r14-9785-g1c89d1b9dc8c4957a4ec3674f691595641fd279b
Author: Tobias Burnus 
Date:   Thu Apr 4 12:20:48 2024 +0200

libgomp.texi: Update entries in OpenMP TR12 implementation status

libgomp/ChangeLog:

* libgomp.texi (TR12): Honor post-TR12 directive name change; add
item about curly braces/BLOCK permitted in canonical loop nests.

Diff:
---
 libgomp/libgomp.texi | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libgomp/libgomp.texi b/libgomp/libgomp.texi
index 1ae0f01ccdc..71d62105a20 100644
--- a/libgomp/libgomp.texi
+++ b/libgomp/libgomp.texi
@@ -515,7 +515,8 @@ Technical Report (TR) 12 is the second preview for OpenMP 
6.0.
 @item @code{strict} modifier keyword to @code{num_threads} @tab N @tab
 @item @code{atomic} permitted in a construct with @code{order(concurrent)}
   @tab N @tab
-@item @code{coexecute} directive for Fortran @tab N @tab
+@item @code{workdistribute} directive for Fortran @tab N
+  @tab Renamed just after TR12; added in TR12 as @code{coexecute}
 @item Fortran DO CONCURRENT as associated loop in a @code{loop} construct
   @tab N @tab
 @item @code{threadset} clause in task-generating constructs @tab N @tab
@@ -539,6 +540,8 @@ Technical Report (TR) 12 is the second preview for OpenMP 
6.0.
 
 @unnumberedsubsec Other new TR 12 features
 @multitable @columnfractions .60 .10 .25
+@item Canonical loop nest enclosed in (multiple) curly braces (C/C++) or BLOCK 
constructs (Fortran)
+  @tab N @tab
 @item Relaxed Fortran restrictions to the @code{aligned} clause @tab N @tab
 @item Mapping lambda captures @tab N @tab
 @item New @code{omp_pause_stop_tool} constant for omp_pause_resource @tab N 
@tab


[gcc r14-9786] tree-optimization/114485 - neg induction with partial vectors

2024-04-04 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:85621f98d245004a6c9787dde21e0acc17ab2c50

commit r14-9786-g85621f98d245004a6c9787dde21e0acc17ab2c50
Author: Richard Biener 
Date:   Thu Apr 4 10:00:51 2024 +0200

tree-optimization/114485 - neg induction with partial vectors

We can't use vect_update_ivs_after_vectorizer for partial vectors,
the following fixes vect_can_peel_nonlinear_iv_p accordingly.

PR tree-optimization/114485
* tree-vect-loop-manip.cc (vect_can_peel_nonlinear_iv_p):
vect_step_op_neg isn't OK for partial vectors but only
for unknown niter.

* gcc.dg/vect/pr114485.c: New testcase.

Diff:
---
 gcc/testsuite/gcc.dg/vect/pr114485.c | 18 ++
 gcc/tree-vect-loop-manip.cc  | 14 +++---
 2 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/vect/pr114485.c 
b/gcc/testsuite/gcc.dg/vect/pr114485.c
new file mode 100644
index 000..6536806e350
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr114485.c
@@ -0,0 +1,18 @@
+#include "tree-vect.h"
+
+int b, c = 8, d;
+int e[23];
+int main()
+{
+  check_vect ();
+
+  int *h = e;
+  for (int i = 1; i < b + 21; i += 2)
+{
+  c *= -1;
+  d = h[i] ? i : 0;
+}
+  if (c != 8)
+abort ();
+  return 0;
+}
diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc
index 56a6d8e4a8d..8d9b533d50f 100644
--- a/gcc/tree-vect-loop-manip.cc
+++ b/gcc/tree-vect-loop-manip.cc
@@ -2128,18 +2128,18 @@ vect_can_peel_nonlinear_iv_p (loop_vec_info loop_vinfo,
  For shift, when shift mount >= precision, there would be UD.
  For mult, don't known how to generate
  init_expr * pow (step, niters) for variable niters.
- For neg, it should be ok, since niters of vectorized main loop
+ For neg unknown niters are ok, since niters of vectorized main loop
  will always be multiple of 2.
- See also PR113163 and PR114196.  */
-  if ((!LOOP_VINFO_VECT_FACTOR (loop_vinfo).is_constant ()
-   || LOOP_VINFO_USING_PARTIAL_VECTORS_P (loop_vinfo)
-   || !LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo))
-  && induction_type != vect_step_op_neg)
+ See also PR113163,  PR114196 and PR114485.  */
+  if (!LOOP_VINFO_VECT_FACTOR (loop_vinfo).is_constant ()
+  || LOOP_VINFO_USING_PARTIAL_VECTORS_P (loop_vinfo)
+  || (!LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo)
+ && induction_type != vect_step_op_neg))
 {
   if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
 "Peeling for epilogue is not supported"
-" for nonlinear induction except neg"
+" for this nonlinear induction"
 " when iteration count is unknown or"
 " when using partial vectorization.\n");
   return false;


[gcc r14-9787] aarch64: Recognise svundef idiom [PR114577]

2024-04-04 Thread Richard Sandiford via Gcc-cvs
https://gcc.gnu.org/g:86dce005a1d440154dbf585dde5a2dd4cfac7a05

commit r14-9787-g86dce005a1d440154dbf585dde5a2dd4cfac7a05
Author: Richard Sandiford 
Date:   Thu Apr 4 14:15:49 2024 +0100

aarch64: Recognise svundef idiom [PR114577]

GCC 14 adds the header file arm_neon_sve_bridge.h to help interface
SVE and Advanced SIMD code.  One of the defined idioms is:

  svset_neonq (svundef_TYPE (), advsimd_vector)

which simply reinterprets advsimd_vector as an SVE vector without
regard for what's in the upper bits.

GCC was failing to recognise this idiom, which was likely to
significantly hamper adoption.

There is (AFAIK) no good way of representing an extension with
undefined bits in gimple.  We could add an internal-only builtin
to represent it, but the current framework makes that somewhat
awkward.  It also doesn't seem very forward-looking.

This patch instead goes for the simpler approach of recognising
undefined arguments at expansion time.

gcc/
PR target/114577
* config/aarch64/aarch64-sve-builtins.h 
(aarch64_sve::lookup_fndecl):
Declare.
* config/aarch64/aarch64-sve-builtins.cc 
(aarch64_sve::lookup_fndecl):
New function.
* config/aarch64/aarch64-sve-builtins-base.cc (is_undef): Likewise.
(svset_neonq_impl::expand): Optimise expansions whose first argument
is undefined.

gcc/testsuite/
PR target/114577
* gcc.target/aarch64/sve/acle/general/pr114577_1.c: New test.
* gcc.target/aarch64/sve/acle/general/pr114577_2.c: Likewise.

Diff:
---
 gcc/config/aarch64/aarch64-sve-builtins-base.cc| 27 +++
 gcc/config/aarch64/aarch64-sve-builtins.cc | 16 
 gcc/config/aarch64/aarch64-sve-builtins.h  |  1 +
 .../aarch64/sve/acle/general/pr114577_1.c  | 94 ++
 .../aarch64/sve/acle/general/pr114577_2.c  | 46 +++
 5 files changed, 184 insertions(+)

diff --git a/gcc/config/aarch64/aarch64-sve-builtins-base.cc 
b/gcc/config/aarch64/aarch64-sve-builtins-base.cc
index a8c3f84a70b..257ca5bf6ad 100644
--- a/gcc/config/aarch64/aarch64-sve-builtins-base.cc
+++ b/gcc/config/aarch64/aarch64-sve-builtins-base.cc
@@ -47,11 +47,31 @@
 #include "aarch64-builtins.h"
 #include "ssa.h"
 #include "gimple-fold.h"
+#include "tree-ssa.h"
 
 using namespace aarch64_sve;
 
 namespace {
 
+/* Return true if VAL is an undefined value.  */
+static bool
+is_undef (tree val)
+{
+  if (TREE_CODE (val) == SSA_NAME)
+{
+  if (ssa_undefined_value_p (val, false))
+   return true;
+
+  gimple *def = SSA_NAME_DEF_STMT (val);
+  if (gcall *call = dyn_cast (def))
+   if (tree fndecl = gimple_call_fndecl (call))
+ if (const function_instance *instance = lookup_fndecl (fndecl))
+   if (instance->base == functions::svundef)
+ return true;
+}
+  return false;
+}
+
 /* Return the UNSPEC_CMLA* unspec for rotation amount ROT.  */
 static int
 unspec_cmla (int rot)
@@ -1142,6 +1162,13 @@ public:
   expand (function_expander &e) const override
   {
 machine_mode mode = e.vector_mode (0);
+
+/* If the SVE argument is undefined, we just need to reinterpret the
+   Advanced SIMD argument as an SVE vector.  */
+if (!BYTES_BIG_ENDIAN
+   && is_undef (CALL_EXPR_ARG (e.call_expr, 0)))
+  return simplify_gen_subreg (mode, e.args[1], GET_MODE (e.args[1]), 0);
+
 rtx_vector_builder builder (VNx16BImode, 16, 2);
 for (unsigned int i = 0; i < 16; i++)
   builder.quick_push (CONST1_RTX (BImode));
diff --git a/gcc/config/aarch64/aarch64-sve-builtins.cc 
b/gcc/config/aarch64/aarch64-sve-builtins.cc
index 11f5c5c500c..e124d1f90a5 100644
--- a/gcc/config/aarch64/aarch64-sve-builtins.cc
+++ b/gcc/config/aarch64/aarch64-sve-builtins.cc
@@ -1055,6 +1055,22 @@ get_vector_type (sve_type type)
   return acle_vector_types[type.num_vectors - 1][vector_type];
 }
 
+/* If FNDECL is an SVE builtin, return its function instance, otherwise
+   return null.  */
+const function_instance *
+lookup_fndecl (tree fndecl)
+{
+  if (!fndecl_built_in_p (fndecl, BUILT_IN_MD))
+return nullptr;
+
+  unsigned int code = DECL_MD_FUNCTION_CODE (fndecl);
+  if ((code & AARCH64_BUILTIN_CLASS) != AARCH64_BUILTIN_SVE)
+return nullptr;
+
+  unsigned int subcode = code >> AARCH64_BUILTIN_SHIFT;
+  return &(*registered_functions)[subcode]->instance;
+}
+
 /* Report an error against LOCATION that the user has tried to use
function FNDECL when extension EXTENSION is disabled.  */
 static void
diff --git a/gcc/config/aarch64/aarch64-sve-builtins.h 
b/gcc/config/aarch64/aarch64-sve-builtins.h
index e66729ed635..053006776a9 100644
--- a/gcc/config/aarch64/aarch64-sve-builtins.h
+++ b/gcc/config/aarch64/aarch64-sve-builtins.h
@@ -810,6 +810,7 @@ extern tree acle_svprfop;
 
 bool vector_cst_all_same (tree, unsigned int);
 bool i

[gcc r14-9788] MAINTAINERS: Update my email address

2024-04-04 Thread Paul-Antoine Arras via Gcc-cvs
https://gcc.gnu.org/g:b7bd2ec73d66f7487bc8842b24daecaa802a72e6

commit r14-9788-gb7bd2ec73d66f7487bc8842b24daecaa802a72e6
Author: Paul-Antoine Arras 
Date:   Thu Apr 4 16:39:52 2024 +0200

MAINTAINERS: Update my email address

ChangeLog:

* MAINTAINERS: Update my email address.

Diff:
---
 MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 9a6c41afb12..27e3872ef93 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -324,7 +324,7 @@ from other maintainers or reviewers.
 Mark G. Adams  
 Ajit Kumar Agarwal 
 Pedro Alves
-Paul-Antoine Arras 
+Paul-Antoine Arras 
 Arsen Arsenović
 Raksit Ashok   
 Matt Austern   


[gcc r13-8579] RISC-V: Fix C23 (...) functions returning large aggregates [PR114175]

2024-04-04 Thread Edwin Lu via Gcc-cvs
https://gcc.gnu.org/g:c4eff4ece764d836eb7ee0c0163780d100471730

commit r13-8579-gc4eff4ece764d836eb7ee0c0163780d100471730
Author: Edwin Lu 
Date:   Mon Mar 18 11:43:41 2024 -0700

RISC-V: Fix C23 (...) functions returning large aggregates [PR114175]

We assume that TYPE_NO_NAMED_ARGS_STDARG_P don't have any named arguments 
and
there is nothing to advance, but that is not the case for (...) functions
returning by hidden reference which have one such artificial argument.
This causes gcc.dg/c23-stdarg-[68].c to fail

Fix the issue by checking if arg.type is NULL as r14-9503-g218d1749612
explains

Tested on linux rv64gcv.

gcc/ChangeLog:

PR target/114175
* config/riscv/riscv.cc (riscv_setup_incoming_varargs): Only skip
riscv_funciton_arg_advance for TYPE_NO_NAMED_ARGS_STDARG_P functions
if arg.type is NULL

(cherry picked from commit 60586710b0646efdbbd77a7f53b93fb5edb87a61)

Diff:
---
 gcc/config/riscv/riscv.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index 01eebc83cc5..cefd3b7b2b2 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -3961,7 +3961,8 @@ riscv_setup_incoming_varargs (cumulative_args_t cum,
  argument.  Advance a local copy of CUM past the last "real" named
  argument, to find out how many registers are left over.  */
   local_cum = *get_cumulative_args (cum);
-  if (!TYPE_NO_NAMED_ARGS_STDARG_P (TREE_TYPE (current_function_decl)))
+  if (!TYPE_NO_NAMED_ARGS_STDARG_P (TREE_TYPE (current_function_decl))
+  || arg.type != NULL_TREE)
 riscv_function_arg_advance (pack_cumulative_args (&local_cum), arg);
 
   /* Found out how many registers we need to save.  */


[gcc r14-9790] Add gcov MC/DC tests for GDC

2024-04-04 Thread J?rgen Kvalsvik via Gcc-cvs
https://gcc.gnu.org/g:dc8a25189dd6e10a50751793f08d6c5857bd6131

commit r14-9790-gdc8a25189dd6e10a50751793f08d6c5857bd6131
Author: Jørgen Kvalsvik 
Date:   Wed Dec 6 09:08:46 2023 +0100

Add gcov MC/DC tests for GDC

This is a mostly straight port from the gcov-19.c tests from the C test
suite. The only notable differences from C to D are that D flips the
true/false outcomes for loop headers, and the D front end ties loop and
ternary conditions to slightly different locus.

The test for >64 conditions warning is disabled as it either needs
support from the testing framework or a something similar to #pragma GCC
diagnostic push to not cause a test failure from detecting a warning.

gcc/testsuite/ChangeLog:

* gdc.dg/gcov.exp: New test.
* gdc.dg/gcov1.d: New test.

Diff:
---
 gcc/testsuite/gdc.dg/gcov.exp |   44 ++
 gcc/testsuite/gdc.dg/gcov1.d  | 1712 +
 2 files changed, 1756 insertions(+)

diff --git a/gcc/testsuite/gdc.dg/gcov.exp b/gcc/testsuite/gdc.dg/gcov.exp
new file mode 100644
index 000..4218771b208
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/gcov.exp
@@ -0,0 +1,44 @@
+#   Copyright (C) 1997-2023 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# .
+
+# Gcov test driver.
+
+# Load support procs.
+load_lib gdc-dg.exp
+load_lib gcov.exp
+
+global GDC_UNDER_TEST
+
+# For now find gcov in the same directory as $GDC_UNDER_TEST.
+if { ![is_remote host] && [string match "*/*" [lindex $GDC_UNDER_TEST 0]] } {
+set GCOV [file dirname [lindex $GDC_UNDER_TEST 
0]]/[gcc-transform-out-of-tree gcov]
+} else {
+set GCOV [gcc-transform-out-of-tree gcov]
+}
+
+# Initialize harness.
+dg-init
+
+# Delete old .gcda files.
+set files [glob -nocomplain gcov*.gcda]
+if { $files != "" } {
+eval "remote_file build delete $files"
+}
+
+# Main loop.
+gdc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/gcov*.d]] "" ""
+
+dg-finish
diff --git a/gcc/testsuite/gdc.dg/gcov1.d b/gcc/testsuite/gdc.dg/gcov1.d
new file mode 100644
index 000..10ffa4a0e30
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/gcov1.d
@@ -0,0 +1,1712 @@
+/* { dg-options "-fcondition-coverage -ftest-coverage" } */
+/* { dg-do run { target native } } */
+
+/* Some side effect to stop branches from being pruned.  */
+int x = 0;
+
+int id  (int x) { return  x; }
+int inv (int x) { return !x; }
+
+/* || works.  */
+void
+mcdc001a (int a, int b)
+{
+if (a || b) /* conditions(1/4) true(0) false(0 1) */
+   /* conditions(end) */
+   x = 1;
+else
+   x = 2;
+}
+
+void
+mcdc001b (int a, int b)
+{
+if (a || b) /* conditions(3/4) true(0) */
+   /* conditions(end) */
+   x = 1;
+else
+   x = 2;
+}
+
+void
+mcdc001c (int a, int b)
+{
+if (a || b) /* conditions(4/4) */
+   x = 1;
+else
+   x = 2;
+}
+
+void
+mcdc001d (int a, int b, int c)
+{
+if (a || b || c) /* conditions(2/6) false(0 1 2) true(2) */
+/* conditions(end) */
+   x = 1;
+}
+
+/* && works */
+void
+mcdc002a (int a, int b)
+{
+if (a && b) /* conditions(1/4) true(0 1) false(0) */
+   /* conditions(end) */
+   x = 1;
+else
+   x = 2;
+}
+
+void
+mcdc002b (int a, int b)
+{
+if (a && b) /* conditions(3/4) false(0) */
+   /* conditions(end) */
+   x = 1;
+else
+   x = 2;
+}
+
+void
+mcdc002c (int a, int b)
+{
+if (a && b) /* conditions(4/4) */
+   x = 1;
+else
+   x = 2;
+}
+
+void
+mcdc002d (int a, int b, int c)
+{
+if (a && b && c) /* conditions(4/6) false(0 2) */
+/* conditions(end) */
+   x = 1;
+}
+
+/* Negation works.  */
+void
+mcdc003a (int a, int b)
+{
+if (!a || !b) /* conditions(2/4) false(0 1) */
+ /* conditions(end) */
+   x = 1;
+else
+   x = 2;
+}
+
+/* Single conditionals with and without else.  */
+void
+mcdc004a (int a)
+{
+if (a) /* conditions(1/2) true(0) */
+  /* conditions(end) */
+   x = 1;
+else
+   x = 2;
+}
+
+void
+mcdc004b (int a)
+{
+if (a) /* conditions(2/2) */
+   x = 1;
+else
+   x = 2;
+}
+
+void
+mcdc004c (int a)
+{
+if (a) /* conditions(1/2) false(0) */
+  /* conditions(end) */
+   x = 1;
+}
+
+void
+mcdc004d (int a, int b, int c)
+{
+ 

[gcc r13-8580] testsuite, x86: Handle a broken assembler

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

commit r13-8580-g250b3be9179b4dca5a5b2f1451a424d386ac88bd
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 6617da7f26c..be8ddc8e0f8 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -9640,6 +9640,7 @@ proc check_effective_target_avx512fp16 { } {
void foo (void)
{
  asm volatile ("vmovw %edi, %xmm0");
+ asm volatile ("vfcmulcph %xmm1, %xmm2, %xmm3{%k1}");
}
 } "-O2 -mavx512fp16" ]
 }


[gcc r13-8581] Testsuite, LTO: silence warning to make test pass on Darwin

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

commit r13-8581-g0d761f903da03b3537522b02ef70127e347b797b
Author: Francois-Xavier Coudert 
Date:   Sun Aug 20 12:17:50 2023 +0200

Testsuite, LTO: silence warning to make test pass on Darwin

gcc/testsuite/ChangeLog:

* gcc.dg/lto/20091013-1_2.c: Add -Wno-stringop-overread.

(cherry picked from commit b9426543e8d3b9333d1561844472c3f568fa6913)

Diff:
---
 gcc/testsuite/gcc.dg/lto/20091013-1_2.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/lto/20091013-1_2.c 
b/gcc/testsuite/gcc.dg/lto/20091013-1_2.c
index 1af49aa97b6..89caea868e6 100644
--- a/gcc/testsuite/gcc.dg/lto/20091013-1_2.c
+++ b/gcc/testsuite/gcc.dg/lto/20091013-1_2.c
@@ -1,3 +1,5 @@
+/* { dg-options "-Wno-stringop-overread" } */
+
 typedef struct HDC__ { int unused; } *HDC;
 typedef struct HFONT__ { int unused; } *HFONT;


[gcc r13-8583] Testsuite, Darwin: skip PIE test

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

commit r13-8583-g982fc5342202e7e3f6c09fec651e18a59b9cbec9
Author: Francois-Xavier Coudert 
Date:   Mon Oct 30 12:41:17 2023 +0100

Testsuite, Darwin: skip PIE test

gcc/testsuite/ChangeLog:

* gcc.dg/pie-2.c: Skip test on darwin.

(cherry picked from commit a0c557690c8d5327deda6e21f8d1deca8451a4cb)

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

diff --git a/gcc/testsuite/gcc.dg/pie-2.c b/gcc/testsuite/gcc.dg/pie-2.c
index 1838745a11a..0a1cc27a503 100644
--- a/gcc/testsuite/gcc.dg/pie-2.c
+++ b/gcc/testsuite/gcc.dg/pie-2.c
@@ -2,6 +2,7 @@
 /* { dg-options "-fPIE" } */
 /* { dg-require-effective-target pie } */
 /* { dg-skip-if "__PIC__ is always 1 for MIPS" { mips*-*-* } } */
+/* { dg-skip-if "__PIE__ is often not defined on darwin" { *-*-darwin* } } */
 
 #if __PIC__ != 2
 # error __PIC__ is not 2!


[gcc r13-8582] Testsuite, DWARF2: adjust regexp to match darwin output

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

commit r13-8582-g672d71a7abd720684282cfd464d4c9fd1ef23a55
Author: Francois-Xavier Coudert 
Date:   Sun Aug 20 12:53:19 2023 +0200

Testsuite, DWARF2: adjust regexp to match darwin output

gcc/testsuite/ChangeLog:

* gcc.dg/debug/dwarf2/inline4.c: Ajdust regexp to match darwin
output.

(cherry picked from commit 94e68ce96c285e479736851f1ad8cc87c8c3ff0c)

Diff:
---
 gcc/testsuite/gcc.dg/debug/dwarf2/inline4.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/inline4.c 
b/gcc/testsuite/gcc.dg/debug/dwarf2/inline4.c
index 2faef6e2a4f..22eb35fcf09 100644
--- a/gcc/testsuite/gcc.dg/debug/dwarf2/inline4.c
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/inline4.c
@@ -2,7 +2,7 @@
the DW_TAG_inlined_subroutine and the DW_TAG_variable for the local.  */
 /* { dg-options "-O -gdwarf -dA" } */
 /* { dg-do compile } */
-/* { dg-final { scan-assembler 
"DW_TAG_inlined_subroutine\[^\\(\]*\\(\[^\\)\]*\\)\[^\\(\]*\\(DIE 
\\(0x\[0-9a-f\]*\\) DW_TAG_formal_parameter\[^\\(\]*\\(DIE \\(0x\[0-9a-f\]*\\) 
DW_TAG_variable" } } */
+/* { dg-final { scan-assembler 
"DW_TAG_inlined_subroutine\[^\\(\]*\(\|\\(\[^\\)\]*\\)\)\[^\\(\]*\\(DIE 
\\(0x\[0-9a-f\]*\\) DW_TAG_formal_parameter\[^\\(\]*\\(DIE \\(0x\[0-9a-f\]*\\) 
DW_TAG_variable" } } */
 /* { dg-final { scan-assembler-times "DW_TAG_inlined_subroutine" 2 } } */
 
 static int foo (int i)


[gcc r13-8584] testsuite, Darwin: Use the IOKit framework in framework-1.c [PR114049].

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

commit r13-8584-gb03827b261d3c8351f9c208fe2d89ca987a25bee
Author: Iain Sandoe 
Date:   Mon Mar 18 10:06:44 2024 +

testsuite, Darwin: Use the IOKit framework in framework-1.c [PR114049].

The intent of the test is to show that we find a framework that
is installed in /System/Library/Frameworks when the user has added
a '-F' option.  The trick is to choose some header that is present
for all the Darwin versions we support and that does not contain any
content we cannot parse.  We had been using the Kernel framework for
this, but recent SDK versions have revealed that this is not suitable.

Replacing with a use of IOKit.

PR target/114049

gcc/testsuite/ChangeLog:

* gcc.dg/framework-1.c: Use an IOKit header instead of a
Kernel one.

Signed-off-by: Iain Sandoe 
(cherry picked from commit 4adb1a5839e7a3310a127c1776f1f95d7edaa6ff)

Diff:
---
 gcc/testsuite/gcc.dg/framework-1.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/framework-1.c 
b/gcc/testsuite/gcc.dg/framework-1.c
index de4adc39868..fdec129a8fb 100644
--- a/gcc/testsuite/gcc.dg/framework-1.c
+++ b/gcc/testsuite/gcc.dg/framework-1.c
@@ -1,4 +1,10 @@
 /* { dg-do compile { target *-*-darwin* } } */
 /* { dg-options "-F." } */
 
-#include 
+/* The intent of the test is to show that we find a framework that
+   is installed in /System/Library/Frameworks when the user has added
+   a '-F' option.  The trick is to choose some header that is present
+   for all the Darwin versions we support and that does not contain any
+   content we cannot parse.  */
+
+#include 


[gcc r13-8585] Darwin: Do not emit .macinfo when dsymutil cannot consume it.

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

commit r13-8585-g48d302702d9c37d0da4f7446c1c09677e4f2f311
Author: Iain Sandoe 
Date:   Sun Mar 31 23:25:31 2024 +0100

Darwin: Do not emit .macinfo when dsymutil cannot consume it.

Some verions of dsymutil do not ignore .macinfo sections, but instead
ignore the entire debug in the file.

To avoid this total loss of debug, when we detect that the debug level
is g3 and the dsymutil version cannot support it, we reduce the level
to g2 and issue a note.

This behaviour can be overidden by -gstrict-dwarf (although the objects
will contain macinfo; dsymutil will not produce a .dSYM with it).

gcc/ChangeLog:

* config/darwin.cc (darwin_override_options): Reduce the debug
level to 2 if dsymutil cannot handle .macinfo sections.

Signed-off-by: Iain Sandoe 
(cherry picked from commit 3c499f8f6f7d19b21d7047efabbe6396ee1c2cac)

Diff:
---
 gcc/config/darwin.cc | 22 ++
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc
index b4a7c4226c4..fd2b6e872b7 100644
--- a/gcc/config/darwin.cc
+++ b/gcc/config/darwin.cc
@@ -3363,10 +3363,6 @@ darwin_override_options (void)
  global_options.x_flag_objc_abi);
 }
 
-  /* Don't emit DWARF3/4 unless specifically selected.  This is a
- workaround for tool bugs.  */
-  if (!OPTION_SET_P (dwarf_strict))
-dwarf_strict = 1;
   if (!OPTION_SET_P (dwarf_version))
 dwarf_version = 2;
 
@@ -3378,6 +3374,24 @@ darwin_override_options (void)
   OPTION_SET_P (dwarf_split_debug_info) = 0;
 }
 
+  /* Cases where dsymutil will exclude files with .macinfo sections; we are
+ better off forcing the debug level to 2 than completely excluding the
+ files.  If strict dwarf is set, then emit the macinfo anyway.  */
+  if (debug_info_level == DINFO_LEVEL_VERBOSE
+  && (!OPTION_SET_P (dwarf_strict) || dwarf_strict == 0)
+  && ((dsymutil_version.kind == CLANG && dsymutil_version.major >= 1500)
+ || (dsymutil_version.kind == LLVM && dsymutil_version.major >= 15)))
+{
+  inform (input_location,
+ "%<-g3%> is not supported by the debug linker in use (set to 2)");
+  debug_info_level = DINFO_LEVEL_NORMAL;
+}
+
+  /* Limit DWARF to the chosen version, the linker and debug linker might not
+ be able to consume newer structures.  */
+  if (!OPTION_SET_P (dwarf_strict))
+dwarf_strict = 1;
+
   /* Do not allow unwind tables to be generated by default for m32.
  fnon-call-exceptions will override this, regardless of what we do.  */
   if (generating_for_darwin_version < 10


[gcc r13-8586] testsuite, Darwin: Allow for an undefined symbol [PR114036].

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

commit r13-8586-g02a1d49da8f95a128d131747546921b67818d144
Author: Iain Sandoe 
Date:   Sun Mar 31 11:27:53 2024 +0100

testsuite, Darwin: Allow for an undefined symbol [PR114036].

Darwin's linker defaults to requiring all symbols to be defined at
static link time (unless specifically noted or dynamic lookuo is
enabled).

For this test, we just need to note that the symbol is expected to
be undefined.

PR testsuite/114036

gcc/testsuite/ChangeLog:

* gcc.misc-tests/gcov-14.c: Allow for 'Foo' to be undefined
on Darwin link lines.

Signed-off-by: Iain Sandoe 
(cherry picked from commit ad8e34eaa870608e2b07b4e7147e6ef2944bb8b5)

Diff:
---
 gcc/testsuite/gcc.misc-tests/gcov-14.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.misc-tests/gcov-14.c 
b/gcc/testsuite/gcc.misc-tests/gcov-14.c
index 2bebf7e4a93..61a9191c068 100644
--- a/gcc/testsuite/gcc.misc-tests/gcov-14.c
+++ b/gcc/testsuite/gcc.misc-tests/gcov-14.c
@@ -3,7 +3,7 @@
 /* { dg-do run { target native } } */
 /* { dg-options "-O2 -fprofile-arcs -ftest-coverage -fgnu89-inline" } */
 /* The following line arranges that Darwin has behavior like elf weak import.  
*/
-/* { dg-additional-options "-flat_namespace -undefined suppress" { target 
*-*-darwin* }  } */
+/* { dg-additional-options "-Wl,-U,_Foo" { target *-*-darwin* }  } */
 /* { dg-require-weak "" } */
 /* { dg-skip-if "undefined weak not supported" { { hppa*-*-hpux* } && { ! lp64 
} } } */
 /* { dg-skip-if "undefined weak not supported" { powerpc-ibm-aix* } } */


[gcc r14-9791] x86: Define __APX_F__ for -mapxf

2024-04-04 Thread H.J. Lu via Gcc-cvs
https://gcc.gnu.org/g:1df56719bd868c58466a549b25d7064dac3eb456

commit r14-9791-g1df56719bd868c58466a549b25d7064dac3eb456
Author: H.J. Lu 
Date:   Thu Apr 4 08:05:58 2024 -0700

x86: Define __APX_F__ for -mapxf

Define __APX_F__ when APX is enabled.

gcc/

PR target/114587
* config/i386/i386-c.cc (ix86_target_macros_internal): Define
__APX_F__ when APX is enabled.

gcc/testsuite/

PR target/114587
* gcc.target/i386/apx-2.c: New test.

Diff:
---
 gcc/config/i386/i386-c.cc | 2 ++
 gcc/testsuite/gcc.target/i386/apx-2.c | 6 ++
 2 files changed, 8 insertions(+)

diff --git a/gcc/config/i386/i386-c.cc b/gcc/config/i386/i386-c.cc
index 114908c7ec0..226d277676c 100644
--- a/gcc/config/i386/i386-c.cc
+++ b/gcc/config/i386/i386-c.cc
@@ -749,6 +749,8 @@ ix86_target_macros_internal (HOST_WIDE_INT isa_flag,
 }
   if (isa_flag2 & OPTION_MASK_ISA2_AVX10_1_512)
 def_or_undef (parse_in, "__AVX10_1_512__");
+  if (isa_flag2 & OPTION_MASK_ISA2_APX_F)
+def_or_undef (parse_in, "__APX_F__");
   if (TARGET_IAMCU)
 {
   def_or_undef (parse_in, "__iamcu");
diff --git a/gcc/testsuite/gcc.target/i386/apx-2.c 
b/gcc/testsuite/gcc.target/i386/apx-2.c
new file mode 100644
index 000..2f6439e4b23
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/apx-2.c
@@ -0,0 +1,6 @@
+/* { dg-do compile { target { ! ia32 } } } */
+/* { dg-options "-mapxf" } */
+
+#ifndef __APX_F__
+# error __APX_F__ not defined
+#endif


[gcc r12-10309] libphobos, testsuite: Disable forkgc2 on Darwin [PR103944]

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

commit r12-10309-g5a72912f9b0a5aa3c5a726ec499137c189921f9b
Author: Iain Sandoe 
Date:   Sun Feb 26 13:53:52 2023 +

libphobos, testsuite: Disable forkgc2 on Darwin [PR103944]

It hangs the testsuite (requiring manual intervention to kill the
spawned processes) which breaks CI.  The reason for the hang id not
clear.  This skips the test for now (xfail does not work).

Signed-off-by: Iain Sandoe 

PR d/103944

libphobos/ChangeLog:

* testsuite/libphobos.gc/forkgc2.d: Skip for Darwin.

(cherry picked from commit fca6d9c12f5bf06469cf9f7db8c42f66ef792fd2)

Diff:
---
 libphobos/testsuite/libphobos.gc/forkgc2.d | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libphobos/testsuite/libphobos.gc/forkgc2.d 
b/libphobos/testsuite/libphobos.gc/forkgc2.d
index de7796ced72..38d0d0c2f93 100644
--- a/libphobos/testsuite/libphobos.gc/forkgc2.d
+++ b/libphobos/testsuite/libphobos.gc/forkgc2.d
@@ -1,3 +1,4 @@
+// { dg-skip-if "test hangs the testsuite PR103944" { *-*-darwin* } }
 import core.stdc.stdlib : exit;
 import core.sys.posix.sys.wait : waitpid;
 import core.sys.posix.unistd : fork;


[gcc r12-10312] Darwin, fixincludes: Handle Apple Blocks in objc/runtime.h.

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

commit r12-10312-g5849685a416cd163201c63718b7d3f10f92bd522
Author: Iain Sandoe 
Date:   Wed Jan 18 23:25:36 2023 +

Darwin, fixincludes: Handle Apple Blocks in objc/runtime.h.

The macOS 13 SDK has unguarded Apple Blocks use in objc/runtime.h which
causes most of the objective-c tests to fail.

Signed-off-by: Iain Sandoe 

fixincludes/ChangeLog:

* fixincl.x: Regenerate.
* inclhack.def (darwin_objc_runtime_1): New hack.
* tests/base/objc/runtime.h: New file.

(cherry picked from commit 046dc9d0d4683bab99d28983d8841ba3c56ef744)

Diff:
---
 fixincludes/fixincl.x | 63 ---
 fixincludes/inclhack.def  | 35 +++
 fixincludes/tests/base/objc/runtime.h | 24 +
 3 files changed, 117 insertions(+), 5 deletions(-)

diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x
index c8612862081..0bc8eb049a3 100644
--- a/fixincludes/fixincl.x
+++ b/fixincludes/fixincl.x
@@ -2,11 +2,11 @@
  *
  * DO NOT EDIT THIS FILE   (fixincl.x)
  *
- * It has been AutoGen-ed  March 30, 2024 at 04:02:13 PM by AutoGen 5.18.7
+ * It has been AutoGen-ed  March 30, 2024 at 04:03:59 PM by AutoGen 5.18.7
  * From the definitionsinclhack.def
  * and the template file   fixincl
  */
-/* DO NOT SVN-MERGE THIS FILE, EITHER Sat Mar 30 16:02:13 GMT 2024
+/* DO NOT SVN-MERGE THIS FILE, EITHER Sat Mar 30 16:03:59 GMT 2024
  *
  * You must regenerate it.  Use the ./genfixes script.
  *
@@ -15,7 +15,7 @@
  * certain ANSI-incompatible system header files which are fixed to work
  * correctly with ANSI C and placed in a directory that GNU C will search.
  *
- * This file contains 268 fixup descriptions.
+ * This file contains 269 fixup descriptions.
  *
  * See README for more information.
  *
@@ -3084,6 +3084,53 @@ static const char* apzDarwin_Os_Trace_2Patch[] = {
 #endif",
 (char*)NULL };
 
+/* * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  Description of Darwin_Objc_Runtime_1 fix
+ */
+tSCC zDarwin_Objc_Runtime_1Name[] =
+ "darwin_objc_runtime_1";
+
+/*
+ *  File name selection pattern
+ */
+tSCC zDarwin_Objc_Runtime_1List[] =
+  "objc/runtime.h\0";
+/*
+ *  Machine/OS name selection pattern
+ */
+tSCC* apzDarwin_Objc_Runtime_1Machs[] = {
+"*-*-darwin2*",
+(const char*)NULL };
+
+/*
+ *  content selection pattern - do fix if pattern found
+ */
+tSCC zDarwin_Objc_Runtime_1Select0[] =
+   "OBJC_EXPORT void.*\n\
+objc_enumerateClasses.*\n\
+.*\n\
+.*\n\
+.*\n\
+.*void \\(\\^ _Nonnull block.*\n\
+.*\n\
+.*\n\
+.*OBJC_REFINED_FOR_SWIFT.*";
+
+#defineDARWIN_OBJC_RUNTIME_1_TEST_CT  1
+static tTestDesc aDarwin_Objc_Runtime_1Tests[] = {
+  { TT_EGREP,zDarwin_Objc_Runtime_1Select0, (regex_t*)NULL }, };
+
+/*
+ *  Fix Command Arguments for Darwin_Objc_Runtime_1
+ */
+static const char* apzDarwin_Objc_Runtime_1Patch[] = {
+"format",
+"#if __BLOCKS__\n\
+%0\n\
+#endif",
+(char*)NULL };
+
 /* * * * * * * * * * * * * * * * * * * * * * * * * *
  *
  *  Description of Darwin_Os_Trace_3 fix
@@ -10912,9 +10959,9 @@ static const char* apzX11_SprintfPatch[] = {
  *
  *  List of all fixes
  */
-#define REGEX_COUNT  306
+#define REGEX_COUNT  307
 #define MACH_LIST_SIZE_LIMIT 187
-#define FIX_COUNT268
+#define FIX_COUNT269
 
 /*
  *  Enumerate the fixes
@@ -10993,6 +11040,7 @@ typedef enum {
 DARWIN_LONGJMP_NORETURN_FIXIDX,
 DARWIN_OS_TRACE_1_FIXIDX,
 DARWIN_OS_TRACE_2_FIXIDX,
+DARWIN_OBJC_RUNTIME_1_FIXIDX,
 DARWIN_OS_TRACE_3_FIXIDX,
 DARWIN_OS_BASE_1_FIXIDX,
 DARWIN_DISPATCH_OBJECT_1_FIXIDX,
@@ -11556,6 +11604,11 @@ tFixDesc fixDescList[ FIX_COUNT ] = {
  DARWIN_OS_TRACE_2_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
  aDarwin_Os_Trace_2Tests,   apzDarwin_Os_Trace_2Patch, 0 },
 
+  {  zDarwin_Objc_Runtime_1Name,zDarwin_Objc_Runtime_1List,
+ apzDarwin_Objc_Runtime_1Machs,
+ DARWIN_OBJC_RUNTIME_1_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
+ aDarwin_Objc_Runtime_1Tests,   apzDarwin_Objc_Runtime_1Patch, 0 },
+
   {  zDarwin_Os_Trace_3Name,zDarwin_Os_Trace_3List,
  apzDarwin_Os_Trace_3Machs,
  DARWIN_OS_TRACE_3_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def
index 0c1a3f0658d..31a21c2a66d 100644
--- a/fixincludes/inclhack.def
+++ b/fixincludes/inclhack.def
@@ -1491,6 +1491,41 @@ fix = {
   test_text = "typedef void (^os_trace_payload_t)(xpc_object_t xdict);";
 };
 
+/*
+ *  macOSX 13.0 SDK objc/runtime.h uses Apple Blocks extension without a guard.
+ */
+
+fix = {
+  hackname  = darwin_objc_runtime_1;
+  mach  = "*-*-darwin2*";
+  files = objc/runtime.h;
+  select=   <<- _EOSelect_
+   OBJC_EXPORT void.*
+   objc_enumerateClasses.*
+   .*
+   .*
+   .*
+   .*void \(\^ _Nonnull block.*
+   .*
+   

[gcc r12-10310] Darwin: Use -platform_version when available [PR110624].

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

commit r12-10310-ga17f5a03e93d2cc6fd40cef6ab3930ba019f804a
Author: Iain Sandoe 
Date:   Thu Jul 13 07:36:51 2023 +0100

Darwin: Use -platform_version when available [PR110624].

Later versions of the static linker support a more flexible flag to
describe the OS, OS version and SDK used to build the code.  This
replaces the functionality of '-mmacosx_version_min' (which is now
deprecated, leading to the diagnostic described in the PR).

We now use the platform_version flag when available which avoids the
diagnostic.

Signed-off-by: Iain Sandoe 

PR target/110624

gcc/ChangeLog:

* config/darwin.h (DARWIN_PLATFORM_ID): New.
(LINK_COMMAND_A): Use DARWIN_PLATFORM_ID to pass OS, OS version
and SDK data to the static linker.

(cherry picked from commit 032b5da1fc781bd3c23d9caa72fb09439e7f6f3a)

Diff:
---
 gcc/config/darwin.h | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index 51e257dc698..ba5fb0a2b48 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -277,6 +277,14 @@ extern GTY(()) int darwin_ms_struct;
 #define DARWIN_RDYNAMIC "%{rdynamic:%nrdynamic is not supported}"
 #endif
 
+#if LD64_HAS_PLATFORM_VERSION
+#define DARWIN_PLATFORM_ID \
+  "%{mmacosx-version-min=*: -platform_version macos %* 0.0} "
+#else
+#define DARWIN_PLATFORM_ID \
+  "%{mmacosx-version-min=*:-macosx_version_min %*} "
+#endif
+
 /* Code built with mdynamic-no-pic does not support PIE/PIC, so  we disallow
these combinations; we also ensure that the no_pie option is passed to
ld64 on system versions that default to PIE when mdynamic-no-pic is given.
@@ -352,7 +360,9 @@ extern GTY(()) int darwin_ms_struct;
 LINK_PLUGIN_SPEC \
 "%{flto*:%

[gcc r12-10311] Darwin, fixincludes: Handle MacOS13 SDK Apple-specific deprecations [PR107568].

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

commit r12-10311-g753d7e4edf63c4ff690858da11bf0d59aa24e1bb
Author: Iain Sandoe 
Date:   Wed Jan 18 19:58:33 2023 +

Darwin, fixincludes: Handle MacOS13 SDK Apple-specific deprecations 
[PR107568].

The SDK for MacOS13 includes Apple-specific deprecations of some functions 
that
are not deprecated in Posix, C or C++ and widely used in GCC.

The fix makes the deprecation conditional on __APPLE_LOCAL_DEPRECATIONS so 
that
end users may still observe them but they are hidden from normal 
compilations.

Signed-off-by: Iain Sandoe 

PR target/107568

fixincludes/ChangeLog:

* fixincl.x: Regenerate.
* inclhack.def: Add a fix for MacOS13 SDK function deprecations
in stdio.h.
* tests/base/stdio.h (__deprecated_msg): New test.

(cherry picked from commit 442d2bdc1d2a98aba0b18aeaa3e87fa946ac8031)

Diff:
---
 fixincludes/fixincl.x  | 56 ++
 fixincludes/inclhack.def   | 12 +
 fixincludes/tests/base/stdio.h |  7 ++
 3 files changed, 70 insertions(+), 5 deletions(-)

diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x
index b314506f00d..c8612862081 100644
--- a/fixincludes/fixincl.x
+++ b/fixincludes/fixincl.x
@@ -2,11 +2,11 @@
  *
  * DO NOT EDIT THIS FILE   (fixincl.x)
  *
- * It has been AutoGen-ed  December 11, 2023 at 06:14:06 PM by AutoGen 5.18.16
+ * It has been AutoGen-ed  March 30, 2024 at 04:02:13 PM by AutoGen 5.18.7
  * From the definitionsinclhack.def
  * and the template file   fixincl
  */
-/* DO NOT SVN-MERGE THIS FILE, EITHER Mon Dec 11 18:14:06 CET 2023
+/* DO NOT SVN-MERGE THIS FILE, EITHER Sat Mar 30 16:02:13 GMT 2024
  *
  * You must regenerate it.  Use the ./genfixes script.
  *
@@ -15,7 +15,7 @@
  * certain ANSI-incompatible system header files which are fixed to work
  * correctly with ANSI C and placed in a directory that GNU C will search.
  *
- * This file contains 267 fixup descriptions.
+ * This file contains 268 fixup descriptions.
  *
  * See README for more information.
  *
@@ -2608,6 +2608,46 @@ static const char* apzBsd_Stdio_Attrs_ConflictPatch[] = {
 int vfscanf(FILE *, const char *, __builtin_va_list) __asm__ 
(_BSD_STRING(__USER_LABEL_PREFIX__) \"__svfscanf\");",
 (char*)NULL };
 
+/* * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  Description of Apple_Local_Stdio_Fn_Deprecation fix
+ */
+tSCC zApple_Local_Stdio_Fn_DeprecationName[] =
+ "apple_local_stdio_fn_deprecation";
+
+/*
+ *  File name selection pattern
+ */
+tSCC zApple_Local_Stdio_Fn_DeprecationList[] =
+  "stdio.h\0";
+/*
+ *  Machine/OS name selection pattern
+ */
+tSCC* apzApple_Local_Stdio_Fn_DeprecationMachs[] = {
+"*-*-*darwin2*",
+(const char*)NULL };
+
+/*
+ *  content selection pattern - do fix if pattern found
+ */
+tSCC zApple_Local_Stdio_Fn_DeprecationSelect0[] =
+   "__deprecated_msg([^\n\
+]*)$";
+
+#defineAPPLE_LOCAL_STDIO_FN_DEPRECATION_TEST_CT  1
+static tTestDesc aApple_Local_Stdio_Fn_DeprecationTests[] = {
+  { TT_EGREP,zApple_Local_Stdio_Fn_DeprecationSelect0, (regex_t*)NULL }, };
+
+/*
+ *  Fix Command Arguments for Apple_Local_Stdio_Fn_Deprecation
+ */
+static const char* apzApple_Local_Stdio_Fn_DeprecationPatch[] = {
+"format",
+"#if defined(__APPLE_LOCAL_DEPRECATIONS)\n\
+%0\n\
+#endif",
+(char*)NULL };
+
 /* * * * * * * * * * * * * * * * * * * * * * * * * *
  *
  *  Description of Ctrl_Quotes_Def fix
@@ -10872,9 +10912,9 @@ static const char* apzX11_SprintfPatch[] = {
  *
  *  List of all fixes
  */
-#define REGEX_COUNT  305
+#define REGEX_COUNT  306
 #define MACH_LIST_SIZE_LIMIT 187
-#define FIX_COUNT267
+#define FIX_COUNT268
 
 /*
  *  Enumerate the fixes
@@ -10941,6 +10981,7 @@ typedef enum {
 BROKEN_CABS_FIXIDX,
 BROKEN_NAN_FIXIDX,
 BSD_STDIO_ATTRS_CONFLICT_FIXIDX,
+APPLE_LOCAL_STDIO_FN_DEPRECATION_FIXIDX,
 CTRL_QUOTES_DEF_FIXIDX,
 CTRL_QUOTES_USE_FIXIDX,
 CXX_UNREADY_FIXIDX,
@@ -11455,6 +11496,11 @@ tFixDesc fixDescList[ FIX_COUNT ] = {
  BSD_STDIO_ATTRS_CONFLICT_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
  aBsd_Stdio_Attrs_ConflictTests,   apzBsd_Stdio_Attrs_ConflictPatch, 0 },
 
+  {  zApple_Local_Stdio_Fn_DeprecationName,
zApple_Local_Stdio_Fn_DeprecationList,
+ apzApple_Local_Stdio_Fn_DeprecationMachs,
+ APPLE_LOCAL_STDIO_FN_DEPRECATION_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
+ aApple_Local_Stdio_Fn_DeprecationTests,   
apzApple_Local_Stdio_Fn_DeprecationPatch, 0 },
+
   {  zCtrl_Quotes_DefName,zCtrl_Quotes_DefList,
  apzCtrl_Quotes_DefMachs,
  CTRL_QUOTES_DEF_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def
index 5cdd52a8de8..0c1a3f0658d 100644
--- a/fixincludes/inclhack.def
+++ b/fixincludes/inclhack.def
@@ -1269,6 +1269,1

[gcc r13-8587] Darwin, debug : Switch to DWARF 3 or 4 when dsymutil supports it.

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

commit r13-8587-ge67f95ca64748f9b85a00925aa1fe63550bf61d0
Author: Iain Sandoe 
Date:   Sun Sep 17 15:56:07 2023 +0100

Darwin,debug : Switch to DWARF 3 or 4 when dsymutil supports it.

The main reason that Darwin has been using DWARF2 only as debug is that
earlier debug linkers (dsymutil) did not support any extensions to this
so that the default "non-strict" mode used in GCC would cause tool errors.

There are two sources for dsymutil, those based off a closed source base
"dwarfutils" and those based off LLVM.

For dsymutil versions based off LLVM-7+ we can use up to DWARF-4, and for
versions based on dwarfutils 121+ we can use DWARF-3.

Signed-off-by: Iain Sandoe 

gcc/ChangeLog:

* config/darwin-protos.h (enum darwin_external_toolchain): New.
* config/darwin.cc (DSYMUTIL_VERSION): New.
(darwin_override_options): Choose the default debug DWARF version
depending on the configured dsymutil version.

(cherry picked from commit 47346acb72b50d178dae72393c851d57beec383f)

Diff:
---
 gcc/config/darwin-protos.h | 11 +++
 gcc/config/darwin.cc   | 29 +++--
 2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/gcc/config/darwin-protos.h b/gcc/config/darwin-protos.h
index 747745fa577..9df358ee7d3 100644
--- a/gcc/config/darwin-protos.h
+++ b/gcc/config/darwin-protos.h
@@ -129,4 +129,15 @@ extern void darwin_patch_builtins (void);
 extern void darwin_rename_builtins (void);
 extern bool darwin_libc_has_function (enum function_class fn_class, tree);
 
+/* For this port, there are several possible sources for external toolchain
+   components (e.g. as, ld, dsymutil) and we have to alter the allowable
+   output in response to which version and source is in use.  */
+enum darwin_external_toolchain {
+  DET_UNKNOWN=0,
+  CCTOOLS,
+  DWARFUTILS,
+  LLVM,
+  CLANG
+};
+
 #endif /* CONFIG_DARWIN_PROTOS_H */
diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc
index fd2b6e872b7..1471dbb6046 100644
--- a/gcc/config/darwin.cc
+++ b/gcc/config/darwin.cc
@@ -114,6 +114,19 @@ static bool ld_needs_eh_markers = false;
 /* Emit a section-start symbol for mod init and term sections.  */
 static bool ld_init_term_start_labels = false;
 
+/* The source and version of dsymutil in use.  */
+#ifndef DSYMUTIL_VERSION
+# warning Darwin toolchain without a defined dsymutil.
+# define DSYMUTIL_VERSION DET_UNKNOWN,0,0,0
+#endif
+
+struct {
+  darwin_external_toolchain kind; /* cctools, llvm, clang etc.  */
+  int major; /* version number.  */
+  int minor;
+  int tiny;
+} dsymutil_version = {DSYMUTIL_VERSION};
+
 /* Section names.  */
 section * darwin_sections[NUM_DARWIN_SECTIONS];
 
@@ -3363,10 +3376,22 @@ darwin_override_options (void)
  global_options.x_flag_objc_abi);
 }
 
+
   if (!OPTION_SET_P (dwarf_version))
-dwarf_version = 2;
+{
+  /* External toolchains based on LLVM or clang 7+ have support for
+dwarf-4.  */
+  if ((dsymutil_version.kind == LLVM && dsymutil_version.major >= 7)
+ || (dsymutil_version.kind == CLANG && dsymutil_version.major >= 700))
+   dwarf_version = 4;
+  else if (dsymutil_version.kind == DWARFUTILS
+  && dsymutil_version.major >= 121)
+   dwarf_version = 3;  /* From XC 6.4.  */
+  else
+   dwarf_version = 2;  /* Older cannot safely exceed dwarf-2.  */
+}
 
-  if (OPTION_SET_P (dwarf_split_debug_info))
+  if (OPTION_SET_P (dwarf_split_debug_info) && dwarf_split_debug_info)
 {
   inform (input_location,
  "%<-gsplit-dwarf%> is not supported on this platform, ignored");


[gcc r14-9792] nvptx: In mkoffload.cc, call diagnostic_color_init + gcc_init_libintl

2024-04-04 Thread Tobias Burnus via Gcc-cvs
https://gcc.gnu.org/g:7520a4992c94254016085a461c58c972497c4483

commit r14-9792-g7520a4992c94254016085a461c58c972497c4483
Author: Tobias Burnus 
Date:   Thu Apr 4 21:55:29 2024 +0200

nvptx: In mkoffload.cc, call diagnostic_color_init + gcc_init_libintl

gcc/ChangeLog:

* config/nvptx/mkoffload.cc (main): Call
gcc_init_libintl and diagnostic_color_init.

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

diff --git a/gcc/config/nvptx/mkoffload.cc b/gcc/config/nvptx/mkoffload.cc
index a7fc28cbd3f..503b1abcefd 100644
--- a/gcc/config/nvptx/mkoffload.cc
+++ b/gcc/config/nvptx/mkoffload.cc
@@ -638,7 +638,9 @@ main (int argc, char **argv)
   const char *outname = 0;
 
   progname = tool_name;
+  gcc_init_libintl ();
   diagnostic_initialize (global_dc, 0);
+  diagnostic_color_init (global_dc);
 
   if (atexit (mkoffload_cleanup) != 0)
 fatal_error (input_location, "atexit failed");


[gcc r14-9793] [PR114415][scheduler]: Fixing wrong code generation

2024-04-04 Thread Vladimir Makarov via Gcc-cvs
https://gcc.gnu.org/g:a24476422ba311b83737cf8bdc5892a7fc7514eb

commit r14-9793-ga24476422ba311b83737cf8bdc5892a7fc7514eb
Author: Vladimir N. Makarov 
Date:   Thu Apr 4 16:04:04 2024 -0400

[PR114415][scheduler]: Fixing wrong code generation

  For the test case, the insn scheduler (working for live range
shrinkage) moves insns modifying stack memory before an insn reserving
the stack memory. Comments in the patch contains more details about
the problem and its solution.

gcc/ChangeLog:

PR rtl-optimization/114415
* sched-deps.cc (add_insn_mem_dependence): Add memory check for mem 
argument.
(sched_analyze_1): Treat stack pointer modification as memory read.
(sched_analyze_2, sched_analyze_insn): Add memory guard for 
processing pending_read_mems.
* sched-int.h (deps_desc): Add comment to pending_read_mems.

gcc/testsuite/ChangeLog:

PR rtl-optimization/114415
* gcc.target/i386/pr114415.c: New test.

Diff:
---
 gcc/sched-deps.cc| 49 +---
 gcc/sched-int.h  |  4 ++-
 gcc/testsuite/gcc.target/i386/pr114415.c | 47 ++
 3 files changed, 83 insertions(+), 17 deletions(-)

diff --git a/gcc/sched-deps.cc b/gcc/sched-deps.cc
index 5034e664e5e..4c668245049 100644
--- a/gcc/sched-deps.cc
+++ b/gcc/sched-deps.cc
@@ -1735,7 +1735,7 @@ add_insn_mem_dependence (class deps_desc *deps, bool 
read_p,
   insn_node = alloc_INSN_LIST (insn, *insn_list);
   *insn_list = insn_node;
 
-  if (sched_deps_info->use_cselib)
+  if (sched_deps_info->use_cselib && MEM_P (mem))
 {
   mem = shallow_copy_rtx (mem);
   XEXP (mem, 0) = cselib_subst_to_values_from_insn (XEXP (mem, 0),
@@ -2458,6 +2458,25 @@ sched_analyze_1 (class deps_desc *deps, rtx x, rtx_insn 
*insn)
   FIRST_STACK_REG);
}
 #endif
+  if (!deps->readonly && regno == STACK_POINTER_REGNUM)
+   {
+ /* Please see PR114115.  We have insn modifying memory on the stack
+and not addressed by stack pointer and we have insn reserving the
+stack space.  If we move the insn modifying memory before insn
+reserving the stack space, we can change memory out of the red
+zone.  Even worse, some optimizations (e.g. peephole) can add
+insns using temporary stack slots before insn reserving the stack
+space but after the insn modifying memory.  This will corrupt the
+modified memory.  Therefore we treat insn changing the stack as
+reading unknown memory.  This will create anti-dependence.  We
+don't need to treat the insn as writing memory because GCC by
+itself does not generate code reading undefined stack memory.  */
+ if ((deps->pending_read_list_length + deps->pending_write_list_length)
+ >= param_max_pending_list_length
+ && !DEBUG_INSN_P (insn))
+   flush_pending_lists (deps, insn, true, true);
+ add_insn_mem_dependence (deps, true, insn, dest);
+   }
 }
   else if (MEM_P (dest))
 {
@@ -2498,10 +2517,11 @@ sched_analyze_1 (class deps_desc *deps, rtx x, rtx_insn 
*insn)
  pending_mem = deps->pending_read_mems;
  while (pending)
{
- if (anti_dependence (pending_mem->element (), t)
- && ! sched_insns_conditions_mutex_p (insn, pending->insn ()))
-   note_mem_dep (t, pending_mem->element (), pending->insn (),
- DEP_ANTI);
+ rtx mem = pending_mem->element ();
+ if (REG_P (mem)
+ || (anti_dependence (mem, t)
+ && ! sched_insns_conditions_mutex_p (insn, pending->insn 
(
+   note_mem_dep (t, mem, pending->insn (), DEP_ANTI);
 
  pending = pending->next ();
  pending_mem = pending_mem->next ();
@@ -2637,12 +2657,10 @@ sched_analyze_2 (class deps_desc *deps, rtx x, rtx_insn 
*insn)
pending_mem = deps->pending_read_mems;
while (pending)
  {
-   if (read_dependence (pending_mem->element (), t)
-   && ! sched_insns_conditions_mutex_p (insn,
-pending->insn ()))
- note_mem_dep (t, pending_mem->element (),
-   pending->insn (),
-   DEP_ANTI);
+   rtx mem = pending_mem->element ();
+   if (MEM_P (mem) && read_dependence (mem, t)
+   && ! sched_insns_conditions_mutex_p (insn, pending->insn 
()))
+ note_mem_dep (t, mem, pending->insn (), DEP_ANTI);
 
pending = pending->next ();
pending_mem = pending_mem->next ();
@@ -3026,8 +3044,7 @@ sched_analyze_insn (class deps_desc

[gcc r14-9794] ipa: Avoid duplicate replacements in IPA-SRA transformation phase

2024-04-04 Thread Martin Jambor via Gcc-cvs
https://gcc.gnu.org/g:ca56b43105fc09021ec445f1978a17cd85ae5e0c

commit r14-9794-gca56b43105fc09021ec445f1978a17cd85ae5e0c
Author: Martin Jambor 
Date:   Thu Apr 4 22:46:16 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.

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 3e0df6a6f77..f4b5e850c2b 100644
--- a/gcc/ipa-param-manipulation.cc
+++ b/gcc/ipa-param-manipulation.cc
@@ -1525,6 +1525,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-9795] c++: alias CTAD and template template parm [PR114377]

2024-04-04 Thread Jason Merrill via Gcc-cvs
https://gcc.gnu.org/g:801e82acd6b4f0cf863529875947e394899ea7b9

commit r14-9795-g801e82acd6b4f0cf863529875947e394899ea7b9
Author: centurion 
Date:   Wed Mar 27 18:36:37 2024 +

c++: alias CTAD and template template parm [PR114377]

To match all the other places that pull a _TEMPLATE_PARM out of a
_DECL (get_template_parm_index, etc.).

This change is too small to be legally significant for copyright.

PR c++/114377

gcc/cp/ChangeLog:

* pt.cc (find_template_parameter_info::found): Use TREE_TYPE for
TEMPLATE_DECL instead of DECL_INITIAL.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/class-deduction-alias19.C: New test.

Reviewed-by: Jason Merrill 

Diff:
---
 gcc/cp/pt.cc |  3 ++-
 gcc/testsuite/g++.dg/cpp2a/class-deduction-alias19.C | 15 +++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 7b00a8615d2..1425d6116d0 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -11032,7 +11032,8 @@ find_template_parameter_info::found (tree parm)
 {
   if (TREE_CODE (parm) == TREE_LIST)
 parm = TREE_VALUE (parm);
-  if (TREE_CODE (parm) == TYPE_DECL)
+  if (TREE_CODE (parm) == TYPE_DECL
+  || TREE_CODE (parm) == TEMPLATE_DECL)
 parm = TREE_TYPE (parm);
   else
 parm = DECL_INITIAL (parm);
diff --git a/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias19.C 
b/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias19.C
new file mode 100644
index 000..1ea79bd7691
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias19.C
@@ -0,0 +1,15 @@
+// PR c++/114377
+// { dg-do compile { target c++20 } }
+
+template  typename Iterator>
+struct K {};
+
+template 
+class Foo {};
+
+template  typename TTP>
+using Bar = Foo>;
+
+void s() {
+Bar(1); // { dg-error "failed|no match" }
+}


[gcc r14-9796] libatomic: Fix build for --disable-gnu-indirect-function [PR113986]

2024-04-04 Thread Wilco Dijkstra via Gcc-cvs
https://gcc.gnu.org/g:27b6d081f68528435066be2234c7329e31e0e84f

commit r14-9796-g27b6d081f68528435066be2234c7329e31e0e84f
Author: Wilco Dijkstra 
Date:   Tue Mar 26 15:08:02 2024 +

libatomic: Fix build for --disable-gnu-indirect-function [PR113986]

Fix libatomic build to support --disable-gnu-indirect-function on AArch64.
Always build atomic_16.S, add aliases to the __atomic_ functions if 
!HAVE_IFUNC.
Include auto-config.h in atomic_16.S to avoid having to pass defines via
makefiles.  Fix build if HWCAP_ATOMICS/CPUID are not defined.

libatomic:
PR target/113986
* Makefile.in: Regenerated.
* Makefile.am: Make atomic_16.S not depend on HAVE_IFUNC.
Remove predefine of HAVE_FEAT_LSE128.
* acinclude.m4: Remove ARCH_AARCH64_HAVE_LSE128.
* configure: Regenerated.
* config/linux/aarch64/atomic_16.S: Add __atomic_ alias if 
!HAVE_IFUNC.
* config/linux/aarch64/host-config.h: Correctly handle !HAVE_IFUNC.
Add defines for HWCAP_ATOMICS and HWCAP_CPUID.

Diff:
---
 libatomic/Makefile.am|  8 ++---
 libatomic/Makefile.in| 18 +-
 libatomic/acinclude.m4   |  1 -
 libatomic/config/linux/aarch64/atomic_16.S   | 47 ++---
 libatomic/config/linux/aarch64/host-config.h | 52 +++-
 libatomic/configure  | 16 -
 6 files changed, 82 insertions(+), 60 deletions(-)

diff --git a/libatomic/Makefile.am b/libatomic/Makefile.am
index d49c44c7d5f..980677f3533 100644
--- a/libatomic/Makefile.am
+++ b/libatomic/Makefile.am
@@ -130,12 +130,8 @@ libatomic_la_LIBADD = $(foreach s,$(SIZES),$(addsuffix 
_$(s)_.lo,$(SIZEOBJS)))
 ## On a target-specific basis, include alternates to be selected by IFUNC.
 if HAVE_IFUNC
 if ARCH_AARCH64_LINUX
-if ARCH_AARCH64_HAVE_LSE128
-AM_CPPFLAGS = -DHAVE_FEAT_LSE128
-endif
 IFUNC_OPTIONS   = -march=armv8-a+lse
 libatomic_la_LIBADD += $(foreach s,$(SIZES),$(addsuffix 
_$(s)_1_.lo,$(SIZEOBJS)))
-libatomic_la_SOURCES += atomic_16.S
 
 endif
 if ARCH_ARM_LINUX
@@ -155,6 +151,10 @@ libatomic_la_LIBADD += $(addsuffix _16_1_.lo,$(SIZEOBJS)) \
 endif
 endif
 
+if ARCH_AARCH64_LINUX
+libatomic_la_SOURCES += atomic_16.S
+endif
+
 libatomic_convenience_la_SOURCES = $(libatomic_la_SOURCES)
 libatomic_convenience_la_LIBADD = $(libatomic_la_LIBADD)
 
diff --git a/libatomic/Makefile.in b/libatomic/Makefile.in
index 11c8ec7ba15..d9d529bc502 100644
--- a/libatomic/Makefile.in
+++ b/libatomic/Makefile.in
@@ -90,17 +90,17 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 @ARCH_AARCH64_LINUX_TRUE@@HAVE_IFUNC_TRUE@am__append_1 = $(foreach 
s,$(SIZES),$(addsuffix _$(s)_1_.lo,$(SIZEOBJS)))
-@ARCH_AARCH64_LINUX_TRUE@@HAVE_IFUNC_TRUE@am__append_2 = atomic_16.S
-@ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@am__append_3 = $(foreach \
+@ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@am__append_2 = $(foreach \
 @ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@ s,$(SIZES),$(addsuffix \
 @ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@ _$(s)_1_.lo,$(SIZEOBJS))) \
 @ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@ $(addsuffix \
 @ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@ _8_2_.lo,$(SIZEOBJS)) \
 @ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@ tas_1_2_.lo
-@ARCH_I386_TRUE@@HAVE_IFUNC_TRUE@am__append_4 = $(addsuffix 
_8_1_.lo,$(SIZEOBJS))
-@ARCH_X86_64_TRUE@@HAVE_IFUNC_TRUE@am__append_5 = $(addsuffix 
_16_1_.lo,$(SIZEOBJS)) \
+@ARCH_I386_TRUE@@HAVE_IFUNC_TRUE@am__append_3 = $(addsuffix 
_8_1_.lo,$(SIZEOBJS))
+@ARCH_X86_64_TRUE@@HAVE_IFUNC_TRUE@am__append_4 = $(addsuffix 
_16_1_.lo,$(SIZEOBJS)) \
 @ARCH_X86_64_TRUE@@HAVE_IFUNC_TRUE@   $(addsuffix 
_16_2_.lo,$(SIZEOBJS))
 
+@ARCH_AARCH64_LINUX_TRUE@am__append_5 = atomic_16.S
 subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
@@ -156,8 +156,7 @@ am__uninstall_files_from_dir = { \
   }
 am__installdirs = "$(DESTDIR)$(toolexeclibdir)"
 LTLIBRARIES = $(noinst_LTLIBRARIES) $(toolexeclib_LTLIBRARIES)
-@ARCH_AARCH64_LINUX_TRUE@@HAVE_IFUNC_TRUE@am__objects_1 =  \
-@ARCH_AARCH64_LINUX_TRUE@@HAVE_IFUNC_TRUE@ atomic_16.lo
+@ARCH_AARCH64_LINUX_TRUE@am__objects_1 = atomic_16.lo
 am_libatomic_la_OBJECTS = gload.lo gstore.lo gcas.lo gexch.lo \
glfree.lo lock.lo init.lo fenv.lo fence.lo flag.lo \
$(am__objects_1)
@@ -425,7 +424,7 @@ libatomic_la_LDFLAGS = $(libatomic_version_info) 
$(libatomic_version_script) \
$(lt_host_flags) $(libatomic_darwin_rpath)
 
 libatomic_la_SOURCES = gload.c gstore.c gcas.c gexch.c glfree.c lock.c \
-   init.c fenv.c fence.c flag.c $(am__append_2)
+   init.c fenv.c fence.c flag.c $(am__append_5)
 SIZEOBJS = load store cas exch fadd fsub fand fior fxor fnand tas
 EXTRA_libatomic_la_SOURCES = $(addsuffix _n.c,$(SIZEOBJS))
 libatomic_la_DEPENDENCIES = $(libatomic_la_LIBADD) $(libatomic_version_dep)
@@ -451,9 +

[gcc r14-9798] testsuite/gcc.dg/debug/btf/btf-datasec-1.c: Handle leading-underscore

2024-04-04 Thread Hans-Peter Nilsson via Gcc-cvs
https://gcc.gnu.org/g:3b36e86d6af3b305207c1aa6d56c2b350fefba65

commit r14-9798-g3b36e86d6af3b305207c1aa6d56c2b350fefba65
Author: Hans-Peter Nilsson 
Date:   Fri Apr 5 01:36:54 2024 +0200

testsuite/gcc.dg/debug/btf/btf-datasec-1.c: Handle leading-underscore

I noticed my autotester for cris-elf flagging this as a regression.

* gcc.dg/debug/btf/btf-datasec-1.c: Adjust pattern for targets with
symbols having a leading underscore.

Diff:
---
 gcc/testsuite/gcc.dg/debug/btf/btf-datasec-1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-datasec-1.c 
b/gcc/testsuite/gcc.dg/debug/btf/btf-datasec-1.c
index 782216d3cb1..c8ebe5d07ca 100644
--- a/gcc/testsuite/gcc.dg/debug/btf/btf-datasec-1.c
+++ b/gcc/testsuite/gcc.dg/debug/btf/btf-datasec-1.c
@@ -20,7 +20,7 @@
 /* { dg-final { scan-assembler-times "0xf01\[\t \]+\[^\n\]*btt_info" 1 } } 
*/
 
 /* The offset entry for each variable in a DATSEC should contain a label.  */
-/* { dg-final { scan-assembler-times 
"(?:(?:\\.4byte|\\.long|data4\\.ua|\\.ualong|\\.uaword|\\.dword|long|dc\\.l|\\.word)\[\t
 \]|\\.vbyte\t4,\[\t \]?)\[a-e\]\[\t \]+\[^\n\]*bts_offset" 5 } } */
+/* { dg-final { scan-assembler-times 
"(?:(?:\\.4byte|\\.long|data4\\.ua|\\.ualong|\\.uaword|\\.dword|long|dc\\.l|\\.word)\[\t
 \]|\\.vbyte\t4,\[\t \]?)_?\[a-e\]\[\t \]+\[^\n\]*bts_offset" 5 } } */
 /* { dg-final { scan-assembler-times "my_cstruct\[\t \]+\[^\n\]*bts_offset" 1 
} } */
 /* { dg-final { scan-assembler-times "bigarr\[\t \]+\[^\n\]*bts_offset" 1 } } 
*/


[gcc r14-9799] testsuite/gcc.target/cris/pr93372-2.c: Handle xpass from combine improvement

2024-04-04 Thread Hans-Peter Nilsson via Gcc-cvs
https://gcc.gnu.org/g:4c8b3600c4856f7915281ae3ff4d97271c83a540

commit r14-9799-g4c8b3600c4856f7915281ae3ff4d97271c83a540
Author: Hans-Peter Nilsson 
Date:   Fri Apr 5 02:50:16 2024 +0200

testsuite/gcc.target/cris/pr93372-2.c: Handle xpass from combine improvement

After r14-9692-g839bc42772ba7a, a sequence that actually
looks optimal is now emitted, observed at
r14-9788-gb7bd2ec73d66f7.  This caused an XPASS for this
test.  While adjusting the test, better also guard it
against regressions by checking that there are no redundant
move insns.

That's the only test that's improved to the point of
affecting test-patterns.  E.g. pr93372-5.c (which references
pr93372-2.c) is also improved, though it retains a redundant
compare insn.  (PR 93372 was about regressions from the cc0
representation; not further improvement like here, thus it's
not tagged.  Though, I did not double-check whether this
actually *was* a regression from cc0.)

* gcc.target/cris/pr93372-2.c: Tweak scan-assembler
checks to cover recent combine improvement.

Diff:
---
 gcc/testsuite/gcc.target/cris/pr93372-2.c | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/gcc/testsuite/gcc.target/cris/pr93372-2.c 
b/gcc/testsuite/gcc.target/cris/pr93372-2.c
index 912069c018d..2ef6471a990 100644
--- a/gcc/testsuite/gcc.target/cris/pr93372-2.c
+++ b/gcc/testsuite/gcc.target/cris/pr93372-2.c
@@ -1,19 +1,20 @@
 /* Check that eliminable compare-instructions are eliminated. */
 /* { dg-do compile } */
 /* { dg-options "-O2" } */
-/* { dg-final { scan-assembler-not "\tcmp|\ttest" { xfail *-*-* } } } */
-/* { dg-final { scan-assembler-not "\tnot" { xfail cc0 } } } */
-/* { dg-final { scan-assembler-not "\tlsr" { xfail cc0 } } } */
+/* { dg-final { scan-assembler-not "\tcmp|\ttest" } } */
+/* { dg-final { scan-assembler-not "\tnot" } } */
+/* { dg-final { scan-assembler-not "\tlsr" } } */
+/* We should get just one move, storing the result into *d.  */
+/* { dg-final { scan-assembler-times "\tmove" 1 } } */
 
 int f(int a, int b, int *d)
 {
   int c = a - b;
 
-  /* Whoops!  We get a cmp.d with the original operands here. */
+  /* We used to get a cmp.d with the original operands here. */
   *d = (c == 0);
 
-  /* Whoops!  While we don't get a test.d for the result here for cc0,
- we get a sequence of insns: a move, a "not" and a shift of the
- subtraction-result, where a simple "spl" would have done. */
+  /* We used to get a suboptimal sequence, but now we get the optimal "sge"
+ (a.k.a "spl") re-using flags from the subtraction. */
   return c >= 0;
 }