Alexandre Oliva [Wed, 11 Dec 2024 13:16:58 +0000 (10:16 -0300)]
ada: Drop g-cpp* units not needed by the compiler
Having moved __gnat_convert_caught_object to g-cstyin.o, we can drop
other g-cpp* units that are now needed by programs that actually use
their APIs to get more information about C++ exceptions and type_info
objects.
gcc/ada/ChangeLog:
* gcc-interface/Make-lang.in (GNAT_ADA_OBJS, GNATBIND_OBJS):
Drop g-cpp, g-cppexc and g-cppstd.
Eric Botcazou [Tue, 10 Dec 2024 09:24:47 +0000 (10:24 +0100)]
ada: Do not create temporaries for initialization statements
Assignment statements marked with the No_Ctrl_Actions or No_Finalize_Actions
flag are initialization statements and, therefore, no temporaries are needed
to hold the value of the right-hand side for them.
gcc/ada/ChangeLog:
* gcc-interface/trans.cc (Call_to_gnu): Always use the return slot
optimization if the parent node is an initialization statement.
(gnat_to_gnu) <N_Assignment_Statement>: Build an INIT_EXPR instead
of a MODIFY_EXPR if this is an initialization statement.
Eric Botcazou [Fri, 20 Dec 2024 15:49:50 +0000 (16:49 +0100)]
ada: Do not raise exceptions from Exp_Aggr.Packed_Array_Aggregate_Handled
An exception is now raised during bootstrap and this causes compatibility
issues with older compilers.
gcc/ada/ChangeLog:
* exp_aggr.adb (Packed_Array_Aggregate_Handled): Remove declaration
and handler for Not_Handled local exception. Check the return value
of Get_Component_Val instead.
(Get_Component_Val): Return No_Uint instead of raising Not_Handled.
Javier Miranda [Thu, 19 Dec 2024 10:41:59 +0000 (10:41 +0000)]
ada: Cleanup preanalysis of static expressions (part 2)
According to RM 13.14(8/4), a static expression in an aspect specification
does not cause freezing; however, the frontend performs many calls to
Preanalyze_Spec_Expression made during the analysis of aspects. This
patch, suggested by Eric Botcazou, takes care of this additional code
cleanup which requires also replacing many occurrences of the global
variable In_Spec_Expression by calls to Preanalysis_Active.
gcc/ada/ChangeLog:
* exp_util.adb (Insert_Actions): Document behavior under strict
preanalysis.
* sem.ads (In_Strict_Preanalysis): New subprogram.
(Preanalysis_Active): Replace 'and' operator by 'and then'.
* sem.adb (In_Strict_Preanalysis): Ditto.
* sem_attr.adb (Check_Dereference): Replace In_Spec_Expression
occurrence by call to Preanalysis_Active, and document it.
(Resolve_Attribute [Atribute_Access]): Ditto.
(Eval_Attribute): No evaluation under strict preanalysis.
(Validate_Static_Object_Name): No action under strict preanalysis.
* sem_ch13.adb (Check_Aspect_At_End_Of_Declarations): Replace
calls to Preanalyze_Spec_Expression by calls to Preanalyze_And_Resolve.
(Check_Aspect_At_Freeze_Point): Ditto.
(Resolve_Aspect_Expressions [Dynamic/Static/Predicate aspects]): Code
cleanup adjusting the code to emulate Preanalyze_And_Resolve, instead
of Preanalyze_Spec_Expression.
(Resolve_Aspect_Expressions [CPU/Interrupt_Priority/Priority/
Storage_Size aspects]): Replace calls to Preanalyze_Spec_Expression
by call to Preanalyze_And _Resolve.
* sem_ch3.adb (Analyze_Object_Declaration): Replace In_Spec_Expression
occurrence by call to Preanalysis_Active.
(Find_Type_Of_Object): Add documentation.
* sem_ch4.adb (Analyze_Case_Expression): Replace In_Spec_Expression
occurrence by call to Preanalysis_Active.
* sem_ch6.adb (Analyze_Expression_Function): Minor code reorganization
moving the code preanalyzing the expression after the new body has
been inserted in the tree to ensure that its Parent attribute is
available for preanalysis.
* sem_cat.adb (Validate_Static_Object_Name): No action under strict
preanalysis.
* sem_elab.adb (Check_For_Eliminated_Subprogram): Replace In_Spec_Expression
occurrence by call to Preanalysis_Active.
* sem_eval.adb (Eval_Intrinsic_Call [Name_Enclosing_Entity]): Ditto.
* sem_elim.adb (Check_For_Eliminated_Subprogram): Ditto.
* sem_res.adb (Resolve_Entity_Name): Ditto.
Piotr Trojanek [Thu, 19 Dec 2024 23:09:15 +0000 (00:09 +0100)]
ada: Improve protection against wrong use from GDB
A code cleanup in routine intended to be used from DGB, suggested by running
GNATcheck rule Boolean_Negations. However, this code can be tuned to protect
against more illegal uses.
gcc/ada/ChangeLog:
* exp_disp.adb (Write_DT): Add guards that prevent crashes on illegal
node numbers.
Piotr Trojanek [Thu, 19 Dec 2024 14:32:56 +0000 (15:32 +0100)]
ada: Remove dead code in detection of null record definitions
Code cleanup; behavior is unaffected.
gcc/ada/ChangeLog:
* sem_util.adb (Is_Null_Record_Definition): Remove check for
Component_List being present after using it; replace check for
component item being a component declaration with an assertion;
fix style in comment.
This patch fixes two problems with how abort was deferred in finally
parts. First, calls to runtime subprograms are now omitted when
aborting is disallowed by active restrictions. Second, Abort_Undefer is
now correctly called when the finally part propagates an exception.
Steve Baird [Tue, 17 Dec 2024 21:27:04 +0000 (13:27 -0800)]
ada: Improved checking of uses of package renamings
In some cases, the RM 8.5.1(3.1) legality rule about uses of renamings of
limited views of packages was implemented incorrectly, resulting in rejecting
legal uses.
gcc/ada/ChangeLog:
* gen_il-fields.ads: add new Renames_Limited_View field.
* gen_il-gen-gen_entities.adb: add Renames_Limited_View flag for
packages.
* einfo.ads: add comment documenting Renames_Limited_View flag.
* sem_ch8.adb (Analyze_Package_Renaming): Set new Renames_Limited_View
flag. Test new Renames_Limited_View flag instead of calling
Has_Limited_With. If Has_Limited_With is True, that just means
that somebody, sometime during this compilation needed to
reference the limited view of the package; so that function
returns True too often to be used here.
(Find_Expanded_Name): Test new Renames_Limited_View flag instead of
calling Has_Limited_With.
Piotr Trojanek [Tue, 30 Jan 2024 00:10:17 +0000 (01:10 +0100)]
ada: Remove flag Is_Inherited_Pragma which is only set and never used
Code cleanup; behavior is unaffected. Flag Is_Inherited_Pragma is only set in
GNAT, but is not actually used, neither by the compiler nor by any backend.
gcc/ada/ChangeLog:
* contracts.adb (Inherit_Pragma): Don't set flag Is_Inherited_Pragma.
* gen_il-fields.ads (Opt_Field_Enum): Remove field identifier.
* gen_il-gen-gen_nodes.adb (N_Pragma): Remove field from node.
* sinfo.ads (Is_Inherited_Pragma): Remove field description.
(N_Pragma): Remove field reference.
Piotr Trojanek [Tue, 26 Mar 2024 15:23:41 +0000 (16:23 +0100)]
ada: Handle attributes related to Ada 2012 iterators as internal
Use existing machinery for internal attributes to handle attributes
related to Ada 2012 iterators. All these attributes exist exclusively
as a mean to delay processing.
Code cleanup. The only change in behavior is the wording of error
emitted when one of the internal attributes appears in source code:
from "illegal attribute" (which used to be emitted in the analysis)
to "unrecognized attribute (which is emitted by the parser).
gcc/ada/ChangeLog:
* exp_attr.adb (Expand_N_Attribute_Reference): Remove explicit
handling of attributes related to Ada 2012 iterators.
* sem_attr.adb (Analyze_Attribute, Eval_Attribute): Likewise;
move attribute Reduce according to alphabetic order.
* snames.adb-tmpl (Get_Attribute_Id): Add support for new internal
attributes.
* snames.ads-tmpl: Recognize names of new internal attributes.
(Attribute_Id): Recognize new internal attributes.
(Internal_Attribute_Id): Likewise.
(Is_Internal_Attribute_Name): Avoid duplication in comment.
Piotr Trojanek [Thu, 2 Mar 2023 21:43:12 +0000 (22:43 +0100)]
ada: Remove unnecessary qualifiers for First/Next list operations
Code cleanup related to work on expression functions for GNATprove
(which require accessibility checks even when they are not expanded
and thus have no explicit return statements).
gcc/ada/ChangeLog:
* accessibility.adb (First_Selector): Remove redundant and locally
inconsistent parenthesis.
(Check_Return_Construct_Accessibility): Remove qualifier from list
operation.
* sem_util.adb (Is_Prim_Of_Abst_Type_With_Nonstatic_CW_Pre_Post):
Likewise.
Eric Botcazou [Wed, 18 Dec 2024 09:16:15 +0000 (10:16 +0100)]
ada: Fix internal error on container aggregate for bounded vectors
The problem is that we analyze references to an object before the actual
subtype of the object is established, thus creating a type mismatch that
is flagged by the code generator.
gcc/ada/ChangeLog:
* exp_ch7.ads (Store_After_Actions_In_Scope_Without_Analysis): New
procedure declaration.
* exp_ch7.adb (Store_New_Actions_In_Scope): New procedure.
(Store_Actions_In_Scope): Call Store_New_Actions_In_Scope when the
target list is empty.
(Store_After_Actions_In_Scope_Without_Analysis): New procedure body.
* exp_aggr.adb (Expand_Container_Aggregate): For a declaration that
is wrapped in a transient scope, also defer the analysis of the new
code until after the declaration is analyzed.
Eric Botcazou [Tue, 17 Dec 2024 19:00:38 +0000 (20:00 +0100)]
ada: Add guard to System.Val_Real.Large_Powfive against pathological input
There is no need to keep multiplying the result once it saturates to +Inf.
gcc/ada/ChangeLog:
* libgnat/s-powflt.ads (Maxpow_Exact): Minor comment fix.
* libgnat/s-powlfl.ads (Maxpow_Exact): Likewise.
* libgnat/s-powllf.ads (Maxpow_Exact): Likewise.
* libgnat/s-valrea.adb (Large_Powfive) [1 parameter]: Exit the loop
as soon as the result saturates to +Inf.
(Large_Powfive) [2 parameters]: Likewise.
Piotr Trojanek [Mon, 16 Dec 2024 13:15:57 +0000 (14:15 +0100)]
ada: Move checks for consequences of Exceptional_Cases to GNAT
Previously checks for consequence expressions of Exceptional_Cases aspects were
done in GNATprove backend. However, we can do them in the frontend, where they
will apply to all subprograms, regardless of the SPARK_Mode aspect.
gcc/ada/ChangeLog:
* sem_prag.adb (Analyze_Exceptional_Cases_In_Decl_Part): Move check
from GNATprove backend to GNAT frontend.
Piotr Trojanek [Mon, 16 Dec 2024 12:52:43 +0000 (13:52 +0100)]
ada: Fix comments about Subprogram_Variant and Exceptional_Cases
The comment about Subprogram_Variant was outdated after more types have been
allowed by the corresponding SPARK RM rule; the comment about Exceptional_Cases
was incorrect, after being copy-pasted.
Steve Baird [Fri, 13 Dec 2024 01:06:00 +0000 (17:06 -0800)]
ada: Put_Image spec incorrectly ignored for Fixed_Point_Type'Base'Image call.
If a Put_Image aspect specification (introduced in Ada 2022) is given for a
fixed point type Fx, then in some cases a call to Fx'Base'Image would
incorrectly ignore the aspect specification and would instead return the
pre-Ada2022 version of the image. However, a call to Fx'Image would do the
right thing.
gcc/ada/ChangeLog:
* exp_put_image.adb (Image_Should_Call_Put_Image): Cope with the case
where the attribute prefix for an Image attribute reference
denotes an Itype constructed for a fixed point type. Calling
Has_Aspect with such an Itype misses applicable aspect
specifications; we need to look on the right list. This comes up
if the prefix of the attribute reference is
Some_Fixed_Point_Type'Base.
Gary Dismukes [Fri, 13 Dec 2024 23:36:05 +0000 (23:36 +0000)]
ada: Error on instantiation with defaulted formal type referencing other formal type
The compiler wasn't accounting for default subtypes on generic formal types
that reference other formal types of the same generic, leading to errors
about invalid subtypes. Several other problems that could lead to blowups
or incorrect errors were noticed through testing related cases and fixed
along the way.
gcc/ada/ChangeLog:
* sem_ch12.adb (Analyze_One_Association): In the case of a formal type
that has a Default_Subtype_Mark that does not have its Entity field set,
this means the default refers to another formal type of the same generic
formal part, so locate the matching subtype in the Result_Renamings and
set Match's Entity to that subtype prior to the call to Instantiate_Type.
(Validate_Formal_TypeDefault.Reference_Formal): Add test of Entity being
Present, to prevent blowups on End_Label ids (which don't have Entity set).
(Validate_Formal_Type_Default.Validate_Derived_Type_Default): Apply
Base_Type to Formal.
(Validate_Formal_Type_Default): Guard interface-related semantic checks
with a test of Is_Tagged_Type.
Eric Botcazou [Mon, 16 Dec 2024 07:59:26 +0000 (08:59 +0100)]
ada: Restrict previous change made to expansion of allocators
There is no need to build a cleanup if exceptions cannot be propagated.
gcc/ada/ChangeLog:
* exp_ch4.adb (Expand_Allocator_Expression): Do not build a cleanup
if restriction No_Exception_Propagation is active.
* exp_ch6.adb (Make_Build_In_Place_Call_In_Allocator): Likewise.
Deng Jianbo [Tue, 31 Dec 2024 11:33:23 +0000 (19:33 +0800)]
LoongArch: Optimize initializing fp resgister to zero
In LoongArch, currently uses instruction movgr2fr.{d|w} to move zero
from fixed-point register to floating-pointer regsiter for initializing
fp register to zero. When LSX or LASX is enabled, we can use instruction
vxor.v which has lower latency than instruction movgr2fr.{d|w} to set fp
register to zero directly.
gcc/ChangeLog:
* config/loongarch/loongarch.cc (loongarch_output_move):
Optimize instructions for initializing fp regsiter to zero.
gcc/testsuite/ChangeLog:
* gcc.target/loongarch/mov-zero-1.c: New test.
* gcc.target/loongarch/mov-zero-2.c: New test.
Gaius Mulley [Tue, 7 Jan 2025 11:20:45 +0000 (11:20 +0000)]
[PR modula2/118010, modula2/118183] Unable to rebuild the bootstrap tools and Wtypemismatch
This patch combines fixes for both PR-118010 (Wtypemismatch) and PR-118183
(unable to rebuild the bootstrap tools). PR-118010 required a new data
type (COFF_T) to be exported from SYSTEM and used in all return
types for libc.lseek. The patch also includes COFF_T implemented in mc
and this data type has been propagated though the translated versions
of pge and mc. Finally the patch adjusts the modula-2 declaration of
location_t to reflect the new gcc 64 bit type.
A new command line option -fm2-file-offset-bits= has been implemented to
override the default 64 bit declaration of COFF_T.
gcc/ChangeLog:
PR modula2/118010
* doc/gm2.texi (Compiler options): New option
-fm2-file-offset-bits=.
Fortran: Extend cylic type detection for deallocate [PR116669]
Using cycles in derived/class types lead to the compiler doing a endless
recursion in several locations, when the cycle was not immediate.
An immediate cyclic dependency is present in, for example T T::comp.
Cylcic dependencies of the form T T2::comp; T2 T::comp2; are now
detected and the recursive bit in the derived type's attr is set.
gcc/fortran/ChangeLog:
PR fortran/116669
* class.cc (gfc_find_derived_vtab): Use attr to determine cyclic
type dependendies.
* expr.cc (gfc_has_default_initializer): Prevent endless
recursion by storing already visited derived types.
* resolve.cc (resolve_cyclic_derived_type): Determine if a type
is used in its hierarchy in a cyclic way.
(resolve_fl_derived0): Call resolve_cyclic_derived_type.
(resolve_fl_derived): Ensure vtab is generated when cyclic
derived types have allocatable components.
* trans-array.cc (structure_alloc_comps): Prevent endless loop
for derived type cycles.
* trans-expr.cc (gfc_get_ultimate_alloc_ptr_comps_caf_token):
Off topic, just prevent memory leaks.
gcc/testsuite/ChangeLog:
* gfortran.dg/class_array_15.f03: Freeing more memory.
* gfortran.dg/recursive_alloc_comp_6.f90: New test.
This patch removes the AARCH64_EXTRA_TUNE_USE_NEW_VECTOR_COSTS tunable and
use_new_vector_costs entry in aarch64-tuning-flags.def and makes the
AARCH64_EXTRA_TUNE_USE_NEW_VECTOR_COSTS paths in the backend the
default. To that end, the function aarch64_use_new_vector_costs_p and its uses
were removed. To prevent costing vec_to_scalar operations with 0, as
described in
https://gcc.gnu.org/pipermail/gcc-patches/2024-October/665481.html,
we adjusted vectorizable_store such that the variable n_adjacent_stores
also covers vec_to_scalar operations. This way vec_to_scalar operations
are not costed individually, but as a group.
As suggested by Richard Sandiford, the "known_ne" in the multilane-check
was replaced by "maybe_ne" in order to treat nunits==1+1X as a vector
rather than a scalar.
Two tests were adjusted due to changes in codegen. In both cases, the
old code performed loop unrolling once, but the new code does not:
Example from gcc.target/aarch64/sve/strided_load_2.c (compiled with
-O2 -ftree-vectorize -march=armv8.2-a+sve -mtune=generic -moverride=tune=none):
f_int64_t_32:
cbz w3, .L92
mov x4, 0
uxtw x3, w3
+ cntd x5
+ whilelo p7.d, xzr, x3
+ mov z29.s, w5
mov z31.s, w2
- whilelo p6.d, xzr, x3
- mov x2, x3
- index z30.s, #0, #1
- uqdecd x2
- ptrue p5.b, all
- whilelo p7.d, xzr, x2
+ index z30.d, #0, #1
+ ptrue p6.b, all
.p2align 3,,7
.L94:
- ld1d z27.d, p7/z, [x0, #1, mul vl]
- ld1d z28.d, p6/z, [x0]
- movprfx z29, z31
- mul z29.s, p5/m, z29.s, z30.s
- incw x4
- uunpklo z0.d, z29.s
- uunpkhi z29.d, z29.s
- ld1d z25.d, p6/z, [x1, z0.d, lsl 3]
- ld1d z26.d, p7/z, [x1, z29.d, lsl 3]
- add z25.d, z28.d, z25.d
+ ld1d z27.d, p7/z, [x0, x4, lsl 3]
+ movprfx z28, z31
+ mul z28.s, p6/m, z28.s, z30.s
+ ld1d z26.d, p7/z, [x1, z28.d, uxtw 3]
add z26.d, z27.d, z26.d
- st1d z26.d, p7, [x0, #1, mul vl]
- whilelo p7.d, x4, x2
- st1d z25.d, p6, [x0]
- incw z30.s
- incb x0, all, mul #2
- whilelo p6.d, x4, x3
+ st1d z26.d, p7, [x0, x4, lsl 3]
+ add z30.s, z30.s, z29.s
+ incd x4
+ whilelo p7.d, x4, x3
b.any .L94
.L92:
ret
Alexandre Oliva [Fri, 20 Dec 2024 21:02:08 +0000 (18:02 -0300)]
expand: drop stack adjustments after barrier [PR118006]
A gimple block with __builtin_unreachable () can't have code after it,
and gimple optimizers ensure there isn't any, even without
optimization. But if the block requires stack adjustments,
e.g. because of a call that passes arguments on the stack, expand will
emit that after the barrier, and then rtl checkers rightfully
complain. Arrange to discard adjustments after a barrier.
Strub expanders seem to be necessary to bring about the exact
conditions that require stack adjustments after the block that ends
with a __builtin_unreachable call.
for gcc/ChangeLog
PR middle-end/118006
* cfgexpand.cc (expand_gimple_basic_block): Do not emit
pending stack adjustments after a barrier.
Akram Ahmad [Mon, 6 Jan 2025 20:09:30 +0000 (20:09 +0000)]
aarch64: remove extra XTN in vector concatenation
GIMPLE code which performs a narrowing truncation on the result of a
vector concatenation currently results in an unnecessary XTN being
emitted following a UZP1 to concate the operands. In cases such as this,
UZP1 should instead use a smaller arrangement specifier to replace the
XTN instruction. This is seen in cases such as in this GIMPLE example:
int32x2_t foo (svint64_t a, svint64_t b)
{
vector(2) int vect__2.8;
long int _1;
long int _3;
vector(2) long int _12;
bar:
ptrue p3.b, all
uaddv d0, p3, z0.d
uaddv d1, p3, z1.d
uzp1 v0.2d, v0.2d, v1.2d
xtn v0.2s, v0.2d
ret
This patch therefore defines the *aarch64_trunc_concat<mode> insn which
truncates the concatenation result, rather than concatenating the
truncated operands (such as in *aarch64_narrow_trunc<mode>), resulting
in the following optimised assembly being emitted:
bar:
ptrue p3.b, all
uaddv d0, p3, z0.d
uaddv d1, p3, z1.d
uzp1 v0.2s, v0.2s, v1.2s
ret
This patch passes all regression tests on aarch64 with no new failures.
A supporting test for this optimisation is also written and passes.
OK for master? I do not have commit rights so I cannot push the patch
myself.
gcc/ChangeLog:
* config/aarch64/aarch64-simd.md: (*aarch64_trunc_concat)
new insn definition.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/sve/truncated_concatenation_1.c: new test
for the above example and other modes covered by insn
definitions.
```
In file included from /gcc/src/libsanitizer/interception/interception.h:18,
from /gcc/src/libsanitizer/interception/interception_type_test.cpp:14:
/gcc/src/libsanitizer/interception/interception_type_test.cpp:30:61: error: static assertion failed
30 | COMPILER_CHECK((__sanitizer::is_same<::SSIZE_T, ::ssize_t>::value));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
/gcc/src/libsanitizer/sanitizer_common/sanitizer_internal_defs.h:363:44: note: in definition of macro 'COMPILER_CHECK'
363 | #define COMPILER_CHECK(pred) static_assert(pred, "")
| ^~~~
make[8]: *** [Makefile:469: interception_type_test.lo] Error 1
```
The culprit seems to be that we don't check for equality of type sizes
anymore but rather whether the types are indeed the same. On s390 -m31
we have that `sizeof(int)==sizeof(long)` holds which is why previously
the checks succeeded. They fail now because
```
size_t => unsigned long
ssize_t => long
ptrdiff_t => int
::SSIZE_T => __sanitizer::sptr => int
::PTRDIFF_T => __sanitizer::sptr => int
```
This is fixed by mapping `SSIZE_T` to `long` in the end.
For some targets uptr is mapped to unsigned int and size_t to unsigned
long and sizeof(int)==sizeof(long) holds. Still, these are distinct
types and type checking may fail. Therefore, replace uptr by
usize/SIZE_T wherever a size_t is expected.
Stafford Horne [Mon, 6 Jan 2025 12:12:40 +0000 (12:12 +0000)]
or1k: add .note.GNU-stack section on linux
In the OpenRISC build we get the following warning:
ld: warning: __modsi3_s.o: missing .note.GNU-stack section implies executable stack
ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
Fix this by adding a .note.GNU-stack to indicate the stack does not need to be
executable for the lib1funcs.
Note, this is also needed for the upcoming glibc 2.41.
libgcc/
* config/or1k/lib1funcs.S: Add .note.GNU-stack section on linux.
SVE intrinsics: Fold svmul by -1 to svneg for unsigned types
As follow-up to
https://gcc.gnu.org/pipermail/gcc-patches/2024-October/665472.html,
this patch implements folding of svmul by -1 to svneg for
unsigned SVE vector types. The key idea is to reuse the existing code that
does this fold for signed types and feed it as callback to a helper function
that adds the necessary type conversions.
For example, for the test case
svuint64_t foo (svuint64_t x, svbool_t pg)
{
return svmul_n_u64_x (pg, x, -1);
}
the following gimple sequence is emitted (-O2 -mcpu=grace):
svuint64_t foo (svuint64_t x, svbool_t pg)
{
svint64_t D.12921;
svint64_t D.12920;
svuint64_t D.12919;
In general, the new helper gimple_folder::convert_and_fold
- takes a target type and a function pointer,
- converts the lhs and all non-boolean vector types to the target type,
- passes the converted lhs and arguments to the callback,
- receives the new gimple statement from the callback function,
- adds the necessary view converts to the gimple sequence,
- and returns the new call.
Because all arguments are converted to the same target types, the helper
function is only suitable for folding calls whose arguments are all of
the same type. If necessary, this could be extended to convert the
arguments to different types differentially.
The patch was bootstrapped and tested on aarch64-linux-gnu, no regression.
OK for mainline?
Signed-off-by: Jennifer Schmitz <jschmitz@nvidia.com>
gcc/ChangeLog:
* config/aarch64/aarch64-sve-builtins-base.cc
(svmul_impl::fold): Wrap code for folding to svneg in lambda
function and pass to gimple_folder::convert_and_fold to enable
the transform for unsigned types.
* config/aarch64/aarch64-sve-builtins.cc
(gimple_folder::convert_and_fold): New function that converts
operands to target type before calling callback function, adding the
necessary conversion statements.
(gimple_folder::redirect_call): Set fntype of redirected call.
(get_vector_type): Move from here to aarch64-sve-builtins.h.
* config/aarch64/aarch64-sve-builtins.h
(gimple_folder::convert_and_fold): Declare function.
(get_vector_type): Move here as inline function.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/sve/acle/asm/mul_u8.c: Adjust expected outcome.
* gcc.target/aarch64/sve/acle/asm/mul_u16.c: Likewise.
* gcc.target/aarch64/sve/acle/asm/mul_u32.c: Likewise.
* gcc.target/aarch64/sve/acle/asm/mul_u64.c: New test and adjust
expected outcome.
Martin Jambor [Mon, 6 Jan 2025 10:58:29 +0000 (11:58 +0100)]
ipa-cp: Make dumping of bit masks representing -1 nicer
Dumps of the lattices representing bit-values and of propagation
results of bit-values can print a really long hexadecimal value when
the bit-value represents -1 (all bits set). This patch simply detect
that situation and prints the string "-1" in that case, making the
dumps somewhat nicer.
gcc/ChangeLog:
2025-01-03 Martin Jambor <mjambor@suse.cz>
* ipa-cp.cc (ipcp_print_widest_int): New function.
(ipcp_store_vr_results): Use it.
(ipcp_bits_lattice::print): Likewise. Fix formatting.
Mark Wielaard [Sun, 5 Jan 2025 17:00:36 +0000 (18:00 +0100)]
tree-switch-conversion: don't apply switch size limit on jump tables
commit 56946c801a7c ("gimple: Add limit after which slower switchlower
algs are used [PR117091] [PR117352]") introduced a limit on the number
of cases of a switch. It also bails out on finding jump tables if the
switch is too large. This introduces a compile time regression during
bootstrap. A riscv bootstrap takes hours longer. Particularly
insn-attrtab.cc will take hours instead of minutes. Fix this by not
applying the switch size limit on jump tables.
An alternative would be to implement greedy switch clustering for jump
tables as is done for switch bitmap clustering.
Tamar Christina [Mon, 6 Jan 2025 09:24:36 +0000 (09:24 +0000)]
AArch64: Implement four and eight chunk VLA concats [PR118272]
The following testcase
#pragma GCC target ("+sve")
extern char __attribute__ ((simd, const)) fn3 (int, short);
void test_fn3 (float *a, float *b, double *c, int n)
{
for (int i = 0; i < n; ++i)
a[i] = fn3 (b[i], c[i]);
}
at -Ofast ICEs because my previous patch only added support for combining 2
partial SVE vectors into a bigger vector. However There can also 4 and 8
piece subvectors.
This patch fixes this by implementing the missing expansions.
gcc/ChangeLog:
PR target/96342
PR target/118272
* config/aarch64/aarch64-sve.md (vec_init<mode><Vquad>,
vec_initvnx16qivnx2qi): New.
* config/aarch64/aarch64.cc (aarch64_sve_expand_vector_init_subvector):
Rewrite to support any arbitrary combinations.
* config/aarch64/iterators.md (SVE_NO2E): Update to use SVE_NO4E
(SVE_NO2E, Vquad): New.
gcc/testsuite/ChangeLog:
PR target/96342
PR target/118272
* gcc.target/aarch64/vect-simd-clone-3.c: New test.
Eric Botcazou [Fri, 13 Dec 2024 18:17:00 +0000 (19:17 +0100)]
ada: Streamline runtime support of finalization collections
Finalization collections are declared as (limited) controlled types so that
they can be naturally attached to a finalization master, but the same result
can be achieved by means of (limited) finalizable types, which need not be
tagged and thus avoid dragging the runtime support of tagged types.
gcc/ada/ChangeLog:
* libgnat/s-finpri.ads: Remove clause for Ada.Finalization.
(Finalization_Collection): Change to limited private type with the
Finalizable aspect.
(Initialize): Remove "overriding" keyword.
(Finalize): Likewise.
* libgnat/s-finpri.adb (Initialize): Likewise.
(Finalize): Likewise.
Eric Botcazou [Thu, 12 Dec 2024 22:08:30 +0000 (23:08 +0100)]
ada: Fix predicate involving array indexing rejected in generic package
The indexing is rejected with the message:
error: reference to current instance of type does not denote a type
when it is applied to a prefix which is the current instance of the type
to which the predicate is applied.
There is already a specific handling of component selection for this case
present in Find_Selected_Component, so this adds an equivalent specific
handling of indexing for this case to Analyze_Indexed_Component_Form.
gcc/ada/ChangeLog:
PR ada/117569
* sem_ch4.adb (Analyze_Indexed_Component_Form): Do not rewrite the
node as a type conversion if it is the current instance of a type
in a generic unit.
* sem_ch8.adb (Find_Selected_Component): Restrict the special case
of the current instance of a type to a generic unit.
Alexandre Oliva [Tue, 10 Dec 2024 12:06:57 +0000 (09:06 -0300)]
ada: Reduce footprint of C++ exception interoperation support
The initial C++ base-type exception interoperation support change
brought all of GNAT.CPP* along with raise-gcc, because of
[__gnat_]Convert_Caught_Object. Move that private but pragma-exported
function to GNAT.CPP.Std.Type_Info, so that it can rely on the C++
virtual/dispatch calls that justified the introduction of the Ada
wrapper type, to avoid emulating virtual calls in C or bringing in a
dependency on the C++ compiler and runtime.
Drop the CharPtr package instantiation, that brought a huge amount of
unnecessary code, and use string and storage primitives instead, using
the strcmp builtin directly for the C string compares.
Move the conversion to Ada String in Name to the wrapper interface in
GNAT.CPP.Std, adjusting the private internal type to shave off a few
more bytes from the only unit that raise-gcc will still need.
Finally, disable heap finalization for Type_Info_Ptr, to avoid
dragging in all of the finalization code. Thank to Eric Botcazou for
the suggestion.
gcc/ada/ChangeLog:
* libgnat/g-cppexc.adb (Convert_Caught_Object): Move...
* libgnat/g-cstyin.adb (Convert_Caught_Object): ... here.
Use object call notation.
(strcmp): New.
(Char_Arr, CharPtr, Char_Pointer, To_chars_ptr): Drop. Do not
import Interfaces.C.Pointers.
(To_Pointer): Convert from System.Address.
(Name_Starts_With_Asterisk): Rename local variable.
(Name_Past_Asterisk): Rewrite with System.Address and strcmp.
Import System.Storage_Elements.
(Equals): Use strcmp.
(Before): Fix logic error. Use strcmp.
(Name): Move conversion to String...
* libgnat/g-cppstd.adb (Name): ... here. Import
Interfaces.C.Strings.
* libgnat/g-cppstd.ads (Type_Info_Ptr): Disable heap
finalization.
* libgnat/g-cstyin.ads (Name): Change return type.
Claire Dross [Mon, 2 Dec 2024 16:14:47 +0000 (17:14 +0100)]
ada: Support new SPARK aspect Exit_Cases
The aspect Exit_Cases allows annotating a subprogram with a list of
cases specifying, for all input which satisfy a guard, how the
subprogram is allowed to terminate. For now, it can only be either
returning normally or propagating an exception. This contract is not
checked at runtime, it is only meant for static verification in SPARK.
gcc/ada/ChangeLog:
* aspects.ads: Add aspect Aspect_Exit_Cases.
* contracts.adb (Analyze_Entry_Or_Subprogram_Contract): Handle Exit_Cases.
(Expand_Subprogram_Contract): Idem.
* einfo-utils.adb (Get_Pragma): Allow Pragma_Exit_Cases.
* einfo-utils.ads (Get_Pragma): Idem.
* exp_prag.adb (Expand_Pragma_Exit_Cases): Ignore the pragma, currently we don't expand it.
* exp_prag.ads (Expand_Pragma_Exit_Cases): Idem.
* inline.adb (Remove_Aspects_And_Pragmas): Add Exit_Cases to the list.
(Remove_Items): Idem.
* par-prag.adb (Last_Arg_Is_Reason): Idem.
* sem_ch12.adb: Idem.
* sem_ch13.adb: Idem.
* sem_util.adb: Idem.
* sem_util.ads: Idem.
* sinfo.ads: Idem.
* snames.ads-tmpl: Add names Name_Exit_Cases, Name_Exception_Raised, and Name_Normal_Return
as well as pragma Pragma_Exit_Cases.
* sem_prag.adb (Analyze_Exit_Cases_In_Decl_Part): Make sure that a
pragma or aspect Exit_Cases is well formed.
(Analyze_Pragma): Make sure that a pragma or aspect Exit_Cases is at the right place.
* sem_prag.ads (Analyze_Exit_Cases_In_Decl_Part): Declaration.
* doc/gnat_rm/implementation_defined_pragmas.rst: Document the Exit_Cases pragma.
* doc/gnat_rm/implementation_defined_aspects.rst: Document the Exit_Cases aspect.
* gnat_rm.texi: Regenerate.
Bob Duff [Thu, 12 Dec 2024 14:13:16 +0000 (09:13 -0500)]
ada: Correct xref of operator expression function body
For an expression function body that is an operator,
make sure the xref entry in the ALI file points one past the
double quote mark. For example, if the name is ">", point
to the greater-than symbol, not the double quote.
This was already the case for proper bodies.
gcc/ada/ChangeLog:
* sem_util.adb (Copy_Subprogram_Spec): When copying
an N_Defining_Operator_Symbol, create an
N_Defining_Operator_Symbol rather than an N_Defining_Identifier.
This will cause Lib.Xref to "skip the initial quote for
navigation purposes" (as per comments in Lib.Xref body).
Eric Botcazou [Tue, 10 Dec 2024 18:43:14 +0000 (19:43 +0100)]
ada: Fix memory leak when failing to initialize newly allocated memory
This makes the compiler generate cleanup code to deallocate the memory when
the evaluation of the expression of an allocator raises an exception, if the
expression is a call to a function that may raise, i.e. is not declared with
the No_Raise aspect/pragma. This can also be disabled by means of -gnatdQ.
gcc/ada/ChangeLog:
* debug.adb (dQ): Document usage.
* exp_ch4.ads (Build_Cleanup_For_Allocator): New declaration.
* exp_ch4.adb (Build_Cleanup_For_Allocator): New procedure.
(Expand_Allocator_Expression): Build a cleanup to deallocate the
memory when the evaluation of the expression raises an exception.
* exp_ch6.adb (Make_Build_In_Place_Call_In_Allocator): Likewise.
* exp_util.adb (Build_Allocate_Deallocate_Proc): Do not generate the
detachment if the deallocation is for the cleanup of an allocator.
* gen_il-fields.ads (Opt_Field_Enum): Add For_Allocator.
* gen_il-gen-gen_nodes.adb (N_Free_Statement): Likewise.
* sinfo.ads (For_Allocator): Document usage on N_Free_Statement.
Piotr Trojanek [Tue, 10 Dec 2024 15:42:46 +0000 (16:42 +0100)]
ada: Fix crash on Depends contract with homonym functions
When resolving names in flow contracts, we refine the ordinary analysis by
knowing that an overloaded name must refer to an abstract state and not a
function. However, when all overloadings refer to function, we shouldn't
crash, but instead let the error to be diagnosed later.
Javier Miranda [Tue, 10 Dec 2024 19:49:15 +0000 (19:49 +0000)]
ada: Crash in prefix notation with access to class-wide object
The compiler crashes analyzing a prefix notation call when its
prefix is an access to a class-wide object, an actual parameter
is missing, and the sources are compiled with language extensions
(-gnatX) and full errors (-gnatf).
gcc/ada/ChangeLog:
* sem_ch4.adb (Try_Object_Operation): if no candidate interpretation
matches the context, redo the same analysis with Report_Error True
to report the error.
Eric Botcazou [Tue, 10 Dec 2024 16:53:34 +0000 (17:53 +0100)]
ada: Plug small loophole in previous change
The initial change only deals with the controlled record case for assignment
statements, but the controlled array case needs the same treatment.
gcc/ada/ChangeLog:
* exp_ch5.adb (Expand_Assign_Array): Bail out for controlled
components if the RHS is a function call and the assignment has
the No_Ctrl_Actions flag set.
Viljar Indus [Tue, 26 Nov 2024 12:10:46 +0000 (14:10 +0200)]
ada: Fix printing boolean attributes in the SARIF report
Boolean attributes should have the value true or false
without any quotes.
gcc/ada/ChangeLog:
* diagnostics-json_utils.adb: Add new method
Write_Boolean_Attribute.
* diagnostics-json_utils.ads: Likewise.
* diagnostics-sarif_emitter.adb (Print_Invocations): print
the executionSuccesful property value without extra quotes.
Viljar Indus [Thu, 28 Nov 2024 10:44:37 +0000 (12:44 +0200)]
ada: Remove level attribute from Rules in the SARIF report
A Rule object in the SARIF report does not have a level
attribute. Result objects are the elements in the SARIF
reprot that have a level attribute that ultimately determines
the level of each diagnostic object.
Rules can have a defaultConfiguration attribute which has a level
attribute that can be overridden in multiple ways. This can make
the overall report more complex than it needs to be. It is simpler
to remove the attribute from rules where it does not really matter
and add it back in under the defaultConfiguration when there is an
explicit need for it.
gcc/ada/ChangeLog:
* diagnostics-sarif_emitter.adb (Print_Rule): Remove printing
of the level attribute since it does not match the SARIF schema.
Piotr Trojanek [Wed, 27 Sep 2023 10:19:53 +0000 (12:19 +0200)]
ada: Avoid null-exclusion checks for Node_Field_Table
By generating the type of Node_Field_Table with a "not null" qualifier
we check the null exclusion of its elements only once, at the object
declaration.
Tiny performance improvement for the debug builds (because in production
builds checks are disabled anyway); semantics is unaffected.
gcc/ada/ChangeLog:
* gen_il-gen.adb (Put_Tables): Add "not null" to the generated code.
* rtsfind.adb (Cstring_Ptr): Same for table with predefined RE_Id
error messages.
* impunit.adb (Aunit_Record): Same for array of alternative unit names.
Bob Duff [Mon, 9 Dec 2024 17:20:34 +0000 (12:20 -0500)]
ada: null procedure cannot be used as compilation unit
This patch gives a syntax error if a null procedure is used as
a compilation unit. The error was already given during semantic
analysis; now it is given in the parser, which is more convenient
for other tools like gprbuild, because the -gnats switch now
gives the error.
Note that the old message "null procedure cannot be declared at library
level" was wrong; "library level" is not the same thing as "is a library
unit".
gcc/ada/ChangeLog:
* par-ch10.adb (P_Compilation_Unit): Give an error for "is null".
* sem_ch10.adb (Analyze_Subunit): Remove check for "is null"
as a subunit.
* sem_ch6.adb (Analyze_Subprogram_Declaration):
Remove check for "is null" as a library unit.
Javier Miranda [Wed, 4 Dec 2024 17:49:01 +0000 (17:49 +0000)]
ada: Cleanup preanalysis of static expressions
Complete previous patch; required to avoid regressions in GNATProve.
gcc/ada/ChangeLog:
* sem_ch6.adb (Analyze_Expression_Function): Set the parent of
the new node to be the parent of the original to get the proper
context, which is needed for complete error reporting and for
semantic analysis. Patch suggested by Eric Botcazou.
* Makefile.rtl (LLVM_BUILD): Define based on LLVM_CONFIG.
(GNATRTL_NONTASKING_OBJS): Make g-cpp, g-cppstd, and g-cstyin
conditional on -gcc or -arm EH, and on no LLVM_BUILD.
* raise-gcc.c (GXX_EH_INTEROP): Define as 0 on gnat-llvm or
CERT, and 1 otherwise.
(__gnat_get_cxx_dependent_exception) Omit on !GXX_EH_INTEROP.
(__gnat_maybe_get_cxx_dependent_exception): Likewise.
(__gnat_get_cxx_exception_type_info): Likewise.
(__gnat_obtain_caught_object): Likewise.
(is_handled_by): Omit eid parameter and G++ interop on
!GXX_EH_INTEROP. Adjust callers.
Eric Botcazou [Mon, 9 Dec 2024 09:01:11 +0000 (10:01 +0100)]
ada: Elide copy for calls as default values of nonlimited by-reference components
This prevents a temporary from being created on the primary stack to hold
the result of the function calls before it is copied to the object being
elaborated in the nonlimited by-reference case.
That's already not done in the nonlimited non-by-reference case and there is
no reason to do it in the former case either. The main issue are the calls
to Remove_Side_Effects in Expand_Ctrl_Function_Call (controlled case only)
and in Expand_N_Assignment_Statement, which serve various purposes including
very technical ones beside removing side effects.
The change is therefore very conservative and only removes the copy in the
case of a naked function call for the time being.
gcc/ada/ChangeLog:
* einfo.ads (Returns_By_Ref): Fix description.
* exp_ch3.adb (Build_Record_Init_Proc.Build_Assignment): Do not
adjust the component manually (if need be), set No_Finalize_Actions
instead of No_Ctrl_Actions for this purpose. Do not adjust when
the expression is a naked function call.
* exp_ch5.adb (Make_Tag_Ctrl_Assignment): Document the quirks of
the function. Assert that the LHS of the assignment does not have
side effects and replace calls to Duplicate_Subexpr_No_Checks with
calls to New_Copy_Tree. Rename local variable Asn to New_N.
(Expand_N_Assignment_Statement): In the tagged or controlled record
case, do remove side effects from both operands on entry. Remove
them in the controlled record case, except if the RHS is a function
call and the assignment has the No_Ctrl_Actions flag set.
* exp_ch6.adb (Expand_Ctrl_Function_Call): Bail out when the parent
node is an assignment statement with the No_Ctrl_Actions flag set.
* sem_util.adb (Statically_Different): Return True for a function
call that does not return its result by reference.
* sinfo.ads (No_Ctrl_Actions): Adjust description and add a note for
the code generator.
(No_Finalize_Actions): Likewise.
Tonu Naks [Thu, 5 Dec 2024 11:34:24 +0000 (11:34 +0000)]
ada: Silence unused parameter warning on linux
In __gnat_locate_exec_on_path (char *exec_name, int current_dir_on_windows)
the recently added second parameter is for windows only. On non-windows
platforms its usage is removed by the preprocessor and the compiler
reports unused parameter.
gcc/ada/ChangeLog:
* adaint.c: void parameter on non-windows platforms
Bob Duff [Mon, 9 Dec 2024 13:47:05 +0000 (08:47 -0500)]
ada: Use inheritance in Gen_IL
In Gen_IL, detect cases where fields could be inherited from
an abstract type instead of being defined in each of two or more
descendants of that type. Raise Illegal when that is the case,
except in specific cases called out as exceptions to this rule.
For every such case, either update the types declared in
Gen_Nodes and Gen_Entities to use inheritance, or add the case
to the list of exceptions where we do not want to use inheritance.
gcc/ada/ChangeLog:
* gen_il-internals.ads: Split Fields field into two fields
Imm_Fields and Fields.
* gen_il-gen.adb: Modify the field-inheritance
algorithm to inherit at each level of the type hierarchy,
rather than just inheriting into concrete types.
For example, if C is a concrete type derived from B,
which is in turn derived from A, we now set the Fields
of B to include those of A. (We had always set the Fields
of C to include those of A and B, and we still do that.)
(Compute_Fields_For_One_Type): Detect cases where a given
field is declared for all descendants of a given abstract
type, in which case we should consider declaring it in
the abstract type, and inheriting it in those descendants.
(Exception_To_Inheritance_Rule): These are the cases where
we could inherit, but we don't want to.
* gen_il-gen-gen_nodes.adb: Move fields up the type hierarchy,
so they are inherited instead of being defined separately.
* gen_il-gen-gen_entities.adb: Likewise.
Eric Botcazou [Fri, 6 Dec 2024 14:30:49 +0000 (15:30 +0100)]
ada: Fix finalization issue introduced by previous change
When detecting calls to subprograms specified for aspects of a type, the
entity denoted by the aspects must go through Ultimate_Alias, since that
of the name of the calls did the same.
gcc/ada/ChangeLog:
* exp_ch6.adb (Expand_Call_Helper): Call Ultimate_Alias for the
detection of calls to subprograms specified for Constant_Indexing.
* exp_util.adb (Is_Indexed_Container): Likewise.
(Is_Iterated_Container): Likewise for Default_Iterator.
Piotr Trojanek [Fri, 6 Dec 2024 08:33:28 +0000 (09:33 +0100)]
ada: Remove workaround for RM_Size being unable to represent unknown size
When validating instances of Ada.Unchecked_Conversion, we explicitly detected
null arrays, because a size of 0 was used to indicate both an unknown size and
an actual size of 0. This limitation has been lifted, so we can remove
detection of null arrays.
Code cleanup; behavior is unaffected.
gcc/ada/ChangeLog:
* sem_ch13.adb (Validate_Unchecked_Conversions): Remove detection of
null arrays; remove tests for sizes being present, which are redundant
after calling Known_Static_RM_Size.
Jakub Jelinek [Mon, 6 Jan 2025 09:12:00 +0000 (10:12 +0100)]
tree-ssa-dce: Punt on allocations with too large constant sizes [PR118224]
As suggested by Richi in the PR, the following patch will fail to DCE
allocation calls if they have constant size which is too large (over
PTRDIFF_MAX), or for the case of calloc, if either of the arguments
is too large (in that case in theory the call could succeed if the other
argument is variable zero but who cares) or if both are constant and
their product overflows or is above PTRDIFF_MAX.
This will make some pedantic conformance tests happy, though if one
hides the size one will still need to use -fno-malloc-dce or obfuscate even
the malloc etc. uses. If the size is constant and too large, it isn't worth
trying to optimize it.
2025-01-06 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/118224
* tree-ssa-dce.cc (is_removable_allocation_p): Don't return true
for allocations with constant size argument larger than PTRDIFF_MAX
or for calloc with one of the arguments constant larger than
PTRDIFF_MAX or their product known constant above PTRDIFF_MAX.
Fix comment typos, furhter -> further and then -> than.
* lto-section-in.cc (lto_free_function_in_decl_state_for_node):
Fix comment typo, furhter -> further.
* gcc.dg/pr118224.c: New test.
* c-c++-common/ubsan/vla-1.c (bar): Use noipa attribute instead
of noinline, noclone.
Synchronizing with the upstream release of v2.109.1.
D front-end changes:
- Import dmd v2.109.1.
- Copying from `const(void)[]' to `void[]' is now disallowed
with `-fpreview=fiximmutableconv'.
- Import expressions are now treated as hex strings.
- Using boolean values other than 0 or 1 in `@safe' code is now
deprecated.
Synchronizing with the upstream release of v2.109.0.
D front-end changes:
- Import dmd v2.109.0.
D runtime changes:
- Import druntime v2.109.0.
Phobos changes:
- Import phobos v2.109.0.
gcc/d/ChangeLog:
* decl.cc (DeclVisitor::finish_vtable): Update for new front-end
interface.
* dmd/MERGE: Merge upstream dmd 07bc5b9b3c.
* dmd/VERSION: Bump version to v2.109.0.
Synchronizing the library with the upstream release of v2.108.1.
D runtime changes:
- Import druntime v2.108.1.
- Removed all `collectNoStack' functions and API from the
garbage collector.
- The static method `core.thread.Thread.sleep' is now marked as
`@trusted'.
Synchronizing the compiler with the upstream release of v2.108.1.
D front-end changes:
- Import dmd v2.108.1.
- Add experimental support for language editions, enabled by
adding the UDA `@__edition_latest_do_not_use' before module
declarations.
- [Next Edition] Aliasing a member of a type instance is now an
error.
- Added `__ctfeWrite' to write messages from CTFE.
- `-fdump-c++-spec' generates signatures for `extern(Windows)'
and `extern(System)' functions.
- `foreach_reverse' on a delegate is now an error.
- ImportC has improved Unicode support.
D runtime changes:
- Mark unsafe unittest @trusted.
Phobos changes:
- Mark unsafe functions @trusted.
gcc/d/ChangeLog:
* Make-lang.in (D_FRONTEND_OBJS): Add d/attribsem.o,
d/common-charactertables.o, d/common-identifiertables.o.
* d-attribs.cc (apply_user_attributes): Update for new front-end
interface.
* d-builtins.cc (d_init_versions): Predefine CppRuntime_GNU.
* d-incpath.cc (add_globalpaths): Update for new front-end interface.
(add_filepaths): Likewise.
(add_import_paths): Likewise.
* d-lang.cc (d_post_options): Likewise.
* dmd/MERGE: Merge upstream dmd c11e1d1708.
* dmd/VERSION: Bump version to v2.108.1.
testsuite: Replace MMIX-specific adjustments with TARGET_CALLEE_COPIES-adjustments
With the dump now emitting "privatized symbols" in the default
"%s.%lu" format also for MMIX, there's still a difference for MMIX.
This time it's because numbers have changed (copies introduced before
this point) because it has TARGET_CALLEE_COPIES yielding true.
Redundant copies may have been elided at this point, but the change
in name remains.
Since that's true for other targets too, an obvious change is to
generalize the tested patterns to include TARGET_CALLEE_COPIES-true
targets, as a brief inspection of the history of these tests shows
that the point of these tests lie not in whether copies have been done
but in the part of the pattern that match a constant.
Also fixed up a "." where there should have been a "\\.".
* gcc.dg/tree-ssa/vector-4.c: Replace MMIX adjustments with
TARGET_CALLEE_COPIES-agnostic adjustments.
* gcc.dg/tree-ssa/forwprop-36.c: Ditto. Correct pattern to match a
literal ".".
MMIX: Replace format for private symbol output by output-time adjustment
All this started with belated MMIX regression patrol in observance of
the holidays, looking at gcc.dg/Wstringop-overflow-27.c as a
regression for target mmix. That's because of a single message not
matched, where there is "note: destination object 'vla::22'" instead
of the expected "note: destination object 'vla'" due to r11-5523-geafe8ee7af13c3 in which the message format and the match
changed.
That ::22 is because some identifiers that are SSA_NAME-versions and
other clones are "privatized" by ASM_FORMAT_PRIVATE_NAME and its
companion macro by default, ASM_PN_FORMAT; see the patch. I found
that these "private names" were "unprivatized" for the purpose of
warnings and error messages *in code that only handles the default
format*, "%s.%lu".
I went ahead and wrote and tested a patch-set to hookize that
unprivatizing code, but found that it would only affect errors and
warnings; dumps still had the "target format". While having bad
thoughts about being hit by yet another structural testism because of
the choice of outputting yet another target-specific format instead of
a canonical "versioned" format, I realized it *already was handling a
canonical format*: only the default "%s.%lu" is properly handled.
To wit, targets are better off with the default "%s.%lu" and adjusting
it (if needed, including not allowing "." or "$"), *at time of
assembly code output*. IOW, outputs, both references and definitions,
pass a single label-output target code point: ASM_OUTPUT_LABELREF,
which is that time of output. Some older testsuite adjustments need
to be unadjusted, but is another rabbit-hole, so I've kept that change
separate. Other tests checking dumps, now started to pass for the
first time, some 20+.
* config/mmix/mmix.cc (mmix_asm_output_labelref): Replace '.'
with '::'.
* config/mmix/mmix.h (ASM_PN_FORMAT): Define to actual default.
OpenMP: Robustify C front end handling of attribute-syntax pragmas
Presently, the code to handle OpenMP attribute-syntax pragmas in the C
front end assumes nothing else is messing with redirecting
parser->tokens, and makes no provision for restoring it from anything
other than parser->tokens_buf when the buffer allocated for the pragma
is exhausted. Adding support for metadirectives will change that,
since it also needs to buffer tokens for the metadirective
alternatives, and an attribute-syntax directive can appear inside a
metadirective.
This patch adds a more general save/restore mechanism attached to the
parser via a pointer to a new struct omp_attribute_pragma_state.
gcc/c/ChangeLog
* c-parser.cc (struct c_parser): Change in_omp_attribute_pragma
field to be of type struct omp_attribute_pragma_state.
(struct omp_attribute_pragma_state): New.
(c_parser_skip_until_found): Use the new way to restore state
on EOF.
(c_parser_skip_to_pragma_eol): Likewise.
(c_parser_handle_statement_omp_attributes): Create an
omp_attribute_pragma_state to hold the restore state. Do not
store state in tok.flags.
(omp_maybe_parse_omp_decl): Likewise.
rtlanal: Treat writes to sp as also writing to memory [PR117938]
This PR was about a case in which late-combine moved a stack
deallocation across an earlier stack access. This was possible
because the deallocation was missing the RTL-SSA equivalent of
a vop, which in turn was because rtl_properties didn't treat
the deallocation as writing to memory. I think the bug was
ultimately there.
gcc/
PR rtl-optimization/117938
* rtlanal.cc (rtx_properties::try_to_add_dest): Treat writes
to the stack pointer as also writing to memory.
gcc/testsuite/
PR rtl-optimization/117938
* gcc.dg/torture/pr117938.c: New test.