]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
14 months agoada: Fix strict aliasing violation in parameter passing (continued)
Eric Botcazou [Sun, 10 Mar 2024 12:22:55 +0000 (13:22 +0100)] 
ada: Fix strict aliasing violation in parameter passing (continued)

This fixes another long-standing (implicit) violation of the strict aliasing
rules that occurs when the result of a value conversion is directly passed
as an actual parameter in a call to a subprogram and the passing mechanism
is by reference.  In this case, the reference passed to the subprogram may
be to a type that is too different from the type of the underlying object,
which is the definition of such a violation.

The change reworks and strengthens the previous fix as follows: first, the
detection of these violations is moved into a dedicated predicate; second,
an assertion is added to check that none of them has been missed, which is
triggered by either -fchecking or -fstrict-aliasing, as the closely related
assertion that is present in relate_alias_sets.

The assertion uncovered two internal sources of violations: implementation
types for packed array types with peculiar index types and interface types,
which are fixed by propagating alias sets in the first case and resorting to
universal aliasing in the second case.

Finally, an unconditional warning is implemented to inform the user that the
temporary is created and to suggest a possible solution to prevent that.

gcc/ada/

* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Array_Type>: For a
packed type implemented specially, temporarily save the XUA type as
equivalent to the entity before processing the implementation type.
For this implementation type, if its component type is the same as
that of the original type, copy the alias set from the latter.
<types>: Resort to universal aliasing for all interface types.
* gcc-interface/trans.cc (Call_to_gnu): Add GNU_ACTUAL_TYPE local
variable and rename existing one to GNU_UNPADDED_ACTUAL_TYPE.
If the formal is passed by reference and the actual is a conversion,
call aliasable_p to detect aliasing violations, issue a warning upon
finding one and create the temporary in the target type.
Add an assertion that no such violation has been missed above.
(addressable_p): Revert latest changes.
(aliasable_p): New predicate.
* gcc-interface/utils2.cc (build_binary_op) <ARRAY_RANGE_REF>: When
creating a new array type on the fly, preserve the alias set of the
operation type.

14 months agoada: Make detection of useless copy for return more robust
Eric Botcazou [Tue, 12 Mar 2024 16:56:00 +0000 (17:56 +0100)] 
ada: Make detection of useless copy for return more robust

In the return-by-invisible-reference case, the return object of an extended
return statement is allocated directly on the return stack and, therefore,
the copy operation on return is useless.  The code detecting this was not
robust enough and missed some complex cases.

gcc/ada/

* gcc-interface/trans.cc (gnat_to_gnu) <N_Simple_Return_Statement>:
In the return-by-invisible-reference case, remove conversions before
looking for a dereference in the return values and building the test
protecting against a useless copy operation.

14 months agoada: Fix strict aliasing violation in parameter passing
Eric Botcazou [Thu, 29 Feb 2024 08:14:27 +0000 (09:14 +0100)] 
ada: Fix strict aliasing violation in parameter passing

This fixes a long-standing (implicit) violation of the strict aliasing rules
that occurs when the result of a call to an instance of Unchecked_Conversion
is directly passed as an actual parameter in a call to a subprogram and the
passing mechanism is by reference.  In this case, the reference passed to
the subprogram may be to a type that has nothing to do with the type of the
underlying object, which is the definition of such a violation.

This implements the following two-pronged approach: first, the problematic
cases are detected and a reference to a temporary is passed instead of the
direct reference to the underlying object; second, the implementation of
pragma Universal_Aliasing is enhanced so that it is propagated from the
component type of an array type to the array type itself, or else can be
applied to the array type directly, and may therefore be used to prevent
the violation from occurring in the first place, when the array type is
involved in the Unchecked_Conversion.

gcc/ada/

* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Array_Type>: Set
TYPE_TYPELESS_STORAGE on the array types if Universal_Aliasing is
set on the type or its component type.
<E_Array_Subtype>: Likewise.
For other aggregate types, set TYPE_TYPELESS_STORAGE in this case.
(set_typeless_storage_on_aggregate_type): New function.
(set_universal_aliasing_on_type): Likewise.
* gcc-interface/trans.cc (Call_to_gnu): Add const to local variable.
Adjust comment.  Pass GNAT_NAME in the call to addressable_p and add
a bypass for atomic types in case it returns false.
(addressable_p): Add GNAT_EXPR third parameter with default value
and add a default value to the existing second parameter.
<VIEW_CONVERT_EXPR:>: Return false if the expression comes from a
function call and if the alias sets of source and target types are
both distinct from zero and each other.

14 months agoada: Fix crash with aliased array and if expression
Ronan Desplanques [Fri, 23 Feb 2024 08:53:32 +0000 (09:53 +0100)] 
ada: Fix crash with aliased array and if expression

The way if expressions were translated led the gimplifying phase
to attempt to create a temporary of a variable-sized type in some
cases. This patch fixes this by adding an address indirection layer
in those cases.

gcc/ada/

* gcc-interface/utils2.cc (build_cond_expr): Also apply an
indirection when the result type is variable-sized.

14 months agoada: Minor typo fix in comment
Marc Poulhiès [Fri, 26 Jan 2024 12:58:34 +0000 (13:58 +0100)] 
ada: Minor typo fix in comment

gcc/ada/

* gcc-interface/decl.cc: Fix typo in comment.

14 months agoada: Follow-up adjustment to earlier fix in Build_Allocate_Deallocate_Proc
Eric Botcazou [Sun, 11 Feb 2024 18:18:46 +0000 (19:18 +0100)] 
ada: Follow-up adjustment to earlier fix in Build_Allocate_Deallocate_Proc

The deallocation call of the return and secondary stacks no longer matches
the profile built in Exp_Util.Build_Allocate_Deallocate_Proc, so this just
removes the code as unreachable and adds an assertion to that effect.

gcc/ada/

* gcc-interface/utils2.cc (build_call_alloc_dealloc_proc): Add an
assertion that this is not a deallocation of the return or secondary
stack and remove subsequent unreachable code.

14 months agoada: Avoid temporary for conditional expression of discriminated record type
Eric Botcazou [Tue, 6 Feb 2024 11:57:38 +0000 (12:57 +0100)] 
ada: Avoid temporary for conditional expression of discriminated record type

This just aligns the definite case (discriminants with default) with the
indefinite case (discriminants without default), the latter case having
been properly handled for long.  In the former case, the maximum size is
used so a temporary can be much larger than the actual data it contains.

gcc/ada/

* gcc-interface/utils2.cc (build_cond_expr): Use the indirect path
for all types containing a placeholder.

14 months agoada: Remove unused dependencies from gnatbind object list
Piotr Trojanek [Fri, 26 Jan 2024 10:08:35 +0000 (11:08 +0100)] 
ada: Remove unused dependencies from gnatbind object list

The gnatbind executable does not depend on aspects, SCIL, style checks,
etc. Also, these dependencies are not needed to actually build the
executable. Cleanup.

gcc/ada/

* gcc-interface/Make-lang.in (GNATBIND_OBJS): Remove unused
dependencies.

14 months agoada: Fix assembler error for gigantic library-level object on 64-bit Windows
Eric Botcazou [Mon, 22 Jan 2024 22:56:37 +0000 (23:56 +0100)] 
ada: Fix assembler error for gigantic library-level object on 64-bit Windows

Most small 64-bit code models have a limit of 2 GB on the span of binaries,
so we also use the limit for the size of the largest statically allocatable
object by the compiler.  If the limit is topped, the compiler switches over
to a dynamic allocation (if not forbidden) after giving a warning.

gcc/ada/

* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Variable>: Give a
warning for a statically allocated object whose size is constant,
valid but too large.
(allocatable_size_p): In the static case, return false for a size
that is constant, valid but too large.

14 months agoada: Fix crash on aliased constant with packed array type and -g switch
Eric Botcazou [Fri, 12 Jan 2024 09:50:01 +0000 (10:50 +0100)] 
ada: Fix crash on aliased constant with packed array type and -g switch

The problem is that we build a template whose array field is not an array
in the case of an aliased object with nominal unconstrained array subtype.

gcc/ada/

* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Variable>: For an
array allocated with its bounds, make sure to have an array type
to build the template.

14 months agoada: Fix small inaccuracy for Size attribute applied to objects
Eric Botcazou [Thu, 14 Dec 2023 14:18:28 +0000 (15:18 +0100)] 
ada: Fix small inaccuracy for Size attribute applied to objects

This reverts a change made some time ago in lvalue_required_for_attribute_p
whereby the Size attribute applied to objects would no longer be considered
as requiring an lvalue.

While not wrong in principle, this turns out to be problematic because the
implementation in Attribute_to_gnu needs to look at the translated prefix
to spot particular cases and not only at the actual type of its value.

This of course requires a small adjustment in gnat_to_gnu to compensate.

gcc/ada/

* gcc-interface/trans.cc (access_attribute_p): New predicate.
(lvalue_required_for_attribute_p): Return again 1 for Size and add
the missing terminating call to gcc_unreachable.
(gnat_to_gnu): Return the result unmodified for a reference to an
unconstrained array only if it is the prefix of an access attribute.

14 months agoada: Fix oversight in previous change
Eric Botcazou [Thu, 14 Dec 2023 12:05:52 +0000 (13:05 +0100)] 
ada: Fix oversight in previous change

In rare cases, types using structural equality may reach relate_alias_sets.

gcc/ada/

* gcc-interface/utils.cc (relate_alias_sets): Restore previous code
when the type uses structural equality.

14 months agoada: Missing constraint check for initial value of object with address clause
Steve Baird [Fri, 5 Apr 2024 19:35:08 +0000 (12:35 -0700)] 
ada: Missing constraint check for initial value of object with address clause

In some cases where an object is declared with an initial value that is
an aggregate and also with a specified Address (either via an
aspect_specification or via an attribute_definition_clause), the
check that the initial value satisfies the constraints of the object's
subtype was incorrectly omitted.

gcc/ada/

* exp_util.adb (Remove_Side_Effects): Make_Reference assumes that
the referenced object satisfies the constraints of the designated
subtype of the access type. Ensure that this assumption holds by
introducing a qualified expression if needed (and then ensuring
that checking associated with evaluation of the qualified
expression is not suppressed).

14 months agoada: Fix layout in a list of aspects
Piotr Trojanek [Wed, 3 Apr 2024 11:36:35 +0000 (13:36 +0200)] 
ada: Fix layout in a list of aspects

Code cleanup; semantics is unaffected.

gcc/ada/

* aspects.ads (Nonoverridable_Aspect_Id): Fix layout.

14 months agoada: Remove duplicate statement
Ronan Desplanques [Tue, 2 Apr 2024 16:27:39 +0000 (18:27 +0200)] 
ada: Remove duplicate statement

This patch removes a duplicate statement that was useless and could
be misleading to the reader by suggesting that there are multiple
global variables named Style_Check, while there is just one.

gcc/ada/

* frontend.adb (Frontend): Remove duplicate statement.

14 months agoada: Remove useless trampolines caused by Unchecked_Conversion
Eric Botcazou [Thu, 4 Apr 2024 16:15:24 +0000 (18:15 +0200)] 
ada: Remove useless trampolines caused by Unchecked_Conversion

The partial solution implemented in Validate_Unchecked_Conversion to support
unchecked conversions between addresses and pointers to subprograms, for the
platforms where pointers to subprograms do not all have the same size, turns
out to be counter-productive for others because it may cause the creation of
useless trampolines, which in turn makes the stack executable.

gcc/ada/

* sem_ch13.adb (Validate_Unchecked_Conversion): Restrict forcing the
Can_Use_Internal_Rep flag to platforms that require unnesting.

14 months agoada: Add elaboration switch tags to info messages
Viljar Indus [Tue, 2 Apr 2024 11:32:04 +0000 (14:32 +0300)] 
ada: Add elaboration switch tags to info messages

Add the ?$? insertion characters for elaboration
message so they would be marked with the [-gnatel]
tag. Note that these insertion characters were
not added for SPARK elaboration messages:

gcc/ada/

* sem_elab.adb: Add missing elaboration insertion
characters to info messages.

14 months agoada: Simplify management of scopes while inlining
Piotr Trojanek [Wed, 3 Apr 2024 11:43:07 +0000 (13:43 +0200)] 
ada: Simplify management of scopes while inlining

Code cleanup; semantics is unaffected.

gcc/ada/

