Richard Biener [Tue, 6 Sep 2022 11:46:00 +0000 (13:46 +0200)]
tree-optimization/106754 - fix compute_control_dep_chain defect
The following handles the situation of a loop exit along the
control path to the PHI def or from there to the use in a different
way, aoviding premature abort of the walks as noticed in the two
cases where the exit is outermost (gcc.dg/uninit-pred-11.c) or
wrapped in a condition that is on the path (gcc.dg/uninit-pred-12.c).
Instead of handling such exits during recursion we now pick them
up in the parent when walking post-dominators. That requires an
additional post-dominator walk at the outermost level which is
facilitated by splitting out the walk to a helper function and
the existing wrapper added earlier.
The patch also removes the bogus early exit from
uninit_analysis::init_use_preds, fixing a simplified version
of the PR106155 testcase.
PR tree-optimization/106754
* gimple-predicate-analysis.cc (compute_control_dep_chain_pdom):
New function, split out from compute_control_dep_chain. Handle
loop-exit like conditions here by pushing to the control vector.
(compute_control_dep_chain): Adjust and streamline dumping.
In the wrapper perform a post-dominator walk as well.
(uninit_analysis::init_use_preds): Remove premature early exit.
* gcc.dg/uninit-pred-12.c: New testcase.
* gcc.dg/uninit-pr106155-1.c: Likewise.
Max Filippov [Sat, 13 Aug 2022 04:02:15 +0000 (21:02 -0700)]
xtensa: gcc: add static PIE support
gcc/
* config/xtensa/linux.h (LINK_SPEC): Add static-pie.
Aldy Hernandez [Tue, 6 Sep 2022 06:20:54 +0000 (08:20 +0200)]
Handle > INF and < INF correctly in range-op-float.cc
The gfortran.dg/minlocval*.f90 tests are generating conditionals past
the infinities. For example:
if (x <= +Inf)
foo (x);
else
bar (x);
It seems to me that the only possible value for x on the false side is
either NAN or undefined (for !HONOR_NANS).
gcc/ChangeLog:
* range-op-float.cc (build_le): Handle NANs and going past infinity.
(build_lt): Same.
(build_ge): Same.
(build_gt): Same.
(foperator_lt::op1_range): Avoid adjustments to range if build_*
returned false.
(foperator_lt::op2_range): Same.
(foperator_le::op1_range): Same.
(foperator_le::op2_range): Same.
(foperator_gt::op1_range): Same.
(foperator_gt::op2_range): Same.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/vrp-float-inf-1.c: New test.
Richard Biener [Tue, 6 Sep 2022 09:56:04 +0000 (11:56 +0200)]
Fix use predicate computation for uninit analysis
In uninit analysis we try to prove that a use is always properly guarded
so it is never reached when the used value is not initialized. This
fails to be conservative when during the computation of the use
predicate components of the || .. || .. chain are dropped so we have
to detect this case and fall back to the conservative computation.
* gimple-predicate-analysis.cc (compute_control_dep_chain):
Add output flag to indicate whether we possibly have dropped
any chains. Return whether the info is complete from the
wrapping overload.
(uninit_analysis::init_use_preds): Adjust accordingly, with
a workaround for PR106754.
(uninit_analysis::init_from_phi_def): Properly guard the
case where we complete an empty chain.
Philipp Fent [Sun, 4 Sep 2022 18:47:34 +0000 (20:47 +0200)]
libstdc++: Fix pretty printer tests of tuple indexes
Signed-off-by: Philipp Fent <fent@in.tum.de>
libstdc++-v3/ChangeLog:
* testsuite/libstdc++-prettyprinters/48362.cc: Fix expected
tuple indices.
* testsuite/libstdc++-prettyprinters/cxx11.cc: Likewise.
Jan-Benedict Glaw [Tue, 6 Sep 2022 11:05:21 +0000 (13:05 +0200)]
Document unused function argument
This patch fixes a small warning about the unused outer_rtx argument in the
msp430 backend.
2022-09-06 Jan-Benedict Glaw <jbglaw@lug-owl.de>
gcc/ChangeLog:
* config/msp430/msp430.cc (msp430_single_op_cost): Document unused argument.
Prathamesh Kulkarni [Tue, 6 Sep 2022 09:48:04 +0000 (15:18 +0530)]
tree-ssa-forwprop.cc: Adjust res_type when operands have differing vector lengths.
gcc/
* tree-ssa-forwprop.cc (simplify_permutation): Set res_type to a vector
type with same element type as arg0, and length as op2.
Richard Biener [Tue, 6 Sep 2022 08:42:50 +0000 (10:42 +0200)]
tree-optimization/106844 - fix ICE in init_use_preds
The following fixes an oversight in the last change to
compute_control_dep_chain where we have to return whether we found
a chain.
PR tree-optimization/106844
* gimple-predicate-analysis.cc (compute_control_dep_chain):
Return whether we found a chain.
* gcc.dg/pr106844.c: New testcase.
Richard Biener [Tue, 6 Sep 2022 08:08:44 +0000 (10:08 +0200)]
tree-optimization/106841 - gather and hybrid SLP
Hybrid SLP detection currently fails to consider a not direct
offset operand of a scatter/gather operation. The following fixes
this.
PR tree-optimization/106841
* tree-vect-slp.cc (vect_detect_hybrid_slp): Also process
scatter/gather offset.
* g++.dg/vect/pr106841.cc: New testcase.
Tobias Burnus [Tue, 6 Sep 2022 08:02:13 +0000 (10:02 +0200)]
Fix Fortran/openmp: Partial OpenMP 5.2 doacross
This removed a checking snippet which accidentally was left in in commit
r13-2446-g938cda536019cd6a1bc0dd2346381185b420bbf8 ; this caused
fails in gfortran.dg/gomp/doacross-5.f90 (added in that very commit).
Note that a similar but refined check is now done in the middle end.
(The ME version additionally checks whether doacross is present.)
gcc/fortran/
* openmp.cc (resolve_omp_clauses): Remove ordered/linear
check as it is handled now in the middle end.
Jakub Jelinek [Tue, 6 Sep 2022 07:24:13 +0000 (09:24 +0200)]
openmp: Be consistent on parsing offsets between normal sink vector and omp_cur_iteration - 1
For normal sink vectors, we just check that the token is CPP_NUMBER and with
INTEGER_CST value, while for omp_cur_iteration I was additionally requiring
integer_type_node type (so only 1, 001, 0x0001 but not 1L or 1ULL etc.).
I think we need to clarify what we actually should allow in the standard, until
then it is better to be consistent.
2022-09-06 Jakub Jelinek <jakub@redhat.com>
gcc/c/
* c-parser.cc (c_parser_omp_clause_doacross_sink): Don't verify val
in omp_cur_iteration - 1 has integer_type_node type.
gcc/cp/
* parser.cc (cp_parser_omp_clause_doacross_sink): Don't verify val
in omp_cur_iteration - 1 has integer_type_node type.
gcc/testsuite/
* c-c++-common/gomp/doacross-6.c (corge): Don't expect an error here.
Add a few further tests.
Jakub Jelinek [Tue, 6 Sep 2022 07:21:10 +0000 (09:21 +0200)]
openmp: Fix ICE when splitting invalid depend(source)/depend(sink:vec)
As we now create OMP_CLAUSE_DOACROSS rather than OMP_CLAUSE_DEPEND when
depend is used with source/sink modifiers, c_omp_split_clauses can see
OMP_CLAUSE_DOACROSS clause too before we diagnose it as erroneous.
The following patch treats it like OMP_CLAUSE_DEPEND during
the splitting but adds an assertion.
2022-09-06 Jakub Jelinek <jakub@redhat.com>
PR c/106836
* c-omp.cc (c_omp_split_clauses): Handle OMP_CLAUSE_DOACROSS.
* c-c++-common/gomp/pr106836.c: New test.
Jan-Benedict Glaw [Tue, 6 Sep 2022 07:18:36 +0000 (09:18 +0200)]
No actual regclasses for bpf
Building for for bpf-unknown-none target, recent GCCs will issue an unused
variable warning as the REGNO_REG_CLASS macro doesn't actually use its
argument. Reference the argument as (void) to silence the warning.
.../gcc/configure --prefix=... --enable-werror-always --enable-languages=all --disable-gcov --disable-shared --disable-threads --target=bpf-unknown-none --without-headers
[...]
make V=1 all-gcc
[...]
/usr/lib/gcc-snapshot/bin/g++ -fno-PIE -c -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common -DHAVE_CONFIG_H -I. -I. -I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -I../../gcc/gcc/../libcody -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc/gcc/../libbacktrace -o regcprop.o -MT regcprop.o -MMD -MP -MF ./.deps/regcprop.TPo ../../gcc/gcc/regcprop.cc
../../gcc/gcc/regcprop.cc: In function 'bool copyprop_hardreg_forward_1(basic_block, value_data*)':
../../gcc/gcc/regcprop.cc:794:24: error: unused variable 'regno' [-Werror=unused-variable]
794 | unsigned int regno = REGNO (SET_SRC (set));
| ^~~~~
cc1plus: all warnings being treated as errors
make[1]: *** [Makefile:1146: regcprop.o] Error 1
make[1]: Leaving directory '/var/lib/laminar/run/gcc-bpf-unknown-none/1/toolchain-build/gcc'
make: *** [Makefile:4565: all-gcc] Error 2
gcc/
* config/bpf/bpf.h (REGNO_REG_CLASS): Reference arguments as (void).
Jakub Jelinek [Tue, 6 Sep 2022 07:19:24 +0000 (09:19 +0200)]
openmp: Introduce gimple_omp_ordered_standalone_p
On Sat, Sep 03, 2022 at 10:07:27AM +0200, Jakub Jelinek via Gcc-patches wrote:
> Incrementally, I'd like to change the way we differentiate between
> stand-alone and block-associated ordered constructs, because the current
> way of looking for presence of doacross clause doesn't work well if those
> clauses are removed because they had been invalid (wrong syntax or
> unknown variables in it etc.)
The following, so far only lightly tested, patch implements that.
2022-09-06 Jakub Jelinek <jakub@redhat.com>
gcc/
* gimple.h (enum gf_mask): Add GF_OMP_ORDERED_STANDALONE enumerator.
(gimple_omp_subcode): Use GIMPLE_OMP_ORDERED instead of
GIMPLE_OMP_TEAMS as upper bound.
(gimple_omp_ordered_standalone_p, gimple_omp_ordered_standalone): New
inline functions.
* gimplify.cc (find_standalone_omp_ordered): Look for OMP_ORDERED with
NULL OMP_ORDERED_BODY rather than with OMP_DOACROSS clause.
(gimplify_expr): Call gimple_omp_ordered_standalone for OMP_ORDERED
with NULL OMP_ORDERED_BODY.
* omp-low.cc (check_omp_nesting_restrictions): Use
gimple_omp_ordered_standalone_p test instead of
omp_find_clause (..., OMP_CLAUSE_DOACROSS).
(lower_omp_ordered): Likewise.
* omp-expand.cc (expand_omp, build_omp_regions_1,
omp_make_gimple_edges): Likewise.
gcc/cp/
* pt.cc (tsubst_expr) <case OMP_ORDERED>: If OMP_BODY was NULL, keep
it NULL after instantiation too.
gcc/testsuite/
* c-c++-common/gomp/sink-3.c: Don't expect a superfluous error during
error recovery.
* c-c++-common/gomp/doacross-6.c (foo): Add further tests.
Eric Botcazou [Mon, 22 Aug 2022 21:32:05 +0000 (23:32 +0200)]
[Ada] Mark artificial formal parameters in the debug info
gcc/ada/
* gcc-interface/decl.cc (gnat_to_gnu_param): Set DECL_ARTIFICIAL.
Eric Botcazou [Mon, 22 Aug 2022 21:23:52 +0000 (23:23 +0200)]
[Ada] Fix problematic line debug info attached to call to finalizer
The End_Label is not defined for body nodes so a small tweak is needed.
gcc/ada/
* gcc-interface/trans.cc (At_End_Proc_to_gnu): Use the End_Label of
the child Handled_Statement_Sequence for body nodes.
(set_end_locus_from_node): Minor tweaks.
Eric Botcazou [Tue, 16 Aug 2022 15:54:59 +0000 (17:54 +0200)]
[Ada] Fix internal error on double renaming of private constant
The first renaming uses the type of the full view of the constant but not
the second, which introduces problematic view conversions downstream.
gcc/ada/
* gcc-interface/trans.cc (Full_View_Of_Private_Constant): New
function returning the Full_View of a private constant, after
looking through a chain of renamings, if any.
(Identifier_to_gnu): Call it on the entity. Small cleanup.
Eric Botcazou [Tue, 19 Jul 2022 18:55:05 +0000 (20:55 +0200)]
[Ada] Fix missing name for access type in generic instantiation
Pointer types aren't named types in C so we need to take extra care in Ada
to make sure that the name of access types is preserved.
gcc/ada/
* gcc-interface/utils.cc (gnat_pushdecl): Preserve named
TYPE_DECLs consistently for all kind of pointer types.
Eric Botcazou [Tue, 12 Jul 2022 12:22:53 +0000 (14:22 +0200)]
[Ada] Extend No_Dependence restriction to code generation (continued)
gcc/ada/
* gcc-interface/trans.cc (gnat_to_gnu) <N_Op_Divide>: Report a
violation of No_Dependence on System.GCC if the result type is
larger than a word.
<N_Op_Shift>: Likewise.
<N_Op_Mod>: Likewise.
<N_Op_Rem>: Likewise.
(convert_with_check): Report a violation of No_Dependence on
System.GCC for a conversion between an integer type larger than
a word and a floating-point type.
Steve Baird [Mon, 22 Aug 2022 22:25:28 +0000 (15:25 -0700)]
[Ada] Disable lock free protected implementation if target lacks support
Do not select a lock free implementation if Targparm.Support_Atomic_Primitives
is False (which indicates that the target cannot support it).
gcc/ada/
* sem_ch9.adb
(Allows_Lock_Free_Implementation): Return False if
Support_Atomic_Primitives is False.
Steve Baird [Sat, 13 Aug 2022 00:04:38 +0000 (17:04 -0700)]
[Ada] Enable lock free protected implementation by default
In the past, the Lock_Free aspect of a protected type (including an
anonymous type) defaulted to False. In the case where an explicit
"Lock_Free => True" aspect specification would be legal, the aspect now
defaults to True (which means that a lock-free implementation is used to
implement the type's protected operations); this is like the previous
behavior of the compiler with the -gnatd9 switch specified. Support for
the Lock_Free attribute (which should not be confused with the Lock_Free
aspect) is removed.
gcc/ada/
* debug.adb: Remove comment regarding the -gnatd9 switch.
* doc/gnat_rm/implementation_defined_attributes.rst: Remove all
mention of the Lock_Free attribute.
* gnat_rm.texi, gnat_ugn.texi: Regenerate.
* exp_attr.adb, sem_attr.adb: Remove all mention of the former
Attribute_Lock_Free enumeration element of the Attribute_Id type.
* sem_ch9.adb
(Allows_Lock_Free_Implementation): Remove the Debug_Flag_9 test.
Return False in the case of a protected function whose result type
requires use of the secondary stack.
(Satisfies_Lock_Free_Requirements): This functions checks for
certain constructs and returns False if one is found. In the case
of a protected function, there is no need to check to see if the
protected object is being modified. So it is ok to omit *some*
checks in the case of a protected function. But other checks which
are required (e.g., the test for a reference to a variable that is
not part of the protected object) were being incorrectly omitted.
This could result in accepting "Lock_Free => True" aspect
specifications that should be rejected.
* snames.adb-tmpl: Name_Lock_Free no longer requires special
treatment in Get_Pragma_Id or Is_Pragma_Name (because it is no
longer an attribute name).
* snames.ads-tmpl: Move the declaration of Name_Lock_Free to
reflect the fact that it is no longer the name of an attribute.
Delete Attribute_Lock_Free from the Attribute_Id enumeration type.
Steve Baird [Fri, 19 Aug 2022 17:26:29 +0000 (10:26 -0700)]
[Ada] Restore missing Aggregate aspect for Ada.Containers.Ordered_Sets.Set
Ada RM A.18.9 includes a specification of the Aggregate aspect for the type
Ada.Containers.Ordered_Sets. That aspect specification was deliberately
commented out in a-coorse.ads at one time, but that workaround is no longer
needed.
gcc/ada/
* libgnat/a-coorse.ads: Restore Aggregate aspect specification for
type Set.
Marc Poulhiès [Mon, 22 Aug 2022 08:25:09 +0000 (10:25 +0200)]
[Ada] Fix formal parameters list for secondary stack allocation procedure
The introduction of the Alignment parameter for the secondary stack
allocator in previous change was missing the corresponding change in the
Build_Allocate_Deallocate_Proc when creating the formal parameters list.
gcc/ada/
* exp_util.adb (Build_Allocate_Deallocate_Proc): Add
Alignment_Param in the formal list for calls to SS_Allocate.
Piotr Trojanek [Fri, 12 Aug 2022 09:33:20 +0000 (11:33 +0200)]
[Ada] Retain Has_Private_View flag for actuals of inlined subprograms
When instantiating a body to inline (either because frontend inlining is
enabled with switch -gnatN or because of inlining-for-proof in GNATprove
mode) we rewrite occurrences of formal parameters into the corresponding
actual parameters. Then we switch type views, so that if the formal had
a full view in the body to inline then the corresponding actual will
have a full view in the particular inlined body.
However, when rewriting occurrences of the formal parameter we were
losing information about whether the formal had a private view.
gcc/ada/
* inline.adb (Process_Formals): Preserve Has_Private_View flag while
rewriting formal into actual parameters.
Javier Miranda [Mon, 15 Aug 2022 16:54:40 +0000 (16:54 +0000)]
[Ada] Enforce matching of extra formals
This patch enforces matching of extra formals in overridden subprograms,
subprogram renamings, and subprograms to which attributes 'Access,
'Unchecked_Access, or 'Unrestricted_Access is applied (for these access
cases the subprogram is checked against its corresponding subprogram
type).
gcc/ada/
* debug.adb
(Debug_Flag_Underscore_X): Switch added temporarily to allow
disabling extra formal checks.
* exp_attr.adb
(Expand_N_Attribute_Reference [access types]): Add extra formals
to the subprogram referenced in the prefix of 'Unchecked_Access,
'Unrestricted_Access or 'Access; required to check that its extra
formals match the extra formals of the corresponding subprogram
type.
* exp_ch3.adb
(Stream_Operation_OK): Declaration moved to the public part of the
package.
(Validate_Tagged_Type_Extra_Formals): New subprogram.
(Expand_Freeze_Record_Type): Improve the code that takes care of
adding the extra formals of dispatching primitives; extended to
add also the extra formals to renamings of dispatching primitives.
* exp_ch3.ads
(Stream_Operation_OK): Declaration moved from the package body.
* exp_ch6.adb
(Has_BIP_Extra_Formal): Subprogram declaration moved to the public
part of the package. In addition, a parameter has been added to
disable an assertion that requires its use with frozen entities.
(Expand_Call_Helper): Enforce assertion checking extra formals on
thunks.
(Is_Build_In_Place_Function): Return False for entities with
foreign convention.
(Make_Build_In_Place_Call_In_Object_Declaration): Occurrences of
Is_Return_Object replaced by the local variable
Is_OK_Return_Object that evaluates to False for scopes with
foreign convention.
(Might_Have_Tasks): Fix check of class-wide limited record types.
(Needs_BIP_Task_Actuals): Remove assertion to allow calling this
function in more contexts; in addition it returns False for
functions returning objects with foreign convention.
(Needs_BIP_Finalization_Master): Likewise.
(Needs_BIP_Alloc_Form): Likewise.
* exp_ch6.ads
(Stream_Operation_OK): Declaration moved from the package body. In
addition, a parameter has been added to disable assertion that
requires its use with frozen entities.
* freeze.adb
(Check_Itype): Add extra formals to anonymous access subprogram
itypes.
(Freeze_Expression): Improve code that disables the addition of
extra formals to functions with foreign convention.
(Check_Extra_Formals): Moved to package Sem_Ch6 as
Extra_Formals_OK.
(Freeze_Subprogram): Add extra formals to non-dispatching
subprograms.
* sem_ch3.adb
(Access_Subprogram_Declaration): Defer the addition of extra
formals to the freezing point so that we know the convention.
(Check_Anonymous_Access_Component): Likewise.
(Derive_Subprogram): Fix documentation.
* sem_ch6.adb
(Check_Anonymous_Return): Fix check of access to class-wide
limited record types.
(Check_Untagged_Equality): Placed in alphabetical order.
(Extra_Formals_OK): Subprogram moved from freeze.adb.
(Extra_Formals_Match_OK): New subprogram.
(Has_BIP_Formals): New subprogram.
(Has_Extra_Formals): New subprograms.
(Needs_Accessibility_Check_Extra): New subprogram.
(Needs_Constrained_Extra): New subprogram.
(Parent_Subprogram): New subprogram.
(Add_Extra_Formal): Minor code cleanup.
(Create_Extra_Formals): Enforce matching extra formals on
overridden and aliased entities.
(Has_Reliable_Extra_Formals): New subprogram.
* sem_ch6.ads
(Extra_Formals_OK): Subprogram moved from freeze.adb.
(Extra_Formals_Match_OK): New subprogram.
* sem_eval.adb
(Compile_Time_Known_Value): Improve predicate to avoid assertion
failure; found working on this ticket; this change does not affect
the behavior of the compiler because this subprogram has an
exception handler that returns False when the assertion fails.
* sem_util.adb
(Needs_Result_Accessibility_Level): Do not return False for
dispatching operations compiled with Ada_Version < 2012 since they
they may be overridden by primitives compiled with Ada_Version >=
Ada_2012.
Arnaud Charlet [Fri, 19 Aug 2022 16:25:45 +0000 (16:25 +0000)]
[Ada] Disable if expression optimization for LLVM
gcc/ada/
* exp_ch4.adb (Expand_N_If_Expression): Disable optimization
for LLVM.
Javier Miranda [Mon, 15 Aug 2022 18:31:50 +0000 (18:31 +0000)]
[Ada] Report error in non-legal class-wide conditions
gcc/ada/
* sem_prag.adb
(Analyze_Pre_Post_Condition_In_Decl_Part): Improve check to report
an error in non-legal class-wide conditions.
Steve Baird [Mon, 15 Aug 2022 23:58:36 +0000 (16:58 -0700)]
[Ada] Slice length computation bug in Generic_Bounded_Length generics
In some cases involving null slices, the Slice subprograms (both the
function and the procedure) in each of the three Generic_Bounded_Length
generic packages (for String, Wide_String, and Wide_Wide_String)
could raise Constraint_Error in cases where this is incorrect.
gcc/ada/
* libgnat/a-strsup.adb, libgnat/a-stwisu.adb, libgnat/a-stzsup.adb
(Super_Slice function and procedure): fix slice length computation.
Steve Baird [Wed, 17 Aug 2022 17:13:55 +0000 (10:13 -0700)]
[Ada] Improve documentation of validation checking control switches
Correct incorrect text and clarify unclear text that has been identified
in the "Validity Checking" section of the GNAT UG.
gcc/ada/
* doc/gnat_ugn/building_executable_programs_with_gnat.rst:
Improve -gnatVa, -gnatVc, -gnatVd, -gnatVe, -gnatVf, -gnatVo,
-gnatVp, -gnatVr, and -gnatVs switch descriptions.
* gnat_ugn.texi: Regenerate.
Justin Squirek [Thu, 18 Aug 2022 19:48:22 +0000 (19:48 +0000)]
[Ada] Handle new At_End expansion during unnesting
This patch modifies the marking of nested subprograms requiring static links,
so that the changes made to "At end" procedures get handled properly.
gcc/ada/
* exp_unst.adb
(Visit_Node): Add N_Block_Statement to the enclosing construct
case since they can now have "At end" procedures. Also, recognize
calls from "At end" procedures when recording subprograms.
Piotr Trojanek [Fri, 12 Aug 2022 10:15:53 +0000 (12:15 +0200)]
[Ada] Fix comment about mapping of parameters and inlining static funcs
Fix glitch in a cross-reference in comment.
gcc/ada/
* inline.adb (Replace_Formal): Fix name of the referenced routine.
Piotr Trojanek [Mon, 8 Aug 2022 14:18:38 +0000 (16:18 +0200)]
[Ada] Cleanup unnecessary shadowing in expansion of attribute Old
Code cleanup; semantics is unaffected.
gcc/ada/
* exp_attr.adb (Expand_N_Attribute_Reference [Attribute_Old]):
Remove unnecessary local constant that was shadowing another
constant with the same initial value.
Julien Bortolussi [Thu, 4 Aug 2022 16:15:13 +0000 (18:15 +0200)]
[Ada] Fix a bug in the contract of formal ordered sets
There are 2 main issues in the postcondition of the function Replace
of the formal ordered sets, in the sub package Generic_Keys. One is
related to the fact that when the element is changed, the key is
also changed. The second one is due to the fact that the arrival of
the new element might modify the ordering of the set and thus
the Positions might be modified.
As a consequence, the postcondition might be false and thus fail
at runtime.
gcc/ada/
* libgnat/a-cforse.ads (Replace): Fix the postcondition.
Steve Baird [Wed, 10 Aug 2022 21:04:29 +0000 (14:04 -0700)]
[Ada] Cope with scalar subtypes that have a non-scalar basetype.
In some cases, the compiler builds a subtype entity Typ such that
Is_Scalar (Typ) is True and Is_Scalar (Base_Type (Typ)) is False.
This comes up in some cases involving a subtype of a private type,
where the full view of the private type is a scalar type. In such a
situation, it may also be the case that Is_Enumeration_Type (Typ) is True
and Is_Enumeration_Type (Base_Type (Typ)) is False. Some code incorrectly
assumed that if a subtype is known to be a scalar (respectively, enumeration)
type, then the same must be true of the base type of that subtype. Fix that
code to handle the case where that assumption does not hold.
gcc/ada/
* exp_attr.adb
(Attribute_Valid): Ensure that PBtyp is initialized to a value for
which Is_Scalar_Type is True.
* checks.adb
(Determine_Range): Call Implemention_Base_Type instead of
Base_Type in order to ensure that result is suitable for passing
to Enum_Pos_To_Rep.
Bob Duff [Mon, 8 Aug 2022 18:45:31 +0000 (14:45 -0400)]
[Ada] Place "at end" on body nodes
This patch fixes a bug where finalization code might refer to variables
outside their lifetime. The previous version moved declarations into the
Handled_Statement_Sequence (HSS), so that the "at end" handler of the
HSS could handle exceptions raised by those declarations. The
First_Real_Statement field was used to find the first statement after
the moved declarations. In addition, if the HSS already had exception
handlers, it was wrapped in another layer of block_statement. This
doesn't work if there are variable-sized objects allocated on the
(primary) stack, because the stack will be popped before the "at end" is
invoked.
In the new version, we allow "at end" on nodes such as
N_Subprogram_Body, in addition to HSS. We modify gigi so that such an
"at end" applies to the whole body (declarations and HSS) by extending
support for At_End_Proc mechanism to N_Block_Statement and N_*_Body
nodes. This also removes the support for First_Real_Statement. In
particular, an exception raised by the declarations will trigger the "at
end". We no longer move declarations into the HSS, we no longer have a
First_Real_Statement field, and we no longer do the wrapping mentioned
above.
This change requires various other changes, in cases where we depended
on the First_Real_Statement and the moving/wrapping mentioned above.
gcc/ada/
* gen_il-fields.ads
(First_Real_Statement): Remove this field.
* gen_il-gen-gen_nodes.adb: Remove the First_Real_Statement field.
Add the At_End_Proc field to nodes that have both Declarations and
HSS.
* sinfo.ads
(At_End_Proc): Document new semantics.
(First_Real_Statement): Remove comment.
* exp_ch11.adb
(Expand_N_Handled_Sequence_Of_Statements): Remove
First_Real_Statement.
* exp_ch7.adb
(Build_Cleanup_Statements): Remove "Historical note"; it doesn't
seem useful, and we have revision history.
(Create_Finalizer): Insert the finalizer later, typically in the
statement list, in some cases.
(Build_Finalizer_Call): Attach the "at end" handler to the parent
of the HSS node in most cases, so it applies to declarations.
(Expand_Cleanup_Actions): Remove Wrap_HSS_In_Block and the call to
it. Remove the code that moves declarations. Remove some redundant
code.
* exp_ch9.adb
(Build_Protected_Entry): Copy the At_End_Proc.
(Build_Protected_Subprogram_Body): Reverse the sense of Exc_Safe,
to avoid double negatives. Remove "Historical note" as in
exp_ch7.adb.
(Build_Unprotected_Subprogram_Body): Copy the At_End_Proc from the
protected version.
(Expand_N_Conditional_Entry_Call): Use First (Statements(...))
instead of First_Real_Statement(...).
(Expand_N_Task_Body): Put the Abort_Undefer call at the beginning
of the declarations, rather than in the HSS. Use First
(Statements(...)) instead of First_Real_Statement(...). Copy the
At_End_Proc.
* inline.adb
(Has_Initialized_Type): Return False if the declaration does not
come from source.
* libgnarl/s-tpoben.ads
(Lock_Entries, Lock_Entries_With_Status): Document when these
things raise Program_Error. It's not clear that
Lock_Entries_With_Status ought to be raising exceptions, but at
least it's documented now.
* sem.ads: Minor comment fixes.
* sem_ch6.adb
(Analyze_Subprogram_Body_Helper): Use First (Statements(...))
instead of First_Real_Statement(...).
(Analyze_Null_Procedure): Minor comment fix.
* sem_util.adb
(Might_Raise): Return True for N_Raise_Expression. Adjust the part
about exceptions generated by the back end to match the reality of
what the back end generates.
(Update_First_Real_Statement): Remove.
* sem_util.ads: Remove First_Real_Statement from comment.
* sinfo-utils.ads
(First_Real_Statement): New function that always returns Empty.
This should be removed once gnat-llvm and codepeer have been
updated to not refer to First_Real_Statement.
* sprint.adb
(Sprint_At_End_Proc): Deal with printing At_End_Proc.
* sem_prag.adb: Minor comment fixes.
* gcc-interface/trans.cc (At_End_Proc_to_gnu): New function.
(Subprogram_Body_to_gnu): Call it to handle an At_End_Proc.
(Handled_Sequence_Of_Statements_to_gnu): Likewise. Remove the
support for First_Real_Statement and clean up the rest.
(Exception_Handler_to_gnu): Do not push binding levels.
(Compilation_Unit_to_gnu): Adjust call to process_decls.
(gnat_to_gnu) <N_Package_Specification>: Likewise. <N_Entry_Body>:
Likewise. <N_Freeze_Entity>: Likewise. <N_Block_Statement>:
Likewise and call At_End_Proc_to_gnu to handle an At_End_Proc.
<N_Package_Body>: Likewise.
(process_decls): Remove GNAT_END_LIST parameter and adjust
recursive calls.
Co-authored-by: Eric Botcazou <ebotcazou@adacore.com>
Steve Baird [Tue, 9 Aug 2022 16:51:41 +0000 (09:51 -0700)]
[Ada] Document change to legality checks for Inox case statements
INOX (which is enabled via -gnatX) supports composite case-statement selectors.
As a temporary measure, simplify the coverage-related compile-time checks
for such case statements via two changes: an others choice is always
required for such a case statement, and no legality checks relating to
overlapping of case choices are performed.
gcc/ada/
* doc/gnat_rm/implementation_defined_pragmas.rst: Document new
temporary rule that a "when others =>" case choice must be given
when casing on a composite selector.
* gnat_rm.texi: Regenerate.
Steve Baird [Mon, 25 Jul 2022 23:03:10 +0000 (16:03 -0700)]
[Ada] Temporarily simplify legality checks for Inox case statements
INOX (which is enabled via -gnatX) supports composite case-statement selectors.
As a temporary measure, simplify the coverage-related compile-time checks
for such case statements via two changes: an others choice is always
required for such a case statement, and no legality checks relating to
overlapping of case choices are performed.
gcc/ada/
* sem_case.adb: Define a new Boolean constant,
Simplified_Composite_Coverage_Rules, initialized to True. Setting
this constant to True has two effects: 1- Representative value
sets are not fully initialized - this is done to avoid capacity
problems, as well as for performance. 2- In
Check_Case_Pattern_Choices, the only legality check performed is a
check that a "when others =>" choice is present.
Piotr Trojanek [Tue, 9 Aug 2022 13:09:53 +0000 (15:09 +0200)]
[Ada] Tune message for illegal aspect Relaxed_Initialization
Error message about illegal aspect Relaxed_Initialization was lacking a
whitespace character.
gcc/ada/
* sem_ch13.adb (Analyze_Aspect_Relaxed_Initialization): Fix error
template.
Steve Baird [Tue, 2 Aug 2022 00:04:20 +0000 (17:04 -0700)]
[Ada] Bad Valid_Scalars result if signed int component type signed has partial view.
For an object X of a composite type, the attribute X'Valid_Scalars should
return False if and only if there exists at least one invalid scalar
subcomponent of X. The validity test for a scalar part may include a
range test. In some cases involving a private type that is implemented as
a signed integer type, this range test was incorrectly implemented using
unsigned comparisons. For an enclosing object X, this could result in
X'Valid_Scalars yielding the wrong Boolean result. Such an incorrect
result would almost always be False, although an incorrect True result is
theoretically possible (this would require that both bounds of the
component subtype are negative and that the invalid component has a positive
value).
gcc/ada/
* exp_attr.adb
(Make_Range_Test): In determining which subtype's First and Last
attributes are to be queried as part of a range test, call
Validated_View in order to get a scalar (as opposed to private)
subtype.
(Attribute_Valid): In determining whether to perform a signed or
unsigned comparison for a range test, call Validated_View in order
to get a scalar (as opposed to private) type. Also correct a typo
which, by itself, is the source of the problem reported for this
ticket.
Steve Baird [Fri, 29 Jul 2022 22:54:19 +0000 (15:54 -0700)]
[Ada] ICE handling discriminant-dependent index constraint for access component
The compiler would fail with an internal error in some cases involving
a discriminated record type that provides a discriminant-dependent index
constraint for the subtype of a component of an access-to-array type when a
dereference of that component of some object is mentioned in a pre- or
postcondition expression.
gcc/ada/
* sem_ch4.adb
(Analyze_Selected_Component): Define new Boolean-valued function,
Constraint_Has_Unprefixed_Discriminant_Reference, which takes a
subtype that is subject to a discriminant-dependent constraint and
returns True if any of the constraint values are unprefixed
discriminant names. Usually, the Etype of a selected component
node is set to Etype of the component. However, in the case of an
access-to-array component for which this predicate returns True,
we instead use the base type of the Etype of the component.
Normally such problematic discriminant references are addressed by
calling Build_Actual_Subtype_Of_Component, but that doesn't work
if Full_Analyze is False.
Piotr Trojanek [Mon, 8 Aug 2022 10:32:12 +0000 (12:32 +0200)]
[Ada] Add formal verification dependencies to libgnat
Spec units for verification of the GNAT standard library with GNATprove
must be listed as part of the libgnat package, as otherwise libadalang
will complain about missing dependencies.
gcc/ada/
* Makefile.rtl (GNATRTL_NONTASKING_OBJS): Include
System.Value_U_Spec and System.Value_I_Spec units.
Eric Botcazou [Fri, 5 Aug 2022 07:42:58 +0000 (09:42 +0200)]
[Ada] Correctly round Value attribute for floating point in more cases
This provides correct rounding in the IEEE 754 sense for the Value attribute
of floating-point types in more cases, by switching from tables of powers of
10 to tables of powers of 5 for precomputed values, thus making it possible
to use a single divide for denormals and normalized numbers just above them.
Although this significantly increases the size of the tables, object files
for them are still quite small (1, 2 and 4 KB respectively on x86-64).
gcc/ada/
* libgnat/s-powflt.ads (Powfive): New constant array.
* libgnat/s-powlfl.ads (Powfive): Likewise.
(Powfive_100): New constant.
(Powfive_200): Likewise.
(Powfive_300): Likewise.
* libgnat/s-powllf.ads (Powfive): New constant array.
(Powfive_100): New constant.
(Powfive_200): Likewise.
(Powfive_300): Likewise.
* libgnat/s-valflt.ads (Impl): Replace Powten with Powfive and pass
Null_Address for the address of large constants.
* libgnat/s-vallfl.ads (Impl): Replace Powten with Powfive and pass
the address of large constants.
* libgnat/s-valllf.ads (Impl): Likewise.
* libgnat/s-valrea.ads (System.Val_Real): Replace Powten_Address
with Powfive_Address and add Powfive_{1,2,3}00_Address parameters.
* libgnat/s-valrea.adb (Is_Large_Type): New boolean constant.
(Is_Very_Large_Type): Likewise.
(Maxexp32): Change value of 10 to that of 5.
(Maxexp64): Likewise.
(Maxexp80): Likewise.
(Integer_to_Real): Use a combination of tables of powers of 5 and
scaling if the base is 10.
(Large_Powten): Rename into...
(Large_Powfive): ...this. Add support for large constants.
(Large_Powfive): New overloaded function for very large exponents.
Piotr Trojanek [Fri, 5 Aug 2022 14:31:19 +0000 (16:31 +0200)]
[Ada] Improve detection of illegal Iterable aspects
Handling of aspect Iterable was lacking guards against illegal code, so
the compiler either crashed or emitted cryptic errors while expanding
loops that rely on this aspect.
gcc/ada/
* doc/gnat_rm/implementation_defined_aspects.rst
(Aspect Iterable): Include Last and Previous primitives in
syntactic and semantic description.
* exp_attr.adb
(Expand_N_Attribute_Reference): Don't expect attributes like
Iterable that can only appear in attribute definition clauses.
* sem_ch13.adb
(Analyze_Attribute_Definition_Clause): Prevent crash on
non-aggregate Iterable attribute; improve basic diagnosis of
attribute values.
(Resolve_Iterable_Operation): Improve checks for illegal
primitives in aspect Iterable, e.g. with wrong number of formal
parameters.
(Validate_Iterable_Aspect): Prevent crashes on syntactically
illegal aspect expression.
* sem_util.adb
(Get_Cursor_Type): Fix style.
* gnat_ugn.texi, gnat_rm.texi: Regenerate.
Eric Botcazou [Mon, 1 Aug 2022 21:10:40 +0000 (23:10 +0200)]
[Ada] Correctly round Value attribute for floating point in more cases
This provides correct rounding in the IEEE 754 sense for the Value attribute
of floating-point types in more cases, by bumping the number of significant
bits used in the initial integer mantissa obtained from parsing.
gcc/ada/
* libgnat/s-valuer.ads (System.Value_R): Add Parts formal parameter
as well as Data_Index, Scale_Array and Value_Array types.
(Scan_Raw_Real): Change type of Scale and return type.
(Value_Raw_Real): Likewise.
* libgnat/s-valuer.adb (Round_Extra): Reorder parameters and adjust
recursive call.
(Scan_Decimal_Digits): Reorder parameters, add N parameter and deal
with multi-part scale and value.
(Scan_Integral_Digits): Likewise.
(Scan_Raw_Real): Change type of Scale and return type and deal with
multi-part scale and value.
(Value_Raw_Real): Change type of Scale and return type and tidy up.
* libgnat/s-valued.adb (Impl): Pass 1 as Parts actual parameter.
(Scan_Decimal): Adjust to type changes.
(Value_Decimal): Likewise.
* libgnat/s-valuef.adb (Impl): Pass 1 as Parts actual parameter.
(Scan_Fixed): Adjust to type changes.
(Value_Fixed): Likewise.
* libgnat/s-valrea.adb (Need_Extra): Delete.
(Precision_Limit): Always use the precision of the mantissa.
(Impl): Pass 2 as Parts actual parameter.
(Exact_Log2): New expression function.
(Integer_to_Real): Change type of Scale and Val and deal with a
2-part integer mantissa.
(Scan_Real): Adjust to type changes.
(Value_Real): Likewise.
Xianmiao Qu [Tue, 6 Sep 2022 07:10:36 +0000 (15:10 +0800)]
C-SKY: Fix missing operand when do spilt for cskyv2_addcc and cskyv2_addcc_invert.
It will cause ICE when compiling the case:
gcc/testsuite/gcc.dg/params/blocksort-part.c
gcc/
* config/csky/csky.md (cskyv2_addcc): Fix missing operand.
(cskyv2_addcc_invert): Likewise.
Jose E. Marchesi [Tue, 6 Sep 2022 06:58:23 +0000 (08:58 +0200)]
bpf: remove unused variables from bpf_expand_{prologue,epilogue}
gcc/ChangeLog:
* config/bpf/bpf.cc (bpf_expand_prologue): Remove unused automatic
`insn'.
(bpf_expand_epilogue): Likewise.
Xianmiao Qu [Tue, 6 Sep 2022 05:48:52 +0000 (13:48 +0800)]
Update c-sky port maintainers' emails.
/
* MAINTAINERS: Update c-sky port maintainers' emails.
liuhongt [Tue, 30 Aug 2022 09:32:47 +0000 (17:32 +0800)]
Fix _mm512_cvt_roundps_ph to generate sae instruction.
zmm-version vcvtps2ph is special, it encodes {sae} in evex, but put
round control in the imm. For intrinsic _mm512_cvt_roundps_ph (a,
imm), imm contains both {sae} and round control, we need to separate
it in the assembly output since vcvtps2ph will ignore imm[3:7].
gcc/ChangeLog:
* config/i386/i386-builtin.def (IX86_BUILTIN_CVTPS2PH512):
Map to CODE_FOR_avx512f_vcvtps2ph512_mask_sae.
* config/i386/sse.md (<mask_codefor>avx512f_vcvtps2ph512<mask_name>): Extend to ..
(<mask_codefor>avx512f_vcvtps2ph512<mask_name><round_saeonly_name>): .. this.
(avx512f_vcvtps2ph512_mask_sae): New expander
gcc/testsuite/ChangeLog:
* gcc.target/i386/avx512f-vcvtps2ph-sae.c: New test.
GCC Administrator [Tue, 6 Sep 2022 00:17:07 +0000 (00:17 +0000)]
Daily bump.
Joseph Myers [Mon, 5 Sep 2022 22:05:06 +0000 (22:05 +0000)]
preprocessor: Disable trigraphs for C2x
ISO C2x removes trigraphs, so disable them accordingly for -std=c2x
(they can still be enabled using -trigraphs).
Bootstrapped with no regressions for x86_64-pc-linux-gnu.
libcpp/
* init.cc (lang_defaults): Disable trigraphs for C2x.
gcc/testsuite/
* gcc.dg/cpp/c11-trigraphs-1.c, gcc.dg/cpp/c2x-trigraphs-1.c,
gcc.dg/cpp/c2x-trigraphs-2.c: New tests.
Aldy Hernandez [Mon, 5 Sep 2022 18:06:30 +0000 (20:06 +0200)]
Do not fold __builtin_signbit if NAN is a possibility.
I had some queued up work to try harder to keep the sign bit up to
date in the presence of NANs, but after the discussion with Richi
regarding the representation of NAN and signs in the frange, I've
decided to put it aside until after Cauldron, since it'll probably get
rewritten anyhow. So for now, the sign property in the frange is not
applicable to NANs.
Right now the only user of the sign bit that affects generated code
(apart from signed zeros) is __builtin_sign, so I'm just checking for
NAN there. Signed zeros continue working as before.
Regstrapped and mpfr checked on x86-64 Linux.
gcc/ChangeLog:
* gimple-range-fold.cc
(fold_using_range::range_of_builtin_int_call): Ignore sign bit
when there's the possibility of a NAN.
Aldy Hernandez [Mon, 5 Sep 2022 05:36:25 +0000 (07:36 +0200)]
Fold __builtin_signbit to nonzero instead of 1.
After Joseph's comment wrt __builtin_signbit, I have been unable to
convince myself that arbitrarily folding __builtin_signbit () of a
negative number to 1 is correct.
For example, on the true side of x < -5.0 we know the sign bit is set,
but on the false side, we know nothing because X may be a NAN. I
don't want to put ourselves in a position where the same call to
__builtin_signbit can return two different things (1 or negative
whatever), so I'm going to return nonzero which is correct across the
board until someone can convince me otherwise.
Setting the range to nonzero still allows us to fold conditionals
checking __fold_builtin, while not actually propagating a 1. Zero
propagation still works.
That being said, I still think we should be folding
__builtin_signbit's of negative numbers to whatever the hardware
returns, instead of 1/0 like what the front ends do.
gcc/ChangeLog:
* gimple-range-fold.cc
(fold_using_range::range_of_builtin_int_call): Fold a set signbit
in __builtin_signbit to nonzero.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/vrp-float-signbit-2.c: New test.
Alexander Monakov [Tue, 23 Aug 2022 15:42:24 +0000 (18:42 +0300)]
i386: avoid zero extension for crc32q
The crc32q instruction takes 64-bit operands, but ignores high 32 bits
of the destination operand, and zero-extends the result from 32 bits.
Let's model this in the RTL pattern to avoid zero-extension when the
_mm_crc32_u64 intrinsic is used with a 32-bit type.
PR target/106453
gcc/ChangeLog:
* config/i386/i386.md (sse4_2_crc32di): Model that only low 32
bits of operand 0 are consumed, and the result is zero-extended
to 64 bits.
gcc/testsuite/ChangeLog:
* gcc.target/i386/pr106453.c: New test.
Jonathan Wakely [Mon, 5 Sep 2022 14:52:34 +0000 (15:52 +0100)]
libstdc++: Move __success_type and __failure_type later in file
libstdc++-v3/ChangeLog:
* include/std/type_traits (__success_type, __failure_type): Move
definitions later in the file.
Tobias Burnus [Mon, 5 Sep 2022 16:05:24 +0000 (18:05 +0200)]
Fortran/openmp: Partial OpenMP 5.2 doacross and omp_cur_iteration support
Add the Fortran support to the ME/C/C++ commit
r13-2388-ga651e6d59188da8992f8bfae2df1cb4e6316f9e6
gcc/fortran/ChangeLog:
* dump-parse-tree.cc (show_omp_namelist, show_omp_clauses): Handle
omp_cur_iteration and distinguish doacross/depend.
* gfortran.h (enum gfc_omp_depend_doacross_op): Renamed from
gfc_omp_depend_op.
(enum gfc_omp_depend_doacross_op): Add OMP_DOACROSS_SINK_FIRST,
Rename OMP_DEPEND_SINK to OMP_DOACROSS_SINK.
(gfc_omp_namelist) Handle renaming, rename depend_op to
depend_doacross_op.
(struct gfc_omp_clauses): Add doacross_source.
* openmp.cc (gfc_match_omp_depend_sink): Renamed to ...
(gfc_match_omp_doacross_sink): ... this; handle omp_all_memory.
(enum omp_mask2): Add OMP_CLAUSE_DOACROSS.
(gfc_match_omp_clauses): Handle 'doacross' and syntax changes to
depend.
(gfc_match_omp_depobj): Simplify as sink/source are now impossible.
(gfc_match_omp_ordered_depend): Request OMP_CLAUSE_DOACROSS.
(resolve_omp_clauses): Update sink/source checks.
(gfc_resolve_omp_directive): Resolve EXEC_OMP_ORDERED clauses.
* parse.cc (decode_omp_directive): Handle 'ordered doacross'.
* trans-openmp.cc (gfc_trans_omp_clauses): Handle doacross.
(gfc_trans_omp_do): Fix OMP_FOR_ORIG_DECLS handling if 'ordered'
clause is present.
(gfc_trans_omp_depobj): Update for member name change.
libgomp/ChangeLog:
* libgomp.texi (OpenMP 5.2): Update doacross/omp_cur_iteration status.
gcc/testsuite/ChangeLog:
* gfortran.dg/gomp/all-memory-1.f90: Update dg-error.
* gfortran.dg/gomp/depend-iterator-2.f90: Likewise.
* gfortran.dg/gomp/depobj-2.f90: Likewise.
* gfortran.dg/gomp/doacross-5.f90: New test.
* gfortran.dg/gomp/doacross-6.f90: New test.
Aldy Hernandez [Mon, 5 Sep 2022 13:41:39 +0000 (15:41 +0200)]
Disable decimal floating point in frange.
As Jakub mentioned in the PR, because many numbers have multiple
possible representations, we can't reliably return true for singleton_p.
For that matter, we may not be capable of modeling them just yet.
Disabling them until someone with DFP knowledge can opine or extend
frange.
PR middle-end/106831
gcc/ChangeLog:
* value-range.h (frange::supports_p): Disable decimal floats.
* range-op-float.cc (frange_drop_inf): Remove DECIMAL_FLOAT_MODE_P
check.
(frange_drop_ninf): Same.
Aldy Hernandez [Mon, 5 Sep 2022 13:28:55 +0000 (15:28 +0200)]
Do not ICE when updating a NAN to a non-NAN.
Updating a definite NAN to a definitely not NAN was an assertion
failure, but it turns out we can have such a scenario while attempting
to thread an impossible path. This patch updates the range to
undefined.
What happens in the testcase is that we are trying to thread path that
starts like this:
<bb 5> [local count:
81335936906]:
SR.30_3 = Nan;
goto <bb 7>; [100.00%]
<bb 7> [local count:
108447915740]:
# SR.30_25 = PHI <SR.30_3(5), SR.30_12(6)>
plus_33 = SR.30_25;
w1$value__13 = f_distance$D2421$value__1;
w2$value__14 = plus_33;
if (w1$value__13 == w2$value__14)
goto <bb 8>; [50.00%]
else
goto <bb 9>; [50.00%]
On the path, SR.30_25 is NAN, which ultimately makes w2$value__14 a NAN.
This means that the 7->8 is impossible on the path.
On the true arm (foperator_equal::op1_range) we are asserting that op1
(w1$value__13) is a !NAN because for the == conditional to succeed,
neither operand can be a NAN. But...we know that operand 2 is a NAN.
This is an impossible scenario.
We are ICEing because frange::set_nan() sees the NAN and the desire to
set the NAN flag to NO. The correct thing to do is to set the range
to undefined, which is basically unreachable, and will cause all the
right things to happen. For that matter, the threader will see that
an UNDEFINED range was calculated in the path and abort trying to
investigate paths in that direction.
PR middle-end/106824
gcc/ChangeLog:
* value-range.cc (frange::set_nan): Set undefined when updating a
NAN to a non-NAN.
gcc/testsuite/ChangeLog:
* g++.dg/pr106824.C: New test.
Jonathan Wakely [Thu, 1 Sep 2022 20:12:40 +0000 (21:12 +0100)]
libstdc++: Use built-ins for more variable templates
libstdc++-v3/ChangeLog:
* include/std/type_traits (is_trivial_v, is_trivially_copyable_v)
(is_standard_layout_v, is_pod_v, is_literal_type_v): Use
built-in instead of class template.
(is_same_v): Add partial specialization for true case.
Tim Lange [Sun, 4 Sep 2022 19:07:14 +0000 (21:07 +0200)]
analyzer: strcpy semantics
This patch adds modelling for the semantics of strcpy in the simple case
where the analyzer is able to infer a concrete string size.
Regrtested on Linux x86_64.
2022-09-04 Tim Lange <mail@tim-lange.me>
gcc/analyzer/ChangeLog:
* region-model-impl-calls.cc (region_model::impl_call_strcpy):
Handle the constant string case.
* region-model.cc (region_model::get_string_size):
New function to get the string size from a region or svalue.
* region-model.h (class region_model): Add get_string_size.
gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/out-of-bounds-4.c: New test.
* gcc.dg/analyzer/strcpy-3.c: New test.
Tim Lange [Sun, 4 Sep 2022 11:07:34 +0000 (13:07 +0200)]
analyzer: return a concrete offset for cast_regions
This patch fixes a bug where maybe_fold_sub_svalue did not fold the
access of a single char from a string to a char when the offset was zero
because get_relative_concrete_offset did return false for cast_regions.
Regrtested on Linux x86_64.
2022-09-04 Tim Lange <mail@tim-lange.me>
gcc/analyzer/ChangeLog:
* region.cc (cast_region::get_relative_concrete_offset):
New overloaded method.
* region.h: Add cast_region::get_relative_concrete_offset.
gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/fold-string-to-char.c: New test.
Kito Cheng [Mon, 5 Sep 2022 13:36:45 +0000 (21:36 +0800)]
RISC-V: Fix division instructions for `m` with `zmmul` extension.
gcc/ChangeLog:
* config/riscv/riscv.cc (riscv_option_override): Fix wrong
condition for MASK_DIV and simplify incompatible checking.
* config/riscv/riscv.md (muldi3): Adding parentheses.
Kyrylo Tkachov [Mon, 5 Sep 2022 13:31:32 +0000 (14:31 +0100)]
aarch64: Suggest an -mcpu option when user passes CPU name to -march
This small patch helps users who confuse -march and -mcpu on AArch64.
Sometimes users pass -march with a CPU name, where they most likely wanted to
use -mcpu, which would select the right architecture features *and* tune for
their desired CPU. Currently we'll just error out with an unkown architecture
message and list the valid architecture options.
With this patch we check if their string matches a known CPU and suggest they
use an -mcpu option instead.
So compiling with -march=neoverse-n1 will now give the error:
cc1: error: unknown value 'neoverse-n1' for '-march'
cc1: note: valid arguments are: armv8-a armv8.1-a armv8.2-a armv8.3-a armv8.4-a armv8.5-a armv8.6-a armv8.7-a armv8.8-a armv8-r armv9-a
cc1: note: did you mean '-mcpu=neoverse-n1'?
Bootstrapped and tested on aarch64-none-linux-gnu.
gcc/ChangeLog:
* config/aarch64/aarch64.cc (aarch64_validate_march): Check if invalid arch
string is a valid -mcpu string and emit hint.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/spellcheck_10.c: New test.
LiaoShihua [Wed, 13 Jul 2022 02:13:26 +0000 (10:13 +0800)]
RISC-V: Support Zmmul extension
gcc/ChangeLog:
* common/config/riscv/riscv-common.cc: Add Zmmul.
* config/riscv/riscv-opts.h (MASK_ZMMUL): New.
(TARGET_ZMMUL): Ditto.
* config/riscv/riscv.cc (riscv_option_override):Ditto.
* config/riscv/riscv.md: Add Zmmul
* config/riscv/riscv.opt: Ditto.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/zmmul-1.c: New test.
* gcc.target/riscv/zmmul-2.c: New test.
Richard Biener [Mon, 5 Sep 2022 12:22:51 +0000 (14:22 +0200)]
Remove MAX_SWITCH_CASES limit
The following removes the MAX_SWITCH_CASES limit to fight quadraticness
when looking up case labels from edges. Instead use the
{start,end}_recording_case_labels facility for that. For it to be
usable I've exported get_cases_for_edge from tree-cfg.cc.
* tree-cfg.h (get_cases_for_edge): Declare.
* tree-cfg.cc (get_cases_for_edge): Export.
* tree-ssa-uninit.cc (execute_late_warn_uninitialized):
Start and end recording case labels.
* gimple-predicate-analysis.cc (MAX_SWITCH_CASES): Remove.
(predicate::init_from_control_deps): Use get_cases_for_edge.
Richard Biener [Mon, 5 Sep 2022 12:21:01 +0000 (14:21 +0200)]
Unify MAX_POSTDOM_CHECK and --param uninit-control-dep-attempts
The following unifies both limits, in particular the MAX_POSTDOM_CHECK
tends to be too low and is not user-controllable.
* gimple-predicate-analysis.cc (MAX_POSTDOM_CHECK): Remove.
(compute_control_dep_chain): Move uninit-control-dep-attempts
checking where it also counts the post-dominator check
invocations.
Richard Biener [Mon, 5 Sep 2022 12:17:36 +0000 (14:17 +0200)]
debug () for predicates
The following adds a debug () member to the predicate class.
* gimple-predicate-analysis.h (predicate::debug): New.
(predicate::dump): Add FILE * argument, add base overload.
* gimple-predicate-analysis.cc (debug): New.
(dump_pred_info): Add FILE * argument.
(dump_pred_chain): Likewise.
(predicate::dump): Split out preamble into overload. Add
FILE * argument.
(predicate::debug): New.
(predicate::simplify): Adjust.
(predicate::normalize): Likewise.
(predicate::init_from_control_deps): Likewise.
Richard Sandiford [Mon, 5 Sep 2022 13:14:44 +0000 (14:14 +0100)]
aarch64: Remove lazy SIMD builtin initialisation
At one time the aarch64 port registered the Advanced SIMD builtins
lazily, when we first encountered a set of target flags that includes
+simd. These days we always initialise them at start-up, temporarily
forcing a conducive set of flags if necessary.
This patch removes some vestiges of the old way of doing things.
gcc/
* config/aarch64/aarch64-protos.h
(aarch64_init_simd_builtins): Remove prototype.
* config/aarch64/aarch64-builtins.cc
(aarch64_simd_builtins_initialized_p): Delete.
(aarch64_init_simd_builtins): Make static. Remove protection
against multiple calls.
* config/aarch64/aarch64-c.cc (aarch64_pragma_target_parse): Remove
lazy SIMD builtin initialization.
* config/aarch64/aarch64.cc
(aarch64_option_valid_attribute_p): Likewise.
Xi Ruoyao [Thu, 1 Sep 2022 10:38:14 +0000 (18:38 +0800)]
LoongArch: add -mdirect-extern-access option
As a new target, LoongArch does not use copy relocation as it's
problematic in some circumstances. One bad consequence is we are
emitting GOT for all accesses to all extern objects with default
visibility. The use of GOT is not needed in statically linked
executables, OS kernels etc. The GOT entry just wastes space, and the
GOT access just slow down the execution in those environments.
Before -mexplicit-relocs, we used "-Wa,-mla-global-with-pcrel" to tell
the assembler not to use GOT for extern access. But with
-mexplicit-relocs, we have to opt the logic in GCC.
The name "-mdirect-extern-access" is learnt from x86 port.
gcc/ChangeLog:
* config/loongarch/genopts/loongarch.opt.in: Add
-mdirect-extern-access option.
* config/loongarch/loongarch.opt: Regenerate.
* config/loongarch/loongarch.cc
(loongarch_symbol_binds_local_p): Return true if
TARGET_DIRECT_EXTERN_ACCESS.
(loongarch_option_override_internal): Complain if
-mdirect-extern-access is used with -fPIC or -fpic.
* doc/invoke.texi: Document -mdirect-extern-access for
LoongArch.
gcc/testsuite/ChangeLog:
* gcc.target/loongarch/direct-extern-1.c: New test.
* gcc.target/loongarch/direct-extern-2.c: New test.
Martin Liska [Mon, 5 Sep 2022 09:20:38 +0000 (11:20 +0200)]
docs: rename DEBUGGER_REGISTER_NUMBER in texi
gcc/ChangeLog:
* doc/tm.texi.in: Rename DEBUGGER_REGISTER_NUMBER to
DEBUGGER_REGNO.
* doc/tm.texi: Regenerate.
Martin Liska [Thu, 25 Aug 2022 07:05:47 +0000 (09:05 +0200)]
rename DBX_REGISTER_NUMBER to DEBUGGER_REGNO
gcc/ada/ChangeLog:
* sigtramp-vxworks-target.h: Rename DBX_REGISTER_NUMBER to
DEBUGGER_REGNO.
gcc/ChangeLog:
* config/aarch64/aarch64-protos.h (aarch64_dbx_regno):
Rename DBX_REGISTER_NUMBER to DEBUGGER_REGNO.
(aarch64_debugger_regno): Likewise.
* config/aarch64/aarch64.cc (aarch64_dbx_regno): Likewise.
(aarch64_debugger_regno): Likewise.
* config/aarch64/aarch64.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
(DWARF_FRAME_REGNUM): Likewise.
* config/alpha/alpha.h (DWARF_FRAME_REGNUM): Likewise.
* config/arc/arc.cc (arc_init_reg_tables): Likewise.
* config/arc/arc.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/arm/arm-protos.h (arm_dbx_regno): Likewise.
(arm_debugger_regno): Likewise.
* config/arm/arm.cc (arm_dbx_regno): Likewise.
(arm_debugger_regno): Likewise.
* config/arm/arm.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/bfin/bfin.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/c6x/c6x.cc: Likewise.
* config/c6x/c6x.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/cris/cris.h (enum reg_class): Likewise.
(DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/csky/csky.cc (enum reg_class): Likewise.
* config/csky/csky.h (DWARF_FRAME_REGNUM): Likewise.
(DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/frv/frv.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/gcn/gcn-hsa.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/gcn/gcn.cc (print_operand): Likewise.
* config/i386/bsd.h (ASM_QUAD): Likewise.
* config/i386/cygming.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
(DWARF_FRAME_REGNUM): Likewise.
* config/i386/darwin.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/i386/djgpp.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/i386/dragonfly.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/i386/freebsd.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/i386/gas.h: Likewise.
* config/i386/gnu-user.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/i386/i386.cc (enum reg_class): Likewise.
* config/i386/i386.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/i386/i386elf.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/i386/iamcu.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/i386/lynx.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/i386/netbsd-elf.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/i386/nto.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/i386/openbsdelf.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/i386/sysv4.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/i386/vxworks.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/i386/x86-64.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/ia64/ia64-protos.h (ia64_dbx_regno): Likewise.
(ia64_debugger_regno): Likewise.
* config/ia64/ia64.cc (ia64_output_function_prologue): Likewise.
(ia64_dbx_regno): Likewise.
(ia64_debugger_regno): Likewise.
(process_cfa_adjust_cfa): Likewise.
(process_cfa_register): Likewise.
(ia64_asm_unwind_emit): Likewise.
* config/ia64/ia64.h: Likewise.
* config/ia64/sysv4.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/lm32/lm32.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/m32c/m32c.cc (m32c_eh_return_stackadj_rtx): Likewise.
* config/m32c/m32c.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/m68k/linux.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/m68k/m68k.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
(__transfer_from_trampoline): Likewise.
* config/m68k/m68kelf.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/m68k/netbsd-elf.h (M68K_STATIC_CHAIN_REG_NAME): Likewise.
(DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/microblaze/microblaze.cc (microblaze_option_override): Likewise.
* config/microblaze/microblaze.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
(GP_DBX_FIRST): Likewise.
(GP_DEBUGGER_FIRST): Likewise.
* config/mips/vxworks.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/mmix/mmix-protos.h (mmix_dbx_regno): Likewise.
(mmix_debugger_regno): Likewise.
* config/mmix/mmix.cc (mmix_dbx_regno): Likewise.
(mmix_debugger_regno): Likewise.
* config/mmix/mmix.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/nds32/nds32-protos.h (nds32_dbx_regno): Likewise.
(nds32_debugger_regno): Likewise.
* config/nds32/nds32.cc (nds32_dbx_regno): Likewise.
(nds32_debugger_regno): Likewise.
(nds32_use_blocks_for_constant_p): Likewise.
* config/nds32/nds32.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/nvptx/nvptx.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/or1k/or1k.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/pa/pa32-regs.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/pa/pa64-regs.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/rs6000/rs6000-protos.h (rs6000_dbx_regno): Likewise.
(rs6000_debugger_regno): Likewise.
* config/rs6000/rs6000.cc (rs6000_dbx_regno): Likewise.
(rs6000_debugger_regno): Likewise.
* config/rs6000/rs6000.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
(DWARF2_FRAME_REG_OUT): Likewise.
* config/s390/s390.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/sh/elf.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/sh/linux.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/sh/sh.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
(SH_DBX_REGISTER_NUMBER): Likewise.
(SH_DEBUGGER_REGNO): Likewise.
* config/visium/visium.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/xtensa/elf.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/xtensa/linux.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/xtensa/uclinux.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* config/xtensa/xtensa-protos.h (xtensa_dbx_regno): Likewise.
(xtensa_debugger_regno): Likewise.
* config/xtensa/xtensa.cc (xtensa_dbx_regno): Likewise.
(xtensa_debugger_regno): Likewise.
* config/xtensa/xtensa.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
* defaults.h (DBX_REGISTER_NUMBER): Likewise.
(DEBUGGER_REGNO): Likewise.
(DWARF_FRAME_REGNUM): Likewise.
* doc/tm.texi: Likewise.
* doc/tm.texi.in: Likewise.
* dwarf2out.cc (dbx_reg_number): Likewise.
(debugger_reg_number): Likewise.
(reg_loc_descriptor): Likewise.
(multiple_reg_loc_descriptor): Likewise.
(mem_loc_descriptor): Likewise.
* except.cc: Likewise.
Piotr Trojanek [Tue, 2 Aug 2022 17:46:36 +0000 (19:46 +0200)]
[Ada] Move check for null array aggregates to expansion
Despite recent changes to runtime checks for null array aggregates,
GNATprove still struggles with N_Raise_Constraint_Error nodes inserted
into AST by aggregate resolution. The ultimate fix is to move these
checks to expansion (which is disabled in GNATprove mode) and explicitly
emit a proof check in the GNATprove backend.
gcc/ada/
* exp_aggr.adb (Check_Bounds): Move code and comment related to
check for null array aggregate from Resolve_Null_Array_Aggregate.
* sem_aggr.ads (Is_Null_Aggregate): Move spec from unit body.
* sem_aggr.adb (Resolve_Null_Array_Aggregate): Move check to
expansion.
Piotr Trojanek [Sun, 31 Jul 2022 20:11:30 +0000 (22:11 +0200)]
[Ada] Fix inconsistent building of itypes for null array aggregates
To analyze Ada 2022 null array aggregates we introduced a dedicated
routine and bypassed the code for ordinary array aggregates. However,
the types for the array indexes created by this dedicated routine
differed from the types created for ordinary array aggregates, i.e.
itypes for null array aggregates were associated with the array subtype
declaration, while itypes for ordinary array aggregates were associated
with the aggregate itself. These differences cause trouble for various
routines in GNATprove.
This patch reduces the special handling of null array aggregates and
reuses the building of itypes for ordinary array aggregates.
gcc/ada/
* sem_aggr.adb
(Array_Aggr_Subtype): Bypass call to Collect_Aggr_Bound with
dedicated code for null array aggregates.
(Resolve_Array_Aggregate): Remove special handling of null array
aggregates.
(Resolve_Array_Aggregate): Create bounds, but let
Array_Aggr_Subtype create itype entities.
Piotr Trojanek [Sun, 31 Jul 2022 20:27:13 +0000 (22:27 +0200)]
[Ada] Fix insertion of a runtime check for null array aggregate
A null array aggregate of Ada 2022 requires a conditional runtime check
that was inserted as an if-statement. While gigi can handle statements
inserted into a list of declarations, in GNATprove such a statement will
cause a crash. It is better to insert a conditional raise node, which is
properly handled by both gigi and GNATprove.
gcc/ada/
* sem_aggr.adb (Resolve_Null_Array_Aggregate): Insert check as a
Raise_Constraint_Error node and not an If_Statement.
Piotr Trojanek [Thu, 21 Jul 2022 09:32:27 +0000 (11:32 +0200)]
[Ada] Cleanup iteration over aggregate component associations
Code cleanup related to fixes for iterated component associations in
GNATprove ; semantics is unaffected.
gcc/ada/
* sem_aggr.adb
(Resolve_Container_Aggregate): Style cleanup.
(Resolve_Record_Aggregate): Remove redundant guard.
Piotr Trojanek [Mon, 1 Aug 2022 08:51:46 +0000 (10:51 +0200)]
[Ada] Remove VMS specific routine that is no longer referenced
Code cleanup related to resctrition No_Local_Allocators.
gcc/ada/
* exp_util.ads (Entry_Names_OK): Remove spec.
* exp_util.adb (Entry_Names_OK): Remove body.
Steve Baird [Wed, 27 Jul 2022 00:17:17 +0000 (17:17 -0700)]
[Ada] Single-element Append performance improvement
Ada.Containers.Vectors has two Append procedures that take an
Element value; one takes a Count parameter and one does not
(the count is implicitly one for the latter). For the former version,
there was code that took a faster path if certain conditions were met
and otherwise took a slower path; one of the prerequisite conditions
for this was Count = 1. For the latter version, no such special-case
detection was performed; the more general code was always executed.
Move the special-case detection/handling code from the former version into
the latter and change the former version to simply call the latter version
if Count = 1. Also apply same change to Ada.Containers.Indefinite_Vectors.
gcc/ada/
* libgnat/a-coinve.adb, libgnat/a-convec.adb
(Append): If the Append that takes an Element and a Count is
called with Count = 1, then call the Append that does not take a
Count parameter; otherwise call the code that handles the general
case. Move the special case detection/handling code that was
formerly in that version of Append into the version that does not
take a Count parameter, so that now both versions get the
performance benefit.
Piotr Trojanek [Wed, 27 Jul 2022 07:37:05 +0000 (09:37 +0200)]
[Ada] Create internal type for null array aggregate as an itype
Internal type created for the null array aggregate of Ada 2022 was
created as a temporary entity and then flagged as internal, but it is
better to create this type directly as an itype.
In particular, when the null array aggregate appears in a spec
expression, its type declaration will not be attached to the AST.
An itype will have Associated_Node_For_Itype, so that the context of
the type can be recovered, which is what GNATprove does.
gcc/ada/
* sem_aggr.adb (Resolve_Null_Array_Aggregate): Create internal
type for the aggregate as an itype.
Piotr Trojanek [Tue, 26 Jul 2022 20:47:58 +0000 (22:47 +0200)]
[Ada] Remove no longer referenced GNATprove utility routine for itypes
Code cleanup related to itypes for Ada 2022 null array aggregates.
Remove routine that was added in 2011 but is not referenced by
GNATprove since 2015.
gcc/ada/
* sem_util.ads (Itype_Has_Declaration): Remove spec.
* sem_util.adb (Itype_Has_Declaration): Remove body.
Steve Baird [Tue, 26 Jul 2022 00:19:29 +0000 (17:19 -0700)]
[Ada] Bad Default_Initial_Condition check for a not-default-initialized object
No Default_Initial_Condition check should be generated for an object
declaration that has an explicit initial value. Previously this was
implemented by testing the Has_Init_Expression flag, but this only works
if the object declaration was created by the parser (since only the
parser sets that attribute, at least currently).
gcc/ada/
* exp_ch3.adb
(Expand_N_Object_Declaration): In deciding whether to emit a DIC
check, we were previously testing the Has_Init_Expression flag.
Continue to test that flag as before, but add a test for the
syntactic presence of an initial value in the object declaration.
This new test would not supersede the old test in the case where
an explicit initial value has been eliminated as part of some tree
transformation.
Piotr Trojanek [Mon, 25 Jul 2022 20:41:21 +0000 (22:41 +0200)]
[Ada] Fix detection of unused warning suppression
The comment for Warnings_Off says: "clients should generally not test
this flag directly, but instead use function Has_Warnings_Off".
Primarily a code cleanup, as this only affects minor a corner case.
gcc/ada/
* sem_ch13.adb (Validate_Unchecked_Conversions): Use
Has_Warnings_Off.
* sem_elab.adb (Check_Internal_Call_Continue): Likewise.
Eric Botcazou [Tue, 26 Jul 2022 15:33:06 +0000 (17:33 +0200)]
[Ada] Small cleanup in body of System.Value_R
This is mostly stylistic but also adds a couple of missing comments.
gcc/ada/
* libgnat/s-valuer.adb (Scan_Decimal_Digits): Consistently avoid
initializing local variables.
(Scan_Integral_Digits): Likewise.
(Scan_Raw_Real): Likewise and add a couple of comments.
Eric Botcazou [Fri, 22 Jul 2022 14:10:25 +0000 (16:10 +0200)]
[Ada] Fix bogus discriminant check failure for type with predicate
This reorders the processing in Freeze_Entity_Checks so that building the
predicate functions, which first requires building discriminated checking
functions for record types with a variant part, is done after processing
and checking this variant part.
gcc/ada/
* sem_ch13.adb (Freeze_Entity_Checks): Build predicate functions
only after checking the variant part of a record type, if any.
Piotr Trojanek [Thu, 21 Jul 2022 19:42:17 +0000 (21:42 +0200)]
[Ada] Detect expansion of iterated component associations into loops
Iterated component associations are expanded into loops, which GNAT
should detect as violating restriction No_Implicit_Loops; same for
iterated element associations and delta array aggregates.
Part of cleanups for correct handling of iterated component associations
in SPARK.
gcc/ada/
* exp_aggr.adb
(Two_Pass_Aggregate_Expansion): Expand into implicit rather than
ordinary loops, to detect violations of restriction
No_Implicit_Loops.
(Generate_Loop): Likewise for delta array aggregates.
Piotr Trojanek [Thu, 21 Jul 2022 15:47:11 +0000 (17:47 +0200)]
[Ada] Fix double identifiers in iterated component association
The iterated_component_association grammar construct appears in Ada RM
in two syntactic forms: with iterator_specification and with
defining_identifier. This is now properly reflected in the GNAT AST,
while previously we had two defining_identifiers regardless of the
syntactic form.
Cleanup related to handling of iterated_component_association in SPARK.
Behavior of the compiler itself should not be affected.
gcc/ada/
* exp_aggr.adb (Two_Pass_Aggregate_Expansion): Expand iterated
component association with an unanalyzed copy of iterated
expression. The previous code worked only because the expanded
loop used both an analyzed copy of the iterator_specification and
an analyzed copy of the iterated expression. Now the iterated
expression is reanalyzed in the context of the expanded loop.
* par-ch4.adb (Build_Iterated_Component_Association): Don't set
defining identifier when iterator specification is present.
* sem_aggr.adb (Resolve_Iterated_Association): Pick index name
from the iterator specification.
* sem_elab.adb (Traverse_Potential_Scenario): Handle iterated
element association just like iterated component association. Not
strictly part of this fix, but still worth for the completeness.
* sem_res.adb (Resolve): Pick index name from the iterator
specification, when present.
* sem_util.adb (Traverse_More): For completeness, just like the
change in Traverse_Potential_Scenario.
* sinfo.ads
(ITERATED_COMPONENT_ASSOCIATION): Fix and complete description.
(ITERATED_ELEMENT_ASSOCIATION): Likewise.
Bob Duff [Wed, 20 Jul 2022 21:37:51 +0000 (17:37 -0400)]
[Ada] Suppress warnings in trivial subprograms with finalization
There are heuristics for suppressing warnings about unused objects in
trivial cases. In particular, we try to suppress warnings here:
function F (A : Integer) return Some_Type;
X : Some_Type;
begin
raise Not_Yet_Implemented;
return X;
end F;
But it doesn't work if Some_Type is controlled. This patch fixes that
bug.
gcc/ada/
* sem_ch6.adb
(Analyze_Subprogram_Body_Helper): Use First_Real_Statement to deal
with this case. Note that First_Real_Statement is likely to be
removed as part of this ticket, so this is a temporary fix.
Arnaud Charlet [Tue, 19 Jul 2022 14:58:44 +0000 (14:58 +0000)]
[Ada] Secondary stack and i-c*
Extend the previous changes related to Ada.Tags trigerring a
dependency on the secondary stack to various i-c* packages.
gcc/ada/
* ali.adb (Scan_ALI): Special case i-c*.ali when setting
Sec_Stack_Used.
Bob Duff [Tue, 19 Jul 2022 21:06:30 +0000 (17:06 -0400)]
[Ada] Enable Error_Msg_GNAT_Extension for mixed decl/stmts
Enable mixing of declarative items and statements under
the -gnatX switch. The previous version used the -gnat2022
switch.
In addition, change the error message so that it advertises
the new feature when it is disabled. Instead of:
declarations must come before "begin"
we now say (without -gnatX):
declarations mixed with statements is a GNAT-specific extension
unit must be compiled with -gnatX or use pragma Extensions_Allowed (On)
gcc/ada/
* par-ch5.adb
(P_Sequence_Of_Statements): Call Error_Msg_GNAT_Extension to give
the error message.
Piotr Trojanek [Tue, 19 Jul 2022 11:57:05 +0000 (13:57 +0200)]
[Ada] Fix resolution of iterated component association
For iterator specification appearing inside an iterated component
association, we just did ad-hoc, incomplete checks and delayed a proper
analysis until the iterated component association is expanded into loop (and
then reanalyzed).
However, when the iterated component association is not expanded, e.g.
because we are in semantic checking mode, GNATprove mode or inside a
generic, then the AST lacked any processing or error reporting.
This is fixed by reusing the existing analysis of iterator specifications,
as they also appear in other constructs, e.g. in quantified expressions.
gcc/ada/
* sem_aggr.adb (Resolve_Iterated_Component_Association): Split
processing of cases with and without iterator specification; reuse
analysis of iterator specification; improve diagnostics for
premature usage of iterator index in discrete choices.
Piotr Trojanek [Tue, 19 Jul 2022 11:56:03 +0000 (13:56 +0200)]
[Ada] Cleanup analysis of iterator specifications
Code cleanup; semantics is unaffected.
gcc/ada/
* sem_ch5.adb (Check_Subtype_Definition): Remove redundant call to
Present; style cleanup.
Piotr Trojanek [Mon, 18 Jul 2022 19:53:31 +0000 (21:53 +0200)]
[Ada] Cleanup resolution of aggregates with mixed component associations
Code cleanup only; semantics is unaffected.
gcc/ada/
* sem_aggr.adb (Resolve_Array_Aggregate): Change an inconsistent
use of False into its local equivalent Failure.
Piotr Trojanek [Mon, 18 Jul 2022 16:56:52 +0000 (18:56 +0200)]
[Ada] Cleanup resolution of iterated component association
Tune names of local entities.
gcc/ada/
* sem_aggr.adb (Resolve_Iterated_Component_Association): Change
generic name Ent to a more intuitive Scop; rename Remove_Ref to
Remove_Reference, so it can be instantiated as a traversal routine
with plural name.
Piotr Trojanek [Mon, 18 Jul 2022 14:14:55 +0000 (16:14 +0200)]
[Ada] Cleanup analysis of quantified expressions with empty ranges
Cleanup handling of quantified expressions before using it as an inspiration
for fixing the handling of iterated component associations. Behavior is
unaffected.
gcc/ada/
* sem_ch4.adb
(Is_Empty_Range): Move error reporting to the caller.
(Analyze_Qualified_Expression): Move error reporting from Is_Empty_Range;
add matching call to End_Scope before rewriting and returning.
Arnaud Charlet [Mon, 18 Jul 2022 07:43:54 +0000 (07:43 +0000)]
[Ada] New gnatbind switch -k
This switch can be used to disable the effect of -F when using -n
explicitly or implicitly.
gcc/ada/
* bindgen.adb (Gen_Elab_Calls): Check for Check_Elaboration_Flags.
* bindusg.adb (Display): Add -k.
* opt.ads (Check_Elaboration_Flags): New.
* switch-b.adb (Scan_Binder_Switches): Add processing of -k.
* doc/gnat_ugn/building_executable_programs_with_gnat.rst: Add
documentation for -k and -K.
* gnat_ugn.texi: Regenerate.
Arnaud Charlet [Mon, 18 Jul 2022 07:11:42 +0000 (07:11 +0000)]
[Ada] Code cleanups
gcc/ada/
* treepr.adb: Remove local To_Lower and use the procedure
version instead.
Eric Botcazou [Sun, 17 Jul 2022 10:38:15 +0000 (12:38 +0200)]
[Ada] Fix crash for Default_Initial_Condition on derived enumeration type
This fixes a crash on the declaration of a private derived enumeration type
with the Default_Initial_Condition aspect and in the process makes a couple
of related adjustments: 1) removes the early freezing of implicit character
and numeric base types and 2) fixes an oversight in the implementation of
delayed representation aspects.
gcc/ada/
* aspects.ads (Delaying Evaluation of Aspect): Fix typos.
* exp_ch3.adb (Freeze_Type): Do not generate Invariant and DIC
procedures for internal types.
* exp_util.adb (Build_DIC_Procedure_Body): Adjust comment.
* freeze.adb (Freeze_Entity): Call Inherit_Delayed_Rep_Aspects for
subtypes and derived types only after the base or parent type has
been frozen. Remove useless freezing for first subtype.
(Freeze_Fixed_Point_Type): Call Inherit_Delayed_Rep_Aspects too.
* layout.adb (Set_Elem_Alignment): Deal with private types.
* sem_ch3.adb (Build_Derived_Enumeration_Type): Build the implicit
base as an itype and do not insert its declaration in the tree.
(Build_Derived_Numeric_Type): Do not freeze the implicit base.
(Derived_Standard_Character): Likewise.
(Constrain_Enumeration): Inherit the chain of representation items
instead of replacing it.
* sem_ch13.ads (Inherit_Aspects_At_Freeze_Point): Add ??? comment.
(Inherit_Delayed_Rep_Aspects): Declare.
* sem_ch13.adb (Analyze_Aspects_At_Freeze_Point): Do not invoke
Inherit_Delayed_Rep_Aspects.
(Inherit_Aspects_At_Freeze_Point): Deal with private types.
(Inherit_Delayed_Rep_Aspects): Move to library level.
Piotr Trojanek [Thu, 25 Feb 2021 20:52:22 +0000 (21:52 +0100)]
[Ada] Cleanup expansion of attribute Priority
Semantically neutral cleanup after the main fix for expansion of
attribute Priority.
gcc/ada/
* einfo-utils.adb (Number_Entries): Refine type of a local variable.
* exp_attr.adb (Expand_N_Attribute_Reference): Rename Conctyp to
Prottyp; refactor repeated calls to New_Occurrence_Of; replace
Number_Entries with Has_Entries.
* exp_ch5.adb (Expand_N_Assignment_Statement): Likewise; remove Subprg
variable (apparently copy-pasted from expansion of the attribute).
Piotr Trojanek [Fri, 30 Oct 2020 23:01:43 +0000 (00:01 +0100)]
[Ada] Fix expansion of attribute Priority
gcc/ada/
* exp_attr.adb (Expand_N_Attribute_Reference): Fix detection of the
enclosing protected type and of the enclosing protected subprogram.
* exp_ch5.adb (Expand_N_Assignment_Statement): Likewise.
Piotr Trojanek [Tue, 12 Jul 2022 13:35:00 +0000 (15:35 +0200)]
[Ada] Remove excessive guards against inserting empty lists of actions
Call to Insert_Actions with empty list does nothing, so there is no need to
guard against such calls. Code cleanup; behavior is unaffected.
gcc/ada/
* freeze.adb (Freeze_Itype): Remove excessive guard.
* sem_ch5.adb (Analyze_Loop_Parameter_Specification): Likewise.
Piotr Trojanek [Tue, 12 Jul 2022 11:18:19 +0000 (13:18 +0200)]
[Ada] Improve pretty-printing of iterated component associations
Pretty-printing used mostly in the debugger now handles more Ada 2022
syntax features. In particular, now it correctly handles expressions like
"[for E of A when E /= X => E]".
gcc/ada/
* sprint.adb (Sprint_Node_Actual): Handle iterator_specification within
iterated_component_association and iterator_filter within
iterator_specification.
Arnaud Charlet [Fri, 15 Jul 2022 07:40:11 +0000 (03:40 -0400)]
[Ada] Fix syntax in documentation
Leading to a poorly formatted example section.
gcc/ada/
* doc/gnat_ugn/gnat_and_program_execution.rst: Fix rest syntax
* gnat_ugn.texi: Regenerate.