]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
2 months agoada: Tweak wording of documentation comments in Atree
Ronan Desplanques [Fri, 7 Feb 2025 13:43:37 +0000 (14:43 +0100)] 
ada: Tweak wording of documentation comments in Atree

This patch removes an outdated reference to the concept of node
extensions in comments. It also slightly clarifies the documentation of
Atree.Relocate_Node.

gcc/ada/ChangeLog:

* atree.ads (New_Copy, Relocate_Node): Tweak documentation comments.

2 months agoada: Activate SPARK_Mode in Ada.Numerics.*_Random specs
Andres Toom [Tue, 28 Jan 2025 13:41:27 +0000 (15:41 +0200)] 
ada: Activate SPARK_Mode in Ada.Numerics.*_Random specs

gcc/ada/ChangeLog:

* libgnat/a-nudira.ads: Activate SPARK mode and add missing
basic contracts. Mark the unit as always terminating.
* libgnat/a-nuflra.ads: Idem.

2 months agoada: Spurious compilation error with repeated loop index
Javier Miranda [Thu, 6 Feb 2025 09:40:57 +0000 (09:40 +0000)] 
ada: Spurious compilation error with repeated loop index

When multiple for-loop statements in the same scope use the
same index name to iterate through container elements, the
compiler reports a spurious error indicating a conflict
between index names.

gcc/ada/ChangeLog:

* exp_ch7.adb (Process_Object_Declaration): Avoid generating
duplicate names for master nodes.

2 months agoada: Remove useless global variable
Ronan Desplanques [Wed, 5 Feb 2025 13:45:28 +0000 (14:45 +0100)] 
ada: Remove useless global variable

This patch removes a global variable that was made useless by a previous
change and mistakenly hadn't been removed then.

gcc/ada/ChangeLog:

* opt.ads: Remove useless variable.
* sem_ch9.adb (Analyze_Abort_Statement, Analyze_Accept_Alternative,
Analyze_Accept_Statement, Analyze_Asynchronous_Select,
Analyze_Conditional_Entry_Call, Analyze_Delay_Alternative,
Analyze_Delay_Relative, Analyze_Delay_Until, Analyze_Entry_Body,
Analyze_Entry_Body_Formal_Part, Analyze_Entry_Call_Alternative,
Analyze_Entry_Declaration, Analyze_Entry_Index_Specification,
Analyze_Protected_Body, Analyze_Protected_Definition,
Analyze_Protected_Type_Declaration, Analyze_Requeue,
Analyze_Selective_Accept, Analyze_Single_Protected_Declaration,
Analyze_Single_Task_Declaration, Analyze_Task_Body,
Analyze_Task_Definition, Analyze_Task_Type_Declaration,
Analyze_Terminate_Alternative, Analyze_Timed_Entry_Call,
Analyze_Triggering_Alternative): Remove useless assignments.

2 months agoada: Exception-raising loop incorrectly eliminated
Steve Baird [Thu, 30 Jan 2025 21:28:50 +0000 (13:28 -0800)] 
ada: Exception-raising loop incorrectly eliminated

If the body of a loop includes a raise statement then the loop should not be
considered to be free of side-effects and therefore eligible for elimination
by the compiler.

gcc/ada/ChangeLog:

* sem_util.adb
(Side_Effect_Free_Statements): Return False if the statement list
includes an explicit (i.e. Comes_From_Source) raise statement.

2 months agoada: Missing error on expression function returning incomplete type
Javier Miranda [Tue, 4 Feb 2025 19:41:53 +0000 (19:41 +0000)] 
ada: Missing error on expression function returning incomplete type

When the type of the expression of an expression function is
an incomplete type, the frontend does not report the expected
error.

gcc/ada/ChangeLog:

* sem_ch6.adb (Analyze_Expression_Function): Add missing check
on premature use of incomplete type.

2 months agoada: Add Ghost aspect to Lo in s-arit32.adb
Aleksandra Pasek [Mon, 3 Feb 2025 18:09:36 +0000 (18:09 +0000)] 
ada: Add Ghost aspect to Lo in s-arit32.adb

gcc/ada/ChangeLog:

* libgnat/s-arit32.adb: Add Ghost aspect to Lo.

2 months agoada: Fix crash on access to protected return
Ronan Desplanques [Mon, 27 Jan 2025 11:04:41 +0000 (12:04 +0100)] 
ada: Fix crash on access to protected return

The generation of the check mandated by Ada issue AI05-0073 was not done
handled properly for protected types when used through subtypes. This
patch fixes the issue.

gcc/ada/ChangeLog:

* exp_ch4.adb (Tagged_Membership): Fix for protected types.

2 months agoada: Improve efficiency of very large shift counts
Bob Duff [Tue, 4 Feb 2025 19:36:03 +0000 (14:36 -0500)] 
ada: Improve efficiency of very large shift counts

