Joseph Myers [Tue, 7 Nov 2023 20:03:37 +0000 (20:03 +0000)]
c: Change T2X_* format checking macros to T23_*
Analogous to previous changes to code that matched "c2x"
(case-insensitive), also update T2X_* macros used in format checking
tables to be named T23_*.
Bootstrapped with no regressions for x86_64-pc-linux-gnu.
gcc/c-family/
* c-format.h (T2X_UI): Rename to T23_UI.
(T2X_UL): Rename to T23_UL.
(T2X_ULL): Rename to T23_ULL.
(T2X_US): Rename to T23_US.
(T2X_UC): Rename to T23_UC.
(T2X_ST): Rename to T23_ST.
(T2X_UPD): Rename to T23_UPD.
(T2X_UIM): Rename to T23_UIM.
(T2X_D32): Rename to T23_D32.
(T2X_D64): Rename to T23_D64.
(T2X_D128): Rename to T23_D128.
(T2X_I8): Rename to T23_I8.
(T2X_I16): Rename to T23_I16.
(T2X_I32): Rename to T23_I32.
(T2X_I64): Rename to T23_I64.
(T2X_U8): Rename to T23_U8.
(T2X_U16): Rename to T23_U16.
(T2X_U32): Rename to T23_U32.
(T2X_U64): Rename to T23_U64.
(T2X_IF8): Rename to T23_IF8.
(T2X_IF16): Rename to T23_IF16.
(T2X_IF32): Rename to T23_IF32.
(T2X_IF64): Rename to T23_IF64.
(T2X_UF8): Rename to T23_UF8.
(T2X_UF16): Rename to T23_UF16.
(T2X_UF32): Rename to T23_UF32.
(T2X_UF64): Rename to T23_UF64.
* c-format.cc: Update all uses of T2X_* macros to use T23_*.
Martin Jambor [Tue, 7 Nov 2023 17:47:09 +0000 (18:47 +0100)]
gcc/configure: Regenerate
Probabaly because of a re-base of changes to gcc/configure there are
line comment mismatches in between what we have and what would be
generated. This patch brings them in line so that consitency
checkers are happy.
Marek Polacek [Tue, 7 Nov 2023 15:41:41 +0000 (10:41 -0500)]
testsuite: nodiscard-reason-nonstring.C FAIL in C++26
Since r14-5071, we emit an extra error for this test (the first one):
nodiscard-reason-nonstring.C:5:13: error: expected string-literal before numeric constant
nodiscard-reason-nonstring.C:5:36: error: 'nodiscard' attribute argument must be a string constant
openmp: Add support for the 'indirect' clause in C/C++
This adds support for the 'indirect' clause in the 'declare target'
directive. Functions declared as indirect may be called via function
pointers passed from the host in offloaded code.
Virtual calls to member functions via the object pointer in C++ are
currently not supported in target regions.
libgomp/
* Makefile.am (libgomp_la_SOURCES): Add target-indirect.c.
* Makefile.in: Regenerate.
* libgomp-plugin.h (GOMP_INDIRECT_ADDR_MAP): New define.
(GOMP_OFFLOAD_load_image): Add extra argument.
* libgomp.h (struct indirect_splay_tree_key_s): New.
(indirect_splay_tree_node, indirect_splay_tree,
indirect_splay_tree_key): New.
(indirect_splay_compare): New.
* libgomp.map (GOMP_5.1.1): Add GOMP_target_map_indirect_ptr.
* libgomp.texi (OpenMP 5.1): Update documentation on indirect
calls in target region and on indirect clause.
(Other new OpenMP 5.2 features): Add entry for virtual function calls.
* libgomp_g.h (GOMP_target_map_indirect_ptr): Add prototype.
* oacc-host.c (host_load_image): Add extra argument.
* target.c (gomp_load_image_to_device): If the GOMP_VERSION is high
enough, read host indirect functions table and pass to
load_image_func.
* config/accel/target-indirect.c: New.
* config/linux/target-indirect.c: New.
* config/gcn/team.c (build_indirect_map): Add prototype.
(gomp_gcn_enter_kernel): Initialize support for indirect
function calls on GCN target.
* config/nvptx/team.c (build_indirect_map): Add prototype.
(gomp_nvptx_main): Initialize support for indirect function
calls on NVPTX target.
* plugin/plugin-gcn.c (struct gcn_image_desc): Add field for
indirect functions count.
(GOMP_OFFLOAD_load_image): Add extra argument. If the GOMP_VERSION
is high enough, build address translation table and copy it to target
memory.
* plugin/plugin-nvptx.c (nvptx_tdata): Add field for indirect
functions count.
(GOMP_OFFLOAD_load_image): Add extra argument. If the GOMP_VERSION
is high enough, Build address translation table and copy it to target
memory.
* testsuite/libgomp.c-c++-common/declare-target-indirect-1.c: New.
* testsuite/libgomp.c-c++-common/declare-target-indirect-2.c: New.
* testsuite/libgomp.c++/declare-target-indirect-1.C: New.
aarch64: Add a %Z operand modifier for SVE registers
This patch adds a %Z operand modifier that prints registers as SVE z
registers. The SME patches need this, but so do Tamar's patches.
I'm separating this out to unblock those.
We should probably document the [wxbhsdqZ] modifiers as
user-facing, but doing that for all of them is a separate patch.
gcc/
* config/aarch64/aarch64.cc (aarch64_print_operand): Add a %Z
modifier for SVE registers.
Joseph Myers [Tue, 7 Nov 2023 14:19:36 +0000 (14:19 +0000)]
c: Refer more consistently to C23 not C2X
Continuing the move to refer to C23 in place of C2X throughout the
source tree, update documentation, diagnostics, comments, variable and
function names, etc., to use the C23 name.
Testsuite updates are left for a future patch, except for testcases
that test diagnostics that previously mentioned C2X (but in those
testcases, sometimes other comments are updated, not just the
diagnostic expectations).
Bootstrapped with no regressions for x86_64-pc-linux-gnu.
gcc/
* builtins.def (DEF_C2X_BUILTIN): Rename to DEF_C23_BUILTIN and
use flag_isoc23 and function_c23_misc.
* config/rl78/rl78.cc (rl78_option_override): Compare
lang_hooks.name with "GNU C23" not "GNU C2X".
* coretypes.h (function_c2x_misc): Rename to function_c23_misc.
* doc/cpp.texi (@code{__has_attribute}): Refer to C23 instead of
C2x.
* doc/extend.texi: Likewise.
* doc/invoke.texi: Likewise.
* dwarf2out.cc (highest_c_language, gen_compile_unit_die): Compare
against and return "GNU C23" language string instead of "GNU C2X".
* ginclude/float.h: Refer to C23 instead of C2X in comments.
* ginclude/stdint-gcc.h: Likewise.
* glimits.h: Likewise.
* tree.h: Likewise.
gcc/ada/
* gcc-interface/utils.cc (flag_isoc2x): Rename to flag_isoc23.
gcc/c-family/
* c-common.cc (flag_isoc2x): Rename to flag_isoc23.
(c_common_reswords): Use D_C23 instead of D_C2X.
* c-common.h: Refer throughout to C23 instead of C2X in comments.
(D_C2X): Rename to D_C23.
(flag_isoc2x): Rename to flag_isoc23.
* c-cppbuiltin.cc (builtin_define_float_constants): Use
flag_isoc23 instead of flag_isoc2x. Refer to C23 instead of C2x
in comments.
* c-format.cc: Use STD_C23 instead of STD_C2X and flag_isoc23
instead of flag_isoc2x. Refer to C23 instead of C2X in comments.
* c-format.h: Use STD_C23 instead of STD_C2X.
* c-lex.cc: Use warn_c11_c23_compat instead of warn_c11_c2x_compat
and flag_isoc23 instead of flag_isoc2x. Refer to C23 instead of
C2X in diagnostics.
* c-opts.cc: Use flag_isoc23 instead of flag_isoc2x. Refer to C23
instead of C2X in comments.
(set_std_c2x): Rename to set_std_c23.
* c.opt (Wc11-c23-compat): Use CPP(cpp_warn_c11_c23_compat)
CppReason(CPP_W_C11_C23_COMPAT) Var(warn_c11_c23_compat) instead
of CPP(cpp_warn_c11_c2x_compat) CppReason(CPP_W_C11_C2X_COMPAT)
Var(warn_c11_c2x_compat).
gcc/c/
* c-decl.cc: Use flag_isoc23 instead of flag_isoc2x and c23_auto_p
instead of c2x_auto_p. Refer to C23 instead of C2X in diagnostics
and comments.
* c-errors.cc: Use flag_isoc23 instead of flag_isoc2x and
warn_c11_c23_compat instead of warn_c11_c2x_compat. Refer to C23
instead of C2X in comments.
* c-parser.cc: Use flag_isoc23 instead of flag_isoc2x,
warn_c11_c23_compat instead of warn_c11_c2x_compat, c23_auto_p
instead of c2x_auto_p and D_C23 instead of D_C2X. Refer to C23
instead of C2X in diagnostics and comments.
* c-tree.h: Refer to C23 instead of C2X in comments.
(struct c_declspecs): Rename c2x_auto_p to c23_auto_p.
* c-typeck.cc: Use flag_isoc23 instead of flag_isoc2x and
warn_c11_c23_compat instead of warn_c11_c2x_compat. Refer to C23
instead of C2X in diagnostics and comments.
gcc/fortran/
* gfortran.h (gfc_real_info): Refer to C23 instead of C2X in
comment.
gcc/lto/
* lto-lang.cc (flag_isoc2x): Rename to flag_isoc23.
libcpp/
* directives.cc: Refer to C23 instead of C2X in diagnostics and
comments.
(STDC2X): Rename to STDC23.
* expr.cc: Use cpp_warn_c11_c23_compat instead of
cpp_warn_c11_c2x_compat and CPP_W_C11_C23_COMPAT instead of
CPP_W_C11_C2X_COMPAT. Refer to C23 instead of C2X in diagnostics
and comments.
* include/cpplib.h: Refer to C23 instead of C2X in diagnostics and
comments.
(CLK_GNUC2X): Rename to CLK_GNUC23.
(CLK_STDC2X): Rename to CLK_STDC23.
(CPP_W_C11_C2X_COMPAT): Rename to CPP_W_C11_C23_COMPAT.
* init.cc: Use GNUC23 instead of GNUC2X, STDC23 instead of STDC2X
and cpp_warn_c11_c23_compat instead of cpp_warn_c11_c2x_compat.
* lex.cc (maybe_va_opt_error): Refer to C23 instead of C2X in
diagnostic.
* macro.cc (_cpp_arguments_ok): Refer to C23 instead of C2X in
comment.
Richard Biener [Mon, 6 Nov 2023 10:31:40 +0000 (11:31 +0100)]
libstdc++/112351 - deal with __gthread_once failure during locale init
The following makes the C++98 locale init path follow the way the
C++11 performs initialization. This way we deal with pthread_once
failing, falling back to non-threadsafe initialization which, given we
initialize from the library, should be serialized by the dynamic
loader already.
Robin Dapp [Tue, 7 Nov 2023 08:15:02 +0000 (09:15 +0100)]
testsuite/vect: Make check more accurate.
Similar to before this modifies a check so we do only match a
vectorization attempt if it succeeded. On riscv we potentially try
several modes if which some may fail.
gcc/testsuite/ChangeLog:
* gcc.dg/vect/vect-cond-reduc-4.c: Make check more accurate.
Robin Dapp [Tue, 7 Nov 2023 07:58:07 +0000 (08:58 +0100)]
testsuite: Change expectation for bb-slp-over-widen-n.c
This patch makes sure we check for
note: Basic block will be vectorized using SLP
instead of
optimized: basic block
which will also match
optimized: basic block part
of which there are many more in an RVV dump.
gcc/testsuite/ChangeLog:
* gcc.dg/vect/bb-slp-over-widen-1.c: Change test expectation.
* gcc.dg/vect/bb-slp-over-widen-2.c: Ditto.
Alexandre Oliva [Tue, 7 Nov 2023 11:02:03 +0000 (08:02 -0300)]
testsuite: check for and use -mno-strict-align where needed
Various tests fail on powerpc if the toolchain is configured to enable
-mstrict-align by default. This patch introduces -mno-strict-align on
tests found to fail that way, when the target supports this option.
I suppose !non_strict_align could be used to skip tests, instead of or
in addition to this tweak, and that might be desirable if they still
fail on targets that do no support -mno-strict-align, but I haven't
observed such scenarios.
The p9-vec-length tests expect vectorization on loop bodies and
epilogues that reference arrays that are not known to be more aligned
than their small element types.
Though VSX vectors work best with 32- or 64-bit alignment, unaligned
vector loads and stores are expected by the tests. However, with
-mstrict-align by default, vector loads and stores not known to be
aligned end up open coded, which doesn't match the asm output
expectations coded in the tests.
for gcc/ChangeLog
* doc/sourcebuild.texi (opt_mstrict_align): New target.
RISC-V: Add ABI requirement for XTheadFMemIdx tests
The XTheadFMemIdx tests set the required ABI for RV32, but not
for RV64, which has the effect that the tests are expected to
succeed for RV64/LP64. Let's set the ABI to LP64D in these
tests to clarify the requirements.
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
gcc/testsuite/ChangeLog:
Eric Botcazou [Tue, 17 Oct 2023 17:20:26 +0000 (19:20 +0200)]
ada: Fix debug info for aliased packed array with unconstrained nominal subtype
The front-end now rewrites it as a renaming when it is initialized with a
function call and the same processing must be applied in the renaming case
as in the regular case for this kind of special objects.
gcc/ada/
* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Variable>: Apply the
specific rewriting done for an aliased object with an unconstrained
array nominal subtype in the renaming case too.
Eric Botcazou [Thu, 12 Oct 2023 12:26:46 +0000 (14:26 +0200)]
ada: Fix spurious -Wstringop-overflow with link time optimization
It comes from an incomplete optimization performed by LTO that is caused by
an obsolete transformation done in Gigi, which is redundant with the common
uniquization of constant CONSTRUCTORs now performed during gimplification.
Bob Duff [Wed, 18 Oct 2023 13:54:06 +0000 (09:54 -0400)]
ada: Compiler crash on early alignment clause
This patch fixes a bug: if "for T'Alignment use..." is followed
by "for T use (<enum rep>);" the compiler crashes. A workaround is
to move the alignment clause after the enumeration rep clause.
gcc/ada/
* sem_ch13.ads (Set_Enum_Esize): Do not set alignment.
* sem_ch13.adb (Set_Enum_Esize): Do not set alignment. Archaeology
seems to show that this line of code dates from when "Alignment =
0" meant "the Alignment is not known at compile time" and "the
Alignment is not yet known at compile time" as well as "the
Alignment is zero". In any case, it seems to be unnecessary, and
in this case harmful, because gigi would crash. Alignment_Clause
is set (because there is one), so gigi would query the Alignment,
but Alignment was destroyed.
Eric Botcazou [Sun, 15 Oct 2023 11:00:10 +0000 (13:00 +0200)]
ada: Fix incorrect resolution of overloaded function call in instance
The problem occurs when the function call is the operand of an equality
operator, the type used to do the comparison is declared outside of the
generic construct but visible inside it, and this generic construct also
declares two functions with the same profile except for the result type,
one result type being the aforementioned type, the other being derived
from this type but not visible inside the generic construct. When the
second operand is either a literal or also overloaded, the call may be
resolved to the second function instead of the first in instances.
gcc/ada/
* gen_il-fields.ads (Opt_Field_Enum): Add Compare_Type.
* gen_il-gen-gen_nodes.adb (N_Op_Eq): Likewise.
(N_Op_Ge): Likewise.
(N_Op_Gt): Likewise.
(N_Op_Le): Likewise.
(N_Op_Lt): Likewise.
(N_Op_Ne): Likewise.
* sinfo.ads (Compare_Type): Document new field.
* sem_ch4.adb (Analyze_Comparison_Equality_Op): If the entity is
already present, set the Compare_Type on overloaded operands if it
is present on the node.
* sem_ch12.adb (Check_Private_View): Look into the Compare_Type
instead of the Etype for comparison operators.
(Copy_Generic_Node): Remove obsolete code for comparison
operators.
(Save_Global_References.Save_References): Do not walk into the
descendants of N_Implicit_Label_Declaration nodes.
(Save_Global_References.Set_Global_Type): Look into the
Compare_Type instead of the Etype for comparison operators.
* sem_res.adb (Resolve_Comparison_Op): Set Compare_Type.
(Resolve_Equality_Op): Likewise.
ada: Fix Ada.Directories.Modification_Time on Windows
Before this patch, Ada.Directories.Modification_Time called
GetFileAttributesExA under the hood on Windows. That would sometimes
fail to work with files whose names were non-ASCII.
This patch replaces the call to GetFileAttributesExA with a call to
GetFileAttributesEx preceded by an encoding scheme conversion, as is
done in other functions of the run-time library. This fixes the issues
that were observed with the previous implementations.
gcc/ada/
* adaint.c (__gnat_file_time): Fix Windows version.
Eric Botcazou [Mon, 16 Oct 2023 19:16:38 +0000 (21:16 +0200)]
ada: Elide temporary for aliased array with unconstrained nominal subtype
When the array is initialized with the result of a call to a function whose
result type is unconstrained, then the result is allocated with its bounds,
so the array can be rewritten as a renaming of the result in this case too.
gcc/ada/
* exp_ch3.adb (Expand_N_Object_Declaration): Fold initialization
expression of Nominal_Subtype_Is_Constrained_Array constant into
the computation of Rewrite_As_Renaming and remove the constant.
Set it to True for an aliased array with unconstrained nominal
subtype if the subtype of the expression is also unconstrained.
Piotr Trojanek [Mon, 16 Oct 2023 15:14:46 +0000 (17:14 +0200)]
ada: Fix expansion of type aspects with handling of aspects
The new handling of aspects stores the aspect expression as the
Expression_Copy of the aspect and not as the Entity of the aspect
identified. This has been changed for most of the aspects, but not for
Type_Invariant and Default_Initial_Condition, which have custom
expansion. Apparently this change only affects GNATprove and not GNAT.
gcc/ada/
* exp_util.adb (Add_Own_DIC, Add_Own_Invariants): Store the aspect
expression in Expression_Copy.
Yannick Moy [Mon, 16 Oct 2023 10:24:46 +0000 (12:24 +0200)]
ada: Rename Is_Limited_View to reflect actual query
Function Sem_Aux.Is_Limited_View returns whether the type is
"inherently limited" in a slightly different way from the "immutably
limited" definition in Ada 2012. Rename for clarity.
In the previous implementation Aspect Specifications were
stored in a separate table and not directly under each node.
This implementation included a lot of extra code that needed
to be maintained manually.
The new implementation stores Aspect_Specfications as a syntactic
field under each node. This removes the extra code that was needed
to store, traverse and clone aspects for nodes.
gcc/ada/
* aspects.adb (Exchange_Aspects): Removed. This method was
typically called after a Rewrite method. Now since the Rewrite
switches the aspects between the new and the old node it is no
longer needed.
(Has_Aspects): Converted to a utility method that performs the same
before as the previous Has_Aspects field did. Meaning it shows whether
a node actually has aspects or not.
(Copy_Aspects): New utility method that performs a deep copy of the
From nodes aspects.
(Aspect_Specfications): Removed. No longer needed. Replaced
by the primitive operation for the Aspect_Specification fields.
(Set_Aspect_Specifications): Likewise.
(Aspect_Specifications_Hash_Table): Remove the table and all the
utility methods for storing the old aspects.
* aspects.ads: Likewise.
* atree.adb (Copy_Separate_Tree): Remove custom code for aspects.
(New_Copy): Likewise.
(Replace): Likewise.
(Rewrite): Likewise.
* exp_ch3.adb (Expand_N_Object_Declaration): Keep the aspects from the old node.
* exp_ch6.adb (Validate_Subprogram_Calls): Previously aspects were ignored
because they were not on the tree. Explicitly ignore them here
when traversing the tree.
* exp_unst.adb (Build_Tables): Likewise
* gen_il-fields.ads: Remove Has_Aspects and add
Aspect_Specifications fields.
* gen_il-gen-gen_nodes.adb: Add Aspect_Specification fields
for all nodes that can have aspects. Additionally add
Expression_Copy for Aspect_Speficiations to avoid reusing
the Associated_Node for generic instantiation and aspect
analysis.
* ghost.adb (Remove_Ignored_Ghost_Node): Remove call to Remove_Aspects.
The rewritten node is a Null_Statement that cannot have aspects
and there is not anything to gain from removing them from the
Orignal_Node of N since it technically is not part of the active
tree.
* inline.adb (Process_Formals_In_Aspects): Simplify code for node traversal.
* par-ch13.adb: Avoid setting the parent explicitly for the
Aspect_Specifications list. This is done explicitly in the setter.
* par-ch6.adb: Likewise.
* par_sco.adb (Traverse_Aspects): Handle early return.
* sem_ch10.adb: Simplify code for Analyze_Aspect_Specifications.
* sem_ch11.adb: Likewise.
* sem_ch12.adb (Analyze_Formal_Derived_Interface_Type): Keep the aspects from
the orignal node after rewrite.
(Analyze_Formal_Derived_Type): Likewise.
(Analyze_Formal_Interface_Type): Likewise.
(Analyze_Formal_Object_Declaration): Simplify code for
Analyze_Aspect_Specifications.
(Analyze_Formal_Package_Declaration): Likewise.
(Analyze_Formal_Subprogram_Declaration): Likewise.
(Analyze_Formal_Type_Declaration): Likewise.
(Analyze_Generic_Package_Declaration): Remove Exchange_Aspects.
The new node already has the correct aspects after the rewrite.
Also simplify code for Analyze_Aspect_Specifications.
(Analyze_Generic_Subprogram_Declaration): Likewise.
(Analyze_Package_Instantiation): Simplify code for
Analyze_Aspect_Specifications.
(Build_Instance_Compilation_Unit_Nodes): Remove explicit copy of
aspects that is no longer needed.
(Save_References): Update the traversal code to handle
Aspect_Specifications in the tree.
(Copy_Generic_Node): Remove explicit copy for aspects. New_Copy
took care of that already.
* sem_ch13.adb (Analyze_Aspect_Specifications): Add early return to simplify
code for its calls. Avoid reusing the Entity(Associated_Node)
field for storing the original expression. Instead use the
new Expression_Copy field since Entity(Associated_Node) is
also used in generic instantiation.
(Analyze_Aspects_On_Subprogram_Body_Or_Stub): Simlify call
to Analyze_Aspect_Specifications.
(Check_Aspect_At_End_Of_Declarations): Use Expression_Copy
instead of Entity.
(Check_Aspect_At_Freeze_Point): Likewise.
* sem_ch3.adb: Simplify calls to Analyze_Aspect_Specifications.
* sem_ch6.adb (Analyze_Abstract_Subprogram_Declaration): Simplify call to
Analyze_Aspect_Specifications.
(Analyze_Expression_Function): Keep the aspects from the
original node after a rewrite.
(Analyze_Generic_Subprogram_Body): Remove Exchange aspects
that is no longer needed. Simplify call to
Analyze_Aspect_Specifications.
(Analyze_Null_Procedure): Keep the aspects from the
original node after a rewrite.
(Analyze_Subprogram_Body_Helper): Simplify calls to
Analyze_Aspect_Specifications.
(Analyze_Subprogram_Declaration): Likewise.
* sem_ch7.adb (Analyze_Package_Body_Helper): Remove Exchange aspects
that is no longer needed. Simplify call to
Analyze_Aspect_Specifications.
(Analyze_Package_Declaration): Simplify call to
Analyze_Aspect_Specifications.
(Analyze_Private_Type_Declaration): Likewise.
* sem_ch8.adb: Simplify calls to
Analyze_Aspect_Specifications.
* sem_ch9.adb (Analyze_Entry_Body): Simplify call to
Analyze_Aspects_On_Subprogram_Body_Or_Stub.
(Analyze_Entry_Declaration): Simplify call to
Analyze_Aspect_Specifications.
(Analyze_Protected_Body): Likewise.
(Analyze_Protected_Type_Declaration): Likewise.
(Analyze_Single_Protected_Declaration): Keep the aspects from
the original node after a rewrite. Simplify call to
Analyze_Aspect_Specifications.
(Analyze_Single_Task_Declaration): Likewise.
(Analyze_Task_Body): Simplify call to
Analyze_Aspect_Specifications.
(Analyze_Task_Type_Declaration): Simplify calls to
Analyze_Aspect_Specifications.
* sem_dim.adb: Remove explicitly setting the parents
for the Aspect_Specification list.
* sem_disp.adb: Remove the with that is no longer
required since Aspect_Specifications is a node operation now.
* sem_util.adb (Copy_Node_With_Replacement): Remove explicit code for aspects.
* treepr.adb (Print_Field): Remove the version that was used for printing
aspects.
(Print_Node): Remove aspect specific code.
Piotr Trojanek [Fri, 13 Oct 2023 08:40:12 +0000 (10:40 +0200)]
ada: Cleanup more "not Present"
We had a GNATcheck rule that suggests replacing "not Present (...)" with
"No (...)", but it only detected calls with a parameter of type Node_Id.
Now this rules also detects parameters of type Elist_Id.
-gnatwc has been correctly emitting warnings for expressions outside
of tests for a while, but its documentation in the user's guide had
never been updated to reflect that. Also, the documentation used
"conditional expressions" to designate boolean expressions, but
"conditional expressions" has been defined by Ada 2012 to designate
if expressions and case expressions. This patch fixes those issues.
Steve Baird [Thu, 10 Aug 2023 21:11:22 +0000 (14:11 -0700)]
ada: New Local_Restrictions and User_Aspect aspects.
A GNAT-defined aspect, Local_Restrictions, is defined.
This provides a way of enforcing a given restriction for an individual
subprogram (and its call-closure) without requiring that the entire
program satisfy the restriction.
A GNAT-defined aspect, User_Aspect, is defined.
This (along with the new User_Aspect_Definition configuration pragma) provides
a way of naming a set of aspect specifications which can then be applied
to multiple declarations without textual repetition of the set.
gcc/ada/
* local_restrict.ads: A new package. Declares Local_Restriction
enumeration type and provides operations to check for local
restriction violations.
* local_restrict.adb: Corresponding package body. Replace "not
Present (X)" calls with "No (X)" calls.
* aspects.ads: Add a new enumeration elements,
Aspect_Local_Restrictions and Aspect_User_Aspect, to the Aspect_Id
enumeration type. Update Aspect_Id-indexed aggregates. Add nested
package User_Aspect_Support to manage two pieces of state. One is
a map from identifiers to User_Aspect_Definition pragmas (updated
when such a pragma is encountered). The other is an
access-to-subprogram variable that is introduced in order to keep
the bulk of semantics out of the closure of package Aspects while
allowing a call from aspects.adb to the sem_ch13 procedure that
analyzes a User_Aspect aspect specification.
* aspects.adb (Find_Aspect): Cope with a case of a block statement
with an empty parent. It is not clear whether this is papering
over a compiler bug. Add indirect call through the aforementioned
access-to-subprogram variable when Find_Aspect enounters an
unanalyzed User_Aspect aspect specification. If Find_Aspect is
called looking for aspect Foo, then a User_Aspect specification
might generate (during analysis) a Foo aspect specification. So
the Find_Aspect call needs to trigger that analysis if it has not
already taken place. Provide a body for package
User_Aspect_Support. Replace "not Present (X)" call with "No (X)"
call.
* freeze.adb (Freeze_Subprogram): Check local restriction
compatibility when a dispatching operation is overridden.
* par-prag.adb: Add support for parsing a User_Aspect_Definition
pragma.
* restrict.ads: We'd like to have the body of package Restrict
include a call to a procedure declared in package Local_Restrict.
Doing that in the obvious way pulls most of semantics into the
closure of package Restrict, and that turns out to cause problems.
So we introduce a level of indirection and instead call through an
access-to-subprogram value. In this unit, we declare the
access-to-subprogram type and object.
* restrict.adb (Check Restriction): When a construct is
encountered that could violate a global restriction (depending on
whether the given restriction is in effect), Check_Restriction is
called. At this point, we also check for a violation of any
corresponding local restriction that is in effect. For reasons
described above, this check is performed via an indirect call.
* sem_ch13.ads (Parse_Aspect_Local_Restrictions): A new function,
similar to the existing Parse_Aspect_Xxx subprograms.
* sem_ch13.adb: Perform semantic analysis of Local_Restrictions
and User_Aspect aspect specifications. Declare and call new
Validate_Aspect_Local_Restrictions and
Analyze_User_Aspect_Aspect_Specification procedures (a reference
to the latter is registered during package elaboration). In
Analyze_Aspect_Specifications, do not set the Analyzed flag of a
User_Aspect aspect specification. Replace "not Present (X)" call
with "No (X)" call. Replace 'Image with 'Img in a case where the
prefix of the attribute reference is an object; this is done to
accomodate older compilers.
* sem_ch6.adb (Check_Subtype_Conformant): Include in subtype
conformance check a check for overriding-related compatibility of
local restrictions.
* sem_ch8.adb (Analyze_Subprogram_Renaming): In the case of an
instance of a generic that takes a formal subprogram, check that
formal and actual are compatible with respect to local
restrictions.
* sem_prag.adb: Add support for User_Aspect_Definition pragma.
* sem_res.adb (Resolve_Call): Check caller/callee compatibility
with respect to local restrictions.
* snames.ads-tmpl: Add Name_Local_Restrictions, Name_User_Aspect,
and Name_User_Aspect_Definition constants.
* doc/gnat_rm/implementation_defined_aspects.rst: Document new
aspects.
* doc/gnat_rm/implementation_defined_pragmas.rst: Document new
pragma.
* doc/gnat_ugn/the_gnat_compilation_model.rst: Add
User_Aspect_Definition to list of GNAT pragmas.
* gcc-interface/Make-lang.in: Add local_restrict.o.
* gnat-style.texi: Regenerate.
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.
Piotr Trojanek [Tue, 3 Oct 2023 17:04:16 +0000 (19:04 +0200)]
ada: Simplify expansion of packed array assignments
When expanding assignment to a packed array object, e.g. a formal
parameter with mode OUT that might have unconstrained type, we took the
component type and component size from the constrained actual subtype.
It is simpler to take these properties from the nominal type of the
assigned object.
Semantics is unaffected, because constraining the array doesn't change
the type or size of the array components.
gcc/ada/
* exp_pakd.adb (Expand_Bit_Packed_Element_Set): Change Ctyp and Csiz
from variables to constants and compute them using the nominal type
of the assigned array object.
Piotr Trojanek [Tue, 3 Oct 2023 19:08:29 +0000 (21:08 +0200)]
ada: Change local variables to constants in expansion of packed arrays
Cleanup; semantics is unaffected.
gcc/ada/
* exp_pakd.adb
(Expand_Bit_Packed_Element_Set): Change local Decl object from
variable to constant.
(Setup_Inline_Packed_Array_Reference): Likewise for Csiz.
Viljar Indus [Fri, 6 Oct 2023 10:12:29 +0000 (13:12 +0300)]
ada: Fix scope of semantic style_check pragmas
Restore the original state of Style_Check pragmas before analyzing
each compilation unit to avoid Style_Check pragmas from unit affecting
the style checks of a different unit.
gcc/ada/
* sem_ch10.adb: (Analyze_Compilation_Unit): Restore the orignal
state of style check pragmas at the end of the analysis.
Eric Botcazou [Tue, 10 Oct 2023 09:13:59 +0000 (11:13 +0200)]
ada: Fix internal error on address of element of packed array component
This occurs when the component is part of a discriminated type and its
offset depends on a discriminant, the problem being that the front-end
generates an incomplete Bit_Position attribute reference.
gcc/ada/
* exp_pakd.adb (Get_Base_And_Bit_Offset): Use the full component
reference instead of just the selector name for 'Bit_Position.
Juzhe-Zhong [Tue, 7 Nov 2023 08:02:43 +0000 (16:02 +0800)]
RISC-V regression test: Fix FAIL bb-slp-cond-1.c for RVV
Previously, in this patch: https://gcc.gnu.org/pipermail/gcc-patches/2023-November/635392.html
I use vect64 && vect128 to represent both RVV and AMDGCN. However, it caused additional FAIL on ARM SVE.
I don't know why ARM SVE vect64 is set as true since their AdvSIMD is 128bit vector and they don't use 64bit vector.
So, here we leverage current AMDGCN solution, just add RISCV like AMDGCN.
Jiufu Guo [Tue, 7 Nov 2023 07:19:36 +0000 (15:19 +0800)]
rs6000,testcase: Add require-effective-target has_arch_ppc64 to pr106550_1.c
With the latest trunk, case pr106550_1.c runs with failure on ppc under -m32.
Previously, this case failed with ICE due to PR111971. Now, this emission is
exposed.
While, the case is testing 64bit constant building. So, "has_arch_ppc64"
is required.
Lehua Ding [Tue, 7 Nov 2023 07:33:20 +0000 (15:33 +0800)]
RISC-V: Fixed failed rvv combine testcases
This patch fixed the fellowing failed testcases on the trunk:
FAIL: gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c scan-assembler-times \\tvfwredusum\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t 2
...
FAIL: gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c scan-assembler-times \\tvwredsumu\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t 3
...
The reason for these failed testcases is the introduce of .VCOND_MASK_LEN
in midend for other bugfix and further leads to a new vcond_mask_len rtl
pattern after expand. So we need add new combine patterns handle this case.
Consider this code:
int16_t foo (int8_t *restrict a, int8_t *restrict pred)
{
int16_t sum = 0;
for (int i = 0; i < 16; i += 1)
if (pred[i])
sum += a[i];
return sum;
}
Juzhe-Zhong [Tue, 7 Nov 2023 03:36:44 +0000 (11:36 +0800)]
test: Fix FAIL of SAD tests for RVV
RVV didn't explicitly enable SAD optab but we can vectorize it
since loop vectorizer is able to recognize SAD pattern for RVV during analysis.
Current scan check of explicit SAD pattern looks odd,
it should be more reasonable to check recognition of SAD pattern during Loop vectorize analysis.
Other SAD tests like slp-reduc-sad-2.c are checking pattern recognition instead of explicit pattern enable.
Fix SAD dump check to fix the FAILS for RVV.
Juzhe-Zhong [Mon, 6 Nov 2023 03:34:26 +0000 (11:34 +0800)]
RISC-V: Enhance AVL propagation for complicate reduction auto-vectorization
I notice we failed to AVL propagate for reduction with more complicate situation:
double foo (double *__restrict a,
double *__restrict b,
double *__restrict c,
int n)
{
double result = 0;
for (int i = 0; i < n; i++)
result += a[i] * b[i] * c[i];
return result;
}
vsetvli a5,a3,e8,mf8,ta,ma -> should be fused into e64m1,TU
slli a4,a5,3
vle64.v v3,0(a0)
vle64.v v1,0(a1)
vsetvli a6,zero,e64,m1,ta,ma -> redundant
vfmul.vv v1,v1,v3
vsetvli zero,a5,e64,m1,tu,ma -> redundant
vle64.v v3,0(a2)
vfmacc.vv v2,v1,v3
add a0,a0,a4
add a1,a1,a4
add a2,a2,a4
sub a3,a3,a5
bne a3,zero,.L3
The failed AVL propgation causes redundant AVL/VL togglling.
The root cause as follows:
vsetvl a5, zero
vadd.vv def r136
vsetvl zero, a3, ... TU
vsub.vv (use r136)
We propagate AVL (r136) from 'vsub.vv' into 'vadd.vv' when 'vsub.vv' is TA policy.
However, it's too restrict so we missed optimization here. We enhance AVL propation
for TU policy for following situation:
vsetvl a5, zero
vadd.vv def r136
vsetvl zero, a3, ... TU
vsub.vv (use r136, merge != r136)
Note that we should only propagate AVL when merge != r136 for 'vsub.vv' doesn't
depend on the tail elements.
After this patch:
Pan Li [Tue, 7 Nov 2023 03:19:56 +0000 (11:19 +0800)]
RISC-V: Support FP ceil to i/l/ll diff size autovec
This patch would like to support the FP below API auto vectorization
with different type size
+---------+-----------+----------+
| API | RV64 | RV32 |
+---------+-----------+----------+
| iceil | DF => SI | DF => SI |
| iceilf | - | - |
| lceil | - | DF => SI |
| lceilf | SF => DI | - |
| llceil | - | - |
| llceilf | SF => DI | SF => DI |
+---------+-----------+----------+
Given below code:
void
test_lceilf (long *out, float *in, unsigned count)
{
for (unsigned i = 0; i < count; i++)
out[i] = __builtin_lceilf (in[i]);
}
Before this patch:
.L3:
flw fa0,0(s0)
addi s0,s0,4
addi s1,s1,8
call ceilf
fcvt.l.s a5,fa0,rtz
sd a5,-8(s1)
bne s2,s0,.L3
ld ra,24(sp)
ld s0,16(sp)
ld s1,8(sp)
ld s2,0(sp)
addi sp,sp,32
jr ra
After this patch:
fsrmi 3 // RUP mode
.L3:
vsetvli a5,a2,e32,mf2,ta,ma
vle32.v v2,0(a1)
slli a3,a5,2
slli a4,a5,3
vfwcvt.x.f.v v1,v2
sub a2,a2,a5
vse64.v v1,0(a0)
add a1,a1,a3
add a0,a0,a4
bne a2,zero,.L3
Unfortunately, the HF mode is not include due to it requires
additional middle-end support from internal-fun.def.
gcc/ChangeLog:
* config/riscv/autovec.md: Remove the size check of lceil.l
* config/riscv/riscv-v.cc (expand_vec_lceil): Leverage
emit_vec_rounding_to_integer for ceil.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/unop/math-iceil-1.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-iceil-run-1.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-lceil-rv32-0.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-lceil-rv32-run-0.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-lceilf-rv64-0.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-lceilf-rv64-run-0.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-llceilf-0.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-llceilf-run-0.c: New test.
* gcc.target/riscv/rvv/autovec/vls/math-iceil-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/math-lceil-rv32-0.c: New test.
* gcc.target/riscv/rvv/autovec/vls/math-lceilf-rv64-0.c: New test.
* gcc.target/riscv/rvv/autovec/vls/math-llceilf-0.c: New test.
For RVV, "loop vectorized" appears 2 times instead of 1. Because:
optimized: loop vectorized using 16 byte vectors
optimized: loop vectorized using 8 byte vectors
As long as targets have both 64bit and 128bit vectors, it will occur 2 times.
2 targets are same situation, one is AMDGCN, the other is RVV.
Replace it target amdgcn with vect64 && vect128 to make test more general and easy maintain.
libstdc++: use -D_GNU_SOURCE when building libbacktrace
PR libbacktrace/111315
PR libbacktrace/112263
* acinclude.m4: Set -D_GNU_SOURCE in BACKTRACE_CPPFLAGS and when
grepping link.h for dl_iterate_phdr.
* configure: Regenerate.
David Malcolm [Mon, 6 Nov 2023 19:28:41 +0000 (14:28 -0500)]
diagnostics: split out struct diagnostic_source_printing_options
This patch removes almost all use of diagnostic_context from the
source-printing code.
No functional change intended.
gcc/ChangeLog:
* diagnostic-show-locus.cc (class colorizer): Take just a
pretty_printer rather than a diagnostic_context.
(layout::layout): Make context param a const reference,
and pretty_printer param non-optional.
(layout::m_context): Drop field.
(layout::m_options): New field.
(layout::m_colorize_source_p): Drop field.
(layout::m_show_labels_p): Drop field.
(layout::m_show_line_numbers_p): Drop field.
(layout::print_gap_in_line_numbering): Use m_options.
(layout::calculate_line_spans): Likewise.
(layout::calculate_linenum_width): Likewise.
(layout::calculate_x_offset_display): Likewise.
(layout::print_source_line): Likewise.
(layout::start_annotation_line): Likewise.
(layout::print_annotation_line): Likewise.
(layout::print_line): Likewise.
(gcc_rich_location::add_location_if_nearby): Update for changes to
layout ctor.
(diagnostic_show_locus): Likewise.
(selftest::test_offset_impl): Likewise.
(selftest::test_layout_x_offset_display_utf8): Likewise.
(selftest::test_layout_x_offset_display_tab): Likewise.
(selftest::test_tab_expansion): Likewise.
* diagnostic.h (diagnostic_context::m_source_printing): Move
declaration of struct outside diagnostic_context as...
(struct diagnostic_source_printing_options)... this.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
David Malcolm [Mon, 6 Nov 2023 19:28:41 +0000 (14:28 -0500)]
diagnostics: introduce class diagnostic_option_classifier
This patch gathers the 6 fields in diagnostic_context relating to
keeping track of overriding the severity of warnings, and
pushing/popping those severities, moving them all into a new class
diagnostic_option_classifier.
No functional change intended.
gcc/ChangeLog:
* diagnostic.cc (diagnostic_context::push_diagnostics): Convert
to...
(diagnostic_option_classifier::push): ...this.
(diagnostic_context::pop_diagnostics): Convert to...
(diagnostic_option_classifier::pop): ...this.
(diagnostic_context::initialize): Move code to...
(diagnostic_option_classifier::init): ...this new function.
(diagnostic_context::finish): Move code to...
(diagnostic_option_classifier::fini): ...this new function.
(diagnostic_context::classify_diagnostic): Convert to...
(diagnostic_option_classifier::classify_diagnostic): ...this.
(diagnostic_context::update_effective_level_from_pragmas): Convert
to...
(diagnostic_option_classifier::update_effective_level_from_pragmas):
...this.
(diagnostic_context::diagnostic_enabled): Update for refactoring.
* diagnostic.h (struct diagnostic_classification_change_t): Move into...
(class diagnostic_option_classifier): ...this new class.
(diagnostic_context::option_unspecified_p): Update for move of
fields into m_option_classifier.
(diagnostic_context::classify_diagnostic): Likewise.
(diagnostic_context::push_diagnostics): Likewise.
(diagnostic_context::pop_diagnostics): Likewise.
(diagnostic_context::update_effective_level_from_pragmas): Delete.
(diagnostic_context::m_classify_diagnostic): Move into class
diagnostic_option_classifier.
(diagnostic_context::m_option_classifier): Likewise.
(diagnostic_context::m_classification_history): Likewise.
(diagnostic_context::m_n_classification_history): Likewise.
(diagnostic_context::m_push_list): Likewise.
(diagnostic_context::m_n_push): Likewise.
(diagnostic_context::m_option_classifier): New.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
David Malcolm [Mon, 6 Nov 2023 19:28:41 +0000 (14:28 -0500)]
diagnostics: eliminate diagnostic_kind_count
No functional change intended.
gcc/ChangeLog:
* diagnostic.cc (diagnostic_context::check_max_errors): Replace
uses of diagnostic_kind_count with simple field acesss.
(diagnostic_context::report_diagnostic): Likewise.
(diagnostic_text_output_format::~diagnostic_text_output_format):
Replace use of diagnostic_kind_count with
diagnostic_context::diagnostic_count.
* diagnostic.h (diagnostic_kind_count): Delete.
(errorcount): Replace use of diagnostic_kind_count with
diagnostic_context::diagnostic_count.
(warningcount): Likewise.
(werrorcount): Likewise.
(sorrycount): Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Christophe Lyon [Fri, 27 Oct 2023 14:38:02 +0000 (14:38 +0000)]
testsuite: Force use of -c when precompiling headers
In some configurations of our validation setup, we always call the
compiler with -Wl,-rpath=XXX, which instructs the driver to invoke the
linker if none of -c, -S or -E is used.
This happens to be the case in the PCH tests, where dg-flags-pch sets
dg-do-what-default to precompile.
This works most of the time, in absence of any linker option, the
compiler defaults to generating a precompiled header (otherwise the
linker complains because it cannot find 'main').
This small patch forces the use of '-c' when generating the .gch file,
which is sufficient not to invoke the linker.
Arguably, this could be seen as a dejagnu bug: in gcc-dg-test-1 (in
gcc-dg.exp), we set compile_type to "precompiled_header", which is not
one of the supported values in dejagnu's default_target_compile (in
target.exp).
testsuite: Add and use thread_fence effective-target
Some targets like arm-eabi with newlib and default settings rely on
__sync_synchronize() to ensure synchronization. Newlib does not
implement it by default, to make users aware they have to take special
care.
This makes a few tests fail to link.
This patch adds a new thread_fence effective target (similar to the
corresponding one in libstdc++ testsuite), and uses it in the tests
that need it, making them UNSUPPORTED instead of FAIL and UNRESOLVED.
Martin Jambor [Mon, 6 Nov 2023 16:04:33 +0000 (17:04 +0100)]
Fortran: Fix generate_error library function fnspec
when developing an otherwise unrelated patch I've discovered that the
fnspec for the Fortran library function generate_error is wrong. It is
currently ". R . R " where the first R describes the first parameter
and means that it "is only read and does not escape." The function
itself, however, with signature:
bool
generate_error_common (st_parameter_common *cmp, int family, const char *message)
contains the following:
/* Report status back to the compiler. */
cmp->flags &= ~IOPARM_LIBRETURN_MASK;
which does not correspond to the fnspec and breaks testcase
gfortran.dg/large_unit_2.f90 when my patch is applied, since it tries
to re-use the flags from before the call.
This patch replaces the "R" with "W" which stands for "specifies that
the memory pointed to by the parameter does not escape."
gcc/fortran/ChangeLog:
2023-11-02 Martin Jambor <mjambor@suse.cz>
* trans-decl.cc (gfc_build_builtin_function_decls): Fix fnspec of
generate_error.
Uros Bizjak [Mon, 6 Nov 2023 15:27:52 +0000 (16:27 +0100)]
i386: Use "addr" attribute to limit address regclass to non-REX regs
Use "addr" attribute with "gpr8" value to limit address register class
to non-REX registers in instructions with high registers, where REX
registers can not be used in the address.
gcc/ChangeLog:
* config/i386/constraints.md (Bc): Remove constraint.
(Bn): Rewrite to use x86_extended_reg_mentioned_p predicate.
* config/i386/i386.cc (ix86_memory_address_reg_class):
Do not limit processing to TARGET_APX_EGPR. Exit early for
NULL insn. Do not check recog_data.insn before calling
extract_insn_cached.
(ix86_insn_base_reg_class): Handle ADDR_GPR8.
(ix86_regno_ok_for_insn_base_p): Ditto.
(ix86_insn_index_reg_class): Ditto.
* config/i386/i386.md (*cmpqi_ext<mode>_1_mem_rex64):
Remove insn pattern and corresponding peephole2 pattern.
(*cmpi_ext<mode>_1): Remove (m,Q) alternative.
Change (QBc,Q) alternative to (QBn,Q). Add "addr" attribute.
(*cmpqi_ext<mode>_3_mem_rex64): Remove insn pattern
and corresponding peephole2 pattern.
(*cmpi_ext<mode>_3): Remove (Q,m) alternative.
Change (Q,QnBc) alternative to (Q,QnBn). Add "addr" attribute.
(*extzvqi_mem_rex64): Remove insn pattern and
corresponding peephole2 pattern.
(*extzvqi): Remove (Q,m) alternative. Change (Q,QnBc)
alternative to (Q,QnBn). Add "addr" attribute.
(*insvqi_1_mem_rex64): Remove insn pattern and
corresponding peephole2 pattern.
(*insvqi_1): Remove (Q,m) alternative. Change (Q,QnBc)
alternative to (Q,QnBn). Add "addr" attribute.
(@insv<mode>_1): Ditto.
(*addqi_ext<mode>_0): Remove (m,0,Q) alternative. Change (QBc,0,Q)
alternative to (QBn,0,Q). Add "addr" attribute.
(*subqi_ext<mode>_0): Ditto.
(*andqi_ext<mode>_0): Ditto.
(*<any_or:code>qi_ext<mode>_0): Ditto.
(*addqi_ext<mode>_1): Remove (Q,0,m) alternative. Change (Q,0,QnBc)
alternative to (Q,0,QnBn). Add "addr" attribute.
(*andqi_ext<mode>_1): Ditto.
(*andqi_ext<mode>_1_cc): Ditto.
(*<any_or:code>qi_ext<mode>_1): Ditto.
(*xorqi_ext<mode>_1_cc): Ditto.
* config/i386/predicates.md (nonimm_x64constmem_operand):
Remove predicate.
(general_x64constmem_operand): Ditto.
(norex_memory_operand): Ditto.
At the June WG14 meeting, WG14 decided it preferred to keep C23 as the
informal name for the next revision of the C standard, despite
publication not being before 2024 (publication is due in 2024 whether
or not technical changes at the January meeting result in an FDIS
ballot being needed). At the Cauldron I raised the question of
whether we should thus now add option names such as -std=c23 to GCC,
and there was support for doing so.
Add -std=c23, making -std=c2x a deprecated alias; also add the alias
-std=iso9899:2024. Likewise, add -std=gnu23, making -std=gnu2x a
deprecated alias, and add -Wc11-c23-compat, making -Wc11-c2x-compat a
deprecated alias.
Here, I'm generally just adding the new options and making the minimum
changes required to do so, with documentation changed to refer to C23
instead of C2X only where directly associated with documentation of
these options. It's intended that future changes will update
documentation, diagnostics, comments, variable names, testcase names,
etc. to refer consistently to C23. When such changes are made, the
new tests c23-opts-3.c, c23-opts-5.c and gnu23-opts-2.c are intended
to keep using the old option names they are specifically testing,
while other tests would start using the c23/gnu23 versions of the
names (as well as the tests themselves being renamed).
Updating option names is independent of updating to the final
__STDC_VERSION__ value. There, the question is whether we should
update the value now or wait for the remaining significant features to
be implemented first. (I intend to review Martin's tag compatibility
patches for GCC 14. I'm not aware of anyone working on #embed - or on
the [[unsequenced]] and [[reproducible]] attributes, though support
for standard attributes is optional.)
Bootstrapped with no regressions for x86_64-pc-linux-gnu.
PR c/107954
gcc/
* doc/cpp.texi (__STDC_VERSION__): Refer to -std=c23 and
-std=gnu23 instead of -std=c2x and -std=gnu2x.
* doc/extend.texi (Attribute Syntax): Refer to C23 and -std=c23
instead of C2x and -std=c2x.
* doc/invoke.texi (-Wc11-c23-compat, -std=c23, -std=gnu23)
(-std=iso9899:2024): Document, with -Wc11-c2x-compat, -std=c2x and
-std=gnu2x as deprecated aliases. Update descriptions of C23.
* doc/standards.texi (Standards): Describe C23 with C2X as an old
name.
gcc/c-family/
* c.opt (Wc11-c2x-compat): Rename to Wc11-c23-compat and make into
a deprecated alias of Wc11-c23-compat.
(std=c2x): Rename to std=c23 and make into a deprecated alias of
std=c23.
(std=gnu2x): Rename to std=gnu23 and make into a deprecated alias
of std=gnu23.
(std=iso9899:2024): New option. Alias of std=c23.
* c-lex.cc (interpret_float): Use OPT_Wc11_c23_compat instead of
OPT_Wc11_c2x_compat.
* c-opts.cc (c_common_handle_option): Use OPT_std_c23 instead of
OPT_std_c2x and OPT_std_gnu23 instead of OPT_std_gnu2x.
gcc/c/
* c-errors.cc (pedwarn_c11): Use OPT_Wc11_c23_compat instead of
OPT_Wc11_c2x_compat.
* c-typeck.cc (build_conditional_expr, convert_for_assignment):
Use OPT_Wc11_c23_compat instead of OPT_Wc11_c2x_compat.
Thomas Schwinge [Thu, 14 Jul 2022 21:22:35 +0000 (23:22 +0200)]
nvptx: Use the usual '#define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)'
With this 'MAKE_DECL_ONE_ONLY' definition, we get 'SUPPORTS_ONE_ONLY', and thus
'__GXX_WEAK__', and thus '__GXX_TYPEINFO_EQUALITY_INLINE'. This unblocks build
of 'libstdc++-v3/libsupc++/tinfo.cc', which otherwise depends on symbol alias
support, which GCC/nvptx doesn't generally provide. Also, this gets us a
number of FAIL -> PASS progressions in the test suite.
Given that GCC/nvptx support for weak symbols isn't complete, we also get a few
more of the already-known
'error: PTX does not support weak declarations (only weak definitions)':
[-PASS:-]{+FAIL:+} g++.old-deja/g++.other/crash11.C -std=c++14 (test for excess errors)
[-PASS:-]{+FAIL:+} g++.old-deja/g++.other/crash11.C -std=c++17 (test for excess errors)
[-PASS:-]{+FAIL:+} g++.old-deja/g++.other/crash11.C -std=c++20 (test for excess errors)
[-PASS:-]{+FAIL:+} g++.old-deja/g++.other/crash11.C -std=c++98 (test for excess errors)
[-PASS:-]{+FAIL:+} g++.old-deja/g++.pt/crash29.C -std=c++14 (test for excess errors)
[-PASS:-]{+FAIL:+} g++.old-deja/g++.pt/crash29.C -std=c++17 (test for excess errors)
[-PASS:-]{+FAIL:+} g++.old-deja/g++.pt/crash29.C -std=c++20 (test for excess errors)
[-PASS:-]{+FAIL:+} g++.old-deja/g++.pt/crash29.C -std=c++98 (test for excess errors)
[-PASS:-]{+FAIL:+} 23_containers/map/56613.cc -std=gnu++17 (test for excess errors)
... as well as one more of the already-known
'sorry, unimplemented: target cannot support nonlocal goto':
PASS: g++.dg/tree-ssa/pr22488.C -std=gnu++14 (test for excess errors)
PASS: g++.dg/tree-ssa/pr22488.C -std=gnu++17 (test for excess errors)
PASS: g++.dg/tree-ssa/pr22488.C -std=gnu++20 (test for excess errors)
[-PASS:-]{+FAIL:+} g++.dg/tree-ssa/pr22488.C -std=gnu++98 (test for excess errors)
Richard Biener [Mon, 6 Nov 2023 13:34:07 +0000 (14:34 +0100)]
tree-optimization/112405 - SIMD clone calls with (loop) mask
The following fixes the mask argument generation for SIMD clone
calls under either loop masking or when the actual call is not
masked but only a inbranch simd clone is available. The issue
was that we tried to directly convert the vector mask to the
call argument type but SIMD clone masks require 1 or 0 (which
could be even float) values for mask elements so we have to
resort to a VEC_COND_EXPR to generate them just like we do for
regular passing of the mask.
Unfortunately, the HF mode is not include due to it requires
additional middle-end support from internal-fun.def.
gcc/ChangeLog:
* config/riscv/autovec.md: Remove the size check of lround.
* config/riscv/riscv-v.cc (expand_vec_lround): Leverage
emit_vec_rounding_to_integer for round.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/unop/math-iround-1.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-iround-run-1.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-llroundf-0.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-llroundf-run-0.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-lround-rv32-0.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-lround-rv32-run-0.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-lroundf-rv64-0.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-lroundf-rv64-run-0.c: New test.
* gcc.target/riscv/rvv/autovec/vls/math-iround-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/math-llroundf-0.c: New test.
* gcc.target/riscv/rvv/autovec/vls/math-lround-rv32-0.c: New test.
* gcc.target/riscv/rvv/autovec/vls/math-lroundf-rv64-0.c: New test.
The root cause is that the RA reload into (set (reg) vec_duplicate:DI). However, it is not valid in RV32 system
since we don't have a single broadcast instruction DI scalar in RV32 system.
We should expand it early for RV32 system.
The following simplifies LC-PHI arg population during epilog peeling,
thereby fixing the testcase in this PR.
PR tree-optimization/111950
* tree-vect-loop-manip.cc (slpeel_duplicate_current_defs_from_edges):
Remove.
(find_guard_arg): Likewise.
(slpeel_update_phi_nodes_for_guard2): Likewise.
(slpeel_tree_duplicate_loop_to_edge_cfg): Remove calls to
slpeel_duplicate_current_defs_from_edges, do not elide
LC-PHIs for invariant values.
(vect_do_peeling): Materialize PHI arguments for the edge
around the epilog from the PHI defs of the main loop exit.
Richard Biener [Mon, 6 Nov 2023 11:43:11 +0000 (12:43 +0100)]
tree-optimization/112404 - two issues with SLP of .MASK_LOAD
The following fixes an oversight in vect_check_scalar_mask when
the mask is external or constant. When doing BB vectorization
we need to provide a group_size, best via an overload accepting
the SLP node as argument.
When fixed we then run into the issue that we have not analyzed
alignment of the .MASK_LOADs because they were not identified
as loads by vect_gather_slp_loads. Fixed by reworking the
detection.
PR tree-optimization/112404
* tree-vectorizer.h (get_mask_type_for_scalar_type): Declare
overload with SLP node argument.
* tree-vect-stmts.cc (get_mask_type_for_scalar_type): Implement it.
(vect_check_scalar_mask): Use it.
* tree-vect-slp.cc (vect_gather_slp_loads): Properly identify
loads also for nodes with children, like .MASK_LOAD.
* tree-vect-loop.cc (vect_analyze_loop_2): Look at the
representative for load nodes and check whether it is a grouped
access before looking for load-lanes support.
Current glibc headers only declare fputs_unlocked for _GNU_SOURCE,
so define it to obtain an official prototype.
Add a fallback prototype declaration for other systems that do not
have fputs_unlocked. This seems to the most straightforward approach
to avoid an implicit function declaration, without reducing test
coverage and introducing ongoing maintenance requirements (e.g.,
FreeBSD added fputs_unlocked support fairly recently).
Robin Dapp [Wed, 25 Oct 2023 20:19:43 +0000 (22:19 +0200)]
internal-fn: Add VCOND_MASK_LEN.
In order to prevent simplification of a COND_OP with degenerate mask
(CONSTM1_RTX) into just an OP in the presence of length masking this
patch introduces a length-masked analog to VEC_COND_EXPR:
IFN_VCOND_MASK_LEN.
It also adds new match patterns that allow the combination of
unconditional unary, binary and ternay operations with the
VCOND_MASK_LEN into a conditional operation if the target supports it.
This patch allows allocate_dynamic_stack_space to be called before
or after virtual registers have been instantiated. It uses the
same approach as allocate_stack_local, which already supported this.
gcc/
* function.h (get_stack_dynamic_offset): Declare.
* function.cc (get_stack_dynamic_offset): New function,
split out from...
(get_stack_dynamic_offset): ...here.
* explow.cc (allocate_dynamic_stack_space): Handle calls made
after virtual registers have been instantiated.
Tobias Burnus [Mon, 6 Nov 2023 10:34:31 +0000 (11:34 +0100)]
libgfortran: Fix calloc call by swapping arg order [PR112364]
The prototype of calloc is
void *calloc(size_t nmemb, size_t size);
denoting "an array of nmemb objects, each of whose size is size." (C23)
In order to follow the meaning of the argument names and to silence
a -Walloc-size warning, this commit swaps the order of the two args
to read now: calloc (1, sizeof (transfer_queue));
libgfortran/ChangeLog:
PR libfortran/112364
* io/async.c (enqueue_transfer, enqueue_done_id, enqueue_done,
enqueue_close): Swap 1st and 2nd arg in calloc call.
Jonathan Wakely [Wed, 1 Nov 2023 14:28:55 +0000 (14:28 +0000)]
libstdc++: Improve static assert messages for monadic operations
The monadic operations for std::optional and std::expected make use of
internal helper traits __is_optional nad __is_expected, which are not
very user-friendly when shown in diagnostics. Add messages to the
assertions explaining the problem more clearly.
Pan Li [Mon, 6 Nov 2023 08:26:09 +0000 (16:26 +0800)]
RISC-V: Adjust FP rint round tests for RV32
The FP rint test cases for RV32 need some additional adjust
for types and data. This patch would like to fix this which
is missed in FP rint support PATCH for RV32 only by mistake.
Please note the math-llrintf-run-0.c will trigger one ICE in the
vsetvl pass in RV32 only.
Richard Biener [Fri, 3 Nov 2023 07:11:05 +0000 (08:11 +0100)]
middle-end/112296 - __builtin_constant_p and side-effects
The following tries to clarify the __builtin_constant_p documentation,
stating that the argument expression is not evaluated and side-effects
are discarded. I'm struggling to find the correct terms matching
what the C language standard would call things so I'd appreciate
some help here.
OK for trunk?
Shall we diagnose arguments with side-effects? It seems to me
such use is usually unintended? I think rather than dropping
side-effects as a side-effect of folding the frontend should
discard them at parsing time instead, no?
Thanks,
Richard.
PR middle-end/112296
* doc/extend.texi (__builtin_constant_p): Clarify that
side-effects are discarded.
Kewen Lin [Mon, 6 Nov 2023 06:14:43 +0000 (00:14 -0600)]
rs6000: Consider inline asm as safe if no assembler complains [PR111828]
As discussed in PR111828, rs6000_update_ipa_fn_target_info
is much conservative, currently for any non-empty inline
asm, without any parsing, it would take inline asm could
have HTM insns. It means for one function attributed with
power8 having inline asm, even if it has no HTM insns, we
don't make a function attributed with power10 inline it.
Peter pointed out an inline asm parser can be a slippery
slope, and noticed that the current gnu assembler still
allows HTM insns even with power10 machine type, so he
suggested that we can aggressively ignore the handling on
inline asm, this patch goes for this suggestion.
Considering that there are a few assembler alternatives
and assembler can update its behaviors (complaining HTM
insns at power10 and later cpus sounds reasonable from a
certain point of view), this patch also checks assembler
complains on HTM insns at power10 or not. For a case that
a caller attributed power10 calls a callee attributed
power8 having inline asm with HTM insn, without inlining
at least the compilation succeeds, but if assembler
complains HTM insns at power10, after inlining the
compilation would fail.
The two associated test cases are fine without and with
this patch (effective target takes effect or not).
PR target/111828
gcc/ChangeLog:
* config.in: Regenerate.
* config/rs6000/rs6000.cc (rs6000_update_ipa_fn_target_info): Guard
inline asm handling under !HAVE_AS_POWER10_HTM.
* configure: Regenerate.
* configure.ac: Detect assembler support for HTM insns at power10.
gcc/testsuite/ChangeLog:
* lib/target-supports.exp
(check_effective_target_powerpc_as_p10_htm): New proc.
* g++.target/powerpc/pr111828-1.C: New test.
* g++.target/powerpc/pr111828-2.C: New test.
xuli [Mon, 30 Oct 2023 08:23:15 +0000 (08:23 +0000)]
RISC-V: Implement RESOLVE_OVERLOADED_BUILTIN for RVV intrinsic
Update in v6:
* Rename maybe_require_frm_p to may_require_frm_p.
* Rename maybe_require_vxrm_p to may_require_vxrm_p.
* Move may_require_frm_p and may_require_vxrm_p to function_base.
Update in v5:
* Split has_vxrm_or_frm_p into maybe_require_frm_p and
maybe_require_vxrm_p.
* Adjust comments.
Update in v4:
* Remove class function_resolver.
* Remove function get_non_overloaded_instance.
* Add overloaded hash traits for non-overloaded intrinsic.
* All overloaded intrinsics are implemented, and the tests pass.
Update in v3:
* Rewrite comment for overloaded function add.
* Move get_non_overloaded_instance to function_base.
Update in v2:
* Add get_non_overloaded_instance for function instance.
* Fix overload check for policy function.
* Enrich the test cases check.
Original log:
This patch would like add the framework to support the RVV overloaded
intrinsic API in riscv-xxx-xxx-gcc, like riscv-xxx-xxx-g++ did.
However, it almost leverage the hook TARGET_RESOLVE_OVERLOADED_BUILTIN
with below steps.
* Register overloaded functions.
* Add function_resolver for overloaded function resolving.
* Add resolve API for function shape with default implementation.
* Implement HOOK for navigating the overloaded API to non-overloaded API.
gcc/ChangeLog:
* config/riscv/riscv-c.cc (riscv_resolve_overloaded_builtin): New function for the hook.
(riscv_register_pragmas): Register the hook.
* config/riscv/riscv-protos.h (resolve_overloaded_builtin): New decl.
* config/riscv/riscv-vector-builtins-bases.cc: New function impl.
* config/riscv/riscv-vector-builtins-shapes.cc (build_one): Register overloaded function.
* config/riscv/riscv-vector-builtins.cc (struct non_overloaded_registered_function_hasher):
New hash table.
(function_builder::add_function): Add overloaded arg.
(function_builder::add_unique_function): Map overloaded function to non-overloaded function.
(function_builder::add_overloaded_function): New API impl.
(registered_function::overloaded_hash): Calculate hash value.
(has_vxrm_or_frm_p): New function impl.
(non_overloaded_registered_function_hasher::hash): Ditto.
(non_overloaded_registered_function_hasher::equal): Ditto.
(handle_pragma_vector): Allocate space for hash table.
(resolve_overloaded_builtin): New function impl.
* config/riscv/riscv-vector-builtins.h (function_base::may_require_frm_p): Ditto.
(function_base::may_require_vxrm_p): Ditto.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/base/overloaded_rv32_vadd.c: New test.
* gcc.target/riscv/rvv/base/overloaded_rv32_vfadd.c: New test.
* gcc.target/riscv/rvv/base/overloaded_rv32_vget_vset.c: New test.
* gcc.target/riscv/rvv/base/overloaded_rv32_vloxseg2ei16.c: New test.
* gcc.target/riscv/rvv/base/overloaded_rv32_vmv.c: New test.
* gcc.target/riscv/rvv/base/overloaded_rv32_vreinterpret.c: New test.
* gcc.target/riscv/rvv/base/overloaded_rv64_vadd.c: New test.
* gcc.target/riscv/rvv/base/overloaded_rv64_vfadd.c: New test.
* gcc.target/riscv/rvv/base/overloaded_rv64_vget_vset.c: New test.
* gcc.target/riscv/rvv/base/overloaded_rv64_vloxseg2ei16.c: New test.
* gcc.target/riscv/rvv/base/overloaded_rv64_vmv.c: New test.
* gcc.target/riscv/rvv/base/overloaded_rv64_vreinterpret.c: New test.
* gcc.target/riscv/rvv/base/overloaded_vadd.h: New test.
* gcc.target/riscv/rvv/base/overloaded_vfadd.h: New test.
* gcc.target/riscv/rvv/base/overloaded_vget_vset.h: New test.
* gcc.target/riscv/rvv/base/overloaded_vloxseg2ei16.h: New test.
* gcc.target/riscv/rvv/base/overloaded_vmv.h: New test.
* gcc.target/riscv/rvv/base/overloaded_vreinterpret.h: New test.
Signed-off-by: Li Xu <xuli1@eswincomputing.com> Co-Authored-By: Pan Li <pan2.li@intel.com>
Haochen Jiang [Mon, 6 Nov 2023 01:37:31 +0000 (09:37 +0800)]
[PATCH 1/3] Change internal intrin call for AVX512 intrins
The newly added _mm{,256}_avx512* intrins are duplicated from their
_mm{,256}_* forms from AVX2 or before. We need to add them to prevent target
option mismatch when calling AVX512 intrins implemented with these intrins
under no-evex512 function attribute. All AVX512 intrins calling those AVX2
intrins or before will change their calls to these newly added AVX512 version.