Richard Biener [Fri, 17 May 2024 09:02:29 +0000 (11:02 +0200)]
middle-end/115110 - Fix view_converted_memref_p
view_converted_memref_p was checking the reference type against the
pointer type of the offset operand rather than its pointed-to type
which leads to all refs being subject to view-convert treatment
in get_alias_set causing numerous testsuite fails but with its
new uses from r15-512-g9b7cad5884f21c is also a wrong-code issue.
Eric Botcazou [Fri, 17 May 2024 09:44:30 +0000 (11:44 +0200)]
Small fix to implementation of -fdump-ada-spec
gcc/c-family/
* c-ada-spec.cc (bitfield_used): Move around.
(packed_layout): Likewise.
(dump_ada_array_type): Do not put "aliased" for a packed layout.
Eric Botcazou [Wed, 8 May 2024 08:07:56 +0000 (10:07 +0200)]
Add widening expansion of MULT_HIGHPART_EXPR for integral modes
For integral modes the expansion of MULT_HIGHPART_EXPR requires the presence
of an {s,u}mul_highpart optab whereas, for vector modes, widening expansion
is supported. This adds a widening expansion for integral modes too, which
is in fact already implemented in expmed_mult_highpart_optab.
gcc/
* expmed.h (expmed_mult_highpart_optab): Declare.
* expmed.cc (expmed_mult_highpart_optab): Remove static keyword.
Do not assume that OP1 is a constant integer. Fix pasto.
(expmed_mult_highpart): Pass OP1 narrowed to MODE in all the calls
to expmed_mult_highpart_optab.
* optabs-query.cc (can_mult_highpart_p): Use 2 for integer widening
and shift subsequent values accordingly.
* optabs.cc (expand_mult_highpart): Call expmed_mult_highpart_optab
when can_mult_highpart_p returns 2 and adjust to above change.
Richard Biener [Fri, 17 May 2024 07:31:52 +0000 (09:31 +0200)]
Add missing check for const_pool in the escaped solutions
The ptr-vs-ptr compare folding using points-to info was missing a
check for const_pool being included in the escaped solution. The
following fixes that, fixing the observed execute FAIL of
experimental/functional/searchers.cc
ada: Remove outdated workaround in aggregate expansion
Before this patch, the compiler refrained from rewriting aggregates
into purely positional form in some cases of one-component aggregates.
As explained in comments, this was because the back end could not
handle positional aggregates in those situations.
As the back end seems to have grown more capable, this patch removes
the workaround. It also extends the comments describing a warning that
is emitted in the same configuration with aggregates.
gcc/ada/
* exp_aggr.adb (Aggr_Size_OK): Remove workaround and extend
comment.
Eric Botcazou [Fri, 15 Mar 2024 15:46:16 +0000 (16:46 +0100)]
ada: Start the initialization of the tasking runtime earlier
This installs the tasking versions of the RTS_Lock manipulation routines
very early, before the elaboration of all the Ada units of the program,
including those of the runtime, because this elaboration may require the
initialization of RTS_Lock objects.
gcc/ada/
* bindgen.adb (Gen_Adainit): Generate declaration and call to the
imported procedure __gnat_tasking_runtime_initialize if need be.
* libgnat/s-soflin.ads (Locking Soft-Links): Add commentary.
* libgnarl/s-tasini.adb (Tasking_Runtime_Initialize): New procedure
exported as __gnat_tasking_runtime_initialize. Initialize RTS_Lock
manipulation routines here instead of...
(Init_RTS): ...here.
Steve Baird [Thu, 14 Mar 2024 00:46:56 +0000 (17:46 -0700)]
ada: Improve test for unprocessed preprocessor directives
Preprocessor directives are case insensitive and may have spaces or tabs
between the '#' and the keyword. When checking for the error case of
unprocessed preprocessor directives, take these rules into account.
gcc/ada/
* scng.adb (scan): When checking for an unprocessed preprocessor
directive, take into account the preprocessor's rules about case
insensitivity and about white space between the '#' and the
keyword.
Eric Botcazou [Tue, 5 Mar 2024 22:30:51 +0000 (23:30 +0100)]
ada: Replace spinlocks with fully-fledged locks in finalization collections
This replaces spinlocks with fully-fledged locks in finalization collections
because the former are deemed problematic with tasks that can be preempted.
Because of the requirement to avoid dragging the tasking runtime when it is
not necessary, the implementation goes through the usual soft links, with an
additional hurdle that space must be reserved for the lock in any case since
it is part of the ABI. This entails the introduction of the System.OS_Locks
unit in the non-tasking runtime and the modification of the tasking runtime
to also use this unit.
This in turn requires a small adjustment: because of the presence of pre-
and post-conditions in Interfaces.C and of the limitations of the RTSfind
mechanism, the System.Finalization_Primitives unit must be preloaded, as
what is done for the Ada.Strings.Text_Buffers unit.
This effectively reverts the implementation to using the global task lock on
bare board platforms.
gcc/ada/
* Makefile.rtl (GNATRTL_NONTASKING_OBJS): Add s-oslock$(objext).
(LIBGNAT_TARGET_PAIRS): Use s-oslock__dummy.ads by default.
Set specific s-oslock.ads source file for all the platforms.
* exp_ch7.ads (Preload_Finalization_Collection): New procedure.
* exp_ch7.adb (Allows_Finalization_Collection): Return False if
System.Finalization_Primitives has not been preloaded.
(Preload_Finalization_Collection): New procedure.
* opt.ads (Interface_Seen): New boolean variable.
* s-oscons-tmplt.c: Use "N" string for pragma Style_Checks.
* scng.adb (Scan): Set Interface_Seen upon seeing "interface".
* sem_ch10.adb: Add clause for Exp_Ch7.
(Analyze_Compilation_Unit): Call Preload_Finalization_Collection
after the context of the unit is analyzed.
* libgnarl/a-rttiev.adb: Add with clause for System.OS_Locks and
alphabetize others.
(Event_Queue_Lock): Adjust qualified name of subtype.
* libgnarl/s-osinte__aix.ads: Add with clause for System.OS_Locks
and change pthread_mutex_t into a local subtype.
* libgnarl/s-osinte__android.ads: Likewise.
* libgnarl/s-osinte__darwin.ads: Likewise.
* libgnarl/s-osinte__dragonfly.ads: Likewise.
* libgnarl/s-osinte__freebsd.ads: Likewise.
* libgnarl/s-osinte__gnu.ads: Likewise.
* libgnarl/s-osinte__hpux-dce.ads: Likewise.
* libgnarl/s-osinte__hpux.ads: Add Likewise.
* libgnarl/s-osinte__kfreebsd-gnu.ads: Likewise.
* libgnarl/s-osinte__linux.ads: Likewise.
* libgnarl/s-osinte__lynxos178e.ads: Likewise.
* libgnarl/s-osinte__qnx.ads: Likewise.
* libgnarl/s-osinte__rtems.ads: Likewise.
* libgnarl/s-osinte__mingw.ads: Add with clause for System.OS_Locks
and change CRITICAL_SECTION into a local subtype. Add declarations
for imported procedures dealing with CRITICAL_SECTION.
* libgnarl/s-osinte__solaris.ads: Add with clause for System.OS_Locks
and change mutex_t into a local subtype.
* libgnarl/s-osinte__vxworks.ads: Add missing blank line.
* libgnarl/s-taprop.ads: Alphabetize clauses and package renamings.
Use qualified name for RTS_Lock throughout.
* libgnarl/s-taprop__dummy.adb: Add use clause for System.OS_Locks
and alphabetize others.
* libgnarl/s-taprop__hpux-dce.adb: Likewise.
* libgnarl/s-taprop__linux.adb: Likewise.
* libgnarl/s-taprop__posix.adb: Likewise.
* libgnarl/s-taprop__qnx.adb: Likewise.
* libgnarl/s-taprop__rtems.adb: Likewise.
* libgnarl/s-taprop__solaris.adb: Likewise.
* libgnarl/s-taprop__vxworks.adb: Likewise.
* libgnarl/s-taprop__mingw.adb: Likewise. Remove declarations for
imported procedures dealing with CRITICAL_SECTION.
* libgnarl/s-tarest.adb: Add with clause for System.OS_Locks and
alphabetize others.
(Global_Task_Lock): Adjust qualified name of subtype.
* libgnarl/s-tasini.adb: Add clause for System.OS_Locks.
(Initialize_RTS_Lock): New procedure.
(Finalize_RTS_Lock): Likewise.
(Acquire_RTS_Lock): Likewise.
(Release_RTS_Lock): Likewise.
(Init_RTS): Add compile-time assertions for RTS_Lock types.
Set the soft links for the RTS lock manipulation routines.
* libgnarl/s-taspri__dummy.ads: Add with clause for System.OS_Locks.
(RTS_Lock): Delete and adjust throughout accordingly.
* libgnarl/s-taspri__hpux-dce.ads: Likewise.
* libgnarl/s-taspri__lynxos.ads: Likewise.
* libgnarl/s-taspri__mingw.ads: Likewise.
* libgnarl/s-taspri__posix-noaltstack.ads: Likewise.
* libgnarl/s-taspri__posix.ads: Likewise.
* libgnarl/s-taspri__solaris.ads: Likewise.
* libgnarl/s-taspri__vxworks.ads: Likewise.
* libgnat/s-finpri.ads: Add clause for System.OS_Locks.
(Finalization_Collection): Change type of Lock.
* libgnat/s-finpri.adb (Initialize): Call Initialize_RTS_Lock.
(Lock_Collection): Call Acquire_RTS_Lock.
(Unlock_Collection): Call Release_RTS_Lock.
* libgnat/s-oslock__dummy.ads: New file.
* libgnat/s-oslock__hpux-dce.ads: Likewise.
* libgnat/s-oslock__mingw.ads: Likewise.
* libgnat/s-oslock__posix.ads: Likewise.
* libgnat/s-oslock__solaris.ads: Likewise.
* libgnat/s-oslock__vxworks.ads: Likewise.
* libgnat/s-soflin.ads (Null_Set_Address): New null procedure.
(Initialize_RTS_Lock): New soft link.
(Finalize_RTS_Lock): Likewise.
(Acquire_RTS_Lock): Likewise.
(Release_RTS_Lock): Likewise.
* exp_ch4.adb (Expand_N_Allocator): In the subtype indication case,
call Apply_Predicate_Check on the resulting access value if need be.
Steve Baird [Tue, 12 Mar 2024 00:45:58 +0000 (17:45 -0700)]
ada: Bug in computing local restrictions inherited from enclosing scopes.
In the function Local_Restrict.Active_Restriction, we traverse enclosing
scopes looking for a relevant Local_Restrictions aspect specification.
Fix a bug in this traversal.
gcc/ada/
* local_restrict.adb (Active_Restriction): When traversing scopes,
do not skip over a subprogram body.
Eric Botcazou [Mon, 4 Mar 2024 11:44:11 +0000 (12:44 +0100)]
ada: Factor out duplicated code in bodies of System.Task_Primitives.Operations
The duplication is present in some POSIX-like implementations (POSIX
and RTEMS) while it has already been eliminated in others (Linux, QNX). The
latter implementations are also slightly modified for consistency's sake.
No functional changes.
gcc/ada/
* libgnarl/s-taprop__dummy.adb (Initialize_Lock): Fix formatting.
* libgnarl/s-taprop__linux.adb (RTS_Lock_Ptr): Delete.
(Init_Mutex): Rename into...
(Initialize_Lock): ...this.
(Initialize_Lock [Lock]): Call above procedure.
(Initialize_Lock [RTS_Lock]): Likewise.
(Initialize_TCB): Likewise.
* libgnarl/s-taprop__posix.adb (Initialize_Lock): New procedure
factored out from the other two homonyms.
(Initialize_Lock [Lock]): Call above procedure.
(Initialize_Lock [RTS_Lock]): Likewise.
* libgnarl/s-taprop__qnx.adb (RTS_Lock_Ptr): Delete.
(Init_Mutex): Rename into...
(Initialize_Lock): ...this.
(Initialize_Lock [Lock]): Call above procedure.
(Initialize_Lock [RTS_Lock]): Likewise.
(Initialize_TCB): Likewise.
* libgnarl/s-taprop__rtems.adb (Initialize_Lock): New procedure
factored out from the other two homonyms.
(Initialize_Lock [Lock]): Call above procedure.
(Initialize_Lock [RTS_Lock]): Likewise.
Piotr Trojanek [Mon, 11 Mar 2024 22:02:50 +0000 (23:02 +0100)]
ada: Fix for validity checking and conditional evaluation of 'Old
Detection of expression that are "known on entry" (as defined in Ada
2022 RM 6.1.1(20/5)) was confused by validity checks when used from
within expansion of attribute 'Old.
gcc/ada/
* sem_util.adb (Is_Known_On_Entry): Handle constants introduced
by validity checks.
Steve Baird [Fri, 8 Mar 2024 23:48:32 +0000 (15:48 -0800)]
ada: Do not query the modification time of a special file.
In Ada.Directories, the function Modification_Time raises Name_Error if it is
called for a special file. So don't do that in Start_Search_Internal.
gcc/ada/
* libgnat/a-direct.adb (Start_Search_Internal): Do not call
Modification_Time for a special file; declare a Calendar.Time
constant No_Time and use that instead.
Steve Baird [Sat, 9 Mar 2024 00:17:41 +0000 (16:17 -0800)]
ada: Disable Equivalent_Array_Aggregate optimization if predicates involved
In most paths, the function Build_Equivalent_Record_Aggregate was already
testing Has_Predicates for a given component type and conditionally returning
an Empty result. This is also needed in the case of a scalar component type.
Without it, we can build corrupt trees that fail use-before-definition
detection checks in gigi.
gcc/ada/
* exp_ch3.adb (Build_Equivalent_Record_Aggregate): Add
Has_Predicates test for a scalar component to match what is
already done for other kinds of components.
This patch improves comments in code that emits warnings about
particular situations involving aggregates. It also removes a
conjunct in a condition that's useless because always true in the
context of the test.
gcc/ada/
* sem_aggr.adb (Resolve_Array_Aggregate): Improve comments
and condition.
Before this patch, the compiler pointed at the wrong component
association when reporting an illegal occurrence of "others" in an
aggregate. This patch fixes this by keeping track of which choice
contains the occurrence of "others" when resolving array aggregates.
gcc/ada/
* sem_aggr.adb (Resolve_Array_Aggregate): Fix location of error
message.
Piotr Trojanek [Fri, 8 Mar 2024 16:02:16 +0000 (17:02 +0100)]
ada: Expose utility routine for processing of Depends contracts in SPARK
Routine Is_Unconstrained_Or_Tagged_Item is now used both in the GNAT
frontend (for checking legality of Depends clauses) and in the GNATprove
backend (for representing implicit inputs in flow graphs).
gcc/ada/
* sem_prag.adb (Is_Unconstrained_Or_Tagged_Item): Move to
Sem_Util, so it can be used from GNATprove.
* sem_util.ads (Is_Unconstrained_Or_Tagged_Item): Move from
Sem_Prag; spec.
* sem_util.adb (Is_Unconstrained_Or_Tagged_Item): Move from
Sem_Prag; body.
Eric Botcazou [Sun, 10 Mar 2024 14:51:21 +0000 (15:51 +0100)]
ada: Couple of adjustments coming from aliasing considerations
The first adjustment is to the expansion of implementation types for array
types with peculiar index types, for which the aliased property set on the
component of the original type must be copied; the implicit base type also
needs to be properly marked if the implementation type is constrained.
The second adjustment is to selected types in the runtime, which need to
be marked with pragma Universal_Aliasing because of their special usage.
gcc/ada/
* exp_pakd.adb (Create_Packed_Array_Impl_Type): For non-bit-packed
array types, propagate the aliased property of the component.
(Install_PAT): Set fields on the implicit base type of an array.
* libgnat/a-stream.ads (private part): Add pragma Universal_Aliasing
for Stream_Element.
* libgnat/g-alleve.ads: Add pragma Universal_Aliasing for all the
vector types.
* libgnat/g-alleve__hard.ads: Likewise.
Bob Duff [Fri, 8 Mar 2024 14:32:51 +0000 (09:32 -0500)]
ada: gnatbind: subprogram spec no longer exists
If a subprogram spec S is present while compiling something that
says "with S;", but the spec is absent while compiling the body
of S, then gnatbind fails to detect the mismatch. The spec and
body of S might have different parameter and result types.
This patch fixes gnatbind to detect this case and give an error.
gcc/ada/
* bcheck.adb (Check_Consistency_Of_Sdep): Split out new procedure.
Add check for special case of subprogram spec that no longer
exists.
(Check_Consistency): Call Check_Consistency_Of_Sdep, except when
Reified_Child_Spec is True. No need for "goto Continue" or "exit
Sdep_Loop".
* ali.ads (Subunit_Name, Unit_Name): Change the type to
Unit_Name_Type. Add a comment pointing to the ALI file
documentation, because it's in a somewhat-surprising place.
* ali.adb (Scan_ALI): Subunit_Name and Unit_Name are now
Unit_Name_Type. Remove comment explaining why Name_Find is used;
Name_Find is the usual case. Do not remove the "%s" or "%b" from
the Unit_Name. We need to be able to distinguish specs and bodies.
This is also necessary to obey the invariant of Unit_Name_Type.
* binde.adb (Write_Closure): Subunit_Name is now Unit_Name_Type.
* clean.adb (Clean_Executables): Likewise.
The documentation comments for Sem_Aggr.Resolve_Null_Array_Aggregate
suggested that this subprogram created a subtype, which it didn't.
This patch replaces those comments with ones that better match the
behavior.
Fix memory leaks in containers' Reference_Preserving_Key functions
Make the same change in each of 3 Ada.Containers child units: Ordered_Sets,
Indefinite_Ordered_Sets, and Bounded_Ordered_Sets. The function
Reference_Preserving_Key evaluates an allocator of type Key_Access whose
storage was not being reclaimed. Update the Finalize procedure for
type Reference_Control_Type to free that storage. But this change introduces
a possible erroneous double-free situation if an object is copied (because
the original and the copy will each be finalized at some point). So also
introduce an Adjust procedure which allocates a copy of the allocated object.
Another possible solution to this problem (which is not being implemented
yet) is based on implementing AI22-0082. Also include a fix for a bug in
Sem_Util.Has_Some_Controlled_Component that was discovered while working
on this.
gcc/ada/
* sem_util.adb (Has_Some_Controlled_Component): Fix a bug which
causes (in some cases involving a Disable_Controlled aspect
specification) Needs_Finalization to return different answers for
one type depending on whether the function is called before or
after the type is frozen.
* libgnat/a-coorse.ads: Type Control_Reference_Type gets an Adjust
procedure.
* libgnat/a-cborse.ads: Likewise.
* libgnat/a-ciorse.ads: Likewise
* libgnat/a-coorse.adb:
(Finalize): Reclaim allocated Key_Type object.
(Adjust): New procedure; prevent sharing of non-null Key_Access
values by allocating a copy.
* libgnat/a-cborse.adb: Likewise.
* libgnat/a-ciorse.adb: Likewise.
Bob Duff [Thu, 7 Mar 2024 12:43:26 +0000 (07:43 -0500)]
ada: gnatbind-related cleanups
This patch cleans up some things noticed while working on gnatbind.
No change in behavior yet.
gcc/ada/
* ali-util.adb (Read_Withed_ALIs): Minor reformatting.
* bindo-units.adb (Corresponding_Body): Add assert.
(Corresponding_Spec): Likewise.
* uname.adb: Clean up assertions, use available functions.
Get_Spec_Name/Get_Body_Name can assert that N obeys the
conventions for Unit_Name_Type (end in "%s" or "%b").
Marc Poulhiès [Tue, 5 Mar 2024 14:16:59 +0000 (15:16 +0100)]
ada: Fix crash caused by missing New_Copy_tree
Since a recent refactor ("Factor common processing in expansion of
aggregates") where Initialize_Array_Component and
Initialize_Record_Component are merged, the behavior has slightly
changed. In the case of the expansion of an aggregate initialization
where the number of 'others' components is <= 3, the initialization
expression is not duplicated anymore, causing some incorrect multiple
definition when said expression is later transformed with
Expressions_With_Action that declares an object. The simple fix is to
add the now missing New_Copy_Tree where the assignments are created.
gcc/ada/
* exp_aggr.adb (Build_Array_Aggr_Code) <Gen_Loop>: Copy the
initialization expression when unrolling the loop.
Bob Duff [Tue, 5 Mar 2024 23:35:25 +0000 (18:35 -0500)]
ada: Fix Constraint_Error on mutable assignment
For an assignment statement "X := Y;", where X is a formal parameter
of a "late overriding" subprogram (i.e. it has no spec, and the body
is overriding), and the subtype of X is an unconstrained record with
defaulted discriminants, if the actual parameter passed to X is
unconstrained, then X is unconstrained. This patch fixes a bug
where X was incorrectly considered constrained, so that if Y's
discriminants are different from X, Constraint_Error was raised.
The bug was caused by the fact that an extra "constrained" formal
parameter was missing in both caller and callee.
gcc/ada/
* sem_disp.adb (Check_Dispatching_Operation): Call
Create_Extra_Formals, so that the caller will have an extra
"constrained" parameter, which will be checked on assignment in
the callee, and will be passed in by the caller.
Piotr Trojanek [Tue, 5 Mar 2024 12:06:18 +0000 (13:06 +0100)]
ada: Simplify code for private types with unknown discriminants
Private type entities have Is_Constrained set when they have no
discriminants and no unknown discriminants; it is now set slightly
later, but simpler (this change could only affect Process_Discriminants,
but this flag should not be needed there).
Also, we now reuse this flag to detect private types with discriminants.
Code cleanup; behavior is unaffected.
gcc/ada/
* sem_ch7.adb (New_Private_Type): Simplify setting of
Is_Constrained flag.
* sem_prag.adb (Is_Unconstrained_Or_Tagged_Item): Simplify
detection of private types with no discriminant.
Piotr Trojanek [Tue, 5 Mar 2024 11:57:50 +0000 (12:57 +0100)]
ada: Tune detection of unconstrained and tagged items in Depends contract
The Tagged/Array/Record/Private types are mutually exclusive, so they
can be examined like with a case statement (except for records with
private extensions, but their handling is not affected by this change).
gcc/ada/
* sem_prag.adb (Is_Unconstrained_Or_Tagged_Item): Tune repeated
testing of type kinds.
Eric Botcazou [Fri, 1 Mar 2024 10:26:32 +0000 (11:26 +0100)]
ada: Add support for 'Object_Size to pragma Compile_Time_{Warning,Error}
With the same level as for 'Size, that is to say, full evaluation of the
boolean expressions it may be contained in and handling of private types.
gcc/ada/
* sem_attr.adb (Analyze_Attribute) <Attribute_Size>: Remove special
processing for pragma Compile_Time_{Warning,Error}.
(Eval_Attribute.Compile_Time_Known_Attribute): Set Is_Static on the
resulting value if In_Compile_Time_Warning_Or_Error is set.
(Eval_Attribute.Full_Type): New helper function.
(Eval_Attribute): Call Full_Type for type attributes. Add handling
of Object_Size and adjust that of Max_Size_In_Storage_Elements in
the non-static case.
Alexandre Oliva [Fri, 17 May 2024 03:45:45 +0000 (00:45 -0300)]
make -freg-struct-return visibly a negative alias of -fpcc-struct-return
The fact that both options accept negative forms suggests that maybe
they aren't negative forms of each other. They are, but that isn't
clear even by examining common.opt. Use NegativeAlias to make it
abundantly clear.
The 'Optimization' keyword next to freg-struct-return was the only
thing that caused flag_pcc_struct_return to be a per-function flag,
and ipa-inline relied on that. After making it an alias, the
Optimization keyword was no longer operational. I'm not sure it was
sensible or desirable for flag_pcc_struct_return to be a per-function
setting, but this patch does not intend to change behavior.
for gcc/ChangeLog
* common.opt (freg-struct-return): Make it explicitly
fpcc-struct-return's NegativeAlias. Copy Optimization...
(freg-struct-return): ... here.
Pan Li [Thu, 16 May 2024 02:04:10 +0000 (10:04 +0800)]
RISC-V: Enable vectorizable early exit testsuite
After we supported vectorizable early exit in RISC-V, we would like to
enable the gcc vect test for vectorizable early test.
The vect-early-break_124-pr114403.c failed to vectorize for now.
Because that the __builtin_memcpy with 8 bytes failed to folded into
int64 assignment during ccp1. We will improve that first and mark
this as xfail for RISC-V.
The below tests are passed for this patch:
1. The riscv fully regression tests.
gcc/testsuite/ChangeLog:
* gcc.dg/vect/slp-mask-store-1.c: Add pragma novector as it will
have 2 times LOOP VECTORIZED in RISC-V.
* gcc.dg/vect/vect-early-break_124-pr114403.c: Xfail for the
riscv backend.
* lib/target-supports.exp: Add RISC-V backend.
The below tests are passed for this patch:
1. The riscv fully regression tests.
gcc/ChangeLog:
* config/riscv/autovec-opt.md(*vcond_mask_len_popcount_<VB_VLS:mode><P:mode>):
New pattern of vcond_mask_len_popcount for vector bool mode.
* config/riscv/autovec.md (vcond_mask_len_<mode>): New pattern of
vcond_mask_len for vector bool mode.
(cbranch<mode>4): New pattern for vector bool mode.
* config/riscv/vector-iterators.md: Add new unspec UNSPEC_SELECT_MASK.
* config/riscv/vector.md (@pred_popcount<VB:mode><P:mode>): Add VLS mode
to popcount pattern.
(@pred_popcount<VB_VLS:mode><P:mode>): Ditto.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/early-break-1.c: New test.
* gcc.target/riscv/rvv/autovec/early-break-2.c: New test.
TARGET_MEM_REF can be used to offset constant base into a memory object (to
produce lea instruction). This confuses points_to_local_or_readonly_memory_p
which treats the constant address as a base of the access.
Richard Biener [Mon, 11 Mar 2024 10:17:32 +0000 (11:17 +0100)]
tree-optimization/13962 - handle ptr-ptr compares in ptrs_compare_unequal
Now that we handle pt.null conservatively we can implement the missing
tracking of constant pool entries (aka STRING_CST) and handle
ptr-ptr compares using points-to info in ptrs_compare_unequal.
PR tree-optimization/13962
PR tree-optimization/96564
* tree-ssa-alias.h (pt_solution::const_pool): New flag.
* tree-ssa-alias.cc (ptrs_compare_unequal): Handle pointer-pointer
compares.
(dump_points_to_solution): Dump the const_pool flag, fix guard
of flag dumping.
* gimple-pretty-print.cc (pp_points_to_solution): Likewise.
* tree-ssa-structalias.cc (find_what_var_points_to): Set
the const_pool flag for STRING.
(pt_solution_ior_into): Handle the const_pool flag.
(ipa_escaped_pt): Initialize it.
* gcc.dg/tree-ssa/alias-39.c: New testcase.
* g++.dg/vect/pr68145.cc: Use -fno-tree-pta to avoid UB
to manifest in transforms no longer vectorizing this testcase
for an ICE.
The below tests are passed for this patch:
1. The riscv fully regression tests.
2. The x86 bootstrap tests.
3. The x86 fully regression tests.
gcc/ChangeLog:
* tree-vect-loop.cc (vect_gen_loop_len_mask): New func to gen
the loop len mask.
* tree-vect-stmts.cc (vectorizable_early_exit): Invoke the
vect_gen_loop_len_mask for 1 or more stmt(s).
* tree-vectorizer.h (vect_gen_loop_len_mask): New func decl
for vect_gen_loop_len_mask.
Pan Li [Wed, 15 May 2024 02:14:06 +0000 (10:14 +0800)]
Vect: Support new IFN SAT_ADD for unsigned vector int
For vectorize, we leverage the existing vect pattern recog to find
the pattern similar to scalar and let the vectorizer to perform
the rest part for standard name usadd<mode>3 in vector mode.
The riscv vector backend have insn "Vector Single-Width Saturating
Add and Subtract" which can be leveraged when expand the usadd<mode>3
in vector mode. For example:
The below test suites are passed for this patch.
* The riscv fully regression tests.
* The x86 bootstrap tests.
* The x86 fully regression tests.
PR target/51492
PR target/112600
gcc/ChangeLog:
* tree-vect-patterns.cc (gimple_unsigned_integer_sat_add): New
func decl generated by match.pd match.
(vect_recog_sat_add_pattern): New func impl to recog the pattern
for unsigned SAT_ADD.
Pan Li [Wed, 15 May 2024 02:14:05 +0000 (10:14 +0800)]
Internal-fn: Support new IFN SAT_ADD for unsigned scalar int
This patch would like to add the middle-end presentation for the
saturation add. Aka set the result of add to the max when overflow.
It will take the pattern similar as below.
Before this patch:
uint64_t sat_add_uint64_t (uint64_t x, uint64_t y)
{
long unsigned int _1;
_Bool _2;
long unsigned int _3;
long unsigned int _4;
uint64_t _7;
long unsigned int _10;
__complex__ long unsigned int _11;
The below tests are passed for this patch:
1. The riscv fully regression tests.
3. The x86 bootstrap tests.
4. The x86 fully regression tests.
PR target/51492
PR target/112600
gcc/ChangeLog:
* internal-fn.cc (commutative_binary_fn_p): Add type IFN_SAT_ADD
to the return true switch case(s).
* internal-fn.def (SAT_ADD): Add new signed optab SAT_ADD.
* match.pd: Add unsigned SAT_ADD match(es).
* optabs.def (OPTAB_NL): Remove fixed-point limitation for
us/ssadd.
* tree-ssa-math-opts.cc (gimple_unsigned_integer_sat_add): New
extern func decl generated in match.pd match.
(match_saturation_arith): New func impl to match the saturation arith.
(math_opts_dom_walker::after_dom_children): Try match saturation
arith when IOR expr.
Aldy Hernandez [Thu, 16 May 2024 07:47:56 +0000 (09:47 +0200)]
Cleanup prange sanity checks.
The pointers_handled_p() code was a temporary sanity check, and not
even a good one, since we have a cleaner way of checking type
mismatches with operand_check_p. This patch removes all the code, and
adds an explicit type check for relational operators, which are the
main problem in PR114985.
Adding this check makes it clear where the type mismatch is happening
in IPA, even without prange. I've added code to skip the range
folding if the types don't match what the operator expects. In order
to reproduce the latent bug, just remove the operand_check_p calls.
Tested on x86-64 and ppc64le with and without prange support.
Aldy Hernandez [Thu, 16 May 2024 07:22:55 +0000 (09:22 +0200)]
Use a boolean type when folding conditionals in simplify_using_ranges.
In adding some traps for PR114985 I noticed that the conditional
folding code in simplify_using_ranges was using the wrong type. This
cleans up the oversight.
gcc/ChangeLog:
PR tree-optimization/114985
* vr-values.cc (simplify_using_ranges::fold_cond_with_ops): Use
boolean type when folding conditionals.
RISC-V: testsuite: Drop march-string in cmpmemsi/cpymemsi tests
The tests cmpmemsi-1.c and cpymemsi-1.c are execution ("dg-do run")
tests, which does not have any restrictions for the enabled extensions.
Further, no other listed options are required.
Let's drop the options, so that the test can also be executed on
non-f and non-d targets. However, we need to set options to the
defaults without '-ansi', because the included test file uses the
'asm' keyword, which is not part of ANSI C.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/cmpmemsi-1.c: Drop options.
* gcc.target/riscv/cpymemsi-1.c: Likewise.
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
Richard Biener [Wed, 15 May 2024 16:32:37 +0000 (18:32 +0200)]
tree-optimization/79958 - make DSE track multiple paths
DSE currently gives up when the path we analyze forks. This leads
to multiple missed dead store elimination PRs. The following fixes
this by recursing for each path and maintaining the visited bitmap
to avoid visiting CFG re-merges multiple times. The overall cost
is still limited by the same bound, it's just more likely we'll hit
the limit now. The patch doesn't try to deal with byte tracking
once a path forks but drops info on the floor and only handling
fully dead stores in that case.
PR tree-optimization/79958
PR tree-optimization/109087
PR tree-optimization/100314
PR tree-optimization/114774
* tree-ssa-dse.cc (dse_classify_store): New forwarder.
(dse_classify_store): Add arguments cnt and visited, recurse
to track multiple paths when we end up with multiple defs.
* gcc.dg/tree-ssa/ssa-dse-48.c: New testcase.
* gcc.dg/tree-ssa/ssa-dse-49.c: Likewise.
* gcc.dg/tree-ssa/ssa-dse-50.c: Likewise.
* gcc.dg/tree-ssa/ssa-dse-51.c: Likewise.
* gcc.dg/graphite/pr80906.c: Avoid DSE of last data reference
in loop.
* g++.dg/ipa/devirt-24.C: Adjust for extra DSE.
* g++.dg/warn/Wuninitialized-pr107919-1.C: Use more important
-O2 optimization level, -O1 regresses.
Marc Poulhiès [Tue, 27 Feb 2024 12:47:27 +0000 (13:47 +0100)]
ada: Reset scope of top level object declaration during unnesting
When unnesting, the compiler gathers elaboration code and wraps it with
a new dedicated procedure. While doing so, it resets the scopes of
entities that are wrapped to point to this new procedure. This change
also resets the scopes of N_Object_Declaration and
N_Object_Renaming_Declaration nodes only if an elaboration procedure
is needed.
gcc/ada/
* exp_ch7.adb (Reset_Scopes_To_Block_Elab_Proc): also reset scope
for object declarations.
Steve Baird [Tue, 27 Feb 2024 20:11:47 +0000 (12:11 -0800)]
ada: Redundant validity checks
In some cases with validity checking enabled via the -gnatVa option,
the compiler generates validity checks that can (obviously) never fail.
These include validity checks for (some) static expressions, and consecutive
identical checks generated for a single read of an object.
gcc/ada/
* checks.adb (Expr_Known_Valid): Return True for a static expression.
* exp_util.adb (Adjust_Condition): No validity check needed for a
condition if it is an expression for which a validity check has
already been generated.
Gary Dismukes [Tue, 27 Feb 2024 22:05:55 +0000 (22:05 +0000)]
ada: Exception on Indefinite_Vector aggregate with loop_parameter_specification
Constraint_Error is raised on evaluation of a container aggregate with
a loop_parameter_specification for the type Indefinite_Vector. This
happens due to the Aggregate aspect for type Indefinite_Vector specifying
the Empty_Vector constant for the type's Empty operation rather than
using the type's primitive Empty function. This problem shows up as
a recent regression relative to earlier compilers, evidently due to
recent fixes in the container aggregate area, which uncovered this
issue of the wrong specification in Ada.Containers.Indefinite_Vectors.
The compiler incorrectly initializes the aggregate object using the
Empty_Vector constant rather than invoking the New_Vector function
to allocate the vector object with the appropriate number of elements,
and subsequent calls to Replace_Element fail because the vector object
is empty.
In addition to correcting the Indefinite_Vectors generic package,
checking is added to give an error for an attempt to specify the
Empty operation as a constant rather than a function. (Also note
that another AdaCore package that needs a similar correction is
the VSS.Vector_Strings package.)
gcc/ada/
* libgnat/a-coinve.ads (type Vector): In the Aggregate aspect for
this type, the Empty operation is changed to denote the Empty
function, rather than the Empty_Vector constant.
* exp_aggr.adb (Expand_Container_Aggregate): Remove code for
handling the case where the Empty_Subp denotes a constant object,
which should never happen (and add an assertion that Empty_Subp
must denote a function).
* sem_ch13.adb (Valid_Empty): No longer allow the entity to be an
E_Constant, and require the (optional) parameter of an Empty
function to be of a signed integer type (rather than any integer
type).
Justin Squirek [Sun, 25 Feb 2024 19:30:01 +0000 (19:30 +0000)]
ada: Implement new experimental attribute 'Super
This patch implements (under -gnatX0) the 'Super attribute which can be
applied to tagged objects in order to get a view conversion to their
immediate parent.
gcc/ada/
* doc/gnat_rm/implementation_defined_attributes.rst: Add entry for
Super attribute.
* accessibility.adb (Accessibility_Level): Add handling for Super.
* exp_attr.adb (Expand_N_Attribute_Reference): Add entry for
Super.
* sem_attr.adb (Analyze_Attribute): Create a case to handle the
semantic checking and expansion for Super.
(Eval_Attribute): Add entry for Super.
* sem_attr.ads: Add entry for Super.
* sem_util.adb (Is_Aliased_View, Is_Variable): Add case to handle
references to 'Super.
* snames.ads-tmpl: Register Name_Super and Attribute_Super.
* gnat_rm.texi: Regenerate.
Define PATH_SEPARATOR and HOST_EXECUTABLE_SUFFIX in standalone MinGW
builds; the definitions normally come from GCC, and the defaults don't
work for native Windows.
Viljar Indus [Thu, 22 Feb 2024 12:27:14 +0000 (14:27 +0200)]
ada: Avoid checking parameters of protected procedures
The compiler triggers warnings on generated protected procedures
if the procedure does not have an explicit spec. Instead check
if the body was created for a protected procedure if the spec
is not present.
gcc/ada/
* sem_ch6.adb (Analyze_Subprogram_Body_Helper):
If the spec is not present for a subprogram body then
check if the body definiton was created for a protected
procedure.
Piotr Trojanek [Mon, 26 Feb 2024 08:32:20 +0000 (09:32 +0100)]
ada: Ignore ghost nodes in call graph information for dispatching calls
When emitting call graph information, we already skipped calls to
ignored ghost entities, but this code was causing crashes (in production
builds) and assertion failures (in development builds), because the
ignored ghost entities are not fully decorated, e.g. when they come from
instances of generic units with default subprograms.
With this patch we skip call graph information for ignored ghost
entities when they are registered, both as explicit calls and as
tagged types that will come with internally generated dispatching
subprograms.
gcc/ada/
* exp_cg.adb (Generate_CG_Output): Remove code for ignored ghost
entities that applied to subprogram calls.
(Register_CG_Node): Skip ignored ghost entities, both calls
and tagged types, when they are registered.
This patch fixes the reason code used by Apply_Selected_Length_Checks,
which was wrong in some cases when the check could be determined to
always fail at compile time.
Eric Botcazou [Fri, 23 Feb 2024 20:55:08 +0000 (21:55 +0100)]
ada: Propagate Program_Error from failed finalization of collection
This aligns finalization collections with finalization masters when it comes
to propagating an exception raised by the finalization of a specific object,
by always propagating Program_Error instead of the aforementioned exception.
gcc/ada/
* libgnat/s-finpri.adb (Raise_From_Controlled_Operation): New
declaration of imported procedure moved from...
(Finalize_Master): ...there.
(Finalize): Call Raise_From_Controlled_Operation instead of
Reraise_Occurrence to propagate the exception, if any.
Piotr Trojanek [Thu, 22 Feb 2024 21:26:01 +0000 (22:26 +0100)]
ada: Improve recovery from illegal occurrence of 'Old in if_expression
Fix assertion failure in developer builds which happened when the THEN
expression contains an illegal occurrence of 'Old and the type of the
THEN expression is left as Any_Type, but there is no ELSE expression.
gcc/ada/
* sem_ch4.adb (Analyze_If_Expression): Add guard for
if_expression without an ELSE part.
Piotr Trojanek [Fri, 23 Feb 2024 12:57:27 +0000 (13:57 +0100)]
ada: No need to follow New_Occurrence_Of with Set_Etype
Routine New_Occurrence_Of itself sets the Etype of its result; there is
no need to set it explicitly afterwards.
Code cleanup related to fix for attribute 'Old; semantics is unaffected.
gcc/ada/
* exp_ch13.adb (Expand_N_Free_Statement): After analysis, the
new temporary has the type of its Object_Definition and the new
occurrence of this temporary has this type as well; simplify.
* sem_util.adb
(Indirect_Temp_Value): Remove redundant call to Set_Etype;
simplify.
(Is_Access_Type_For_Indirect_Temp): Add missing body header.
Piotr Trojanek [Thu, 22 Feb 2024 21:25:16 +0000 (22:25 +0100)]
ada: Fix detection of if_expressions that are known on entry
Fix a small glitch in routine Is_Known_On_Entry, which returned False
for all if_expressions, regardless whether their conditions or dependent
expressions are known on entry.
gcc/ada/
* sem_util.adb (Is_Known_On_Entry): Check whether condition and
dependent expressions of an if_expression are known on entry.
Checks.Get_Ranged_Checks was onced named Range_Check, and a few
comments referred to it by that name before this commit. To avoid
confusion with Types.Range_Check, this commits fixes those comments.
Eric Botcazou [Thu, 22 Feb 2024 07:47:42 +0000 (08:47 +0100)]
ada: Minor performance improvement for dynamically-allocated controlled objects
The values returned by Header_Alignment and Header_Size are known at compile
time and powers of two on almost all platforms, so inlining them by means of
an expression function improves the object code generated for alignment and
size calculations involving them.
gcc/ada/
* libgnat/s-finpri.ads: Add use type clause for Storage_Offset.
(Header_Alignment): Turn into an expression function.
(Header_Size): Likewise.
* libgnat/s-finpri.adb: Remove use type clause for Storage_Offset.
(Header_Alignment): Delete.
(Header_Size): Likewise.
Marc Poulhiès [Tue, 13 Feb 2024 11:20:19 +0000 (12:20 +0100)]
ada: Fixup one more pattern of broken scope information
When an array's initialization contains a `others =>` clause with an
expression that involves finalization, the resulting scope information
is incorrect and can cause crashes with backend (i.e. gnat-llvm) that
also use unnesting. The observable symptom is a nested object
declaration (created by the compiler) within a loop wrapped in a
procedure created by the unnester that has incoherent scope information:
its Scope field points to the scope of the procedure (1 level too high)
and is contained in the entity chain of some entity nested in the
procedure (correct).
The correct solution would be to fix the scope information when it is
created, but this revealed too large of a task with many interaction
with existing code.
This change adds another pattern to the Fixup_Inner_Scopes procedure to
detect the problematic case and fix the scope, "after the facts".
gcc/ada/
* exp_ch7.adb (Unnest_Loop::Fixup_Inner_Scopes): detect a new
problematic pattern and fixup the scope accordingly.
Eric Botcazou [Wed, 21 Feb 2024 20:48:13 +0000 (21:48 +0100)]
ada: Fix latent alignment issue for dynamically-allocated controlled objects
Dynamically-allocated controlled objects are attached to a finalization
collection by means of a hidden header placed right before the object,
which means that the size effectively allocated must naturally account
for the size of this header. But the allocation must also account for
the alignment of this header in order to have it properly aligned.
gcc/ada/
* libgnat/s-finpri.ads (Header_Alignment): New function.
(Header_Size): Adjust description.
(Master_Node): Put Finalize_Address as first component.
(Collection_Node): Likewise.
* libgnat/s-finpri.adb (Header_Alignment): New function.
(Header_Size): Return the object size in storage units.
* libgnat/s-stposu.ads (Adjust_Controlled_Dereference): Replace
collection node with header in description.
* libgnat/s-stposu.adb (Adjust_Controlled_Dereference): Likewise.
(Allocate_Any_Controlled): Likewise. Pass the maximum of the
specified alignment and that of the header to the allocator.
(Deallocate_Any_Controlled): Likewise to the deallocator.
Viljar Indus [Fri, 9 Feb 2024 10:29:41 +0000 (12:29 +0200)]
ada: Fix resolving tagged operations in array aggregates
In the Two_Pass_Aggregate_Expansion we were removing
all of the entity links in the Iterator_Specification
to avoid reusing the same Iterator_Definition in both
loops.
However this approach was also breaking the links to
calls with dot notation that had been transformed to
the regular call notation.
In order to circumvent this, explicitly create new
identifier definitions when copying the
Iterator_Specfications for both of the loops.
gcc/ada/
* exp_aggr.adb (Two_Pass_Aggregate_Expansion):
Explicitly create new Defining_Iterators for both
of the loops.
Eric Botcazou [Tue, 20 Feb 2024 21:40:47 +0000 (22:40 +0100)]
ada: Fix bogus error on function returning noncontrolling result in private part
This occurs in the additional case of RM 3.9.3(10) in Ada 2012, that is to
say the access controlling result, because the implementation does not use
the same (correct) conditions as in the original case.
This factors out these conditions and uses them in both cases, as well as
adjusts the wording of the message in the first case.
gcc/ada/
* sem_ch6.adb (Check_Private_Overriding): Implement the second part
of RM 3.9.3(10) consistently in both cases.
Piotr Trojanek [Wed, 21 Feb 2024 11:14:48 +0000 (12:14 +0100)]
ada: Fix casing of CUDA in error messages
Error messages now capitalize CUDA.
gcc/ada/
* erroutc.adb (Set_Msg_Insertion_Reserved_Word): Fix casing for
CUDA appearing in error message strings.
(Set_Msg_Str): Likewise for CUDA being a part of a Name_Id.
This commit makes the emission of -gnatw_q warnings pass node information
so as to handle the enclosing subprogram display of -gnatdJ instead of
crashing.
gcc/ada/
* exp_ch4.adb (Expand_Composite_Equality): Call Error_Msg_N
instead of Error_Msg.
Steve Baird [Sat, 17 Feb 2024 01:05:09 +0000 (17:05 -0800)]
ada: Follow up fixes for Put_Image/streaming regressions
A recent change to reduce duplication of compiler-generated Put_Image and
streaming subprograms introduced some regressions. The fix for one of them
was incomplete.
gcc/ada/
* exp_attr.adb (Build_And_Insert_Type_Attr_Subp): Further tweaking
of the point where a compiler-generated Put_Image or streaming
subprogram is to be inserted in the tree. If one such subprogram
calls another (as is often the case with, for example, Put_Image
procedures for composite type and for a component type thereof),
then we want to avoid use-before-definition problems that can
result from inserting the caller ahead of the callee.
This changes the implementation of finalization collections from using the
global task lock to using per-collection spinlocks. Spinlocks are a good
fit in this context because they are very cheap and therefore can be taken
with a fine granularity only around the portions of code implementing the
shuffling of pointers required by attachment and detachment actions.
gcc/ada/
* libgnat/s-finpri.ads (Lock_Type): New modular type.
(Collection_Node): Add Enclosing_Collection component.
(Finalization_Collection): Add Lock component.
* libgnat/s-finpri.adb: Add clauses for System.Atomic_Primitives.
(Attach_Object_To_Collection): Lock and unlock the collection.
Save a pointer to the enclosing collection in the node.
(Detach_Object_From_Collection): Lock and unlock the collection.
(Finalize): Likewise.
(Initialize): Initialize the lock.
(Lock_Collection): New procedure.
(Unlock_Collection): Likewise.
Steve Baird [Thu, 15 Feb 2024 22:49:18 +0000 (14:49 -0800)]
ada: Formal_Derived_Type'Size is not static
In deciding whether a Size attribute reference is static, the compiler could
get confused about whether an implicitly-declared subtype of a generic formal
type is itself a generic formal type, possibly resulting in an assertion
failure and then a bugbox.
gcc/ada/
* sem_attr.adb (Eval_Attribute): Expand existing checks for
generic formal types for which Is_Generic_Type returns False. In
that case, mark the attribute reference as nonstatic.
Steve Baird [Thu, 15 Feb 2024 23:13:12 +0000 (15:13 -0800)]
ada: Fix bug in maintaining dimension info
Copying a node does not automatically propagate its associated dimension
information (if any). This must be done explicitly.
gcc/ada/
* sem_util.adb (Copy_Node_With_Replacement): Add call to
Copy_Dimensions so that any dimension information associated with
the copied node is also associated with the resulting copy.
Piotr Trojanek [Fri, 16 Feb 2024 15:57:10 +0000 (16:57 +0100)]
ada: Fix casing in error messages
Error messages should not start with a capital letter.
gcc/ada/
* gnat_cuda.adb (Remove_CUDA_Device_Entities): Fix casing
(this primarily fixes a style, because the capitalization will
not be preserved by the error-reporting machinery anyway).
* sem_ch13.adb (Analyze_User_Aspect_Aspect_Specification): Fix
casing in error message.
David Malcolm [Thu, 16 May 2024 01:22:52 +0000 (21:22 -0400)]
diagnostics: use unicode art for interprocedural depth
gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/out-of-bounds-diagram-1-emoji.c: Update expected
output to use unicode for depth indication.
* gcc.dg/analyzer/out-of-bounds-diagram-1-unicode.c: Likewise.
gcc/ChangeLog:
* text-art/theme.cc (ascii_theme::get_cppchar): Add
cell_kind::INTERPROCEDURAL_*.
(unicode_theme::get_cppchar): Likewise.
* text-art/theme.h (theme::cell_kind): Likewise.
* tree-diagnostic-path.cc:
(thread_event_printer::print_swimlane_for_event_range): Use the
above to get characters for indicating interprocedural stack
depth activity, falling back to ascii.
(selftest::test_interprocedural_path_1): Test with both ascii
and unicode themes.
(selftest::test_interprocedural_path_2): Likewise.
(selftest::test_recursion): Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
David Malcolm [Thu, 16 May 2024 01:22:51 +0000 (21:22 -0400)]
diagnostics: add warning emoji to events with VERB_danger
Tweak the printing of -fdiagnostics-path-format=inline-events so that
any event with diagnostic_event::VERB_danger gains a warning emoji,
provided that the text art theme enables emoji support.
VERB_danger is set by the analyzer on the last event in a path, and so
this emoji appears at the end of all analyzer execution paths
highlighting the location of the problem.
gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/out-of-bounds-diagram-1-emoji.c: Update expected
output to include warning emoji.
* gcc.dg/analyzer/warning-emoji.c: New test.
gcc/ChangeLog:
* tree-diagnostic-path.cc: Include "text-art/theme.h".
(path_label::get_text): If the event has
diagnostic_event::VERB_danger, and the theme enables emojis, then
add a warning emoji between the event number and the event text.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
David Malcolm [Thu, 16 May 2024 01:22:51 +0000 (21:22 -0400)]
diagnostics: simplify output of purely intraprocedural execution paths
Diagnostic path printing was added in r10-5901-g4bc1899b2e883f. As of
that commit, with -fdiagnostics-path-format=inline-events (the default),
we print a vertical line to the left of the source line numbering,
visualizing the stack depth and interprocedural calls and returns as
indentation changes.
For cases where the events on a thread are purely interprocedural, this
line does nothing except take up space and complicate the output.
This patch adds logic to omit it for such cases, simpifying the output,
and, I believe, improving readability.
gcc/ChangeLog:
* diagnostic-path.h: Update leading comment to reflect
intraprocedural cases. Fix typo in comment.
* doc/invoke.texi: Update intraprocedural example.
gcc/testsuite/ChangeLog:
* c-c++-common/analyzer/allocation-size-multiline-1.c: Update
expected results for purely intraprocedural path.
* c-c++-common/analyzer/allocation-size-multiline-2.c: Likewise.
* c-c++-common/analyzer/allocation-size-multiline-3.c: Likewise.
* c-c++-common/analyzer/analyzer-verbosity-0.c: Likewise.
* c-c++-common/analyzer/analyzer-verbosity-1.c: Likewise.
* c-c++-common/analyzer/analyzer-verbosity-2.c: Likewise.
* c-c++-common/analyzer/analyzer-verbosity-3.c: Likewise.
* c-c++-common/analyzer/malloc-macro-inline-events.c: Likewise.
Doing so for this file requires a rewrite since the paths
prefixing the "in expansion of macro" lines become the only thing
on their line and so are no longer pruned by multiline.exp logic
for pruning extra content on non-blank lines.
* c-c++-common/analyzer/malloc-paths-9-noexcept.c: Likewise.
* c-c++-common/analyzer/setjmp-2.c: Likewise.
* gcc.dg/analyzer/malloc-paths-9.c: Likewise.
* gcc.dg/analyzer/out-of-bounds-multiline-2.c: Likewise.
* gcc.dg/plugin/diagnostic-test-paths-2.c: Likewise.
gcc/ChangeLog:
* tree-diagnostic-path.cc (per_thread_summary::interprocedural_p):
New.
(thread_event_printer::print_swimlane_for_event_range): Don't
indent and print the stack depth line if this thread's events are
purely intraprocedural.
(selftest::test_intraprocedural_path): Update expected output.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
David Malcolm [Thu, 16 May 2024 01:22:51 +0000 (21:22 -0400)]
diagnostics: handle SGR codes in line_label::m_display_width
gcc/ChangeLog:
* diagnostic-show-locus.cc: Define INCLUDE_VECTOR and include
"text-art/types.h".
(line_label::line_label): Drop "policy" argument. Use
styled_string::calc_canvas_width when computing m_display_width,
as this skips SGR codes.
(layout::print_any_labels): Update for line_label ctor change.
(selftest::test_one_liner_labels_utf8): Update expected text to
reflect that the labels can fit on one line if we don't get
confused by SGR colorization codes.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Xiao Zeng [Wed, 15 May 2024 02:03:40 +0000 (10:03 +0800)]
RISC-V: Add Zvfbfwma extension to the -march= option
This patch would like to add new sub extension (aka Zvfbfwma) to the
-march= option. It introduces a new data type BF16.
1 In spec: "Zvfbfwma requires the Zvfbfmin extension and the Zfbfmin extension."
1.1 In Embedded Processor: Zvfbfwma -> Zvfbfmin -> Zve32f
1.2 In Application Processor: Zvfbfwma -> Zvfbfmin -> V
1.3 In both scenarios, there are: Zvfbfwma -> Zfbfmin
4 Depending on different usage scenarios, the Zvfbfwma extension may
depend on 'V' or 'Zve32f'. This patch only implements dependencies in
scenario of Embedded Processor. This is consistent with the processing
strategy in Zvfbfmin. In scenario of Application Processor, it is
necessary to explicitly indicate the dependent 'V' extension.
5 You can locate more information about Zvfbfwma from below spec doc:
<https://github.com/riscv/riscv-bfloat16/releases/download/v59042fc71c31a9bcb2f1957621c960ed36fac401/riscv-bfloat16.pdf>
* gcc.target/riscv/arch-37.c: New test.
* gcc.target/riscv/arch-38.c: New test.
* gcc.target/riscv/predef-36.c: New test.
* gcc.target/riscv/predef-37.c: New test.
Although there's a memory load from constant pool, but it should be
better when it's inside a loop. The load from constant pool can be
hoist out. it's 1 instruction vs 4 instructions.
liuhongt [Tue, 14 May 2024 10:39:54 +0000 (18:39 +0800)]
Optimize ashift >> 7 to vpcmpgtb for vector int8.
Since there is no corresponding instruction, the shift operation for
vector int8 is implemented using the instructions for vector int16,
but for some special shift counts, it can be transformed into vpcmpgtb.