[gcc r15-9450] gccrs: attributes: Add missing attributes used in `core`

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:34c516efbb8dce4bffe09045e6b941806744d1fd

commit r15-9450-g34c516efbb8dce4bffe09045e6b941806744d1fd
Author: Arthur Cohen 
Date:   Fri Apr 4 14:20:04 2025 +0200

gccrs: attributes: Add missing attributes used in `core`

gcc/rust/ChangeLog:

* util/rust-attribute-values.h: Add missing attributes.
* util/rust-attributes.cc: Likewise.
* util/rust-attributes.h (enum CompilerPass): Mention adding 
something for const
functions.

Diff:
---
 gcc/rust/util/rust-attribute-values.h | 24 
 gcc/rust/util/rust-attributes.cc  | 20 +++-
 gcc/rust/util/rust-attributes.h   |  2 ++
 3 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/gcc/rust/util/rust-attribute-values.h 
b/gcc/rust/util/rust-attribute-values.h
index d579fa298013..50ccb4ab6dc0 100644
--- a/gcc/rust/util/rust-attribute-values.h
+++ b/gcc/rust/util/rust-attribute-values.h
@@ -40,12 +40,14 @@ public:
   static constexpr auto &NO_MANGLE = "no_mangle";
   static constexpr auto &REPR = "repr";
   static constexpr auto &RUSTC_BUILTIN_MACRO = "rustc_builtin_macro";
+  static constexpr auto &RUSTC_MACRO_TRANSPARENCY = "rustc_macro_transparency";
   static constexpr auto &PATH = "path";
   static constexpr auto &MACRO_USE = "macro_use";
   static constexpr auto &MACRO_EXPORT = "macro_export";
   static constexpr auto &PROC_MACRO = "proc_macro";
   static constexpr auto &PROC_MACRO_DERIVE = "proc_macro_derive";
   static constexpr auto &PROC_MACRO_ATTRIBUTE = "proc_macro_attribute";
+
   static constexpr auto &TARGET_FEATURE = "target_feature";
   // From now on, these are reserved by the compiler and gated through
   // #![feature(rustc_attrs)]
@@ -54,11 +56,33 @@ public:
 = "rustc_inherit_overflow_checks";
   static constexpr auto &STABLE = "stable";
   static constexpr auto &UNSTABLE = "unstable";
+
+  static constexpr auto &RUSTC_PROMOTABLE = "rustc_promotable";
   static constexpr auto &RUSTC_CONST_STABLE = "rustc_const_stable";
   static constexpr auto &RUSTC_CONST_UNSTABLE = "rustc_const_unstable";
+
+  static constexpr auto &RUSTC_SPECIALIZATION_TRAIT
+= "rustc_specialization_trait";
+  static constexpr auto &RUSTC_UNSAFE_SPECIALIZATION_MARKER
+= "rustc_unsafe_specialization_marker";
+  static constexpr auto &RUSTC_RESERVATION_IMPL = "rustc_reservation_impl";
+  static constexpr auto &RUSTC_PAREN_SUGAR = "rustc_paren_sugar";
+  static constexpr auto &RUSTC_NONNULL_OPTIMIZATION_GUARANTEED
+= "rustc_nonnull_optimization_guaranteed";
+
+  static constexpr auto &RUSTC_LAYOUT_SCALAR_VALID_RANGE_START
+= "rustc_layout_scalar_valid_range_start";
+
   static constexpr auto &MAY_DANGLE = "may_dangle";
   static constexpr auto &PRELUDE_IMPORT = "prelude_import";
   static constexpr auto &TRACK_CALLER = "track_caller";
+
+  static constexpr auto &RUSTC_DIAGNOSTIC_ITEM = "rustc_diagnostic_item";
+  static constexpr auto &RUSTC_ON_UNIMPLEMENTED = "rustc_on_unimplemented";
+
+  static constexpr auto &FUNDAMENTAL = "fundamental";
+
+  static constexpr auto &NON_EXHAUSTIVE = "non_exhaustive";
 };
 } // namespace Values
 } // namespace Rust
diff --git a/gcc/rust/util/rust-attributes.cc b/gcc/rust/util/rust-attributes.cc
index df0fe1b0bcac..7ddb476bbe6f 100644
--- a/gcc/rust/util/rust-attributes.cc
+++ b/gcc/rust/util/rust-attributes.cc
@@ -57,6 +57,7 @@ static const BuiltinAttrDefinition __definitions[]
  {Attrs::NO_MANGLE, CODE_GENERATION},
  {Attrs::REPR, CODE_GENERATION},
  {Attrs::RUSTC_BUILTIN_MACRO, EXPANSION},
+ {Attrs::RUSTC_MACRO_TRANSPARENCY, EXPANSION},
  {Attrs::PATH, EXPANSION},
  {Attrs::MACRO_USE, NAME_RESOLUTION},
  {Attrs::MACRO_EXPORT, NAME_RESOLUTION},
@@ -72,11 +73,28 @@ static const BuiltinAttrDefinition __definitions[]
  {Attrs::RUSTC_INHERIT_OVERFLOW_CHECKS, CODE_GENERATION},
  {Attrs::STABLE, STATIC_ANALYSIS},
  {Attrs::UNSTABLE, STATIC_ANALYSIS},
+
  // assuming we keep these for static analysis
+ {Attrs::RUSTC_PROMOTABLE, CODE_GENERATION},
  {Attrs::RUSTC_CONST_STABLE, STATIC_ANALYSIS},
  {Attrs::RUSTC_CONST_UNSTABLE, STATIC_ANALYSIS},
  {Attrs::PRELUDE_IMPORT, NAME_RESOLUTION},
- {Attrs::TRACK_CALLER, CODE_GENERATION}};
+ {Attrs::TRACK_CALLER, CODE_GENERATION},
+ {Attrs::RUSTC_SPECIALIZATION_TRAIT, TYPE_CHECK},
+ {Attrs::RUSTC_UNSAFE_SPECIALIZATION_MARKER, TYPE_CHECK},
+ {Attrs::RUSTC_RESERVATION_IMPL, TYPE_CHECK},
+ {Attrs::RUSTC_PAREN_SUGAR, TYPE_CHECK},
+ {Attrs::RUSTC_NONNULL_OPTIMIZATION_GUARANTEED, TYPE_CHECK},
+
+ {Attrs::RUSTC_LAYOUT_SCALAR_VALID_RANGE_START, CODE_GENERATION},
+
+ {Attrs::PRELUDE_IMPORT, NAME_RESOLUTION},
+
+ {Attrs::RUSTC_DIAGNOSTIC_ITEM, STATIC_ANALYSIS},
+ {Attrs::RUSTC_ON_UNIMPLEMENTED, STATIC_ANALYSIS},
+
+ {Attrs::FUNDAMENTAL, TYPE_CHECK},
+ {Attrs::NON_EXHAUSTIVE, TYPE_CHECK}};
 
 BuiltinAttributeMappings *
 BuiltinAttributeMappings::get ()
diff --

[gcc r15-9451] gccrs: nr2.0: Only insert derive macros if they exist

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:9ed95c06977068cce86b5d35aee905533c757d57

commit r15-9451-g9ed95c06977068cce86b5d35aee905533c757d57
Author: Arthur Cohen 
Date:   Wed Apr 9 14:48:55 2025 +0200

gccrs: nr2.0: Only insert derive macros if they exist

This causes an assertion failure when compiling core with nr2.0, but should
probably be improved. I'm not sure how this code enables built-in derive
macros to be resolved so this is a temporary fix.

gcc/rust/ChangeLog:

* resolve/rust-early-name-resolver-2.0.cc 
(Early::visit_attributes): Remove assertion.

Diff:
---
 gcc/rust/resolve/rust-early-name-resolver-2.0.cc | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc 
b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
index afaca1f71f03..36456e10ff26 100644
--- a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
@@ -325,10 +325,9 @@ Early::visit_attributes (std::vector 
&attrs)
  auto pm_def = mappings.lookup_derive_proc_macro_def (
definition->get_node_id ());
 
- rust_assert (pm_def.has_value ());
-
- mappings.insert_derive_proc_macro_invocation (trait,
-   pm_def.value ());
+ if (pm_def.has_value ())
+   mappings.insert_derive_proc_macro_invocation (trait,
+ pm_def.value ());
}
}
   else if (Analysis::BuiltinAttributeMappings::get ()


[gcc r15-9448] gccrs: install.texi: Mention Rust requirement for building gccrs

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:497ed6099b2c9f8f37b0acca5b7e2800ee1d9331

commit r15-9448-g497ed6099b2c9f8f37b0acca5b7e2800ee1d9331
Author: Arthur Cohen 
Date:   Tue Apr 1 13:00:56 2025 +0200

gccrs: install.texi: Mention Rust requirement for building gccrs

Addresses PR#117869

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117869

gcc/ChangeLog:

* doc/install.texi: Add requirements for building gccrs.

Diff:
---
 gcc/doc/install.texi | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index b5509ff0c86b..1af0082ed772 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -350,6 +350,12 @@ documentation including the target @code{SYSTEM} 
definition module.
 If Python3 is unavailable Modula-2 documentation will include a target
 independent version of the SYSTEM modules.
 
+@item @anchor{gccrs-prerequisite}gccrs
+
+The official Rust compiler and Rust build system (cargo) are required for
+building various parts of the gccrs frontend, until gccrs can compile them
+by itself. The minimum supported Rust version is 1.49.
+
 @item A ``working'' POSIX compatible shell, or GNU bash
 
 Necessary when running @command{configure} because some


[gcc r15-9453] gccrs: lang-items: Add ManuallyDrop

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:901d94e8b4eb9a273e9e75d5586cb5abde73a7a6

commit r15-9453-g901d94e8b4eb9a273e9e75d5586cb5abde73a7a6
Author: Arthur Cohen 
Date:   Tue Apr 8 17:04:09 2025 +0200

gccrs: lang-items: Add ManuallyDrop

gcc/rust/ChangeLog:

* util/rust-lang-item.h: Add new manually_drop lang item.
* util/rust-lang-item.cc: Likewise.

Diff:
---
 gcc/rust/util/rust-lang-item.cc | 1 +
 gcc/rust/util/rust-lang-item.h  | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/gcc/rust/util/rust-lang-item.cc b/gcc/rust/util/rust-lang-item.cc
index a76cc7ff6519..9aff31b657c8 100644
--- a/gcc/rust/util/rust-lang-item.cc
+++ b/gcc/rust/util/rust-lang-item.cc
@@ -118,6 +118,7 @@ const BiMap 
Rust::LangItem::lang_items = {{
 
   {"discriminant_kind", Kind::DISCRIMINANT_KIND},
   {"discriminant_type", Kind::DISCRIMINANT_TYPE},
+  {"manually_drop", Kind::MANUALLY_DROP},
 }};
 
 tl::optional
diff --git a/gcc/rust/util/rust-lang-item.h b/gcc/rust/util/rust-lang-item.h
index 8f3af3615bb2..67a5d9c438f8 100644
--- a/gcc/rust/util/rust-lang-item.h
+++ b/gcc/rust/util/rust-lang-item.h
@@ -150,6 +150,8 @@ public:
 
 DISCRIMINANT_TYPE,
 DISCRIMINANT_KIND,
+
+MANUALLY_DROP,
   };
 
   static const BiMap lang_items;


[gcc r15-9457] cobol: Fix -fmax-errors option [PR119776]

2025-04-14 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:e0b57c75e6daa1664bea03ce96733bf1ebb38ced

commit r15-9457-ge0b57c75e6daa1664bea03ce96733bf1ebb38ced
Author: Jakub Jelinek 
Date:   Mon Apr 14 19:33:11 2025 +0200

cobol: Fix -fmax-errors option [PR119776]

There seems to be inconsistency in the -fmax-errors option
naming.  It is a generic option in common.opt (so applies
to all languages) but with the = character in it.
The gcobol.1 man page in one spot documents the generic
option (in the syntax, -fmax-errors=nerror) but in another
spot without the = character.

In common.opt it is
fmax-errors=
Common Joined RejectNegative UInteger Var(flag_max_errors)
-fmax-errors=   Maximum number of errors to report.

I hope the cobol addition is just a mistake, having -fmax-errors variant
without = character when Joined Separate would allow to specify
-fmax-errors 10 with the same meaning as -fmax-errors=10
but also -fmax-errors10 with the same meaning which is just weird.
Also, there is no UInteger and RejectNegative on it, so one can
also specific -fno-max-errors42 or -fmax-errors blah.

So, unless the spelling without = is intentional, here is a patch
to just remove it, the common option already should have arranged
for flag_max_errors to be set to the right number.

Or if it is intentional, I guess we'd need to at least add
RejectNegative UInteger (plus using atoi is generally undesirable
anywhere in the compiler because it does no error checking).
And the man page would need to be updated to specify both forms.

2025-04-14  Jakub Jelinek  

PR cobol/119776
* lang.opt (fmax-errors): Remove.
* lang.opt.urls: Regenerate.
* cobol1.cc (cobol_langhook_handle_option) :
Remove.
* gcobol.1: Document -fmax-errors=nerror rather than
-fmax-errors nerror.

Diff:
---
 gcc/cobol/cobol1.cc | 4 
 gcc/cobol/gcobol.1  | 2 +-
 gcc/cobol/lang.opt  | 4 
 gcc/cobol/lang.opt.urls | 3 ---
 4 files changed, 1 insertion(+), 12 deletions(-)

diff --git a/gcc/cobol/cobol1.cc b/gcc/cobol/cobol1.cc
index 7d742b907764..3bd21c783ded 100644
--- a/gcc/cobol/cobol1.cc
+++ b/gcc/cobol/cobol1.cc
@@ -385,10 +385,6 @@ cobol_langhook_handle_option (size_t scode,
 return true;
 }
 
-case OPT_fmax_errors:
-flag_max_errors = atoi(arg);
-return true;
-
 case OPT_ffixed_form:
 cobol_set_indicator_column(-7);
 return true;
diff --git a/gcc/cobol/gcobol.1 b/gcc/cobol/gcobol.1
index 64c017c22144..4377c1401efe 100644
--- a/gcc/cobol/gcobol.1
+++ b/gcc/cobol/gcobol.1
@@ -224,7 +224,7 @@ had appeared.
 Not all exception conditions are implemented.  Any that are not
 produce a warning message.
 .
-.It Fl fmax-errors Ar nerror
+.It Fl fmax-errors Ns Li = Ns Ar nerror
 .Ar nerror
 represents the number of error messages produced.  Without this option,
 .Nm
diff --git a/gcc/cobol/lang.opt b/gcc/cobol/lang.opt
index 1d33f34aceeb..59278a147e99 100644
--- a/gcc/cobol/lang.opt
+++ b/gcc/cobol/lang.opt
@@ -89,10 +89,6 @@ finternal-ebcdic
 Cobol Var(cobol_ebcdic, 1) Init(0)
 -finternal-ebcdic  Internal processing is in EBCDIC Code Page 1140
 
-fmax-errors
-Cobol Joined Separate
-; Documented in C
-
 fstatic-call
 Cobol Var(cobol_static_call, 1) Init(1)
 Enable/disable static linkage for CALL literals