For a call to an intrinsic shift function with a large Amount, for
example Shift_Right(..., Amount => Natural'Last), and a
compile-time-known value, the compiler would take an absurdly long time
to compute the value. This patch fixes that by special-casing shift
counts that are larger than the size of the thing being shifted.

gcc/ada/ChangeLog:

* sem_eval.adb (Fold_Shift): If the Amount parameter is greater
than the size in bits, use the size. For example, if we are
shifting an Unsigned_8 value, then Amount => 1_000_001 gives the
same result as Amount => 8. This change avoids computing the value
of 2**1_000_000, which takes too long and uses too much memory.
Note that the computation we're talking about is a compile-time
computation. Minor cleanup. DRY.
* sem_eval.ads (Fold_Str, Fold_Uint, Fold_Ureal): Fold the
comments into one comment, because DRY. Remove useless
verbiage.

2 months agoada: Tweak caching of streaming subprograms
Ronan Desplanques [Fri, 31 Jan 2025 09:40:42 +0000 (10:40 +0100)] 
ada: Tweak caching of streaming subprograms

gcc/ada/ChangeLog:

* exp_attr.adb (Interunit_Ref_OK): Tweak categorization of compilation
units.

2 months agoada: Add missing Ghost aspect to Lemma_Not_In_Range_Big2xx64 in s-aridou.adb
Aleksandra Pasek [Mon, 3 Feb 2025 16:29:21 +0000 (16:29 +0000)] 
ada: Add missing Ghost aspect to Lemma_Not_In_Range_Big2xx64 in s-aridou.adb

gcc/ada/ChangeLog:

* libgnat/s-aridou.adb: Add missing Ghost aspect to
Lemma_Not_In_Range_Big2xx64.

2 months agoada: Mitigate issue with tracebacks
Ronan Desplanques [Thu, 30 Jan 2025 15:02:31 +0000 (16:02 +0100)] 
ada: Mitigate issue with tracebacks

The way we fetch the path to shared objects for traceback generation is
not perfectly precise. This patch adds a sanity check to mitigate the
consequences of incorrect shared object paths. It's motivated by a real
world failure in a GNATSAS test.

gcc/ada/ChangeLog:

* libgnat/s-trasym__dwarf.adb (Init_Module): Add mitigation.

2 months agoada: Implement built-in-place expansion of two-pass array aggregates
Eric Botcazou [Fri, 24 Jan 2025 09:26:13 +0000 (10:26 +0100)] 
ada: Implement built-in-place expansion of two-pass array aggregates

These are array aggregates containing only component associations that are
iterated with iterator specifications, as per RM 4.3.3(20.2/5-20.4/5).

It is implemented for the array aggregates that are used to initialize an
object, as specified by RM 7.6(17.2/3-17.3/3) for immutably limited types
and types that need finalization, but for all types like other aggregates.

gcc/ada/ChangeLog:

* exp_aggr.adb (Build_Two_Pass_Aggr_Code): New function containing
most of the code initially present in Two_Pass_Aggregate_Expansion.
(Two_Pass_Aggregate_Expansion): Remove redundant N parameter.
Implement built-in-place expansion for (static) object declarations
and allocators, using Build_Two_Pass_Aggr_Code for the main work.
(Expand_Array_Aggregate): Adjust Two_Pass_Aggregate_Expansion call.
Replace Etype (N) by Typ in a couple of places.
* exp_ch3.adb (Expand_Freeze_Array_Type): Remove special case for
two-pass array aggregates.
(Expand_N_Object_Declaration): Do not adjust the object when it is
initialized by a two-pass array aggregate.
* exp_ch4.adb (Expand_Allocator_Expression): Apply the processing
used for container aggregates to two-pass array aggregates.
* exp_ch6.adb (Validate_Subprogram_Calls): Skip calls present in
initialization expressions of N_Object_Declaration nodes that have
No_Initialization set.
* sem_ch3.adb (Analyze_Object_Declaration): Detect the cases of an
array originally initialized by an aggregate consistently.

2 months agoada: Add missing Ghost aspect to Lemma_Not_In_Range_Big2xx32 in s-arit32.adb
Johannes Kliemann [Tue, 28 Jan 2025 12:13:31 +0000 (12:13 +0000)] 
ada: Add missing Ghost aspect to Lemma_Not_In_Range_Big2xx32 in s-arit32.adb

gcc/ada/ChangeLog:

* libgnat/s-arit32.adb (Lemma_Not_In_Range_Big2xx32): Add missing
Ghost aspect.

2 months agoada: Fix reproducer generation
Ronan Desplanques [Mon, 20 Jan 2025 15:14:21 +0000 (16:14 +0100)] 
ada: Fix reproducer generation

This patch fixes reproducer generation in the case of crashes in the
back end in the presence of preprocessing dependencies.

gcc/ada/ChangeLog:

* generate_minimal_reproducer.adb (Generate_Minimal_Reproducer): Fix
handling of preprocessing dependencies.

2 months agoada: Reject Valid_Value arguments originating from Standard
Viljar Indus [Mon, 20 Jan 2025 13:10:22 +0000 (15:10 +0200)] 
ada: Reject Valid_Value arguments originating from Standard

The constraint for Valid_Value not applying to types from Standard
should also apply to all types derived from those types.

gcc/ada/ChangeLog:

* doc/gnat_rm/implementation_defined_attributes.rst: Update the
documentation for Valid_Value.
* sem_attr.adb (Analyze_Attribute): Reject types where
the root type originates from Standard.
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.

2 months agoada: Error about assignment to limited target on aggregate with "for of" iterator
Gary Dismukes [Sat, 18 Jan 2025 01:11:12 +0000 (01:11 +0000)] 
ada: Error about assignment to limited target on aggregate with "for of" iterator

The compiler reports a spurious error about an assignment to a limited
object on an aggregate of a array type with limited components that has
an association with a "for of" iterator. This is fixed by arranging to
have the Assignment_OK flag set on the indexed_names generated by the
expander for initializing the aggregate object.

gcc/ada/ChangeLog:

* exp_aggr.adb (Two_Pass_Aggregate_Expansion): Change call to Make_Assignment
for the indexed aggregate object to call Change_Make_OK_Assignment instead.

2 months agoada: Add error message for a declared-too-late abstract state constituent
Steve Baird [Tue, 14 Jan 2025 23:53:57 +0000 (15:53 -0800)] 
ada: Add error message for a declared-too-late abstract state constituent

In the error case of an undefined abstract state constituent, we want to
help users distinguish between the case where the constituent is
"really" undefined versus being defined "too late" (i.e., after a body).
So in the latter case we generate an additional message.

gcc/ada/ChangeLog:

* sem_prag.adb
(Analyze_Constituent): In the specific case case of a defined-too-late
abstract state constituent, generate an additional error message.

2 months agoada: Fix various issues in the SARIF report
Viljar Indus [Mon, 20 Jan 2025 18:04:59 +0000 (20:04 +0200)] 
ada: Fix various issues in the SARIF report

gcc/ada/ChangeLog:

* diagnostics-sarif_emitter.adb (Print_Invocations): fix
commandLine and executionSuccessful nodes.
Fix typo in the name for startLine.
* osint.adb (Modified Get_Current_Dir) Fix generation of
the current directory.
(Relative_Path): Avoid relative paths starting with a
path separator.
* osint.ads: Update the documentation for Relative_Path.

2 months agoada: Fix unnecessarily large allocation in New_String
Ronan Desplanques [Mon, 20 Jan 2025 12:37:08 +0000 (13:37 +0100)] 
ada: Fix unnecessarily large allocation in New_String

This patches fixes an issue where Interfaces.C.Strings.New_String
allocates more memory than necessary when passed a string that contains
a NUL character.

gcc/ada/ChangeLog:

* libgnat/i-cstrin.adb (New_String): Fix size of allocation.

2 months agoada: Implement use implies with experimental extension
squirek [Fri, 17 Jan 2025 15:38:43 +0000 (15:38 +0000)] 
ada: Implement use implies with experimental extension

The patch implements the experimental feature to allow use package
clauses within the context area to imply with.

gcc/ada/ChangeLog:

* sem_ch8.adb (Analyze_Package_Name): Add code to expand use
clauses such that they have an implicit with associated with them
when extensions are enabled.
* sem_ch10.ads (Analyze_With_Clause): New.
* sem_ch10.adb (Analyze_With_Clause): Add comes from source check
for warning.
(Expand_With_Clause): Moved to the spec.
* sem_util.adb, sem_util.ads
(Is_In_Context_Clause): Moved from sem_prag.
* sem_prag.adb (Analyze_Pragma): Update calls to
Is_In_Context_Clause.
(Is_In_Context_Clause): Moved to sem_util.

2 months agoada: Extend and clarify documentation of stack size settings for Windows
Piotr Trojanek [Thu, 16 Jan 2025 16:41:56 +0000 (17:41 +0100)] 
ada: Extend and clarify documentation of stack size settings for Windows

The original documentation for more recent versions of Windows didn't specify
whether the specified stack size acts as a "reserved" or "committed" stack
size.

Also, clarify the wording for older versions of Windows.

gcc/ada/ChangeLog:

* doc/gnat_ugn/platform_specific_information.rst
(Setting Stack Size from gnatlink): Improve documentation.
* gnat-style.texi: Regenerate.
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.

2 months agoada: Spurious accessibility error with -gnatc
squirek [Thu, 16 Jan 2025 17:09:49 +0000 (17:09 +0000)] 
ada: Spurious accessibility error with -gnatc

The patch fixes an issue in the compiler whereby a spurious accessibility
error gets generated in semantic checking mode (-gnatc) when an explicitly
aliased formal gets used as an actual for an access disriminant in a return
object.

gcc/ada/ChangeLog:

* accessibility.adb (Check_Return_Construct_Accessibility):
Disable check generation when we are only checking semantics.
* opt.ads: Add new flag for -gnatc mode
* switch-c.adb (Scan_Front_End_Switches): Set flag for -gnatc mode

2 months agoada: Mark the types of operator arguments as used
Viljar Indus [Thu, 9 Jan 2025 10:37:56 +0000 (12:37 +0200)] 
ada: Mark the types of operator arguments as used

When a use type clause is used then it makes the type and
all of its operators use visible in the context. When analyzing
whether a use type clause is effective we should additionally
mark the types of an overloaded operator as cases where the
use type clause is effective.

gcc/ada/ChangeLog:

* sem_ch8.adb (Mark_Use_Type): Additionally mark the types
of the parameters and return values as used when analyzing an
operator.

2 months agoada: Fix couple of remaining incompatibilities with CHERI architecture
Eric Botcazou [Thu, 16 Jan 2025 14:51:00 +0000 (15:51 +0100)] 
ada: Fix couple of remaining incompatibilities with CHERI architecture

These are the usual problematic patterns in the expanded code.

gcc/ada/ChangeLog:

* exp_ch9.adb (Build_Dispatching_Requeue): Take 'Tag of the
concurrent object instead of doing an unchecked conversion.
* exp_pakd.adb (Expand_Packed_Address_Reference): Perform address
arithmetic using an operator of System.Storage_Elements.

2 months agoada: Fix buffer overflow for function call returning discriminated limited record
Eric Botcazou [Wed, 15 Jan 2025 19:37:48 +0000 (20:37 +0100)] 
ada: Fix buffer overflow for function call returning discriminated limited record

This occurs when the discriminated limited record type is declared with
default values for its discriminants, is not controlled, and the context
of the call is anonymous, i.e. the result of the call is not assigned
to an object.  In this case, a temporary is created to hold the result
of the call, with the default values of the discriminants, but the result
may have different values for the discriminants and, in particular, may
be larger than the temporary, which leads to a buffer overflow.

This problem does not occur when the context is an object declaration, so
the fix just makes sure that the expansion in an anonymous context always
uses the model of an object declaration.  It requires a minor tweak to the
helper function Entity_Of of the Sem_Util package.

gcc/ada/ChangeLog:

* exp_ch6.adb (Expand_Actuals): Remove obsolete comment.
(Make_Build_In_Place_Call_In_Anonymous_Context): Always use a proper
object declaration initialized with the function call in the cases
where a temporary is needed, with Assignment_OK set on it.
* sem_util.adb (Entity_Of): Deal with rewritten function call first.

2 months agoada: Fix New_Char_Array with empty arrays
Ronan Desplanques [Thu, 16 Jan 2025 11:55:37 +0000 (12:55 +0100)] 
ada: Fix New_Char_Array with empty arrays

This patch fixes an integer underflow issue on calls of the form
New_Char_Array (X) with X'Last < X'First - 2. That integer underflow
caused attempts at allocating impossibly large amount of memory in some
cases.

gcc/ada/ChangeLog:

* libgnat/i-cstrin.adb (Position_Of_Nul): Change specification and
adjust body accordingly.
(New_Char_Array): Fix size of allocation.
(To_Chars_Ptr): Adapt to Position_Of_Nul change.

2 months agoada: Fix adareducer oracle generation
Ronan Desplanques [Wed, 15 Jan 2025 08:57:10 +0000 (09:57 +0100)] 
ada: Fix adareducer oracle generation

This patch adds a missing "-quiet" switch to the compiler invocations
performed by generated oracles. Without that switch, log lines could be
present before bug boxes for crashes in gigi and that caused the crash
detection logic to fail.

gcc/ada/ChangeLog:

* generate_minimal_reproducer.adb (Generate_Minimal_Reproducer): Fix
oracle generation.

2 months agoada: Fix Generate_Minimal_Reproducer on instantiations
Ronan Desplanques [Wed, 15 Jan 2025 08:54:45 +0000 (09:54 +0100)] 
ada: Fix Generate_Minimal_Reproducer on instantiations

Before this patch, the code that creates a copy of the semantic closure
with the default naming convention was incorrect when the compiler was
processing a library unit that was an instantiation of a generic with a
body. This patch adds code to detect that situation and adjusts the
copying process accordingly.

gcc/ada/ChangeLog:

* generate_minimal_reproducer.adb (Generate_Minimal_Reproducer):
Fix when main library item is an instantiation.

2 months agoada: Fix compile-time failure due to duplicated attribute subprograms.
Steve Baird [Mon, 13 Jan 2025 22:18:26 +0000 (14:18 -0800)] 
ada: Fix compile-time failure due to duplicated attribute subprograms.

For a given type, and for certain attributes (the 4 streaming attributes
and, for Ada2022, the Put_Image attribute), the compiler needs to keep track
of whether a subprogram has already been generated for the given
type/attribute pair. In some cases this was being done incorrectly;
the compiler ended up generating duplicate subprograms (with the same
name), resulting in compilation failures. This could occur if the prefix
of an attribute reference denoted a subtype (more precisely, a non-first
subtype). This includes the case of a subtype declaration that is implicitly
introduced by the compiler to capture the binding between a formal type
in a generic and the corresponding actual type in an instantiation.

gcc/ada/ChangeLog:

* exp_attr.adb (Expand_N_Attribute_Reference): When accessing the
maps declared in package Cached_Attribute_Ops, the key value
passed to Get or to Set should never be the entity node for a
subtype. Use the entity of the corresponding type declaration
instead.

2 months agoada: Mark constants inside a declare expression as referenced
Viljar Indus [Tue, 14 Jan 2025 11:31:04 +0000 (13:31 +0200)] 
ada: Mark constants inside a declare expression as referenced

Expressions within a declare expression were simply bound to
locally defined constants. However they were never marked as
referenced. This would trigger an unreferenced constant warning
if -gnatwu was used.

gcc/ada/ChangeLog:

* sem_res.adb (Resolve_Declare_Expression): Mark used
local variables inside a declare expression as referenced.

2 months agoada: Cleanup preanalysis of static expressions (part 6)
Javier Miranda [Tue, 14 Jan 2025 11:08:57 +0000 (11:08 +0000)] 
ada: Cleanup preanalysis of static expressions (part 6)

Rename Preanalyze_Spec_Expression as Preanalyze_And_Resolve_Spec_Expression,
Preanalyze_Assert_Expression as Preanalyze_And_Resolve_Assert_Expression,
and Preanalyze_Default_Expression as Preanalyze_And_Resolve_Default_Expression;
cleanup the version of Preanalyze_Assert_Expression without context type.

gcc/ada/ChangeLog:

* sem.ads: Update reference to renamed subprogram in documentation.
* sem_ch3.ads (Preanalyze_Assert_Expression): Renamed.
(Preanalyze_Spec_Expression): Renamed.
* sem_ch3.adb (Preanalyze_Assert_Expression): Renamed and code cleanup.
(Preanalyze_Spec_Expression): Renamed.
(Preanalyze_Default_Expression): Renamed.
* contracts.adb: Update calls to renamed subprograms.
* exp_pakd.adb: Ditto.
* exp_util.adb: Ditto.
* freeze.adb: Ditto.
* sem_ch12.adb: Ditto.
* sem_ch13.adb: Ditto.
* sem_ch6.adb: Ditto.
* sem_prag.adb: Ditto.
* sem_res.adb (Preanalyze_And_Resolve): Add to the version without
context type the special handling for GNATprove mode provided by
the version with context type; required to cleanup the body of
Preanalyze_Assert_Expression.

2 months agoada: Spurious accessibility error with -gnatc
squirek [Tue, 14 Jan 2025 06:40:08 +0000 (06:40 +0000)] 
ada: Spurious accessibility error with -gnatc

The patch fixes an issue in the compiler whereby a spurious accessibility
error gets generated in semantic checking mode (-gnatc) when an explicitly
aliased formal gets used as an actual for an access disriminant in a return
object.

gcc/ada/ChangeLog:

* accessibility.adb
(Check_Return_Construct_Accessibility): Disable check generation
when we are only checking semantics.

2 months agoada: Use absolute paths in SARIF reports
Viljar Indus [Mon, 2 Dec 2024 10:18:06 +0000 (12:18 +0200)] 
ada: Use absolute paths in SARIF reports

gcc/ada/ChangeLog:

* diagnostics-json_utils.adb: Add new method To_File_Uri to
convert any path to the URI standard.
* diagnostics-json_utils.ads: Likewise.
* diagnostics-sarif_emitter.adb: Converted Artifact_Change
types to use the Source_File_Index instead of the file name
to store the source file.
Removed the body from Destroy (Elem : in out Artifact_Change)
since it no longer contained elements with dynamic memory.
Updated the implementation of Equals (L, R : Artifact_Change)
to take into account the changes for Artifact_Change.
Print_Artifact_Location: Use the Source_File_Index as an
input argument. Now prints the uriBaseId attribute and a
relative path from the uriBaseId to the file in question as
the value of the uri attribute.
New method Print_Original_Uri_Base_Ids to print the
originalUriBaseIds node.
Print_Run no prints the originalUriBaseIds node.
Use constants instead of strings for all the SARIF attributes.
* osint.adb: Add new method Relative_Path to calculate the
relative path from a base directory.
Add new method Root to calculate the root of each directory.
Add new method Get_Current_Dir to get the current working
directory for the execution environment.
* osint.ads: Likewise.
* clean.adb: Use full names for calls to Get_Current_Dir.
* gnatls.adb: Likewise.

2 months agoada: Avoid calling Resolve with Stand.Any_Fixed as the expected type
Steve Baird [Fri, 10 Jan 2025 21:15:18 +0000 (13:15 -0800)] 
ada: Avoid calling Resolve with Stand.Any_Fixed as the expected type

When we call Resolve for an expression, we pass in the expected type
for that expression. In the absence of semantic errors, that expected type
should never be any of the "Any_xxx" types declared in stand.ads (e.g.,
Any_Array, Any_Numeric, Any_Real). In particular, it should never be Any_Fixed.
Fix a case in which this rule was being violated.

gcc/ada/ChangeLog:

* sem_res.adb
(Set_Mixed_Mode_Operand): If we are about to call Resolve
passing in Any_Fixed as the expected type, then instead pass in
the fixed point type of the other operand (i.e., B_Typ).

2 months agoada: Compiler crash on array aggregate association iterating over function result
Gary Dismukes [Fri, 10 Jan 2025 22:39:52 +0000 (22:39 +0000)] 
ada: Compiler crash on array aggregate association iterating over function result

The compiler triggers a bug box when compiling an array aggregate with
an iterated_component_association that iterates over another array object,
failing when trying to retrieve a Choices field, which isn't an allowed
field for N_Iterated_Component_Association nodes. This occurs in procedure
Check_Function_Writable_Actuals, which wasn't accounting for the iterated
association forms.

gcc/ada/ChangeLog:

* sem_util.adb (Check_Function_Writable_Actuals): Add handling for
N_Iterated_Component_Association and N_Iterated_Element_Association.
Fix a typo in an RM reference (6.4.1(20/3) => 6.4.1(6.20/3)).
(Collect_Expression_Ids): New procedure factoring code for collecting
identifiers from expressions of aggregate associations.
(Handle_Association_Choices): New procedure factoring code for handling
id collection for expressions of aggregate associations with multiple
choices. Removed redundant test of Box_Present from original code.

2 months agotree-sra: Use MOVE_MAX for sra size limit [PR112824]
Hongyu Wang [Thu, 5 Jun 2025 06:45:08 +0000 (14:45 +0800)] 
tree-sra: Use MOVE_MAX for sra size limit [PR112824]

Current sra use UNITS_PER_WORD to define max scalarization size, but
for targets like x86 it allows operations on larger size, so the
components like vector variables in an aggregate can be larger than
just UNITS_PER_WORD. Use MOVE_MAX instead of UNITS_PER_WORD to allow
sra for aggregates with vector components.

gcc/ChangeLog:

PR middle-end/112824
* tree-sra.cc (sra_get_max_scalarization_size): Use MOVE_MAX
instead of UNITS_PER_WORD to define max_scalarization_size.

gcc/testsuite/ChangeLog:

* g++.target/i386/pr112824-2.C: New test.

2 months agoc++, coroutines: Make analyze_fn_params into a class method.
Iain Sandoe [Thu, 29 May 2025 15:45:44 +0000 (16:45 +0100)] 
c++, coroutines: Make analyze_fn_params into a class method.

This continues code cleanups and migration to encapsulation of the
whole coroutine transform.

gcc/cp/ChangeLog:

* coroutines.cc (analyze_fn_parms): Move from free function..
(cp_coroutine_transform::analyze_fn_parms):... to method.
(cp_coroutine_transform::apply_transforms): Adjust call to
analyze_fn_parms.
* coroutines.h: Declare analyze_fn_parms.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2 months agoc++, coroutines: Simplify initial_await_resume_called.
Iain Sandoe [Thu, 29 May 2025 12:43:37 +0000 (13:43 +0100)] 
c++, coroutines: Simplify initial_await_resume_called.

We do not need to generate this code early, since it does not affect
any of the analysis.  Lowering it later takes less code, and avoids
modifying the initial await expresssion which will simplify changes
to analysis to deal with open PRs.

gcc/cp/ChangeLog:

* coroutines.cc (expand_one_await_expression): Set the
initial_await_resume_called flag here.
(build_actor_fn): Populate the frame accessor for the
initial_await_resume_called flag.
(cp_coroutine_transform::wrap_original_function_body): Do
not modify the initial_await expression to include the
initial_await_resume_called flag here.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2 months agoi386: Fix vmovvdup's mem attribute
Hu, Lin1 [Tue, 27 May 2025 11:09:04 +0000 (19:09 +0800)] 
i386: Fix vmovvdup's mem attribute

Some vmovvdup pattern's type attribute is sselog1 and then mem attribute is
both. Modify type attribute according to other patterns about vmovvdup.

gcc/ChangeLog:

* config/i386/sse.md
(avx512f_movddup512<mask_name>): Change sselog1 to ssemov.
(avx_movddup256<mask_name>): Ditto.
(*vec_dupv2di): Change alternative 4's type attribute from sselog1
to ssemov.

2 months agoRevert "libstdc++: sstream from string_view (P2495R3) [PR119741]"
Nathan Myers [Thu, 5 Jun 2025 03:19:52 +0000 (23:19 -0400)] 
Revert "libstdc++: sstream from string_view (P2495R3) [PR119741]"

This reverts commit 8537e4851072ea1f1982c4c6ab0d24c9383e9edd.

2 months agoRISC-V: Update extension defination.
Jiawei [Thu, 5 Jun 2025 01:38:40 +0000 (09:38 +0800)] 
RISC-V: Update extension defination.

Update the defination of RISC-V extensions in riscv-ext.def.

gcc/ChangeLog:

* config/riscv/riscv-ext.def: Update declaration.

Signed-off-by: Jiawei <jiawei@iscas.ac.cn>
2 months agoDaily bump.
GCC Administrator [Thu, 5 Jun 2025 00:19:21 +0000 (00:19 +0000)] 
Daily bump.

2 months ago[AutoFDO] Profile merging for clone test
Kugan Vivekanandarajah [Wed, 4 Jun 2025 21:15:34 +0000 (07:15 +1000)] 
[AutoFDO] Profile merging for clone test

This patch introduces a new testcase to verify the merging of profiles
is performed for cloned functions.

Since this is invoked very early, before the pass manager, we need to
set up the dumping explicitly. This is similar to the handling in
finish_optimization_passes.

gcc/ChangeLog:

* auto-profile.cc (autofdo_source_profile::read): Dump message
while merging profile.
* pass_manager.h (get_pass_auto_profile): New.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-prof/clone-merge-1.c: New test.

Signed-off-by: Kugan Vivekanandarajah <kvivekananda@nvidia.com>
2 months agolibstdc++: Skip time zone format testing for COW std::string
Jonathan Wakely [Wed, 4 Jun 2025 20:49:54 +0000 (21:49 +0100)] 
libstdc++: Skip time zone format testing for COW std::string

This is needed when testing with -D_GLIBCXX_USE_CXX11_ABI=0 to fix:
FAIL: std/time/format/empty_spec.cc  -std=gnu++20 (test for excess errors)

libstdc++-v3/ChangeLog:

* testsuite/std/time/format/empty_spec.cc: Only test time zones
for cxx11 string ABI.

2 months agoOpenMP: Fix regressions in metadirective-target-device-2.c [PR120518]
Sandra Loosemore [Wed, 4 Jun 2025 04:03:03 +0000 (04:03 +0000)] 
OpenMP: Fix regressions in metadirective-target-device-2.c [PR120518]

My previous patch that added a CLEANUP_POINT_EXPR around the device_num
selector expression in the C++ front end broke the testcase
c-c++-common/gomp/metadirective-target-device-2.c on offload targets.
It confused the code in omp_device_num_check that tries to bypass error
checking and do early resolution when the expression is a call to one
of the OpenMP library functions.  The solution is to make that code smart
enough to look inside a CLEANUP_POINT_EXPR.

gcc/ChangeLog
PR c++/120518
* omp-general.cc (omp_device_num_check): Look inside a
CLEANUP_POINT_EXPR when trying to optimize special cases.

2 months agolibstdc++: Make system_clock::to_time_t always_inline [PR99832]
Jonathan Wakely [Wed, 28 May 2025 14:19:18 +0000 (15:19 +0100)] 
libstdc++: Make system_clock::to_time_t always_inline [PR99832]

For some 32-bit targets Glibc supports changing the size of time_t to be
64 bits by defining _TIME_BITS=64. That causes an ABI change which
would affect std::chrono::system_clock::to_time_t. Because to_time_t is
not a function template, its mangled name does not depend on the return
type, so it has the same mangled name whether it returns a 32-bit time_t
or a 64-bit time_t. On targets where the size of time_t can be selected
at preprocessing time, that can cause ODR violations, e.g. the linker
selects a definition of to_time_t that returns a 32-bit value but a
caller expects 64-bit and so reads 32 bits of garbage from the stack.

This commit adds always_inline to to_time_t so that all callers inline
the conversion to time_t, and will do so using whatever type time_t
happens to be in that translation unit.

Existing objects compiled before this change will either have inlined
the function anyway (which is likely if compiled with any optimization
enabled) or will contain a COMDAT definition of the inline function and
so still be able to find it at link-time.

The attribute is also added to system_clock::from_time_t, because that's
an equally simple function and it seems reasonable for them to both be
always inlined.

libstdc++-v3/ChangeLog:

PR libstdc++/99832
* include/bits/chrono.h (system_clock::to_time_t): Add
always_inline attribute to be agnostic to the underlying type of
time_t.
(system_clock::from_time_t): Add always_inline for consistency
with to_time_t.
* testsuite/20_util/system_clock/99832.cc: New test.

2 months agolibstdc++: sstream from string_view (P2495R3) [PR119741]
Nathan Myers [Wed, 4 Jun 2025 18:52:29 +0000 (14:52 -0400)] 
libstdc++: sstream from string_view (P2495R3) [PR119741]

Add constructors to stringbuf, stringstream, istringstream, and ostringstream,
and a matching overload of str(sv) in each, that take anything convertible to
a string_view in places where the existing ctors and function take a string.
Note this change omits the constraint applied to the istringstream constructor
from string cited as a "drive-by" in P2495R3, as we have determined it is
redundant.

libstdc++-v3/ChangeLog:

PR libstdc++/119741
* include/std/sstream: full implementation, really just
decls, requires clause and plumbing.
* include/bits/version.def, include/bits/version.h:
new preprocessor symbol
__cpp_lib_sstream_from_string_view.
* testsuite/27_io/basic_stringbuf/cons/char/string_view.cc:
New tests.
* testsuite/27_io/basic_istringstream/cons/char/string_view.cc:
New tests.
* testsuite/27_io/basic_ostringstream/cons/char/string_view.cc:
New tests.
* testsuite/27_io/basic_stringstream/cons/char/string_view.cc:
New tests.
* testsuite/27_io/basic_stringbuf/cons/wchar_t/string_view.cc:
New tests.
* testsuite/27_io/basic_istringstream/cons/wchar_t/string_view.cc:
New tests.
* testsuite/27_io/basic_ostringstream/cons/wchar_t/string_view.cc:
New tests.
* testsuite/27_io/basic_stringstream/cons/wchar_t/string_view.cc:
New tests.

2 months agolibstdc++: Implement P0849R8 auto(x) library changes
Patrick Palka [Wed, 4 Jun 2025 18:55:40 +0000 (14:55 -0400)] 
libstdc++: Implement P0849R8 auto(x) library changes

This implements the library changes in P0849R8 "auto(x): decay-copy
in the language" which consist of replacing most uses of the
exposition-only function decay-copy with auto(x) throughout the library
wording.  We implement this as a DR against C++20 since there should be
no behavior change in practice (especially in light of LWG 3724 which
makes decay-copy SFINAE-friendly).

The main difference between decay-copy and auto(x) is that decay-copy
materializes its argument unlike auto(x), and so the latter is a no-op
when its argument is a prvalue.  Effectively the former could introduce
an unnecessary move constructor call in some contexts.  In C++20 and
earlier we could emulate auto(x) with decay_t<decltype((x))>(x).

After this paper the only remaining uses of decay-copy in the standard
are in the specification of some range adaptors.  In our implementation
of those range adaptors I believe decay-copy is already implied which is
why we don't use __decay_copy explicitly there.  So since it's apparently
no longer needed this patch goes ahead and removes __decay_copy.

libstdc++-v3/ChangeLog:

* include/bits/c++config (_GLIBCXX_AUTO_CAST): Define.
* include/bits/iterator_concepts.h (_Decay_copy, __decay_copy):
Remove.
(__member_begin, __adl_begin): Use _GLIBCXX_AUTO_CAST instead of
__decay_copy as per P0849R8.
* include/bits/ranges_base.h (_Begin): Likewise.
(__member_end, __adl_end, _End): Likewise.
(__member_rbegin, __adl_rbegin, _RBegin): Likewise.
(__member_rend, __adl_rend, _Rend): Likewise.
(__member_size, __adl_size, _Size): Likewise.
(_Data): Likewise.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2 months agoc++: constexpr prvalues vs genericize [PR120502]
Jason Merrill [Wed, 4 Jun 2025 17:31:02 +0000 (13:31 -0400)] 
c++: constexpr prvalues vs genericize [PR120502]

Here constexpr evaluation was getting confused by the result of
split_nonconstant_init, which leaves an INIT_EXPR from an empty CONSTRUCTOR
to be followed by member initialization.  As a result
CONSTRUCTOR_NO_CLEARING was set for the time_zone, and
cxx_eval_store_expression didn't set it again for the initial clobber in the
basic_string constructor, so when cxx_fold_indirect_ref wants to check
whether the anonymous union active member had type non_trivial_if, we see
that we don't currently have a value for the anonymous union, try to add
one, and fail.

So let's do constexpr evaluation before split_nonconstant_init.

PR c++/120502

gcc/cp/ChangeLog:

* cp-gimplify.cc (cp_fold_r) [TARGET_EXPR]: Do constexpr evaluation
before genericize.
* constexpr.cc (cxx_eval_store_expression): Add comment.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/constexpr-prvalue2.C: New test.

2 months agoAvoid SIGSEGV in nvptx 'mkoffload' for voluminous PTX code
Thomas Schwinge [Mon, 26 May 2025 11:31:54 +0000 (13:31 +0200)] 
Avoid SIGSEGV in nvptx 'mkoffload' for voluminous PTX code

In commit 50be486dff4ea2676ed022e9524ef190b92ae2b1
"nvptx: libgomp+mkoffload.cc: Prepare for reverse offload fn lookup", some
additional tracking of the PTX code was added, and this assumes that
potentially every single character of PTX code needs to be tracked as a new
chunk of PTX code.  That's problematic if we're dealing with voluminous PTX
code (for example, non-trivial C++ code), and the 'file_idx' 'alloca'tion then
causes stack overflow.  For example:

    FAIL: libgomp.c++/target-std__valarray-1.C (test for excess errors)
    UNRESOLVED: libgomp.c++/target-std__valarray-1.C compilation failed to produce executable

    lto-wrapper: fatal error: [...]/build-gcc/gcc//accel/nvptx-none/mkoffload terminated with signal 11 [Segmentation fault], core dumped

gcc/
* config/nvptx/mkoffload.cc (process): Use an 'auto_vec' for
'file_idx'.

2 months agogimple-fold: Implement simple copy propagation for aggregates [PR14295]
Andrew Pinski [Fri, 21 Feb 2025 06:05:38 +0000 (22:05 -0800)] 
gimple-fold: Implement simple copy propagation for aggregates [PR14295]

This implements a simple copy propagation for aggregates in the similar
fashion as we already do for copy prop of zeroing.

Right now this only looks at the previous vdef statement but this allows us
to catch a lot of cases that show up in C++ code.

This used to deleted aggregate copies that are to the same location (PR57361)
But that was found to delete statements that are needed for aliasing markers reason.
So we need to keep them around until that is solved. Note DSE will delete the statements
anyways so there is no testcase added since we expose the latent bug in the same way.
See https://gcc.gnu.org/pipermail/gcc-patches/2025-May/685003.html for the testcase and
explaintation there.

Also adds a variant of pr22237.c which was found while working on this patch.

Changes since v1:
* v2: change check for vuse to use default definition.
      Remove dest/src arguments for optimize_agr_copyprop
      Changed dump messages slightly.
      Added stats
      Don't delete `a = a` until aliasing markers are added.

PR tree-optimization/14295
PR tree-optimization/108358
PR tree-optimization/114169

gcc/ChangeLog:

* tree-ssa-forwprop.cc (optimize_agr_copyprop): New function.
(pass_forwprop::execute): Call optimize_agr_copyprop for load/store statements.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/20031106-6.c: Un-xfail. Add scan for forwprop1.
* g++.dg/opt/pr66119.C: Disable forwprop since that does
the copy prop now.
* gcc.dg/tree-ssa/pr108358-a.c: New test.
* gcc.dg/tree-ssa/pr114169-1.c: New test.
* gcc.c-torture/execute/builtins/pr22237-1-lib.c: New test.
* gcc.c-torture/execute/builtins/pr22237-1.c: New test.
* gcc.dg/tree-ssa/pr57361.c: Disable forwprop1.
* gcc.dg/tree-ssa/pr57361-1.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2 months agomatch.pd: Fold (x + y) >> 1 into IFN_AVG_FLOOR (x, y) for vectors
Pengfei Li [Wed, 4 Jun 2025 15:59:44 +0000 (16:59 +0100)] 
match.pd: Fold (x + y) >> 1 into IFN_AVG_FLOOR (x, y) for vectors

This patch folds vector expressions of the form (x + y) >> 1 into
IFN_AVG_FLOOR (x, y), reducing instruction count on platforms that
support averaging operations. For example, it can help improve the
codegen on AArch64 from:
        add     v0.4s, v0.4s, v31.4s
        ushr    v0.4s, v0.4s, 1
to:
        uhadd   v0.4s, v0.4s, v31.4s

As this folding is only valid when the most significant bit of each
element in both x and y is known to be zero, this patch checks leading
zero bits of elements in x and y, and extends get_nonzero_bits_1() to
handle uniform vectors. When the input is a uniform vector, the function
now returns the nonzero bits of its element.

Additionally, this patch adds more checks to reject vector types in bit
constant propagation (tree-bit-ccp), since tree-bit-ccp was designed for
scalar values only, and the new vector logic in get_non_zero_bits_1()
could lead to incorrect propagation results.

gcc/ChangeLog:

* match.pd: Add folding rule for vector average.
* tree-ssa-ccp.cc (get_default_value): Reject vector types.
(evaluate_stmt): Reject vector types.
* tree-ssanames.cc (get_nonzero_bits_1): Extend to handle
uniform vectors.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/acle/uhadd_1.c: New test.

2 months agocobol: Eliminate cppcheck warnings for libgcobol [PR119323]
Robert Dubner [Mon, 2 Jun 2025 22:40:28 +0000 (18:40 -0400)] 
cobol: Eliminate cppcheck warnings for libgcobol [PR119323]

I configured and ran cppcheck-2.17.0 with this config file:

<?xml version="1.0"?>
<def format="2">
  <define name="HOST_SIZE_T_PRINT_UNSIGNED" value="&quot;%ld&quot;"/>
  <define name="GCC_PRISZ" value="&quot;z&quot;"/>
  <define name="YYLTYPE" value="struct {int first_line; int first_column; int last_line; int last_column;}"/>
  <define name="__FLT128_MANT_DIG__" value="113"/>
  <define name="__FLT128_MIN_EXP__" value="-16381"/>
</def>

and this command line

cppcheck --inline-suppr --enable=all --force --language=c++ --library=$CFG \
--check-level=exhaustive \
--disable=unusedFunction \
--disable=missingInclude \
$(cat $FILES) > $RESULT 2>&1

$FILES was all of the .cc files in libgcobol.

The result was many hundreds of warnings.  The vast bulk of them were
recommendations for declaring variables as const, recommendations for
changing C-style casts to C++ casts, cheery notes about shadowed
variables, and complaints that malloc() results weren't being checked
for errors.

Two and a half days of applied OCD on my part has reduced the number of
warnings down to zero.

libgcobol/ChangeLog:

PR cobol/119323
* charmaps.cc (__gg__raw_to_ascii):  Eliminate cppcheck warnings.
(__gg__raw_to_ebcdic): Likewise.
(__gg__ebcdic_to_console): Likewise.
(__gg__console_to_ascii): Likewise.
(__gg__console_to_ebcdic): Likewise.
* common-defs.h (struct cbl_declarative_t): Likewise.
* gfileio.cc (get_filename): Likewise.
(max_value): Likewise.
(relative_file_delete_varying): Likewise.
(relative_file_delete): Likewise.
(read_an_indexed_record): Likewise.
(position_state_restore): Likewise.
(indexed_file_delete): Likewise.
(indexed_file_start): Likewise.
(sequential_file_rewrite): Likewise.
(relative_file_write_varying): Likewise.
(relative_file_write): Likewise.
(sequential_file_write): Likewise.
(indexed_file_write): Likewise.
(__io__file_write): Likewise.
(line_sequential_file_read): Likewise.
(indexed_file_read): Likewise.
(file_indexed_open): Likewise.
(__gg__file_reopen): Likewise.
* gmath.cc (conditional_stash): Likewise.
(__gg__pow): Likewise.
(multiply_int256_by_int64): Likewise.
(add_int256_to_int256): Likewise.
(divide_int256_by_int64): Likewise.
(squeeze_int256): Likewise.
(get_int256_from_qualified_field): Likewise.
(__gg__add_fixed_phase1): Likewise.
(__gg__addf1_fixed_phase2): Likewise.
(__gg__fixed_phase2_assign_to_c): Likewise.
(__gg__add_float_phase1): Likewise.
(__gg__addf1_float_phase2): Likewise.
(__gg__float_phase2_assign_to_c): Likewise.
(__gg__addf3): Likewise.
(__gg__subtractf1_fixed_phase2): Likewise.
(__gg__subtractf2_fixed_phase1): Likewise.
(__gg__subtractf1_float_phase2): Likewise.
(__gg__subtractf2_float_phase1): Likewise.
(__gg__subtractf3): Likewise.
(__gg__multiplyf1_phase1): Likewise.
(multiply_int128_by_int128): Likewise.
(__gg__multiplyf1_phase2): Likewise.
(__gg__multiplyf2): Likewise.
(shift_in_place128): Likewise.
(divide_int128_by_int128): Likewise.
(__gg__dividef1_phase2): Likewise.
(__gg__dividef23): Likewise.
(__gg__dividef45): Likewise.
* intrinsic.cc (struct input_state): Likewise.
(get_value_as_double_from_qualified_field): Likewise.
(kahan_summation): Likewise.
(variance): Likewise.
(get_all_time): Likewise.
(populate_ctm_from_date): Likewise.
(populate_ctm_from_time): Likewise.
(ftime_replace): Likewise.
(__gg__abs): Likewise.
(__gg__acos): Likewise.
(__gg__annuity): Likewise.
(__gg__asin): Likewise.
(__gg__atan): Likewise.
(__gg__byte_length): Likewise.
(__gg__char): Likewise.
(__gg__combined_datetime): Likewise.
(__gg__cos): Likewise.
(__gg__date_of_integer): Likewise.
(__gg__date_to_yyyymmdd): Likewise.
(__gg__day_of_integer): Likewise.
(__gg__day_to_yyyyddd): Likewise.
(__gg__exp): Likewise.
(__gg__exp10): Likewise.
(__gg__factorial): Likewise.
(__gg__formatted_current_date): Likewise.
(__gg__formatted_date): Likewise.
(__gg__formatted_datetime): Likewise.
(__gg__formatted_time): Likewise.
(__gg__integer): Likewise.
(__gg__integer_of_date): Likewise.
(__gg__integer_of_day): Likewise.
(__gg__integer_part): Likewise.
(__gg__fraction_part): Likewise.
(__gg__log): Likewise.
(__gg__log10): Likewise.
(__gg__max): Likewise.
(__gg__lower_case): Likewise.
(__gg__median): Likewise.
(__gg__min): Likewise.
(numval): Likewise.
(numval_c): Likewise.
(__gg__numval): Likewise.
(__gg__test_numval): Likewise.
(__gg__numval_c): Likewise.
(__gg__test_numval_c): Likewise.
(__gg__ord): Likewise.
(__gg__rem): Likewise.
(__gg__trim): Likewise.
(__gg__random): Likewise.
(__gg__reverse): Likewise.
(__gg__sign): Likewise.
(__gg__sin): Likewise.
(__gg__sqrt): Likewise.
(__gg__tan): Likewise.
(__gg__test_date_yyyymmdd): Likewise.
(__gg__test_day_yyyyddd): Likewise.
(__gg__upper_case): Likewise.
(__gg__year_to_yyyy): Likewise.
(gets_int): Likewise.
(gets_year): Likewise.
(gets_month): Likewise.
(gets_day): Likewise.
(gets_day_of_week): Likewise.
(gets_day_of_year): Likewise.
(gets_week): Likewise.
(gets_hours): Likewise.
(gets_minutes): Likewise.
(gets_seconds): Likewise.
(gets_nanoseconds): Likewise.
(fill_cobol_tm): Likewise.
(__gg__test_formatted_datetime): Likewise.
(__gg__integer_of_formatted_date): Likewise.
(__gg__seconds_from_formatted_time): Likewise.
(__gg__hex_of): Likewise.
(__gg__highest_algebraic): Likewise.
(__gg__lowest_algebraic): Likewise.
(floating_format_tester): Likewise.
(__gg__numval_f): Likewise.
(__gg__test_numval_f): Likewise.
(ismatch): Likewise.
(iscasematch): Likewise.
(strstr): Likewise.
(strcasestr): Likewise.
(strlaststr): Likewise.
(strcaselaststr): Likewise.
(__gg__substitute): Likewise.
(__gg__locale_compare): Likewise.
(__gg__locale_date): Likewise.
(__gg__locale_time): Likewise.
(__gg__locale_time_from_seconds): Likewise.
* libgcobol.cc (class ec_status_t): Likewise.
(__gg__set_truncation_mode): Likewise.
(malloc): Likewise.
(__gg__mabort): Likewise.
(__gg__resize_int_p): Likewise.
(__gg__resize_treeplet): Likewise.
(var_is_refmod): Likewise.
(value_is_too_big): Likewise.
(__gg__string_to_alpha_edited_ascii): Likewise.
(int128_to_field): Likewise.
(edited_to_binary): Likewise.
(get_binary_value_local): Likewise.
(__gg__get_date_yymmdd): Likewise.
(__gg__get_date_yyyymmdd): Likewise.
(__gg__get_date_yyddd): Likewise.
(__gg__get_yyyyddd): Likewise.
(__gg__get_date_dow): Likewise.
(get_scaled_rdigits): Likewise.
(format_for_display_internal): Likewise.
(compare_88): Likewise.
(get_float128): Likewise.
(compare_field_class): Likewise.
(compare_strings): Likewise.
(__gg__compare_2): Likewise.
(__gg__sort_table): Likewise.
(init_var_both): Likewise.
(alpha_to_alpha_move_from_location): Likewise.
(alpha_to_alpha_move): Likewise.
(__gg__move): Likewise.
(__gg__move_literala): Likewise.
(__gg__sort_workfile): Likewise.
(__gg__merge_files): Likewise.
(normalize_id): Likewise.
(inspect_backward_format_1): Likewise.
(__gg__inspect_format_1): Likewise.
(inspect_backward_format_2): Likewise.
(__gg__inspect_format_2): Likewise.
(__gg__inspect_format_4): Likewise.
(move_string): Likewise.
(__gg__string): Likewise.
(display_both): Likewise.
(__gg__display_string): Likewise.
(__gg__accept): Likewise.
(__gg__binary_value_from_qualified_field): Likewise.
(__gg__float128_from_qualified_field): Likewise.
(float128_to_int128): Likewise.
(float128_to_location): Likewise.
(__gg__set_initial_switch_value): Likewise.
(is_numeric_display_numeric): Likewise.
(is_packed_numeric): Likewise.
(is_alpha_a_number): Likewise.
(__gg__classify): Likewise.
(__gg__accept_envar): Likewise.
(__gg__set_envar): Likewise.
(command_line_plan_b): Likewise.
(__gg__get_command_line): Likewise.
(__gg__set_pointer): Likewise.
(__gg__ascii_to_internal_field): Likewise.
(__gg__internal_to_console_in_place): Likewise.
(__gg__routine_to_call): Likewise.
(__gg__fetch_call_by_value_value): Likewise.
(__gg__assign_value_from_stack): Likewise.
(__gg__literaln_alpha_compare): Likewise.
(string_in): Likewise.
(__gg__unstring): Likewise.
(local_ec_type_of): Likewise.
(struct exception_descr_t): Likewise.
(struct cbl_exception_t): Likewise.
(cbl_enabled_exception_t: Likewise.: Likewise.dump): Likewise.
(__gg__match_exception): Likewise.
(__gg__float128_from_location): Likewise.
(__gg__integer_from_float128): Likewise.
(__gg__set_exception_file): Likewise.
(__gg__func_exception_file): Likewise.
(__gg__set_exception_code): Likewise.
(__gg__is_float_infinite): Likewise.
(__gg__float32_from_128): Likewise.
(__gg__float32_from_64): Likewise.
(__gg__float64_from_128): Likewise.
(__gg__copy_as_big_endian): Likewise.
(__gg__get_figconst_data): Likewise.
(find_in_dirs): Likewise.
(__gg__function_handle_from_cobpath): Likewise.
(__gg__just_mangle_name): Likewise.
(__gg__function_handle_from_literal): Likewise.
(__gg__function_handle_from_name): Likewise.
(__gg__mirror_range): Likewise.
(__gg__deallocate): Likewise.
(__gg__allocate): Likewise.
(__gg__module_name): Likewise.
(__gg__set_env_name): Likewise.
(__gg__set_env_value): Likewise.
* libgcobol.h (__gg__mabort): Likewise.
(massert): Likewise.
(PTRCAST): Likewise.
(__gg__float128_from_location): Likewise.
(__gg__set_exception_file): Likewise.
(__gg__binary_value_from_qualified_field): Likewise.
(__gg__float128_from_qualified_field): Likewise.
* valconv.cc (__gg__realloc_if_necessary): Likewise.
(__gg__alphabet_create): Likewise.
(__gg__string_to_numeric_edited): Likewise.
(__gg__string_to_alpha_edited): Likewise.
* valconv.h: Likewise.

2 months agoext-dce: Don't refine live width with SUBREG mode if !TRULY_NOOP_TRUNCATION_MODES_P...
Xi Ruoyao [Sun, 11 May 2025 08:44:31 +0000 (16:44 +0800)] 
ext-dce: Don't refine live width with SUBREG mode if !TRULY_NOOP_TRUNCATION_MODES_P [PR 120050]

If we see a promoted subreg and TRULY_NOOP_TRUNCATION says the
truncation is not a noop, then all bits of the inner reg are live.  We
cannot reduce the live mask to that of the mode of the subreg.

gcc/ChangeLog:

PR rtl-optimization/120050
* ext-dce.cc (ext_dce_process_uses): Break early if a SUBREG in
rhs is promoted and the truncation from the inner mode to the
outer mode is not a noop when handling SETs.

2 months agoranger: Some parameter formatting fixes
Jakub Jelinek [Wed, 4 Jun 2025 15:22:58 +0000 (17:22 +0200)] 
ranger: Some parameter formatting fixes

When reading the code, I've noticed various function definitions
with misaligned parameters, they should IMHO always align below the first
character after opening ( and in most cases they do, but in some
cases they were indented more or less.  Perhaps the functions changed
name or something.

2025-06-04  Jakub Jelinek  <jakub@redhat.com>

* range-op-float.cc (range_operator::fold_range,
range_operator::op1_range, range_operator::op2_range,
range_operator::lhs_op1_relation, range_operator::lhs_op2_relation,
operator_equal::op1_range, foperator_unordered_gt::op1_range): Fix
up parameter indentation.
* range-op.cc (range_operator::fold_range, range_operator::op1_range,
range_operator::op1_op2_relation_effect,
range_operator::update_bitmask, plus_minus_ranges,
operator_bitwise_and::lhs_op1_relation): Likewise.

2 months agoranger: Add support for float <-> float casts [PR120231]
Jakub Jelinek [Wed, 4 Jun 2025 15:21:51 +0000 (17:21 +0200)] 
ranger: Add support for float <-> float casts [PR120231]

I've noticed we don't even support say float -> double and other
scalar floating point to scalar floating point conversions in the
ranger, we just end up with VARYING for those.

The following patch attempts to fix that.
The reverse cast case uses float_binary_op_range_finish e.g. because
if the result isn't infinite, then the source couldn't be infinite
either even if the reverse fold_range would suggest that.
And special cases the case of guaranteed widening cast (where
we have assurance that all the source type values are exactly
representable in the destination type; using ieee_bits for that).

2025-06-04  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/120231
* range-op-mixed.h (operator_cast::fold_range): Add overload
with 3 {,const} frange & operands.  Change parameter names and
add final override keywords for float <-> integer cast overloads.
(operator_cast::op1_range): Likewise.
* range-op-float.cc (operator_cast::fold_range): New overload
with 3 {,const} frange & operands.
(operator_cast::op1_range): Likewise.

* gcc.dg/tree-ssa/pr120231-1.c: New test.

2 months agolibstdc++: Test for formatting with empty spec for time points.
Tomasz Kamiński [Tue, 3 Jun 2025 09:40:17 +0000 (11:40 +0200)] 
libstdc++: Test for formatting with empty spec for time points.

Adding a tests for behavior of the ostream operator and the formatting
with empty chrono-spec for the chrono types. Current coverage is:
 * time point, zoned_time and local_time_format in this commit,
 * duration and hh_mm_ss in r16-1099-gac0a04b7a254fb,
 * calendar types in r16-1016-g28a17985dd34b7.

libstdc++-v3/ChangeLog:

* testsuite/std/time/format/empty_spec.cc: New tests.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 months agolibstdc++: Implement C++23 P1659R3 starts_with and ends_with
Patrick Palka [Wed, 4 Jun 2025 14:29:47 +0000 (10:29 -0400)] 
libstdc++: Implement C++23 P1659R3 starts_with and ends_with

This implements ranges::starts_with and ranges::ends_with from the C++23
paper P1659R3.  The corresponding_S_impl member functions take optional
optional size parameters __n1 and __n2 of the two ranges, where -1 means
the corresponding size is not known.

libstdc++-v3/ChangeLog:

* include/bits/ranges_algo.h (__starts_with_fn, starts_with):
Define.
(__ends_with_fn, ends_with): Define.
* include/bits/version.def (ranges_starts_ends_with): Define.
* include/bits/version.h: Regenerate.
* include/std/algorithm: Provide __cpp_lib_ranges_starts_ends_with.
* src/c++23/std.cc.in (ranges::starts_with): Export.
(ranges::ends_with): Export.
* testsuite/25_algorithms/ends_with/1.cc: New test.
* testsuite/25_algorithms/starts_with/1.cc: New test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2 months ago[PATCH] RISC-V: Imply zicsr for svade and svadu extensions.
Dongyan Chen [Wed, 4 Jun 2025 14:03:31 +0000 (08:03 -0600)] 
[PATCH] RISC-V: Imply zicsr for svade and svadu extensions.

This patch implies zicsr for svade and svadu extensions.
According to the riscv-privileged spec, the svade and svadu extensions
are privileged instructions, so they should imply zicsr.

gcc/ChangeLog:

* config/riscv/riscv-ext.def: Imply zicsr.

2 months ago[PATCH v2] RISC-V: Add svbare extension.
Dongyan Chen [Wed, 4 Jun 2025 13:57:01 +0000 (07:57 -0600)] 
[PATCH v2] RISC-V: Add svbare extension.

This patch support svbare extension, which is an extension in RVA23 profile.
To enable GCC to recognize and process svbare extension correctly at compile time.

gcc/ChangeLog:

* config/riscv/riscv-ext.def: New extension defs.
* config/riscv/riscv-ext.opt: Ditto.
* doc/riscv-ext.texi: Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/arch-60.c: New test.

2 months agolibstdc++: Refactor __semaphore_base member functions
Jonathan Wakely [Mon, 2 Jun 2025 22:01:40 +0000 (23:01 +0100)] 
libstdc++: Refactor __semaphore_base member functions

Replace the _S_get_current and _S_do_try_acquire static member functions
with non-static member functions _M_get_current and _M_do_try_acquire.
This means they don't need the address of _M_counter passed in.

libstdc++-v3/ChangeLog:

* include/bits/semaphore_base.h (_S_get_current): Replace with
non-static _M_get_current.
(_S_do_try_acquire): Replace with non-static _M_do_try_acquire.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 months agolibstdc++: Fix std::counting_semaphore::acquire deadlock [PR104928]
Jonathan Wakely [Mon, 2 Jun 2025 12:06:27 +0000 (13:06 +0100)] 
libstdc++: Fix std::counting_semaphore::acquire deadlock [PR104928]

There's a deadlock in std::counting_semaphore that occurs when the
semaphore is under contention. The bug happens when one thread tries to
acquire the mutex, calling __semaphore_base::_S_do_try_acquire to
atomically decrement the counter using compare_exchange_strong. If the
counter is non-zero (and so should be possible to decrement) but another
thread changes it (either incrementing or decrementing it) then the
compare_exchange fails and _S_do_try_acquire returns false. Because that
function is used by the predicate passed to __atomic_wait_address, when
it returns false the thread does a futex wait until the value changes.
However, when the predicate is false because the compare_exchange failed
due to not matching the expected value, waiting for the value to change
is incorrect. The correct behaviour would be to retry the
compare_exchange using the new value (as long as it's still non-zero).
Waiting for the value to change again means we can block forever,
because it might never change again.

The predicate should only test the value, not also attempt to alter it,
and its return value should mean only one thing, not conflate a busy
semaphore that cannot be acquired with a contended one that can be
acquired by retrying.

The correct behaviour of __semaphore_base::_M_acquire would be to
attempt the decrement, and to retry immediately if it failed due to
contention on the variable (i.e. due to the variable not having the
expected value).  It should only wait for the value to change when the
value is zero, because that's the only time we can't decrement it.

This commit moves the _S_do_try_acquire call out of the predicate and
loops while it is false, only doing an atomic wait when the counter's
value is zero. The predicate used for the atomic wait now only checks
whether the value is decrementable (non-zero), without also trying to
perform that decrement.

In order for the caller to tell whether it should retry a failed
_S_do_try_acquire or should wait for the value to be non-zero, the value
obtained by a failed compare_exchange needs to be passed back to the
caller. _S_do_try_acquire is changed to take its parameter by reference,
so that the caller gets the new value and can check whether it's zero.

In order to avoid doing another atomic load after returning from an
atomic wait, the predicate is also changed to capture the local __val by
reference, and then assign to __val when it sees a non-zero value. That
makes the new value available to _M_acquire, so it can be passed to
_S_do_try_acquire as the expected value of the compare_exchange.
Although this means that the predicate is modifying data again, not just
checking a value, this modification is safe. It's not changing the
semaphore's counter, only changing a local variable in the caller to
avoid a redundant atomic load.

Equivalent changes are made to _M_try_acquire_until and
_M_try_acquire_for. They have the same bug, although they can escape the
deadlock if the wait is interrupted by timing out. For _M_acquire
there's no time out so it potentially waits forever.

_M_try_acquire also has the same bug, but can be simplified to just
calling _M_try_acquire_for(0ns). A timeout of zero results in calling
__wait_impl with the __spin_only flag set, so that the value is loaded
and checked in a spin loop but there is no futex wait. This means that
_M_try_acquire can still succeed under light contention if the counter
is being changed concurrently, at the cost of a little extra overhead.
It would be possible to implement _M_try_acquire as nothing more than an
atomic load and a compare_exchange, but it would fail when there is any
contention.

libstdc++-v3/ChangeLog:

PR libstdc++/104928
* include/bits/semaphore_base.h (_S_do_try_acquire): Take old
value by reference.
(_M_acquire): Move _S_do_try_acquire call out of the predicate
and loop on its result. Make the predicate capture and update
the local copy of the value.
(_M_try_acquire_until, _M_try_acquire_for): Likewise.
(_M_try_acquire): Just call _M_try_acquire_for.
* testsuite/30_threads/semaphore/104928-2.cc: New test.
* testsuite/30_threads/semaphore/104928.cc: New test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 months agoemit-rtl: Tweak validate_subreg ordered_p condition [PR120447]
Richard Sandiford [Wed, 4 Jun 2025 12:36:51 +0000 (13:36 +0100)] 
emit-rtl: Tweak validate_subreg ordered_p condition [PR120447]

In the comment trail for PR119966, I'd said that the validate_subreg
condition:

  /* The outer size must be ordered wrt the register size, otherwise
     we wouldn't know at compile time how many registers the outer
     mode occupies.  */
  if (!ordered_p (osize, regsize))
    return false;

"is also potentially relevant" for paradoxical subregs.  But I'd
forgotten an important caveat.  If the inner size is smaller than
a register, we know that the inner value will only occupy a single
register.  Although the paradoxical subreg might extend that single
register to multiple registers by padding with undefined bits,
the register size that matters for the extension is:

   REGMODE_NATURAL_SIZE (omode)

rather than regsize's:

   REGMODE_NATURAL_SIZE (imode)

The ordered check is still relevant if the inner value spans
multiple registers.

Enabling the check above for paradoxical subregs led to an ICE in the
testcase, where we tried to generate a VNx4QI paradoxical subreg of a
QI scalar.  This was previously allowed, and AFAIK worked correctly.

The patch doesn't have the effect of relaxing the condition for
non-paradoxical subregs, since:

  known_le (osize, isize) && known_le (isize, regsize)
    => known_le (osize, regsize)
    => ordered_p (osize, regsize)

So even before the patch for PR119966, the condition only existed for
the maybe_gt (isize, regsize) case.

The term "block" used in the comment is taken from the rtl.texi
documentation of subregs.

gcc/
PR rtl-optimization/120447
* emit-rtl.cc (validate_subreg): Restrict ordered_p test
between osize and regsize to cases where the inner value
occupies multiple blocks.

gcc/testsuite/
PR rtl-optimization/120447
* gcc.dg/pr120447.c: New test.

2 months agolibgomp.texi (omp_interop_*): Add note about 5.2-to-6.0 incompatibility
Tobias Burnus [Wed, 4 Jun 2025 11:25:05 +0000 (13:25 +0200)] 
libgomp.texi (omp_interop_*): Add note about 5.2-to-6.0 incompatibility

GCC uses the 6.0 types - which are unfortunately not quite compatible with
code expecting 5.1/5.2 data types.  Therefore, this commit adds a note to
hopefully reduce surprises. Namely:

For C/C++: while OpenMP 5.1 and 5.2 used 'int *ret_code', OpenMP 6.0 uses
'omp_interop_rc_t *ret_code' in omp_interop_{int,ptr,str} and 'int' instead
of 'omp_interop_rc_t ret_code' in omp_get_interop_rc_desc.

Neither C nor C++ like passing the wrong pointer type, albeit for C, GCC < 14
and clang only warn (gcc >= r14-6037-g9715c545d33b3a has an error) and
using -fpermissive turns it into a warning and -Wno-incompatible-pointer-types
silences it for C.

C++ also dislikes passing an int to an enum, albeit -fpermissive turns the
error into a warning with g++ (but not clang++). And, here, using an enum
on the caller side works with both int and enum on the callee side.

libgomp/ChangeLog:

* libgomp.texi (omp_interop_{int,ptr,str,rc_desc}): Add note about
the 'ret_code' type change in OpenMP 6.

Co-authored-by: Sandra Loosemore <sloosemore@baylibre.com>
2 months agolibstdc++: Fix format call and test formatting with empty specs for durations.
Tomasz Kamiński [Wed, 4 Jun 2025 09:05:11 +0000 (11:05 +0200)] 
libstdc++: Fix format call and test formatting with empty specs for durations.

This patches fixes an obvious error, where the output iterator argument was
missing for call to format_to, when duration with custom representation types
are used.

It's also adding the test for behavior of ostream operator and the formatting
with empty chron-spec for the chrono types. Current coverage is:
 * duration and hh_mm_ss in this commit,
 * calendar types in r16-1016-g28a17985dd34b7.

libstdc++-v3/ChangeLog:

* include/bits/chrono_io.h (__formatter_chrono:_M_s): Add missing
__out argument to format_to call.
* testsuite/std/time/format/empty_spec.cc: New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 months agoRISC-V: Leverage get_vector_binary_rtx_cost to avoid code dup [NFC]
Pan Li [Wed, 4 Jun 2025 03:06:52 +0000 (11:06 +0800)] 
RISC-V: Leverage get_vector_binary_rtx_cost to avoid code dup [NFC]

Some similar code could be wrapped to func get_vector_binary_rtx_cost,
thus leverage this function to avoid code duplication.

The below test suites are passed for this patch series.
* The rv64gcv fully regression test.

gcc/ChangeLog:

* config/riscv/riscv.cc (get_vector_binary_rtx_cost): Rename
the args to scalar2vr.
(riscv_rtx_costs): Leverage above func to avoid code dup.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 months agoUse MEM_EXPR only if MEM_P is true
H.J. Lu [Wed, 4 Jun 2025 00:48:40 +0000 (08:48 +0800)] 
Use MEM_EXPR only if MEM_P is true

On s390x, for input:

(call_insn/u 7 6 11 2 (parallel [
            (set (reg:SI 2 %r2)
                (call (subreg:QI (symbol_ref:SI ("__tls_get_offset") [flags 0x1]) 3)
                    (const_int 0 [0])))
            (clobber (reg:SI 14 %r14))
            (use (unspec:SI [
                        (const_int 0 [0])
                    ] UNSPEC_TLSLDM))
        ]) "/tmp/foo.c":12:26 2602 {*brasl_tls}
     (expr_list:REG_EH_REGION (const_int -2147483648 [0xffffffff80000000])
        (nil))
    (expr_list (use (reg:SI 2 %r2))
        (expr_list (use (reg:SI 12 %r12))
            (nil))))

after r16-1041-g2da641d0170090, get_call_rtx_from returns:

(call (subreg:QI (symbol_ref:SI ("__tls_get_offset") [flags 0x1]) 3)
    (const_int 0 [0]))

and we got

Program received signal SIGSEGV, Segmentation fault.
0x000000000131174f in prepare_call_arguments (
    bb=<basic_block 0x7fffe99dfba0 (2)>, insn=0x7fffe980cc60)
    at /export/gnu/import/git/sources/gcc/gcc/var-tracking.cc:6277
6277 fndecl = MEM_EXPR (XEXP (call, 0));
(gdb) bt
    bb=<basic_block 0x7fffe99dfba0 (2)>, insn=0x7fffe980cc60)
    at /export/gnu/import/git/sources/gcc/gcc/var-tracking.cc:6277
    at /export/gnu/import/git/sources/gcc/gcc/var-tracking.cc:10297
    at /export/gnu/import/git/sources/gcc/gcc/var-tracking.cc:10526
    at /export/gnu/import/git/sources/gcc/gcc/var-tracking.cc:10579
    at /export/gnu/import/git/sources/gcc/gcc/var-tracking.cc:10616

Update prepare_call_arguments to check MEM_P before using MEM_EXPR.

gcc/

PR debug/120525
* var-tracking.cc (prepare_call_arguments): Use MEM_EXPR only
if MEM_P is true.

gcc/testsuite/

PR debug/120525
* gcc.dg/pr120525.c: New test.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2 months agoFortran: Fix missing substring ref for allocatable saved vars [PR120483]
Andre Vehreschild [Mon, 2 Jun 2025 08:41:48 +0000 (10:41 +0200)] 
Fortran: Fix missing substring ref for allocatable saved vars [PR120483]

Compute a substring ref on an allocatable static character array
using pointer arithmetic.  Using an array type corrupts type
layouting and crashes omp generation.

PR fortran/120483

gcc/fortran/ChangeLog:

* trans-expr.cc (gfc_conv_substring): Use pointer arithmetic on
static allocatable char arrays.

gcc/testsuite/ChangeLog:

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

2 months agoRISC-V: Add Shlcofideleg extension.
Jiawei [Tue, 27 May 2025 06:37:03 +0000 (14:37 +0800)] 
RISC-V: Add Shlcofideleg extension.

This patch add the RISC-V Shlcofideleg extension. It supports delegating
LCOFI interrupts(the count-overflow interrupts) to VS-mode.[1]

[1] https://riscv.github.io/riscv-isa-manual/snapshot/privileged

gcc/ChangeLog:

* config/riscv/riscv-ext.def: New extension defs.
* config/riscv/riscv-ext.opt: Ditto.
* doc/riscv-ext.texi: Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/arch-shlocofideleg.c: New test.

Signed-off-by: Jiawei <jiawei@iscas.ac.cn>
2 months agoi386: Add more peephole2 for APX NDD
Hu, Lin1 [Mon, 10 Mar 2025 08:52:22 +0000 (16:52 +0800)] 
i386: Add more peephole2 for APX NDD

The patch aims to optimize
         movb    (%rdi), %al
         movq    %rdi, %rbx
         xorl    %esi, %eax, %edx
         movb    %dl, (%rdi)
         cmpb    %sil, %al
 jne
to
         xorb    %sil, (%rdi)
         movq    %rdi, %rbx
 jne

Reduce 2 mov and 1 cmp instructions.

Due to APX NDD allowing the dest register and source register to be different,
some original peephole2 are invalid. Add new peephole2 patterns for APX NDD.

gcc/ChangeLog:

* config/i386/i386.md (define_peephole2): Define some new peephole2 for
APX NDD.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr49095-2.c: New test.

2 months agoi386: Add more forms peephole2 for adc/sbb
Hu, Lin1 [Wed, 19 Feb 2025 07:51:40 +0000 (15:51 +0800)] 
i386: Add more forms peephole2 for adc/sbb

Enable -mapxf will change some patterns about adc/sbb.

Hence gcc will raise an extra mov like
         movq    8(%rdi), %rax
         adcq    %rax, 8(%rsi), %rax
         movq    %rax, 8(%rdi)
rather than
         movq    8(%rsi), %rax
         adcq    %rax, 8(%rdi)

The patch add more kinds of peephole2 to eliminate the extra mov.

gcc/ChangeLog:

* config/i386/i386.md: Add 4 new peephole2 by swap the original
peephole2's operands' order to support new pattern.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr79173-13.c: New test.
* gcc.target/i386/pr79173-14.c: Ditto.
* gcc.target/i386/pr79173-15.c: Ditto.
* gcc.target/i386/pr79173-16.c: Ditto.
* gcc.target/i386/pr79173-17.c: Ditto.
* gcc.target/i386/pr79173-18.c: Ditto.

2 months agoAlways add REG_CALL_DECL note for CALL
H.J. Lu [Mon, 2 Jun 2025 21:56:37 +0000 (05:56 +0800)] 
Always add REG_CALL_DECL note for CALL

Always add REG_CALL_DECL note for CALL so that get_call_fndecl works
without -fipa-ra.

PR other/120494
* calls.cc (expand_call): Always add REG_CALL_DECL note.
(emit_library_call_value_1): Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2 months agoDaily bump.
GCC Administrator [Wed, 4 Jun 2025 00:18:13 +0000 (00:18 +0000)] 
Daily bump.

2 months agoFortran: ICE due to missing locus with data statement for coarray [PR99838]
Harald Anlauf [Tue, 3 Jun 2025 18:48:31 +0000 (20:48 +0200)] 
Fortran: ICE due to missing locus with data statement for coarray [PR99838]

PR fortran/99838

gcc/fortran/ChangeLog:

* data.cc (gfc_assign_data_value): For a new initializer use the
location from the constructor as fallback.

gcc/testsuite/ChangeLog:

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

2 months agoc: Enable -Wjump-misses-init for -Wc++-compat [PR120078]
Martin Uecker [Mon, 2 Jun 2025 11:57:03 +0000 (13:57 +0200)] 
c: Enable -Wjump-misses-init for -Wc++-compat [PR120078]

Fix a typo that prevented the warning from being activated with -Wc++compat.

PR c/120078

gcc/c-family/ChangeLog:
* c.opt (Wjump-misses-init): Fix typo.

gcc/testsuite/ChangeLog:
* gcc.dg/Wjump-misses-init-3.c: New test.

2 months agoc: Move checking assertions from recursion when forming composite types to avoid...
Martin Uecker [Sun, 1 Jun 2025 18:34:52 +0000 (20:34 +0200)] 
c: Move checking assertions from recursion when forming composite types to avoid ICE.

The checking assertion in composite_type_internal for structures and unions may
fail if there are self-referential types.  To avoid this, we move them out of
the recursion.  This should also be more efficient and covers other types.
We have to ignore some cases where we form composite types with qualifiers
not matching (PR120510).

gcc/c/ChangeLog:
* c-typeck.cc (composite_type_internal,composite_type): Move
checking assertions.

gcc/testsuite/ChangeLog:
* gcc.dg/gnu23-tag-composite-6.c: Update.

2 months agoc: fix ICE with enum completed with packed attribute after forward decl [PR116892]
Martin Uecker [Sun, 1 Jun 2025 20:30:42 +0000 (22:30 +0200)] 
c: fix ICE with enum completed with packed attribute after forward decl [PR116892]

After forward declaration of an enum and when completing it with the
attribute packed, we need to propagate TYPE_PACKED to all main variants.

PR c/116892

gcc/c/ChangeLog:
* c-decl.cc (finish_enum): Propagate TYPE_PACKED.

gcc/testsuite/ChangeLog:
* gcc.dg/pr116892.c: New test.

2 months agoc++: add -fno-modules to some tests
Jason Merrill [Thu, 21 Nov 2024 19:43:17 +0000 (20:43 +0100)] 
c++: add -fno-modules to some tests

These tests in the modules/ directory specifically want to test
behavior without modules enabled, so let's make that explicit.

gcc/testsuite/ChangeLog:

* g++.dg/modules/cpp-1.C
* g++.dg/modules/cpp-3.C
* g++.dg/modules/cpp-4.C: Specify -fno-modules.

2 months agoImprove create_tmp_reg_or_ssa_name, always create SSA name
Richard Biener [Tue, 3 Jun 2025 13:02:16 +0000 (15:02 +0200)] 
Improve create_tmp_reg_or_ssa_name, always create SSA name

In GIMPLE we can always use SSA names, so do that as it is cheaper.

* gimple-fold.cc (create_tmp_reg_or_ssa_name): Always
create a SSA name.

2 months agoc++: add operator| for WMB_Flags
Jason Merrill [Sat, 24 May 2025 18:41:43 +0000 (14:41 -0400)] 
c++: add operator| for WMB_Flags

There are a lot of uses of | on WMB_Flags, that currently need to then be
cast back to WMB_Flags.  Let's avoid the need for that.

gcc/cp/ChangeLog:

* name-lookup.h (operator|, operator|=): Define for WMB_Flags.

2 months agoRISC-V: Reconcile the existing test for vdiv.vx combine
Pan Li [Mon, 2 Jun 2025 13:21:18 +0000 (21:21 +0800)] 
RISC-V: Reconcile the existing test for vdiv.vx combine

Some existing vdiv related test need some adjust for the
asm check.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/binop/vdiv-rv32gcv-nofm.c: Adjust
the asm check for vdiv.
* gcc.target/riscv/rvv/autovec/binop/vdiv-rv32gcv.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vdiv-rv64gcv-nofm.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vdiv-rv64gcv.c: Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 months agoRISC-V: Add test for vec_duplicate + vdiv.vv combine case 1 with GR2VR cost 0, 1...
Pan Li [Mon, 2 Jun 2025 09:03:02 +0000 (17:03 +0800)] 
RISC-V: Add test for vec_duplicate + vdiv.vv combine case 1 with GR2VR cost 0, 1 and 2

Add asm dump check test for vec_duplicate + vdiv.vv combine to vdiv.vx,
with the GR2VR cost is 0, 1 and 2.

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

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vx_vf/vx-4-i16.c: Add asm check
check for vdiv.vx combine.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-4-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-4-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-4-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-5-i16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-5-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-5-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-5-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-6-i16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-6-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-6-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-6-i8.c: Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 months agoRISC-V: Add test for vec_duplicate + vdiv.vv combine case 0 with GR2VR cost 0, 2...
Pan Li [Mon, 2 Jun 2025 09:01:27 +0000 (17:01 +0800)] 
RISC-V: Add test for vec_duplicate + vdiv.vv combine case 0 with GR2VR cost 0, 2 and 15

Add asm dump check test for vec_duplicate + vdiv.vv combine to vdiv.vx,
with the GR2VR cost is 0, 2 and 15.

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

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-i16.c: Add asm check
for vdiv.vx combine.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-i16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-i16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_binary_data.h: Add test
data for vdiv run test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vdiv-run-1-i16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vdiv-run-1-i32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vdiv-run-1-i64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vdiv-run-1-i8.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 months agoRISC-V: Combine vec_duplicate + vidv.vv to vdiv.vx on GR2VR cost
Pan Li [Mon, 2 Jun 2025 08:56:59 +0000 (16:56 +0800)] 
RISC-V: Combine vec_duplicate + vidv.vv to vdiv.vx on GR2VR cost

This patch would like to combine the vec_duplicate + vdiv.vv to the
vdiv.vx.  From example as below code.  The related pattern will depend
on the cost of vec_duplicate from GR2VR.  Then the late-combine will
take action if the cost of GR2VR is zero, and reject the combination
if the GR2VR cost is greater than zero.

Assume we have example code like below, GR2VR cost is 0.

  #define DEF_VX_BINARY(T, OP)                                        \
  void                                                                \
  test_vx_binary (T * restrict out, T * restrict in, T x, unsigned n) \
  {                                                                   \
    for (unsigned i = 0; i < n; i++)                                  \
      out[i] = in[i] OP x;                                            \
  }

  DEF_VX_BINARY(int32_t, /)

Before this patch:
  10   │ test_vx_binary_or_int32_t_case_0:
  11   │     beq a3,zero,.L8
  12   │     vsetvli a5,zero,e32,m1,ta,ma
  13   │     vmv.v.x v2,a2
  14   │     slli    a3,a3,32
  15   │     srli    a3,a3,32
  16   │ .L3:
  17   │     vsetvli a5,a3,e32,m1,ta,ma
  18   │     vle32.v v1,0(a1)
  19   │     slli    a4,a5,2
  20   │     sub a3,a3,a5
  21   │     add a1,a1,a4
  22   │     vdiv.vv v1,v1,v2
  23   │     vse32.v v1,0(a0)
  24   │     add a0,a0,a4
  25   │     bne a3,zero,.L3

After this patch:
  10   │ test_vx_binary_or_int32_t_case_0:
  11   │     beq a3,zero,.L8
  12   │     slli    a3,a3,32
  13   │     srli    a3,a3,32
  14   │ .L3:
  15   │     vsetvli a5,a3,e32,m1,ta,ma
  16   │     vle32.v v1,0(a1)
  17   │     slli    a4,a5,2
  18   │     sub a3,a3,a5
  19   │     add a1,a1,a4
  20   │     vdiv.vx v1,v1,a2
  21   │     vse32.v v1,0(a0)
  22   │     add a0,a0,a4
  23   │     bne a3,zero,.L3

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

gcc/ChangeLog:

* config/riscv/riscv-v.cc (expand_vx_binary_vec_vec_dup): Add new
case for DIV op.
* config/riscv/riscv.cc (get_vector_binary_rtx_cost): Add new func
to get the cost of vector binary.
(riscv_rtx_costs): Add div rtx match and leverage above wrap to
get cost.
* config/riscv/vector-iterators.md: Add new op div to no_shift_vx_op.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 months agotree-optimization/120517 - fix dataref group split math
Richard Biener [Tue, 3 Jun 2025 12:09:22 +0000 (14:09 +0200)] 
tree-optimization/120517 - fix dataref group split math

DR_INIT is already measured in bytes, so there's no need to multiply
the DR_INIT difference of two DRs by the size of one of the DRs when
comparing that difference against MAX_BITSIZE_MODE_ANY_MODE.

PR tree-optimization/120517
* tree-vect-data-refs.cc (vect_analyze_data_ref_accesses):
Fix math in dataref group split.

2 months agolibstdc++: Check feature test macro for jthread in <stop_token>
Jonathan Wakely [Mon, 2 Jun 2025 22:25:43 +0000 (23:25 +0100)] 
libstdc++: Check feature test macro for jthread in <stop_token>

Check the appropriate feature test macro instead of checking that
__cplusplus >= 201703L.

libstdc++-v3/ChangeLog:

* include/std/stop_token: Check __glibcxx_jthread instead of
__cplusplus.

2 months agolibstdc++: Use new __is_destructible built-in in <type_traits>
Jonathan Wakely [Thu, 29 May 2025 12:50:08 +0000 (13:50 +0100)] 
libstdc++: Use new __is_destructible built-in in <type_traits>

libstdc++-v3/ChangeLog:

* include/std/type_traits (is_destructible, is_destructible_v):
Define using new built-in.
(is_nothrow_destructible, is_nothrow_destructible_v): Likewise.
(is_trivially_destructible, is_trivially_destructible_v):
Likewise.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 months agolibstdc++: Fix errors and incorrect returns in atomic timed waits
Jonathan Wakely [Mon, 2 Jun 2025 10:24:32 +0000 (11:24 +0100)] 
libstdc++: Fix errors and incorrect returns in atomic timed waits

The __detail::__wait_until function has a comment that should have been
removed when r16-1000-g225622398a9631 changed the return type from a
std::pair to a struct with three members.

The __atomic_wait_address_until_v and __atomic_wait_address_for_v
function templates are apparently never used or instantiated, because
they don't compile. This fixes them, but they're still unused.  I plan
to make use of them in a later commit.

In __atomic_wait_address_until_v, __res.first in the return statement
should have also been changed when r16-1000-g225622398a9631 changed
__wait_result_type, and &__args should have been changed to just __args
by r16-988-g219bb905a60d95.

In __atomic_wait_address_for_v, the parameter is a copy & paste error
and should use chrono::duration not chrono::time_point

Fix _M_spin_until_impl so that the _M_has_val member of the result is
accurate.  If the deadline has passed then it never enters the loop and
so never loads a fresh value, so _M_has_val should be false.  There's
also a redundant clock::now() call in __spin_until_impl which can be
removed, we can reuse the call immediately before it.

libstdc++-v3/ChangeLog:

* include/bits/atomic_timed_wait.h (__detail::__wait_until):
Remove incorrect comment.
(__atomic_wait_address_until_v): Do not take address of __args in
call to __detail::__wait_until. Fix return statement to refer to
member of __wait_result_type.
(__atomic_wait_address_for_v): Change parameter type from
time_point to duration.
* src/c++20/atomic.cc (__spin_until_impl): Fix incorrect
return value. Reuse result of first call to clock.

2 months agolibstdc++: Replace some implicit conversions in std::vector
Jonathan Wakely [Thu, 29 May 2025 10:40:59 +0000 (11:40 +0100)] 
libstdc++: Replace some implicit conversions in std::vector

This replaces two implicit conversions from ptrdiff_t to size_t with
explicit conversions that include unreachable hints for the ptrdiff_t
value not being negative.

libstdc++-v3/ChangeLog:

* include/bits/stl_vector.h (~_Vector_base): Add unreachable
hint for negative capacity and cast to size_t explicitly.
* include/bits/vector.tcc (vector::_M_realloc_append): Use
size() instead of end() - begin().

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 months agolibstdc++: Use explicit cast to unsigned in std::rotr and std::rotl
Jonathan Wakely [Thu, 29 May 2025 10:29:38 +0000 (11:29 +0100)] 
libstdc++: Use explicit cast to unsigned in std::rotr and std::rotl

This suppresses some -Wsign-conversion warnings from Clang when
compiling with -Wsystem-headers.

libstdc++-v3/ChangeLog:

* include/std/bit (__rotl, __rotr): Use static_cast for
conversion from int to unsigned.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 months agolibstdc++: Remove redundant macro checks in std.cc.in
Jonathan Wakely [Tue, 27 May 2025 15:54:52 +0000 (16:54 +0100)] 
libstdc++: Remove redundant macro checks in std.cc.in

__cpp_lib_any and __cpp_lib_chrono are defined unconditionally in C++20
and __cpp_lib_three_way_comparison and __cpp_lib_concepts depend on
front-end features which are definitely supported by GCC trunk and all
non-GCC compilers we care about.

libstdc++-v3/ChangeLog:

* src/c++23/std.cc.in: Remove redundant checks for feature test
macros that are always true.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 months agoRISC-V: Use helper function to get FPR to VR move cost
Paul-Antoine Arras [Wed, 28 May 2025 10:09:22 +0000 (12:09 +0200)] 
RISC-V: Use helper function to get FPR to VR move cost

Since last patch introduced get_fr2vr_cost () to get the correct cost to move
data from a floating-point to a vector register, this patch replaces existing
uses of the constant FR2VR.

gcc/ChangeLog:

* config/riscv/riscv-vector-costs.cc (costs::adjust_stmt_cost): Replace
FR2VR with get_fr2vr_cost ().
* config/riscv/riscv.cc (riscv_register_move_cost): Likewise.
(riscv_builtin_vectorization_cost): Likewise.

2 months agoRISC-V: Add pattern for vector-scalar multiply-add/sub [PR119100]
Paul-Antoine Arras [Mon, 12 May 2025 12:42:24 +0000 (14:42 +0200)] 
RISC-V: Add pattern for vector-scalar multiply-add/sub [PR119100]

This pattern enables the combine pass (or late-combine, depending on the case)
to merge a vec_duplicate into a plus-mult or minus-mult RTL instruction.

Before this patch, we have two instructions, e.g.:
  vfmv.v.f        v6,fa0
  vfmadd.vv       v9,v6,v7

After, we get only one:
  vfmadd.vf       v9,fa0,v7

On SPEC2017's 503.bwaves_r, depending on the workload, the reduction in dynamic
instruction count varies from -4.66% to -4.75%.

PR target/119100

gcc/ChangeLog:

* config/riscv/autovec-opt.md (*<optab>_vf_<mode>): Add new pattern to
combine vec_duplicate + vfm{add,sub}.vv into vfm{add,sub}.vf.
* config/riscv/riscv-opts.h (FPR2VR_COST_UNPROVIDED): Define.
* config/riscv/riscv-protos.h (get_fr2vr_cost): Declare function.
* config/riscv/riscv.cc (riscv_rtx_costs): Add cost model for MULT with
VEC_DUPLICATE.
(get_fr2vr_cost): New function.
* config/riscv/riscv.opt: Add new option --param=fpr2vr-cost.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vx_vf/vf-1-f16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-1-f32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-1-f64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-2-f16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-2-f32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-2-f64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-3-f16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-3-f32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-3-f64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-4-f16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-4-f32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-4-f64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_mulop.h: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_mulop_data.h: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_mulop_run.h: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfmadd-run-1-f16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfmadd-run-1-f32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfmadd-run-1-f64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfmsub-run-1-f16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfmsub-run-1-f32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfmsub-run-1-f64.c: New test.

2 months agox86: Add g++.target/i386/pr103750.C
H.J. Lu [Tue, 3 Jun 2025 09:17:57 +0000 (17:17 +0800)] 
x86: Add g++.target/i386/pr103750.C

Add a test for PR target/103750 fixed by r16-170-ga670ebde399548.

PR target/103750
* g++.target/i386/pr103750.C: New test.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2 months agolibgomp: Fix up omp_target_memset-3.c test for C++ [PR120444]
Jakub Jelinek [Tue, 3 Jun 2025 05:54:37 +0000 (07:54 +0200)] 
libgomp: Fix up omp_target_memset-3.c test for C++ [PR120444]

The test PASSes for C, but FAILs for C++:
.../libgomp.c-c++-common/omp_target_memset-3.c: In function 'void test_it(void*, int, size_t)':
.../libgomp.c-c++-common/omp_target_memset-3.c:31:7: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
.../libgomp.c-c++-common/omp_target_memset-3.c:33:13: error: invalid conversion from 'void*' to 'int8_t*' {aka 'signed char*'} [-fpermissive]
.../libgomp.c-c++-common/omp_target_memset-3.c:10:19: note: initializing argument 1 of 'void init_val(int8_t*, int, size_t)'
.../libgomp.c-c++-common/omp_target_memset-3.c:37:14: error: invalid conversion from 'void*' to 'int8_t*' {aka 'signed char*'} [-fpermissive]
.../libgomp.c-c++-common/omp_target_memset-3.c:17:20: note: initializing argument 1 of 'void check_val(int8_t*, int, size_t)'
.../libgomp.c-c++-common/omp_target_memset-3.c:38:18: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
.../libgomp.c-c++-common/omp_target_memset-3.c:38:18: error: invalid conversion from 'void*' to 'int8_t*' {aka 'signed char*'} [-fpermissive]
.../libgomp.c-c++-common/omp_target_memset-3.c:17:20: note: initializing argument 1 of 'void check_val(int8_t*, int, size_t)'
.../libgomp.c-c++-common/omp_target_memset-3.c: In function 'int main()':
.../libgomp.c-c++-common/omp_target_memset-3.c:46:7: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]

The following two-liner fixes that, tested on x86_64-linux and i686-linux.

2025-06-03  Jakub Jelinek  <jakub@redhat.com>

PR libgomp/120444
* testsuite/libgomp.c-c++-common/omp_target_memset-3.c (test_it):
Change ptr argument type from void * to int8_t *.
(main): Change ptr variable type from void * to int8_t * and cast
omp_target_alloc result to the latter type.

2 months agophiprop: Add testcase for already fixed case [PR116824]
Andrew Pinski [Tue, 3 Jun 2025 03:50:44 +0000 (20:50 -0700)] 
phiprop: Add testcase for already fixed case [PR116824]

This testcase was fixed by r16-906-g8da568c885dc90. Since
this is a C testcase, it would be useful to have a C testcase besides
a C++ one too.

Tested for x86_64-linux-gnu.

PR tree-optimization/116824

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/phiprop-2.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2 months agoswitch-conversion: Mark CSWTCH as mergeable [PR120451]
Andrew Pinski [Mon, 2 Jun 2025 22:56:20 +0000 (15:56 -0700)] 
switch-conversion: Mark CSWTCH as mergeable [PR120451]

When we have a smallish CSWTCH, it could be placed in the rodata.cst16
section so it can be merged with other constants across TUs.

The fix is simple; just mark the decl as mergable (DECL_MERGEABLE).
DECL_MERGEABLE was added with r14-1500-g4d935f52b0d5c0 specifically
to improve these kind of decls.

PR tree-optimization/120451

gcc/ChangeLog:

* tree-switch-conversion.cc (switch_conversion::build_one_array): Mark
the newly created decl as mergable.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/cswtch-6.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2 months agoDaily bump.
GCC Administrator [Tue, 3 Jun 2025 00:18:06 +0000 (00:18 +0000)] 
Daily bump.

2 months ago[lra] force reg update after spilling to memory [PR120424]
Alexandre Oliva [Mon, 2 Jun 2025 23:21:45 +0000 (20:21 -0300)] 
[lra] force reg update after spilling to memory [PR120424]

In the added C++ testcase, a stack slot at a negative sp offset is
used to hold a value across a call.

There are a couple of causes that directly lead to this outcome:

- the -fstack-clash-protection and -fnon-call-exception options, that
cause arm_frame_pointer_required to flip from false to true when the
first pseudo gets spilled to memory;

- when the affected pseudo is spilled to memory, we fail to update lra
regno info, because the insns that reference it are already on the
lra_constraint_insn_stack;

There is another potentially-related issue:

- when we notice that the frame pointer can no longer be eliminated to
the stack pointer, we immediately clear can_eliminate, and also
prev_can_eliminate, but update_reg_eliminate relied on the latter to
tell that it needs to propagate a previous_offset to the
newly-selected elimination, or restore the original offsets.

This patch ensures that we update insn register info after spilling a
pseudo to memory, and enables update_reg_eliminate to recognize the
case in which a previously-preferred elimination is disabled
regardless of prev_can_eliminate.

for  gcc/ChangeLog

PR rtl-optimization/120424
PR middle-end/118939
* lra-spills.cc (spill_pseudos): Update insn regno info.
* lra-eliminations.cc (update_reg_eliminate): Recognize
disabling of active elimination regardless of
prev_can_eliminate.

for  gcc/testsuite/ChangeLog

PR rtl-optimization/120424
PR middle-end/118939
* g++.target/arm/pr120424.C: New.
* gnat.dg/controlled9.adb: New.
* gnat.dg/controlled9_pkg.ads: New.