* inline.adb (Add_Scope_To_Clean): Use Append_Unique_Elmt.
(Analyze_Inlined_Bodies): Refine type of a local counter;
remove extra whitespace.

14 months agoada: Remove some explicit yields in tasking run-time
Ronan Desplanques [Tue, 2 Apr 2024 07:09:31 +0000 (09:09 +0200)] 
ada: Remove some explicit yields in tasking run-time

This patch removes three occurrences where tasking run-time
subprograms yielded control shortly before conditional calls to Sleep,
in order to avoid these calls more often. It was intended as an
optimization on systems where calls to Sleep are costly and in
particular VMS.

A problem was that two of the yields contained data races that were
reported by thread sanitizing tools on some platforms, and that's the
motivation for removing them.

gcc/ada/

* libgnarl/s-taenca.adb (Wait_For_Completion): Remove call to
Yield.
* libgnarl/s-tasren.adb (Timed_Selective_Wait, Wait_For_Call):
Remove calls to Yield.

14 months agoada: Fix formatting in list of implemented Ada 2012 features
Piotr Trojanek [Mon, 18 Mar 2024 21:43:54 +0000 (22:43 +0100)] 
ada: Fix formatting in list of implemented Ada 2012 features

Fix formatting; meaning is unaffected.

gcc/ada/

* doc/gnat_rm/implementation_of_ada_2012_features.rst:
Fix formatting.
* gnat_rm.texi: Regenerate.

14 months agoada: Sort list of implemented Ada 2012 features
Piotr Trojanek [Mon, 18 Mar 2024 17:00:55 +0000 (18:00 +0100)] 
ada: Sort list of implemented Ada 2012 features

The list of implemented Ada 2012 features is now ordered by the AI
numbers. It has been sorted mechanically using the csplit command with
a bit of shell scripting.

gcc/ada/

* doc/gnat_rm/implementation_of_ada_2012_features.rst:
Order list by AI number.
* gnat_rm.texi: Regenerate.

14 months agoada: Fix index entry for an implemented AI feature
Piotr Trojanek [Mon, 18 Mar 2024 16:29:07 +0000 (17:29 +0100)] 
ada: Fix index entry for an implemented AI feature

Fix inconsistent reference with "05" in the name of AI.

gcc/ada/

* doc/gnat_rm/implementation_of_ada_2012_features.rst
(AI-0216): Fix index reference.
* gnat_rm.texi: Regenerate.

14 months agoada: Update documentation of warning messages
Viljar Indus [Tue, 2 Apr 2024 10:48:55 +0000 (13:48 +0300)] 
ada: Update documentation of warning messages

Update the documentation of warning messages that only
emit info messages to clearly reflect that they only emit
info messages and not warning messages.

gcc/ada/

* doc/gnat_ugn/building_executable_programs_with_gnat.rst:
Update the documentation of -gnatw.n and -gnatw.l
* gnat_ugn.texi: Regenerate.

14 months agoada: Do not leak tagged type names when Discard_Names is enabled
Piotr Trojanek [Fri, 22 Mar 2024 22:11:10 +0000 (23:11 +0100)] 
ada: Do not leak tagged type names when Discard_Names is enabled

When both pragmas Discard_Names and No_Tagged_Streams apply to a tagged
type, the intended behavior is to prevent type names from leaking into
object code, as documented in GNAT RM.

However, while Discard_Names can be used as a configuration pragma,
No_Tagged_Streams must be applied to each type separately. This patch
enables the use of restriction No_Streams, which can be activated
globally, instead of No_Tagged_Streams on individual types.

When no tagged stream object can be created and allocated, then routines
that make use of the External_Tag won't be used.

gcc/ada/

* doc/gnat_rm/implementation_defined_pragmas.rst
(No_Tagged_Streams): Document how to avoid exposing entity names
for the entire partition.
* exp_disp.adb (Make_DT): Make use of restriction No_Streams.
* exp_put_image.adb (Build_Record_Put_Image_Procedure): Respect
Discard_Names in the generated Put_Image procedure.
* gnat_rm.texi: Regenerate.

14 months agoada: Remove conversion from String_Id to String and back to String_Id
Piotr Trojanek [Fri, 22 Mar 2024 18:06:48 +0000 (19:06 +0100)] 
ada: Remove conversion from String_Id to String and back to String_Id

Code cleanup; semantics is unaffected.

gcc/ada/

* exp_put_image.adb (Build_Record_Put_Image_Procedure): Remove
useless conversions.

14 months agoada: Remove trailing NUL in minimal expansion of Put_Image attribute
Piotr Trojanek [Fri, 22 Mar 2024 18:02:00 +0000 (19:02 +0100)] 
ada: Remove trailing NUL in minimal expansion of Put_Image attribute

When procedure that implements Put_Image attribute emits the type name,
this name was wrongly followed by a NUL character.

gcc/ada/

* exp_put_image.adb (Build_Record_Put_Image_Procedure): Remove
trailing NUL from the fully qualified type name.

14 months agoada: Follow-up fix to previous change for Text_Ptr
Eric Botcazou [Tue, 2 Apr 2024 08:51:00 +0000 (10:51 +0200)] 
ada: Follow-up fix to previous change for Text_Ptr

The variable would be saved and restored while still uninitialized.

gcc/ada/

* err_vars.ads (Error_Msg_Sloc): Initialize to No_Location.

14 months agoada: Add new Mingw task priority mapping
Justin Squirek [Mon, 11 Mar 2024 15:15:34 +0000 (15:15 +0000)] 
ada: Add new Mingw task priority mapping

This patch adds a new mapping (Non_FIFO_Underlying_Priorities) for dynamically
setting task priorities in Windows when pragma Task_Dispatching_Policy
(FIFO_Within_Priorities) is not present. Additionally, it documents the
requirement to specify the pragma in order to use Set_Priority in the general
case.

gcc/ada/

* doc/gnat_ugn/platform_specific_information.rst: Add note about
different priority level granularities under different policies in
Windows and move POSIX related info into new section.
* libgnarl/s-taprop.ads: Add note about Task_Dispatching_Policy.
* libgnarl/s-taprop__mingw.adb:
(Set_Priority): Add use of Non_FIFO_Underlying_Priorities.
* libgnat/system-mingw.ads: Add documentation for modifying
priority mappings and add alternative mapping
Non_FIFO_Underlying_Priorities.
* gnat_ugn.texi: Regenerate.

14 months agoUse pblendw instead of pand to clear upper 16 bits.
liuhongt [Fri, 22 Mar 2024 06:40:00 +0000 (14:40 +0800)] 
Use pblendw instead of pand to clear upper 16 bits.

For vec_pack_truncv8si/v4si w/o AVX512,
(const_vector:v4si (const_int 0xffff) x4) is used as mask to clear
upper 16 bits, but vpblendw with zero_vector can also be used, and
zero vector is cheaper than (const_vector:v4si (const_int 0xffff) x4).

gcc/ChangeLog:
PR target/114427
* config/i386/i386-expand.cc (expand_vec_perm_even_odd_pack):
Use pblendw instead of pand to clear upper bits.

gcc/testsuite/ChangeLog:
* gcc.target/i386/pr114427.c: New test.

14 months agotestsuite, rs6000: Make powerpc_altivec consider current_compiler_flags [PR114842]
Kewen Lin [Tue, 21 May 2024 02:01:08 +0000 (21:01 -0500)] 
testsuite, rs6000: Make powerpc_altivec consider current_compiler_flags [PR114842]

As noted in PR114842, most of the test cases which require
effective target check powerpc_altivec_ok actually care
about if ALTIVEC feature is enabled, and they should adopt
effective target powerpc_altivec instead.  By considering
we already have a number of test cases having explicit
-maltivec in dg-options etc., to keep them still be tested
as before even without altivec enabled by default, this
patch makes powerpc_altivec consider current_compiler_flags
like what we do for powerpc_vsx.

PR testsuite/114842

gcc/testsuite/ChangeLog:

* lib/target-supports.exp (check_effective_target_powerpc_altivec):
Take current_compiler_flags into account.

14 months agotestsuite, rs6000: Make powerpc_vsx consider current_compiler_flags [PR114842]
Kewen Lin [Tue, 21 May 2024 02:01:08 +0000 (21:01 -0500)] 
testsuite, rs6000: Make powerpc_vsx consider current_compiler_flags [PR114842]

As noted in PR114842, most of the test cases which require
effective target check powerpc_vsx_ok actually care about
if VSX feature is enabled, and they should adopt effective
target powerpc_vsx instead.  By considering we already have
a number of test cases having explicit -mvsx in dg-options
etc., to keep them still be tested as before even without
vsx enabled by default, this patch is to make powerpc_vsx
consider current_compiler_flags.

PR testsuite/114842

gcc/testsuite/ChangeLog:

* lib/target-supports.exp (check_effective_target_powerpc_vsx): Take
current_compiler_flags into account.

14 months agotestsuite, rs6000: Remove effective target powerpc_405_nocache
Kewen Lin [Tue, 21 May 2024 02:01:08 +0000 (21:01 -0500)] 
testsuite, rs6000: Remove effective target powerpc_405_nocache

With the introduction of -mdejagnu-cpu=, when the test case
is specifying -mdejagnu-cpu=405, it would override the other
possibly given -mcpu=, so it would compile for PowerPC 405
for sure.  This patch is to remove the effective target
powerpc_405_nocache and update all its uses.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/405-dlmzb-strlen-1.c: Remove the line using
powerpc_405_nocache check.
* gcc.target/powerpc/405-macchw-1.c: Likewise.
* gcc.target/powerpc/405-macchw-2.c: Likewise.
* gcc.target/powerpc/405-macchwu-1.c: Likewise.
* gcc.target/powerpc/405-macchwu-2.c: Likewise.
* gcc.target/powerpc/405-machhw-1.c: Likewise.
* gcc.target/powerpc/405-machhw-2.c: Likewise.
* gcc.target/powerpc/405-machhwu-1.c: Likewise.
* gcc.target/powerpc/405-machhwu-2.c: Likewise.
* gcc.target/powerpc/405-maclhw-1.c: Likewise.
* gcc.target/powerpc/405-maclhw-2.c: Likewise.
* gcc.target/powerpc/405-maclhwu-1.c: Likewise.
* gcc.target/powerpc/405-maclhwu-2.c: Likewise.
* gcc.target/powerpc/405-mulchw-1.c: Likewise.
* gcc.target/powerpc/405-mulchw-2.c: Likewise.
* gcc.target/powerpc/405-mulchwu-1.c: Likewise.
* gcc.target/powerpc/405-mulchwu-2.c: Likewise.
* gcc.target/powerpc/405-mulhhw-1.c: Likewise.
* gcc.target/powerpc/405-mulhhw-2.c: Likewise.
* gcc.target/powerpc/405-mulhhwu-1.c: Likewise.
* gcc.target/powerpc/405-mulhhwu-2.c: Likewise.
* gcc.target/powerpc/405-mullhw-1.c: Likewise.
* gcc.target/powerpc/405-mullhw-2.c: Likewise.
* gcc.target/powerpc/405-mullhwu-1.c: Likewise.
* gcc.target/powerpc/405-mullhwu-2.c: Likewise.
* gcc.target/powerpc/405-nmacchw-1.c: Likewise.
* gcc.target/powerpc/405-nmacchw-2.c: Likewise.
* gcc.target/powerpc/405-nmachhw-1.c: Likewise.
* gcc.target/powerpc/405-nmachhw-2.c: Likewise.
* gcc.target/powerpc/405-nmaclhw-1.c: Likewise.
* gcc.target/powerpc/405-nmaclhw-2.c: Likewise.
* lib/target-supports.exp
(check_effective_target_powerpc_405_nocache): Remove.

14 months agolibgcc, rs6000: Remove powerpcspe related code
Kewen Lin [Tue, 21 May 2024 02:01:08 +0000 (21:01 -0500)] 
libgcc, rs6000: Remove powerpcspe related code

Since r9-4728 the powerpcspe support had been removed, this
follow-up patch is to remove the remaining pieces in libgcc.

libgcc/ChangeLog:

* config.host: Remove powerpc-*-eabispe* support.
* config/rs6000/linux-unwind.h (ppc_fallback_frame_state): Remove
__SPE__ code.
* config/rs6000/t-savresfgpr (LIB2ADD_ST): Remove e500crtres32gpr.S,
e500crtres32gpr.S, e500crtsav64gpr.S, e500crtsav64gprctr.S,
e500crtres64gpr.S, e500crtsav32gpr.S, e500crtsavg32gpr.S,
e500crtres64gprctr.S, e500crtsavg64gprctr.S, e500crtresx32gpr.S,
e500crtrest32gpr.S, e500crtrest64gpr.S and e500crtresx64gpr.S.
* config/rs6000/e500crtres32gpr.S: Remove.
* config/rs6000/e500crtres64gpr.S: Remove.
* config/rs6000/e500crtres64gprctr.S: Remove.
* config/rs6000/e500crtrest32gpr.S: Remove.
* config/rs6000/e500crtrest64gpr.S: Remove.
* config/rs6000/e500crtresx32gpr.S: Remove.
* config/rs6000/e500crtresx64gpr.S: Remove.
* config/rs6000/e500crtsav32gpr.S: Remove.
* config/rs6000/e500crtsav64gpr.S: Remove.
* config/rs6000/e500crtsav64gprctr.S: Remove.
* config/rs6000/e500crtsavg32gpr.S: Remove.
* config/rs6000/e500crtsavg64gpr.S: Remove.
* config/rs6000/e500crtsavg64gprctr.S: Remove.

14 months agotestsuite, rs6000: Remove powerpcspe test cases and checks
Kewen Lin [Tue, 21 May 2024 02:01:08 +0000 (21:01 -0500)] 
testsuite, rs6000: Remove powerpcspe test cases and checks

Since r9-4728 the powerpcspe support had been removed, this
follow-up patch is to remove the remaining pieces in testsuite.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp
(check_effective_target_vect_cmdline_needed): Remove
check_effective_target_powerpc_spe.
(check_effective_target_powerpc_spe_nocache): Remove.
(check_effective_target_powerpc_spe): Remove.
(check_ppc_cpu_supports_hw_available): Remove powerpc*-*-eabispe check.
(check_p8vector_hw_available): Likewise.
(check_p9vector_hw_available): Likewise.
(check_p9modulo_hw_available): Likewise.
(check_ppc_float128_sw_available): Likewise.
(check_ppc_float128_hw_available): Likewise.
(check_vsx_hw_available): Likewise.
(check_vmx_hw_available): Likewise.
(check_ppc_recip_hw_available): Likewise.
(check_dfp_hw_available): Likewise.
(check_htm_hw_available): Likewise.
* g++.dg/ext/spe1.C: Remove.
* g++.dg/other/opaque-1.C: Remove.
* g++.dg/other/opaque-2.C: Remove.
* g++.dg/other/opaque-3.C: Remove.
* g++.target/powerpc/simd-5.C: Remove.

14 months agotestsuite, rs6000: Remove powerpc_popcntb_ok
Kewen Lin [Tue, 21 May 2024 02:01:07 +0000 (21:01 -0500)] 
testsuite, rs6000: Remove powerpc_popcntb_ok

There are three uses of effective target powerpc_popcntb_ok,
they are all for compiling, but powerpc_popcntb_ok checks
for executable generation, which is too heavy.  This patch
is to remove powerpc_popcntb_ok and adjust its three uses
accordingly.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp (check_effective_target_powerpc_popcntb_ok):
Remove.
* gcc.target/powerpc/cmpb-2.c: Adjust with dg-skip-if as
powerpc_popcntb_ok gets removed.
* gcc.target/powerpc/cmpb-3.c: Likewise.
* gcc.target/powerpc/cmpb32-2.c: Likewise.

14 months agotestsuite, rs6000: Remove all linux*paired* checks and cases
Kewen Lin [Tue, 21 May 2024 02:01:07 +0000 (21:01 -0500)] 
testsuite, rs6000: Remove all linux*paired* checks and cases

Since r9-115-g559289370f76bf the support of paired single
had been dropped, but we still have some test checks and
cases for that, this patch is to get rid of them.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp (check_effective_target_vect_int): Remove
the check on powerpc-*-linux*paired*.
(check_effective_target_vect_intfloat_cvt): Likewise.
(check_effective_target_vect_uintfloat_cvt): Likewise.
(check_effective_target_vect_floatint_cvt): Likewise.
(check_effective_target_vect_floatuint_cvt): Likewise.
(check_effective_target_powerpc_altivec_ok): Likewise.
(check_effective_target_powerpc_p9modulo_ok): Likewise.
(check_effective_target_powerpc_float128_sw_ok): Likewise.
(check_effective_target_powerpc_float128_hw_ok): Likewise.
(check_effective_target_powerpc_vsx_ok): Likewise.
(check_effective_target_powerpc_htm_ok): Likewise.
(check_effective_target_vect_shift): Likewise.
(check_effective_target_vect_char_add): Likewise.
(check_effective_target_vect_shift_char): Likewise.
(check_effective_target_vect_long): Likewise.
(check_effective_target_ifn_copysign): Likewise.
(check_effective_target_vect_sdot_hi): Likewise.
(check_effective_target_vect_udot_hi): Likewise.
(check_effective_target_vect_pack_trunc): Likewise.
(check_effective_target_vect_int_mult): Likewise.
* gcc.target/powerpc/paired-1.c: Remove.
* gcc.target/powerpc/paired-10.c: Remove.
* gcc.target/powerpc/paired-2.c: Remove.
* gcc.target/powerpc/paired-3.c: Remove.
* gcc.target/powerpc/paired-4.c: Remove.
* gcc.target/powerpc/paired-5.c: Remove.
* gcc.target/powerpc/paired-6.c: Remove.
* gcc.target/powerpc/paired-7.c: Remove.
* gcc.target/powerpc/paired-8.c: Remove.
* gcc.target/powerpc/paired-9.c: Remove.
* gcc.target/powerpc/ppc-paired.c: Remove.

14 months agotestsuite, rs6000: Remove some checks with aix[456]
Kewen Lin [Tue, 21 May 2024 02:01:07 +0000 (21:01 -0500)] 
testsuite, rs6000: Remove some checks with aix[456]

Since r12-75-g0745b6fa66c69c aix6 support had been dropped,
so we don't need to check for aix[456].* when testing, this
patch is to remove such checks.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp
(check_effective_target_powerpc_altivec_ok): Remove checks for
aix[456].*
(check_effective_target_powerpc_p9modulo_ok): Likewise.
(check_effective_target_powerpc_float128_sw_ok): Likewise.
(check_effective_target_powerpc_float128_hw_ok): Likewise.
(check_effective_target_powerpc_vsx_ok): Likewise.

14 months agotestsuite: Fix typo in torture/vector-{1,2}.c
Kewen Lin [Tue, 21 May 2024 02:01:07 +0000 (21:01 -0500)] 
testsuite: Fix typo in torture/vector-{1,2}.c

When making some clean up patches, I happened to find test
cases vector-{1,2}.c are having typo "powerpc64--*-*" in
target selector, which should be powerpc64-*-*.  The reason
why we didn't catch before is that all our testing machines
support VMX insns, so it passes always.  But it would break
if a test machine doesn't support that, so this patch is to
fix it to ensure robustness.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/vector-1.c: Fix typo.
* gcc.dg/torture/vector-2.c: Likewise.

14 months agors6000: Remove useless operands[3]
Kewen Lin [Tue, 21 May 2024 02:01:07 +0000 (21:01 -0500)] 
rs6000: Remove useless operands[3]

As shown, three uses of operands[3] are totally useless, so
this patch is to remove them to avoid any confusion.

gcc/ChangeLog:

* config/rs6000/rs6000.md (@ieee_128bit_vsx_neg<IEEE128>2): Remove
the use of operands[3].
(@ieee_128bit_vsx_neg<IEEE128>2): Likewise.
(*ieee_128bit_vsx_nabs<mode>2): Likewise.

14 months agors6000: Remove useless entries in rreg
Kewen Lin [Tue, 21 May 2024 02:01:07 +0000 (21:01 -0500)] 
rs6000: Remove useless entries in rreg

When I was working on a trial patch to get rid of TFmode,
I noticed that mode attribute rreg only gets used for mode
iterator SFDF, it means that only SF and DF key-value pairs
are useful, the other are useless, so this patch is to clean
up them.

gcc/ChangeLog:

* config/rs6000/rs6000.md (mode attribute rreg): Remove useless
entries with modes TF, TD, V4SF and V2DF.

14 months agors6000: Drop useless vector_{load,store}_<mode> defines
Kewen Lin [Tue, 21 May 2024 02:01:06 +0000 (21:01 -0500)] 
rs6000: Drop useless vector_{load,store}_<mode> defines

When I was working on a patch to get rid of TFmode, I
noticed that define_expands vector_load_<mode> and
vector_store_<mode> are useless.  This patch is to clean up
both.

gcc/ChangeLog:

* config/rs6000/vector.md (define_expand vector_load_<mode>): Remove.
(vector_store_<mode>): Likewise.

14 months agors6000: Clean up TF and TD check with FLOAT128_2REG_P
Kewen Lin [Tue, 21 May 2024 02:01:06 +0000 (21:01 -0500)] 
rs6000: Clean up TF and TD check with FLOAT128_2REG_P

Commit r6-2116-g2c83faf86827bf did some clean up on TFmode
and TFmode check with FLOAT128_2REG_P, but it missed to
update an assertion, this patch is to make it align.

btw, it's noticed when I'm making a patch to get rid of
TFmode.

gcc/ChangeLog:

* config/rs6000/rs6000-call.cc (rs6000_darwin64_record_arg_recurse):
Clean up TFmode and TDmode check with FLOAT128_2REG_P.

14 months agors6000: Add assert !TARGET_VSX if !TARGET_ALTIVEC and strip a useless check
Kewen Lin [Tue, 21 May 2024 02:01:06 +0000 (21:01 -0500)] 
rs6000: Add assert !TARGET_VSX if !TARGET_ALTIVEC and strip a useless check

In function rs6000_option_override_internal, we have the
checks and adjustments like:

  if (TARGET_P8_VECTOR && !TARGET_ALTIVEC)
    rs6000_isa_flags &= ~OPTION_MASK_P8_VECTOR;

  if (TARGET_P8_VECTOR && !TARGET_VSX)
    rs6000_isa_flags &= ~OPTION_MASK_P8_VECTOR;

But in fact some previous code has guaranteed !TARGET_VSX if
!TARGET_ALTIVEC, so we can remove the former check and
adjustment.  This patch is to remove it accordingly and also
place an explicit assertion.

gcc/ChangeLog:

* config/rs6000/rs6000.cc (rs6000_option_override_internal): Remove
useless check on TARGET_P8_VECTOR && !TARGET_ALTIVEC and add an
assertion on !TARGET_VSX if !TARGET_ALTIVEC.

14 months agors6000: Fix ICE on IEEE128 long double without vsx [PR114402]
Kewen Lin [Tue, 21 May 2024 02:01:06 +0000 (21:01 -0500)] 
rs6000: Fix ICE on IEEE128 long double without vsx [PR114402]

As PR114402 shows, we supports IEEE128 format long double
even if there is no vsx support, but there is an ICE about
cbranch as the test case shows.  For now, we only supports
compare:CCFP pattern for IEEE128 fp if TARGET_FLOAT128_HW,
so in function rs6000_generate_compare we have a check with
!TARGET_FLOAT128_HW && FLOAT128_VECTOR_P (mode) to make
!TARGET_FLOAT128_HW IEEE128 fp handling go with libcall.
But unfortunately the IEEE128 without vsx support doesn't
meet FLOAT128_VECTOR_P (mode) so it goes further with an
unmatched compare:CCFP pattern which triggers ICE.

So this patch is to make rs6000_generate_compare consider
IEEE128 without vsx as well then it can end up with libcall.

PR target/114402

gcc/ChangeLog:

* config/rs6000/rs6000.cc (rs6000_generate_compare): Make IEEE128
handling without vsx go with libcall.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr114402.c: New test.

14 months agoDaily bump.
GCC Administrator [Tue, 21 May 2024 00:17:26 +0000 (00:17 +0000)] 
Daily bump.

14 months agoPR modula2/115164 initial test code highlighting the problem
Gaius Mulley [Tue, 21 May 2024 00:11:48 +0000 (01:11 +0100)] 
PR modula2/115164 initial test code highlighting the problem

This patch includes some trivial testcode which highlights
PR 115164.  Expect future test code to perform runtime checks
for a series of trailing zeros.

gcc/testsuite/ChangeLog:

PR modula2/115164
* gm2/isolib/run/pass/testlowread.mod: New test.
* gm2/isolib/run/pass/testwritereal.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
14 months agoPHIOPT: Don't transform minmax if middle bb contains a phi [PR115143]
Andrew Pinski [Sat, 18 May 2024 18:55:58 +0000 (11:55 -0700)] 
PHIOPT: Don't transform minmax if middle bb contains a phi [PR115143]

The problem here is even if last_and_only_stmt returns a statement,
the bb might still contain a phi node which defines a ssa name
which is used in that statement so we need to add a check to make sure
that the phi nodes are empty for the middle bbs in both the
`CMP?MINMAX:MINMAX` case and the `CMP?MINMAX:B` cases.

Bootstrapped and tested on x86_64_linux-gnu with no regressions.

PR tree-optimization/115143

gcc/ChangeLog:

* tree-ssa-phiopt.cc (minmax_replacement): Check for empty
phi nodes for middle bbs for the case where middle bb is not empty.

gcc/testsuite/ChangeLog:

* gcc.c-torture/compile/pr115143-1.c: New test.
* gcc.c-torture/compile/pr115143-2.c: New test.
* gcc.c-torture/compile/pr115143-3.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
14 months agofortran: Assume there is no cyclic reference with submodule symbols [PR99798]
Mikael Morin [Sun, 12 May 2024 13:16:23 +0000 (15:16 +0200)] 
fortran: Assume there is no cyclic reference with submodule symbols [PR99798]

This prevents a premature release of memory with procedure symbols from
submodules, causing random compiler crashes.

The problem is a fragile detection of cyclic references, which can match
with procedures host-associated from a module in submodules, in cases where it
shouldn't.  The formal namespace is released, and with it the dummy arguments
symbols of the procedure.  But there is no cyclic reference, so the procedure
symbol itself is not released and remains, with pointers to its dummy arguments
now dangling.

The fix adds a condition to avoid the case, and refactors to a new predicate
by the way.  Part of the original condition is also removed, for lack of a
reason to keep it.

PR fortran/99798

gcc/fortran/ChangeLog:

* symbol.cc (gfc_release_symbol): Move the condition guarding
the handling cyclic references...
(cyclic_reference_break_needed): ... here as a new predicate.
Remove superfluous parts.  Add a condition preventing any premature
release with submodule symbols.

gcc/testsuite/ChangeLog:

* gfortran.dg/submodule_33.f08: New test.

14 months agoaarch64: Fold vget_low_* intrinsics to BIT_FIELD_REF [PR102171]
Pengxuan Zheng [Mon, 13 May 2024 17:47:10 +0000 (10:47 -0700)] 
aarch64: Fold vget_low_* intrinsics to BIT_FIELD_REF [PR102171]

This patch folds vget_low_* intrinsics to BIT_FILED_REF to open up more
optimization opportunities for gimple optimizers.

While we are here, we also remove the vget_low_* definitions from arm_neon.h and
use the new intrinsics framework.

PR target/102171

gcc/ChangeLog:

* config/aarch64/aarch64-builtins.cc (AARCH64_SIMD_VGET_LOW_BUILTINS):
New macro to create definitions for all vget_low intrinsics.
(VGET_LOW_BUILTIN): Likewise.
(enum aarch64_builtins): Add vget_low function codes.
(aarch64_general_fold_builtin): Fold vget_low calls.
* config/aarch64/aarch64-simd-builtins.def: Delete vget_low builtins.
* config/aarch64/aarch64-simd.md (aarch64_get_low<mode>): Delete.
(aarch64_vget_lo_halfv8bf): Likewise.
* config/aarch64/arm_neon.h (__attribute__): Delete.
(vget_low_f16): Likewise.
(vget_low_f32): Likewise.
(vget_low_f64): Likewise.
(vget_low_p8): Likewise.
(vget_low_p16): Likewise.
(vget_low_p64): Likewise.
(vget_low_s8): Likewise.
(vget_low_s16): Likewise.
(vget_low_s32): Likewise.
(vget_low_s64): Likewise.
(vget_low_u8): Likewise.
(vget_low_u16): Likewise.
(vget_low_u32): Likewise.
(vget_low_u64): Likewise.
(vget_low_bf16): Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/pr113573.c: Replace __builtin_aarch64_get_lowv8hi
with vget_low_s16.
* gcc.target/aarch64/vget_low_2.c: New test.
* gcc.target/aarch64/vget_low_2_be.c: New test.

Signed-off-by: Pengxuan Zheng <quic_pzheng@quicinc.com>
14 months agoAArch64: Improve costing of ctz
Wilco Dijkstra [Wed, 17 Apr 2024 16:18:23 +0000 (17:18 +0100)] 
AArch64: Improve costing of ctz

Improve costing of ctz - both TARGET_CSSC and vector cases were not handled yet.

gcc:
* config/aarch64/aarch64.cc (aarch64_rtx_costs): Improve CTZ costing.

14 months agoAArch64: Fix printing of 2-instruction alternatives
Wilco Dijkstra [Thu, 25 Apr 2024 16:33:00 +0000 (17:33 +0100)] 
AArch64: Fix printing of 2-instruction alternatives

Add missing '\' in 2-instruction movsi/di alternatives so that they are
printed on separate lines.

gcc:
* config/aarch64/aarch64.md (movsi_aarch64): Use '\;' to force
newline in 2-instruction pattern.
(movdi_aarch64): Likewise.

14 months agoaarch64: Further renaming of generic code
Ajit Kumar Agarwal [Mon, 20 May 2024 14:51:46 +0000 (09:51 -0500)] 
aarch64: Further renaming of generic code

Renaming of generic code is done to make target independent
and target dependent code to support multiple targets.

Target independent code is the Generic code with pure virtual function
to interface betwwen target independent and dependent code.

Target dependent code is the implementation of pure virtual function for
aarch64 target and the call to target independent code.

2024-05-20  Ajit Kumar Agarwal  <aagarwa1@linux.ibm.com>

gcc/ChangeLog:

* config/aarch64/aarch64-ldp-fusion.cc: Rename generic parts of code
to avoid "ldp" and "stp".

14 months agoMAINTAINERS: Update Joern Rennecke's status
Gerald Pfeifer [Mon, 20 May 2024 14:43:05 +0000 (16:43 +0200)] 
MAINTAINERS: Update Joern Rennecke's status

This is per his mail to gcc@gcc.gnu.org on 7 Jul 2023.

ChangeLog:
* MAINTAINERS: Move Joern Rennecke from arc and epiphany maintainer
to Write After Approval.

14 months agoRegenerate riscv.opt.urls and i386.opt.urls
Mark Wielaard [Mon, 20 May 2024 11:13:02 +0000 (13:13 +0200)] 
Regenerate riscv.opt.urls and i386.opt.urls

risc-v added an -mfence-tso option. i386 removed Xeon Phi ISA support
options. But the opt.urls files weren't regenerated.

Fixes: a6114c2a6911 ("RISC-V: Implement -m{,no}fence-tso")
Fixes: e1a7e2c54d52 ("i386: Remove Xeon Phi ISA support")
gcc/ChangeLog:

* config/riscv/riscv.opt.urls: Regenerate.
* config/i386/i386.opt.urls: Likewise.

14 months agoaarch64: Preparatory patch to place target independent and dependent changed code...
Ajit Kumar Agarwal [Mon, 20 May 2024 09:09:37 +0000 (04:09 -0500)] 
aarch64: Preparatory patch to place target independent and dependent changed code in one file

Common infrastructure of load store pair fusion is divided into target
independent and target dependent changed code.

Target independent code is the Generic code with pure virtual function
to interface betwwen target independent and dependent code.

Target dependent code is the implementation of pure virtual function for
aarch64 target and the call to target independent code.

2024-05-20  Ajit Kumar Agarwal  <aagarwa1@linux.ibm.com>

gcc/ChangeLog:

* config/aarch64/aarch64-ldp-fusion.cc: Factor out a
target-independent interface and move it to the head of the file

14 months agoManually add ChangeLog entry for r15-575-gda73261ce7731be7f2b164f1db796878cdc23365
Jakub Jelinek [Mon, 20 May 2024 07:48:27 +0000 (09:48 +0200)] 
Manually add ChangeLog entry for r15-575-gda73261ce7731be7f2b164f1db796878cdc23365

14 months agoada: Allow 'others' in formal packages with overloaded formals
Bob Duff [Mon, 1 Apr 2024 18:05:14 +0000 (14:05 -0400)] 
ada: Allow 'others' in formal packages with overloaded formals

If a generic package has two or more generic formal parameters with the
same defining name (which can happen only for formal subprograms), then
RM-12.7(4.1/3) disallows named associations in a corresponding formal
package. This is not intended to cover "others => <>".

This patch allows "others => <>" even when it applies to such
formals. Previously, the compiler incorrectly gave an error.

Minor related cleanups involving type Text_Ptr.

gcc/ada/

* sem_ch12.adb: Misc cleanups and comment fixes.
(Check_Overloaded_Formal_Subprogram): Remove the Others_Choice
error message.
(Others_Choice): Remove this variable; no longer needed.
* types.ads (Text_Ptr): Add a range constraint limiting the
subtype to values that are actually used. This has the advantage
that when the compiler is compiled with validity checks,
uninitialized values of subtypes Text_Ptr and Source_Ptr will be
caught.
* sinput.ads (Sloc_Adjust): Use the base subtype; this is used as
an offset, so we need to allow arbitrary negative values.

14 months agoada: Add direct workaround for limitations of RTSfind mechanism
Eric Botcazou [Sat, 30 Mar 2024 22:12:51 +0000 (23:12 +0100)] 
ada: Add direct workaround for limitations of RTSfind mechanism

This adds a direct workaround for the spurious compilation errors caused by
the presence of preconditions/postconditions in the Interfaces.C unit, which
trip on limitations of the RTSfind mechanism when it comes to visibility, as
well as removes an indirect workaround that was added very recently.

These errors were first triggered in the context of finalization and worked
around by preloading the System.Finalization_Primitives unit.  Now they also
appear in the context of tasking, and it turns out that the preloading trick
does not work for separate compilation units.

gcc/ada/

* exp_ch7.ads (Preload_Finalization_Collection): Delete.
* exp_ch7.adb (Allows_Finalization_Collection): Revert change.
(Preload_Finalization_Collection): Delete.
* opt.ads (Interface_Seen): Likewise.
* scng.adb (Scan): Revert latest change.
* sem_ch10.adb: Remove clause for Exp_Ch7.
(Analyze_Compilation_Unit): Revert latest change.
* libgnat/i-c.ads: Use a fully qualified name for the standard "+"
operator in the preconditons/postconditions of subprograms.

14 months agoada: Fix internal error on nested aggregate in conditional expression
Eric Botcazou [Fri, 29 Mar 2024 16:46:43 +0000 (17:46 +0100)] 
ada: Fix internal error on nested aggregate in conditional expression

This plugs a loophole in the change improving code generation for nested
aggregates present in conditional expressions: once the delayed expansion
is chosen for the nested aggregate, the expansion of the parent aggregate
cannot be left to the back-end and the test must be adjusted to implement
this in the presence of conditional expressions too.

gcc/ada/

* exp_aggr.adb (Expand_Record_Aggregate.Component_OK_For_Backend):
Also return False for a delayed conditional expression.

14 months agoada: Get rid of secondary stack for indefinite record types with size clause
Eric Botcazou [Fri, 29 Mar 2024 12:29:54 +0000 (13:29 +0100)] 
ada: Get rid of secondary stack for indefinite record types with size clause

This change eliminates the use of the secondary stack for indefinite record
types for which a valid (object) size clause is specified.  In accordance
with the RM, the compiler accepts (object) size clauses on such types only
if all the components, including those of the variants of the variant part
if any, have a size known at compile time, and only if the clauses specify
a value that is at least as large as the largest possible size of objects
of the types when all the variants are considered.  However, it would still
have used the secondary stack, despite valid (object) size clauses, before
the change, as soon as a variant part was present in the types.

gcc/ada/

* freeze.ads (Check_Compile_Time_Size): Remove obsolete description
of usage for the Size_Known_At_Compile_Time flag.
* freeze.adb (Check_Compile_Time_Size.Size_Known): In the case where
a variant part is present, do not return False if Esize is known.
* sem_util.adb (Needs_Secondary_Stack.Caller_Known_Size_Record): Add
missing "Start of processing" comment.  Return true if either a size
clause or an object size clause has been given for the first subtype
of the type.

