[gcc r15-3034] [optc-save-gen.awk] Fix streaming of command line options for offloading.

2024-08-20 Thread Prathamesh Kulkarni via Gcc-cvs
https://gcc.gnu.org/g:db2e9a2a46f64b037494e8300c46f2d90a9fa55c

commit r15-3034-gdb2e9a2a46f64b037494e8300c46f2d90a9fa55c
Author: Prathamesh Kulkarni 
Date:   Tue Aug 20 12:54:02 2024 +0530

[optc-save-gen.awk] Fix streaming of command line options for offloading.

The patch modifies optc-save-gen.awk to generate if (!lto_stream_offload_p)
check before streaming out target-specific opt in 
cl_optimization_stream_out,
when offloading is enabled.

Also, it modifies cl_optimization_stream_in to issue an error during build 
time
if accelerator backend defines a target-specific Optimization option. This
restriction currently is in place to maintain consistency for streaming of
Optimization options between host and accelerator. A proper fix would be
to merge target-specific Optimization options for host and accelerators
enabled for offloading.

gcc/ChangeLog:
* optc-save-gen.awk: New array var_target_opt. Use it to generate
if (!lto_stream_offload_p) check in cl_optimization_stream_out,
and generate a diagnostic with #error if accelerator backend uses
Optimization for target-specifc options in 
cl_optimization_stream_in.

Signed-off-by: Prathamesh Kulkarni 

Diff:
---
 gcc/optc-save-gen.awk | 16 
 1 file changed, 16 insertions(+)

diff --git a/gcc/optc-save-gen.awk b/gcc/optc-save-gen.awk
index a3af88e3776..b1289c281e7 100644
--- a/gcc/optc-save-gen.awk
+++ b/gcc/optc-save-gen.awk
@@ -1307,6 +1307,11 @@ for (i = 0; i < n_opts; i++) {
var_opt_optimize_init[n_opt_val] = init;
}
 
+   # Mark options that are annotated with both Optimization and
+   # Target so we can avoid streaming out target-specific opts when
+   # offloading is enabled.
+   if (flag_set_p("Target", flags[i]))
+   var_target_opt[n_opt_val] = 1;
n_opt_val++;
}
 }
@@ -1384,6 +1389,10 @@ for (i = 0; i < n_opt_val; i++) {
} else {
sgn = "int";
}
+   # Do not stream out target-specific opts if offloading is
+   # enabled.
+   if (var_target_opt[i])
+   print "  if (!lto_stream_offload_p)"
# If applicable, encode the streamed value.
if (var_opt_optimize_init[i]) {
print "  if (" var_opt_optimize_init[i] " > (" 
var_opt_val_type[i] ") 10)";
@@ -1408,6 +1417,11 @@ print "   struct cl_optimization 
*ptr ATTRIBUTE_UNUSED)"
 print "{";
 for (i = 0; i < n_opt_val; i++) {
name = var_opt_val[i]
+if (var_target_opt[i]) {
+   print "#ifdef ACCEL_COMPILER"
+   print "#error accel compiler cannot define Optimization 
attribute for target-specific option " name;
+   print "#else"
+   }
otype = var_opt_val_type[i];
if (otype ~ "^const char \\**$") {
print "  ptr->" name" = bp_unpack_string (data_in, bp);";
@@ -1427,6 +1441,8 @@ for (i = 0; i < n_opt_val; i++) {
print "ptr->" name" ^= " var_opt_optimize_init[i] 
";";
}
}
+   if (var_target_opt[i])
+   print "#endif"
 }
 print "  for (size_t i = 0; i < ARRAY_SIZE (ptr->explicit_mask); i++)";
 print "ptr->explicit_mask[i] = bp_unpack_value (bp, 64);";


[gcc r15-3093] Recompute TYPE_MODE and DECL_MODE for aggregate type for acclerator.

2024-08-22 Thread Prathamesh Kulkarni via Gcc-cvs
https://gcc.gnu.org/g:792adb8d222d0d1d16b182871e105f47823b8e72

commit r15-3093-g792adb8d222d0d1d16b182871e105f47823b8e72
Author: Prathamesh Kulkarni 
Date:   Thu Aug 22 19:25:20 2024 +0530

Recompute TYPE_MODE and DECL_MODE for aggregate type for acclerator.

The patch streams out VOIDmode for aggregate types with offloading enabled,
and recomputes appropriate TYPE_MODE and DECL_MODE while streaming-in on 
accel
side. The rationale for this change is to avoid streaming out host-specific
modes that may be used for aggregate types, which may not be representable 
on
the accelerator. For eg, AArch64 uses OImode for ARRAY_TYPE whose size is 
256-bits,
and nvptx doesn't have OImode, and thus ends up emitting an error from
lto_input_mode_table.

gcc/ChangeLog:
* lto-streamer-in.cc: (lto_read_tree_1): Set DECL_MODE (expr) to
TREE_TYPE (TYPE_MODE (expr)) if TREE_TYPE (expr) is aggregate type 
and
offloading is enabled.
* stor-layout.cc (layout_type): Move computation of mode for
ARRAY_TYPE from ...
(compute_array_mode): ... to here.
* stor-layout.h (compute_array_mode): Declare.
* tree-streamer-in.cc: Include stor-layout.h.
(unpack_ts_common_value_fields): Call compute_array_mode if 
offloading
is enabled.
* tree-streamer-out.cc (pack_ts_fixed_cst_value_fields): Stream out
VOIDmode if decl has aggregate type and offloading is enabled.
(pack_ts_type_common_value_fields): Stream out VOIDmode for 
aggregate
type if offloading is enabled.

Signed-off-by: Prathamesh Kulkarni 

Diff:
---
 gcc/lto-streamer-in.cc   |  9 +
 gcc/stor-layout.cc   | 45 +++--
 gcc/stor-layout.h|  1 +
 gcc/tree-streamer-in.cc  | 12 
 gcc/tree-streamer-out.cc | 22 --
 5 files changed, 69 insertions(+), 20 deletions(-)

diff --git a/gcc/lto-streamer-in.cc b/gcc/lto-streamer-in.cc
index cbf6041fd685..64f758073280 100644
--- a/gcc/lto-streamer-in.cc
+++ b/gcc/lto-streamer-in.cc
@@ -1752,6 +1752,15 @@ lto_read_tree_1 (class lto_input_block *ib, class 
data_in *data_in, tree expr)
 with -g1, see for example PR113488.  */
   else if (DECL_P (expr) && DECL_ABSTRACT_ORIGIN (expr) == expr)
DECL_ABSTRACT_ORIGIN (expr) = NULL_TREE;
+
+#ifdef ACCEL_COMPILER
+  if ((VAR_P (expr)
+  || TREE_CODE (expr) == PARM_DECL
+  || TREE_CODE (expr) == FIELD_DECL)
+ && AGGREGATE_TYPE_P (TREE_TYPE (expr))
+ && DECL_MODE (expr) == VOIDmode)
+   SET_DECL_MODE (expr, TYPE_MODE (TREE_TYPE (expr)));
+#endif
 }
 }
 
diff --git a/gcc/stor-layout.cc b/gcc/stor-layout.cc
index 10c0809914cd..0ff8bd1171e1 100644
--- a/gcc/stor-layout.cc
+++ b/gcc/stor-layout.cc
@@ -2396,6 +2396,32 @@ finish_builtin_struct (tree type, const char *name, tree 
fields,
   layout_decl (TYPE_NAME (type), 0);
 }
 