diff --git a/gcc/cobol/lang.opt.urls b/gcc/cobol/lang.opt.urls
index 75df59643eab..69f52973c025 100644
--- a/gcc/cobol/lang.opt.urls
+++ b/gcc/cobol/lang.opt.urls
@@ -16,9 +16,6 @@ 
LangUrlSuffix_Fortran(gfortran/Fortran-Dialect-Options.html#index-ffixed-form)
 ffree-form
 LangUrlSuffix_Fortran(gfortran/Fortran-Dialect-Options.html#index-ffree-form)
 
-fmax-errors
-UrlSuffix(gcc/Warning-Options.html#index-fmax-errors) 
LangUrlSuffix_D(gdc/Warnings.html#index-fmax-errors)
-
 iprefix
 UrlSuffix(gcc/Directory-Options.html#index-iprefix) 
LangUrlSuffix_D(gdc/Directory-Options.html#index-iprefix) 
LangUrlSuffix_Fortran(gfortran/Preprocessing-Options.html#index-iprefix)


[gcc r15-9458] expmed: Always use QImode for init_expmed set_zero_cost [PR119785]

2025-04-14 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:f96a54350afcf7f3c90d0ecb51d7683d826acc00

commit r15-9458-gf96a54350afcf7f3c90d0ecb51d7683d826acc00
Author: Jakub Jelinek 
Date:   Mon Apr 14 19:34:22 2025 +0200

expmed: Always use QImode for init_expmed set_zero_cost [PR119785]

This is a regression on some targets introduced I believe by r6-2055
which added mode argument to set_src_cost.

The problem here is that in the first iteration, mode is always QImode
and we get as -Os zero cost set_src_cost (const0_rtx, QImode, false).
But then we use the mode variable for iterating over int, partial int
and vector int modes, so for the second iteration we call set_src_cost
with mode which is at that time (machine_mode) (MAX_MODE_VECTOR_INT + 1).

In the x86 case that happens to be V2HFmode and we don't crash (and
compute the same 0 cost as we would for QImode).
But e.g. in the SPARC case (machine_mode) (MAX_MODE_VECTOR_INT + 1) is
MAX_MACHINE_MODE and that does all kinds of weird things especially
when doing ubsan bootstrap.

Fixed by always using QImode.

2025-04-14  Jakub Jelinek  

PR rtl-optimization/119785
* expmed.cc (init_expmed): Always pass QImode rather than mode to
set_src_cost passed to set_zero_cost.

Diff:
---
 gcc/expmed.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/expmed.cc b/gcc/expmed.cc
index df09cbccd083..8cf10d9c73bf 100644
--- a/gcc/expmed.cc
+++ b/gcc/expmed.cc
@@ -285,7 +285,7 @@ init_expmed (void)
   for (speed = 0; speed < 2; speed++)
 {
   crtl->maybe_hot_insn_p = speed;
-  set_zero_cost (speed, set_src_cost (const0_rtx, mode, speed));
+  set_zero_cost (speed, set_src_cost (const0_rtx, QImode, speed));
 
   for (mode = MIN_MODE_INT; mode <= MAX_MODE_INT;
   mode = (machine_mode)(mode + 1))


[gcc r15-9455] cobol: Drop -fsyntax-only from COBOL lang.opt [PR119777]

2025-04-14 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:e96cb35ceb08bb6d12670172115f27819c806e82

commit r15-9455-ge96cb35ceb08bb6d12670172115f27819c806e82
Author: Jakub Jelinek 
Date:   Mon Apr 14 19:32:06 2025 +0200

cobol: Drop -fsyntax-only from COBOL lang.opt [PR119777]

The comment is incorrect, fsyntax-only is not documented in c.opt,
but in common.opt:
fsyntax-only
Common Var(flag_syntax_only)
Check for syntax errors, then stop.
and as such it applies to all languages, so adding CL_Cobol to
the CL_COMMON is both unnecessary and because of RejectNegative which
contradicts the generic option very harmful, because it makes
-fno-syntax-only invalid for all languages.

Fixed by just dropping it.

2025-04-14  Jakub Jelinek  

PR cobol/119777
* lang.opt (fsyntax-only): Remove.
* lang.opt.urls: Regenerate.

Diff:
---
 gcc/cobol/lang.opt  | 4 
 gcc/cobol/lang.opt.urls | 3 ---
 2 files changed, 7 deletions(-)

diff --git a/gcc/cobol/lang.opt b/gcc/cobol/lang.opt
index 42c402037b5c..142ec4f34bf2 100644
--- a/gcc/cobol/lang.opt
+++ b/gcc/cobol/lang.opt
@@ -77,10 +77,6 @@ ffixed-form
 Cobol RejectNegative
 Assume that the source file is fixed form.
 
-fsyntax-only
-Cobol RejectNegative
-; Documented in c.opt
-
 ffree-form
 Cobol RejectNegative
 Assume that the source file is free form.
diff --git a/gcc/cobol/lang.opt.urls b/gcc/cobol/lang.opt.urls
index 6a5dc1c0f580..75df59643eab 100644
--- a/gcc/cobol/lang.opt.urls
+++ b/gcc/cobol/lang.opt.urls
@@ -13,9 +13,6 @@ UrlSuffix(gcc/Directory-Options.html#index-I) 
LangUrlSuffix_D(gdc/Directory-Opti
 ffixed-form
 LangUrlSuffix_Fortran(gfortran/Fortran-Dialect-Options.html#index-ffixed-form)
 
-fsyntax-only
-UrlSuffix(gcc/Warning-Options.html#index-fsyntax-only) 
LangUrlSuffix_D(gdc/Warnings.html#index-fno-syntax-only) 
LangUrlSuffix_Fortran(gfortran/Error-and-Warning-Options.html#index-fsyntax-only)
-
 ffree-form
 LangUrlSuffix_Fortran(gfortran/Fortran-Dialect-Options.html#index-ffree-form)


[gcc r15-9454] pretty-print, expand: Print [must tail call] for CALL_EXPRs and fix up maybe_complain_about_tail_cal

2025-04-14 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:2e3c91786a981f2d68600e2d7b2e25a766e59c21

commit r15-9454-g2e3c91786a981f2d68600e2d7b2e25a766e59c21
Author: Jakub Jelinek 
Date:   Mon Apr 14 19:31:23 2025 +0200

pretty-print, expand: Print [must tail call] for CALL_EXPRs and fix up 
maybe_complain_about_tail_call [PR119718]

Andrew P. mentioned earlier he'd like to see in the dump files a note
whether it was a failed must tail call or not.
We already print that on the tailc/musttail pass side, because
print_gimple_stmt prints [must tail call] after the musttail calls.
The first hunk below does it for GENERIC CALL_EXPRs too (which is needed
for the expand diagnostics).  That isn't enough though, because the
error on it was done first and then CALL_EXPR_MUST_TAIL_CALL flag was
cleared, so the dump didn't have it anymore.  I've reordered the
dump printing with error, so that it works properly.

2025-04-14  Jakub Jelinek  

PR tree-optimization/119718
* tree-pretty-print.cc (dump_generic_node) : Dump
also CALL_EXPR_MUST_TAIL_CALL flag.
* calls.cc (maybe_complain_about_tail_call): Emit error about
CALL_EXPR_MUST_TAIL_CALL only after emitting dump message, not 
before
it.

Diff:
---
 gcc/calls.cc | 10 +-
 gcc/tree-pretty-print.cc |  2 ++
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/gcc/calls.cc b/gcc/calls.cc
index 372fab317f6f..076e046a8ef1 100644
--- a/gcc/calls.cc
+++ b/gcc/calls.cc
@@ -1273,11 +1273,6 @@ void
 maybe_complain_about_tail_call (tree call_expr, const char *reason)
 {
   gcc_assert (TREE_CODE (call_expr) == CALL_EXPR);
-  if (CALL_EXPR_MUST_TAIL_CALL (call_expr))
-{
-  error_at (EXPR_LOCATION (call_expr), "cannot tail-call: %s", reason);
-  CALL_EXPR_MUST_TAIL_CALL (call_expr) = 0;
-}
   if (CALL_EXPR_TAILCALL (call_expr)
   && dump_file
   && (dump_flags & TDF_DETAILS))
@@ -1286,6 +1281,11 @@ maybe_complain_about_tail_call (tree call_expr, const 
char *reason)
   print_generic_expr (dump_file, call_expr, TDF_SLIM);
   fprintf (dump_file, "\n");
 }
+  if (CALL_EXPR_MUST_TAIL_CALL (call_expr))
+{
+  error_at (EXPR_LOCATION (call_expr), "cannot tail-call: %s", reason);
+  CALL_EXPR_MUST_TAIL_CALL (call_expr) = 0;
+}
 }
 
 /* Fill in ARGS_SIZE and ARGS array based on the parameters found in
diff --git a/gcc/tree-pretty-print.cc b/gcc/tree-pretty-print.cc
index a2a4f5bfa2f1..c1a21e77bd29 100644
--- a/gcc/tree-pretty-print.cc
+++ b/gcc/tree-pretty-print.cc
@@ -3201,6 +3201,8 @@ dump_generic_node (pretty_printer *pp, tree node, int 
spc, dump_flags_t flags,
pp_string (pp, " [return slot optimization]");
   if (CALL_EXPR_TAILCALL (node))
pp_string (pp, " [tail call]");
+  if (CALL_EXPR_MUST_TAIL_CALL (node))
+   pp_string (pp, " [must tail call]");
   break;
 
 case WITH_CLEANUP_EXPR:


[gcc(refs/users/meissner/heads/work201)] Add ChangeLog.meissner and REVISION.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:b5abb63c30bd6dba56d6d7fedada5e9c4ef34e11

commit b5abb63c30bd6dba56d6d7fedada5e9c4ef34e11
Author: Michael Meissner 
Date:   Mon Apr 14 15:11:21 2025 -0400

Add ChangeLog.meissner and REVISION.

2025-04-14  Michael Meissner  

gcc/

* REVISION: New file for branch.
* ChangeLog.meissner: New file.

gcc/c-family/

* ChangeLog.meissner: New file.

gcc/c/

* ChangeLog.meissner: New file.

gcc/cp/

* ChangeLog.meissner: New file.

gcc/fortran/

* ChangeLog.meissner: New file.

gcc/testsuite/

* ChangeLog.meissner: New file.

libgcc/

* ChangeLog.meissner: New file.

Diff:
---
 gcc/ChangeLog.meissner   | 5 +
 gcc/REVISION | 1 +
 gcc/c-family/ChangeLog.meissner  | 5 +
 gcc/c/ChangeLog.meissner | 5 +
 gcc/cp/ChangeLog.meissner| 5 +
 gcc/fortran/ChangeLog.meissner   | 5 +
 gcc/testsuite/ChangeLog.meissner | 5 +
 libgcc/ChangeLog.meissner| 5 +
 libstdc++-v3/ChangeLog.meissner  | 5 +
 9 files changed, 41 insertions(+)

diff --git a/gcc/ChangeLog.meissner b/gcc/ChangeLog.meissner
new file mode 100644
index ..8fe7da956044
--- /dev/null
+++ b/gcc/ChangeLog.meissner
@@ -0,0 +1,5 @@
+ Branch work201, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/REVISION b/gcc/REVISION
new file mode 100644
index ..5f8715c4844d
--- /dev/null
+++ b/gcc/REVISION
@@ -0,0 +1 @@
+work201 branch
diff --git a/gcc/c-family/ChangeLog.meissner b/gcc/c-family/ChangeLog.meissner
new file mode 100644
index ..8fe7da956044
--- /dev/null
+++ b/gcc/c-family/ChangeLog.meissner
@@ -0,0 +1,5 @@
+ Branch work201, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/c/ChangeLog.meissner b/gcc/c/ChangeLog.meissner
new file mode 100644
index ..8fe7da956044
--- /dev/null
+++ b/gcc/c/ChangeLog.meissner
@@ -0,0 +1,5 @@
+ Branch work201, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/cp/ChangeLog.meissner b/gcc/cp/ChangeLog.meissner
new file mode 100644
index ..8fe7da956044
--- /dev/null
+++ b/gcc/cp/ChangeLog.meissner
@@ -0,0 +1,5 @@
+ Branch work201, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/fortran/ChangeLog.meissner b/gcc/fortran/ChangeLog.meissner
new file mode 100644
index ..8fe7da956044
--- /dev/null
+++ b/gcc/fortran/ChangeLog.meissner
@@ -0,0 +1,5 @@
+ Branch work201, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/testsuite/ChangeLog.meissner b/gcc/testsuite/ChangeLog.meissner
new file mode 100644
index ..8fe7da956044
--- /dev/null
+++ b/gcc/testsuite/ChangeLog.meissner
@@ -0,0 +1,5 @@
+ Branch work201, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/libgcc/ChangeLog.meissner b/libgcc/ChangeLog.meissner
new file mode 100644
index ..8fe7da956044
--- /dev/null
+++ b/libgcc/ChangeLog.meissner
@@ -0,0 +1,5 @@
+ Branch work201, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/libstdc++-v3/ChangeLog.meissner b/libstdc++-v3/ChangeLog.meissner
new file mode 100644
index ..8fe7da956044
--- /dev/null
+++ b/libstdc++-v3/ChangeLog.meissner
@@ -0,0 +1,5 @@
+ Branch work201, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch


[gcc] Created branch 'meissner/heads/work201' in namespace 'refs/users'

2025-04-14 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work201' was created in namespace 'refs/users' 
pointing to:

 ebdf92b6067a... testsuite: Fix up ipa/pr119530.c testcase [PR119318]


[gcc] Created branch 'meissner/heads/work201-dmf' in namespace 'refs/users'

2025-04-14 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work201-dmf' was created in namespace 'refs/users' 
pointing to:

 b5abb63c30bd... Add ChangeLog.meissner and REVISION.


[gcc(refs/users/meissner/heads/work201-dmf)] Add ChangeLog.dmf and update REVISION.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:0d37093f29db1cc49d1fdbdec65563d2468082f6

commit 0d37093f29db1cc49d1fdbdec65563d2468082f6
Author: Michael Meissner 
Date:   Mon Apr 14 15:12:24 2025 -0400

Add ChangeLog.dmf and update REVISION.

2025-04-14  Michael Meissner  

gcc/

* ChangeLog.dmf: New file for branch.
* REVISION: Update.

Diff:
---
 gcc/ChangeLog.dmf | 5 +
 gcc/REVISION  | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.dmf b/gcc/ChangeLog.dmf
new file mode 100644
index ..211e3edc44fc
--- /dev/null
+++ b/gcc/ChangeLog.dmf
@@ -0,0 +1,5 @@
+ Branch work201-dmf, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/REVISION b/gcc/REVISION
index 5f8715c4844d..c257804fb56a 100644
--- a/gcc/REVISION
+++ b/gcc/REVISION
@@ -1 +1 @@
-work201 branch
+work201-dmf branch


[gcc] Created branch 'meissner/heads/work201-bugs' in namespace 'refs/users'

2025-04-14 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work201-bugs' was created in namespace 'refs/users' 
pointing to:

 b5abb63c30bd... Add ChangeLog.meissner and REVISION.


[gcc] Created branch 'meissner/heads/work201-vpair' in namespace 'refs/users'

2025-04-14 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work201-vpair' was created in namespace 'refs/users' 
pointing to:

 b5abb63c30bd... Add ChangeLog.meissner and REVISION.


[gcc(refs/users/meissner/heads/work201-bugs)] Add ChangeLog.bugs and update REVISION.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:7e0a10be75e40e83e6f87b0ea493fdae5855a69a

commit 7e0a10be75e40e83e6f87b0ea493fdae5855a69a
Author: Michael Meissner 
Date:   Mon Apr 14 15:14:06 2025 -0400

Add ChangeLog.bugs and update REVISION.

2025-04-14  Michael Meissner  

gcc/

* ChangeLog.bugs: New file for branch.
* REVISION: Update.

Diff:
---
 gcc/ChangeLog.bugs | 5 +
 gcc/REVISION   | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.bugs b/gcc/ChangeLog.bugs
new file mode 100644
index ..6f3c5d84f221
--- /dev/null
+++ b/gcc/ChangeLog.bugs
@@ -0,0 +1,5 @@
+ Branch work201-bugs, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/REVISION b/gcc/REVISION
index 5f8715c4844d..028186c1b5c7 100644
--- a/gcc/REVISION
+++ b/gcc/REVISION
@@ -1 +1 @@
-work201 branch
+work201-bugs branch


[gcc r14-11609] match: Reject non-ssa name/min invariants in gimple_extract [PR116412]

2025-04-14 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:f6efcd3d4855e57646a9e3561404ad735d702c60

commit r14-11609-gf6efcd3d4855e57646a9e3561404ad735d702c60
Author: Andrew Pinski 
Date:   Mon Aug 19 08:06:36 2024 -0700

match: Reject non-ssa name/min invariants in gimple_extract [PR116412]

After the conversion for phiopt's conditional operand
to use maybe_push_res_to_seq, it was found that gimple_extract
will extract out from REALPART_EXPR/IMAGPART_EXPR/VCE and BIT_FIELD_REF,
a memory load. But that extraction was not needed as memory loads are not
simplified in match and simplify. So gimple_extract should return false
in those cases.

Changes since v1:
* Move the rejection to gimple_extract from 
factor_out_conditional_operation.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/116412

gcc/ChangeLog:

* gimple-match-exports.cc (gimple_extract): Return false if op0
was not a SSA name nor a min invariant for 
REALPART_EXPR/IMAGPART_EXPR/VCE
and BIT_FIELD_REF.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr116412-1.c: New test.

Signed-off-by: Andrew Pinski 
(cherry picked from commit c7b76a076cb2c6ded7ae208464019b04cb0531a2)

Diff:
---
 gcc/gimple-match-exports.cc   | 6 ++
 gcc/testsuite/gcc.dg/torture/pr116412-1.c | 6 ++
 2 files changed, 12 insertions(+)

diff --git a/gcc/gimple-match-exports.cc b/gcc/gimple-match-exports.cc
index 1fe6c0e38833..d81f8bc40d62 100644
--- a/gcc/gimple-match-exports.cc
+++ b/gcc/gimple-match-exports.cc
@@ -732,6 +732,9 @@ gimple_extract (gimple *stmt, gimple_match_op *res_op,
|| code == VIEW_CONVERT_EXPR)
  {
tree op0 = TREE_OPERAND (gimple_assign_rhs1 (stmt), 0);
+   /* op0 needs to be a SSA name or an min invariant. */
+   if (TREE_CODE (op0) != SSA_NAME && !is_gimple_min_invariant 
(op0))
+ return false;
res_op->set_op (code, type, valueize_op (op0));
return true;
  }
@@ -739,6 +742,9 @@ gimple_extract (gimple *stmt, gimple_match_op *res_op,
  {
tree rhs1 = gimple_assign_rhs1 (stmt);
tree op0 = valueize_op (TREE_OPERAND (rhs1, 0));
+   /* op0 needs to be a SSA name or an min invariant. */
+   if (TREE_CODE (op0) != SSA_NAME && !is_gimple_min_invariant 
(op0))
+ return false;
res_op->set_op (code, type, op0,
TREE_OPERAND (rhs1, 1),
TREE_OPERAND (rhs1, 2),
diff --git a/gcc/testsuite/gcc.dg/torture/pr116412-1.c 
b/gcc/testsuite/gcc.dg/torture/pr116412-1.c
new file mode 100644
index ..3bc26ecd8b83
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr116412-1.c
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+double f(_Complex double a, _Complex double *b, int c)
+{
+  if (c) return __real__ a;
+  return __real__ *b;
+}


[gcc(refs/users/meissner/heads/work201-test)] Add ChangeLog.test and update REVISION.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:bf8ac60a11f33c94f981c6ad2d828eef5755700a

commit bf8ac60a11f33c94f981c6ad2d828eef5755700a
Author: Michael Meissner 
Date:   Mon Apr 14 15:17:00 2025 -0400

Add ChangeLog.test and update REVISION.

2025-04-14  Michael Meissner  

gcc/

* ChangeLog.test: New file for branch.
* REVISION: Update.

Diff:
---
 gcc/ChangeLog.test | 5 +
 gcc/REVISION   | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.test b/gcc/ChangeLog.test
new file mode 100644
index ..b7353453a268
--- /dev/null
+++ b/gcc/ChangeLog.test
@@ -0,0 +1,5 @@
+ Branch work201-test, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/REVISION b/gcc/REVISION
index 5f8715c4844d..a43f066a082a 100644
--- a/gcc/REVISION
+++ b/gcc/REVISION
@@ -1 +1 @@
-work201 branch
+work201-test branch


[gcc(refs/users/meissner/heads/work201-vpair)] Add ChangeLog.vpair and update REVISION.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:7804b9c15da58030675556042158a34dc77f15ff

commit 7804b9c15da58030675556042158a34dc77f15ff
Author: Michael Meissner 
Date:   Mon Apr 14 15:13:15 2025 -0400

Add ChangeLog.vpair and update REVISION.

2025-04-14  Michael Meissner  

gcc/

* ChangeLog.vpair: New file for branch.
* REVISION: Update.

Diff:
---
 gcc/ChangeLog.vpair | 5 +
 gcc/REVISION| 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.vpair b/gcc/ChangeLog.vpair
new file mode 100644
index ..07257f300349
--- /dev/null
+++ b/gcc/ChangeLog.vpair
@@ -0,0 +1,5 @@
+ Branch work201-vpair, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/REVISION b/gcc/REVISION
index 5f8715c4844d..260696cdbbdd 100644
--- a/gcc/REVISION
+++ b/gcc/REVISION
@@ -1 +1 @@
-work201 branch
+work201-vpair branch


[gcc r15-9429] ipa-cp: Use the stored and streamed pass-through types in ipa-vr (PR118785)

2025-04-14 Thread Martin Jambor via Gcc-cvs
https://gcc.gnu.org/g:4f19487f2606d25516d31f0279101deea9772da4

commit r15-9429-g4f19487f2606d25516d31f0279101deea9772da4
Author: Martin Jambor 
Date:   Mon Apr 14 14:21:15 2025 +0200

ipa-cp: Use the stored and streamed pass-through types in ipa-vr (PR118785)

This patch revisits the fix for PR 118785 and intead of deducing the
necessary operation type it just uses the value collected and streamed
by an earlier patch.  The main advantage is that we do not rely on
expr_type_first_operand_type_p enumarating all operations.

gcc/ChangeLog:

2025-03-20  Martin Jambor  

PR ipa/118785
* ipa-cp.cc (ipa_vr_intersect_with_arith_jfunc): Use the stored
and streamed type of arithmetic pass-through functions.

Diff:
---
 gcc/ipa-cp.cc | 28 ++--
 1 file changed, 2 insertions(+), 26 deletions(-)

diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc
index 637bc49f0482..21033c666bf4 100644
--- a/gcc/ipa-cp.cc
+++ b/gcc/ipa-cp.cc
@@ -1735,24 +1735,7 @@ ipa_vr_intersect_with_arith_jfunc (vrange &vr,
   const value_range *inter_vr;
   if (operation != NOP_EXPR)
{
- /* Since we construct arithmetic jump functions even when there is a
- type conversion in between the operation encoded in the jump
- function and when it is passed in a call argument, the IPA
- propagation phase must also perform the operation and conversion
- in two separate steps.
-
-TODO: In order to remove the use of expr_type_first_operand_type_p
-predicate we would need to stream the operation type, ideally
-encoding the whole jump function as a series of expr_eval_op
-structures.  */
-
- tree operation_type;
- if (expr_type_first_operand_type_p (operation))
-   operation_type = src_type;
- else if (operation == ABSU_EXPR)
-   operation_type = unsigned_type_for (src_type);
- else
-   return;
+ tree operation_type = ipa_get_jf_pass_through_op_type (jfunc);
  op_res.set_varying (operation_type);
  if (!ipa_vr_operation_and_type_effects (op_res, src_vr, operation,
  operation_type, src_type))
@@ -1782,14 +1765,7 @@ ipa_vr_intersect_with_arith_jfunc (vrange &vr,
   value_range op_vr (TREE_TYPE (operand));
   ipa_get_range_from_ip_invariant (op_vr, operand, context_node);
 
-  tree operation_type;
-  if (TREE_CODE_CLASS (operation) == tcc_comparison)
-operation_type = boolean_type_node;
-  else if (expr_type_first_operand_type_p (operation))
-operation_type = src_type;
-  else
-return;
-
+  tree operation_type = ipa_get_jf_pass_through_op_type (jfunc);
   value_range op_res (operation_type);
   if (!ipa_vr_supported_type_p (operation_type)
   || !handler.operand_check_p (operation_type, src_type, op_vr.type ())


[gcc r15-9431] APX: Don't use red-zone with 32 GPRs and no caller-saved registers

2025-04-14 Thread H.J. Lu via Gcc-cvs
https://gcc.gnu.org/g:0a074b8c7e79f9d9359d044f1499b0a9ce9d2801

commit r15-9431-g0a074b8c7e79f9d9359d044f1499b0a9ce9d2801
Author: H.J. Lu 
Date:   Sun Apr 13 12:20:42 2025 -0700

APX: Don't use red-zone with 32 GPRs and no caller-saved registers

Don't use red-zone when there are no caller-saved registers with 32 GPRs
since 128-byte red-zone is too small for 31 GPRs.

gcc/

PR target/119784
* config/i386/i386.cc (ix86_using_red_zone): Don't use red-zone
with 32 GPRs and no caller-saved registers.

gcc/testsuite/

PR target/119784
* gcc.target/i386/pr119784a.c: New test.
* gcc.target/i386/pr119784b.c: Likewise.

Signed-off-by: H.J. Lu 

Diff:
---
 gcc/config/i386/i386.cc   |  6 ++
 gcc/testsuite/gcc.target/i386/pr119784a.c | 96 +++
 gcc/testsuite/gcc.target/i386/pr119784b.c | 87 
 3 files changed, 189 insertions(+)

diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index 4f8380c4a58b..b172f716c683 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -458,6 +458,9 @@ int ix86_arch_specified;
indirect thunk pushes the return address onto stack, destroying
red-zone.
 
+   NB: Don't use red-zone for functions with no_caller_saved_registers
+   and 32 GPRs since 128-byte red-zone is too small for 31 GPRs.
+
TODO: If we can reserve the first 2 WORDs, for PUSH and, another
for CALL, in red-zone, we can allow local indirect jumps with
indirect thunk.  */
@@ -467,6 +470,9 @@ ix86_using_red_zone (void)
 {
   return (TARGET_RED_ZONE
  && !TARGET_64BIT_MS_ABI
+ && (!TARGET_APX_EGPR
+ || (cfun->machine->call_saved_registers
+ != TYPE_NO_CALLER_SAVED_REGISTERS))
  && (!cfun->machine->has_local_indirect_jump
  || cfun->machine->indirect_branch_type == indirect_branch_keep));
 }
diff --git a/gcc/testsuite/gcc.target/i386/pr119784a.c 
b/gcc/testsuite/gcc.target/i386/pr119784a.c
new file mode 100644
index ..8a119d4cc1f8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr119784a.c
@@ -0,0 +1,96 @@
+/* { dg-do compile { target { *-*-linux* && lp64 } } } */
+/* { dg-options "-O2 -fno-pic -mtune=generic -mgeneral-regs-only -mapxf 
-mtune-ctrl=prologue_using_move,epilogue_using_move" } */
+/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc').  */
+/* { dg-final { check-function-bodies "**" "" "" { target "*-*-*" } {^\t?\.}  
} } */
+
+/* start must save and restore all caller saved registers.  */
+
+/*
+**start:
+**.LFB[0-9]+:
+** .cfi_startproc
+** subq\$248, %rsp
+**...
+** movq%rax, \(%rsp\)
+** movq%rdx, 8\(%rsp\)
+** movq%rcx, 16\(%rsp\)
+** movq%rbx, 24\(%rsp\)
+** movq%rsi, 32\(%rsp\)
+** movq%rdi, 40\(%rsp\)
+**...
+** movq%rbp, 48\(%rsp\)
+** movq%r8, 56\(%rsp\)
+** movq%r9, 64\(%rsp\)
+** movq%r10, 72\(%rsp\)
+** movq%r11, 80\(%rsp\)
+** movq%r12, 88\(%rsp\)
+** movq%r13, 96\(%rsp\)
+** movq%r14, 104\(%rsp\)
+** movq%r15, 112\(%rsp\)
+** movq%r16, 120\(%rsp\)
+** movq%r17, 128\(%rsp\)
+** movq%r18, 136\(%rsp\)
+** movq%r19, 144\(%rsp\)
+** movq%r20, 152\(%rsp\)
+** movq%r21, 160\(%rsp\)
+** movq%r22, 168\(%rsp\)
+** movq%r23, 176\(%rsp\)
+** movq%r24, 184\(%rsp\)
+** movq%r25, 192\(%rsp\)
+** movq%r26, 200\(%rsp\)
+** movq%r27, 208\(%rsp\)
+** movq%r28, 216\(%rsp\)
+** movq%r29, 224\(%rsp\)
+** movq%r30, 232\(%rsp\)
+** movq%r31, 240\(%rsp\)
+**...
+** call\*code\(%rip\)
+** movq\(%rsp\), %rax
+** movq8\(%rsp\), %rdx
+** movq16\(%rsp\), %rcx
+** movq24\(%rsp\), %rbx
+** movq32\(%rsp\), %rsi
+** movq40\(%rsp\), %rdi
+** movq48\(%rsp\), %rbp
+** movq56\(%rsp\), %r8
+** movq64\(%rsp\), %r9
+** movq72\(%rsp\), %r10
+** movq80\(%rsp\), %r11
+** movq88\(%rsp\), %r12
+** movq96\(%rsp\), %r13
+** movq104\(%rsp\), %r14
+** movq112\(%rsp\), %r15
+** movq120\(%rsp\), %r16
+** movq128\(%rsp\), %r17
+** movq136\(%rsp\), %r18
+** movq144\(%rsp\), %r19
+** movq152\(%rsp\), %r20
+** movq160\(%rsp\), %r21
+** movq168\(%rsp\), %r22
+** movq176\(%rsp\), %r23
+** movq184\(%rsp\), %r24
+** movq192\(%rsp\), %r25
+** movq200\(%rsp\), %r26
+** movq208\(%rsp\), %r27
+** movq216\(%rsp\), %r28
+** movq224\(%rsp\), %r29
+** movq232\(%rsp\), %r30
+** movq240\(%rsp\), %r31
+** addq\$248, %rsp
+**...
+** ret
+** .cfi_endproc
+**...
+*/
+
+#define DONT_SAVE_REGS __attribute__((no_callee_saved_registers))

[gcc r15-9432] libgcobol: Add missing float128 suffix

2025-04-14 Thread Andreas Schwab via Gcc-cvs
https://gcc.gnu.org/g:6518799b2dfe8cf6dd7afa96041c5842bb4b9a49

commit r15-9432-g6518799b2dfe8cf6dd7afa96041c5842bb4b9a49
Author: Andreas Schwab 
Date:   Mon Apr 14 14:20:08 2025 +0200

libgcobol: Add missing float128 suffix

* libgcobol.cc (__gg__float64_from_128): Mark literal as float128
literal.

Diff:
---
 libgcobol/libgcobol.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libgcobol/libgcobol.cc b/libgcobol/libgcobol.cc
index 1d4cdf849cbf..07d4e8ba9fc8 100644
--- a/libgcobol/libgcobol.cc
+++ b/libgcobol/libgcobol.cc
@@ -11708,7 +11708,7 @@ __gg__float64_from_128( cblc_field_t *dest,
   // _Float128 value = *(_Float128*)(source->data+source_offset);
   GCOB_FP128 value;
   memcpy(&value, source->data+source_offset, 16);
-  if( FP128_FUNC(fabs)(value) > 1.7976931348623157E308 )
+  if( FP128_FUNC(fabs)(value) > GCOB_FP128_LITERAL(1.7976931348623157E308) )
 {
 retval = 1;
 }


[gcc r15-9437] rust: use range for inside rust-gcc.cc [PR119341]

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:ec2edeffedeaaeceecf8c85fded9fd2ee3c1aa52

commit r15-9437-gec2edeffedeaaeceecf8c85fded9fd2ee3c1aa52
Author: Andrew Pinski 
Date:   Wed Mar 19 17:30:01 2025 -0700

rust: use range for inside rust-gcc.cc [PR119341]

There are some places inside rust-gcc.cc which are candidates
to use range for instead of iterators directly. This changes
the locations I saw and makes the code slightly more readable.

gcc/rust/ChangeLog:

PR rust/119341
* rust-gcc.cc (function_type): Use range fors.
(function_type_variadic): Likewise.
(fill_in_fields): Likewise.
(statement_list): Likewise.
(block): Likewise.
(block_add_statements): Likewise.
(function_set_parameters): Likewise.
(write_global_definitions): Likewise.

Signed-off-by: Andrew Pinski 

Diff:
---
 gcc/rust/rust-gcc.cc | 57 +++-
 1 file changed, 21 insertions(+), 36 deletions(-)

diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
index 13b7cea6a3fc..bd1f13920bfe 100644
--- a/gcc/rust/rust-gcc.cc
+++ b/gcc/rust/rust-gcc.cc
@@ -478,10 +478,9 @@ function_type (const typed_identifier &receiver,
   pp = &TREE_CHAIN (*pp);
 }
 
-  for (std::vector::const_iterator p = parameters.begin ();
-   p != parameters.end (); ++p)
+  for (const auto &p : parameters)
 {
-  tree t = p->type;
+  tree t = p.type;
   if (error_operand_p (t))
return error_mark_node;
   *pp = tree_cons (NULL_TREE, t, NULL_TREE);
@@ -527,10 +526,9 @@ function_type_variadic (const typed_identifier &receiver,
   if (receiver.type != NULL_TREE)
 args[offs++] = receiver.type;
 
-  for (std::vector::const_iterator p = parameters.begin ();
-   p != parameters.end (); ++p)
+  for (const auto &p : parameters)
 {
-  tree t = p->type;
+  tree t = p.type;
   if (error_operand_p (t))
return error_mark_node;
   args[offs++] = t;
@@ -609,14 +607,13 @@ fill_in_fields (tree fill, const 
std::vector &fields,
 {
   tree field_trees = NULL_TREE;
   tree *pp = &field_trees;
-  for (std::vector::const_iterator p = fields.begin ();
-   p != fields.end (); ++p)
+  for (const auto &p : fields)
 {
-  tree name_tree = get_identifier_from_string (p->name);
-  tree type_tree = p->type;
+  tree name_tree = get_identifier_from_string (p.name);
+  tree type_tree = p.type;
   if (error_operand_p (type_tree))
return error_mark_node;
-  tree field = build_decl (p->location, FIELD_DECL, name_tree, type_tree);
+  tree field = build_decl (p.location, FIELD_DECL, name_tree, type_tree);
   DECL_CONTEXT (field) = fill;
   *pp = field;
   pp = &DECL_CHAIN (field);
@@ -1741,10 +1738,8 @@ tree
 statement_list (const std::vector &statements)
 {
   tree stmt_list = NULL_TREE;
-  for (std::vector::const_iterator p = statements.begin ();
-   p != statements.end (); ++p)
+  for (tree t : statements)
 {
-  tree t = (*p);
   if (error_operand_p (t))
return error_mark_node;
   append_to_statement_list (t, &stmt_list);
@@ -1798,10 +1793,9 @@ block (tree fndecl, tree enclosing, const 
std::vector &vars,
 }
 
   tree *pp = &BLOCK_VARS (block_tree);
-  for (std::vector::const_iterator pv = vars.begin ();
-   pv != vars.end (); ++pv)
+  for (Bvariable *bv : vars)
 {
-  *pp = (*pv)->get_decl ();
+  *pp = bv->get_decl ();
   if (!error_operand_p (*pp))
pp = &DECL_CHAIN (*pp);
 }
@@ -1821,10 +1815,8 @@ void
 block_add_statements (tree bind_tree, const std::vector &statements)
 {
   tree stmt_list = NULL_TREE;
-  for (std::vector::const_iterator p = statements.begin ();
-   p != statements.end (); ++p)
+  for (tree s : statements)
 {
-  tree s = (*p);
   if (!error_operand_p (s))
append_to_statement_list (s, &stmt_list);
 }
@@ -2268,10 +2260,9 @@ function_set_parameters (tree function,
 
   tree params = NULL_TREE;
   tree *pp = ¶ms;
-  for (std::vector::const_iterator pv = param_vars.begin ();
-   pv != param_vars.end (); ++pv)
+  for (Bvariable *bv : param_vars)
 {
-  *pp = (*pv)->get_decl ();
+  *pp = bv->get_decl ();
   gcc_assert (!error_operand_p (*pp));
   pp = &DECL_CHAIN (*pp);
 }
@@ -2297,10 +2288,9 @@ write_global_definitions (const std::vector 
&type_decls,
 
   // Convert all non-erroneous declarations into Gimple form.
   size_t i = 0;
-  for (std::vector::const_iterator p = variable_decls.begin ();
-   p != variable_decls.end (); ++p)
+  for (Bvariable *bv : variable_decls)
 {
-  tree v = (*p)->get_decl ();
+  tree v = bv->get_decl ();
   if (error_operand_p (v))
continue;
   defs[i] = v;
@@ -2308,10 +2298,8 @@ write_global_definitions (const std::vector 
&type_decls,
   ++i;
 }
 
-  for (std::vector::const_iterator p = type_decls.begin ();
- 

[gcc r15-9442] gccrs: ast: Add get_locus() to DelimTokenTree

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:4aa6cae27bd1ca3513dcb512158ed27a4afe800d

commit r15-9442-g4aa6cae27bd1ca3513dcb512158ed27a4afe800d
Author: Arthur Cohen 
Date:   Wed Apr 9 14:44:11 2025 +0200

gccrs: ast: Add get_locus() to DelimTokenTree

gcc/rust/ChangeLog:

* ast/rust-ast.h (DelimTokenTree::get_locus): New function.

Diff:
---
 gcc/rust/ast/rust-ast.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h
index 09e0fce4f190..91611ec6a622 100644
--- a/gcc/rust/ast/rust-ast.h
+++ b/gcc/rust/ast/rust-ast.h
@@ -1018,6 +1018,7 @@ public:
   }
 
   DelimType get_delim_type () const { return delim_type; }
+  location_t get_locus () const { return locus; }
 };
 
 /* Forward decl - definition moved to rust-expr.h as it requires LiteralExpr


[gcc r15-9441] gccrs: ast: Support outer attributes for AST::RangeExpr

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:09c4a7a58b4dd6a95b72224d83c715308da9838a

commit r15-9441-g09c4a7a58b4dd6a95b72224d83c715308da9838a
Author: Arthur Cohen 
Date:   Wed Apr 9 14:44:56 2025 +0200

gccrs: ast: Support outer attributes for AST::RangeExpr

gcc/rust/ChangeLog:

* ast/rust-expr.h (class RangeExpr): Add empty outer attributes and 
allow getting them
and setting them.

Diff:
---
 gcc/rust/ast/rust-expr.h | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h
index 84cdfdb46780..69538df63e5c 100644
--- a/gcc/rust/ast/rust-expr.h
+++ b/gcc/rust/ast/rust-expr.h
@@ -3004,6 +3004,10 @@ class RangeExpr : public ExprWithoutBlock
 {
   location_t locus;
 
+  // Some visitors still check for attributes on RangeExprs, and they will need
+  // to be supported in the future - so keep that for now
+  std::vector empty_attributes = {};
+
 protected:
   // outer attributes not allowed before range expressions
   RangeExpr (location_t locus) : locus (locus) {}
@@ -3013,15 +3017,11 @@ public:
 
   std::vector &get_outer_attrs () override final
   {
-// RangeExpr cannot have any outer attributes
-rust_assert (false);
+return empty_attributes;
   }
 
   // should never be called - error if called
-  void set_outer_attrs (std::vector /* new_attrs */) override
-  {
-rust_assert (false);
-  }
+  void set_outer_attrs (std::vector /* new_attrs */) override {}
 
   Expr::Kind get_expr_kind () const override { return Expr::Kind::Range; }
 };


[gcc r15-9443] gccrs: session: Desugar question mark operator after expansion instead.

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:76477f965552b5872bb14255f272bff78978ef0c

commit r15-9443-g76477f965552b5872bb14255f272bff78978ef0c
Author: Arthur Cohen 
Date:   Fri Apr 4 14:21:00 2025 +0200

gccrs: session: Desugar question mark operator after expansion instead.

gcc/rust/ChangeLog:

* rust-session-manager.cc (Session::compile_crate): Call the 
visitor later in the pipeline.

Diff:
---
 gcc/rust/rust-session-manager.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc
index 15f21ef12a96..48acbf34 100644
--- a/gcc/rust/rust-session-manager.cc
+++ b/gcc/rust/rust-session-manager.cc
@@ -611,7 +611,6 @@ Session::compile_crate (const char *filename)
 return;
 
   AST::CollectLangItems ().go (parsed_crate);
-  AST::DesugarQuestionMark ().go (parsed_crate);
 
   auto name_resolution_ctx = Resolver2_0::NameResolutionContext ();
   // expansion pipeline stage
@@ -619,6 +618,7 @@ Session::compile_crate (const char *filename)
   expansion (parsed_crate, name_resolution_ctx);
 
   AST::DesugarForLoops ().go (parsed_crate);
+  AST::DesugarQuestionMark ().go (parsed_crate);
 
   rust_debug ("\033[0;31mSUCCESSFULLY FINISHED EXPANSION \033[0m");
   if (options.dump_option_enabled (CompileOptions::EXPANSION_DUMP))


[gcc r15-9438] rust: Add comment inside block [PR119342]

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:9e367223ce5c42e0598ef52637af34f74e14acc1

commit r15-9438-g9e367223ce5c42e0598ef52637af34f74e14acc1
Author: Andrew Pinski 
Date:   Wed Mar 19 17:30:02 2025 -0700

rust: Add comment inside block [PR119342]

Inside a BLOCK node, all of the variables of the scope/block
are chained together and that connects them to the block.
This just adds a comment to that effect as reading the code
it is not so obvious why they need to be chained together.

gcc/rust/ChangeLog:

PR rust/119342
* rust-gcc.cc (block): Add comment on why chaining
the variables of the scope toether.

Signed-off-by: Andrew Pinski 

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

diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
index bd1f13920bfe..234721c585fd 100644
--- a/gcc/rust/rust-gcc.cc
+++ b/gcc/rust/rust-gcc.cc
@@ -1792,6 +1792,8 @@ block (tree fndecl, tree enclosing, const 
std::vector &vars,
   *pp = block_tree;
 }
 
+  // Chain the variables of the scope together so they are all connected
+  // to the block.
   tree *pp = &BLOCK_VARS (block_tree);
   for (Bvariable *bv : vars)
 {


[gcc r15-9445] gccrs: expansion: Desugar doc comments into attributes before expansion

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:9710cf3e3419954fb543224faa9efd3c8d97a800

commit r15-9445-g9710cf3e3419954fb543224faa9efd3c8d97a800
Author: Arthur Cohen 
Date:   Tue Apr 8 16:20:18 2025 +0200

gccrs: expansion: Desugar doc comments into attributes before expansion

gcc/rust/ChangeLog:

* expand/rust-macro-expand.cc (MacroExpander::expand_decl_macro): 
Call into
TokenTreeDesugar.
* expand/rust-token-tree-desugar.cc: New file.
* expand/rust-token-tree-desugar.h: New file.
* Make-lang.in: Compile them.

gcc/testsuite/ChangeLog:

* rust/compile/macros/mbe/macro-issue3709-1.rs: New test.
* rust/compile/macros/mbe/macro-issue3709-2.rs: New test.

Diff:
---
 gcc/rust/Make-lang.in  |  1 +
 gcc/rust/expand/rust-macro-expand.cc   |  6 +-
 gcc/rust/expand/rust-token-tree-desugar.cc | 72 +++
 gcc/rust/expand/rust-token-tree-desugar.h  | 55 +++
 .../rust/compile/macros/mbe/macro-issue3693.rs | 10 +++
 .../rust/compile/macros/mbe/macro-issue3709-1.rs   | 10 +++
 .../rust/compile/macros/mbe/macro-issue3709-2.rs   | 81 ++
 7 files changed, 234 insertions(+), 1 deletion(-)

diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in
index 4028b47fa87f..835e113aee2c 100644
--- a/gcc/rust/Make-lang.in
+++ b/gcc/rust/Make-lang.in
@@ -115,6 +115,7 @@ GRS_OBJS = \
 rust/rust-macro-builtins-format-args.o \
 rust/rust-macro-builtins-location.o \
 rust/rust-macro-builtins-include.o \
+rust/rust-token-tree-desugar.o \
rust/rust-fmt.o \
 rust/rust-hir.o \
 rust/rust-hir-map.o \
diff --git a/gcc/rust/expand/rust-macro-expand.cc 
b/gcc/rust/expand/rust-macro-expand.cc
index 6e62a083ae7a..673b8fb20fa3 100644
--- a/gcc/rust/expand/rust-macro-expand.cc
+++ b/gcc/rust/expand/rust-macro-expand.cc
@@ -28,6 +28,7 @@
 #include "rust-cfg-strip.h"
 #include "rust-early-name-resolver.h"
 #include "rust-proc-macro.h"
+#include "rust-token-tree-desugar.h"
 
 namespace Rust {
 
@@ -78,7 +79,10 @@ MacroExpander::expand_decl_macro (location_t invoc_locus,
* trees.
*/
 
-  AST::DelimTokenTree &invoc_token_tree = invoc.get_delim_tok_tree ();
+  AST::DelimTokenTree &invoc_token_tree_sugar = invoc.get_delim_tok_tree ();
+
+  // We must first desugar doc comments into proper attributes
+  auto invoc_token_tree = AST::TokenTreeDesugar ().go (invoc_token_tree_sugar);
 
   // find matching arm
   AST::MacroRule *matched_rule = nullptr;
diff --git a/gcc/rust/expand/rust-token-tree-desugar.cc 
b/gcc/rust/expand/rust-token-tree-desugar.cc
new file mode 100644
index ..3b471805924a
--- /dev/null
+++ b/gcc/rust/expand/rust-token-tree-desugar.cc
@@ -0,0 +1,72 @@
+// Copyright (C) 2025 Free Software Foundation, Inc.
+
+// This file is part of GCC.
+
+// GCC 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, or (at your option) any later
+// version.
+
+// GCC 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
+// .
+
+#include "rust-token-tree-desugar.h"
+#include "rust-ast.h"
+#include "rust-token.h"
+
+namespace Rust {
+namespace AST {
+
+DelimTokenTree
+TokenTreeDesugar::go (DelimTokenTree &tts)
+{
+  tts.accept_vis (*this);
+
+  return DelimTokenTree (tts.get_delim_type (), std::move (desugared),
+tts.get_locus ());
+}
+
+void
+TokenTreeDesugar::append (TokenPtr &&new_token)
+{
+  desugared.emplace_back (std::make_unique (std::move (new_token)));
+}
+
+void
+TokenTreeDesugar::append (std::unique_ptr &&new_token)
+{
+  desugared.emplace_back (std::move (new_token));
+}
+
+void
+TokenTreeDesugar::visit (Token &tts)
+{
+  if (tts.get_id () == TokenId::OUTER_DOC_COMMENT
+  || tts.get_id () == TokenId::INNER_DOC_COMMENT)
+{
+  append (Rust::Token::make (TokenId::HASH, tts.get_locus ()));
+
+  if (tts.get_id () == TokenId::INNER_DOC_COMMENT)
+   append (Rust::Token::make (EXCLAM, tts.get_locus ()));
+
+  append (Rust::Token::make (TokenId::LEFT_SQUARE, tts.get_locus ()));
+  append (Rust::Token::make_identifier (tts.get_locus (), "doc"));
+  append (Rust::Token::make (TokenId::EQUAL, tts.get_locus ()));
+  append (Rust::Token::make_string (tts.get_locus (),
+   std::string (tts.get_str (;
+  append (Rust::Token::make (TokenId::RIGHT_SQUARE, tts.get_locus ()));
+}
+  else
+{
+  append (tts.clone_token ());
+}
+}
+
+}; // namespace AST

[gcc r15-9440] gccrs: nr2.0: Do not resolve modules this run if they are unloaded

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:6dcbbcd27c534df3a4b8d0d0d0319677b8edee08

commit r15-9440-g6dcbbcd27c534df3a4b8d0d0d0319677b8edee08
Author: Arthur Cohen 
Date:   Fri Apr 4 14:18:33 2025 +0200

gccrs: nr2.0: Do not resolve modules this run if they are unloaded

Instead, mark the visitor as dirty and wait for the next round of the fixed 
point to take care of
them. This avoids issues with module items being loaded while not being 
stripped yet.

gcc/rust/ChangeLog:

* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): 
Return if module
is unloaded.

Diff:
---
 gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc 
b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
index 8863be768a1a..ba37dee88faf 100644
--- a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
@@ -113,7 +113,17 @@ TopLevel::visit (AST::Module &module)
   // This was copied from the old early resolver method
   // 'accumulate_escaped_macros'
   if (module.get_kind () == AST::Module::UNLOADED)
-module.load_items ();
+{
+  module.load_items ();
+
+  // If the module was previously unloaded, then we don't want to visit it
+  // this time around as the CfgStrip hasn't run on its inner items yet.
+  // Skip it for now, mark the visitor as dirty and try again
+
+  dirty = true;
+
+  return;
+}
 
   DefaultResolver::visit (module);


[gcc r15-9439] gccrs: typecheck: Properly select methods when dealing with specialization

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:eb5eee065b3e5fe189ea1f51dc88eae7dc4c25d6

commit r15-9439-geb5eee065b3e5fe189ea1f51dc88eae7dc4c25d6
Author: Arthur Cohen 
Date:   Thu Apr 3 16:22:10 2025 +0200

gccrs: typecheck: Properly select methods when dealing with specialization

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-expr.cc (is_default_fn): New.
(emit_ambiguous_resolution_error): New.
(handle_multiple_candidates): Properly handle multiple candidates in
the case of specialization.
(TypeCheckExpr::visit): Call `handle_multiple_candidates`.

gcc/testsuite/ChangeLog:

* rust/execute/torture/min_specialization2.rs: New test.
* rust/execute/torture/min_specialization3.rs: New test.

Diff:
---
 gcc/rust/typecheck/rust-hir-type-check-expr.cc | 129 +
 .../rust/execute/torture/min_specialization2.rs|  31 +
 .../rust/execute/torture/min_specialization3.rs|  36 ++
 3 files changed, 172 insertions(+), 24 deletions(-)

diff --git a/gcc/rust/typecheck/rust-hir-type-check-expr.cc 
b/gcc/rust/typecheck/rust-hir-type-check-expr.cc
index 791795f3b0e0..b2bcac065eb2 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-expr.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-expr.cc
@@ -16,6 +16,8 @@
 // along with GCC; see the file COPYING3.  If not see
 // .
 
+#include "optional.h"
+#include "rust-hir-expr.h"
 #include "rust-system.h"
 #include "rust-tyty-call.h"
 #include "rust-hir-type-check-struct-field.h"
@@ -1154,6 +1156,94 @@ TypeCheckExpr::visit (HIR::FieldAccessExpr &expr)
   infered = lookup->get_field_type ();
 }
 
+bool
+is_default_fn (const MethodCandidate &candidate)
+{
+  if (candidate.candidate.is_impl_candidate ())
+{
+  auto *item = candidate.candidate.item.impl.impl_item;
+
+  if (item->get_impl_item_type () == HIR::ImplItem::FUNCTION)
+   {
+ auto &fn = static_cast (*item);
+
+ return fn.is_default ();
+   }
+}
+
+  return false;
+}
+
+void
+emit_ambiguous_resolution_error (HIR::MethodCallExpr &expr,
+std::set &candidates)
+{
+  rich_location r (line_table, expr.get_method_name ().get_locus ());
+  std::string rich_msg = "multiple "
++ expr.get_method_name ().get_segment ().as_string ()
++ " found";
+
+  // We have to filter out default candidates
+  for (auto &c : candidates)
+if (!is_default_fn (c))
+  r.add_range (c.candidate.locus);
+
+  r.add_fixit_replace (rich_msg.c_str ());
+
+  rust_error_at (r, ErrorCode::E0592, "duplicate definitions with name %qs",
+expr.get_method_name ().get_segment ().as_string ().c_str ());
+}
+
+// We are allowed to have multiple candidates if they are all specializable
+// functions or if all of them except one are specializable functions.
+// In the later case, we just return a valid candidate without erroring out
+// about ambiguity. If there are two or more specialized functions, then we
+// error out.
+//
+// FIXME: The first case is not handled at the moment, so we error out
+tl::optional
+handle_multiple_candidates (HIR::MethodCallExpr &expr,
+   std::set &candidates)
+{
+  auto all_default = true;
+  tl::optional found = tl::nullopt;
+
+  for (auto &c : candidates)
+{
+  if (!is_default_fn (c))
+   {
+ all_default = false;
+
+ // We haven't found a final candidate yet, so we can select
+ // this one. However, if we already have a candidate, then
+ // that means there are multiple non-default candidates - we
+ // must error out
+ if (!found)
+   {
+ found = c;
+   }
+ else
+   {
+ emit_ambiguous_resolution_error (expr, candidates);
+ return tl::nullopt;
+   }
+   }
+}
+
+  // None of the candidates were a non-default (specialized) function, so we
+  // error out
+  if (all_default)
+{
+  rust_sorry_at (expr.get_locus (),
+"cannot resolve method calls to non-specialized methods "
+"(all function candidates are %qs)",
+"default");
+  return tl::nullopt;
+}
+
+  return found;
+}
+
 void
 TypeCheckExpr::visit (HIR::MethodCallExpr &expr)
 {
@@ -1181,34 +1271,25 @@ TypeCheckExpr::visit (HIR::MethodCallExpr &expr)
   return;
 }
 
-  if (candidates.size () > 1)
-{
-  rich_location r (line_table, expr.get_method_name ().get_locus ());
-  std::string rich_msg
-   = "multiple " + expr.get_method_name ().get_segment ().as_string ()
- + " found";
+  tl::optional candidate = *candidates.begin ();
 
-  for (auto &c : candidates)
-   r.add_range (c.candidate.locus);
+  if (candidates.size () > 1)
+candidate = handle_multiple_candidates (expr, candidates);
 
-  r.add_fixit_replace (rich_

[gcc r15-9446] gccrs: format_args: Allow extraneous commas, improve safety

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:5074a85e0380a4ba97d367a76f4a4efba7424e79

commit r15-9446-g5074a85e0380a4ba97d367a76f4a4efba7424e79
Author: Arthur Cohen 
Date:   Wed Apr 9 14:42:08 2025 +0200

gccrs: format_args: Allow extraneous commas, improve safety

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-format-args.cc 
(format_args_parse_arguments): Improve safety,
allow extra commas after end of argument list.

gcc/testsuite/ChangeLog:

* rust/compile/format_args_extra_comma.rs: New test.

Diff:
---
 gcc/rust/expand/rust-macro-builtins-format-args.cc |  7 
 .../rust/compile/format_args_extra_comma.rs| 47 ++
 2 files changed, 54 insertions(+)

diff --git a/gcc/rust/expand/rust-macro-builtins-format-args.cc 
b/gcc/rust/expand/rust-macro-builtins-format-args.cc
index 8eb32d5f1b31..3e1249d3d36f 100644
--- a/gcc/rust/expand/rust-macro-builtins-format-args.cc
+++ b/gcc/rust/expand/rust-macro-builtins-format-args.cc
@@ -55,6 +55,8 @@ format_args_parse_arguments (AST::MacroInvocData &invoc)
   if (parser.peek_current_token ()->get_id () == STRING_LITERAL)
 format_expr = parser.parse_literal_expr ();
 
+  rust_assert (format_expr);
+
   // TODO(Arthur): Clean this up - if we haven't parsed a string literal but a
   // macro invocation, what do we do here? return a tl::unexpected?
   auto format_str = static_cast (*format_expr)
@@ -81,6 +83,11 @@ format_args_parse_arguments (AST::MacroInvocData &invoc)
 {
   parser.skip_token (COMMA);
 
+  // Check in case of an extraneous comma in the args list, which is
+  // allowed - format_args!("fmt", arg, arg2,)
+  if (parser.peek_current_token ()->get_id () == last_token_id)
+   break;
+
   if (parser.peek_current_token ()->get_id () == IDENTIFIER
  && parser.peek (1)->get_id () == EQUAL)
{
diff --git a/gcc/testsuite/rust/compile/format_args_extra_comma.rs 
b/gcc/testsuite/rust/compile/format_args_extra_comma.rs
new file mode 100644
index ..fcc435c074c2
--- /dev/null
+++ b/gcc/testsuite/rust/compile/format_args_extra_comma.rs
@@ -0,0 +1,47 @@
+#![feature(rustc_attrs)]
+
+#[rustc_builtin_macro]
+macro_rules! format_args {
+() => {};
+}
+
+#[lang = "sized"]
+trait Sized {}
+
+pub mod core {
+pub mod fmt {
+pub struct Formatter;
+pub struct Result;
+
+pub struct Arguments<'a>;
+
+impl<'a> Arguments<'a> {
+pub fn new_v1(_: &'a [&'static str], _: &'a [ArgumentV1<'a>]) -> 
Arguments<'a> {
+Arguments
+}
+}
+
+pub struct ArgumentV1<'a>;
+
+impl<'a> ArgumentV1<'a> {
+pub fn new<'b, T>(_: &'b T, _: fn(&T, &mut Formatter) -> Result) 
-> ArgumentV1 {
+ArgumentV1
+}
+}
+
+pub trait Display {
+fn fmt(&self, _: &mut Formatter) -> Result;
+}
+
+impl Display for i32 {
+fn fmt(&self, _: &mut Formatter) -> Result {
+// { dg-warning "unused name .self." "" { target *-*-* } .-1 }
+Result
+}
+}
+}
+}
+
+fn main() {
+let _formatted = format_args!("extra commas {} {}", 15, 14,);
+}


[gcc r15-9434] testcase: Add testcase for already fixed PR [PR118476]

2025-04-14 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:d45a6502d1ec87d43f1a39f87cca58f1e28369c8

commit r15-9434-gd45a6502d1ec87d43f1a39f87cca58f1e28369c8
Author: Andrew Pinski 
Date:   Mon Apr 14 08:40:24 2025 -0700

testcase: Add testcase for already fixed PR [PR118476]

This testcase was fixed by r15-3052-gc7b76a076cb2c6ded but is
a testcase that failed in a different fashion and a much older
failure than the one added with r15-3052.

Pushed as obvious after a quick test.

PR tree-optimization/118476

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr118476-1.c: New test.

Signed-off-by: Andrew Pinski 

Diff:
---
 gcc/testsuite/gcc.dg/torture/pr118476-1.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/torture/pr118476-1.c 
b/gcc/testsuite/gcc.dg/torture/pr118476-1.c
new file mode 100644
index ..33509403b61a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr118476-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+/* PR tree-optimization/118476 */
+
+typedef unsigned long long poly64x1 
__attribute__((__vector_size__(1*sizeof(long long;
+
+poly64x1 vext_p64(poly64x1 a, poly64x1 b, const int n)
+{
+  poly64x1 r = a;
+  unsigned src = (unsigned)n;
+  long long t = b[0];
+  r[0] = (src < 1) ? a[src] : t;
+  return r;
+}


[gcc r15-9449] gccrs: Add `#[track_caller]` as known attribute

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:e84f76dc584192826700ebb89f726984b0788259

commit r15-9449-ge84f76dc584192826700ebb89f726984b0788259
Author: beamandala 
Date:   Thu Mar 20 17:34:48 2025 -0500

gccrs: Add `#[track_caller]` as known attribute

gcc/rust/ChangeLog:

* expand/rust-macro-builtins.cc 
(MacroBuiltin::builtin_transcribers):
Add entry for track_caller.
* util/rust-attribute-values.h: add `TRACK_CALLER` attribute.
* util/rust-attributes.cc: add `track_caller` attribute definition.

gcc/testsuite/ChangeLog:

* rust/compile/track_caller.rs: New test.

Signed-off-by: Bhavesh Mandalapu 

Diff:
---
 gcc/rust/expand/rust-macro-builtins.cc | 1 +
 gcc/rust/util/rust-attribute-values.h  | 1 +
 gcc/rust/util/rust-attributes.cc   | 3 ++-
 gcc/testsuite/rust/compile/track_caller.rs | 6 ++
 4 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/gcc/rust/expand/rust-macro-builtins.cc 
b/gcc/rust/expand/rust-macro-builtins.cc
index 39c4c46b8e0d..a1388fb1dfb3 100644
--- a/gcc/rust/expand/rust-macro-builtins.cc
+++ b/gcc/rust/expand/rust-macro-builtins.cc
@@ -137,6 +137,7 @@ std::unordered_map
 {"cfg_accessible", MacroBuiltin::sorry},
 {"rustc_const_stable", MacroBuiltin::sorry},
 {"rustc_const_unstable", MacroBuiltin::sorry},
+{"track_caller", MacroBuiltin::sorry},
 /* Derive builtins do not need a real transcriber, but still need one. It
should however never be called since builtin derive macros get expanded
differently, and benefit from knowing on what kind of items they are
diff --git a/gcc/rust/util/rust-attribute-values.h 
b/gcc/rust/util/rust-attribute-values.h
index 9ef5cc52e81a..d579fa298013 100644
--- a/gcc/rust/util/rust-attribute-values.h
+++ b/gcc/rust/util/rust-attribute-values.h
@@ -58,6 +58,7 @@ public:
   static constexpr auto &RUSTC_CONST_UNSTABLE = "rustc_const_unstable";
   static constexpr auto &MAY_DANGLE = "may_dangle";
   static constexpr auto &PRELUDE_IMPORT = "prelude_import";
+  static constexpr auto &TRACK_CALLER = "track_caller";
 };
 } // namespace Values
 } // namespace Rust
diff --git a/gcc/rust/util/rust-attributes.cc b/gcc/rust/util/rust-attributes.cc
index 03452c75bd8a..df0fe1b0bcac 100644
--- a/gcc/rust/util/rust-attributes.cc
+++ b/gcc/rust/util/rust-attributes.cc
@@ -75,7 +75,8 @@ static const BuiltinAttrDefinition __definitions[]
  // assuming we keep these for static analysis
  {Attrs::RUSTC_CONST_STABLE, STATIC_ANALYSIS},
  {Attrs::RUSTC_CONST_UNSTABLE, STATIC_ANALYSIS},
- {Attrs::PRELUDE_IMPORT, NAME_RESOLUTION}};
+ {Attrs::PRELUDE_IMPORT, NAME_RESOLUTION},
+ {Attrs::TRACK_CALLER, CODE_GENERATION}};
 
 BuiltinAttributeMappings *
 BuiltinAttributeMappings::get ()
diff --git a/gcc/testsuite/rust/compile/track_caller.rs 
b/gcc/testsuite/rust/compile/track_caller.rs
new file mode 100644
index ..fd1d84295887
--- /dev/null
+++ b/gcc/testsuite/rust/compile/track_caller.rs
@@ -0,0 +1,6 @@
+#[track_caller]
+fn foo() {}
+
+fn main() {
+foo();
+}


[gcc r14-11608] vec-lowering: Fix ABSU lowering [PR111285]

2025-04-14 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:8ee9d7b26342b96f462ebafa1304a26d83b4e833

commit r14-11608-g8ee9d7b26342b96f462ebafa1304a26d83b4e833
Author: Andrew Pinski 
Date:   Sun Oct 27 13:16:22 2024 -0700

vec-lowering: Fix ABSU lowering [PR111285]

ABSU_EXPR lowering incorrectly used the resulting type
for the new expression but in the case of ABSU the resulting
type is an unsigned type and with ABSU is folded away. The fix
is to use a signed type for the expression instead.

Bootstrapped and tested on x86_64-linux-gnu.

PR middle-end/111285

gcc/ChangeLog:

* tree-vect-generic.cc (do_unop): Use a signed type for the
operand if the operation was ABSU_EXPR.

gcc/testsuite/ChangeLog:

* g++.dg/torture/vect-absu-1.C: New test.

Signed-off-by: Andrew Pinski 
(cherry picked from commit ad0084337e901ddaedd48c14e7a5dad9fc2a093e)

Diff:
---
 gcc/testsuite/g++.dg/torture/vect-absu-1.C | 29 +
 gcc/tree-vect-generic.cc   | 10 +-
 2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/g++.dg/torture/vect-absu-1.C 
b/gcc/testsuite/g++.dg/torture/vect-absu-1.C
new file mode 100644
index ..0b2035f638f5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/vect-absu-1.C
@@ -0,0 +1,29 @@
+// { dg-do run }
+// PR middle-end/111285
+
+// The lowering of vect absu was done incorrectly
+
+#define vect1 __attribute__((vector_size(sizeof(int
+
+#define negabs(a) a < 0 ? a : -a
+
+__attribute__((noinline))
+int s(int a)
+{
+  return negabs(a);
+}
+__attribute__((noinline))
+vect1 int v(vect1 int a)
+{
+  return negabs(a);
+}
+
+int main(void)
+{
+for(int i = -10; i < 10; i++)
+{
+  vect1 int t = {i};
+  if (v(t)[0] != s(i))
+__builtin_abort();
+}
+}
diff --git a/gcc/tree-vect-generic.cc b/gcc/tree-vect-generic.cc
index 86d273923bb5..84361dd5781a 100644
--- a/gcc/tree-vect-generic.cc
+++ b/gcc/tree-vect-generic.cc
@@ -165,7 +165,15 @@ do_unop (gimple_stmt_iterator *gsi, tree inner_type, tree 
a,
 tree b ATTRIBUTE_UNUSED, tree bitpos, tree bitsize,
 enum tree_code code, tree type ATTRIBUTE_UNUSED)
 {
-  a = tree_vec_extract (gsi, inner_type, a, bitsize, bitpos);
+  tree rhs_type = inner_type;
+
+  /* For ABSU_EXPR, use the signed type for the rhs if the rhs was signed. */
+  if (code == ABSU_EXPR
+  && ANY_INTEGRAL_TYPE_P (TREE_TYPE (a))
+  && !TYPE_UNSIGNED (TREE_TYPE (a)))
+rhs_type = signed_type_for (rhs_type);
+
+  a = tree_vec_extract (gsi, rhs_type, a, bitsize, bitpos);
   return gimplify_build1 (gsi, code, inner_type, a);
 }


[gcc] Created branch 'meissner/heads/work201-math' in namespace 'refs/users'

2025-04-14 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work201-math' was created in namespace 'refs/users' 
pointing to:

 b5abb63c30bd... Add ChangeLog.meissner and REVISION.


[gcc r14-11606] aarch64: Fix early ra for -fno-delete-dead-exceptions [PR116927]

2025-04-14 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:16446f19f1313c57a312857026b6982aaa7241c7

commit r14-11606-g16446f19f1313c57a312857026b6982aaa7241c7
Author: Andrew Pinski 
Date:   Wed Oct 2 14:21:24 2024 -0700

aarch64: Fix early ra for -fno-delete-dead-exceptions [PR116927]

Early-RA was considering throwing instructions as being dead and removing
them even if -fno-delete-dead-exceptions was in use. This fixes that 
oversight.

Built and tested for aarch64-linux-gnu.

PR target/116927

gcc/ChangeLog:

* config/aarch64/aarch64-early-ra.cc (early_ra::is_dead_insn): Insns
that throw are not dead with -fno-delete-dead-exceptions.

gcc/testsuite/ChangeLog:

* g++.dg/torture/pr116927-1.C: New test.

Signed-off-by: Andrew Pinski 
(cherry picked from commit edec4bfc99744b48da3ffde1e4f39c9aceecfd42)

Diff:
---
 gcc/config/aarch64/aarch64-early-ra.cc|  6 ++
 gcc/testsuite/g++.dg/torture/pr116927-1.C | 15 +++
 2 files changed, 21 insertions(+)

diff --git a/gcc/config/aarch64/aarch64-early-ra.cc 
b/gcc/config/aarch64/aarch64-early-ra.cc
index dd2ed762f8ac..427b6a13aecd 100644
--- a/gcc/config/aarch64/aarch64-early-ra.cc
+++ b/gcc/config/aarch64/aarch64-early-ra.cc
@@ -3437,6 +3437,12 @@ early_ra::is_dead_insn (rtx_insn *insn)
   if (side_effects_p (set))
 return false;
 
+  /* If we can't delete dead exceptions and the insn throws,
+ then the instruction is not dead.  */
+  if (!cfun->can_delete_dead_exceptions
+  && !insn_nothrow_p (insn))
+return false;
+
   return true;
 }
 
diff --git a/gcc/testsuite/g++.dg/torture/pr116927-1.C 
b/gcc/testsuite/g++.dg/torture/pr116927-1.C
new file mode 100644
index ..22fa1dbd7e1a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr116927-1.C
@@ -0,0 +1,15 @@
+// { dg-do compile }
+// { dg-additional-options "-fnon-call-exceptions -fno-delete-dead-exceptions" 
}
+
+// PR target/116927
+// aarch64's Early ra was removing possiblely trapping
+// floating point insn
+
+void
+foo (float f)
+{
+  try {
+f ++;
+  }catch(...)
+  {}
+}


[gcc r14-11607] backprop: Fix deleting of a phi node [PR116922]

2025-04-14 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:aaef5d6409742574c2ff6acbc75a2a0f597ce8a3

commit r14-11607-gaaef5d6409742574c2ff6acbc75a2a0f597ce8a3
Author: Andrew Pinski 
Date:   Tue Oct 1 14:48:19 2024 -0700

backprop: Fix deleting of a phi node [PR116922]

The problem here is remove_unused_var is called on a name that is
defined by a phi node but it deletes it like removing a normal statement.
remove_phi_node should be called rather than gsi_remove for phinodes.

Note there is a possibility of using simple_dce_from_worklist instead
but that is for another day.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/116922

gcc/ChangeLog:

* gimple-ssa-backprop.cc (remove_unused_var): Handle phi
nodes correctly.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr116922.c: New test.

Signed-off-by: Andrew Pinski 
(cherry picked from commit cea87c84eacdb422caeada734ba5138c994d7022)

Diff:
---
 gcc/gimple-ssa-backprop.cc  | 10 --
 gcc/testsuite/gcc.dg/torture/pr116922.c | 19 +++
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/gcc/gimple-ssa-backprop.cc b/gcc/gimple-ssa-backprop.cc
index fe27ef51cdf2..e3374b181386 100644
--- a/gcc/gimple-ssa-backprop.cc
+++ b/gcc/gimple-ssa-backprop.cc
@@ -663,8 +663,14 @@ remove_unused_var (tree var)
   print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM);
 }
   gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
-  gsi_remove (&gsi, true);
-  release_defs (stmt);
+  if (gimple_code (stmt) == GIMPLE_PHI)
+remove_phi_node (&gsi, true);
+  else
+{
+  unlink_stmt_vdef (stmt);
+  gsi_remove (&gsi, true);
+  release_defs (stmt);
+}
 }
 
 /* Note that we're replacing OLD_RHS with NEW_RHS in STMT.  */
diff --git a/gcc/testsuite/gcc.dg/torture/pr116922.c 
b/gcc/testsuite/gcc.dg/torture/pr116922.c
new file mode 100644
index ..0fcf912930f4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr116922.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-ffast-math" } */
+/* PR tree-optimization/116922 */
+
+
+static int g;
+
+void
+foo (int c, double v, double *r)
+{
+b:
+  do
+v /= g - v;
+  while (c);
+  *r = v;
+
+  double x;
+  foo (5, (double)0, &x);
+}


[gcc] Created branch 'meissner/heads/work201-paddis' in namespace 'refs/users'

2025-04-14 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work201-paddis' was created in namespace 
'refs/users' pointing to:

 b5abb63c30bd... Add ChangeLog.meissner and REVISION.


[gcc(refs/users/meissner/heads/work201-math)] Add ChangeLog.math and update REVISION.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:faf9364c987569b9f6807649b10902f7e20b2afb

commit faf9364c987569b9f6807649b10902f7e20b2afb
Author: Michael Meissner 
Date:   Mon Apr 14 15:17:52 2025 -0400

Add ChangeLog.math and update REVISION.

2025-04-14  Michael Meissner  

gcc/

* ChangeLog.math: New file for branch.
* REVISION: Update.

Diff:
---
 gcc/ChangeLog.math | 5 +
 gcc/REVISION   | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.math b/gcc/ChangeLog.math
new file mode 100644
index ..fe8cef4665ad
--- /dev/null
+++ b/gcc/ChangeLog.math
@@ -0,0 +1,5 @@
+ Branch work201-math, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/REVISION b/gcc/REVISION
index 5f8715c4844d..6f5edba6571c 100644
--- a/gcc/REVISION
+++ b/gcc/REVISION
@@ -1 +1 @@
-work201 branch
+work201-math branch


[gcc] Created branch 'meissner/heads/work201-sha' in namespace 'refs/users'

2025-04-14 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work201-sha' was created in namespace 'refs/users' 
pointing to:

 b5abb63c30bd... Add ChangeLog.meissner and REVISION.


[gcc(refs/users/meissner/heads/work201-paddis)] Add ChangeLog.paddis and update REVISION.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:f20a5086a2cf96e96dc36d320b0a6d434a6aa877

commit f20a5086a2cf96e96dc36d320b0a6d434a6aa877
Author: Michael Meissner 
Date:   Mon Apr 14 15:19:36 2025 -0400

Add ChangeLog.paddis and update REVISION.

2025-04-14  Michael Meissner  

gcc/

* ChangeLog.paddis: New file for branch.
* REVISION: Update.

Diff:
---
 gcc/ChangeLog.paddis | 5 +
 gcc/REVISION | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.paddis b/gcc/ChangeLog.paddis
new file mode 100644
index ..b8c9b5293f20
--- /dev/null
+++ b/gcc/ChangeLog.paddis
@@ -0,0 +1,5 @@
+ Branch work201-paddis, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/REVISION b/gcc/REVISION
index 5f8715c4844d..d90dc19a4f8f 100644
--- a/gcc/REVISION
+++ b/gcc/REVISION
@@ -1 +1 @@
-work201 branch
+work201-paddis branch


[gcc] Created branch 'meissner/heads/work201-orig' in namespace 'refs/users'

2025-04-14 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work201-orig' was created in namespace 'refs/users' 
pointing to:

 ebdf92b6067a... testsuite: Fix up ipa/pr119530.c testcase [PR119318]


[gcc(refs/users/meissner/heads/work201-libs)] Add ChangeLog.libs and update REVISION.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:95d53c351e59dd8649b88702c9cf8df17f775ef8

commit 95d53c351e59dd8649b88702c9cf8df17f775ef8
Author: Michael Meissner 
Date:   Mon Apr 14 15:15:07 2025 -0400

Add ChangeLog.libs and update REVISION.

2025-04-14  Michael Meissner  

gcc/

* ChangeLog.libs: New file for branch.
* REVISION: Update.

Diff:
---
 gcc/ChangeLog.libs | 5 +
 gcc/REVISION   | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.libs b/gcc/ChangeLog.libs
new file mode 100644
index ..69f46576250c
--- /dev/null
+++ b/gcc/ChangeLog.libs
@@ -0,0 +1,5 @@
+ Branch work201-libs, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/REVISION b/gcc/REVISION
index 5f8715c4844d..7dae70785b31 100644
--- a/gcc/REVISION
+++ b/gcc/REVISION
@@ -1 +1 @@
-work201 branch
+work201-libs branch


[gcc] Created branch 'meissner/heads/work201-submit' in namespace 'refs/users'

2025-04-14 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work201-submit' was created in namespace 
'refs/users' pointing to:

 b5abb63c30bd... Add ChangeLog.meissner and REVISION.


[gcc r14-11610] testcase: Add testcase for already fixed PR [PR118476]

2025-04-14 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:52b97f984f2f2dfd1e1d815a2c75153568718462

commit r14-11610-g52b97f984f2f2dfd1e1d815a2c75153568718462
Author: Andrew Pinski 
Date:   Mon Apr 14 08:40:24 2025 -0700

testcase: Add testcase for already fixed PR [PR118476]

This testcase was fixed by r15-3052-gc7b76a076cb2c6ded but is
a testcase that failed in a different fashion and a much older
failure than the one added with r15-3052.

Pushed as obvious after a quick test.

PR tree-optimization/118476

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr118476-1.c: New test.

Signed-off-by: Andrew Pinski 
(cherry picked from commit d45a6502d1ec87d43f1a39f87cca58f1e28369c8)

Diff:
---
 gcc/testsuite/gcc.dg/torture/pr118476-1.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/torture/pr118476-1.c 
b/gcc/testsuite/gcc.dg/torture/pr118476-1.c
new file mode 100644
index ..33509403b61a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr118476-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+/* PR tree-optimization/118476 */
+
+typedef unsigned long long poly64x1 
__attribute__((__vector_size__(1*sizeof(long long;
+
+poly64x1 vext_p64(poly64x1 a, poly64x1 b, const int n)
+{
+  poly64x1 r = a;
+  unsigned src = (unsigned)n;
+  long long t = b[0];
+  r[0] = (src < 1) ? a[src] : t;
+  return r;
+}


[gcc] Created branch 'meissner/heads/work201-test' in namespace 'refs/users'

2025-04-14 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work201-test' was created in namespace 'refs/users' 
pointing to:

 b5abb63c30bd... Add ChangeLog.meissner and REVISION.


[gcc(refs/users/mikael/heads/refactor_descriptor_v05)] Retour en arrière délinearisation tableaux compil' OK.

2025-04-14 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:22ce751b60bba098a6e0c2a75cd4d1e882eaa51a

commit 22ce751b60bba098a6e0c2a75cd4d1e882eaa51a
Author: Mikael Morin 
Date:   Mon Apr 14 13:52:49 2025 +0200

Retour en arrière délinearisation tableaux compil' OK.

Diff:
---
 gcc/fortran/trans-array.cc  | 353 +---
 gcc/fortran/trans-decl.cc   |  35 +---
 gcc/fortran/trans-descriptor.cc |  33 
 gcc/fortran/trans-types.cc  |  60 +++
 libgfortran/caf/single.c|   4 +-
 5 files changed, 136 insertions(+), 349 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index fa84f007bee5..41d0a612edf5 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -2169,43 +2169,6 @@ gfc_build_constant_array_constructor (gfc_expr * expr, 
tree type)
   gfc_free_expr (as.upper[i]);
 }
 
-  if (expr->shape && expr->rank > 1)
-{
-  vec *vsrc = v;
-
-  for (int r = 0; r < expr->rank - 1; r++)
-   {
- vec *vdest = nullptr;
- unsigned sidx = 0;
-
- tree type = tmptype;
- for (int j = expr->rank - 1; j > r; j--)
-   {
- gcc_assert (TREE_CODE (type) == ARRAY_TYPE); 
- type = TREE_TYPE (type);
-   }
-
- int len = (int) mpz_get_si (expr->shape[r]);
-
- while (sidx != vec_safe_length (vsrc))
-   {
- vec *vtmp = nullptr;
-
- for (int i = 0; i < len; i++)
-   {
- append_constructor (vtmp, (*vsrc)[sidx].value);
- sidx++;
-   }
-
- append_constructor (vdest, build_constructor (type, vtmp));
-   }
-
- vsrc = vdest;
-   }
-
-  v = vsrc;
-}
-
   init = build_constructor (tmptype, v);
 
   TREE_CONSTANT (init) = 1;
@@ -3007,6 +2970,11 @@ gfc_conv_ss_descriptor (stmtblock_t * block, gfc_ss * 
ss, int base)
   if (!ss->is_alloc_lhs)
tmp = gfc_evaluate_now (tmp, block);
   info->offset = tmp;
+
+  /* Make absolutely sure that the saved_offset is indeed saved
+so that the variable is still accessible after the loops
+are translated.  */
+  info->saved_data = info->data;
 }
 }
 
@@ -3359,82 +3327,6 @@ array_bound_check_elemental (gfc_se * se, gfc_ss * ss, 
gfc_expr * expr)
 }
 
 
-/* Build a scalarized array reference using the vptr 'size'.  */
-
-static bool
-build_class_array_ref (gfc_se *se, tree base, tree index)
-{
-  tree size;
-  tree decl = NULL_TREE;
-  tree tmp;
-  gfc_expr *expr = se->ss->info->expr;
-  gfc_expr *class_expr;
-  gfc_typespec *ts;
-  gfc_symbol *sym;
-
-  tmp = !VAR_P (base) ? gfc_get_class_from_expr (base) : NULL_TREE;
-
-  if (tmp != NULL_TREE)
-decl = tmp;
-  else
-{
-  /* The base expression does not contain a class component, either
-because it is a temporary array or array descriptor.  Class
-array functions are correctly resolved above.  */
-  if (!expr
- || (expr->ts.type != BT_CLASS
- && !gfc_is_class_array_ref (expr, NULL)))
-   return false;
-
-  /* Obtain the expression for the class entity or component that is
-followed by an array reference, which is not an element, so that
-the span of the array can be obtained.  */
-  class_expr = gfc_find_and_cut_at_last_class_ref (expr, false, &ts);
-
-  if (!ts)
-   return false;
-
-  sym = (!class_expr && expr) ? expr->symtree->n.sym : NULL;
-  if (sym && sym->attr.function
- && sym == sym->result
- && sym->backend_decl == current_function_decl)
-   /* The temporary is the data field of the class data component
-  of the current function.  */
-   decl = gfc_get_fake_result_decl (sym, 0);
-  else if (sym)
-   {
- if (decl == NULL_TREE)
-   decl = expr->symtree->n.sym->backend_decl;
- /* For class arrays the tree containing the class is stored in
-GFC_DECL_SAVED_DESCRIPTOR of the sym's backend_decl.
-For all others it's sym's backend_decl directly.  */
- if (DECL_LANG_SPECIFIC (decl) && GFC_DECL_SAVED_DESCRIPTOR (decl))
-   decl = GFC_DECL_SAVED_DESCRIPTOR (decl);
-   }
-  else
-   decl = gfc_get_class_from_gfc_expr (class_expr);
-
-  if (POINTER_TYPE_P (TREE_TYPE (decl)))
-   decl = build_fold_indirect_ref_loc (input_location, decl);
-
-  if (!GFC_CLASS_TYPE_P (TREE_TYPE (decl)))
-   return false;
-}
-
-  se->class_vptr = gfc_evaluate_now (gfc_class_vptr_get (decl), &se->pre);
-
-  size = gfc_class_vtab_size_get (decl);
-  /* For unlimited polymorphic entities then _len component needs to be
- multiplied with the size.  */
-  size = gfc_resize_class_size_with_len (&se->pre, decl, size);
-  size = fold_convert (gfc_array_index_type, size);
-
-  /* Return the element in the se expression.  */
-  se->expr = gfc_build_spanned_array_ref (base, index, size);
-  return true;
-}
-
-
 /* Ind

[gcc(refs/users/mikael/heads/refactor_descriptor_v05)] Correction régression ISO_Fortran_binding_14.f90

2025-04-14 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:650dc7274c9d7bab9a010ae93fca1aee7e2ee1f0

commit 650dc7274c9d7bab9a010ae93fca1aee7e2ee1f0
Author: Mikael Morin 
Date:   Mon Apr 14 17:43:04 2025 +0200

Correction régression ISO_Fortran_binding_14.f90

Diff:
---
 gcc/fortran/trans-types.cc | 20 
 1 file changed, 20 insertions(+)

diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc
index c8d56ec55999..0c07de4bd18a 100644
--- a/gcc/fortran/trans-types.cc
+++ b/gcc/fortran/trans-types.cc
@@ -1994,6 +1994,26 @@ gfc_get_nodesc_array_type (tree etype, gfc_array_spec * 
as, gfc_packed packed,
   else
 GFC_TYPE_ARRAY_SIZE (type) = NULL_TREE;
 
+  if (as->rank != 0)
+{
+  tree max_idx;
+  if (known_stride)
+   {
+ mpz_t size;
+ mpz_init (size);
+ mpz_sub_ui (size, stride, 1);
+ max_idx = gfc_conv_mpz_to_tree (size, gfc_index_integer_kind);
+   }
+  else
+   max_idx = NULL_TREE;
+
+  TYPE_DOMAIN (type) = build_range_type (gfc_array_index_type,
+gfc_index_zero_node, max_idx);
+  TREE_TYPE (type) = etype;
+}
+
+  layout_type (type);
+
   if (packed != PACKED_NO)
 GFC_TYPE_ARRAY_ELEM_LEN (type) = TYPE_SIZE_UNIT (etype);


[gcc(refs/users/mikael/heads/refactor_descriptor_v05)] Correction ISO_Fortran_binding_18.f90

2025-04-14 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:84a4b72e8e5b98e35554044aa42a7592a79557b9

commit 84a4b72e8e5b98e35554044aa42a7592a79557b9
Author: Mikael Morin 
Date:   Mon Apr 14 18:16:13 2025 +0200

Correction ISO_Fortran_binding_18.f90

Diff:
---
 gcc/fortran/trans-array.cc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 41d0a612edf5..8cd7de71fe4a 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -3722,6 +3722,8 @@ add_array_offset (stmtblock_t *pblock, gfc_loopinfo 
*loop, gfc_ss *ss,
 
   info = &ss->info->data.array;
 
+  tree type = TREE_TYPE (info->data);
+
   gfc_init_se (&se, NULL);
   se.loop = loop;
   se.expr = info->descriptor;
@@ -3731,6 +3733,7 @@ add_array_offset (stmtblock_t *pblock, gfc_loopinfo 
*loop, gfc_ss *ss,
 
   tree tmp = build_array_ref_dim (ss, index, info->spacing[array_dim]);
   tmp = gfc_build_addr_expr (NULL_TREE, tmp);
+  tmp = fold_convert_loc (input_location, type, tmp);
   info->data = gfc_evaluate_now (tmp, pblock);
 }


[gcc r14-11604] Fortran: fix issue with impure elemental subroutine and interface [PR119656]

2025-04-14 Thread Harald Anlauf via Gcc-cvs
https://gcc.gnu.org/g:477d8ba89ff71592f7d66fb01a4d10018e86e502

commit r14-11604-g477d8ba89ff71592f7d66fb01a4d10018e86e502
Author: Harald Anlauf 
Date:   Tue Apr 8 22:30:15 2025 +0200

Fortran: fix issue with impure elemental subroutine and interface [PR119656]

PR fortran/119656

gcc/fortran/ChangeLog:

* interface.cc (gfc_compare_actual_formal): Fix front-end memleak
when searching for matching interfaces.
* trans-expr.cc (gfc_conv_procedure_call): If there is a formal
dummy corresponding to an absent argument, use its type, and only
fall back to inferred type otherwise.

gcc/testsuite/ChangeLog:

* gfortran.dg/optional_absent_13.f90: New test.

(cherry picked from commit 334545194d9023fb9b2f72ee0dcde8af94930f25)

Diff:
---
 gcc/fortran/interface.cc |  6 ++-
 gcc/fortran/trans-expr.cc| 18 ++---
 gcc/testsuite/gfortran.dg/optional_absent_13.f90 | 48 
 3 files changed, 65 insertions(+), 7 deletions(-)

diff --git a/gcc/fortran/interface.cc b/gcc/fortran/interface.cc
index c4f3a3b03fbe..25f27f83458c 100644
--- a/gcc/fortran/interface.cc
+++ b/gcc/fortran/interface.cc
@@ -3291,7 +3291,11 @@ gfc_compare_actual_formal (gfc_actual_arglist **ap, 
gfc_formal_arglist *formal,
  return false;
}
   else
-   a->associated_dummy = get_nonintrinsic_dummy_arg (f);
+   {
+ if (a->associated_dummy)
+   free (a->associated_dummy);
+ a->associated_dummy = get_nonintrinsic_dummy_arg (f);
+   }
 
   if (a->expr == NULL)
{
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index cf6511852132..1f0361d55d8b 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -6543,10 +6543,18 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
{
  /* Pass a NULL pointer for an absent arg.  */
  parmse.expr = null_pointer_node;
+
+ /* Is it an absent character dummy?  */
+ bool absent_char = false;
  gfc_dummy_arg * const dummy_arg = arg->associated_dummy;
- if (dummy_arg
- && gfc_dummy_arg_get_typespec (*dummy_arg).type
-== BT_CHARACTER)
+
+ /* Fall back to inferred type only if no formal.  */
+ if (fsym)
+   absent_char = (fsym->ts.type == BT_CHARACTER);
+ else if (dummy_arg)
+   absent_char = (gfc_dummy_arg_get_typespec (*dummy_arg).type
+  == BT_CHARACTER);
+ if (absent_char)
parmse.string_length = build_int_cst (gfc_charlen_type_node,
  0);
}
@@ -6563,9 +6571,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
  || !CLASS_DATA (fsym)->attr.allocatable));
  gfc_init_se (&parmse, NULL);
  parmse.expr = null_pointer_node;
- if (arg->associated_dummy
- && gfc_dummy_arg_get_typespec (*arg->associated_dummy).type
-== BT_CHARACTER)
+ if (fsym->ts.type == BT_CHARACTER)
parmse.string_length = build_int_cst (gfc_charlen_type_node, 0);
}
   else if (fsym && fsym->ts.type == BT_CLASS
diff --git a/gcc/testsuite/gfortran.dg/optional_absent_13.f90 
b/gcc/testsuite/gfortran.dg/optional_absent_13.f90
new file mode 100644
index ..9c2039bfb3f6
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/optional_absent_13.f90
@@ -0,0 +1,48 @@
+! { dg-do run }
+! PR fortran/119656 - wrong code with impure elemental subroutine and interface
+!
+! Derived from testcase at:
+!   https://fortran-lang.discourse.group/t/
+! problem-with-impure-elemental-subroutine-in-interface-with-gfortran/9545
+
+module m2
+  implicit none
+  interface foo
+ module procedure foo_mat
+ module procedure foo_df
+ module procedure foo_cmat
+  end interface foo
+contains
+
+  subroutine foo_mat(x, nacf, label)
+real, intent(in)   :: x(:,:)
+integer,  intent(in)   :: nacf
+character(len=*), intent(in), optional :: label
+  end subroutine foo_mat
+
+  impure elemental subroutine foo_df(nacf, outu, xstr)
+integer , intent(in)   :: nacf
+integer , intent(in), optional :: outu
+character(len=*), intent(in), optional :: xstr
+if (present(xstr)) then
+   if (len (xstr) /= 2) then
+  print *,"nacf, len(xstr) =", nacf, len(xstr)
+  stop nacf
+   end if
+end if
+  end subroutine foo_df
+
+  subroutine foo_cmat(x, nacf, label)
+complex,  intent(in)   :: x(:,:)
+integer,  intent(in)   :: nacf
+character(len=*), intent(in), optional :: lab

[gcc r15-9433] c++: wrong targs in satisfaction diagnostic context line [PR99214]

2025-04-14 Thread Patrick Palka via Gcc-cvs
https://gcc.gnu.org/g:00966a7fdb1478b3af5254ff3a80a3ef336c5a94

commit r15-9433-g00966a7fdb1478b3af5254ff3a80a3ef336c5a94
Author: Patrick Palka 
Date:   Mon Apr 14 11:20:13 2025 -0400

c++: wrong targs in satisfaction diagnostic context line [PR99214]

In the three-parameter version of satisfy_declaration_constraints, when
't' isn't the most general template, then 't' won't correspond with
'args' after we augment the latter via add_outermost_template_args, and
so the instantiation context that we push via push_tinst_level isn't
quite correct: 'args' is a complete set of template arguments, but 't'
is not necessarily the most general template.  This manifests as
misleading diagnostic context lines when issuing a satisfaction failure
error, e.g.  the below testcase without this patch we emit:
  In substitution of '... void A::f() ... [with U = int]'
and with this patch we emit:
  In substitution of '... void A::f() ... [with U = char]'.

This patch fixes this by passing the original 'args' to push_tinst_level,
which ought to properly correspond to 't'.

PR c++/99214

gcc/cp/ChangeLog:

* constraint.cc (satisfy_declaration_constraints): Pass the
original ARGS to push_tinst_level.

gcc/testsuite/ChangeLog:

* g++.dg/concepts/diagnostic20.C: New test.

Reviewed-by: Jason Merrill 

Diff:
---
 gcc/cp/constraint.cc |  4 +++-
 gcc/testsuite/g++.dg/concepts/diagnostic20.C | 13 +
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc
index 2f1678ce4ff9..44fb086c6306 100644
--- a/gcc/cp/constraint.cc
+++ b/gcc/cp/constraint.cc
@@ -2704,6 +2704,8 @@ satisfy_declaration_constraints (tree t, sat_info info)
 static tree
 satisfy_declaration_constraints (tree t, tree args, sat_info info)
 {
+  tree orig_args = args;
+
   /* Update the declaration for diagnostics.  */
   info.in_decl = t;
 
@@ -2732,7 +2734,7 @@ satisfy_declaration_constraints (tree t, tree args, 
sat_info info)
   tree result = boolean_true_node;
   if (tree norm = get_normalized_constraints_from_decl (t, info.noisy ()))
 {
-  if (!push_tinst_level (t, args))
+  if (!push_tinst_level (t, orig_args))
return result;
   tree pattern = DECL_TEMPLATE_RESULT (t);
   push_to_top_level ();
diff --git a/gcc/testsuite/g++.dg/concepts/diagnostic20.C 
b/gcc/testsuite/g++.dg/concepts/diagnostic20.C
new file mode 100644
index ..2bb01db44dec
--- /dev/null
+++ b/gcc/testsuite/g++.dg/concepts/diagnostic20.C
@@ -0,0 +1,13 @@
+// PR c++/99214
+// { dg-do compile { target c++20 } }
+
+template 
+struct A {
+  template  static void f() requires requires { T::fail; };
+};
+
+int main() {
+  A::f(); // { dg-error "no match" }
+}
+
+// { dg-message "In substitution of '\[^\r\n\]* \\\[with U = char\\\]'" "" { 
target *-*-* } 0 }


[gcc r15-9447] gccrs: Fix const checking of enum discriminants

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:85a57bf4708085cc522732a9b7b2b0f6b1882125

commit r15-9447-g85a57bf4708085cc522732a9b7b2b0f6b1882125
Author: Owen Avery 
Date:   Sat Apr 5 17:20:44 2025 -0400

gccrs: Fix const checking of enum discriminants

gcc/rust/ChangeLog:

* checks/errors/rust-const-checker.cc
(ConstChecker::visit): Visit the enum items of enums.
* resolve/rust-ast-resolve-item.cc
(ResolveItem::visit): Resolve enum discriminants during nr1.0.

gcc/testsuite/ChangeLog:

* rust/compile/enum_discriminant2.rs: New test.

Signed-off-by: Owen Avery 

Diff:
---
 gcc/rust/checks/errors/rust-const-checker.cc | 3 +++
 gcc/rust/resolve/rust-ast-resolve-item.cc| 2 ++
 gcc/testsuite/rust/compile/enum_discriminant2.rs | 9 +
 3 files changed, 14 insertions(+)

diff --git a/gcc/rust/checks/errors/rust-const-checker.cc 
b/gcc/rust/checks/errors/rust-const-checker.cc
index 4904322b9382..4c2257a24556 100644
--- a/gcc/rust/checks/errors/rust-const-checker.cc
+++ b/gcc/rust/checks/errors/rust-const-checker.cc
@@ -646,6 +646,9 @@ ConstChecker::visit (Enum &enum_item)
 {
   check_default_const_generics (enum_item.get_generic_params (),
ConstGenericCtx::Enum);
+
+  for (auto &item : enum_item.get_variants ())
+item->accept_vis (*this);
 }
 
 void
diff --git a/gcc/rust/resolve/rust-ast-resolve-item.cc 
b/gcc/rust/resolve/rust-ast-resolve-item.cc
index d584961354fd..30f6d430b861 100644
--- a/gcc/rust/resolve/rust-ast-resolve-item.cc
+++ b/gcc/rust/resolve/rust-ast-resolve-item.cc
@@ -356,6 +356,8 @@ ResolveItem::visit (AST::EnumItemDiscriminant &item)
   auto cpath = canonical_prefix.append (decl);
 
   mappings.insert_canonical_path (item.get_node_id (), cpath);
+
+  ResolveExpr::go (item.get_expr (), path, cpath);
 }
 
 void
diff --git a/gcc/testsuite/rust/compile/enum_discriminant2.rs 
b/gcc/testsuite/rust/compile/enum_discriminant2.rs
new file mode 100644
index ..351dfbb6f85d
--- /dev/null
+++ b/gcc/testsuite/rust/compile/enum_discriminant2.rs
@@ -0,0 +1,9 @@
+fn test() -> isize {
+1
+}
+
+enum Foo {
+Bar = test() // { dg-error "only functions marked as .const." }
+}
+
+fn main() {}


[gcc r15-9456] cobol: Fix up COBOL -include [PR119777]

2025-04-14 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:d0b41f3d6d0ace2b0ca57d105cd7fd8361d0b2a8

commit r15-9456-gd0b41f3d6d0ace2b0ca57d105cd7fd8361d0b2a8
Author: Jakub Jelinek 
Date:   Mon Apr 14 19:32:43 2025 +0200

cobol: Fix up COBOL -include [PR119777]

I was looking through options.cc diff between GCC 14 and 15, looking for
entries with added CL_Cobol where at least one other language is present
and was present before too.  Besides the -fsyntax-only changes this is
the only other one I found, COBOL adds Var(cobol_include) to something
which didn't have a Var at all before and IMHO it is actively harmful.
Because one can specify multiple -include file1 -include file2 options,
both in C/C++ etc. and in COBOL as well (as documented in the man
page).  A Var can track just one entry.  cobol_langhook_handle_option
should use arg instead.

2025-04-14  Jakub Jelinek  

PR cobol/119777
* lang.opt (include): Remove Var(cobol_include).
* cobol1.cc (cobol_langhook_handle_option) : Use
arg instead of cobol_include.

Diff:
---
 gcc/cobol/cobol1.cc | 4 ++--
 gcc/cobol/lang.opt  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/cobol/cobol1.cc b/gcc/cobol/cobol1.cc
index 98d15a8d1eda..7d742b907764 100644
--- a/gcc/cobol/cobol1.cc
+++ b/gcc/cobol/cobol1.cc
@@ -413,8 +413,8 @@ cobol_langhook_handle_option (size_t scode,
   }
   return true;
 case OPT_include:
-  if( ! include_file_add(cobol_include) ) {
-cbl_errx( "could not include %s", cobol_include);
+  if( ! include_file_add(arg) ) {
+cbl_errx( "could not include %s", arg);
   }
 return true;
 
diff --git a/gcc/cobol/lang.opt b/gcc/cobol/lang.opt
index 142ec4f34bf2..1d33f34aceeb 100644
--- a/gcc/cobol/lang.opt
+++ b/gcc/cobol/lang.opt
@@ -114,7 +114,7 @@ Cobol Joined Separate
 ; Documented in C
 
 include
-Cobol Joined Separate Var(cobol_include)
+Cobol Joined Separate
 ; Documented in C
 
 isysroot


[gcc r15-9459] testsuite: Fix up ipa/pr119530.c testcase [PR119318]

2025-04-14 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:ebdf92b6067a357e7bb08bfde294cc19b50e6abb

commit r15-9459-gebdf92b6067a357e7bb08bfde294cc19b50e6abb
Author: Jakub Jelinek 
Date:   Mon Apr 14 19:35:20 2025 +0200

testsuite: Fix up ipa/pr119530.c testcase [PR119318]

I'm seeing
+FAIL: gcc.dg/ipa/pr119530.c execution test
on i686-linux.  The problem is that when long is just 32-bit and
so is unsigned, the testcase then behaves differently and should abort.
Fixed by making the argument long long instead.
While at it, just in case I've changed type of d variable to signed char
as well just in case there is -funsigned-char 8-bit int target or something
similar.

2025-04-14  Jakub Jelinek  

PR ipa/119318
* gcc.dg/ipa/pr119530.c (d): Change type from char to signed char.
(e): Change argument type from long to long long.

Diff:
---
 gcc/testsuite/gcc.dg/ipa/pr119530.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/ipa/pr119530.c 
b/gcc/testsuite/gcc.dg/ipa/pr119530.c
index 70f158a2de84..f99c4fdbe20c 100644
--- a/gcc/testsuite/gcc.dg/ipa/pr119530.c
+++ b/gcc/testsuite/gcc.dg/ipa/pr119530.c
@@ -5,8 +5,8 @@ struct a {
   int b;
 };
 int c;
-char d;
-static int e(long f) { return f < 0; }
+signed char d;
+static int e(long long f) { return f < 0; }
 static void g(unsigned f) { c = e(~f); }
 int main() {
   int h;


[gcc(refs/users/meissner/heads/work201-orig)] Add REVISION.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:7cfd776ecfdadf03f835e0547b1e2b901d19c671

commit 7cfd776ecfdadf03f835e0547b1e2b901d19c671
Author: Michael Meissner 
Date:   Mon Apr 14 15:20:36 2025 -0400

Add REVISION.

2025-04-14  Michael Meissner  

gcc/

* REVISION: New file for branch.

Diff:
---
 gcc/REVISION | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/REVISION b/gcc/REVISION
new file mode 100644
index ..311ed3c92ba2
--- /dev/null
+++ b/gcc/REVISION
@@ -0,0 +1 @@
+work201-orig branch


[gcc] Created branch 'meissner/heads/work201-libs' in namespace 'refs/users'

2025-04-14 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work201-libs' was created in namespace 'refs/users' 
pointing to:

 b5abb63c30bd... Add ChangeLog.meissner and REVISION.


[gcc(refs/users/meissner/heads/work201-sha)] Add ChangeLog.sha and update REVISION.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:0339a910393a1f7eb4dd09dc6bbd624909557b40

commit 0339a910393a1f7eb4dd09dc6bbd624909557b40
Author: Michael Meissner 
Date:   Mon Apr 14 15:16:10 2025 -0400

Add ChangeLog.sha and update REVISION.

2025-04-14  Michael Meissner  

gcc/

* ChangeLog.sha: New file for branch.
* REVISION: Update.

Diff:
---
 gcc/ChangeLog.sha | 5 +
 gcc/REVISION  | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.sha b/gcc/ChangeLog.sha
new file mode 100644
index ..389f91f54250
--- /dev/null
+++ b/gcc/ChangeLog.sha
@@ -0,0 +1,5 @@
+ Branch work201-sha, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/REVISION b/gcc/REVISION
index 5f8715c4844d..4363e39c6b26 100644
--- a/gcc/REVISION
+++ b/gcc/REVISION
@@ -1 +1 @@
-work201 branch
+work201-sha branch


[gcc r14-11605] phiopt: Fix VCE moving by rewriting it into cast [PR116098]

2025-04-14 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:c2c1046b83a92283cd0863942efe9df453d78a78

commit r14-11605-gc2c1046b83a92283cd0863942efe9df453d78a78
Author: Andrew Pinski 
Date:   Tue Oct 1 18:34:00 2024 +

phiopt: Fix VCE moving by rewriting it into cast [PR116098]

Phiopt match_and_simplify might move a well defined VCE assign statement
from being conditional to being uncondtitional; that VCE might no longer
being defined. It will need a rewrite into a cast instead.

This adds the rewriting code to move_stmt for the VCE case.
This is enough to fix the issue at hand. It should also be using 
rewrite_to_defined_overflow
but first I need to move the check to see a rewrite is needed into its own 
function
and that is causing issues (see 
https://gcc.gnu.org/pipermail/gcc-patches/2024-September/663938.html).
Plus this version is easiest to backport.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/116098

gcc/ChangeLog:

* tree-ssa-phiopt.cc (move_stmt): Rewrite VCEs from integer to 
integer
types to case.

gcc/testsuite/ChangeLog:

* c-c++-common/torture/pr116098-2.c: New test.
* g++.dg/torture/pr116098-1.C: New test.

Signed-off-by: Andrew Pinski 
(cherry picked from commit 1f619fe25925a5f79b9c33962e7a72e1f9fa)

Diff:
---
 gcc/testsuite/c-c++-common/torture/pr116098-2.c | 46 +
 gcc/testsuite/g++.dg/torture/pr116098-1.C   | 33 ++
 gcc/tree-ssa-phiopt.cc  | 28 ++-
 3 files changed, 106 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/c-c++-common/torture/pr116098-2.c 
b/gcc/testsuite/c-c++-common/torture/pr116098-2.c
new file mode 100644
index ..614ed0491717
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/torture/pr116098-2.c
@@ -0,0 +1,46 @@
+/* { dg-do run } */
+/* PR tree-optimization/116098 */
+
+
+#include 
+
+struct Value {
+int type;
+union {
+bool boolean;
+long long t;
+};
+};
+
+static struct Value s_item_mem;
+
+/* truthy was being miscompiled for the value.type==2 case,
+   because we would have a VCE from unsigned char to bool
+   that went from being conditional in the value.type==1 case
+   to unconditional when `value.type!=0`.
+   The move of the VCE from conditional to unconditional,
+   needs to changed into a convert (NOP_EXPR). */
+static bool truthy(void) __attribute__((noipa));
+static bool
+truthy(void)
+{
+struct Value value = s_item_mem;
+if (value.type == 0)
+  return 0;
+if (value.type == 1)
+  return value.boolean;
+return 1;
+}
+
+int
+main(void)
+{
+s_item_mem.type = 2;
+s_item_mem.t = -1;
+bool b1 = !truthy();
+s_item_mem.type = 1;
+s_item_mem.boolean = b1;
+bool b = truthy();
+if (b1 != b)  __builtin_abort();
+if (b) __builtin_abort();
+}
diff --git a/gcc/testsuite/g++.dg/torture/pr116098-1.C 
b/gcc/testsuite/g++.dg/torture/pr116098-1.C
new file mode 100644
index ..90e44a6eeedb
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr116098-1.C
@@ -0,0 +1,33 @@
+// { dg-do run }
+/* PR tree-optimization/116098 */
+
+
+static bool truthy(int type, unsigned char data) __attribute__((noipa));
+/* truthy was being miscompiled for the type==2 case,
+   because we would have a VCE from unsigned char to bool
+   that went from being conditional in the type==1 case
+   to unconditional when `type!=0`.
+   The move of the VCE from conditional to unconditional,
+   needs to changed into a convert (NOP_EXPR). */
+
+static bool truthy(void) __attribute__((noipa));
+static bool
+truthy(int type, unsigned char data)
+{
+if (type == 0)
+  return 0;
+if (type == 1)
+  /* Emulate what SRA does, so this can be
+tested without depending on SRA. */
+  return __builtin_bit_cast (bool, data);
+return 1;
+}
+
+int
+main(void)
+{
+bool b1 = !truthy(2, -1);
+bool b = truthy(1, b1);
+if (b1 != b)  __builtin_abort();
+if (b) __builtin_abort();
+}
diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
index f01979aa0038..fa8dc2c8a4e3 100644
--- a/gcc/tree-ssa-phiopt.cc
+++ b/gcc/tree-ssa-phiopt.cc
@@ -728,7 +728,8 @@ empty_bb_or_one_feeding_into_p (basic_block bb,
 }
 
 /* Move STMT to before GSI and insert its defining
-   name into INSERTED_EXPRS bitmap. */
+   name into INSERTED_EXPRS bitmap.
+   Also rewrite its if it might be undefined when unconditionalized.  */
 static void
 move_stmt (gimple *stmt, gimple_stmt_iterator *gsi, auto_bitmap 
&inserted_exprs)
 {
@@ -747,6 +748,31 @@ move_stmt (gimple *stmt, gimple_stmt_iterator *gsi, 
auto_bitmap &inserted_exprs)
   gimple_stmt_iterator gsi1 = gsi_for_stmt (stmt);
   gsi_move_before (&gsi1, gsi);
   reset_flow_sensitive_info (name);
+
+  /* Rewrite some code which might be undefined when
+ unconditionalized. */
+  if (gimple_assign_single_p (stmt))
+{
+  

[gcc r15-9452] gccrs: attributes: Handle external tool annotations like rustfmt::

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:73d72498f97f601414919607ebf150b69694ce16

commit r15-9452-g73d72498f97f601414919607ebf150b69694ce16
Author: Arthur Cohen 
Date:   Wed Apr 9 15:17:38 2025 +0200

gccrs: attributes: Handle external tool annotations like rustfmt::

gcc/rust/ChangeLog:

* util/rust-attribute-values.h: Add RUSTFMT value.
* util/rust-attributes.cc: Define the attribute.
* util/rust-attributes.h (enum CompilerPass): Add EXTERNAL variant.
* expand/rust-macro-builtins.cc: Fix formatting.

Diff:
---
 gcc/rust/expand/rust-macro-builtins.cc | 1 -
 gcc/rust/util/rust-attribute-values.h  | 2 ++
 gcc/rust/util/rust-attributes.cc   | 3 ++-
 gcc/rust/util/rust-attributes.h| 5 -
 4 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/gcc/rust/expand/rust-macro-builtins.cc 
b/gcc/rust/expand/rust-macro-builtins.cc
index a1388fb1dfb3..8b406fff9e63 100644
--- a/gcc/rust/expand/rust-macro-builtins.cc
+++ b/gcc/rust/expand/rust-macro-builtins.cc
@@ -83,7 +83,6 @@ const BiMap MacroBuiltin::builtins 
= {{
   {"Ord", BuiltinMacro::Ord},
   {"PartialOrd", BuiltinMacro::PartialOrd},
   {"Hash", BuiltinMacro::Hash},
-
 }};
 
 AST::MacroTranscriberFunc
diff --git a/gcc/rust/util/rust-attribute-values.h 
b/gcc/rust/util/rust-attribute-values.h
index 50ccb4ab6dc0..47e6a175396c 100644
--- a/gcc/rust/util/rust-attribute-values.h
+++ b/gcc/rust/util/rust-attribute-values.h
@@ -83,6 +83,8 @@ public:
   static constexpr auto &FUNDAMENTAL = "fundamental";
 
   static constexpr auto &NON_EXHAUSTIVE = "non_exhaustive";
+
+  static constexpr auto &RUSTFMT = "rustfmt";
 };
 } // namespace Values
 } // namespace Rust
diff --git a/gcc/rust/util/rust-attributes.cc b/gcc/rust/util/rust-attributes.cc
index 7ddb476bbe6f..c77e99c1ca5a 100644
--- a/gcc/rust/util/rust-attributes.cc
+++ b/gcc/rust/util/rust-attributes.cc
@@ -94,7 +94,8 @@ static const BuiltinAttrDefinition __definitions[]
  {Attrs::RUSTC_ON_UNIMPLEMENTED, STATIC_ANALYSIS},
 
  {Attrs::FUNDAMENTAL, TYPE_CHECK},
- {Attrs::NON_EXHAUSTIVE, TYPE_CHECK}};
+ {Attrs::NON_EXHAUSTIVE, TYPE_CHECK},
+ {Attrs::RUSTFMT, EXTERNAL}};
 
 BuiltinAttributeMappings *
 BuiltinAttributeMappings::get ()
diff --git a/gcc/rust/util/rust-attributes.h b/gcc/rust/util/rust-attributes.h
index 7e7cd2c3c633..7c7a1fc3f6b1 100644
--- a/gcc/rust/util/rust-attributes.h
+++ b/gcc/rust/util/rust-attributes.h
@@ -40,7 +40,10 @@ enum CompilerPass
   HIR_LOWERING,
   TYPE_CHECK,
   STATIC_ANALYSIS,
-  CODE_GENERATION
+  CODE_GENERATION,
+
+  // External Rust tooling attributes, like #[rustfmt::skip]
+  EXTERNAL,
 
   // Do we need to add something here for const fns?
 };


[gcc(refs/users/meissner/heads/work201-submit)] Add ChangeLog.submit and update REVISION.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:23957de2218d4f56ffabac9888d4694fb2f28869

commit 23957de2218d4f56ffabac9888d4694fb2f28869
Author: Michael Meissner 
Date:   Mon Apr 14 15:18:41 2025 -0400

Add ChangeLog.submit and update REVISION.

2025-04-14  Michael Meissner  

gcc/

* ChangeLog.submit: New file for branch.
* REVISION: Update.

Diff:
---
 gcc/ChangeLog.submit | 5 +
 gcc/REVISION | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.submit b/gcc/ChangeLog.submit
new file mode 100644
index ..8cada4ac5598
--- /dev/null
+++ b/gcc/ChangeLog.submit
@@ -0,0 +1,5 @@
+ Branch work201-submit, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/REVISION b/gcc/REVISION
index 5f8715c4844d..e53943b0c13c 100644
--- a/gcc/REVISION
+++ b/gcc/REVISION
@@ -1 +1 @@
-work201 branch
+work201-submit branch


[gcc r15-9418] Add testcase for PR lto/119792

2025-04-14 Thread Eric Botcazou via Gcc-cvs
https://gcc.gnu.org/g:ec4bf5b6c22e205c9396fc7250da971ec75e3aa3

commit r15-9418-gec4bf5b6c22e205c9396fc7250da971ec75e3aa3
Author: Eric Botcazou 
Date:   Mon Apr 14 09:23:30 2025 +0200

Add testcase for PR lto/119792

It demonstrates a serious LTO breakage for the Ada language.

gcc/testsuite/
PR lto/119792
* gnat.dg/lto29.adb: New test.
* gnat.dg/lto29_pkg.ads: New helper.

Diff:
---
 gcc/testsuite/gnat.dg/lto29.adb |  9 +
 gcc/testsuite/gnat.dg/lto29_pkg.ads | 15 +++
 2 files changed, 24 insertions(+)

diff --git a/gcc/testsuite/gnat.dg/lto29.adb b/gcc/testsuite/gnat.dg/lto29.adb
new file mode 100644
index ..44f556f04b6e
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/lto29.adb
@@ -0,0 +1,9 @@
+-- { dg-do run }
+-- { dg-options "-O -flto" { target lto } }
+
+with Lto29_Pkg;
+
+procedure Lto29 is
+begin
+  null;
+end;
diff --git a/gcc/testsuite/gnat.dg/lto29_pkg.ads 
b/gcc/testsuite/gnat.dg/lto29_pkg.ads
new file mode 100644
index ..6008dc58a74e
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/lto29_pkg.ads
@@ -0,0 +1,15 @@
+with Ada.Strings.Bounded;
+
+package Lto29_Pkg is
+
+  package M is new Ada.Strings.Bounded.Generic_Bounded_Length (10);
+
+  type T is new M.Bounded_String;
+
+  Null_T : constant T;
+
+private
+
+  Null_T : constant T := To_Bounded_String ("");
+
+end Lto29_Pkg;


[gcc r15-9419] Fix implementation of Win32 thread model for C++ modules

2025-04-14 Thread Eric Botcazou via Gcc-cvs
https://gcc.gnu.org/g:5c82694319a168a1369bafa4c6e21b664a5d0bc8

commit r15-9419-g5c82694319a168a1369bafa4c6e21b664a5d0bc8
Author: Eric Botcazou 
Date:   Mon Apr 14 09:32:20 2025 +0200

Fix implementation of Win32 thread model for C++ modules

This applies the same magic to config/i386/gthr-win32.h that was applied
to gthr-posix.h (https://gcc.gnu.org/cgit/gcc/commit/?id=6a4d1c374eed17)
for the sake of C++ modules.

libgcc/
PR target/119673
* config/i386/gthr-win32.h (__GTHREAD_ALWAYS_INLINE): New macro.
(__GTHREAD_INLINE): Likewise.
(__GTHR_W32_InterlockedCompareExchange): Delete.
(__gthread_active_p): Mark as __GTHREAD_INLINE instead of
static inline.
(__gthread_create): Likewise.
(__gthread_join): Likewise.
(__gthread_self): Likewise.
(__gthread_detach): Likewise.
(__gthread_equal): Likewise.
(__gthread_yield): Likewise.
(__gthread_once): Likewise.
(__gthread_key_create): Likewise.
(__gthread_key_delete): Likewise.
(__gthread_getspecific): Likewise.
(__gthread_setspecific): Likewise.
(__gthread_mutex_init_function): Likewise.
(__gthread_mutex_destroy): Likewise.
(__gthread_mutex_lock): Likewise.
(__gthread_mutex_trylock): Likewise.
(__gthread_mutex_timedlock): Likewise.
(__gthread_mutex_unlock): Likewise.
(__gthread_recursive_mutex_trylock): Likewise.
(__gthread_cond_init_function): Likewise.
(__gthread_cond_broadcast): Likewise.
(__gthread_cond_signal): Likewise.
(__gthread_cond_wait): Likewise.
(__gthread_cond_timedwait): Likewise.
(__GTHREAD_WIN32_INLINE): Likewise.
(__GTHREAD_WIN32_COND_INLINE): Likewise.
(__gthread_recursive_mutex_init_function): Likewise.
(__gthread_recursive_mutex_destroy): Likewise.
(__gthread_recursive_mutex_lock): Likewise.
(__gthread_recursive_mutex_unlock): Likewise.
(__gthread_cond_destroy): Likewise.
(__gthread_cond_wait_recursive): Likewise.

Diff:
---
 libgcc/config/i386/gthr-win32.h | 81 +++--
 1 file changed, 46 insertions(+), 35 deletions(-)

diff --git a/libgcc/config/i386/gthr-win32.h b/libgcc/config/i386/gthr-win32.h
index 98e11b42e5c5..34988d4c3df6 100644
--- a/libgcc/config/i386/gthr-win32.h
+++ b/libgcc/config/i386/gthr-win32.h
@@ -71,6 +71,21 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If 
not, see
 #error Timed lock primitives are not supported on Windows targets
 #endif
 
+#ifdef __has_attribute
+# if __has_attribute(__always_inline__)
+#  define __GTHREAD_ALWAYS_INLINE __attribute__((__always_inline__))
+# endif
+#endif
+#ifndef __GTHREAD_ALWAYS_INLINE
+# define __GTHREAD_ALWAYS_INLINE
+#endif
+
+#ifdef __cplusplus
+# define __GTHREAD_INLINE inline __GTHREAD_ALWAYS_INLINE
+#else
+# define __GTHREAD_INLINE static inline
+#endif
+
 /* Make sure CONST_CAST2 (origin in system.h) is declared.  */
 #ifndef CONST_CAST2
 #ifdef __cplusplus
@@ -398,11 +413,7 @@ extern int _CRT_MT;
 extern int __mingwthr_key_dtor (unsigned long, void (*) (void *));
 #endif /* _WIN32 && !__CYGWIN__ */
 
-/* __GTHR_W32_InterlockedCompareExchange is left over from win95,
-   which did not support InterlockedCompareExchange. */
-#define __GTHR_W32_InterlockedCompareExchange InterlockedCompareExchange
-
-static inline int
+__GTHREAD_INLINE int
 __gthread_active_p (void)
 {
 #ifdef MINGW32_SUPPORTS_MT_EH
@@ -438,20 +449,20 @@ extern int __gthr_win32_cond_timedwait (__gthread_cond_t 
*, __gthread_mutex_t *,
const __gthread_time_t *);
 #endif
 
-static inline int
+__GTHREAD_INLINE int
 __gthread_create (__gthread_t *__thr, void *(*__func) (void*),
  void *__args)
 {
   return __gthr_win32_create (__thr, __func, __args);
 }
 
-static inline int
+__GTHREAD_INLINE int
 __gthread_join (__gthread_t __thr, void **__value_ptr)
 {
   return __gthr_win32_join (__thr, __value_ptr);
 }
 
-static inline __gthread_t
+__GTHREAD_INLINE __gthread_t
 __gthread_self (void)
 {
   return __gthr_win32_self ();
@@ -463,25 +474,25 @@ __gthread_self (void)
Only stubs are exposed to avoid polluting the C++ namespace with
Win32 API definitions.  */
 
-static inline int
+__GTHREAD_INLINE int
 __gthread_detach (__gthread_t __thr)
 {
   return __gthr_win32_detach (__thr);
 }
 
-static inline int
+__GTHREAD_INLINE int
 __gthread_equal (__gthread_t __thr1, __gthread_t __thr2)
 {
   return __gthr_win32_equal (__thr1, __thr2);
 }
 
-static inline int
+__GTHREAD_INLINE int
 __gthread_yield (void)
 {
   return __gthr_win32_yield ();
 }
 
-static inline int
+__GTHREAD_INLINE int
 __gthread_once (__gthread_once_t *__once, void (*__func) (void))
 {
   i

[gcc r15-9426] ipa: Record and stream result types of arithemetic jump functions

2025-04-14 Thread Martin Jambor via Gcc-cvs
https://gcc.gnu.org/g:f33d2e6b532304d487193667e6b5d8f8d7df2bf4

commit r15-9426-gf33d2e6b532304d487193667e6b5d8f8d7df2bf4
Author: Martin Jambor 
Date:   Mon Apr 14 14:21:14 2025 +0200

ipa: Record and stream result types of arithemetic jump functions

In order to replace the use of somewhat unweildy
expr_type_first_operand_type_p we need to record and stream the types
of results of operations recorded in arithmetic jump functions.  This
is necessary so that we can then simulate them at the IPA stage with
the corresponding precision and signedness.  This patch does the
recorsing and streaming, the following one adds the use of the date.

Per Honza's request this version also checks that we do not put VLA
types into the global LTO stream, even though I was not able to
actually craft a test-case that would do that without them.

gcc/ChangeLog:

2025-04-11  Martin Jambor  

PR ipa/118097
PR ipa/118785
PR ipa/119318
* lto-streamer.h (lto_variably_modified_type_p): Declare.
* ipa-prop.h (ipa_pass_through_data): New field op_type.
(ipa_get_jf_pass_through_op_type): New function.
* ipa-prop.cc: Include lto-streamer.h.
(ipa_dump_jump_function): Dump also pass-through
operation types, if any.  Dump pass-through operands only if not 
NULL.
(ipa_set_jf_simple_pass_through): Set op_type accordingly.
(compute_complex_assign_jump_func): Set op_type of arithmetic
pass-through jump_functions.
(analyze_agg_content_value): Update lhs when walking assighment
copies.  Set op_type of aggregate arithmetic pass-through
jump_functions.
(update_jump_functions_after_inlining): Also transfer the operation
type from the source arithmentic pass-through jump function to the
destination jump function.
(ipa_write_jump_function): Stream also the op_type when necessary.
(ipa_read_jump_function): Likewise.
(ipa_agg_pass_through_jf_equivalent_p): Also compare operation 
types.
* lto-streamer-out.cc (lto_variably_modified_type_p): Make public.

Diff:
---
 gcc/ipa-prop.cc | 76 -
 gcc/ipa-prop.h  | 15 ++
 gcc/lto-streamer-out.cc |  2 +-
 gcc/lto-streamer.h  |  1 +
 4 files changed, 80 insertions(+), 14 deletions(-)

diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc
index a120f942dc25..49d68ab044b7 100644
--- a/gcc/ipa-prop.cc
+++ b/gcc/ipa-prop.cc
@@ -60,6 +60,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "gimple-range.h"
 #include "value-range-storage.h"
 #include "vr-values.h"
+#include "lto-streamer.h"
 
 /* Function summary where the parameter infos are actually stored. */
 ipa_node_params_t *ipa_node_params_sum = NULL;
@@ -454,7 +455,11 @@ ipa_dump_jump_function (FILE *f, ipa_jump_func *jump_func,
   if (jump_func->value.pass_through.operation != NOP_EXPR)
{
  fprintf (f, " ");
- print_generic_expr (f, jump_func->value.pass_through.operand);
+ if (jump_func->value.pass_through.operand)
+   print_generic_expr (f, jump_func->value.pass_through.operand);
+ fprintf (f, " (in type ");
+ print_generic_expr (f, jump_func->value.pass_through.op_type);
+ fprintf (f, ")");
}
   if (jump_func->value.pass_through.agg_preserved)
fprintf (f, ", agg_preserved");
@@ -510,7 +515,11 @@ ipa_dump_jump_function (FILE *f, ipa_jump_func *jump_func,
  if (item->value.pass_through.operation != NOP_EXPR)
{
  fprintf (f, " ");
- print_generic_expr (f, item->value.pass_through.operand);
+ if (item->value.pass_through.operand)
+   print_generic_expr (f, item->value.pass_through.operand);
+ fprintf (f, " (in type ");
+ print_generic_expr (f, jump_func->value.pass_through.op_type);
+ fprintf (f, ")");
}
}
  else if (item->jftype == IPA_JF_CONST)
@@ -682,6 +691,7 @@ ipa_set_jf_simple_pass_through (struct ipa_jump_func 
*jfunc, int formal_id,
 {
   jfunc->type = IPA_JF_PASS_THROUGH;
   jfunc->value.pass_through.operand = NULL_TREE;
+  jfunc->value.pass_through.op_type = NULL_TREE;
   jfunc->value.pass_through.formal_id = formal_id;
   jfunc->value.pass_through.operation = NOP_EXPR;
   jfunc->value.pass_through.agg_preserved = agg_preserved;
@@ -692,10 +702,11 @@ ipa_set_jf_simple_pass_through (struct ipa_jump_func 
*jfunc, int formal_id,
 
 static void
 ipa_set_jf_unary_pass_through (struct ipa_jump_func *jfunc, int formal_id,
-  enum tree_code operation)
+  enum tree_code operation, tree op_type)
 {
   jfunc->type = IPA_JF_PASS_THROUGH;
   j

[gcc r15-9428] ipa-cp: Make dumping of widest_ints even more sane

2025-04-14 Thread Martin Jambor via Gcc-cvs
https://gcc.gnu.org/g:044d0d1ee1a61c21670068485d4a250edfbb695a

commit r15-9428-g044d0d1ee1a61c21670068485d4a250edfbb695a
Author: Martin Jambor 
Date:   Mon Apr 14 14:21:15 2025 +0200

ipa-cp: Make dumping of widest_ints even more sane

This patch just introduces a form of dumping of widest ints that only
have zeros in the lowest 128 bits so that instead of printing
thousands of f's the output looks like:

   Bits: value = 0x, mask = all ones folled by 
0x

and then makes sure we use the function not only to print bits but
also to print masks where values like these can also occur.

gcc/ChangeLog:

2025-03-21  Martin Jambor  

* ipa-cp.cc (ipcp_print_widest_int): Also add a truncated form of
dumping of widest ints which only have zeros in the lowest 128 bits.
Update the comment.
(ipcp_bits_lattice::print): Also dump the mask using
ipcp_print_widest_int.
(ipcp_store_vr_results): Likewise.

Diff:
---
 gcc/ipa-cp.cc | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc
index fd2c4cca1365..637bc49f0482 100644
--- a/gcc/ipa-cp.cc
+++ b/gcc/ipa-cp.cc
@@ -307,14 +307,21 @@ ipcp_lattice::print (FILE * f, bool 
dump_sources, bool dump_benefits)
 fprintf (f, "\n");
 }
 
-/* If VALUE has all bits set to one, print "-1" to F, otherwise simply print it
-   hexadecimally to F. */
+/* Print VALUE to F in a form which in usual cases does not take thousands of
+   characters. */
 
 static void
 ipcp_print_widest_int (FILE *f, const widest_int &value)
 {
   if (wi::eq_p (wi::bit_not (value), 0))
 fprintf (f, "-1");
+  else if (wi::eq_p (wi::bit_not (wi::bit_or (value,
+ wi::sub (wi::lshift (1, 128),
+  1))), 0))
+{
+  fprintf (f, "all ones folled by ");
+  print_hex (wi::bit_and (value, wi::sub (wi::lshift (1, 128), 1)), f);
+}
   else
 print_hex (value, f);
 }
@@ -331,7 +338,7 @@ ipcp_bits_lattice::print (FILE *f)
   fprintf (f, " Bits: value = ");
   ipcp_print_widest_int (f, get_value ());
   fprintf (f, ", mask = ");
-  print_hex (get_mask (), f);
+  ipcp_print_widest_int (f, get_mask ());
   fprintf (f, "\n");
 }
 }
@@ -6437,7 +6444,7 @@ ipcp_store_vr_results (void)
  fprintf (dump_file, " param %i: value = ", i);
  ipcp_print_widest_int (dump_file, bits->get_value ());
  fprintf (dump_file, ", mask = ");
- print_hex (bits->get_mask (), dump_file);
+ ipcp_print_widest_int (dump_file, bits->get_mask ());
  fprintf (dump_file, "\n");
}
 }


[gcc r15-9430] ipa-cp: Use the collected pass-through types to propgate constants (PR118097)

2025-04-14 Thread Martin Jambor via Gcc-cvs
https://gcc.gnu.org/g:6b6611f81476b6375c90859d85331c2981a2ce51

commit r15-9430-g6b6611f81476b6375c90859d85331c2981a2ce51
Author: Martin Jambor 
Date:   Mon Apr 14 14:21:15 2025 +0200

ipa-cp: Use the collected pass-through types to propgate constants 
(PR118097)

This patch revisits the fix for PR 118097 and instead of deducing the
necessary operation type it just uses the value collected and streamed
by an earlier patch.

It is bigger than the ones for propagating value ranges and known bits
because we track constants both in parameters themselves and also in
memory they point to or within aggregates, we clone functions for them
and we do fancy things for some types of recursive calls.

In the case of constants in aggregates or passed by reference, the
situation should not change because the code creating jump functions
for them does not allow type-casts, unlike for the plain ones.
However, this patch changes how we handle them for the sake of
consistency and also so that we can try and eliminate this limitation
in the next stage 1.

gcc/ChangeLog:

2025-03-20  Martin Jambor  

PR ipa/118097
* ipa-cp.cc (ipa_get_jf_arith_result): Require res_operand for
anything except NOP_EXPR or ADDR_EXPR, document it and remove the 
code
trying to deduce it.
(ipa_value_from_jfunc): Use the stored and streamed type of 
arithmetic
pass-through functions.
(ipa_agg_value_from_jfunc): Use the stored and streamed type of
arithmetic pass-through functions, convert to the type used to store
the value if necessary.
(get_val_across_arith_op): New parameter op_type, pass it to
ipa_get_jf_arith_result.
(propagate_vals_across_arith_jfunc): New parameter op_type, pass it 
to
get_val_across_arith_op.
(propagate_vals_across_pass_through): Use the stored and streamed 
type
of arithmetic pass-through functions.
(propagate_aggregate_lattice): Likewise.
(push_agg_values_for_index_from_edge): Use the stored and streamed
type of arithmetic pass-through functions, convert to the type used 
to
store the value if necessary.

Diff:
---
 gcc/ipa-cp.cc | 94 +--
 1 file changed, 52 insertions(+), 42 deletions(-)

diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc
index 21033c666bf4..26b1496f29bb 100644
--- a/gcc/ipa-cp.cc
+++ b/gcc/ipa-cp.cc
@@ -1478,10 +1478,12 @@ ipacp_value_safe_for_type (tree param_type, tree value)
 return NULL_TREE;
 }
 
-/* Return the result of a (possibly arithmetic) operation on the constant value
-   INPUT.  OPERAND is 2nd operand for binary operation.  RES_TYPE is the type
-   in which any operation is to be performed.  Return NULL_TREE if that cannot
-   be determined or be considered an interprocedural invariant.  */
+/* Return the result of a (possibly arithmetic) operation determined by OPCODE
+   on the constant value INPUT.  OPERAND is 2nd operand for binary operation
+   and is required for binary operations.  RES_TYPE, required when opcode is
+   not NOP_EXPR, is the type in which any operation is to be performed.  Return
+   NULL_TREE if that cannot be determined or be considered an interprocedural
+   invariant.  */
 
 static tree
 ipa_get_jf_arith_result (enum tree_code opcode, tree input, tree operand,
@@ -1502,16 +1504,6 @@ ipa_get_jf_arith_result (enum tree_code opcode, tree 
input, tree operand,
return NULL_TREE;
 }
 
-  if (!res_type)
-{
-  if (TREE_CODE_CLASS (opcode) == tcc_comparison)
-   res_type = boolean_type_node;
-  else if (expr_type_first_operand_type_p (opcode))
-   res_type = TREE_TYPE (input);
-  else
-   return NULL_TREE;
-}
-
   if (TREE_CODE_CLASS (opcode) == tcc_unary)
 res = fold_unary (opcode, res_type, input);
   else
@@ -1595,7 +1587,10 @@ ipa_value_from_jfunc (class ipa_node_params *info, 
struct ipa_jump_func *jfunc,
return NULL_TREE;
  enum tree_code opcode = ipa_get_jf_pass_through_operation (jfunc);
  tree op2 = ipa_get_jf_pass_through_operand (jfunc);
- tree cstval = ipa_get_jf_arith_result (opcode, input, op2, NULL_TREE);
+ tree op_type
+   = (opcode == NOP_EXPR) ? NULL_TREE
+   : ipa_get_jf_pass_through_op_type (jfunc);
+ tree cstval = ipa_get_jf_arith_result (opcode, input, op2, op_type);
  return ipacp_value_safe_for_type (parm_type, cstval);
}
   else
@@ -1905,10 +1900,11 @@ ipa_agg_value_from_jfunc (ipa_node_params *info, 
cgraph_node *node,
return NULL_TREE;
 }
 
-  return ipa_get_jf_arith_result (item->value.pass_through.operation,
- value,
- item->value.pass_through.operand,
-   

[gcc r15-9420] driver: On linux hosts disable ASLR during -freport-bug [PR119727]

2025-04-14 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:5a32e85810d33dc46b1b5fe2803ee787d40709d5

commit r15-9420-g5a32e85810d33dc46b1b5fe2803ee787d40709d5
Author: Jakub Jelinek 
Date:   Mon Apr 14 10:18:13 2025 +0200

driver: On linux hosts disable ASLR during -freport-bug [PR119727]

Andi had a useful comment that even with the PR119727 workaround to
ignore differences in libbacktrace printed addresses, it is still better
to turn off ASLR when easily possible, e.g. in case some address leaks
in somewhere in the ICE message elsewhere, or to verify the ICE doesn't
depend on a particular library/binary load addresses.

The following patch adds a configure check and uses personality syscall
to turn off randomization for further -freport-bug subprocesses.

2025-04-14  Jakub Jelinek  

PR driver/119727
* configure.ac (HOST_HAS_PERSONALITY_ADDR_NO_RANDOMIZE): New check.
* gcc.cc: Include sys/personality.h if
HOST_HAS_PERSONALITY_ADDR_NO_RANDOMIZE is defined.
(try_generate_repro): Call
personality (personality (0xU) | ADDR_NO_RANDOMIZE)
if HOST_HAS_PERSONALITY_ADDR_NO_RANDOMIZE is defined.
* config.in: Regenerate.
* configure: Regenerate.

Diff:
---
 gcc/config.in|  7 +++
 gcc/configure| 40 ++--
 gcc/configure.ac | 15 +++
 gcc/gcc.cc   |  7 +++
 4 files changed, 67 insertions(+), 2 deletions(-)

diff --git a/gcc/config.in b/gcc/config.in
index 7c89cab7717f..a79c51adb2b3 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -2320,6 +2320,13 @@
 #endif
 
 
+/* Define if personality and ADDR_NO_RANDOMIZE are declared in
+   sys/personality.h. */
+#ifndef USED_FOR_TARGET
+#undef HOST_HAS_PERSONALITY_ADDR_NO_RANDOMIZE
+#endif
+
+
 /* Define which stat syscall is able to handle 64bit indodes. */
 #ifndef USED_FOR_TARGET
 #undef HOST_STAT_FOR_64BIT_INODES
diff --git a/gcc/configure b/gcc/configure
index ab6bec1f0ae7..821f8b44bc6a 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -12694,6 +12694,42 @@ $as_echo "#define HOST_HAS_O_NONBLOCK 1" >>confdefs.h
 
 fi
 
+# Check if personality and ADDR_NO_RANDOMIZE are declared
+# in sys/personality.h
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for personality 
ADDR_NO_RANDOMIZE" >&5
+$as_echo_n "checking for personality ADDR_NO_RANDOMIZE... " >&6; }
+if ${ac_cv_personality_addr_no_randomize+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include 
+int
+main ()
+{
+
+personality (personality (0xU) | ADDR_NO_RANDOMIZE);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_cv_personality_addr_no_randomize=yes
+else
+  ac_cv_personality_addr_no_randomize=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: 
$ac_cv_personality_addr_no_randomize" >&5
+$as_echo "$ac_cv_personality_addr_no_randomize" >&6; }
+if test $ac_cv_personality_addr_no_randomize = yes; then
+
+$as_echo "#define HOST_HAS_PERSONALITY_ADDR_NO_RANDOMIZE 1" >>confdefs.h
+
+fi
+
 
 # C++ Modules would like some networking features to provide the mapping
 # server.  You can still use modules without them though.
@@ -21484,7 +21520,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 21487 "configure"
+#line 21523 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -21590,7 +21626,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 21593 "configure"
+#line 21629 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gcc/configure.ac b/gcc/configure.ac
index fca0579574fa..3d0a4e6f8f55 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -1781,6 +1781,21 @@ if test $ac_cv_have_decl_O_NONBLOCK = yes; then
   [Define if O_NONBLOCK supported by fcntl.])
 fi
 
+# Check if personality and ADDR_NO_RANDOMIZE are declared
+# in sys/personality.h
+AC_CACHE_CHECK(for personality ADDR_NO_RANDOMIZE,
+  ac_cv_personality_addr_no_randomize, [
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include ]], [[
+personality (personality (0xU) | ADDR_NO_RANDOMIZE);]])],
+[ac_cv_personality_addr_no_randomize=yes],
+[ac_cv_personality_addr_no_randomize=no])])
+if test $ac_cv_personality_addr_no_randomize = yes; then
+  AC_DEFINE(HOST_HAS_PERSONALITY_ADDR_NO_RANDOMIZE, 1,
+  [Define if personality and ADDR_NO_RANDOMIZE are declared in
+sys/personality.h.])
+fi
+
 
 # C++ Modules would like some networking features to provide the mapping
 # server.  You can still use modules without them though.
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index 9064671b86cf..4fd87f2c4a13 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -30,6 +30,9 @@ compilation is specified by a string called a

[gcc r15-9423] libstdc++: Use UTF-32BE as wide encoding for big-endian machines [PR119725]

2025-04-14 Thread Tomasz Kaminski via Libstdc++-cvs
https://gcc.gnu.org/g:c2f1dda34defe739db6016dda97a6516243372e6

commit r15-9423-gc2f1dda34defe739db6016dda97a6516243372e6
Author: Tomasz Kamiński 
Date:   Mon Apr 14 08:43:58 2025 +0200

libstdc++: Use UTF-32BE as wide encoding for big-endian machines [PR119725]

This changes the `dg-options` line so UTF-32 with byte order native to the
machine is used as wide encoding.

We still do not handle mismatch in the byte order of the Unicode encodings
(UTF32-BE on little-endian machines). This would require larger changes,
as for example `unicode-data.h` tables are encoded with native byte order.

PR libstdc++/119725

libstdc++-v3/ChangeLog:

* testsuite/std/format/debug.cc: Updated dg-options.
* testsuite/std/format/debug_nonunicode.cc: Updated dg-options.

Reviewed-by: Jonathan Wakely 
Signed-off-by: Tomasz Kamiński 

Diff:
---
 libstdc++-v3/testsuite/std/format/debug.cc| 3 ++-
 libstdc++-v3/testsuite/std/format/debug_nonunicode.cc | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/testsuite/std/format/debug.cc 
b/libstdc++-v3/testsuite/std/format/debug.cc
index 07cd1e0e349e..71bb7f4a0fe8 100644
--- a/libstdc++-v3/testsuite/std/format/debug.cc
+++ b/libstdc++-v3/testsuite/std/format/debug.cc
@@ -1,4 +1,5 @@
-// { dg-options "-fexec-charset=UTF-8 -fwide-exec-charset=UTF-32LE 
-DUNICODE_ENC" }
+// { dg-options "-fexec-charset=UTF-8 -fwide-exec-charset=UTF-32LE 
-DUNICODE_ENC" { target le } }
+// { dg-options "-fexec-charset=UTF-8 -fwide-exec-charset=UTF-32BE 
-DUNICODE_ENC" { target be } }
 // { dg-do run { target c++23 } }
 // { dg-add-options no_pch }
 
diff --git a/libstdc++-v3/testsuite/std/format/debug_nonunicode.cc 
b/libstdc++-v3/testsuite/std/format/debug_nonunicode.cc
index 5c03171d71a1..2ac7e757ea8d 100644
--- a/libstdc++-v3/testsuite/std/format/debug_nonunicode.cc
+++ b/libstdc++-v3/testsuite/std/format/debug_nonunicode.cc
@@ -1,4 +1,4 @@
-// { dg-options "-fexec-charset=ISO8859-1 -fwide-exec-charset=UTF-32LE" }
+// { dg-options "-fexec-charset=ISO8859-1" }
 // { dg-do run { target c++23 } }
 // { dg-add-options no_pch }


[gcc r14-11603] Add testcase for PR lto/119792

2025-04-14 Thread Eric Botcazou via Gcc-cvs
https://gcc.gnu.org/g:569f826774a90e18d6a020a30efd6075587ebcb3

commit r14-11603-g569f826774a90e18d6a020a30efd6075587ebcb3
Author: Eric Botcazou 
Date:   Mon Apr 14 09:23:30 2025 +0200

Add testcase for PR lto/119792

It demonstrates a serious LTO breakage for the Ada language.

gcc/testsuite/
PR lto/119792
* gnat.dg/lto29.adb: New test.
* gnat.dg/lto29_pkg.ads: New helper.

Diff:
---
 gcc/testsuite/gnat.dg/lto29.adb |  9 +
 gcc/testsuite/gnat.dg/lto29_pkg.ads | 15 +++
 2 files changed, 24 insertions(+)

diff --git a/gcc/testsuite/gnat.dg/lto29.adb b/gcc/testsuite/gnat.dg/lto29.adb
new file mode 100644
index ..44f556f04b6e
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/lto29.adb
@@ -0,0 +1,9 @@
+-- { dg-do run }
+-- { dg-options "-O -flto" { target lto } }
+
+with Lto29_Pkg;
+
+procedure Lto29 is
+begin
+  null;
+end;
diff --git a/gcc/testsuite/gnat.dg/lto29_pkg.ads 
b/gcc/testsuite/gnat.dg/lto29_pkg.ads
new file mode 100644
index ..6008dc58a74e
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/lto29_pkg.ads
@@ -0,0 +1,15 @@
+with Ada.Strings.Bounded;
+
+package Lto29_Pkg is
+
+  package M is new Ada.Strings.Bounded.Generic_Bounded_Length (10);
+
+  type T is new M.Bounded_String;
+
+  Null_T : constant T;
+
+private
+
+  Null_T : constant T := To_Bounded_String ("");
+
+end Lto29_Pkg;


[gcc r15-9424] tree-optimization/119757 - reject mixed mask/non-mask ldst SLP

2025-04-14 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:2f334a10bce0409c2cb4616496aafcb78f7db3d8

commit r15-9424-g2f334a10bce0409c2cb4616496aafcb78f7db3d8
Author: Richard Biener 
Date:   Mon Apr 14 12:44:02 2025 +0200

tree-optimization/119757 - reject mixed mask/non-mask ldst SLP

The following makes sure to not mix masked/non-masked stmts when
forming a SLP node.

PR tree-optimization/119757
* tree-vect-slp.cc (vect_build_slp_tree_1): Record and compare
whether a stmt uses a maks.

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

Diff:
---
 gcc/testsuite/gcc.dg/vect/pr119757.c | 17 +
 gcc/tree-vect-slp.cc | 24 
 2 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/vect/pr119757.c 
b/gcc/testsuite/gcc.dg/vect/pr119757.c
new file mode 100644
index ..86442998628b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr119757.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+void base64_encode(const char *table64,
+   const char *inputbuff, int insize,
+   char * __restrict output)
+{
+  const unsigned char *in = (const unsigned char *)inputbuff;
+
+  while(insize >= 3) {
+*output++ = table64[ in[0] >> 2 ];
+*output++ = table64[ ((in[0] & 0x03) << 4) | (in[1] >> 4) ];
+*output++ = table64[ ((in[1] & 0x0F) << 2) | ((in[2] & 0xC0) >> 6) ];
+*output++ = table64[ in[2] & 0x3F ];
+insize -= 3;
+in += 3;
+  }
+}
diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index ecb4a6521dec..19beeed8a3a9 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -1099,7 +1099,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char 
*swap,
   tree first_lhs = NULL_TREE;
   tree first_op1 = NULL_TREE;
   stmt_vec_info first_load = NULL, prev_first_load = NULL;
-  bool first_stmt_ldst_p = false;
+  bool first_stmt_ldst_p = false, first_stmt_ldst_masklen_p = false;
   bool first_stmt_phi_p = false;
   int first_reduc_idx = -1;
   bool maybe_soft_fail = false;
@@ -1133,6 +1133,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char 
*swap,
   FOR_EACH_VEC_ELT (stmts, i, stmt_info)
 {
   bool ldst_p = false;
+  bool ldst_masklen_p = false;
   bool phi_p = false;
   code_helper rhs_code = ERROR_MARK;
 
@@ -1195,17 +1196,22 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char 
*swap,
  else
rhs_code = CALL_EXPR;
 
- if (cfn == CFN_MASK_LOAD
- || cfn == CFN_GATHER_LOAD
- || cfn == CFN_MASK_GATHER_LOAD
- || cfn == CFN_MASK_LEN_GATHER_LOAD
- || cfn == CFN_SCATTER_STORE
- || cfn == CFN_MASK_SCATTER_STORE
- || cfn == CFN_MASK_LEN_SCATTER_STORE)
+ if (cfn == CFN_GATHER_LOAD
+ || cfn == CFN_SCATTER_STORE)
ldst_p = true;
+ else if (cfn == CFN_MASK_LOAD
+  || cfn == CFN_MASK_GATHER_LOAD
+  || cfn == CFN_MASK_LEN_GATHER_LOAD
+  || cfn == CFN_MASK_SCATTER_STORE
+  || cfn == CFN_MASK_LEN_SCATTER_STORE)
+   {
+ ldst_p = true;
+ ldst_masklen_p = true;
+   }
  else if (cfn == CFN_MASK_STORE)
{
  ldst_p = true;
+ ldst_masklen_p = true;
  rhs_code = CFN_MASK_STORE;
}
  else if (cfn == CFN_GOMP_SIMD_LANE)
@@ -1246,6 +1252,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char 
*swap,
  first_lhs = lhs;
  first_stmt_code = rhs_code;
  first_stmt_ldst_p = ldst_p;
+ first_stmt_ldst_masklen_p = ldst_masklen_p;
  first_stmt_phi_p = phi_p;
  first_reduc_idx = STMT_VINFO_REDUC_IDX (stmt_info);
 
@@ -1364,6 +1371,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char 
*swap,
  && (STMT_VINFO_GATHER_SCATTER_P (stmt_info)
  != STMT_VINFO_GATHER_SCATTER_P (first_stmt_info)))
  || first_stmt_ldst_p != ldst_p
+ || (ldst_p && first_stmt_ldst_masklen_p != ldst_masklen_p)
  || first_stmt_phi_p != phi_p)
{
  if (dump_enabled_p ())


[gcc r15-9425] libstdc++: Document thread-safety for COW std::string [PR21334]

2025-04-14 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:dd35f66287b7cca196a720c9641e463255dceb1c

commit r15-9425-gdd35f66287b7cca196a720c9641e463255dceb1c
Author: Jonathan Wakely 
Date:   Fri Apr 11 11:08:34 2025 +0100

libstdc++: Document thread-safety for COW std::string [PR21334]

The gcc4-compatible copy-on-write std::string does not conform to the
C++11 requirements on data race avoidance in standard containers.
Specifically, calling non-const member functions such as begin() and
data() needs to do the "copy on write" operation and so is most
definitely a modification of the object. As such, those non-const
members must not be called concurrently with any other uses of the
string object.

libstdc++-v3/ChangeLog:

PR libstdc++/21334
* doc/xml/manual/using.xml: Document that container data race
avoidance rules do not apply to COW std::string.
* doc/html/*: Regenerate.

Diff:
---
 libstdc++-v3/doc/html/manual/using_concurrency.html | 10 ++
 libstdc++-v3/doc/xml/manual/using.xml   | 12 
 2 files changed, 22 insertions(+)

diff --git a/libstdc++-v3/doc/html/manual/using_concurrency.html 
b/libstdc++-v3/doc/html/manual/using_concurrency.html
index d21f15884949..d570d3a2b84d 100644
--- a/libstdc++-v3/doc/html/manual/using_concurrency.html
+++ b/libstdc++-v3/doc/html/manual/using_concurrency.html
@@ -126,6 +126,16 @@ gcc version 4.1.2 20070925 (Red Hat 4.1.2-33)
  the container the iterator refers to (for example incrementing a
  list iterator must access the pointers between nodes, which are part
  of the container and so conflict with other accesses to the 
container).
+  
+The Copy-On-Write std::string 
implementation
+used before GCC 5 (and with
+_GLIBCXX_USE_CXX11_ABI=0)
+is not a standard container and does not conform to the data race
+avoidance rules described above. For the Copy-On-Write
+std::string, non-const member functions 
such as
+begin() are considered to be modifying 
accesses
+and so must not be used concurrently with any other accesses to the
+same object.
   Programs which follow the rules above will not encounter data
  races in library code, even when using library types which share
  state between distinct objects.  In the example below the
diff --git a/libstdc++-v3/doc/xml/manual/using.xml 
b/libstdc++-v3/doc/xml/manual/using.xml
index 7ca3a3f4b4c0..bf92c495f6d3 100644
--- a/libstdc++-v3/doc/xml/manual/using.xml
+++ b/libstdc++-v3/doc/xml/manual/using.xml
@@ -2069,6 +2069,18 @@ gcc version 4.1.2 20070925 (Red Hat 4.1.2-33)
  of the container and so conflict with other accesses to the 
container).
   
 
+  
+The Copy-On-Write std::string implementation
+used before GCC 5 (and with
+_GLIBCXX_USE_CXX11_ABI=0)
+is not a standard container and does not conform to the data race
+avoidance rules described above. For the Copy-On-Write
+std::string, non-const member functions such as
+begin() are considered to be modifying accesses
+and so must not be used concurrently with any other accesses to the
+same object.
+  
+
   Programs which follow the rules above will not encounter data
  races in library code, even when using library types which share
  state between distinct objects.  In the example below the


[gcc r14-11602] c++: Properly fold .* [PR114525]

2025-04-14 Thread Simon Martin via Gcc-cvs
https://gcc.gnu.org/g:7e79c32ac1cc84f933000d5cc45249b2eb338aad

commit r14-11602-g7e79c32ac1cc84f933000d5cc45249b2eb338aad
Author: Simon Martin 
Date:   Mon Apr 14 08:36:06 2025 +0200

c++: Properly fold .* [PR114525]

We've been miscompiling the following since r0-51314-gd6b4ea8592e338 (I
did not go compile something that old, and identified this change via
git blame, so might be wrong)

=== cut here ===
struct Foo { int x; };
Foo& get (Foo &v) { return v; }
void bar () {
  Foo v; v.x = 1;
  (true ? get (v) : get (v)).*(&Foo::x) = 2;
  // v.x still equals 1 here...
}
=== cut here ===

The problem lies in build_m_component_ref, that computes the address of
the COND_EXPR using build_address to build the representation of
  (true ? get (v) : get (v)).*(&Foo::x);
and gets something like
  &(true ? get (v) : get (v))  // #1
instead of
  (true ? &get (v) : &get (v)) // #2
and the write does not go where want it to, hence the miscompile.

This patch replaces the call to build_address by a call to
cp_build_addr_expr, which gives #2, that is properly handled.

PR c++/114525

gcc/cp/ChangeLog:

* typeck2.cc (build_m_component_ref): Call cp_build_addr_expr
instead of build_address.

gcc/testsuite/ChangeLog:

* g++.dg/expr/cond18.C: New test.

(cherry picked from commit 35ce9afc84a63fb647a90cbecb2adf3e748178be)

Diff:
---
 gcc/cp/typeck2.cc  |  2 +-
 gcc/testsuite/g++.dg/expr/cond18.C | 36 
 2 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/typeck2.cc b/gcc/cp/typeck2.cc
index e32a4c638c59..3adb8dec1616 100644
--- a/gcc/cp/typeck2.cc
+++ b/gcc/cp/typeck2.cc
@@ -2347,7 +2347,7 @@ build_m_component_ref (tree datum, tree component, 
tsubst_flags_t complain)
  (cp_type_quals (type)
   | cp_type_quals (TREE_TYPE (datum;
 
-  datum = build_address (datum);
+  datum = cp_build_addr_expr (datum, complain);
 
   /* Convert object to the correct base.  */
   if (binfo)
diff --git a/gcc/testsuite/g++.dg/expr/cond18.C 
b/gcc/testsuite/g++.dg/expr/cond18.C
new file mode 100644
index ..326985eed506
--- /dev/null
+++ b/gcc/testsuite/g++.dg/expr/cond18.C
@@ -0,0 +1,36 @@
+/* PR c++/114525 */
+/* { dg-do run } */
+
+struct Foo {
+  int x;
+};
+
+Foo& get (Foo& v) {
+  return v;
+}
+
+int main () {
+  bool cond = true;
+
+  /* Testcase from PR; v.x would wrongly remain equal to 1.  */
+  Foo v_ko;
+  v_ko.x = 1;
+  (cond ? get (v_ko) : get (v_ko)).*(&Foo::x) = 2;
+  if (v_ko.x != 2)
+__builtin_abort ();
+
+  /* Those would already work, i.e. x be changed to 2.  */
+  Foo v_ok_1;
+  v_ok_1.x = 1;
+  (cond ? get (v_ok_1) : get (v_ok_1)).x = 2;
+  if (v_ok_1.x != 2)
+__builtin_abort ();
+
+  Foo v_ok_2;
+  v_ok_2.x = 1;
+  get (v_ok_2).*(&Foo::x) = 2;
+  if (v_ok_2.x != 2)
+__builtin_abort ();
+
+  return 0;
+}


[gcc r15-9421] PR modula2/119779 ASM examples no longer work

2025-04-14 Thread Gaius Mulley via Gcc-cvs
https://gcc.gnu.org/g:9e0a98a47c98fd159a26de4433a3ed1d85afb8c3

commit r15-9421-g9e0a98a47c98fd159a26de4433a3ed1d85afb8c3
Author: Gaius Mulley 
Date:   Mon Apr 14 10:13:40 2025 +0100

PR modula2/119779 ASM examples no longer work

This patch introduces four dejagnu tests matching four
documentation examples.  Both asm examples are added and only built if
the x86_64 target is available.  The other two are hello world using
libc and StrIO.  The doc/gm2.texi asm examples are changed to
use eax rather than rax.

gcc/ChangeLog:

PR modula2/119779
* doc/gm2.texi (Interface to assembly language): Use eax
rather than rax in both examples.

gcc/testsuite/ChangeLog:

PR modula2/119779
* gm2.dg/doc/examples/pass/doc-examples-pass.exp: New test.
* gm2.dg/doc/examples/pass/exampleadd.mod: New test.
* gm2.dg/doc/examples/pass/exampleadd2.mod: New test.
* gm2.dg/doc/examples/pass/hello.mod: New test.
* gm2.dg/doc/examples/pass/hellopim.mod: New test.

Signed-off-by: Gaius Mulley 

Diff:
---
 gcc/doc/gm2.texi   |  8 +++---
 .../gm2.dg/doc/examples/pass/doc-examples-pass.exp | 18 
 .../gm2.dg/doc/examples/pass/exampleadd.mod| 32 ++
 .../gm2.dg/doc/examples/pass/exampleadd2.mod   | 32 ++
 gcc/testsuite/gm2.dg/doc/examples/pass/hello.mod   | 10 +++
 .../gm2.dg/doc/examples/pass/hellopim.mod  | 10 +++
 6 files changed, 106 insertions(+), 4 deletions(-)

diff --git a/gcc/doc/gm2.texi b/gcc/doc/gm2.texi
index 8baee24f14e0..cb52e8c0d3e4 100644
--- a/gcc/doc/gm2.texi
+++ b/gcc/doc/gm2.texi
@@ -2699,10 +2699,10 @@ PROCEDURE Example (foo, bar: CARDINAL) : CARDINAL ;
 VAR
myout: CARDINAL ;
 BEGIN
-   ASM VOLATILE ("movq %1,%%rax; addq %2,%%rax; movq %%rax,%0"
+   ASM VOLATILE ("movl %1,%%eax; addl %2,%%eax; movl %%eax,%0"
   : "=rm" (myout)(* outputs *)
   : "rm" (foo), "rm" (bar)   (* inputs  *)
-  : "rax") ; (* we trash *)
+  : "eax") ; (* we trash *)
RETURN( myout )
 END Example ;
 @end example
@@ -2720,10 +2720,10 @@ VAR
myout: CARDINAL ;
 BEGIN
ASM VOLATILE (
-"movq %[left],%%rax; addq %[right],%%rax; movq %%rax,%[output]"
+"movl %[left],%%eax; addl %[right],%%eax; movl %%eax,%[output]"
   : [output] "=rm" (myout)  (* outputs *)
   : [left] "rm" (foo), [right] "rm" (bar)   (* inputs  *)
-  : "rax") ;(* we trash *)
+  : "eax") ;(* we trash *)
RETURN( myout )
 END Example ;
 @end example
diff --git a/gcc/testsuite/gm2.dg/doc/examples/pass/doc-examples-pass.exp 
b/gcc/testsuite/gm2.dg/doc/examples/pass/doc-examples-pass.exp
new file mode 100644
index ..0bfcea0f1250
--- /dev/null
+++ b/gcc/testsuite/gm2.dg/doc/examples/pass/doc-examples-pass.exp
@@ -0,0 +1,18 @@
+# Compile tests, no torture testing.
+#
+# These tests should all pass.
+
+# Load support procs.
+load_lib gm2-dg.exp
+
+gm2_init_pim4 $srcdir/$subdir
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.mod]] "" ""
+
+# All done.
+dg-finish
diff --git a/gcc/testsuite/gm2.dg/doc/examples/pass/exampleadd.mod 
b/gcc/testsuite/gm2.dg/doc/examples/pass/exampleadd.mod
new file mode 100644
index ..84020a85907d
--- /dev/null
+++ b/gcc/testsuite/gm2.dg/doc/examples/pass/exampleadd.mod
@@ -0,0 +1,32 @@
+(* { dg-do assemble { target { x86_64-*-* } } } *)
+(* { dg-options "-g" } *)
+
+MODULE exampleadd ;  
+
+FROM libc IMPORT printf, exit ;
+
+
+PROCEDURE Example (foo, bar: CARDINAL) : CARDINAL ;
+VAR
+   myout: CARDINAL ;
+BEGIN
+   ASM VOLATILE ("movl %1,%%eax; addl %2,%%eax; movl %%eax,%0"
+  : "=rm" (myout)(* outputs *)
+  : "rm" (foo), "rm" (bar)   (* inputs  *)
+  : "eax") ; (* we trash *)
+   RETURN( myout )
+END Example ;
+
+
+VAR
+   a, b, c: CARDINAL ;
+BEGIN
+   a := 1 ;
+   b := 2 ;
+   c := Example (a, b) ;
+   IF c # 3
+   THEN
+  printf ("Example procedure function failed to return 3, seen %d", c) ;
+  exit (1)
+   END
+END exampleadd.
diff --git a/gcc/testsuite/gm2.dg/doc/examples/pass/exampleadd2.mod 
b/gcc/testsuite/gm2.dg/doc/examples/pass/exampleadd2.mod
new file mode 100644
index ..f25397fa8ba0
--- /dev/null
+++ b/gcc/testsuite/gm2.dg/doc/examples/pass/exampleadd2.mod
@@ -0,0 +1,32 @@
+(* { dg-do assemble { target { x86_64-*-* } } } *)
+(* { dg-options "-g" } *)
+
+MODULE exampleadd2 ;  
+
+FROM libc IMPORT printf, exit ;
+
+
+PROCEDURE Example (foo, bar: CARDINAL) : CARDINAL ;
+VAR
+   myout: CARDINAL ;
+BEGIN
+   ASM VOLATILE (
+"movl %[left],%%eax; addl %[right],%%eax; movl %%eax,%[output]"
+  : [output] "=rm" (myout)  (* outputs *)
+  : [left] 

[gcc r15-9422] tree-optimization/119778 - properly mark abnormal edge sources during inlining

2025-04-14 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:a48f934211434cac1be951c207ee76e4b4340fac

commit r15-9422-ga48f934211434cac1be951c207ee76e4b4340fac
Author: Richard Biener 
Date:   Mon Apr 14 11:42:18 2025 +0200

tree-optimization/119778 - properly mark abnormal edge sources during 
inlining

When inlining a call that abnormally transfers control-flow we make
all inlined calls that can possibly transfer abnormal control-flow
do so as well.  But we failed to mark the calls as altering
control-flow.  This results in inconsistent behavior later and
possibly wrong-code (we'd eventually prune those edges).

PR tree-optimization/119778
* tree-inline.cc (copy_edges_for_bb): Mark calls that are
source of abnormal edges as altering control-flow.

* g++.dg/torture/pr119778.C: New testcase.

Diff:
---
 gcc/testsuite/g++.dg/torture/pr119778.C | 20 
 gcc/tree-inline.cc  |  7 +--
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/g++.dg/torture/pr119778.C 
b/gcc/testsuite/g++.dg/torture/pr119778.C
new file mode 100644
index ..494805619282
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr119778.C
@@ -0,0 +1,20 @@
+// { dg-do compile }
+// { dg-additional-options "-Wall" }
+
+struct jmp_buf { long l[16]; };
+extern "C" int setjmp (jmp_buf *);
+struct S {
+  void foo () { bar (); }
+  virtual char bar () { return 0; }
+};
+void baz ();
+jmp_buf *a;
+
+void
+qux (bool x, S *y)
+{
+  if (x)
+setjmp (a);
+  y->foo ();
+  baz ();
+}
diff --git a/gcc/tree-inline.cc b/gcc/tree-inline.cc
index 05843b8ccf09..3289b4f6d050 100644
--- a/gcc/tree-inline.cc
+++ b/gcc/tree-inline.cc
@@ -2729,8 +2729,11 @@ copy_edges_for_bb (basic_block bb, profile_count num, 
profile_count den,
   && gimple_call_arg (copy_stmt, 0) == boolean_true_node)
nonlocal_goto = false;
  else
-   make_single_succ_edge (copy_stmt_bb, abnormal_goto_dest,
-  EDGE_ABNORMAL);
+   {
+ make_single_succ_edge (copy_stmt_bb, abnormal_goto_dest,
+EDGE_ABNORMAL);
+ gimple_call_set_ctrl_altering (copy_stmt, true);
+   }
}
 
   if ((can_throw || nonlocal_goto)


[gcc r15-9476] libgcobol: Handle long double as an alternate IEEE754 quad [PR119244]

2025-04-14 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:69ffddd8bd9947c5c060979e453d6b138ad3ed8c

commit r15-9476-g69ffddd8bd9947c5c060979e453d6b138ad3ed8c
Author: Jakub Jelinek 
Date:   Tue Apr 15 07:55:55 2025 +0200

libgcobol: Handle long double as an alternate IEEE754 quad [PR119244]

I think there should be consistency in what we use, so like
libgcobol-fp.h specifies, IEEE quad long double should have highest
priority, then _Float128 with *f128 APIs, then libquadmath.
And when we decide to use say long double, we shouldn't mix that with
strfromf128/strtof128.

Additionally, given that the *l vs. *f128 vs. *q API decision is done
solely in libgcobol and not in the compiler (which is different from
the Fortran case where compiled code emits say sinq or sinf128 calls),
I think libgcobol.spec should only have -lquadmath in any form only in
the case when using libquadmath for everything.  In the Fortran case
it is for backwards compatibility purposes, if something has been
compiled with older gfortran which used say sinq and link is done by
gfortran which has been configured against new glibc with *f128, linking
would fail otherwise.

2025-04-15  Jakub Jelinek  
Rainer Orth  

PR cobol/119244
* acinclude.m4 (LIBGCOBOL_CHECK_FLOAT128): Ensure
libgcob_cv_have_float128 is not yes on targets with IEEE quad
long double.  Don't check for --as-needed nor set LIBQUADSPEC
on targets which USE_IEC_60559.
* libgcobol-fp.h (FP128_FMT, strtofp128, strfromfp128): Define.
* intrinsic.cc (strtof128): Don't redefine.
(WEIRD_TRANSCENDENT_RETURN_VALUE): Use GCOB_FP128_LITERAL macro.
(__gg__numval_f): Use strtofp128 instead of strtof128.
* libgcobol.cc (strtof128): Don't redefine.
(format_for_display_internal): Use strfromfp128 instead of
strfromf128 or quadmath_snprintf and use FP128_FMT in the format
string.
(get_float128, __gg__compare_2, __gg__move, __gg__move_literala):
Use strtofp128 instead of strtof128.
* configure: Regenerate.

Diff:
---
 libgcobol/acinclude.m4   | 124 +++
 libgcobol/configure  | 102 --
 libgcobol/intrinsic.cc   |  12 +
 libgcobol/libgcobol-fp.h |   9 
 libgcobol/libgcobol.cc   |  41 
 5 files changed, 137 insertions(+), 151 deletions(-)

diff --git a/libgcobol/acinclude.m4 b/libgcobol/acinclude.m4
index aab0895146b9..0e81b1083863 100644
--- a/libgcobol/acinclude.m4
+++ b/libgcobol/acinclude.m4
@@ -44,6 +44,10 @@ AC_DEFUN([LIBGCOBOL_CHECK_FLOAT128], [
   AC_CACHE_CHECK([whether we have a usable _Float128 type],
  libgcob_cv_have_float128, [
GCC_TRY_COMPILE_OR_LINK([
+#if __LDBL_MANT_DIG__ == 113 && __LDBL_MIN_EXP__ == -16381
+#error "long double is IEEE quad, no need for libquadmath"
+#endif
+
 _Float128 foo (_Float128 x)
 {
  _Complex _Float128 z1, z2;
@@ -90,32 +94,22 @@ AC_DEFUN([LIBGCOBOL_CHECK_FLOAT128], [
 fi
 AC_DEFINE(HAVE_FLOAT128, 1, [Define if target has usable _Float128 and 
__float128 types.])
 
-dnl Check whether -Wl,--as-needed resp. -Wl,-zignore is supported
-dnl 
-dnl Turn warnings into error to avoid testsuite breakage.  So enable
-dnl AC_LANG_WERROR, but there's currently (autoconf 2.64) no way to turn
-dnl it off again.  As a workaround, save and restore werror flag like
-dnl AC_PATH_XTRA.
-dnl Cf. http://gcc.gnu.org/ml/gcc-patches/2010-05/msg01889.html
-
ac_xsave_[]_AC_LANG_ABBREV[]_werror_flag=$ac_[]_AC_LANG_ABBREV[]_werror_flag
-AC_CACHE_CHECK([whether --as-needed/-z ignore works],
-  [libgcob_cv_have_as_needed],
-  [
-  # Test for native Solaris options first.
-  # No whitespace after -z to pass it through -Wl.
-  libgcob_cv_as_needed_option="-zignore"
-  libgcob_cv_no_as_needed_option="-zrecord"
-  save_LDFLAGS="$LDFLAGS"
-  LDFLAGS="$LDFLAGS -Wl,$libgcob_cv_as_needed_option -lm 
-Wl,$libgcob_cv_no_as_needed_option"
-  libgcob_cv_have_as_needed=no
-  AC_LANG_WERROR
-  AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
-[libgcob_cv_have_as_needed=yes],
-[libgcob_cv_have_as_needed=no])
-  LDFLAGS="$save_LDFLAGS"
-  if test "x$libgcob_cv_have_as_needed" = xno; then
-   libgcob_cv_as_needed_option="--as-needed"
-   libgcob_cv_no_as_needed_option="--no-as-needed"
+if test "x$USE_IEC_60559" != xyes; then
+  dnl Check whether -Wl,--as-needed resp. -Wl,-zignore is supported
+  dnl 
+  dnl Turn warnings into error to avoid testsuite breakage.  So enable
+  dnl AC_LANG_WERROR, but there's currently (autoconf 2.64) no way to turn
+  dnl it off again.  As a workaround, save and restore werror flag like
+  dnl AC_PATH_XTRA.
+  dnl Cf. http://

[gcc r13-9525] vec-lowering: Fix ABSU lowering [PR111285]

2025-04-14 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:935c21e2719cb3124d8d9daa8c5611e1974bd93d

commit r13-9525-g935c21e2719cb3124d8d9daa8c5611e1974bd93d
Author: Andrew Pinski 
Date:   Sun Oct 27 13:16:22 2024 -0700

vec-lowering: Fix ABSU lowering [PR111285]

ABSU_EXPR lowering incorrectly used the resulting type
for the new expression but in the case of ABSU the resulting
type is an unsigned type and with ABSU is folded away. The fix
is to use a signed type for the expression instead.

Bootstrapped and tested on x86_64-linux-gnu.

PR middle-end/111285

gcc/ChangeLog:

* tree-vect-generic.cc (do_unop): Use a signed type for the
operand if the operation was ABSU_EXPR.

gcc/testsuite/ChangeLog:

* g++.dg/torture/vect-absu-1.C: New test.

Signed-off-by: Andrew Pinski 
(cherry picked from commit ad0084337e901ddaedd48c14e7a5dad9fc2a093e)

Diff:
---
 gcc/testsuite/g++.dg/torture/vect-absu-1.C | 29 +
 gcc/tree-vect-generic.cc   | 10 +-
 2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/g++.dg/torture/vect-absu-1.C 
b/gcc/testsuite/g++.dg/torture/vect-absu-1.C
new file mode 100644
index ..0b2035f638f5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/vect-absu-1.C
@@ -0,0 +1,29 @@
+// { dg-do run }
+// PR middle-end/111285
+
+// The lowering of vect absu was done incorrectly
+
+#define vect1 __attribute__((vector_size(sizeof(int
+
+#define negabs(a) a < 0 ? a : -a
+
+__attribute__((noinline))
+int s(int a)
+{
+  return negabs(a);
+}
+__attribute__((noinline))
+vect1 int v(vect1 int a)
+{
+  return negabs(a);
+}
+
+int main(void)
+{
+for(int i = -10; i < 10; i++)
+{
+  vect1 int t = {i};
+  if (v(t)[0] != s(i))
+__builtin_abort();
+}
+}
diff --git a/gcc/tree-vect-generic.cc b/gcc/tree-vect-generic.cc
index 6e74bf05be2b..0b85a54a4ce1 100644
--- a/gcc/tree-vect-generic.cc
+++ b/gcc/tree-vect-generic.cc
@@ -193,7 +193,15 @@ do_unop (gimple_stmt_iterator *gsi, tree inner_type, tree 
a,
 tree b ATTRIBUTE_UNUSED, tree bitpos, tree bitsize,
 enum tree_code code, tree type ATTRIBUTE_UNUSED)
 {
-  a = tree_vec_extract (gsi, inner_type, a, bitsize, bitpos);
+  tree rhs_type = inner_type;
+
+  /* For ABSU_EXPR, use the signed type for the rhs if the rhs was signed. */
+  if (code == ABSU_EXPR
+  && ANY_INTEGRAL_TYPE_P (TREE_TYPE (a))
+  && !TYPE_UNSIGNED (TREE_TYPE (a)))
+rhs_type = signed_type_for (rhs_type);
+
+  a = tree_vec_extract (gsi, rhs_type, a, bitsize, bitpos);
   return gimplify_build1 (gsi, code, inner_type, a);
 }


[gcc r15-9472] Doc: clarify -march=pentiumpro has no MMX support [PR42683]

2025-04-14 Thread Sandra Loosemore via Gcc-cvs
https://gcc.gnu.org/g:f7a2f0aa6bd28c054cecfda9d2c499a304cd4c2a

commit r15-9472-gf7a2f0aa6bd28c054cecfda9d2c499a304cd4c2a
Author: Sandra Loosemore 
Date:   Tue Apr 15 00:56:30 2025 +

Doc: clarify -march=pentiumpro has no MMX support [PR42683]

gcc/ChangeLog
PR target/42683
* doc/invoke.texi (x86 Options): Clarify that -march=pentiumpro
doesn't include MMX.

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

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 67155eeeda7d..1f7657b72b7f 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -34872,7 +34872,7 @@ Intel Lakemont MCU, based on Intel Pentium CPU.
 Intel Pentium MMX CPU, based on Pentium core with MMX instruction set support.
 
 @item pentiumpro
-Intel Pentium Pro CPU@.
+Intel Pentium Pro CPU with no MMX support.
 
 @item i686
 When used with @option{-march}, the Pentium Pro


[gcc(refs/users/meissner/heads/work201)] Add support for -mcpu=future

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:51126db6a9cf3a0be5da2baac765986feafc78fc

commit 51126db6a9cf3a0be5da2baac765986feafc78fc
Author: Michael Meissner 
Date:   Mon Apr 14 20:26:49 2025 -0400

Add support for -mcpu=future

This patch adds the support that can be used in developing GCC support for
future PowerPC processors.

2025-04-14  Michael Meissner  

* config.gcc (powerpc*-*-*): Add support for --with-cpu=future.
* config/rs6000/aix71.h (ASM_CPU_SPEC): Add support for 
-mcpu=future.
* config/rs6000/aix72.h (ASM_CPU_SPEC): Likewise.
* config/rs6000/aix73.h (ASM_CPU_SPEC): Likewise.
* config/rs6000/driver-rs6000.cc (asm_names): Likewise.
* config/rs6000/rs6000-c.cc (rs6000_target_modify_macros): If
-mcpu=future, define _ARCH_FUTURE.
* config/rs6000/rs6000-cpus.def (FUTURE_MASKS_SERVER): New macro.
(POWERPC_MASKS): Add OPTION_MASK_FUTURE.
(future cpu): Define.
* config/rs6000/rs6000-opts.h (enum processor_type): Add
PROCESSOR_FUTURE.
* config/rs6000/rs6000-tables.opt: Regenerate.
* config/rs6000/rs6000.cc (power10_cost): Update comment.
(get_arch_flags): Add support for future processor.
(rs6000_option_override_internal): Likewise.
(rs6000_machine_from_flags): Likewise.
(rs6000_reassociation_width): Likewise.
(rs6000_adjust_cost): Likewise.
(rs6000_issue_rate): Likewise.
(rs6000_sched_reorder): Likewise.
(rs6000_sched_reorder2): Likewise.
(rs6000_register_move_cost): Likewise.
(rs6000_opt_masks): Add -mfuture.
* config/rs6000/rs6000.h (ASM_CPU_SPEC): Likewise.
* config/rs6000/rs6000.md (cpu attribute): Likewise.
* config/rs6000/rs6000.opt (-mfuture): New internal option.

Diff:
---
 gcc/config.gcc  |  4 ++--
 gcc/config/rs6000/aix71.h   |  1 +
 gcc/config/rs6000/aix72.h   |  1 +
 gcc/config/rs6000/aix73.h   |  1 +
 gcc/config/rs6000/driver-rs6000.cc  |  2 ++
 gcc/config/rs6000/rs6000-c.cc   |  2 ++
 gcc/config/rs6000/rs6000-cpus.def   |  5 +
 gcc/config/rs6000/rs6000-opts.h |  1 +
 gcc/config/rs6000/rs6000-tables.opt | 11 +++
 gcc/config/rs6000/rs6000.cc | 30 ++
 gcc/config/rs6000/rs6000.h  |  1 +
 gcc/config/rs6000/rs6000.md |  2 +-
 gcc/config/rs6000/rs6000.opt|  6 ++
 13 files changed, 52 insertions(+), 15 deletions(-)

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 40b50dc969ed..1d8a0c80672f 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -535,7 +535,7 @@ powerpc*-*-*)
extra_headers="${extra_headers} ppu_intrinsics.h spu2vmx.h vec_types.h 
si2vmx.h"
extra_headers="${extra_headers} amo.h"
case x$with_cpu in
-   
xpowerpc64|xdefault64|x6[23]0|x970|xG5|xpower[3456789]|xpower1[01]|xpower6x|xrs64a|xcell|xa2|xe500mc64|xe5500|xe6500)
+   
xpowerpc64|xdefault64|x6[23]0|x970|xG5|xpower[3456789]|xpower1[01]|xpower6x|xrs64a|xcell|xa2|xe500mc64|xe5500|xe6500|xfuture)
cpu_is_64bit=yes
;;
esac
@@ -5682,7 +5682,7 @@ case "${target}" in
tm_defines="${tm_defines} CONFIG_PPC405CR"
eval "with_$which=405"
;;
-   "" | common | native \
+   "" | common | native | future \
| power[3456789] | power1[01] | power5+ | power6x \
| powerpc | powerpc64 | powerpc64le \
| rs64 \
diff --git a/gcc/config/rs6000/aix71.h b/gcc/config/rs6000/aix71.h
index 2b21dd7cd1e0..77651f5ea309 100644
--- a/gcc/config/rs6000/aix71.h
+++ b/gcc/config/rs6000/aix71.h
@@ -79,6 +79,7 @@ do {  
\
 #undef ASM_CPU_SPEC
 #define ASM_CPU_SPEC \
 "%{mcpu=native: %(asm_cpu_native); \
+  mcpu=future: -mfuture; \
   mcpu=power11: -mpwr11; \
   mcpu=power10: -mpwr10; \
   mcpu=power9: -mpwr9; \
diff --git a/gcc/config/rs6000/aix72.h b/gcc/config/rs6000/aix72.h
index 53c0bde5ad4a..652f60c7f494 100644
--- a/gcc/config/rs6000/aix72.h
+++ b/gcc/config/rs6000/aix72.h
@@ -79,6 +79,7 @@ do {  
\
 #undef ASM_CPU_SPEC
 #define ASM_CPU_SPEC \
 "%{mcpu=native: %(asm_cpu_native); \
+  mcpu=future: -mfuture; \
   mcpu=power11: -mpwr11; \
   mcpu=power10: -mpwr10; \
   mcpu=power9: -mpwr9; \
diff --git a/gcc/config/rs6000/aix73.h b/gcc/config/rs6000/aix73.h
index c7639368a264..3c66ac1d9171 100644
--- a/gcc/config/rs6000/aix73.h
+++ b/gcc/config/rs6000/aix73.h
@@ -79,6 +79,7 @@ do {  
\
 #undef ASM_CPU_SPEC
 #define ASM_CPU_SPEC \
 "%{mcpu=nati

[gcc r15-9464] Add 'std::bad_cast' exception test cases for GCN, nvptx target and OpenACC, OpenMP 'target' offloadi

2025-04-14 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:0e68f49db986d8d6c1eaaa96dd14f7b2a927a0d0

commit r15-9464-g0e68f49db986d8d6c1eaaa96dd14f7b2a927a0d0
Author: Thomas Schwinge 
Date:   Thu Mar 27 14:46:20 2025 +0100

Add 'std::bad_cast' exception test cases for GCN, nvptx target and OpenACC, 
OpenMP 'target' offloading

gcc/testsuite/
* g++.target/gcn/exceptions-bad_cast-1.C: New.
* g++.target/nvptx/exceptions-bad_cast-1.C: Likewise.
libgomp/
* testsuite/libgomp.c++/target-exceptions-bad_cast-1.C: New.
* testsuite/libgomp.oacc-c++/exceptions-bad_cast-1.C: Likewise.

Diff:
---
 .../g++.target/gcn/exceptions-bad_cast-1.C | 15 ++
 .../g++.target/nvptx/exceptions-bad_cast-1.C   | 15 ++
 .../libgomp.c++/target-exceptions-bad_cast-1.C | 25 ++
 .../libgomp.oacc-c++/exceptions-bad_cast-1.C   | 54 ++
 4 files changed, 109 insertions(+)

diff --git a/gcc/testsuite/g++.target/gcn/exceptions-bad_cast-1.C 
b/gcc/testsuite/g++.target/gcn/exceptions-bad_cast-1.C
new file mode 100644
index ..f3e30994bc7c
--- /dev/null
+++ b/gcc/testsuite/g++.target/gcn/exceptions-bad_cast-1.C
@@ -0,0 +1,15 @@
+/* 'std::bad_cast' exception.  */
+
+/* { dg-do run } */
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+/* { dg-additional-options -fexceptions } */
+/* { dg-additional-options -fdump-tree-optimized-raw } */
+
+#include 
"../../../../libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-1.C"
+
+/* { dg-output {CheCKpOInT[\r\n]+} }
+
+   { dg-final { scan-tree-dump-times {gimple_call <__cxa_bad_cast, } 1 
optimized } }
+   We don't print anything, but just 'abort'.
+
+   { dg-shouldfail {'std::bad_cast' exception} } */
diff --git a/gcc/testsuite/g++.target/nvptx/exceptions-bad_cast-1.C 
b/gcc/testsuite/g++.target/nvptx/exceptions-bad_cast-1.C
new file mode 100644
index ..f3e30994bc7c
--- /dev/null
+++ b/gcc/testsuite/g++.target/nvptx/exceptions-bad_cast-1.C
@@ -0,0 +1,15 @@
+/* 'std::bad_cast' exception.  */
+
+/* { dg-do run } */
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+/* { dg-additional-options -fexceptions } */
+/* { dg-additional-options -fdump-tree-optimized-raw } */
+
+#include 
"../../../../libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-1.C"
+
+/* { dg-output {CheCKpOInT[\r\n]+} }
+
+   { dg-final { scan-tree-dump-times {gimple_call <__cxa_bad_cast, } 1 
optimized } }
+   We don't print anything, but just 'abort'.
+
+   { dg-shouldfail {'std::bad_cast' exception} } */
diff --git a/libgomp/testsuite/libgomp.c++/target-exceptions-bad_cast-1.C 
b/libgomp/testsuite/libgomp.c++/target-exceptions-bad_cast-1.C
new file mode 100644
index ..3848295fbabc
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/target-exceptions-bad_cast-1.C
@@ -0,0 +1,25 @@
+/* 'std::bad_cast' exception in OpenMP 'target' region.  */
+
+/* { dg-require-effective-target exceptions }
+   { dg-additional-options -fexceptions } */
+/* { dg-additional-options -fdump-tree-optimized-raw }
+   { dg-additional-options -foffload-options=-fdump-tree-optimized-raw } */
+
+#include "../libgomp.oacc-c++/exceptions-bad_cast-1.C"
+
+/* { dg-output {CheCKpOInT[\r\n]+} }
+
+   { dg-final { scan-tree-dump-times {gimple_call <__cxa_bad_cast, } 1 
optimized } }
+   { dg-final { scan-offload-tree-dump-times {gimple_call <__cxa_bad_cast, } 1 
optimized } }
+   For host execution, we print something like:
+   terminate called after throwing an instance of 'std::bad_cast'
+ what():  std::bad_cast
+   Aborted (core dumped)
+   { dg-output {.*std::bad_cast} { target { ! offload_device } } }
+   For GCN, nvptx offload execution, we don't print anything, but just 'abort'.
+
+   TODO For GCN, nvptx offload execution, this currently doesn't 'abort' due to
+   the 'std::bad_cast' exception, but rather due to SIGSEGV in 'dynamic_cast';
+   PR119692.
+
+   { dg-shouldfail {'std::bad_cast' exception} } */
diff --git a/libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-1.C 
b/libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-1.C
new file mode 100644
index ..05456011ca1d
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-1.C
@@ -0,0 +1,54 @@
+/* 'std::bad_cast' exception in OpenACC compute region.  */
+
+/* { dg-require-effective-target exceptions }
+   { dg-additional-options -fexceptions } */
+/* { dg-additional-options -fdump-tree-optimized-raw }
+   { dg-additional-options -foffload-options=-fdump-tree-optimized-raw } */
+
+/* See also '../libgomp.c++/target-exceptions-bad_cast-1.C'.  */
+
+/* See also '../../../gcc/testsuite/g++.target/gcn/exceptions-bad_cast-1.C',
+   '../../../gcc/testsuite/g++.target/nvptx/exceptions-bad_cast-1.C'.  */
+
+#include 
+
+struct C1
+{
+  virtual void f()
+  {}
+};
+
+struct C2 : C1
+{
+};
+
+int main()
+{
+  std::cerr <<

[gcc/meissner/heads/work201-libs] (14 commits) Merge commit 'refs/users/meissner/heads/work201-libs' of gi

2025-04-14 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work201-libs' was updated to point to:

 c9ef15b5cf8e... Merge commit 'refs/users/meissner/heads/work201-libs' of gi

It previously pointed to:

 95d53c351e59... Add ChangeLog.libs and update REVISION.

Diff:

Summary of changes (added commits):
---

  c9ef15b... Merge commit 'refs/users/meissner/heads/work201-libs' of gi
  aaad547... Add ChangeLog.libs and update REVISION.
  a6ffd50... Update ChangeLog.* (*)
  ccc8b43... Use architecture flags for defining _ARCH_PWR macros. (*)
  680d73b... Add rs6000 architecture masks. (*)
  c8a6cb0... xUse vector pair load/store for memcpy with -mcpu=future (*)
  7880c5c... Add -mcpu=future tests. (*)
  3e1e33a... Add -mcpu=future tuning support. (*)
  51126db... Add support for -mcpu=future (*)
  754bb7e... Change TARGET_MODULO to TARGET_POWER9. (*)
  4bc7533... Change TARGET_POPCNTD to TARGET_POWER7. (*)
  d1ebe30... Change TARGET_CMPB to TARGET_POWER6. (*)
  aa02d95... Change TARGET_FPRND to TARGET_POWER5X. (*)
  40b94e8... Change TARGET_POPCNTB to TARGET_POWER5. (*)

(*) This commit already exists in another branch.
Because the reference `refs/users/meissner/heads/work201-libs' matches
your hooks.email-new-commits-only configuration,
no separate email is sent for this commit.


[gcc(refs/users/meissner/heads/work201)] Use architecture flags for defining _ARCH_PWR macros.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:ccc8b43a88efd7ecf0e4556ffd4865f1fe58456f

commit ccc8b43a88efd7ecf0e4556ffd4865f1fe58456f
Author: Michael Meissner 
Date:   Mon Apr 14 20:32:30 2025 -0400

Use architecture flags for defining _ARCH_PWR macros.

For the newer architectures, this patch changes GCC to define the 
_ARCH_PWR
macros using the new architecture flags instead of relying on isa options 
like
-mpower10.

The -mpower8-internal, -mpower10, -mpower11, and -mfuture options were 
removed.
The -mpower11 and -mfuture options were removed completely, since they were 
just
added in GCC 15. The other two options were marked as WarnRemoved, and the
various ISA bits were removed.

TARGET_POWER8, TARGET_POWER10, TARGET_POWER11, and TARGET_FUTURE were 
re-defined
to use the architeture bits instead of the ISA bits.

There are other internal isa bits that aren't removed with this patch 
because
the built-in function support uses those bits.

I have built both big endian and little endian bootstrap compilers and there
were no regressions.

Can I install this patch on the GCC 15 trunk?

2025-04-14  Michael Meissner  

gcc/

* config/rs6000/rs6000-c.cc (rs6000_target_modify_macros) Add 
support to
use architecture flags instead of ISA flags for setting most of the
_ARCH_PWR* macros.
(rs6000_cpu_cpp_builtins): Update rs6000_target_modify_macros call.
* config/rs6000/rs6000-cpus.def (ISA_2_7_MASKS_SERVER): Remove
OPTION_MASK_POWER8.
(ISA_3_1_MASKS_SERVER): Remove OPTION_MASK_POWER10.
(POWER11_MASKS_SERVER): Remove OPTION_MASK_POWER11.
(FUTURE_MASKS_SERVER): Remove OPTION_MASK_FUTURE.
(POWERPC_MASKS): Remove OPTION_MASK_POWER8, OPTION_MASK_POWER10,
OPTION_MASK_POWER11, and OPTION_MASK_FUTURE.
* config/rs6000/rs6000-protos.h (rs6000_target_modify_macros): 
Update
declaration.
(rs6000_target_modify_macros_ptr): Likewise.
* config/rs6000/rs6000.cc (rs6000_target_modify_macros_ptr): 
Likewise.
(rs6000_option_override_internal): Use architecture flags instead 
of ISA
flags.
(rs6000_opt_masks): Remove -mpower10, -mpower11, and -mfuture which 
are
no longer in the ISA flags.
(rs6000_pragma_target_parse): Use architecture flags as well as ISA
flags.
* config/rs6000/rs6000.h (TARGET_POWER5): Redefine to use 
architecture
flags.
(TARGET_POWER5X): Likewise.
(TARGET_POWER6): Likewise.
(TARGET_POWER7): Likewise.
(TARGET_POWER8): Likewise.
(TARGET_POWER9): Likewise.
(TARGET_POWER10): New macro.
(TARGET_POWER11): Likewise.
(TARGET_FUTURE): Likewise.
* config/rs6000/rs6000.opt (-mpower8-internal): Remove ISA flag 
bits.
(-mpower10): Likewise.
(-mpower11): Likewise.
(-mfuture): Likewise.

Diff:
---
 gcc/config/rs6000/rs6000-c.cc | 29 -
 gcc/config/rs6000/rs6000-cpus.def | 10 +-
 gcc/config/rs6000/rs6000-protos.h |  5 +++--
 gcc/config/rs6000/rs6000.cc   | 20 +++-
 gcc/config/rs6000/rs6000.h| 19 +--
 gcc/config/rs6000/rs6000.opt  | 17 ++---
 6 files changed, 46 insertions(+), 54 deletions(-)

diff --git a/gcc/config/rs6000/rs6000-c.cc b/gcc/config/rs6000/rs6000-c.cc
index 6757a2477ad1..6d6838735b33 100644
--- a/gcc/config/rs6000/rs6000-c.cc
+++ b/gcc/config/rs6000/rs6000-c.cc
@@ -338,7 +338,8 @@ rs6000_define_or_undefine_macro (bool define_p, const char 
*name)
#pragma GCC target, we need to adjust the macros dynamically.  */
 
 void
-rs6000_target_modify_macros (bool define_p, HOST_WIDE_INT flags)
+rs6000_target_modify_macros (bool define_p, HOST_WIDE_INT flags,
+HOST_WIDE_INT arch_flags)
 {
   if (TARGET_DEBUG_BUILTIN || TARGET_DEBUG_TARGET)
 fprintf (stderr,
@@ -411,7 +412,7 @@ rs6000_target_modify_macros (bool define_p, HOST_WIDE_INT 
flags)
summary of the flags associated with particular cpu
definitions.  */
 
-  /* rs6000_isa_flags based options.  */
+  /* rs6000_isa_flags and rs6000_arch_flags based options.  */
   rs6000_define_or_undefine_macro (define_p, "_ARCH_PPC");
   if ((flags & OPTION_MASK_PPC_GPOPT) != 0)
 rs6000_define_or_undefine_macro (define_p, "_ARCH_PPCSQ");
@@ -419,25 +420,27 @@ rs6000_target_modify_macros (bool define_p, HOST_WIDE_INT 
flags)
 rs6000_define_or_undefine_macro (define_p, "_ARCH_PPCGR");
   if ((flags & OPTION_MASK_POWERPC64) != 0)
 rs6000_define_or_undefine_macro (define_p, "_ARCH_PPC64");
-  if ((flags & OPTION_MASK_MFCRF) != 0)
+  if ((flags & OPTION_MASK_POWERPC64) != 0)
+rs6000_define_or_undefine_macro (define_p, "_ARCH_PPC64");

[gcc r14-11614] phiopt: Reset the number of iterations information of a loop when changing an exit from the loop [PR

2025-04-14 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:6f0d80202b62ae48381d9ec7488522199cb7922a

commit r14-11614-g6f0d80202b62ae48381d9ec7488522199cb7922a
Author: Andrew Pinski 
Date:   Mon Dec 2 08:35:23 2024 -0800

phiopt: Reset the number of iterations information of a loop when changing 
an exit from the loop [PR117243]

After r12-5300-gf98f373dd822b3, phiopt could get the following bb structure:
  |
middle-bb -|
  ||
  |   ||   |
phi<1, 2>  |   |
cond   |   |
  ||   |
  |+---|

Which was considered 2 loops. The inner loop had esimtate of upper_bound to 
be 8,
due to the original `for (b = 0; b <= 7; b++)`. The outer loop was already 
an
infinite one.
So phiopt would come along and change the condition to be unconditionally 
true,
we change the inner loop to being an infinite one but don't reset the 
estimate
on the loop and cleanup cfg comes along and changes it into one loop but 
also
does not reset the estimate of the loop. Then the loop unrolling uses the 
old estimate
and decides to add an unreachable there.o
So the fix is when phiopt changes an exit to a loop, reset the estimates, 
similar to
how cleanupcfg does it when merging some basic blocks.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/117243
PR tree-optimization/116749

gcc/ChangeLog:

* tree-ssa-phiopt.cc (replace_phi_edge_with_variable): Reset loop
estimates if the cond_block was an exit to a loop.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr117243-1.c: New test.
* gcc.dg/torture/pr117243-2.c: New test.

Signed-off-by: Andrew Pinski 
(cherry picked from commit b7c69cc072ef0da36439ebc55c513b48e68391b7)

Diff:
---
 gcc/testsuite/gcc.dg/torture/pr117243-1.c | 30 +++
 gcc/testsuite/gcc.dg/torture/pr117243-2.c | 34 +++
 gcc/tree-ssa-phiopt.cc| 11 ++
 3 files changed, 75 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/torture/pr117243-1.c 
b/gcc/testsuite/gcc.dg/torture/pr117243-1.c
new file mode 100644
index ..c4bbc31467c5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr117243-1.c
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-options "-fdump-tree-optimized" } */
+/* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } { "" } } */
+
+/* PR tree-optimization/117243 */
+/* foo should be an infinite but sometimes it gets optimized incorrectly into
+   an __builtin_unreachable(); which is not valid.  */
+void
+foo (unsigned int a, unsigned char b)
+{
+  lbl:
+  for (b = 0; b <= 7; b++)
+{
+  unsigned char c[1][1];
+  int i, j;
+  for (i = 0; i < 1; i++)
+for (j = 0; j < 1; j++)
+  c[i][j] = 1;
+  if (b)
+   goto lbl;
+}
+}
+
+int
+main ()
+{
+  foo (1, 2);
+}
+
+/* { dg-final { scan-tree-dump-not "__builtin_unreachable " "optimized"} } */
diff --git a/gcc/testsuite/gcc.dg/torture/pr117243-2.c 
b/gcc/testsuite/gcc.dg/torture/pr117243-2.c
new file mode 100644
index ..d9b0d3eeb982
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr117243-2.c
@@ -0,0 +1,34 @@
+/* { dg-do compile } */
+/* { dg-options "-fno-tree-ch -fdump-tree-optimized" } */
+/* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } { "" } } */
+
+/* PR tree-optimization/117243 */
+/* PR tree-optimization/116749 */
+
+/* main1 should be an infinite but sometimes it gets optimized incorrectly into
+   an __builtin_unreachable(); which is not valid.  */
+int main1 (void)
+{
+int g=0;
+int l1[1];
+int *l2 = &g;
+int i;
+for (i=0; i<1; i++)
+l1[i] = (1);
+for (g=0; g; ++g)
+{
+int *l3[1] = {&l1[0]};
+}
+*l2 = *l1;
+b:
+for (i=0; i<2; ++i)
+{ 
+if (i)
+goto b;
+if (g)
+continue;
+}
+return 0;
+}
+
+/* { dg-final { scan-tree-dump-not "__builtin_unreachable " "optimized"} } */
diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
index 14bb8442a395..b8c5cc0e0d30 100644
--- a/gcc/tree-ssa-phiopt.cc
+++ b/gcc/tree-ssa-phiopt.cc
@@ -54,6 +54,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "dbgcnt.h"
 #include "tree-ssa-propagate.h"
 #include "tree-ssa-dce.h"
+#include "tree-ssa-loop-niter.h"
 
 /* Return the singleton PHI in the SEQ of PHIs for edges E0 and E1. */
 
@@ -159,6 +160,16 @@ replace_phi_edge_with_variable (basic_block cond_block,
   else
 gcc_unreachable ();
 
+  /* If we are removing the cond on a loop exit,
+ reset number of iteration information of the loop. */
+  if (loop_exits_from_bb_p (cond_block->loop_father, cond_block))
+{
+  auto loop = cond_block->loop_father;
+  free_numbers_of_iterations_estimates (loop);
+  loop->any_upper_bound = false;
+  loop->any_likely_upper_bound = false;
+}
+
   i

[gcc/meissner/heads/work201-bugs] (14 commits) Merge commit 'refs/users/meissner/heads/work201-bugs' of gi

2025-04-14 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work201-bugs' was updated to point to:

 67f6869ed192... Merge commit 'refs/users/meissner/heads/work201-bugs' of gi

It previously pointed to:

 7e0a10be75e4... Add ChangeLog.bugs and update REVISION.

Diff:

Summary of changes (added commits):
---

  67f6869... Merge commit 'refs/users/meissner/heads/work201-bugs' of gi
  954acd8... Add ChangeLog.bugs and update REVISION.
  a6ffd50... Update ChangeLog.* (*)
  ccc8b43... Use architecture flags for defining _ARCH_PWR macros. (*)
  680d73b... Add rs6000 architecture masks. (*)
  c8a6cb0... xUse vector pair load/store for memcpy with -mcpu=future (*)
  7880c5c... Add -mcpu=future tests. (*)
  3e1e33a... Add -mcpu=future tuning support. (*)
  51126db... Add support for -mcpu=future (*)
  754bb7e... Change TARGET_MODULO to TARGET_POWER9. (*)
  4bc7533... Change TARGET_POPCNTD to TARGET_POWER7. (*)
  d1ebe30... Change TARGET_CMPB to TARGET_POWER6. (*)
  aa02d95... Change TARGET_FPRND to TARGET_POWER5X. (*)
  40b94e8... Change TARGET_POPCNTB to TARGET_POWER5. (*)

(*) This commit already exists in another branch.
Because the reference `refs/users/meissner/heads/work201-bugs' matches
your hooks.email-new-commits-only configuration,
no separate email is sent for this commit.


[gcc r15-9465] Add 'std::bad_cast' exception, caught test cases for GCN, nvptx target and OpenACC, OpenMP 'target'

2025-04-14 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:00cde164eeb834958ae8f9eec0c7c9cc3ac697a1

commit r15-9465-g00cde164eeb834958ae8f9eec0c7c9cc3ac697a1
Author: Thomas Schwinge 
Date:   Thu Mar 27 14:46:20 2025 +0100

Add 'std::bad_cast' exception, caught test cases for GCN, nvptx target and 
OpenACC, OpenMP 'target' offloading

gcc/testsuite/
* g++.target/gcn/exceptions-bad_cast-2.C: New.
* g++.target/nvptx/exceptions-bad_cast-2.C: Likewise.
libgomp/
* testsuite/libgomp.c++/target-exceptions-bad_cast-2.C: New.
* 
testsuite/libgomp.c++/target-exceptions-bad_cast-2-offload-sorry-GCN.C: 
Likewise.
* 
testsuite/libgomp.c++/target-exceptions-bad_cast-2-offload-sorry-nvptx.C: 
Likewise.
* testsuite/libgomp.oacc-c++/exceptions-bad_cast-2.C: Likewise.
* 
testsuite/libgomp.oacc-c++/exceptions-bad_cast-2-offload-sorry-GCN.C: Likewise.
* 
testsuite/libgomp.oacc-c++/exceptions-bad_cast-2-offload-sorry-nvptx.C: 
Likewise.

Diff:
---
 .../g++.target/gcn/exceptions-bad_cast-2.C | 12 ++
 .../g++.target/nvptx/exceptions-bad_cast-2.C   | 12 ++
 ...arget-exceptions-bad_cast-2-offload-sorry-GCN.C | 18 
 ...get-exceptions-bad_cast-2-offload-sorry-nvptx.C | 18 
 .../libgomp.c++/target-exceptions-bad_cast-2.C | 14 +++
 .../exceptions-bad_cast-2-offload-sorry-GCN.C  | 17 
 .../exceptions-bad_cast-2-offload-sorry-nvptx.C| 19 +
 .../libgomp.oacc-c++/exceptions-bad_cast-2.C   | 48 ++
 8 files changed, 158 insertions(+)

diff --git a/gcc/testsuite/g++.target/gcn/exceptions-bad_cast-2.C 
b/gcc/testsuite/g++.target/gcn/exceptions-bad_cast-2.C
new file mode 100644
index ..ffe9e19a281e
--- /dev/null
+++ b/gcc/testsuite/g++.target/gcn/exceptions-bad_cast-2.C
@@ -0,0 +1,12 @@
+/* 'std::bad_cast' exception, caught.  */
+
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+/* { dg-additional-options -fexceptions } */
+/* { dg-additional-options -fdump-tree-optimized-raw } */
+
+#include 
"../../../../libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-2.C"
+
+/* { dg-final { scan-tree-dump-times {gimple_call <__cxa_bad_cast, } 1 
optimized } }
+   Compilation fails:
+   { dg-regexp {[^\r\n]+: In function 'int main\(\)':[\r\n]+(?:[^\r\n]+: 
sorry, unimplemented: exception handling not supported[\r\n]+)+} }
+   (Note, using 'dg-regexp' instead of 'dg-message', as the former runs before 
the auto-mark-UNSUPPORTED.)  */
diff --git a/gcc/testsuite/g++.target/nvptx/exceptions-bad_cast-2.C 
b/gcc/testsuite/g++.target/nvptx/exceptions-bad_cast-2.C
new file mode 100644
index ..ffe9e19a281e
--- /dev/null
+++ b/gcc/testsuite/g++.target/nvptx/exceptions-bad_cast-2.C
@@ -0,0 +1,12 @@
+/* 'std::bad_cast' exception, caught.  */
+
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+/* { dg-additional-options -fexceptions } */
+/* { dg-additional-options -fdump-tree-optimized-raw } */
+
+#include 
"../../../../libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-2.C"
+
+/* { dg-final { scan-tree-dump-times {gimple_call <__cxa_bad_cast, } 1 
optimized } }
+   Compilation fails:
+   { dg-regexp {[^\r\n]+: In function 'int main\(\)':[\r\n]+(?:[^\r\n]+: 
sorry, unimplemented: exception handling not supported[\r\n]+)+} }
+   (Note, using 'dg-regexp' instead of 'dg-message', as the former runs before 
the auto-mark-UNSUPPORTED.)  */
diff --git 
a/libgomp/testsuite/libgomp.c++/target-exceptions-bad_cast-2-offload-sorry-GCN.C
 
b/libgomp/testsuite/libgomp.c++/target-exceptions-bad_cast-2-offload-sorry-GCN.C
new file mode 100644
index ..ed670a80fb63
--- /dev/null
+++ 
b/libgomp/testsuite/libgomp.c++/target-exceptions-bad_cast-2-offload-sorry-GCN.C
@@ -0,0 +1,18 @@
+/* 'std::bad_cast' exception in OpenMP 'target' region, caught.  */
+
+/* As this test case involves an expected offload compilation failure, we have 
to handle each offload target individually.
+   { dg-do link { target offload_target_amdgcn } }
+   { dg-additional-options -foffload=amdgcn-amdhsa } */
+/* { dg-require-effective-target exceptions }
+   { dg-additional-options -fexceptions } */
+/* { dg-additional-options -fdump-tree-optimized-raw }
+   { dg-additional-options -foffload-options=-fdump-tree-optimized-raw } */
+
+#include "target-exceptions-bad_cast-2.C"
+
+/* { dg-final { scan-tree-dump-times {gimple_call <__cxa_bad_cast, } 1 
optimized } }
+   { dg-final { only_for_offload_target amdgcn-amdhsa 
scan-offload-tree-dump-times {gimple_call <__cxa_bad_cast, } 1 optimized } }
+   Offload compilation fails:
+   { dg-regexp {[^\r\n]+: In function 'main[^']+':[\r\n]+(?:[^\r\n]+: sorry, 
unimplemented: exception handling not supported[\r\n]+)+} }
+   (Note, using 'dg-regexp' instead of 'dg-message', as the former runs before 
the auto-mark-UNSUPPORTED.)
+   { 

[gcc(refs/users/meissner/heads/work201-math)] Add ChangeLog.math and update REVISION.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:af080c41f0511b1e3987bbf5aa15b01c32021176

commit af080c41f0511b1e3987bbf5aa15b01c32021176
Author: Michael Meissner 
Date:   Mon Apr 14 15:17:52 2025 -0400

Add ChangeLog.math and update REVISION.

2025-04-14  Michael Meissner  

gcc/

* ChangeLog.math: New file for branch.
* REVISION: Update.

Diff:
---
 gcc/ChangeLog.math | 5 +
 gcc/REVISION   | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.math b/gcc/ChangeLog.math
new file mode 100644
index ..fe8cef4665ad
--- /dev/null
+++ b/gcc/ChangeLog.math
@@ -0,0 +1,5 @@
+ Branch work201-math, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/REVISION b/gcc/REVISION
index 5f8715c4844d..6f5edba6571c 100644
--- a/gcc/REVISION
+++ b/gcc/REVISION
@@ -1 +1 @@
-work201 branch
+work201-math branch


[gcc/meissner/heads/work201-vpair] (14 commits) Merge commit 'refs/users/meissner/heads/work201-vpair' of g

2025-04-14 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work201-vpair' was updated to point to:

 8092330895ee... Merge commit 'refs/users/meissner/heads/work201-vpair' of g

It previously pointed to:

 7804b9c15da5... Add ChangeLog.vpair and update REVISION.

Diff:

Summary of changes (added commits):
---

  8092330... Merge commit 'refs/users/meissner/heads/work201-vpair' of g
  8e650b3... Add ChangeLog.vpair and update REVISION.
  a6ffd50... Update ChangeLog.* (*)
  ccc8b43... Use architecture flags for defining _ARCH_PWR macros. (*)
  680d73b... Add rs6000 architecture masks. (*)
  c8a6cb0... xUse vector pair load/store for memcpy with -mcpu=future (*)
  7880c5c... Add -mcpu=future tests. (*)
  3e1e33a... Add -mcpu=future tuning support. (*)
  51126db... Add support for -mcpu=future (*)
  754bb7e... Change TARGET_MODULO to TARGET_POWER9. (*)
  4bc7533... Change TARGET_POPCNTD to TARGET_POWER7. (*)
  d1ebe30... Change TARGET_CMPB to TARGET_POWER6. (*)
  aa02d95... Change TARGET_FPRND to TARGET_POWER5X. (*)
  40b94e8... Change TARGET_POPCNTB to TARGET_POWER5. (*)

(*) This commit already exists in another branch.
Because the reference `refs/users/meissner/heads/work201-vpair' matches
your hooks.email-new-commits-only configuration,
no separate email is sent for this commit.


[gcc(refs/users/meissner/heads/work201-test)] Add ChangeLog.test and update REVISION.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:3f1549119891b7780e00185f64fffde588cb07bb

commit 3f1549119891b7780e00185f64fffde588cb07bb
Author: Michael Meissner 
Date:   Mon Apr 14 15:17:00 2025 -0400

Add ChangeLog.test and update REVISION.

2025-04-14  Michael Meissner  

gcc/

* ChangeLog.test: New file for branch.
* REVISION: Update.

Diff:
---
 gcc/ChangeLog.test | 5 +
 gcc/REVISION   | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.test b/gcc/ChangeLog.test
new file mode 100644
index ..b7353453a268
--- /dev/null
+++ b/gcc/ChangeLog.test
@@ -0,0 +1,5 @@
+ Branch work201-test, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/REVISION b/gcc/REVISION
index 5f8715c4844d..a43f066a082a 100644
--- a/gcc/REVISION
+++ b/gcc/REVISION
@@ -1 +1 @@
-work201 branch
+work201-test branch


[gcc(refs/users/meissner/heads/work201)] Add rs6000 architecture masks.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:680d73b40150fad81c2531e155f2ecb58452b9d0

commit 680d73b40150fad81c2531e155f2ecb58452b9d0
Author: Michael Meissner 
Date:   Mon Apr 14 20:31:44 2025 -0400

Add rs6000 architecture masks.

This patch begins the journey to move architecture bits that are not user 
ISA
options from rs6000_isa_flags to a new targt variable rs6000_arch_flags.  
The
intention is to remove switches that are currently isa options, but the user
should not be using this particular option. For example, we want users to 
use
-mcpu=power10 and not just -mpower10.

This patch also changes the target_clones support to use an architecture 
mask
instead of isa bits.

This patch also switches the handling of .machine to use architecture masks 
if
they exist (power4 through power11).  All of the other PowerPCs will 
continue to
use the existing code for setting the .machine option.

I have built both big endian and little endian bootstrap compilers and there
were no regressions.

In addition, I constructed a test case that used every archiecture define 
(like
_ARCH_PWR4, etc.) and I also looked at the .machine directive generated.  I 
ran
this test for all supported combinations of -mcpu, big/little endian, and 
32/64
bit support.  Every single instance generated exactly the same code with the
patches installed compared to the compiler before installing the patches.

The only difference in this patch compared to the first version posted on
November 6th is that I the correct attribution and copyright year (i.e. 
that I
created rs6000-arch.def in 2024).

Can I install this patch on the GCC 15 trunk?

2025-04-14  Michael Meissner  

gcc/

* config/rs6000/default64.h (TARGET_CPU_DEFAULT): Set default cpu 
name.
* config/rs6000/rs6000-arch.def: New file.
* config/rs6000/rs6000.cc (struct clone_map): Switch to using
architecture masks instead of ISA masks.
(rs6000_clone_map): Likewise.
(rs6000_print_isa_options): Add an architecture flags argument, 
change
all callers.
(get_arch_flag): New function.
(rs6000_debug_reg_global): Update rs6000_print_isa_options calls.
(rs6000_option_override_internal): Likewise.
(rs6000_machine_from_flags): Switch to using architecture masks 
instead
of ISA masks.
(struct rs6000_arch_mask): New structure.
(rs6000_arch_masks): New table of architecutre masks and names.
(rs6000_function_specific_save): Save architecture flags.
(rs6000_function_specific_restore): Restore architecture flags.
(rs6000_function_specific_print): Update rs6000_print_isa_options 
calls.
(rs6000_print_options_internal): Add architecture flags options.
(rs6000_clone_priority): Switch to using architecture masks instead 
of
ISA masks.
(rs6000_can_inline_p): Don't allow inling if the callee requires a 
newer
architecture than the caller.
* config/rs6000/rs6000.h: Use rs6000-arch.def to create the 
architecture
masks.
* config/rs6000/rs6000.opt (rs6000_arch_flags): New target variable.
(x_rs6000_arch_flags): New save/restore field for rs6000_arch_flags.

Diff:
---
 gcc/config/rs6000/default64.h |  11 ++
 gcc/config/rs6000/rs6000-arch.def |  49 +
 gcc/config/rs6000/rs6000.cc   | 222 +++---
 gcc/config/rs6000/rs6000.h|  24 +
 gcc/config/rs6000/rs6000.opt  |   8 ++
 5 files changed, 277 insertions(+), 37 deletions(-)

diff --git a/gcc/config/rs6000/default64.h b/gcc/config/rs6000/default64.h
index 7f6001ded852..188f5c1d1378 100644
--- a/gcc/config/rs6000/default64.h
+++ b/gcc/config/rs6000/default64.h
@@ -21,6 +21,7 @@ along with GCC; see the file COPYING3.  If not see
 #define RS6000_CPU(NAME, CPU, FLAGS)
 #include "rs6000-cpus.def"
 #undef RS6000_CPU
+#undef TARGET_CPU_DEFAULT
 
 #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN)
 #undef TARGET_DEFAULT
@@ -28,10 +29,20 @@ along with GCC; see the file COPYING3.  If not see
| MASK_LITTLE_ENDIAN)
 #undef ASM_DEFAULT_SPEC
 #define ASM_DEFAULT_SPEC "-mpower8"
+#define TARGET_CPU_DEFAULT "power8"
+
 #else
 #undef TARGET_DEFAULT
 #define TARGET_DEFAULT (OPTION_MASK_PPC_GFXOPT | OPTION_MASK_PPC_GPOPT \
| OPTION_MASK_MFCRF | MASK_POWERPC64 | MASK_64BIT)
 #undef ASM_DEFAULT_SPEC
 #define ASM_DEFAULT_SPEC "-mpower4"
+
+#if (TARGET_DEFAULT & MASK_POWERPC64)
+#define TARGET_CPU_DEFAULT "powerpc64"
+
+#else
+#define TARGET_CPU_DEFAULT "powerpc"
+#endif
+
 #endif
diff --git a/gcc/config/rs6000/rs6000-arch.def 
b/gcc/config/rs6000/rs6000-arch.def
new file mode 100644
index ..c0dbc5834333
--- /dev/null
+++ b/gcc/config/rs6000/rs6000-arch.def
@

[gcc(refs/users/meissner/heads/work201-dmf)] Add ChangeLog.dmf and update REVISION.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:5b28ebfda6ca34cc1b085c208cbb569b6a49

commit 5b28ebfda6ca34cc1b085c208cbb569b6a49
Author: Michael Meissner 
Date:   Mon Apr 14 15:12:24 2025 -0400

Add ChangeLog.dmf and update REVISION.

2025-04-14  Michael Meissner  

gcc/

* ChangeLog.dmf: New file for branch.
* REVISION: Update.

Diff:
---
 gcc/ChangeLog.dmf | 5 +
 gcc/REVISION  | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.dmf b/gcc/ChangeLog.dmf
new file mode 100644
index ..211e3edc44fc
--- /dev/null
+++ b/gcc/ChangeLog.dmf
@@ -0,0 +1,5 @@
+ Branch work201-dmf, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/REVISION b/gcc/REVISION
index 5f8715c4844d..c257804fb56a 100644
--- a/gcc/REVISION
+++ b/gcc/REVISION
@@ -1 +1 @@
-work201 branch
+work201-dmf branch


[gcc/meissner/heads/work201-dmf] (14 commits) Merge commit 'refs/users/meissner/heads/work201-dmf' of git

2025-04-14 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work201-dmf' was updated to point to:

 6f82e02caa34... Merge commit 'refs/users/meissner/heads/work201-dmf' of git

It previously pointed to:

 0d37093f29db... Add ChangeLog.dmf and update REVISION.

Diff:

Summary of changes (added commits):
---

  6f82e02... Merge commit 'refs/users/meissner/heads/work201-dmf' of git
  5b2... Add ChangeLog.dmf and update REVISION.
  a6ffd50... Update ChangeLog.* (*)
  ccc8b43... Use architecture flags for defining _ARCH_PWR macros. (*)
  680d73b... Add rs6000 architecture masks. (*)
  c8a6cb0... xUse vector pair load/store for memcpy with -mcpu=future (*)
  7880c5c... Add -mcpu=future tests. (*)
  3e1e33a... Add -mcpu=future tuning support. (*)
  51126db... Add support for -mcpu=future (*)
  754bb7e... Change TARGET_MODULO to TARGET_POWER9. (*)
  4bc7533... Change TARGET_POPCNTD to TARGET_POWER7. (*)
  d1ebe30... Change TARGET_CMPB to TARGET_POWER6. (*)
  aa02d95... Change TARGET_FPRND to TARGET_POWER5X. (*)
  40b94e8... Change TARGET_POPCNTB to TARGET_POWER5. (*)

(*) This commit already exists in another branch.
Because the reference `refs/users/meissner/heads/work201-dmf' matches
your hooks.email-new-commits-only configuration,
no separate email is sent for this commit.


[gcc(refs/users/meissner/heads/work201-bugs)] Merge commit 'refs/users/meissner/heads/work201-bugs' of git+ssh://gcc.gnu.org/git/gcc into me/work2

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:67f6869ed192629f2dd443f209ef402ad532d4c6

commit 67f6869ed192629f2dd443f209ef402ad532d4c6
Merge: 954acd83eaba 7e0a10be75e4
Author: Michael Meissner 
Date:   Mon Apr 14 20:37:11 2025 -0400

Merge commit 'refs/users/meissner/heads/work201-bugs' of 
git+ssh://gcc.gnu.org/git/gcc into me/work201-bugs

Diff:


[gcc(refs/users/meissner/heads/work201)] Update ChangeLog.*

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:a6ffd5060cdf0f1724d715c2739b37df604c4800

commit a6ffd5060cdf0f1724d715c2739b37df604c4800
Author: Michael Meissner 
Date:   Mon Apr 14 20:35:57 2025 -0400

Update ChangeLog.*

Diff:
---
 gcc/ChangeLog.meissner | 396 +
 1 file changed, 396 insertions(+)

diff --git a/gcc/ChangeLog.meissner b/gcc/ChangeLog.meissner
index 8fe7da956044..9257f309048e 100644
--- a/gcc/ChangeLog.meissner
+++ b/gcc/ChangeLog.meissner
@@ -1,5 +1,401 @@
+ Branch work201, patch #21 
+
+Use architecture flags for defining _ARCH_PWR macros.
+
+For the newer architectures, this patch changes GCC to define the _ARCH_PWR
+macros using the new architecture flags instead of relying on isa options like
+-mpower10.
+
+The -mpower8-internal, -mpower10, -mpower11, and -mfuture options were removed.
+The -mpower11 and -mfuture options were removed completely, since they were 
just
+added in GCC 15. The other two options were marked as WarnRemoved, and the
+various ISA bits were removed.
+
+TARGET_POWER8, TARGET_POWER10, TARGET_POWER11, and TARGET_FUTURE were 
re-defined
+to use the architeture bits instead of the ISA bits.
+
+There are other internal isa bits that aren't removed with this patch because
+the built-in function support uses those bits.
+
+I have built both big endian and little endian bootstrap compilers and there
+were no regressions.
+
+Can I install this patch on the GCC 15 trunk?
+
+2025-04-14  Michael Meissner  
+
+gcc/
+
+   * config/rs6000/rs6000-c.cc (rs6000_target_modify_macros) Add support to
+   use architecture flags instead of ISA flags for setting most of the
+   _ARCH_PWR* macros.
+   (rs6000_cpu_cpp_builtins): Update rs6000_target_modify_macros call.
+   * config/rs6000/rs6000-cpus.def (ISA_2_7_MASKS_SERVER): Remove
+   OPTION_MASK_POWER8.
+   (ISA_3_1_MASKS_SERVER): Remove OPTION_MASK_POWER10.
+   (POWER11_MASKS_SERVER): Remove OPTION_MASK_POWER11.
+   (FUTURE_MASKS_SERVER): Remove OPTION_MASK_FUTURE.
+   (POWERPC_MASKS): Remove OPTION_MASK_POWER8, OPTION_MASK_POWER10,
+   OPTION_MASK_POWER11, and OPTION_MASK_FUTURE.
+   * config/rs6000/rs6000-protos.h (rs6000_target_modify_macros): Update
+   declaration.
+   (rs6000_target_modify_macros_ptr): Likewise.
+   * config/rs6000/rs6000.cc (rs6000_target_modify_macros_ptr): Likewise.
+   (rs6000_option_override_internal): Use architecture flags instead of ISA
+   flags.
+   (rs6000_opt_masks): Remove -mpower10, -mpower11, and -mfuture which are
+   no longer in the ISA flags.
+   (rs6000_pragma_target_parse): Use architecture flags as well as ISA
+   flags.
+   * config/rs6000/rs6000.h (TARGET_POWER5): Redefine to use architecture
+   flags.
+   (TARGET_POWER5X): Likewise.
+   (TARGET_POWER6): Likewise.
+   (TARGET_POWER7): Likewise.
+   (TARGET_POWER8): Likewise.
+   (TARGET_POWER9): Likewise.
+   (TARGET_POWER10): New macro.
+   (TARGET_POWER11): Likewise.
+   (TARGET_FUTURE): Likewise.
+   * config/rs6000/rs6000.opt (-mpower8-internal): Remove ISA flag bits.
+   (-mpower10): Likewise.
+   (-mpower11): Likewise.
+   (-mfuture): Likewise.
+
+ Branch work201, patch #20 
+
+Add rs6000 architecture masks.
+
+This patch begins the journey to move architecture bits that are not user ISA
+options from rs6000_isa_flags to a new targt variable rs6000_arch_flags.  The
+intention is to remove switches that are currently isa options, but the user
+should not be using this particular option. For example, we want users to use
+-mcpu=power10 and not just -mpower10.
+
+This patch also changes the target_clones support to use an architecture mask
+instead of isa bits.
+
+This patch also switches the handling of .machine to use architecture masks if
+they exist (power4 through power11).  All of the other PowerPCs will continue 
to
+use the existing code for setting the .machine option.
+
+I have built both big endian and little endian bootstrap compilers and there
+were no regressions.
+
+In addition, I constructed a test case that used every archiecture define (like
+_ARCH_PWR4, etc.) and I also looked at the .machine directive generated.  I ran
+this test for all supported combinations of -mcpu, big/little endian, and 32/64
+bit support.  Every single instance generated exactly the same code with the
+patches installed compared to the compiler before installing the patches.
+
+The only difference in this patch compared to the first version posted on
+November 6th is that I the correct attribution and copyright year (i.e. that I
+created rs6000-arch.def in 2024).
+
+Can I install this patch on the GCC 15 trunk?
+
+2025-04-14  Michael Meissner  
+
+gcc/
+
+   * config/rs6000/default64.h (TARGET_CPU_DEFAULT): Set default cpu name.
+   * config/rs6000/rs6000-arch.def: New file.
+   * conf

[gcc(refs/users/meissner/heads/work201-libs)] Merge commit 'refs/users/meissner/heads/work201-libs' of git+ssh://gcc.gnu.org/git/gcc into me/work2

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:c9ef15b5cf8ecf8de021fcf1189be8f57e2e0a7f

commit c9ef15b5cf8ecf8de021fcf1189be8f57e2e0a7f
Merge: aaad5476d7f6 95d53c351e59
Author: Michael Meissner 
Date:   Mon Apr 14 20:41:14 2025 -0400

Merge commit 'refs/users/meissner/heads/work201-libs' of 
git+ssh://gcc.gnu.org/git/gcc into me/work201-libs

Diff:


[gcc/meissner/heads/work201-math] (14 commits) Merge commit 'refs/users/meissner/heads/work201-math' of gi

2025-04-14 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work201-math' was updated to point to:

 882e2314109a... Merge commit 'refs/users/meissner/heads/work201-math' of gi

It previously pointed to:

 faf9364c9875... Add ChangeLog.math and update REVISION.

Diff:

Summary of changes (added commits):
---

  882e231... Merge commit 'refs/users/meissner/heads/work201-math' of gi
  af080c4... Add ChangeLog.math and update REVISION.
  a6ffd50... Update ChangeLog.* (*)
  ccc8b43... Use architecture flags for defining _ARCH_PWR macros. (*)
  680d73b... Add rs6000 architecture masks. (*)
  c8a6cb0... xUse vector pair load/store for memcpy with -mcpu=future (*)
  7880c5c... Add -mcpu=future tests. (*)
  3e1e33a... Add -mcpu=future tuning support. (*)
  51126db... Add support for -mcpu=future (*)
  754bb7e... Change TARGET_MODULO to TARGET_POWER9. (*)
  4bc7533... Change TARGET_POPCNTD to TARGET_POWER7. (*)
  d1ebe30... Change TARGET_CMPB to TARGET_POWER6. (*)
  aa02d95... Change TARGET_FPRND to TARGET_POWER5X. (*)
  40b94e8... Change TARGET_POPCNTB to TARGET_POWER5. (*)

(*) This commit already exists in another branch.
Because the reference `refs/users/meissner/heads/work201-math' matches
your hooks.email-new-commits-only configuration,
no separate email is sent for this commit.


[gcc(refs/users/meissner/heads/work201-libs)] Add ChangeLog.libs and update REVISION.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:aaad5476d7f6c18a797d999b650a73140b0c9d52

commit aaad5476d7f6c18a797d999b650a73140b0c9d52
Author: Michael Meissner 
Date:   Mon Apr 14 15:15:07 2025 -0400

Add ChangeLog.libs and update REVISION.

2025-04-14  Michael Meissner  

gcc/

* ChangeLog.libs: New file for branch.
* REVISION: Update.

Diff:
---
 gcc/ChangeLog.libs | 5 +
 gcc/REVISION   | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.libs b/gcc/ChangeLog.libs
new file mode 100644
index ..69f46576250c
--- /dev/null
+++ b/gcc/ChangeLog.libs
@@ -0,0 +1,5 @@
+ Branch work201-libs, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/REVISION b/gcc/REVISION
index 5f8715c4844d..7dae70785b31 100644
--- a/gcc/REVISION
+++ b/gcc/REVISION
@@ -1 +1 @@
-work201 branch
+work201-libs branch


[gcc/meissner/heads/work201-test] (14 commits) Merge commit 'refs/users/meissner/heads/work201-test' of gi

2025-04-14 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work201-test' was updated to point to:

 8616368e9404... Merge commit 'refs/users/meissner/heads/work201-test' of gi

It previously pointed to:

 bf8ac60a11f3... Add ChangeLog.test and update REVISION.

Diff:

Summary of changes (added commits):
---

  8616368... Merge commit 'refs/users/meissner/heads/work201-test' of gi
  3f15491... Add ChangeLog.test and update REVISION.
  a6ffd50... Update ChangeLog.* (*)
  ccc8b43... Use architecture flags for defining _ARCH_PWR macros. (*)
  680d73b... Add rs6000 architecture masks. (*)
  c8a6cb0... xUse vector pair load/store for memcpy with -mcpu=future (*)
  7880c5c... Add -mcpu=future tests. (*)
  3e1e33a... Add -mcpu=future tuning support. (*)
  51126db... Add support for -mcpu=future (*)
  754bb7e... Change TARGET_MODULO to TARGET_POWER9. (*)
  4bc7533... Change TARGET_POPCNTD to TARGET_POWER7. (*)
  d1ebe30... Change TARGET_CMPB to TARGET_POWER6. (*)
  aa02d95... Change TARGET_FPRND to TARGET_POWER5X. (*)
  40b94e8... Change TARGET_POPCNTB to TARGET_POWER5. (*)

(*) This commit already exists in another branch.
Because the reference `refs/users/meissner/heads/work201-test' matches
your hooks.email-new-commits-only configuration,
no separate email is sent for this commit.


[gcc(refs/users/meissner/heads/work201-sha)] Merge commit 'refs/users/meissner/heads/work201-sha' of git+ssh://gcc.gnu.org/git/gcc into me/work20

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:e326d72a05dc4ebe0caadc0dc94c50cedbc53b4a

commit e326d72a05dc4ebe0caadc0dc94c50cedbc53b4a
Merge: 00f23871ca09 0339a910393a
Author: Michael Meissner 
Date:   Mon Apr 14 20:49:51 2025 -0400

Merge commit 'refs/users/meissner/heads/work201-sha' of 
git+ssh://gcc.gnu.org/git/gcc into me/work201-sha

Diff:


[gcc(refs/users/meissner/heads/work201-dmf)] Merge commit 'refs/users/meissner/heads/work201-dmf' of git+ssh://gcc.gnu.org/git/gcc into me/work20

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:6f82e02caa34a1622acaccd5f282301402aea568

commit 6f82e02caa34a1622acaccd5f282301402aea568
Merge: 5b28ebfd 0d37093f29db
Author: Michael Meissner 
Date:   Mon Apr 14 20:38:36 2025 -0400

Merge commit 'refs/users/meissner/heads/work201-dmf' of 
git+ssh://gcc.gnu.org/git/gcc into me/work201-dmf

Diff:


[gcc(refs/users/meissner/heads/work201-vpair)] Merge commit 'refs/users/meissner/heads/work201-vpair' of git+ssh://gcc.gnu.org/git/gcc into me/work

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:8092330895ee8ac344aedbe583f3c85ab9e03277

commit 8092330895ee8ac344aedbe583f3c85ab9e03277
Merge: 8e650b368108 7804b9c15da5
Author: Michael Meissner 
Date:   Mon Apr 14 20:52:37 2025 -0400

Merge commit 'refs/users/meissner/heads/work201-vpair' of 
git+ssh://gcc.gnu.org/git/gcc into me/work201-vpair

Diff:


[gcc r15-9436] rust: Use error_operand_p in rust-gcc.cc

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:a2db03fdf37ba823c9acf479aaed841b7d0de761

commit r15-9436-ga2db03fdf37ba823c9acf479aaed841b7d0de761
Author: Andrew Pinski 
Date:   Wed Mar 19 17:30:00 2025 -0700

rust: Use error_operand_p in rust-gcc.cc

Just a simple cleanupof the code to use error_operand_p
instead of directly comparing against error_mark_node.

This also moves some cdoe around when dealing with error_operand_p
just to be faster and/or slightly tighten up the code slightly.

gcc/rust/ChangeLog:

* rust-gcc.cc (Bvariable::get_tree): Use error_operand_p.
(pointer_type): Likewise.
(reference_type): Likewise.
(immutable_type): Likewise.
(function_type): Likewise.
(function_type_variadic): Likewise.
Cleanup the check for receiver.type first.
(function_ptr_type): Use error_operand_p.
(fill_in_fields): Likewise.
(fill_in_array): Likewise.
(named_type): Likewise.
(type_size): Likewise.
(type_alignment): Likewise.
(type_field_alignment): Likewise.
(type_field_offset): Likewise.
(zero_expression): Likewise.
(float_constant_expression): Likewise.
(convert_expression): Likewise.
(struct_field_expression): Likewise.
(compound_expression): Likewise.
(conditional_expression): Likewise.
(negation_expression): Likewise.
(arithmetic_or_logical_expression): Likewise.
(arithmetic_or_logical_expression_checked): Likewise.
(comparison_expression): Likewise.
(lazy_boolean_expression): Likewise.
(constructor_expression): Likewise.
(array_constructor_expression): Likewise.
(array_index_expression): Likewise.
(call_expression): Likewise.
(init_statement): Likewise.
(assignment_statement): Likewise.
(return_statement): Likewise.
(exception_handler_statement): Likewise.
(if_statement): Likewise.
(compound_statement): Likewise.
Tighten up the code, removing t variable.
(statement_list): Use error_operand_p.
(block): Likewise.
(block_add_statements): Likewise.
(convert_tree): Likewise.
(global_variable): Likewise.
(global_variable_set_init): Likewise.
(local_variable): Likewise.
(parameter_variable): Likewise.
(static_chain_variable): Likewise.
(temporary_variable): Likewise.
(function): Likewise. Tighten up the code.
(function_defer_statement): Use error_operand_p.
(function_set_parameters): Use error_operand_p.
(write_global_definitions): Use error_operand_p.
Tighten up the code around the loop.

Signed-off-by: Andrew Pinski 

Diff:
---
 gcc/rust/rust-gcc.cc | 189 ---
 1 file changed, 88 insertions(+), 101 deletions(-)

diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
index 7c5af211bbc7..13b7cea6a3fc 100644
--- a/gcc/rust/rust-gcc.cc
+++ b/gcc/rust/rust-gcc.cc
@@ -61,7 +61,7 @@
 tree
 Bvariable::get_tree (location_t location) const
 {
-  if (this->t_ == error_mark_node)
+  if (error_operand_p (this->t_))
 return error_mark_node;
 
   TREE_USED (this->t_) = 1;
@@ -431,7 +431,7 @@ float_type (int bits)
 tree
 pointer_type (tree to_type)
 {
-  if (to_type == error_mark_node)
+  if (error_operand_p (to_type))
 return error_mark_node;
   tree type = build_pointer_type (to_type);
   return type;
@@ -442,7 +442,7 @@ pointer_type (tree to_type)
 tree
 reference_type (tree to_type)
 {
-  if (to_type == error_mark_node)
+  if (error_operand_p (to_type))
 return error_mark_node;
   tree type = build_reference_type (to_type);
   return type;
@@ -453,7 +453,7 @@ reference_type (tree to_type)
 tree
 immutable_type (tree base)
 {
-  if (base == error_mark_node)
+  if (error_operand_p (base))
 return error_mark_node;
   tree constified = build_qualified_type (base, TYPE_QUAL_CONST);
   return constified;
@@ -472,7 +472,7 @@ function_type (const typed_identifier &receiver,
   if (receiver.type != NULL_TREE)
 {
   tree t = receiver.type;
-  if (t == error_mark_node)
+  if (error_operand_p (t))
return error_mark_node;
   *pp = tree_cons (NULL_TREE, t, NULL_TREE);
   pp = &TREE_CHAIN (*pp);
@@ -482,7 +482,7 @@ function_type (const typed_identifier &receiver,
p != parameters.end (); ++p)
 {
   tree t = p->type;
-  if (t == error_mark_node)
+  if (error_operand_p (t))
return error_mark_node;
   *pp = tree_cons (NULL_TREE, t, NULL_TREE);
   pp = &TREE_CHAIN (*pp);
@@ -502,11 +502,11 @@ function_type (const typed_identifier &receiver,
   gcc_assert (result_struc

[gcc r15-9435] rust: Use FLOAT_TYPE_P instead of manual checking

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:3eb76b8c62a2b3a9c6c7292e6692b48b3483fde0

commit r15-9435-g3eb76b8c62a2b3a9c6c7292e6692b48b3483fde0
Author: Andrew Pinski 
Date:   Wed Mar 19 17:29:59 2025 -0700

rust: Use FLOAT_TYPE_P instead of manual checking

This moves is_floating_point over to using FLOAT_TYPE_P instead
of manually checking. Note before it would return true for all
COMPLEX_TYPE but complex types' inner type could be integral.

Also fixes up the comment to be in more of the GNU style.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/rust/ChangeLog:

* rust-gcc.cc (is_floating_point): Use FLOAT_TYPE_P
instead of manually checking the type.

Signed-off-by: Andrew Pinski 

Diff:
---
 gcc/rust/rust-gcc.cc | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
index 72aef08e35a0..7c5af211bbc7 100644
--- a/gcc/rust/rust-gcc.cc
+++ b/gcc/rust/rust-gcc.cc
@@ -1021,12 +1021,12 @@ operator_to_tree_code (LazyBooleanOperator op)
 }
 }
 
-/* Helper function for deciding if a tree is a floating point node. */
+/* Returns true if the type of EXP is a floating point type.
+   False otherwise.  */
 bool
-is_floating_point (tree t)
+is_floating_point (tree exp)
 {
-  auto tree_type = TREE_CODE (TREE_TYPE (t));
-  return tree_type == REAL_TYPE || tree_type == COMPLEX_TYPE;
+  return FLOAT_TYPE_P (TREE_TYPE (exp));
 }
 
 // Return an expression for the negation operation OP EXPR.


[gcc r15-9463] Add test cases for exception handling constructs in dead code for GCN, nvptx target and OpenMP 'targ

2025-04-14 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:aa3e72f943032e5f074b2bd2fd06d130dda8760b

commit r15-9463-gaa3e72f943032e5f074b2bd2fd06d130dda8760b
Author: Thomas Schwinge 
Date:   Thu Mar 27 23:06:37 2025 +0100

Add test cases for exception handling constructs in dead code for GCN, 
nvptx target and OpenMP 'target' offloading [PR118794]

PR target/118794
gcc/testsuite/
* g++.target/gcn/exceptions-pr118794-1.C: New.
* g++.target/nvptx/exceptions-pr118794-1.C: Likewise.
libgomp/
* testsuite/libgomp.c++/target-exceptions-pr118794-1.C: New.
* 
testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-GCN.C:
Likewise.
* 
testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-nvptx.C:
Likewise.

Diff:
---
 .../g++.target/gcn/exceptions-pr118794-1.C | 16 ++
 .../g++.target/nvptx/exceptions-pr118794-1.C   | 16 ++
 ...arget-exceptions-pr118794-1-offload-sorry-GCN.C | 23 +
 ...get-exceptions-pr118794-1-offload-sorry-nvptx.C | 23 +
 .../libgomp.c++/target-exceptions-pr118794-1.C | 58 ++
 5 files changed, 136 insertions(+)

diff --git a/gcc/testsuite/g++.target/gcn/exceptions-pr118794-1.C 
b/gcc/testsuite/g++.target/gcn/exceptions-pr118794-1.C
new file mode 100644
index ..a7013791511d
--- /dev/null
+++ b/gcc/testsuite/g++.target/gcn/exceptions-pr118794-1.C
@@ -0,0 +1,16 @@
+/* Exception handling constructs in dead code.  */
+
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+/* { dg-additional-options -fexceptions } */
+/* { dg-additional-options -O0 } */
+/* { dg-additional-options -fdump-tree-optimized-raw } */
+
+#include 
"../../../../libgomp/testsuite/libgomp.c++/target-exceptions-pr118794-1.C"
+
+/* In this specific C++ arrangement, distilled from PR118794, GCC synthesizes
+   '__builtin_eh_pointer', '__builtin_unwind_resume' calls as dead code in 'f':
+   { dg-final { scan-tree-dump-times {gimple_call <__builtin_eh_pointer, } 1 
optimized } }
+   { dg-final { scan-tree-dump-times {gimple_call <__builtin_unwind_resume, } 
1 optimized } }
+   Given '-O0', compilation fails:
+   { dg-regexp {[^\r\n]+: In function 'void f\(\)':[\r\n]+(?:[^\r\n]+: sorry, 
unimplemented: exception handling not supported[\r\n]+)+} }
+   (Note, using 'dg-regexp' instead of 'dg-message', as the former runs before 
the auto-mark-UNSUPPORTED.)  */
diff --git a/gcc/testsuite/g++.target/nvptx/exceptions-pr118794-1.C 
b/gcc/testsuite/g++.target/nvptx/exceptions-pr118794-1.C
new file mode 100644
index ..a7013791511d
--- /dev/null
+++ b/gcc/testsuite/g++.target/nvptx/exceptions-pr118794-1.C
@@ -0,0 +1,16 @@
+/* Exception handling constructs in dead code.  */
+
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+/* { dg-additional-options -fexceptions } */
+/* { dg-additional-options -O0 } */
+/* { dg-additional-options -fdump-tree-optimized-raw } */
+
+#include 
"../../../../libgomp/testsuite/libgomp.c++/target-exceptions-pr118794-1.C"
+
+/* In this specific C++ arrangement, distilled from PR118794, GCC synthesizes
+   '__builtin_eh_pointer', '__builtin_unwind_resume' calls as dead code in 'f':
+   { dg-final { scan-tree-dump-times {gimple_call <__builtin_eh_pointer, } 1 
optimized } }
+   { dg-final { scan-tree-dump-times {gimple_call <__builtin_unwind_resume, } 
1 optimized } }
+   Given '-O0', compilation fails:
+   { dg-regexp {[^\r\n]+: In function 'void f\(\)':[\r\n]+(?:[^\r\n]+: sorry, 
unimplemented: exception handling not supported[\r\n]+)+} }
+   (Note, using 'dg-regexp' instead of 'dg-message', as the former runs before 
the auto-mark-UNSUPPORTED.)  */
diff --git 
a/libgomp/testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-GCN.C
 
b/libgomp/testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-GCN.C
new file mode 100644
index ..a588016210c4
--- /dev/null
+++ 
b/libgomp/testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-GCN.C
@@ -0,0 +1,23 @@
+/* Exception handling constructs in dead code.  */
+
+/* As this test case involves an expected offload compilation failure, we have 
to handle each offload target individually.
+   { dg-do link { target offload_target_amdgcn } }
+   { dg-additional-options -foffload=amdgcn-amdhsa } */
+/* { dg-require-effective-target exceptions }
+   { dg-additional-options -fexceptions } */
+/* { dg-additional-options -O0 } */
+/* { dg-additional-options -fdump-tree-optimized-raw }
+   { dg-additional-options -foffload-options=-fdump-tree-optimized-raw } */
+
+#include "target-exceptions-pr118794-1.C"
+
+/* In this specific C++ arrangement, distilled from PR118794, GCC synthesizes
+   '__builtin_eh_pointer', '__builtin_unwind_resume' calls as dead code in 'f':
+   { dg-final { scan-tree-dump-times {gimple_call <__builtin_eh_pointer, } 1 
opt

  1   2   >