14 months agoada: Formal package comment corrections in sinfo.ads
Bob Duff [Fri, 29 Mar 2024 16:17:56 +0000 (12:17 -0400)] 
ada: Formal package comment corrections in sinfo.ads

Misc comment corrections and clarifications in sinfo.ads
related to generic formal packages.

gcc/ada/

* sinfo.ads: Misc comment corrections and clarifications.

The syntax for GENERIC_ASSOCIATION and FORMAL_PACKAGE_ACTUAL_PART
was wrong.

Emphasize that "others => <>" is not represented as an
N_Generic_Association (with or without Box_Present set),
and give examples illustrating the various possibilities.

14 months agoada: Add Is_Base_Type predicate to C interface
Eric Botcazou [Fri, 29 Mar 2024 08:03:28 +0000 (09:03 +0100)] 
ada: Add Is_Base_Type predicate to C interface

This also documents what the predicate effectively does.

gcc/ada/

* einfo-utils.ads (Is_Base_Type): Move to Miscellaneous Subprograms
section and add description.
* fe.h (Is_Base_Type): Declare.

14 months agoada: Error on instantiation of generic containing legal container aggregate
Gary Dismukes [Tue, 26 Mar 2024 22:36:02 +0000 (22:36 +0000)] 
ada: Error on instantiation of generic containing legal container aggregate

When a container aggregate for a predefined container type (such as
a Vector type) that has an iterated component association occurs within
a generic unit and that generic is instantiated, the compiler reports
a spurious error message "iterated component association can only appear
in an array aggregate" and the compilation aborts (because Unrecoverable_Error
is raised unconditionally after that error). The problem is that as part of
the instantiation process, for aggregates whose type has a partial view,
in Copy_Generic_Node the compiler switches the visibility so that the full
view of the type is available, and for a type whose full view is a record
type this leads to incorrectly trying to process the aggregate as a record
aggregate in Resolve_Aggregate (making a call to Resolve_Record_Aggregate).

Rather than trying to address this by changing what Copy_Generic_Node does,
this can be fixed by reordering and adjusting the code in Resolve_Aggregate,
so that we first test whether we need to resolve as a record aggregate
(if the aggregate is not homogeneous), followed by testing whether the
type has an Aggregate aspect and calling Resolve_Container_Aggregate.
As a bonus, we also remove the subsequent complex condition and redundant
code for handling null container aggregates.

gcc/ada/

* sem_aggr.adb (Resolve_Aggregate): Move condition and call for
Resolve_Record_Aggregate in front of code related to calling
Resolve_Container_Aggregate (and add test that the aggregate is
not homogeneous), and remove special-case testing and call to
Resolve_Container_Aggregate for empty aggregates. Also, add error
check for an attempt to use "[]" for an aggregate of a record type
that does not specify an Aggregate aspect.
(Resolve_Record_Aggregate): Remove error check for record
aggregates with "[]" (now done by Resolve_Aggregate).

14 months agoada: Error on instantiation of generic containing legal container aggregate
Gary Dismukes [Tue, 26 Mar 2024 01:01:57 +0000 (01:01 +0000)] 
ada: Error on instantiation of generic containing legal container aggregate

When a container aggregate for a predefined container type (such as
a Vector type) that has an iterated component association occurs within
a generic unit and that generic is instantiated, the compiler reports
a spurious error message "iterated component association can only appear
in an array aggregate" and the compilation aborts (because Unrecoverable_Error
is raised unconditionally after that error). The problem is that as part of
the instantiation process, for aggregates whose type has a partial view,
in Copy_Generic_Node the compiler switches the visibility so that the full
view of the type is available, and for a type whose full view is a record
type this leads to incorrectly trying to process the aggregate as a record
aggregate in Resolve_Aggregate (making a call to Resolve_Record_Aggregate).

Rather than trying to address this by changing what Copy_Generic_Node does,
this can be fixed by reordering and adjusting the code in Resolve_Aggregate,
so that we first test whether we need to resolve as a record aggregate
(if the aggregate is not homogeneous), followed by testing whether the
type has an Aggregate aspect and calling Resolve_Container_Aggregate.
As a bonus, we also remove the subsequent complex condition and redundant
code for handling null container aggregates.

gcc/ada/

* sem_aggr.adb (Resolve_Aggregate): Move condition and call for
Resolve_Record_Aggregate in front of code related to calling
Resolve_Container_Aggregate (and add test that the aggregate
is not homogeneous), and remove special-case testing and call
to Resolve_Container_Aggregate for empty aggregates.

14 months agoada: Handle accessibility calculations for 'First and 'Last
Justin Squirek [Wed, 27 Mar 2024 01:02:41 +0000 (01:02 +0000)] 
ada: Handle accessibility calculations for 'First and 'Last

This patch fixes a crash in the compiler whereby calculating the accessibility
level of of a local variable whose original expression is an 'First on an
array type led to an error during compilation.

gcc/ada/

* accessibility.adb (Accessibility_Level): Add cases for 'First
and 'Last.

14 months agoada: Further refine 'Super attribute
Justin Squirek [Tue, 26 Mar 2024 15:02:58 +0000 (15:02 +0000)] 
ada: Further refine 'Super attribute

This patch relaxes the restriction on 'Super such that it can apply to abstract
type objects.

gcc/ada/

* sem_attr.adb (Analyze_Attribute): Remove restriction on 'Super
for abstract types.

14 months agoada: Fix list of implementation-defined attributes
Piotr Trojanek [Mon, 25 Mar 2024 22:00:13 +0000 (23:00 +0100)] 
ada: Fix list of implementation-defined attributes

Several of the implementation-defined attributes were wrongly recognized
as defined by the Ada RM.

This change only affects code with restriction
No_Implementation_Attributes.

gcc/ada/

* sem_attr.ads (Attribute_Impl_Def): Fix list of
implementation-defined attributes.

14 months agoada: Fix list of attributes defined by Ada 2012
Piotr Trojanek [Mon, 25 Mar 2024 21:52:14 +0000 (22:52 +0100)] 
ada: Fix list of attributes defined by Ada 2012

Recognize references to attributes Old, Overlaps_Storage and Result as
language-defined in Ada 2012 and implementation-defined in earlier
versions of Ada. Other attributes introduced by Ada 2012 RM are
correctly categorized.

This change only affects code with restriction
No_Implementation_Attributes.

gcc/ada/

* sem_attr.adb (Attribute_12): Add attributes Old,
Overlaps_Storage and Result.

14 months agoada: Apply restriction No_Implementation_Attributes to source nodes only
Piotr Trojanek [Mon, 25 Mar 2024 21:49:58 +0000 (22:49 +0100)] 
ada: Apply restriction No_Implementation_Attributes to source nodes only

Restriction No_Implementation_Attributes must not be applied to nodes
that come from expansion. In particular, it must not be applied to
Object_Size, which is implementation-defined attribute before Ada 2022,
but appears in expansion of tagged types since Ada 95.

gcc/ada/

* sem_attr.adb (Analyze_Attribute): Move IF statement that
checks restriction No_Implementation_Attributes for Ada 2005,
2012 and Ada 2022 attributes inside Comes_From_Source condition
that checks the same restriction for Ada 83 attributes.

14 months agoada: Remove repeated condition in check for implementation attributes
Piotr Trojanek [Mon, 25 Mar 2024 21:50:47 +0000 (22:50 +0100)] 
ada: Remove repeated condition in check for implementation attributes

Code cleanup; semantics is unaffected.

gcc/ada/

* sem_attr.adb (Analyze_Attribute): Remove condition that is
already checked by an enclosing IF statement.

14 months agoada: Use discrete choice list in declaration of universal type attributes
Piotr Trojanek [Mon, 25 Mar 2024 22:01:32 +0000 (23:01 +0100)] 
ada: Use discrete choice list in declaration of universal type attributes

Code cleanup.

gcc/ada/

* sem_attr.ads (Universal_Type_Attribute): Simplify using
array aggregate syntax with discrete choice list.

14 months agoada: Fix style in list of implementation-defined attributes
Piotr Trojanek [Mon, 25 Mar 2024 20:47:55 +0000 (21:47 +0100)] 
ada: Fix style in list of implementation-defined attributes

Code cleanup.

gcc/ada/

* sem_attr.ads (Attribute_Impl_Def): Fix style in comment.

14 months agoada: Tweak handling of thread ID on POSIX
Ronan Desplanques [Mon, 25 Mar 2024 13:36:56 +0000 (14:36 +0100)] 
ada: Tweak handling of thread ID on POSIX

This patch changes the task initialization subprograms on POSIX
platforms so that the thread ID of an ATCB is only set once.
This has the advantage of getting rid of the Atomic aspect on
the corresponding record component, and silences a Helgrind
warning about a data race.

gcc/ada/

* libgnarl/s-taprop__linux.adb (Enter_Task): Move setting
of thread ID out of Enter_Task.
(Initialize): Set thread ID for the environment task.
(Create_Task): Remove now unnecessary Unrestricted_Access
attribute and add justification for a memory write.
* libgnarl/s-taprop__posix.adb: Likewise.
* libgnarl/s-taprop__qnx.adb: Likewise.
* libgnarl/s-taprop__rtems.adb: Likewise.
* libgnarl/s-taprop__solaris.adb: Likewise.
* libgnarl/s-taspri__posix.ads: Remove pragma Atomic for
Private_Data.Thread, and update documentation comment.
* libgnarl/s-taspri__lynxos.ads: Likewise.
* libgnarl/s-taspri__posix-noaltstack.ads: Likewise.
* libgnarl/s-taspri__solaris.ads: Likewise.
* libgnarl/s-tporft.adb (Register_Foreign_Thread): Adapt to
Enter_Task not setting the thread ID anymore.
* libgnarl/s-tassta.adb (Task_Wrapper): Update comment.

14 months agoada: Extend expansion delaying mechanism to conditional expressions
Eric Botcazou [Mon, 25 Mar 2024 10:44:21 +0000 (11:44 +0100)] 
ada: Extend expansion delaying mechanism to conditional expressions

When an aggregate that needs to be converted into a series of assignments is
present in an expression of a parent aggregate, or in the expression of an
allocator, an object declaration, or an assignment in very specific cases,
its expansion is delayed until its parent itself is expanded.  This makes
it possible to avoid creating a superfluous temporary for the aggregate.

This change extends the delaying mechanism in the case of record aggregates
to intermediate conditional expressions, that is to say, to the conditional
expressions that are present between the parent and the aggregate, provided
that the aggregate be a dependent expression, directly or recursively.  This
again makes it possible to avoid creating a temporary for the aggregate.

gcc/ada/

* exp_aggr.ads (Is_Delayed_Conditional_Expression): New predicate.
* exp_aggr.adb (Convert_To_Assignments.Known_Size): Likewise.
(Convert_To_Assignments): Climb the parent chain, looking through
qualified expressions and dependent expressions of conditional
expressions, to find out whether the expansion may be delayed.
Call Known_Size for this in the case of an object declaration.
If so, set Expansion_Delayed on the aggregate as well as all the
intermediate conditional expressions.
(Initialize_Component): Reset the Analyzed flag on an initialization
expression that is a conditional expression whose expansion has been
delayed.
(Is_Delayed_Conditional_Expression): New predicate.
* exp_ch3.adb (Expand_N_Object_Declaration): Handle initialization
expressions that are conditional expressions whose expansion has
been delayed.
* exp_ch4.adb (Build_Explicit_Assignment): New procedure.
(Expand_Allocator_Expression): Handle initialization expressions
that are conditional expressions whose expansion has been delayed.
(Expand_N_Case_Expression): Deal with expressions whose expansion
has been delayed by waiting for the rewriting of their parent as
an assignment statement and then optimizing the assignment.
(Expand_N_If_Expression): Likewise.
(Expand_N_Qualified_Expression): Do not apply a predicate check to
an operand that is a delayed aggregate or conditional expression.
* gen_il-gen-gen_nodes.adb (N_If_Expression): Add Expansion_Delayed
semantic flag.
(N_Case_Expression): Likewise.
* sinfo.ads (Expansion_Delayed): Document extended usage.

14 months agoada: Resolve ACATS compilation and execution issues with container aggregates
Gary Dismukes [Mon, 18 Mar 2024 21:16:58 +0000 (21:16 +0000)] 
ada: Resolve ACATS compilation and execution issues with container aggregates