+/* Compute TYPE_MODE for TYPE (which is ARRAY_TYPE).  */
+
+void compute_array_mode (tree type)
+{
+  gcc_assert (TREE_CODE (type) == ARRAY_TYPE);
+
+  SET_TYPE_MODE (type, BLKmode);
+  if (TYPE_SIZE (type) != 0
+  && ! targetm.member_type_forces_blk (type, VOIDmode)
+  /* BLKmode elements force BLKmode aggregate;
+else extract/store fields may lose.  */
+  && (TYPE_MODE (TREE_TYPE (type)) != BLKmode
+ || TYPE_NO_FORCE_BLK (TREE_TYPE (type
+{
+  SET_TYPE_MODE (type, mode_for_array (TREE_TYPE (type),
+  TYPE_SIZE (type)));
+  if (TYPE_MODE (type) != BLKmode
+ && STRICT_ALIGNMENT && TYPE_ALIGN (type) < BIGGEST_ALIGNMENT
+ && TYPE_ALIGN (type) < GET_MODE_ALIGNMENT (TYPE_MODE (type)))
+   {
+ TYPE_NO_FORCE_BLK (type) = 1;
+ SET_TYPE_MODE (type, BLKmode);
+   }
+}
+}
+
 /* Calculate the mode, size, and alignment for TYPE.
For an array type, calculate the element separation as well.
Record TYPE on the chain of permanent or temporary types
@@ -2709,24 +2735,7 @@ layout_type (tree type)
align = MAX (align, BITS_PER_UNIT);
 #endif
SET_TYPE_ALIGN (type, align);
-   SET_TYPE_MODE (type, BLKmode);
-   if (TYPE_SIZE (type) != 0
-   && ! targetm.member_type_forces_blk (type, VOIDmode)
-   /* BLKmode elements force BLKmode aggregate;
-  else extract/store fields may lose.  */
-   && (TYPE_MODE (TREE_TYPE (type)) != BLKmode
-   || TYPE_NO_FORCE_BLK (TREE_TYPE (type
- {
-   SET_TYPE_MODE (type, mode_for_array (TREE_TYPE (type),
-TYPE_SIZE (type)));
-   if (TYPE_MODE (type) != BLKmode
-   && STRICT_ALIGNMENT && TYPE_ALIGN (type) < BIGGEST_ALIGNMENT
-   && TYPE_ALIGN (type) < GET_MODE_ALIGNMENT (TYPE_MODE (type)))
- {
-   

[gcc r15-3488] Avoid ICE when passing VLA vector to accelerator.

2024-09-05 Thread Prathamesh Kulkarni via Gcc-cvs
https://gcc.gnu.org/g:ae88e91938af364ef5613e5461b12b484b578bc5

commit r15-3488-gae88e91938af364ef5613e5461b12b484b578bc5
Author: Prathamesh Kulkarni 
Date:   Thu Sep 5 18:52:53 2024 +0530

Avoid ICE when passing VLA vector to accelerator.

gcc/ChangeLog:
* gimplify.cc (omp_add_variable): Check if decl size is not 
poly_int_tree_p.
(gimplify_adjust_omp_clauses): Likewise.
* omp-low.cc (scan_sharing_clauses): Likewise.
(lower_omp_target): Likewise.

Signed-off-by: Prathamesh Kulkarni 

Diff:
---
 gcc/gimplify.cc | 4 ++--
 gcc/omp-low.cc  | 8 
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 9300138aa0c..ceb53e5d5bb 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -7799,7 +7799,7 @@ omp_add_variable (struct gimplify_omp_ctx *ctx, tree 
decl, unsigned int flags)
   /* When adding a variable-sized variable, we have to handle all sorts
  of additional bits of data: the pointer replacement variable, and
  the parameters of the type.  */
-  if (DECL_SIZE (decl) && TREE_CODE (DECL_SIZE (decl)) != INTEGER_CST)
+  if (DECL_SIZE (decl) && !poly_int_tree_p (DECL_SIZE (decl)))
 {
   /* Add the pointer replacement variable as PRIVATE if the variable
 replacement is private, else FIRSTPRIVATE since we'll need the
@@ -14413,7 +14413,7 @@ gimplify_adjust_omp_clauses (gimple_seq *pre_p, 
gimple_seq body, tree *list_p,
}
}
  else if (DECL_SIZE (decl)
-  && TREE_CODE (DECL_SIZE (decl)) != INTEGER_CST
+  && !poly_int_tree_p (DECL_SIZE (decl))
   && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_POINTER
   && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_FIRSTPRIVATE_POINTER
   && (OMP_CLAUSE_MAP_KIND (c)
diff --git a/gcc/omp-low.cc b/gcc/omp-low.cc
index 4d003f42098..241f79e34a9 100644
--- a/gcc/omp-low.cc
+++ b/gcc/omp-low.cc
@@ -1664,7 +1664,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
  if (DECL_P (decl))
{
  if (DECL_SIZE (decl)
- && TREE_CODE (DECL_SIZE (decl)) != INTEGER_CST)
+ && !poly_int_tree_p (DECL_SIZE (decl)))
{
  tree decl2 = DECL_VALUE_EXPR (decl);
  gcc_assert (INDIRECT_REF_P (decl2));
@@ -1906,7 +1906,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
= remap_type (TREE_TYPE (decl), &ctx->cb);
}
  else if (DECL_SIZE (decl)
-  && TREE_CODE (DECL_SIZE (decl)) != INTEGER_CST)
+  && !poly_int_tree_p (DECL_SIZE (decl)))
{
  tree decl2 = DECL_VALUE_EXPR (decl);
  gcc_assert (INDIRECT_REF_P (decl2));
@@ -12750,7 +12750,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, 
omp_context *ctx)
  }
 
if (DECL_SIZE (var)
-   && TREE_CODE (DECL_SIZE (var)) != INTEGER_CST)
+   && !poly_int_tree_p (DECL_SIZE (var)))
  {
tree var2 = DECL_VALUE_EXPR (var);
gcc_assert (TREE_CODE (var2) == INDIRECT_REF);
@@ -13077,7 +13077,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, 
omp_context *ctx)
else
  {
if (DECL_SIZE (ovar)
-   && TREE_CODE (DECL_SIZE (ovar)) != INTEGER_CST)
+   && !poly_int_tree_p (DECL_SIZE (ovar)))
  {
tree ovar2 = DECL_VALUE_EXPR (ovar);
gcc_assert (TREE_CODE (ovar2) == INDIRECT_REF);


[gcc r15-3571] Pass host specific ABI opts from mkoffload.

2024-09-10 Thread Prathamesh Kulkarni via Gcc-cvs
https://gcc.gnu.org/g:e783a4a683762487cb003ae48235f3d44875de1b

commit r15-3571-ge783a4a683762487cb003ae48235f3d44875de1b
Author: Prathamesh Kulkarni 
Date:   Tue Sep 10 21:01:58 2024 +0530

Pass host specific ABI opts from mkoffload.

The patch adds an option -foffload-abi-host-opts, which
is set by host in TARGET_OFFLOAD_OPTIONS, and mkoffload then passes its 
value
to host_compiler.

gcc/ChangeLog:
PR target/96265
* common.opt (foffload-abi-host-opts): New option.
* config/aarch64/aarch64.cc (aarch64_offload_options): Pass
-foffload-abi-host-opts.
* config/i386/i386-options.cc (ix86_offload_options): Likewise.
* config/rs6000/rs6000.cc (rs6000_offload_options): Likewise.
* config/nvptx/mkoffload.cc (offload_abi_host_opts): Define.
(compile_native): Append offload_abi_host_opts to argv_obstack.
(main): Handle option -foffload-abi-host-opts.
* config/gcn/mkoffload.cc (offload_abi_host_opts): Define.
(compile_native): Append offload_abi_host_opts to argv_obstack.
(main): Handle option -foffload-abi-host-opts.
* lto-wrapper.cc (merge_and_complain): Handle
-foffload-abi-host-opts.
(append_compiler_options): Likewise.
* opts.cc (common_handle_option): Likewise.

Signed-off-by: Prathamesh Kulkarni 

Diff:
---
 gcc/common.opt  |  4 
 gcc/config/aarch64/aarch64.cc   |  4 ++--
 gcc/config/gcn/mkoffload.cc | 26 +++---
 gcc/config/i386/i386-options.cc |  4 ++--
 gcc/config/nvptx/mkoffload.cc   | 25 ++---
 gcc/config/rs6000/rs6000.cc |  4 ++--
 gcc/lto-wrapper.cc  |  2 ++
 gcc/opts.cc |  7 +--
 8 files changed, 46 insertions(+), 30 deletions(-)

diff --git a/gcc/common.opt b/gcc/common.opt
index ea39f87ae716..d270e524ff45 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -2361,6 +2361,10 @@ Enum(offload_abi) String(ilp32) Value(OFFLOAD_ABI_ILP32)
 EnumValue
 Enum(offload_abi) String(lp64) Value(OFFLOAD_ABI_LP64)
 
+foffload-abi-host-opts=
+Common Joined MissingArgError(option missing after %qs)
+-foffload-abi-host-opts=  Specify host ABI options.
+
 fomit-frame-pointer
 Common Var(flag_omit_frame_pointer) Optimization
 When possible do not generate stack frames.
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 6a3f1a23a9f4..6ccf08d1cc0a 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -19000,9 +19000,9 @@ static char *
 aarch64_offload_options (void)
 {
   if (TARGET_ILP32)
-return xstrdup ("-foffload-abi=ilp32");
+return xstrdup ("-foffload-abi=ilp32 -foffload-abi-host-opts=-mabi=ilp32");
   else
-return xstrdup ("-foffload-abi=lp64");
+return xstrdup ("-foffload-abi=lp64 -foffload-abi-host-opts=-mabi=lp64");
 }
 
 static struct machine_function *
diff --git a/gcc/config/gcn/mkoffload.cc b/gcc/config/gcn/mkoffload.cc
index b8d981878edf..345bbf7709c4 100644
--- a/gcc/config/gcn/mkoffload.cc
+++ b/gcc/config/gcn/mkoffload.cc
@@ -133,6 +133,8 @@ static const char *gcn_dumpbase;
 static struct obstack files_to_cleanup;
 
 enum offload_abi offload_abi = OFFLOAD_ABI_UNSET;
+const char *offload_abi_host_opts = NULL;
+
 uint32_t elf_arch = EF_AMDGPU_MACH_AMDGCN_GFX900;  // Default GPU architecture.
 uint32_t elf_flags = EF_AMDGPU_FEATURE_SRAMECC_UNSUPPORTED_V4;
 
@@ -819,17 +821,10 @@ compile_native (const char *infile, const char *outfile, 
const char *compiler,
   obstack_ptr_grow (&argv_obstack, gcn_dumpbase);
   obstack_ptr_grow (&argv_obstack, "-dumpbase-ext");
   obstack_ptr_grow (&argv_obstack, ".c");
-  switch (offload_abi)
-{
-case OFFLOAD_ABI_LP64:
-  obstack_ptr_grow (&argv_obstack, "-m64");
-  break;
-case OFFLOAD_ABI_ILP32:
-  obstack_ptr_grow (&argv_obstack, "-m32");
-  break;
-default:
-  gcc_unreachable ();
-}
+  if (!offload_abi_host_opts)
+fatal_error (input_location,
+"%<-foffload-abi-host-opts%> not specified.");
+  obstack_ptr_grow (&argv_obstack, offload_abi_host_opts);
   obstack_ptr_grow (&argv_obstack, infile);
   obstack_ptr_grow (&argv_obstack, "-c");
   obstack_ptr_grow (&argv_obstack, "-o");
@@ -998,6 +993,15 @@ main (int argc, char **argv)
 "unrecognizable argument of option %<" STR "%>");
}
 #undef STR
+  else if (startswith (argv[i], "-foffload-abi-host-opts="))
+   {
+ if (offload_abi_host_opts)
+   fatal_error (input_location,
+"%<-foffload-abi-host-opts%> specified "
+"multiple times");
+ offload_abi_host_opts
+   = argv[i] + strlen ("-foffload-abi-host-opts=");
+   }
   else if (strcmp (argv[i], "-fopenmp") == 0)
fopenmp = true;
   else if (strcmp (argv[i], "-fopenacc") == 0)
diff

[gcc r15-1821] [MAINTAINERS] Update my email address.

2024-07-03 Thread Prathamesh Kulkarni via Gcc-cvs
https://gcc.gnu.org/g:56814070003d2d54885c9009b7594c2b758ff81b

commit r15-1821-g56814070003d2d54885c9009b7594c2b758ff81b
Author: Prathamesh Kulkarni 
Date:   Wed Jul 3 18:59:48 2024 +0530

[MAINTAINERS] Update my email address.

* MAINTAINERS: Update my email address and add myself to DCO.

Signed-off-by: Prathamesh Kulkarni  

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

diff --git a/MAINTAINERS b/MAINTAINERS
index ddeea7b497f..b4739f29107 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -511,7 +511,7 @@ Matt Kraai  

 Jan Kratochvil 
 Matthias Kretz 
 Louis Krupp
-Prathamesh Kulkarni
+Prathamesh Kulkarni
 Venkataramanan Kumar   
 Doug Kwan  
 Aaron W. LaFramboise   
@@ -791,3 +791,4 @@ Jonathan Wakely 

 Alexander Westbrooks   
 Chung-Ju Wu
 Pengxuan Zheng 
+Prathamesh Kulkarni


[gcc r15-1937] [PR115394] Remove streamer_debugging and it's uses.

2024-07-10 Thread Prathamesh Kulkarni via Gcc-cvs
https://gcc.gnu.org/g:23c2e6de305b8a9e44041d54e587f1333f06134c

commit r15-1937-g23c2e6de305b8a9e44041d54e587f1333f06134c
Author: Prathamesh Kulkarni 
Date:   Wed Jul 10 16:58:20 2024 +0530

[PR115394] Remove streamer_debugging and it's uses.

gcc/ChangeLog:
PR lto/115394
* lto-streamer.h: Remove streamer_debugging definition.
* lto-streamer-out.cc (stream_write_tree_ref): Remove use of 
streamer_debugging.
(lto_output_tree): Likewise.
* tree-streamer-in.cc (streamer_read_tree_bitfields): Likewise.
(streamer_get_pickled_tree): Likewise.
* tree-streamer-out.cc (pack_ts_base_value_fields): Likewise.

Signed-off-by: Prathamesh Kulkarni 

Diff:
---
 gcc/lto-streamer-out.cc  |  8 
 gcc/lto-streamer.h   |  4 
 gcc/tree-streamer-in.cc  | 18 --
 gcc/tree-streamer-out.cc |  2 --
 4 files changed, 32 deletions(-)

diff --git a/gcc/lto-streamer-out.cc b/gcc/lto-streamer-out.cc
index d4f728094ed5..8b4bf9659cb3 100644
--- a/gcc/lto-streamer-out.cc
+++ b/gcc/lto-streamer-out.cc
@@ -487,8 +487,6 @@ stream_write_tree_ref (struct output_block *ob, tree t)
gcc_checking_assert (tag == LTO_global_stream_ref);
  streamer_write_hwi (ob, -(int)(ix * 2 + id + 1));
}
-  if (streamer_debugging)
-   streamer_write_uhwi (ob, TREE_CODE (t));
 }
 }
 
@@ -1839,9 +1837,6 @@ lto_output_tree (struct output_block *ob, tree expr,
 will instantiate two different nodes for the same object.  */
   streamer_write_record_start (ob, LTO_tree_pickle_reference);
   streamer_write_uhwi (ob, ix);
-  if (streamer_debugging)
-   streamer_write_enum (ob->main_stream, LTO_tags, LTO_NUM_TAGS,
-lto_tree_code_to_tag (TREE_CODE (expr)));
   lto_stats.num_pickle_refs_output++;
 }
   else
@@ -1882,9 +1877,6 @@ lto_output_tree (struct output_block *ob, tree expr,
}
  streamer_write_record_start (ob, LTO_tree_pickle_reference);
  streamer_write_uhwi (ob, ix);
- if (streamer_debugging)
-   streamer_write_enum (ob->main_stream, LTO_tags, LTO_NUM_TAGS,
-lto_tree_code_to_tag (TREE_CODE (expr)));
}
   in_dfs_walk = false;
   lto_stats.num_pickle_refs_output++;
diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h
index e8dbba471edb..79c44d2cae71 100644
--- a/gcc/lto-streamer.h
+++ b/gcc/lto-streamer.h
@@ -126,10 +126,6 @@ along with GCC; see the file COPYING3.  If not see
 
 typedef unsigned char  lto_decl_flags_t;
 
-/* Stream additional data to LTO object files to make it easier to debug
-   streaming code.  This changes object files.  */
-static const bool streamer_debugging = false;
-
 /* Tags representing the various IL objects written to the bytecode file
(GIMPLE statements, basic blocks, EH regions, tree nodes, etc).
 
diff --git a/gcc/tree-streamer-in.cc b/gcc/tree-streamer-in.cc
index 35341a2b2b68..c248a74f7a1a 100644
--- a/gcc/tree-streamer-in.cc
+++ b/gcc/tree-streamer-in.cc
@@ -485,15 +485,6 @@ streamer_read_tree_bitfields (class lto_input_block *ib,
 
   /* Read the bitpack of non-pointer values from IB.  */
   bp = streamer_read_bitpack (ib);
-
-  /* The first word in BP contains the code of the tree that we
- are about to read.  */
-  if (streamer_debugging)
-{
-  code = (enum tree_code) bp_unpack_value (&bp, 16);
-  lto_tag_check (lto_tree_code_to_tag (code),
-lto_tree_code_to_tag (TREE_CODE (expr)));
-}
   code = TREE_CODE (expr);
 
   /* Note that all these functions are highly sensitive to changes in
@@ -1110,17 +1101,8 @@ streamer_get_pickled_tree (class lto_input_block *ib, 
class data_in *data_in)
 {
   unsigned HOST_WIDE_INT ix;
   tree result;
-  enum LTO_tags expected_tag;
 
   ix = streamer_read_uhwi (ib);
   result = streamer_tree_cache_get_tree (data_in->reader_cache, ix);
-
-  if (streamer_debugging)
-{
-  expected_tag = streamer_read_enum (ib, LTO_tags, LTO_NUM_TAGS);
-  gcc_assert (result
- && TREE_CODE (result) == lto_tag_to_tree_code (expected_tag));
-}
-
   return result;
 }
diff --git a/gcc/tree-streamer-out.cc b/gcc/tree-streamer-out.cc
index c30ab62a5856..b7205287ffb6 100644
--- a/gcc/tree-streamer-out.cc
+++ b/gcc/tree-streamer-out.cc
@@ -71,8 +71,6 @@ write_identifier (struct output_block *ob,
 static inline void
 pack_ts_base_value_fields (struct bitpack_d *bp, tree expr)
 {
-  if (streamer_debugging)
-bp_pack_value (bp, TREE_CODE (expr), 16);
   if (!TYPE_P (expr))
 {
   bp_pack_value (bp, TREE_SIDE_EFFECTS (expr), 1);


[gcc r15-2066] Lower zeroing array assignment to memset for allocatable arrays.

2024-07-16 Thread Prathamesh Kulkarni via Gcc-cvs
https://gcc.gnu.org/g:616627245fb06106f7c5bc4a36784acc8ec166f0

commit r15-2066-g616627245fb06106f7c5bc4a36784acc8ec166f0
Author: Prathamesh Kulkarni 
Date:   Tue Jul 16 19:43:54 2024 +0530

Lower zeroing array assignment to memset for allocatable arrays.

gcc/fortran/ChangeLog:
* trans-expr.cc (gfc_trans_zero_assign): Handle allocatable arrays.

gcc/testsuite/ChangeLog:
* gfortran.dg/array_memset_3.f90: New test.

Signed-off-by: Prathamesh Kulkarni 

Diff:
---
 gcc/fortran/trans-expr.cc| 31 +++--
 gcc/testsuite/gfortran.dg/array_memset_3.f90 | 52 
 2 files changed, 73 insertions(+), 10 deletions(-)

diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index 3ff248549c6e..fc23fb1a7ebf 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -11499,18 +11499,24 @@ gfc_trans_zero_assign (gfc_expr * expr)
   type = TREE_TYPE (dest);
   if (POINTER_TYPE_P (type))
 type = TREE_TYPE (type);
-  if (!GFC_ARRAY_TYPE_P (type))
-return NULL_TREE;
-
-  /* Determine the length of the array.  */
-  len = GFC_TYPE_ARRAY_SIZE (type);
-  if (!len || TREE_CODE (len) != INTEGER_CST)
+  if (GFC_ARRAY_TYPE_P (type))
+{
+  /* Determine the length of the array.  */
+  len = GFC_TYPE_ARRAY_SIZE (type);
+  if (!len || TREE_CODE (len) != INTEGER_CST)
+   return NULL_TREE;
+}
+  else if (GFC_DESCRIPTOR_TYPE_P (type)
+ && gfc_is_simply_contiguous (expr, false, false))
+{
+  if (POINTER_TYPE_P (TREE_TYPE (dest)))
+   dest = build_fold_indirect_ref_loc (input_location, dest);
+  len = gfc_conv_descriptor_size (dest, GFC_TYPE_ARRAY_RANK (type));
+  dest = gfc_conv_descriptor_data_get (dest);
+}
+  else
 return NULL_TREE;
 
-  tmp = TYPE_SIZE_UNIT (gfc_get_element_type (type));
-  len = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type, len,
-fold_convert (gfc_array_index_type, tmp));
-
   /* If we are zeroing a local array avoid taking its address by emitting
  a = {} instead.  */
   if (!POINTER_TYPE_P (TREE_TYPE (dest)))
@@ -11518,6 +11524,11 @@ gfc_trans_zero_assign (gfc_expr * expr)
   dest, build_constructor (TREE_TYPE (dest),
  NULL));
 
+  /* Multiply len by element size.  */
+  tmp = TYPE_SIZE_UNIT (gfc_get_element_type (type));
+  len = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
+len, fold_convert (gfc_array_index_type, tmp));
+
   /* Convert arguments to the correct types.  */
   dest = fold_convert (pvoid_type_node, dest);
   len = fold_convert (size_type_node, len);
diff --git a/gcc/testsuite/gfortran.dg/array_memset_3.f90 
b/gcc/testsuite/gfortran.dg/array_memset_3.f90
new file mode 100644
index ..f3945aacbbdf
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/array_memset_3.f90
@@ -0,0 +1,52 @@
+! { dg-do compile }
+! { dg-options "-O2 -fdump-tree-original" }
+
+subroutine test1(n)
+  implicit none
+integer(8) :: n
+real(4), allocatable :: z(:,:,:)
+
+allocate(z(n, 100, 200))
+z = 0
+end subroutine
+
+subroutine test2(n)
+  implicit none
+integer(8) :: n
+integer, allocatable :: z(:,:,:)
+
+allocate(z(n, 100, 200))
+z = 0
+end subroutine
+
+subroutine test3(n)
+  implicit none
+integer(8) :: n
+logical, allocatable :: z(:,:,:)
+
+allocate(z(n, 100, 200))
+z = .false. 
+end subroutine
+
+subroutine test4(n, z)
+   implicit none
+   integer :: n
+   real, pointer :: z(:,:,:) ! need not be contiguous!
+   z = 0
+end subroutine
+
+subroutine test5(n, z)
+   implicit none
+   integer :: n
+   real, contiguous, pointer :: z(:,:,:)
+   z = 0
+end subroutine
+
+subroutine test6 (n, z)
+   implicit none
+   integer :: n
+   real, contiguous, pointer :: z(:,:,:)
+   z(:,::1,:) = 0
+end subroutine
+
+! { dg-final { scan-tree-dump-times "__builtin_memset" 5 "original" } }


[gcc r15-2801] Partially support streaming of poly_int for offloading.

2024-08-07 Thread Prathamesh Kulkarni via Gcc-cvs
https://gcc.gnu.org/g:38900247f3880d6eca2e364a000e5898f8deae64

commit r15-2801-g38900247f3880d6eca2e364a000e5898f8deae64
Author: Prathamesh Kulkarni 
Date:   Wed Aug 7 23:45:38 2024 +0530

Partially support streaming of poly_int for offloading.

When offloading is enabled, the patch streams out host
NUM_POLY_INT_COEFFS, and changes streaming in as follows:

if (host_num_poly_int_coeffs <= NUM_POLY_INT_COEFFS)
{
  for (i = 0; i < host_num_poly_int_coeffs; i++)
poly_int.coeffs[i] = stream_in coeff;
  for (; i < NUM_POLY_INT_COEFFS; i++)
poly_int.coeffs[i] = 0;
}
else
{
  for (i = 0; i < NUM_POLY_INT_COEFFS; i++)
poly_int.coeffs[i] = stream_in coeff;

  /* Ensure that degree of poly_int <= accel NUM_POLY_INT_COEFFS.  */
  for (; i < host_num_poly_int_coeffs; i++)
{
  val = stream_in coeff;
  if (val != 0)
error ();
}
}

gcc/ChangeLog:
PR ipa/96265
PR ipa/111937
* data-streamer-in.cc (streamer_read_poly_uint64): Remove code for
streaming, and call poly_int_read_common instead.
(streamer_read_poly_int64): Likewise.
* data-streamer.cc (host_num_poly_int_coeffs): Conditionally define
new variable if ACCEL_COMPILER is defined.
* data-streamer.h (host_num_poly_int_coeffs): Declare.
(poly_int_read_common): New function template.
(bp_unpack_poly_value): Remove code for streaming and call
poly_int_read_common instead.
* lto-streamer-in.cc (lto_input_mode_table): Stream-in host
NUM_POLY_INT_COEFFS into host_num_poly_int_coeffs if ACCEL_COMPILER
is defined.
* lto-streamer-out.cc (lto_write_mode_table): Stream out
NUM_POLY_INT_COEFFS if offloading is enabled.
* poly-int.h (MAX_NUM_POLY_INT_COEFFS_BITS): New macro.
* tree-streamer-in.cc (lto_input_ts_poly_tree_pointers): Adjust
streaming-in of poly_int.

Signed-off-by: Prathamesh Kulkarni 

Diff:
---
 gcc/data-streamer-in.cc | 12 
 gcc/data-streamer.cc|  8 
 gcc/data-streamer.h | 49 +
 gcc/lto-streamer-in.cc  |  5 +
 gcc/lto-streamer-out.cc |  3 +++
 gcc/poly-int.h  |  4 
 gcc/tree-streamer-in.cc | 33 +++--
 7 files changed, 100 insertions(+), 14 deletions(-)

diff --git a/gcc/data-streamer-in.cc b/gcc/data-streamer-in.cc
index 7dce2928ef03..07dbc5e2bc36 100644
--- a/gcc/data-streamer-in.cc
+++ b/gcc/data-streamer-in.cc
@@ -182,10 +182,8 @@ streamer_read_hwi (class lto_input_block *ib)
 poly_uint64
 streamer_read_poly_uint64 (class lto_input_block *ib)
 {
-  poly_uint64 res;
-  for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
-res.coeffs[i] = streamer_read_uhwi (ib);
-  return res;
+  using coeff_type = poly_int_traits::coeff_type;
+  return poly_int_read_common (streamer_read_uhwi, ib);
 }
 
 /* Read a poly_int64 from IB.  */
@@ -193,10 +191,8 @@ streamer_read_poly_uint64 (class lto_input_block *ib)
 poly_int64
 streamer_read_poly_int64 (class lto_input_block *ib)
 {
-  poly_int64 res;
-  for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
-res.coeffs[i] = streamer_read_hwi (ib);
-  return res;
+  using coeff_type = poly_int_traits::coeff_type;
+  return poly_int_read_common (streamer_read_hwi, ib);
 }
 
 /* Read gcov_type value from IB.  */
diff --git a/gcc/data-streamer.cc b/gcc/data-streamer.cc
index 346b294c72ac..896413e8d2b6 100644
--- a/gcc/data-streamer.cc
+++ b/gcc/data-streamer.cc
@@ -28,6 +28,14 @@ along with GCC; see the file COPYING3.  If not see
 #include "cgraph.h"
 #include "data-streamer.h"
 
+/* For offloading -- While streaming-out, host NUM_POLY_INT_COEFFS is
+   stored at beginning of mode_table.  While streaming-in, the value is read
+   in host_num_poly_int_coeffs.  */
+
+#ifdef ACCEL_COMPILER
+unsigned host_num_poly_int_coeffs = 0;
+#endif
+
 /* Pack WORK into BP in a variant of uleb format.  */
 
 void
diff --git a/gcc/data-streamer.h b/gcc/data-streamer.h
index 6a2596134ceb..b3dc4b984767 100644
--- a/gcc/data-streamer.h
+++ b/gcc/data-streamer.h
@@ -50,6 +50,7 @@ void bp_pack_real_value (struct bitpack_d *, const 
REAL_VALUE_TYPE *);
 void bp_unpack_real_value (struct bitpack_d *, REAL_VALUE_TYPE *);
 unsigned HOST_WIDE_INT bp_unpack_var_len_unsigned (struct bitpack_d *);
 HOST_WIDE_INT bp_unpack_var_len_int (struct bitpack_d *);
+extern unsigned host_num_poly_int_coeffs;
 
 /* In data-streamer-out.cc  */
 void streamer_write_zero (struct output_block *);
@@ -194,15 +195,55 @@ bp_unpack_value (struct bitpack_d *bp, unsigned nbits)
   return val & mask;
 }
 
+/* Common code for reading poly_int.  */
+
+template
+poly_int
+poly_int_read_common (F read_coeff, Args ...args)
+{
+  poly_int x;
+  unsigned i;
+
+#ifdef ACCEL_COMPILER
+  /* Ensur

[gcc r15-4133] Recompute TYPE_MODE and DECL_MODE for vector_type for accelerator.

2024-10-08 Thread Prathamesh Kulkarni via Gcc-cvs
https://gcc.gnu.org/g:ae88da5e070659d37b3c3daa4b880531769183bf

commit r15-4133-gae88da5e070659d37b3c3daa4b880531769183bf
Author: Prathamesh Kulkarni 
Date:   Tue Oct 8 12:38:31 2024 +0530

Recompute TYPE_MODE and DECL_MODE for vector_type for accelerator.

gcc/ChangeLog:
PR ipa/96265
* lto-streamer-in.cc (lto_read_tree_1): Set TYPE_MODE and DECL_MODE
for vector_type if offloading is enabled.
(lto_input_mode_table): Remove handling of vector modes.
* tree-streamer-out.cc (pack_ts_decl_common_value_fields): Stream 
out
VOIDmode for vector_type if offloading is enabled.
(pack_ts_decl_common_value_fields): Likewise.

Signed-off-by: Prathamesh Kulkarni 

Diff:
---
 gcc/lto-streamer-in.cc   | 38 --
 gcc/tree-streamer-out.cc |  6 --
 2 files changed, 28 insertions(+), 16 deletions(-)

diff --git a/gcc/lto-streamer-in.cc b/gcc/lto-streamer-in.cc
index 9d0ec5d589c4..15181c3f5746 100644
--- a/gcc/lto-streamer-in.cc
+++ b/gcc/lto-streamer-in.cc
@@ -1753,16 +1753,30 @@ lto_read_tree_1 (class lto_input_block *ib, class 
data_in *data_in, tree expr)
 with -g1, see for example PR113488.  */
   else if (DECL_P (expr) && DECL_ABSTRACT_ORIGIN (expr) == expr)
DECL_ABSTRACT_ORIGIN (expr) = NULL_TREE;
+}
 
 #ifdef ACCEL_COMPILER
-  if ((VAR_P (expr)
-  || TREE_CODE (expr) == PARM_DECL
-  || TREE_CODE (expr) == FIELD_DECL)
- && AGGREGATE_TYPE_P (TREE_TYPE (expr))
- && DECL_MODE (expr) == VOIDmode)
-   SET_DECL_MODE (expr, TYPE_MODE (TREE_TYPE (expr)));
-#endif
+  if ((VAR_P (expr)
+   || TREE_CODE (expr) == PARM_DECL
+   || TREE_CODE (expr) == FIELD_DECL)
+  && DECL_MODE (expr) == VOIDmode)
+{
+  tree type = TREE_TYPE (expr);
+  if (AGGREGATE_TYPE_P (type))
+   SET_DECL_MODE (expr, TYPE_MODE (type));
+  else if (VECTOR_TYPE_P (type))
+   SET_DECL_MODE (expr, TYPE_MODE_RAW (type));
 }
+
+  if (VECTOR_TYPE_P (expr) && TYPE_MODE (expr) == VOIDmode)
+{
+  poly_uint64 nunits = TYPE_VECTOR_SUBPARTS (expr);
+  tree innertype = TREE_TYPE (expr);
+  machine_mode vmode
+   = mode_for_vector (SCALAR_TYPE_MODE (innertype), nunits).else_blk ();
+  SET_TYPE_MODE (expr, vmode);
+}
+#endif
 }
 
 /* Read the physical representation of a tree node with tag TAG from
@@ -2106,13 +2120,9 @@ lto_input_mode_table (struct lto_file_decl_data 
*file_data)
case MODE_VECTOR_UFRACT:
case MODE_VECTOR_ACCUM:
case MODE_VECTOR_UACCUM:
- /* For unsupported vector modes just use BLKmode,
-if the scalar mode is supported.  */
- if (table[(int) inner] != VOIDmode)
-   {
- table[m] = BLKmode;
- break;
-   }
+ /* Vector modes are recomputed on accel side and shouldn't have
+been streamed-out from host.  */
+ gcc_unreachable ();
  /* FALLTHRU */
default:
  /* This is only used for offloading-target compilations and
diff --git a/gcc/tree-streamer-out.cc b/gcc/tree-streamer-out.cc
index 7de4447a1b53..81f5aeb30a6d 100644
--- a/gcc/tree-streamer-out.cc
+++ b/gcc/tree-streamer-out.cc
@@ -194,7 +194,8 @@ pack_ts_decl_common_value_fields (struct bitpack_d *bp, 
tree expr)
   && (VAR_P (expr)
  || TREE_CODE (expr) == PARM_DECL
  || TREE_CODE (expr) == FIELD_DECL)
-  && AGGREGATE_TYPE_P (TREE_TYPE (expr)))
+  && (AGGREGATE_TYPE_P (TREE_TYPE (expr))
+ || VECTOR_TYPE_P (TREE_TYPE (expr
 bp_pack_machine_mode (bp, VOIDmode);
   else
 bp_pack_machine_mode (bp, DECL_MODE (expr));
@@ -332,7 +333,8 @@ pack_ts_type_common_value_fields (struct bitpack_d *bp, 
tree expr)
  whose size is 256-bits, which is not representable on accelerator.
  Instead stream out VOIDmode, and while streaming-in, recompute
  appropriate TYPE_MODE for accelerator.  */
-  if (lto_stream_offload_p && AGGREGATE_TYPE_P (expr))
+  if (lto_stream_offload_p
+  && (AGGREGATE_TYPE_P (expr) || VECTOR_TYPE_P (expr)))
 bp_pack_machine_mode (bp, VOIDmode);
   /* for VECTOR_TYPE, TYPE_MODE reevaluates the mode using target_flags
  not necessary valid in a global context.


[gcc r15-3816] nvptx: Partial support for aliases to aliases.

2024-09-23 Thread Prathamesh Kulkarni via Gcc-cvs
https://gcc.gnu.org/g:f5ee372b012594830f6d5f7f4b7e01bae810b1da

commit r15-3816-gf5ee372b012594830f6d5f7f4b7e01bae810b1da
Author: Prathamesh Kulkarni 
Date:   Tue Sep 24 08:18:48 2024 +0530

nvptx: Partial support for aliases to aliases.

For the following test (adapted from pr96390.c):

__attribute__((noipa)) int foo () { return 42; }
int bar () __attribute__((alias ("foo")));
int baz () __attribute__((alias ("bar")));

int main ()
{
  int n;
  #pragma omp target map(from:n)
n = baz ();
  return n;
}

gcc emits following ptx for baz:
.visible .func (.param.u32 %value_out) bar;
.alias bar,foo;
.visible .func (.param.u32 %value_out) baz;
.alias baz,bar;

which is incorrect since PTX requires aliasee to be a defined function.
The patch instead uses cgraph_node::get(name)->ultimate_alias_target,
which generates the following PTX:

.visible .func (.param.u32 %value_out) baz;
.alias baz,foo;

gcc/ChangeLog:
PR target/104957
* config/nvptx/nvptx.cc (nvptx_asm_output_def_from_decls): Use
cgraph_node::get(name)->ultimate_alias_target instead of value.

gcc/testsuite/ChangeLog:
PR target/104957
* gcc.target/nvptx/alias-to-alias-1.c: Adjust.

Signed-off-by: Prathamesh Kulkarni 
Co-authored-by: Thomas Schwinge 

Diff:
---
 gcc/config/nvptx/nvptx.cc | 24 ---
 gcc/testsuite/gcc.target/nvptx/alias-to-alias-1.c |  6 --
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc
index 4a7c64f05eb8..96a1134220ed 100644
--- a/gcc/config/nvptx/nvptx.cc
+++ b/gcc/config/nvptx/nvptx.cc
@@ -7582,7 +7582,8 @@ nvptx_mem_local_p (rtx mem)
   while (0)
 
 void
-nvptx_asm_output_def_from_decls (FILE *stream, tree name, tree value)
+nvptx_asm_output_def_from_decls (FILE *stream, tree name,
+tree value ATTRIBUTE_UNUSED)
 {
   if (nvptx_alias == 0 || !TARGET_PTX_6_3)
 {
@@ -7617,7 +7618,8 @@ nvptx_asm_output_def_from_decls (FILE *stream, tree name, 
tree value)
   return;
 }
 
-  if (!cgraph_node::get (name)->referred_to_p ())
+  cgraph_node *cnode = cgraph_node::get (name);
+  if (!cnode->referred_to_p ())
 /* Prevent "Internal error: reference to deleted section".  */
 return;
 
@@ -7626,11 +7628,27 @@ nvptx_asm_output_def_from_decls (FILE *stream, tree 
name, tree value)
   fputs (s.str ().c_str (), stream);
 
   tree id = DECL_ASSEMBLER_NAME (name);
+
+  /* Walk alias chain to get reference callgraph node.
+ The rationale of using ultimate_alias_target here is that
+ PTX's .alias directive only supports 1-level aliasing where
+ aliasee is function defined in same module.
+
+ So for the following case:
+ int foo() { return 42; }
+ int bar () __attribute__((alias ("foo")));
+ int baz () __attribute__((alias ("bar")));
+
+ should resolve baz to foo:
+ .visible .func (.param.u32 %value_out) baz;
+ .alias baz,foo;  */
+  symtab_node *alias_target_node = cnode->ultimate_alias_target ();
+  tree alias_target_id = DECL_ASSEMBLER_NAME (alias_target_node->decl);
   std::stringstream s_def;
   write_fn_marker (s_def, true, TREE_PUBLIC (name), IDENTIFIER_POINTER (id));
   fputs (s_def.str ().c_str (), stream);
   NVPTX_ASM_OUTPUT_DEF (stream, IDENTIFIER_POINTER (id),
-   IDENTIFIER_POINTER (value));
+   IDENTIFIER_POINTER (alias_target_id));
 }
 
 #undef NVPTX_ASM_OUTPUT_DEF
diff --git a/gcc/testsuite/gcc.target/nvptx/alias-to-alias-1.c 
b/gcc/testsuite/gcc.target/nvptx/alias-to-alias-1.c
index 7bce7a358c79..08de9e6d69da 100644
--- a/gcc/testsuite/gcc.target/nvptx/alias-to-alias-1.c
+++ b/gcc/testsuite/gcc.target/nvptx/alias-to-alias-1.c
@@ -1,6 +1,8 @@
 /* Alias to alias; 'libgomp.c-c++-common/pr96390.c'.  */
 
-/* { dg-do compile } */
+/* { dg-do link } */
+/* { dg-do run { target nvptx_runtime_alias_ptx } } */
+/* { dg-options -save-temps } */
 /* { dg-add-options nvptx_alias_ptx } */
 
 int v;
@@ -32,7 +34,7 @@ main (void)
 /* { dg-final { scan-assembler-times {(?n)^// BEGIN GLOBAL FUNCTION DECL: 
baz$} 1 } }
{ dg-final { scan-assembler-times {(?n)^\.visible \.func baz;$} 1 } }
{ dg-final { scan-assembler-times {(?n)^// BEGIN GLOBAL FUNCTION DEF: baz$} 
1 } }
-   { dg-final { scan-assembler-times {(?n)^\.alias baz,bar;$} 1 } } */
+   { dg-final { scan-assembler-times {(?n)^\.alias baz,foo;$} 1 } } */
 
 /* { dg-final { scan-assembler-times {(?n)\tcall foo;$} 0 } }
{ dg-final { scan-assembler-times {(?n)\tcall bar;$} 0 } }


[gcc r15-6341] Revert "PR81358: Enable automatic linking of libatomic."

2024-12-18 Thread Prathamesh Kulkarni via Gcc-cvs
https://gcc.gnu.org/g:17d8a3da25cd5262df1075b210cb4fa707c527df

commit r15-6341-g17d8a3da25cd5262df1075b210cb4fa707c527df
Author: Prathamesh Kulkarni 
Date:   Wed Dec 18 22:03:38 2024 +0530

Revert "PR81358: Enable automatic linking of libatomic."

This reverts commit e2f6ed54f75bbf8dd0292af90304890f06a9be17.

Diff:
---
 Makefile.def   |  20 -
 Makefile.in| 113 -
 Makefile.tpl   |   1 -
 configure  |   5 ---
 configure.ac   |   5 ---
 gcc/common.opt |   3 --
 gcc/config.in  |   6 ---
 gcc/config/gnu-user.h  |   3 +-
 gcc/configure  |   6 ---
 gcc/configure.ac   |   5 ---
 gcc/doc/invoke.texi|   6 +--
 gcc/gcc.cc |   7 ---
 libatomic/Makefile.am  |   7 +--
 libatomic/Makefile.in  |   6 +--
 libatomic/configure|  29 +++--
 libatomic/configure.ac |  25 +++
 16 files changed, 16 insertions(+), 231 deletions(-)

diff --git a/Makefile.def b/Makefile.def
index 90899fa28cf0..19954e7d7318 100644
--- a/Makefile.def
+++ b/Makefile.def
@@ -656,26 +656,6 @@ lang_env_dependencies = { module=libgcc; no_gcc=true; 
no_c=true; };
 // a dependency on libgcc for native targets to configure.
 lang_env_dependencies = { module=libiberty; no_c=true; };
 
-dependencies = { module=configure-target-libbacktrace; 
on=all-target-libatomic; };
-dependencies = { module=configure-target-libgloss; on=all-target-libatomic; };
-dependencies = { module=configure-target-newlib; on=all-target-libatomic; };
-dependencies = { module=configure-target-libgomp; on=all-target-libatomic; };
-dependencies = { module=configure-target-libitm; on=all-target-libatomic; };
-dependencies = { module=configure-target-libstdc++v3; on=all-target-libatomic; 
};
-dependencies = { module=configure-target-libsanitizer; 
on=all-target-libatomic; };
-dependencies = { module=configure-target-libvtv; on=all-target-libatomic; };
-dependencies = { module=configure-target-libssp; on=all-target-libatomic; };
-dependencies = { module=configure-target-libquadmath; on=all-target-libatomic; 
};
-dependencies = { module=configure-target-libgfortran; on=all-target-libatomic; 
};
-dependencies = { module=configure-target-libffi; on=all-target-libatomic; };
-dependencies = { module=configure-target-libobjc; on=all-target-libatomic; };
-dependencies = { module=configure-target-libada; on=all-target-libatomic; };
-dependencies = { module=configure-target-libgm2; on=all-target-libatomic; };
-dependencies = { module=configure-target-libgo; on=all-target-libatomic; };
-dependencies = { module=configure-target-libgrust; on=all-target-libatomic; };
-dependencies = { module=configure-target-libphobos; on=all-target-libatomic; };
-dependencies = { module=configure-target-zlib; on=all-target-libatomic; };
-
 dependencies = { module=configure-target-fastjar; on=configure-target-zlib; };
 dependencies = { module=all-target-fastjar; on=all-target-zlib; };
 dependencies = { module=configure-target-libgo; on=configure-target-libffi; };
diff --git a/Makefile.in b/Makefile.in
index 4a85f11d7e66..966d60454960 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -242,7 +242,6 @@ HOST_EXPORTS = \
GMPINC="$(HOST_GMPINC)"; export GMPINC; \
ISLLIBS="$(HOST_ISLLIBS)"; export ISLLIBS; \
ISLINC="$(HOST_ISLINC)"; export ISLINC; \
-   TARGET_CONFIGDIRS="$(TARGET_CONFIGDIRS)"; export TARGET_CONFIGDIRS; \
XGCC_FLAGS_FOR_TARGET="$(XGCC_FLAGS_FOR_TARGET)"; export 
XGCC_FLAGS_FOR_TARGET; \
 @if gcc-bootstrap
$(RPATH_ENVVAR)=`echo "$(TARGET_LIB_PATH)$$$(RPATH_ENVVAR)" | sed 
's,::*,:,g;s,^:*,,;s,:*$$,,'`; export $(RPATH_ENVVAR); \
@@ -68552,66 +68551,6 @@ all-flex: maybe-all-build-bison
 all-flex: maybe-all-m4
 all-flex: maybe-all-build-texinfo
 all-m4: maybe-all-build-texinfo
-configure-target-libbacktrace: maybe-all-target-libatomic
-configure-stage1-target-libbacktrace: maybe-all-stage1-target-libatomic
-configure-stage2-target-libbacktrace: maybe-all-stage2-target-libatomic
-configure-stage3-target-libbacktrace: maybe-all-stage3-target-libatomic
-configure-stage4-target-libbacktrace: maybe-all-stage4-target-libatomic
-configure-stageprofile-target-libbacktrace: 
maybe-all-stageprofile-target-libatomic
-configure-stagetrain-target-libbacktrace: maybe-all-stagetrain-target-libatomic
-configure-stagefeedback-target-libbacktrace: 
maybe-all-stagefeedback-target-libatomic
-configure-stageautoprofile-target-libbacktrace: 
maybe-all-stageautoprofile-target-libatomic
-configure-stageautofeedback-target-libbacktrace: 
maybe-all-stageautofeedback-target-libatomic
-configure-target-libgomp: maybe-all-target-libatomic
-configure-stage1-target-libgomp: maybe-all-stage1-target-libatomic
-configure-stage2-target-libgomp: maybe-all-stage2-target-libatomic
-configure-stage3-target-libgomp: maybe-all-stage3-target-libatomic
-configure-stage4-target-libgomp: maybe-all-stage4-target-libatomic
-configure-stageprofile-

[gcc r15-6337] PR81358: Enable automatic linking of libatomic.

2024-12-18 Thread Prathamesh Kulkarni via Gcc-cvs
https://gcc.gnu.org/g:e2f6ed54f75bbf8dd0292af90304890f06a9be17

commit r15-6337-ge2f6ed54f75bbf8dd0292af90304890f06a9be17
Author: Prathamesh Kulkarni 
Date:   Wed Dec 18 17:03:51 2024 +0530

PR81358: Enable automatic linking of libatomic.

ChangeLog:
PR driver/81358
* Makefile.def: Add dependencies so libatomic is built before target
libraries are configured.
* Makefile.tpl: Export TARGET_CONFIGDIRS.
* configure.ac: Add libatomic to bootstrap_target_libs.
* Makefile.in: Regenerate.
* configure: Regenerate.

gcc/ChangeLog:
PR driver/81358
* common.opt: New option -flink-libatomic.
* gcc.cc (LINK_LIBATOMIC_SPEC): New macro.
* config/gnu-user.h (GNU_USER_TARGET_LINK_GCC_C_SEQUENCE_SPEC): Use
LINK_LIBATOMIC_SPEC.
* doc/invoke.texi: Document -flink-libatomic.
* configure.ac: Define TARGET_PROVIDES_LIBATOMIC.
* configure: Regenerate.
* config.in: Regenerate.

libatomic/ChangeLog:
PR driver/81358
* Makefile.am: Pass -fno-link-libatomic.
New rule all.
* configure.ac: Assert that CFLAGS is set and pass 
-fno-link-libatomic.
* Makefile.in: Regenerate.
* configure: Regenerate.

Signed-off-by: Prathamesh Kulkarni 
Co-authored-by: Matthew Malcolmson 

Diff:
---
 Makefile.def   |  20 +
 Makefile.in| 113 +
 Makefile.tpl   |   1 +
 configure  |   5 +++
 configure.ac   |   5 +++
 gcc/common.opt |   3 ++
 gcc/config.in  |   6 +++
 gcc/config/gnu-user.h  |   3 +-
 gcc/configure  |   6 +++
 gcc/configure.ac   |   5 +++
 gcc/doc/invoke.texi|   6 ++-
 gcc/gcc.cc |   7 +++
 libatomic/Makefile.am  |   7 ++-
 libatomic/Makefile.in  |   6 ++-
 libatomic/configure|  29 ++---
 libatomic/configure.ac |  25 ---
 16 files changed, 231 insertions(+), 16 deletions(-)

diff --git a/Makefile.def b/Makefile.def
index 19954e7d7318..90899fa28cf0 100644
--- a/Makefile.def
+++ b/Makefile.def
@@ -656,6 +656,26 @@ lang_env_dependencies = { module=libgcc; no_gcc=true; 
no_c=true; };
 // a dependency on libgcc for native targets to configure.
 lang_env_dependencies = { module=libiberty; no_c=true; };
 
+dependencies = { module=configure-target-libbacktrace; 
on=all-target-libatomic; };
+dependencies = { module=configure-target-libgloss; on=all-target-libatomic; };
+dependencies = { module=configure-target-newlib; on=all-target-libatomic; };
+dependencies = { module=configure-target-libgomp; on=all-target-libatomic; };
+dependencies = { module=configure-target-libitm; on=all-target-libatomic; };
+dependencies = { module=configure-target-libstdc++v3; on=all-target-libatomic; 
};
+dependencies = { module=configure-target-libsanitizer; 
on=all-target-libatomic; };
+dependencies = { module=configure-target-libvtv; on=all-target-libatomic; };
+dependencies = { module=configure-target-libssp; on=all-target-libatomic; };
+dependencies = { module=configure-target-libquadmath; on=all-target-libatomic; 
};
+dependencies = { module=configure-target-libgfortran; on=all-target-libatomic; 
};
+dependencies = { module=configure-target-libffi; on=all-target-libatomic; };
+dependencies = { module=configure-target-libobjc; on=all-target-libatomic; };
+dependencies = { module=configure-target-libada; on=all-target-libatomic; };
+dependencies = { module=configure-target-libgm2; on=all-target-libatomic; };
+dependencies = { module=configure-target-libgo; on=all-target-libatomic; };
+dependencies = { module=configure-target-libgrust; on=all-target-libatomic; };
+dependencies = { module=configure-target-libphobos; on=all-target-libatomic; };
+dependencies = { module=configure-target-zlib; on=all-target-libatomic; };
+
 dependencies = { module=configure-target-fastjar; on=configure-target-zlib; };
 dependencies = { module=all-target-fastjar; on=all-target-zlib; };
 dependencies = { module=configure-target-libgo; on=configure-target-libffi; };
diff --git a/Makefile.in b/Makefile.in
index 966d60454960..4a85f11d7e66 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -242,6 +242,7 @@ HOST_EXPORTS = \
GMPINC="$(HOST_GMPINC)"; export GMPINC; \
ISLLIBS="$(HOST_ISLLIBS)"; export ISLLIBS; \
ISLINC="$(HOST_ISLINC)"; export ISLINC; \
+   TARGET_CONFIGDIRS="$(TARGET_CONFIGDIRS)"; export TARGET_CONFIGDIRS; \
XGCC_FLAGS_FOR_TARGET="$(XGCC_FLAGS_FOR_TARGET)"; export 
XGCC_FLAGS_FOR_TARGET; \
 @if gcc-bootstrap
$(RPATH_ENVVAR)=`echo "$(TARGET_LIB_PATH)$$$(RPATH_ENVVAR)" | sed 
's,::*,:,g;s,^:*,,;s,:*$$,,'`; export $(RPATH_ENVVAR); \
@@ -68551,6 +68552,66 @@ all-flex: maybe-all-build-bison
 all-flex: maybe-all-m4
 all-flex: maybe-all-build-texinfo
 all-m4: maybe-all-build-texinfo
+configur