This change set addresses various compilation and execution problems
encountered in the draft ACATS tests for container aggregates:

C435001 (container aggregates with Assign_Indexed)
C435002 (container aggregates with Add_Unnamed)
C435003 (container aggregates with Add_Named)
C435004 (container aggregates with Assign_Indexed and Add_Unnamed)

gcc/ada/

* exp_aggr.adb (Expand_Container_Aggregate): Add top-level
variables Choice_{Lo|Hi} and Int_Choice_{Lo|Hi} used for
determining the low and high bounds of component association
choices. Replace code for determining whether we have an indexed
aggregate with call to new function Sem_Aggr.Is_Indexed_Aggregate.
Remove test of whether Empty_Subp is a function, since it must be
a function. Move Default and Count_Type to be locals of a new
block enclosing the code that creates the object to hold the
aggregate length, and set them according to the default and type
of the Empty function's parameter when present (and to Empty and
Standard_Natural otherwise). Use Siz_Exp for the aggregate length
when set, and use Empty's default length when available, and use
zero for the length otherwise. In generating the call to the
New_Indexed function, use the determined lower and upper bounds if
determined earlier by Aggregate_Size, and otherwise compute those
from the index type's lower bound and the determined aggregate
length. In the case where a call to Empty is generated and the
function has a formal parameter, pass the value saved in Siz_Decl
(otherwise the parameter list is empty). Remove code specific to
making a parameterless call to the Empty function. Extend the code
for handling positional container aggregates to account for types
that define Assign_Indexed, rather than just Add_Unnamed, and in
the case of indexed aggregates, create a temporary object to hold
values of the aggregate's key index, and initialize and increment
that temporary for each call generated to the Assign_Indexed
procedure. For named container aggregates that have key choices
given by ranges, call Expand_Range_Component to generate a loop
that will call the appropriate insertion procedure for each value
of the range. For indexed aggregates with a Component_Associations
list, set and use the Assign_Indexed procedure for each component
association, whether or not there's an iterator specification.
(Add_Range_Size): Add code to determine the low and high bounds of
the range and capture those in up-level variables when their value
is less than or greater than (respectively) the current minimum
and maximum bounds values.
(Aggregate_Size): Separately handle the case where a single choice
is of a discrete type, and call Add_Range_Size to take its value
into consideration for determination of min and max bounds of the
aggregate. Add comments in a couple of places.
(Build_Siz_Exp): Remove the last sentence and "???" from the
comment that talks about accumulating nonstatic sizes, since that
sentence seems to be obsolete. Record the low and high bound
values in Choice_Lo and Choice_Hi in the case of a nonstatic
range.
(Expand_Iterated_Component): Set the Defining_Identifier of the
iterator specification to the Loop_Id in the
N_Iterated_Component_Association case.
(Expand_Range_Component): Procedure unnested from the block
handling indexed aggregates in Expand_Container_Aggregate, and
moved to top level of that procedure so it can also be called for
Add_Named cases. A formal parameter Insert_Op is added, and
existing calls to this procedure are changed to pass the
appropriate insertion procedure's Entity.
* sem_aggr.ads: Add with_clause for Sinfo.Nodes.
(Is_Indexed_Aggregate): New function for use by
Resolve_Container_Aggregate and Expand_Container_Aggregate.
* sem_aggr.adb: Add with_clause for Sem_Ch5. Move with_clause for
Sinfo.Nodes to sem_aggr.ads.
(Is_Indexed_Aggregate): New function to determine whether a
container aggregate is a container aggregate (replacing local
variable of the same name in Resolve_Container_Aggregate).
(Resolve_Iterated_Association): Remove part of comment saying that
a Key_Expression is always present. Set Parent field of the copy
of a component association with a loop parameter specification. On
the setting of Loop_Param_Id, account for a
Loop_Parameter_Specification being changed into an
Iterator_Specification as a result of being analyzed. Only call
Preanalyze_And_Resolve on Key_Expr when a key expression is
actually present. Remove loop for handling choices for the case of
an N_Component_Association with a Defining_Identifier (there
shouldn't be more than one choice in this case, and add an
assertion to ensure that). Also add code here to handle the case
where the choice is a function call, creating an
iterator_specification analyzing it, and call
Resolve_Iterated_Association recursively to process it. Add error
check to enforce RM22 4.3.5(27), which requires that the type of
the loop parameter must be the same as the key type when there is
no key expression and the aggregate is an indexed aggregate or has
an Add_Named op.
(Resolve_Container_Aggregate): In the Add_Unnamed case, call
Resolve_Iterated_Association for both
N_Iterated_Element_Association and N_Component_Association (rather
than just the latter). Remove error check for nonstatic choices in
component associations in Add_Named cases (multiple named
nonstatic associations are fine except in indexed aggregates).
Remove local variable Is_Indexed_Aggregate, replaced with new
library-level function of the same name, and add test of
Is_Indexed_Aggregate in the case where the aggregate type has an
Assign_Indexed operation, as a guard for doing error checks for
indexed aggregates. For indexed aggregate resolution, do not call
Analyze_And_Resolve on the expression of an
N_Component_Association in the "box association" case. Move error
checks for indexed aggregates with iterated associations that flag
cases where an association is a loop_parameter_specification with
an iterator filter or a key expression (violation of RM22
4.3.5(28/5)), from the loop that checks for contiguous and
nonoverlapping choices and into the preceding association loop
after the call to Resolve_Iterated_Association. The RM reference
is added to the error-message strings.

14 months agoada: Fix incorrect free with Task_Info pragma
Ronan Desplanques [Mon, 25 Mar 2024 09:12:17 +0000 (10:12 +0100)] 
ada: Fix incorrect free with Task_Info pragma

Before this patch, on Linux, the procedure
System.Task_Primitives.Operations.Set_Task_Affinity called CPU_FREE on
instances of cpu_set_t_ptr that it didn't own when the obsolescent
Task_Info pragma was in play. This patch fixes that issue.

gcc/ada/

* libgnarl/s-taprop__linux.adb (Set_Task_Affinity): Fix
decision about whether to call CPU_FREE.

14 months agoada: Another small cleanup about allocators and aggregates
Eric Botcazou [Sat, 23 Mar 2024 13:20:14 +0000 (14:20 +0100)] 
ada: Another small cleanup about allocators and aggregates

This eliminates a few more oddities present in the expander for allocators
and aggregates nested in allocators and other constructs:

  - Convert_Aggr_In_Allocator takes both the N_Allocator and the aggregate
    as parameters, while the sibling procedures Convert_Aggr_In_Assignment
    and Convert_Aggr_In_Object_Decl only take the former.  This changes the
    first to be consistent with the two others and propagates the change to
    Convert_Array_Aggr_In_Allocator.

  - Convert_Aggr_In_Object_Decl contains an awkward code structure with a
    useless inner block statement.

  - In_Place_Assign_OK and Convert_To_Assignments have some declarations of
    local variables not in the right place.

No functional changes (presumably).

gcc/ada/

* exp_aggr.ads (Convert_Aggr_In_Allocator): Remove Aggr parameter
and adjust description.
(Convert_Aggr_In_Object_Decl): Adjust description.
* exp_aggr.adb (Convert_Aggr_In_Allocator): Remove Aggr parameter
and add local variable of the same name instead.  Adjust call to
Convert_Array_Aggr_In_Allocator.
(Convert_Aggr_In_Object_Decl): Add comment for early return and
remove useless inner block statement.
(Convert_Array_Aggr_In_Allocator):  Remove Aggr parameter and add
local variable of the same name instead.
(In_Place_Assign_OK): Move down declarations of local variables.
(Convert_To_Assignments): Put all declarations of local variables
in the same place.  Fix typo in comment.  Replace T with Full_Typ.
* exp_ch4.adb (Expand_Allocator_Expression): Call Unqualify instead
of Expression on the qualified expression of the allocator for the
sake of consistency.  Adjust call to Convert_Aggr_In_Allocator.

14 months agoada: Fix static 'Img for enumeration type with Discard_Names
Piotr Trojanek [Fri, 22 Mar 2024 13:50:15 +0000 (14:50 +0100)] 
ada: Fix static 'Img for enumeration type with Discard_Names

Fix a short-circuit folding of 'Img for enumeration type, which wrongly
ignored Discard_Names and exposed enumeration literals.

gcc/ada/

* sem_attr.adb (Eval_Attribute): Handle enumeration type with
Discard_Names.

14 months agoada: Fix for attribute Width on enumeration types with Discard_Name
Piotr Trojanek [Wed, 20 Mar 2024 22:19:35 +0000 (23:19 +0100)] 
ada: Fix for attribute Width on enumeration types with Discard_Name

Fix computation of attribute 'Width for enumeration types with
Discard_Name aspect enabled.

gcc/ada/

* exp_imgv.adb (Expand_Width_Attribute): Fix for 'Width that
is computed at run time.
* sem_attr.adb (Eval_Attribute): Fix for 'Width that is computed
at compilation time.

14 months agoada: Use System.Address for address computation in System.Pool_Global
Sebastian Poeplau [Wed, 20 Mar 2024 10:48:22 +0000 (11:48 +0100)] 
ada: Use System.Address for address computation in System.Pool_Global

Some architectures don't let us convert
System.Storage_Elements.Integer_Address back to a valid System.Address.
Using the arithmetic operations on System.Address from
System.Storage_Elements prevents the problem while leaving semantics
unchanged.

gcc/ada/

* libgnat/s-pooglo.adb (Allocate): Use arithmetic on
System.Address to compute the aligned address.

14 months agoada: Reject too-strict alignment specifications.
Steve Baird [Mon, 18 Mar 2024 21:35:33 +0000 (14:35 -0700)] 
ada: Reject too-strict alignment specifications.

For a discrete (or fixed-point) type T, GNAT requires that T'Object_Size
shall be a multiple of T'Alignment * 8 .
GNAT also requires that T'Object_Size shall be no larger than
Standard'Max_Integer_Size.
For a sufficiently-large alignment specification, these requirements can
conflict.
The conflict is resolved by rejecting such alignment specifications (which
were previously accepted in some cases).

gcc/ada/

* freeze.adb (Adjust_Esize_For_Alignment): Assert that a valid
Alignment specification cannot result in adjusting the given
type's Esize to be larger than System_Max_Integer_Size.
* sem_ch13.adb (Analyze_Attribute_Definition_Clause): In analyzing
an Alignment specification, enforce the rule that a specified
Alignment value for a discrete or fixed-point type shall not be
larger than System_Max_Integer_Size / 8 .

gcc/testsuite/ChangeLog:

* gnat.dg/specs/alignment2.ads: Adjust.
* gnat.dg/specs/alignment2_bis.ads: New test.

14 months agoada: One more adjustment coming from aliasing considerations
Eric Botcazou [Tue, 19 Mar 2024 09:56:34 +0000 (10:56 +0100)] 
ada: One more adjustment coming from aliasing considerations

It is needed on PowerPC platforms because of specific calling conventions.

gcc/ada/

* libgnat/g-sothco.ads (In_Addr): Add aspect Universal_Aliasing.

14 months agoada: Detect only conflict with synomyms of max queue length
Jose Ruiz [Thu, 7 Mar 2024 18:16:18 +0000 (19:16 +0100)] 
ada: Detect only conflict with synomyms of max queue length

Use of duplicated representation aspect is detected elsewhere
so we do not try to detect them here to avoid repetition of
messages.

gcc/ada/

* sem_prag.adb (Analyze_Pragma): Exclude detection of duplicates
because they are detected elsewhere.

14 months agoada: Implement representation aspect Max_Entry_Queue_Length
Jose Ruiz [Thu, 7 Mar 2024 10:20:03 +0000 (11:20 +0100)] 
ada: Implement representation aspect Max_Entry_Queue_Length

Enforce Max_Entry_Queue_Length (and its
synonym Max_Entry_Queue_Depth) when applied to individual
protected entries.

gcc/ada/

* exp_ch9.adb (Expand_N_Protected_Type_Declaration): Clarify
comments.
* sem_prag.adb (Analyze_Pragma): Check for duplicates
Max_Entry_Queue_Length, Max_Entry_Queue_Depth and Max_Queue_Length
for the same protected entry.
* sem_util.adb (Get_Max_Queue_Length): Take into account all three
representation aspects that can be used to set this restriction.
(Has_Max_Queue_Length): Likewise.
* doc/gnat_rm/implementation_defined_pragmas.rst:
(pragma Max_Queue_Length): Fix pragma in example.
* gnat_rm.texi: Regenerate.

14 months agoada: Small cleanup in System.Finalization_Primitives unit
Eric Botcazou [Sat, 16 Mar 2024 18:20:43 +0000 (19:20 +0100)] 
ada: Small cleanup in System.Finalization_Primitives unit

It has been made possible by recent changes.

gcc/ada/

* libgnat/s-finpri.ads (Collection_Node): Move to private part.
(Collection_Node_Ptr): Likewise.
(Header_Alignment): Change to declaration and move completion to
private part.
(Header_Size): Likewise.
(Lock_Type): Delete.
(Finalization_Collection): Move Lock component and remove default
value for Finalization_Started component.
* libgnat/s-finpri.adb (Initialize): Reorder statements.

14 months agoada: Rework and augment documentation on strict aliasing
Eric Botcazou [Wed, 13 Mar 2024 16:05:12 +0000 (17:05 +0100)] 
ada: Rework and augment documentation on strict aliasing

The documentation was originally centered around pragma No_Strict_Aliasing
and pragma Universal_Aliasing was mentioned only as an afterthought.  It
also contained a warning about the usage of overlays implemented by means
of address clauses that has been obsolete for long.

gcc/ada/

* doc/gnat_rm/implementation_defined_pragmas.rst
(Universal_Aliasing): Remove reference to No_Strict_Aliasing.
* doc/gnat_ugn/gnat_and_program_execution.rst
(Optimization and Strict Aliasinng): Simplify first example and
make it more consistent with the second.  Add description of the
effects of pragma Universal_Aliasing and document new warning
issued for unchecked conversions.  Remove obsolete stuff.
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.

14 months agoMIPS: Remove -m(no-)lra option
YunQiang Su [Wed, 15 May 2024 18:30:50 +0000 (02:30 +0800)] 
MIPS: Remove -m(no-)lra option

PR target/113955
The `-mlra` option was introduced in 2014 for MIPS, and was set to
default since then.  It's time for us to drop no-lra support by
dropping -m(no-)lra options.

gcc:
* config/mips/mips.cc(mips_option_override):
Drop mips_lra_flag variable;
(mips_lra_p): Removed.
(TARGET_LRA_P): Remove definition here to use the default one.
* config/mips/mips.md(*mul_acc_si, *mul_acc_si_r3900, *mul_sub_si):
Drop mips_lra_flag variable.
* config/mips/mips.opt(-mlra): Removed.
* config/mips/mips.opt.urls(mlra): Removed.

14 months agoFortran: Fix SHAPE for zero-size arrays
Tobias Burnus [Mon, 20 May 2024 06:34:48 +0000 (08:34 +0200)] 
Fortran: Fix SHAPE for zero-size arrays

PR fortran/115150

gcc/fortran/ChangeLog:

* trans-intrinsic.cc (gfc_conv_intrinsic_bound): Fix SHAPE
for zero-size arrays

gcc/testsuite/ChangeLog:

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

14 months agoFortran: invoke.texi - link to OpenCoarrays.org + mention libcaf_single
Tobias Burnus [Mon, 20 May 2024 06:33:31 +0000 (08:33 +0200)] 
Fortran: invoke.texi - link to OpenCoarrays.org + mention libcaf_single

gcc/fortran/ChangeLog:

* invoke.texi (fcoarray): Link to OpenCoarrays.org;
mention libcaf_single.

14 months agoi386: Remove Xeon Phi ISA support
Haochen Jiang [Mon, 20 May 2024 02:43:44 +0000 (10:43 +0800)] 
i386: Remove Xeon Phi ISA support

gcc/ChangeLog:

* common/config/i386/cpuinfo.h
(get_intel_cpu): Remove Xeon Phi cpus.
(get_available_features): Remove Xeon Phi ISAs.
* common/config/i386/i386-common.cc
(OPTION_MASK_ISA_AVX512PF_SET): Removed.
(OPTION_MASK_ISA_AVX512ER_SET): Ditto.
(OPTION_MASK_ISA2_AVX5124FMAPS_SET): Ditto.
(OPTION_MASK_ISA2_AVX5124VNNIW_SET): Ditto.
(OPTION_MASK_ISA_PREFETCHWT1_SET): Ditto.
(OPTION_MASK_ISA_AVX512F_UNSET): Remove AVX512PF and AVX512ER.
(OPTION_MASK_ISA_AVX512PF_UNSET): Removed.
(OPTION_MASK_ISA_AVX512ER_UNSET): Ditto.
(OPTION_MASK_ISA2_AVX5124FMAPS_UNSET): Ditto.
(OPTION_MASK_ISA2_AVX5124VNNIW_UNSET): Ditto.
(OPTION_MASK_ISA_PREFETCHWT1_UNSET): Ditto.
(OPTION_MASK_ISA2_AVX512F_UNSET): Remove AVX5124FMAPS and
AVX5125VNNIW.
(ix86_handle_option): Remove Xeon Phi options.
(processor_names): Remove Xeon Phi cpus.
(processor_alias_table): Ditto.
* common/config/i386/i386-cpuinfo.h
(enum processor_types): Ditto.
(enum processor_features): Remove Xeon Phi ISAs.
* common/config/i386/i386-isas.h: Ditto.
* config.gcc: Remove Xeon Phi cpus and ISAs.
* config/i386/avx5124fmapsintrin.h: Remove intrin support.
* config/i386/avx5124vnniwintrin.h: Ditto.
* config/i386/avx512erintrin.h: Ditto.
* config/i386/avx512pfintrin.h: Ditto.
* config/i386/cpuid.h (bit_AVX512PF): Removed.
(bit_AVX512ER): Ditto.
(bit_PREFETCHWT1): Ditto.
(bit_AVX5124VNNIW): Ditto.
(bit_AVX5124FMAPS): Ditto.
* config/i386/driver-i386.cc
(host_detect_local_cpu): Remove Xeon Phi.
* config/i386/i386-builtin-types.def: Remove unused types.
* config/i386/i386-builtin.def (BDESC): Remove builtins.
* config/i386/i386-builtins.cc (ix86_init_mmx_sse_builtins): Ditto.
* config/i386/i386-c.cc (ix86_target_macros_internal): Remove Xeon
Phi cpus and ISAs.
* config/i386/i386-expand.cc (ix86_expand_builtin): Remove Xeon Phi
related handlers.
(ix86_emit_swdivsf): Ditto.
(ix86_emit_swsqrtsf): Ditto.
* config/i386/i386-isa.def: Remove Xeon Phi ISAs.
* config/i386/i386-options.cc (m_KNL): Removed.
(m_KNM): Ditto.
(isa2_opts): Remove Xeon Phi ISAs.
(isa_opts): Ditto.
(processor_cost_table): Remove Xeon Phi cpus.
(ix86_valid_target_attribute_inner_p): Remove Xeon Phi ISAs.
(ix86_option_override_internal): Remove Xeon Phi related handlers.
* config/i386/i386-rust.cc (ix86_rust_target_cpu_info): Remove Xeon
Phi ISAs.
* config/i386/i386.cc (ix86_hard_regno_mode_ok): Remove Xeon Phi
related handler.
* config/i386/i386.h (TARGET_EMIT_VZEROUPPER): Removed.
(enum processor_type): Remove Xeon Phi cpus.
* config/i386/i386.md (prefetch): Remove PREFETCHWT1.
(*prefetch_3dnow): Ditto.
(*prefetch_prefetchwt1): Removed.
* config/i386/i386.opt: Remove Xeon Phi ISAs.
* config/i386/immintrin.h: Ditto.
* config/i386/sse.md (VF1_AVX512ER_128_256): Removed.
(rsqrt<mode>2): Change iterator from VF1_AVX512ER_128_256 to
VF1_128_256.
(GATHER_SCATTER_SF_MEM_MODE): Removed.
(avx512pf_gatherpf<mode>sf): Ditto.
(*avx512pf_gatherpf<VI48_512:mode>sf_mask): Ditto.
(avx512pf_gatherpf<mode>df): Ditto.
(*avx512pf_gatherpf<VI4_256_8_512:mode>df_mask): Ditto.
(avx512pf_scatterpf<mode>sf): Ditto.
(*avx512pf_scatterpf<VI48_512:mode>sf_mask): Ditto.
(avx512pf_scatterpf<mode>df): Ditto.
(*avx512pf_scatterpf<VI4_256_8_512:mode>df_mask): Ditto.
(exp2<mode>2): Ditto.
(avx512er_exp2<mode><mask_name><round_saeonly_name>): Ditto.
(<mask_codefor>avx512er_rcp28<mode><mask_name><round_saeonly_name>):
Ditto.
(avx512er_vmrcp28<mode><mask_name><round_saeonly_name>): Ditto.
(<mask_codefor>avx512er_rsqrt28<mode><mask_name><round_saeonly_name>):
Ditto.
(avx512er_vmrsqrt28<mode><mask_name><round_saeonly_name>): Ditto.
(IMOD4): Ditto.
(imod4_narrow): Ditto.
(mov<mode>): Ditto.
(*mov<mode>_internal): Ditto.
(avx5124fmaddps_4fmaddps): Ditto.
(avx5124fmaddps_4fmaddps_mask): Ditto.
(avx5124fmaddps_4fmaddps_maskz): Ditto.
(avx5124fmaddps_4fmaddss): Ditto.
(avx5124fmaddps_4fmaddss_mask): Ditto.
(avx5124fmaddps_4fmaddss_maskz): Ditto.
(avx5124fmaddps_4fnmaddps): Ditto.
(avx5124fmaddps_4fnmaddps_mask): Ditto.
(avx5124fmaddps_4fnmaddps_maskz): Ditto.
(avx5124fmaddps_4fnmaddss): Ditto.
(avx5124fmaddps_4fnmaddss_mask): Ditto.
(avx5124fmaddps_4fnmaddss_maskz): Ditto.
(avx5124vnniw_vp4dpwssd): Ditto.
(avx5124vnniw_vp4dpwssd_mask): Ditto.
(avx5124vnniw_vp4dpwssd_maskz): Ditto.
(avx5124vnniw_vp4dpwssds): Ditto.
(avx5124vnniw_vp4dpwssds_mask): Ditto.
(avx5124vnniw_vp4dpwssds_maskz): Ditto.
* config/i386/x86-tune-sched.cc (ix86_issue_rate): Remove Xeon Phi cpus.
(ix86_adjust_cost): Ditto.
* config/i386/x86-tune.def (X86_TUNE_SCHEDULE): Ditto.
(X86_TUNE_PARTIAL_REG_DEPENDENCY): Ditto.
(X86_TUNE_MOVX): Ditto.
(X86_TUNE_MEMORY_MISMATCH_STALL): Ditto.
(X86_TUNE_ACCUMULATE_OUTGOING_ARGS): Ditto.
(X86_TUNE_FOUR_JUMP_LIMIT): Ditto.
(X86_TUNE_USE_INCDEC): Ditto.
(X86_TUNE_INTEGER_DFMODE_MOVES): Ditto.
(X86_TUNE_OPT_AGU): Ditto.
(X86_TUNE_AVOID_LEA_FOR_ADDR): Ditto.
(X86_TUNE_AVOID_MEM_OPND_FOR_CMOVE): Ditto.
(X86_TUNE_USE_SAHF): Ditto.
(X86_TUNE_USE_CLTD): Ditto.
(X86_TUNE_USE_BT): Ditto.
(X86_TUNE_ONE_IF_CONV_INSN): Ditto.
(X86_TUNE_EXPAND_ABS): Ditto.
(X86_TUNE_USE_SIMODE_FIOP): Ditto.
(X86_TUNE_EXT_80387_CONSTANTS): Ditto.
(X86_TUNE_SSE_UNALIGNED_LOAD_OPTIMAL): Ditto.
(X86_TUNE_SSE_UNALIGNED_STORE_OPTIMAL): Ditto.
(X86_TUNE_SPLIT_MEM_OPND_FOR_FP_CONVERTS): Ditto.
(X86_TUNE_SLOW_PSHUFB): Ditto.
(X86_TUNE_EMIT_VZEROUPPER): Removed.
* config/i386/xmmintrin.h (enum _mm_hint): Remove _MM_HINT_ET1.
* doc/extend.texi: Remove Xeon Phi.
* doc/invoke.texi: Ditto.

gcc/testsuite/ChangeLog:

* g++.dg/other/i386-2.C: Remove Xeon Phi ISAs.
* g++.dg/other/i386-3.C: Ditto.
* g++.target/i386/mv28.C: Ditto.
* gcc.target/i386/builtin_target.c: Ditto.
* gcc.target/i386/sse-12.c: Ditto.
* gcc.target/i386/sse-13.c: Ditto.
* gcc.target/i386/sse-14.c: Ditto.
* gcc.target/i386/sse-22.c: Ditto.
* gcc.target/i386/sse-23.c: Ditto.
* gcc.target/i386/sse-26.c: Ditto.
* gcc.target/i386/avx5124fmadd-v4fmaddps-1.c: Removed.
* gcc.target/i386/avx5124fmadd-v4fmaddps-2.c: Ditto.
* gcc.target/i386/avx5124fmadd-v4fmaddss-1.c: Ditto.
* gcc.target/i386/avx5124fmadd-v4fnmaddps-1.c: Ditto.
* gcc.target/i386/avx5124fmadd-v4fnmaddps-2.c: Ditto.
* gcc.target/i386/avx5124fmadd-v4fnmaddss-1.c: Ditto.
* gcc.target/i386/avx5124vnniw-vp4dpwssd-1.c: Ditto.
* gcc.target/i386/avx5124vnniw-vp4dpwssd-2.c: Ditto.
* gcc.target/i386/avx5124vnniw-vp4dpwssds-1.c: Ditto.
* gcc.target/i386/avx5124vnniw-vp4dpwssds-2.c: Ditto.
* gcc.target/i386/avx512er-check.h: Ditto.
* gcc.target/i386/avx512er-vexp2pd-1.c: Ditto.
* gcc.target/i386/avx512er-vexp2pd-2.c: Ditto.
* gcc.target/i386/avx512er-vexp2ps-1.c: Ditto.
* gcc.target/i386/avx512er-vexp2ps-2.c: Ditto.
* gcc.target/i386/avx512er-vrcp28pd-1.c: Ditto.
* gcc.target/i386/avx512er-vrcp28pd-2.c: Ditto.
* gcc.target/i386/avx512er-vrcp28ps-1.c: Ditto.
* gcc.target/i386/avx512er-vrcp28ps-2.c: Ditto.
* gcc.target/i386/avx512er-vrcp28ps-3.c: Ditto.
* gcc.target/i386/avx512er-vrcp28ps-4.c: Ditto.
* gcc.target/i386/avx512er-vrcp28sd-1.c: Ditto.
* gcc.target/i386/avx512er-vrcp28sd-2.c: Ditto.
* gcc.target/i386/avx512er-vrcp28ss-1.c: Ditto.
* gcc.target/i386/avx512er-vrcp28ss-2.c: Ditto.
* gcc.target/i386/avx512er-vrsqrt28pd-1.c: Ditto.
* gcc.target/i386/avx512er-vrsqrt28pd-2.c: Ditto.
* gcc.target/i386/avx512er-vrsqrt28ps-1.c: Ditto.
* gcc.target/i386/avx512er-vrsqrt28ps-2.c: Ditto.
* gcc.target/i386/avx512er-vrsqrt28ps-3.c: Ditto.
* gcc.target/i386/avx512er-vrsqrt28ps-4.c: Ditto.
* gcc.target/i386/avx512er-vrsqrt28ps-5.c: Ditto.
* gcc.target/i386/avx512er-vrsqrt28ps-6.c: Ditto.
* gcc.target/i386/avx512er-vrsqrt28sd-1.c: Ditto.
* gcc.target/i386/avx512er-vrsqrt28sd-2.c: Ditto.
* gcc.target/i386/avx512er-vrsqrt28ss-1.c: Ditto.
* gcc.target/i386/avx512er-vrsqrt28ss-2.c: Ditto.
* gcc.target/i386/avx512pf-vgatherpf0dpd-1.c: Ditto.
* gcc.target/i386/avx512pf-vgatherpf0dps-1.c: Ditto.
* gcc.target/i386/avx512pf-vgatherpf0qpd-1.c: Ditto.
* gcc.target/i386/avx512pf-vgatherpf0qps-1.c: Ditto.
* gcc.target/i386/avx512pf-vgatherpf1dpd-1.c: Ditto.
* gcc.target/i386/avx512pf-vgatherpf1dps-1.c: Ditto.
* gcc.target/i386/avx512pf-vgatherpf1qpd-1.c: Ditto.
* gcc.target/i386/avx512pf-vgatherpf1qps-1.c: Ditto.
* gcc.target/i386/avx512pf-vscatterpf0dpd-1.c: Ditto.
* gcc.target/i386/avx512pf-vscatterpf0dps-1.c: Ditto.
* gcc.target/i386/avx512pf-vscatterpf0qpd-1.c: Ditto.
* gcc.target/i386/avx512pf-vscatterpf0qps-1.c: Ditto.
* gcc.target/i386/avx512pf-vscatterpf1dpd-1.c: Ditto.
* gcc.target/i386/avx512pf-vscatterpf1dps-1.c: Ditto.
* gcc.target/i386/avx512pf-vscatterpf1qpd-1.c: Ditto.
* gcc.target/i386/avx512pf-vscatterpf1qps-1.c: Ditto.
* gcc.target/i386/pr104448.c: Ditto.
* gcc.target/i386/pr82941-2.c: Ditto.
* gcc.target/i386/pr82942-2.c: Ditto.
* gcc.target/i386/pr82990-1.c: Ditto.
* gcc.target/i386/pr82990-3.c: Ditto.
* gcc.target/i386/pr82990-6.c: Ditto.
* gcc.target/i386/pr82990-7.c: Ditto.
* gcc.target/i386/pr89523-5.c: Ditto.
* gcc.target/i386/pr89523-6.c: Ditto.
* gcc.target/i386/pr91033.c: Ditto.
* gcc.target/i386/prefetchwt1-1.c: Ditto.

14 months agoDSE: Fix ICE after allow vector type in get_stored_val
Pan Li [Tue, 30 Apr 2024 01:42:39 +0000 (09:42 +0800)] 
DSE: Fix ICE after allow vector type in get_stored_val

We allowed vector type for get_stored_val when read is less than or
equal to store in previous.  Unfortunately,  the valididate_subreg
treats the vector type's size is less than vector register as
invalid.  Then we will have ICE here.

This patch would like to fix it by filter-out the invalid type size,
and make sure the subreg is valid for both the read_mode and store_mode
before perform the real gen_lowpart.

The below test suites are passed for this patch:

* The x86 bootstrap test.
* The x86 regression test.
* The riscv rv64gcv regression test.
* The riscv rv64gc regression test.
* The aarch64 regression test.

gcc/ChangeLog:

* dse.cc (get_stored_val): Make sure read_mode/write_mode
is valid subreg before gen_lowpart.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/bug-6.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
14 months agoDaily bump.
GCC Administrator [Mon, 20 May 2024 00:16:30 +0000 (00:16 +0000)] 
Daily bump.

14 months agoDaily bump.
GCC Administrator [Sun, 19 May 2024 18:15:28 +0000 (18:15 +0000)] 
Daily bump.

14 months ago[to-be-committed][RISC-V][PR target/115142] Do not create invalidate shift-add insn
Jeff Law [Sun, 19 May 2024 15:56:16 +0000 (09:56 -0600)] 
[to-be-committed][RISC-V][PR target/115142] Do not create invalidate shift-add insn

The circumstances which triggered this weren't something that should appear in
the wild (-ftree-ter, without optimization enabled).  So I wasn't planning to
backport.  Obviously if it shows up in another context we can revisit that
decision.

I've run this through my rv32gcv and rv64gc tester.  Waiting on the CI system before committing.

PR target/115142
gcc/

* config/riscv/riscv.cc (mem_shadd_or_shadd_rtx_p): Make sure
shifted argument is a register.

gcc/testsuite

* gcc.target/riscv/pr115142.c: New test.

14 months agotestsuite, C++, Darwin: Skip cxa_atexit-6, which is not applicable.
Iain Sandoe [Sat, 11 May 2024 08:24:33 +0000 (09:24 +0100)] 
testsuite, C++, Darwin: Skip cxa_atexit-6, which is not applicable.

For Darwin, non-weak functions defined in a TU always bind locally
and so cxa_atexit-6.C is not applicable here.

PR testsuite/114982

gcc/testsuite/ChangeLog:

* g++.dg/tree-ssa/cxa_atexit-6.C: Skip for Darwin.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
14 months agotestsuite, darwin: Compile a test without unwind frames.
Iain Sandoe [Sun, 5 May 2024 13:13:37 +0000 (14:13 +0100)] 
testsuite, darwin: Compile a test without unwind frames.

In the current Darwin implementation, we do not use .cfi_ insns
and emitted EH frames contain 'coalesced' section designations
which interfere with the scan asm.

gcc/testsuite/ChangeLog:

* gcc.dg/darwin-weakimport-3.c: Suppress unwind frames.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
14 months agoFix oversight in latest change to can_mult_highpart_p
Eric Botcazou [Sun, 19 May 2024 09:38:40 +0000 (11:38 +0200)] 
Fix oversight in latest change to can_mult_highpart_p

gcc/
* optabs-query.cc (can_mult_highpart_p): Test for the existence of
a wider mode instead of requiring it.

14 months agonvptx: Correct pattern for popcountdi2 insn in nvptx.md.
Roger Sayle [Sun, 19 May 2024 08:49:45 +0000 (09:49 +0100)] 
nvptx: Correct pattern for popcountdi2 insn in nvptx.md.

The result of a POPCOUNT operation in RTL should have the same mode
as its operand.  This corrects the specification of popcount in
the nvptx backend, splitting the current generic define_insn into
two, one for popcountsi2 and the other for popcountdi2 (the latter
with an explicit truncate).

2024-05-19  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
* config/nvptx/nvptx.md (popcount<mode>2): Split into...
(popcountsi2): define_insn handling SImode popcount.
(popcountdi2): define_insn handling DImode popcount, with an
explicit truncate:SI to produce an SImode result.

14 months agoRISC-V: Implement -m{,no}fence-tso
Palmer Dabbelt [Sat, 18 May 2024 21:15:09 +0000 (15:15 -0600)] 
RISC-V: Implement -m{,no}fence-tso

Some processors from T-Head don't implement the `fence.tso` instruction
natively and instead trap to firmware.  This breaks some users who
haven't yet updated the firmware and one could imagine it breaking users
who are trying to build firmware if they're using the C memory model.

So just add an option to disable emitting it, in a similar fashion to
how we allow users to forbid other instructions.

Link: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1070959
---
I've just smoke tested this one, but

    void func(void) { __atomic_thread_fence(__ATOMIC_ACQ_REL); }

generates `fence.tso` without the argument and `fence rw,rw` with
`-mno-fence-tso`, so it seems to be at least mostly there.  I figured
I'd just send it up for comments before putting together the DG bits:
it's kind of a pain to carry around these workarounds for unimplemented
instructions, but it's in HW so there's not much we can do about that.

gcc/ChangeLog:

* config/riscv/riscv.opt: Add -mno-fence-tso.
* config/riscv/sync-rvwmo.md (mem_thread_fence_rvwmo): Respect
-mno-fence-tso.
* doc/invoke.texi (RISC-V): Document -mno-fence-tso.

14 months ago[to-be-committed,RISC-V] Improve some shift-add sequences
Jeff Law [Sat, 18 May 2024 21:08:07 +0000 (15:08 -0600)] 
[to-be-committed,RISC-V] Improve some shift-add sequences

So this is a minor fix/improvement for shift-add sequences.  This was
supposed to help xz in a minor way IIRC.

Combine may present us with (x + C2') << C1 which was canonicalized from
(x << C1) + C2.

Depending on the precise values of C2 and C2' one form may be better
than the other.  We can (somewhat awkwardly) use riscv_const_insns to
test for which sequence would be preferred.

Tested on Ventana's CI system as well as my own.  Waiting on CI results
from Rivos's tester before moving forward.

Jeff
gcc/
* config/riscv/riscv.md: Add new patterns to allow selection
between (x << C1) + C2 vs (x + C2') << C1 depending on the
cost C2 vs C2'.

gcc/testsuite

* gcc.target/riscv/shift-add-1.c: New test.