platform/upstream/gcc.git
2 years agoinput: add get_source_text_between
Jeff Chapman II [Thu, 3 Nov 2022 19:47:47 +0000 (15:47 -0400)]
input: add get_source_text_between

The c++-contracts branch uses this to retrieve the source form of the
contract predicate, to be returned by contract_violation::comment().

Co-authored-by: Jason Merrill <jason@redhat.com>
gcc/ChangeLog:

* input.cc (get_source_text_between): New fn.
* input.h (get_source_text_between): Declare.

2 years agoSet nonzero bits for multiplication and divisions by a power of 2.
Aldy Hernandez [Fri, 4 Nov 2022 09:20:46 +0000 (10:20 +0100)]
Set nonzero bits for multiplication and divisions by a power of 2.

We're missing a lot of TLC in keeping track of nonzero bits across
range-ops.  It isn't an oversight, but just limited amount of hours to
implement stuff.

This patch keeps better track of the nonzero mask (really
maybe_nonzero bits as discussed) across multiplication and division
when the RHS is a power of 2.

It fixes PR107342 and also touches on PR55157.  In the latter, the
nonzero mask is being set quite late (CCP2) but could be set by evrp
time if we enhanced range-ops.  I have added tests from both PRs.

Tested

PR tree-optimization/107342

gcc/ChangeLog:

* range-op.cc (operator_mult::fold_range): New.
(operator_div::fold_range): New.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/vrp122.c: New test.
* gcc.dg/tree-ssa/vrp123.c: New test.

2 years agoFix recent thinko in operand_equal_p
Eric Botcazou [Fri, 4 Nov 2022 10:23:12 +0000 (11:23 +0100)]
Fix recent thinko in operand_equal_p

There is a thinko in a recent improvement made to operand_equal_p where
the code just looks at operand 2 of COMPONENT_REF, if it is present, to
compare addresses.  That's wrong because operand 2 contains the number of
DECL_OFFSET_ALIGN-bit-sized words so, when DECL_OFFSET_ALIGN > 8, not all
the  bytes are included and some of them are in DECL_FIELD_BIT_OFFSET, see
get_inner_reference for the model computation.

In other words, you would need to compare operand 2 and DECL_OFFSET_ALIGN
and DECL_FIELD_BIT_OFFSET in this situation, but I'm not sure this is worth
the hassle in practice so the fix just removes this alternate handling.

gcc/
* fold-const.cc (operand_compare::operand_equal_p) <COMPONENT_REF>:
Do not take into account operand 2.
(operand_compare::hash_operand) <COMPONENT_REF>: Likewise.

gcc/testsuite/
* gnat.dg/opt99.adb: New test.
* gnat.dg/opt99_pkg1.ads, gnat.dg/opt99_pkg1.adb: New helper.
* gnat.dg/opt99_pkg2.ads: Likewise.

2 years agoDo not use subword paradoxical subregs in emit_group_store
Eric Botcazou [Fri, 4 Nov 2022 10:15:57 +0000 (11:15 +0100)]
Do not use subword paradoxical subregs in emit_group_store

The goal of the trick is to make life easier for the combiner, but subword
paradoxical subregs make it harder for the register allocator instead.

gcc/
* expr.cc (emit_group_store): Do not use subword paradoxical subregs

2 years agolibstdc++: Simplify lifetime of eh_globals variable [PR107500]
Jonathan Wakely [Thu, 3 Nov 2022 11:48:57 +0000 (11:48 +0000)]
libstdc++: Simplify lifetime of eh_globals variable [PR107500]

Since this is a trivial type, we probably don't need to do anything to
ensure it's still accessible after other static dtors.

libstdc++-v3/ChangeLog:

PR libstdc++/107500
* libsupc++/eh_globals.cc (eh_globals): Remove immortalizing
wrapper.
(__cxxabiv1::__cxa_get_globals_fast): Adjust.
(__cxxabiv1::__cxa_get_globals): Adjust.

2 years agolibstdc++: Define _GNU_SOURCE for secure_getenv on Cygwin [PR107511]
Jonathan Wakely [Thu, 3 Nov 2022 11:44:47 +0000 (11:44 +0000)]
libstdc++: Define _GNU_SOURCE for secure_getenv on Cygwin [PR107511]

As in r12-6867-ge20486d508afdf we need to define _GNU_SOURCE explicitly
for Cygwin, because configure finds it in libc but it isn't declared
unless we request it.

libstdc++-v3/ChangeLog:

PR libstdc++/107511
* libsupc++/eh_alloc.cc (_GNU_SOURCE): Define.

2 years agoada: Fix for validity checks combined with aliasing checks
Justin Squirek [Wed, 12 Oct 2022 09:53:04 +0000 (11:53 +0200)]
ada: Fix for validity checks combined with aliasing checks

Attribute Overlaps_Storage, which can appear implicitly in expansion of
aliasing checks, is now excluded from operand validity checks. Likewise
for attribute Has_Same_Storage.

gcc/ada/

* exp_attr.adb (Expand_N_Attribute_Reference): Skip operand
validity checks for attributes Has_Same_Storage and
Overlaps_Storage.

2 years agoada: Fix couple of issues with arrays indexed by enumeration type
Eric Botcazou [Wed, 12 Oct 2022 10:41:49 +0000 (12:41 +0200)]
ada: Fix couple of issues with arrays indexed by enumeration type

The first one is that Remove_Warning_Messages reinstates the Original_Node
of an N_Raise_Constraint_Error node in the tree for no clear reasons, and
the Original_Node may contain constructs whose expansion has been stopped
when the Constraint_Error was asserted, eventually causing gigi to stop.

The second one is that a path in Build_Array_Aggr_Code.Gen_Loop does not
copy the loop bounds, unlike other paths, thus triggering a sharing issue.

gcc/ada/

* errout.adb (Remove_Warning_Messages.Check_For_Warning): Do not
reinstate the Original_Node in the tree.
* exp_aggr.adb (Build_Array_Aggr_Code.Gen_Loop): Copy the bounds
on all paths.

2 years agoada: Fix typo in comment referring to pragma Restrictions
Piotr Trojanek [Thu, 1 Sep 2022 08:16:23 +0000 (10:16 +0200)]
ada: Fix typo in comment referring to pragma Restrictions

Comment cleanup only.

gcc/ada/

* libgnat/g-excact.ads
(Register_Global_Action): Refill comment.
(Name_To_Id): Change pragma Restriction from singular to plural.

2 years agoada: Cleanup code for warnings about unreferenced formal parameters
Piotr Trojanek [Wed, 24 Aug 2022 11:27:49 +0000 (13:27 +0200)]
ada: Cleanup code for warnings about unreferenced formal parameters

Cleanup related to new checks for unset references.

gcc/ada/

* sem_warn.adb (Check_References): Remove redundant guard, as it
is implied by a preceding call to Referenced_Check_Spec.

2 years agoada: Cleanup code for unreferenced variables
Piotr Trojanek [Tue, 23 Aug 2022 13:59:32 +0000 (15:59 +0200)]
ada: Cleanup code for unreferenced variables

Further cleanups related to warnings about unreferenced objects.

gcc/ada/

* sem_warn.adb (Check_References): Remove useless query for "spec"
of a variable; refactor nested if-statements into a single
condition.

2 years agoada: Cleanup code for warnings about unset references
Piotr Trojanek [Tue, 23 Aug 2022 10:57:35 +0000 (12:57 +0200)]
ada: Cleanup code for warnings about unset references

Cleanup related to new checks for unset references.

gcc/ada/

* sem_util.adb
(In_Pragma_Expression): Add standard guard against searching too
far.
(In_Quantified_Expression): Likewise.
* sem_warn.adb
(May_Need_Initialized_Actual): Remove redundant parens.
(Check_References): Remove guard that duplicates a condition from
the enclosing if-statement; only assign E1T variable when
necessary.
(Within_Postcondition): Fix layout.
(No_Warn_On_In_Out): Balance parens in comment.

2 years agoada: Static intrinsic functions are a core language extension.
Steve Baird [Sat, 8 Oct 2022 00:20:31 +0000 (17:20 -0700)]
ada: Static intrinsic functions are a core language extension.

GNAT-defined Ada extensions are divided into two categories: those that are
enabled by either -gnatX or -gnatX0 and those which require -gnatX0.
Move static intrinsic functions from the second category into the first.

gcc/ada/

* doc/gnat_rm/implementation_defined_pragmas.rst: Add the standard
'... "On" enables this extension.' sentence to the description of
static intrinsic functions.
* sem_ch13.adb
(Analyze_Aspect_Spec): In the call to Error_Msg_GNAT_Extension for
a Static aspect specification for an intrinsic function, specify
Is_Core_Extension => True.
* sem_eval.adb
(Eval_Intrinsic_Call): Test Core_Extensions_Allowed instead of
testing All_Extensions_Allowed.
* gnat_rm.texi: Regenerate.

2 years agoada: Remove redundant calls in handling of aspect specifications
Piotr Trojanek [Fri, 26 Aug 2022 13:27:31 +0000 (15:27 +0200)]
ada: Remove redundant calls in handling of aspect specifications

Routine Set_Aspect_Specifications sets the Has_Aspect flag, so there is
no need to set this flag again afterwards.

Code cleanup; semantics is unaffected.

gcc/ada/

* aspects.adb (Relocate_Aspect): Remove call to Set_Has_Aspects.
* sem_ch12.adb (Analyze_Formal_Package_Declaration): Likewise.
* sem_util.adb (Copy_Ghost_Aspect, Copy_SPARK_Mode_Aspect):
Likewise.

2 years agoada: Flag unsupported dispatching constructor calls
Javier Miranda [Fri, 7 Oct 2022 18:43:46 +0000 (18:43 +0000)]
ada: Flag unsupported dispatching constructor calls

gcc/ada/

* exp_intr.adb
(Expand_Dispatching_Constructor_Call): Report an error on
unsupported dispatching constructor calls and report a warning on
calls that may fail at run time.

gcc/testsuite/

* gnat.dg/abstract1.ads: Cleanup whitespaces.
* gnat.dg/abstract1.adb: Likewise and add -gnatws to silence new
warning.

2 years agoada: Avoid repeated iteration over private protected components
Piotr Trojanek [Thu, 1 Sep 2022 08:19:09 +0000 (10:19 +0200)]
ada: Avoid repeated iteration over private protected components

The First_Entity/Next_Entity chain includes private entities, so there
it no need to iterate starting both from First_Entity and
First_Private_Entity.

Code cleanup related to improved detection of references to
uninitialized objects; behavior is unaffected.

gcc/ada/

* sem_util.adb
(Check_Components): Iterate using
First/Next_Component_Or_Discriminant.
(Has_Preelaborable_Initialization): Avoid repeated iteration with
calls to Check_Components with First_Entity and
First_Private_Entity.
(Is_Independent_Object_Entity): Tune indentation.

2 years agoada: Cleanup clearing flags on package variables
Piotr Trojanek [Tue, 23 Aug 2022 15:16:44 +0000 (17:16 +0200)]
ada: Cleanup clearing flags on package variables

When killing flags on assignable entities we iterated from First_Entity
and then again from First_Private_Entity. This second iteration was
unnecessary, because the entity chain that starts with First_Entity
contains all entities, including the private ones.

This is just a performance improvement; the behavior is unchanged.

gcc/ada/

* sem_ch7.adb (Clear_Constants): Only iterate from First_Entity
through Next_Entity; only examine variables because packages have
no assignable formal parameters.

2 years agoada: Fix various typos in GNAT User's Guide
Piotr Trojanek [Sun, 9 Oct 2022 20:01:51 +0000 (22:01 +0200)]
ada: Fix various typos in GNAT User's Guide

Fix uncontroversial typos.

gcc/ada/

* doc/gnat_ugn/building_executable_programs_with_gnat.rst: Fix
typos.
* doc/gnat_ugn/elaboration_order_handling_in_gnat.rst: Fix typos
and refill as necessary; remove trailing whitespace.
* doc/gnat_ugn/gnat_and_program_execution.rst: Fix typos.
* gnat_ugn.texi: Regenerate.

2 years agoada: Fix loop unnesting issue.
Marc Poulhiès [Thu, 22 Sep 2022 08:59:42 +0000 (10:59 +0200)]
ada: Fix loop unnesting issue.

During loop unnesting, when the loop statements are wrapped in a code
block, the newly created block's scope must be set to the loop
scope (instead of the previous 'Current_Scope' that would point to an
upper scope).

gcc/ada/

* sem_util.ads (Add_Block_Identifier): Add new extra Scope
argument.
* sem_util.adb (Add_Block_Identifier): Likewise and use this scope
variable instead of Current_Scope.
* exp_util.adb (Wrap_Statements_In_Block): Add new scope argument
to Add_Block_Identifier call.

2 years agoada: Fix repeated killing of private entity values
Piotr Trojanek [Fri, 7 Oct 2022 10:55:14 +0000 (12:55 +0200)]
ada: Fix repeated killing of private entity values

When killing known values of assignable entities we iterated from
First_Entity and then again from First_Private_Entity. This second
iteration was unnecessary, because the entity chain that starts with
First_Entity contains all entities, including the private ones.

This is just a performance improvement; the behavior is unchanged.

gcc/ada/

* sem_util.adb (Kill_Current_Values): Only iterate from
First_Entity through Next_Entity.

2 years agoada: Simplify detection of controlling formals
Piotr Trojanek [Fri, 7 Oct 2022 19:58:58 +0000 (21:58 +0200)]
ada: Simplify detection of controlling formals

When detecting controlling formals we are only interested in formal
parameters and not in other entities.

gcc/ada/

* sem_ch6.adb (Controlling_Formal): Iterate with First/Next_Formal
and not with First/Next_Entity.

2 years agoada: Skip dynamic interface conversion under configurable runtime
Javier Miranda [Fri, 7 Oct 2022 16:02:02 +0000 (16:02 +0000)]
ada: Skip dynamic interface conversion under configurable runtime

gcc/ada/

* exp_disp.adb
(Expand_Interface_Conversion): Fix typo in comment.

2 years agoada: Skip dynamic interface conversion under configurable runtime
Javier Miranda [Thu, 6 Oct 2022 21:44:43 +0000 (21:44 +0000)]
ada: Skip dynamic interface conversion under configurable runtime

gcc/ada/

* exp_disp.adb
(Expand_Interface_Conversion): Under configurable runtime, when
the target type is an interface that is an ancestor of the operand
type, skip generating code to displace the pointer to reference
the target dispatch table.
* sem_disp.adb
(Propagate_Tag): Handle class-wide types when checking for the
addition of an implicit interface conversion.

2 years agoada: Fix typo
Ronan Desplanques [Thu, 6 Oct 2022 12:34:17 +0000 (14:34 +0200)]
ada: Fix typo

Fix typo in documentation.

gcc/ada/

* doc/gnat_rm/standard_library_routines.rst: Fix typo.
* gnat_rm.texi: Regenerate.

2 years agoada: Remove sa_messages
Ghjuvan Lacambre [Fri, 30 Sep 2022 13:44:49 +0000 (15:44 +0200)]
ada: Remove sa_messages

Spark and CodePeer do not depend on this unit anymore.

gcc/ada/

* sa_messages.ads, sa_messages.adb: Remove files.

2 years agoada: Refactor: replace uses of `not Present(X)` with `No (X)`
Ghjuvan Lacambre [Sat, 17 Sep 2022 17:35:48 +0000 (19:35 +0200)]
ada: Refactor: replace uses of `not Present(X)` with `No (X)`

`No (X)` is essentially `not Present (X)`, there's no reason for not
using this shorter form.

gcc/ada/

* checks.adb, exp_atag.adb, exp_attr.adb, exp_ch4.adb, exp_ch6.adb,
exp_ch7.adb, exp_dbug.adb, exp_disp.adb, exp_unst.adb, exp_util.adb,
freeze.adb, layout.adb, pprint.adb, rtsfind.adb, sem_aggr.adb,
sem_attr.adb, sem_case.adb, sem_ch12.adb, sem_ch13.adb, sem_ch3.adb,
sem_ch5.adb, sem_ch6.adb, sem_ch8.adb, sem_dim.adb, sem_prag.adb,
sem_util.adb, sem_warn.adb:
Replace uses of `not Present (X)` with `No (X)`.

2 years agoada: Fix various typos in node and entity description comments
Piotr Trojanek [Fri, 7 Oct 2022 10:42:34 +0000 (12:42 +0200)]
ada: Fix various typos in node and entity description comments

Fix typos in units that describe GNAT abstract syntax tree.

gcc/ada/

* einfo.ads: Fix typos in comments; refill as necessary.
* sinfo.ads: Likewise.

2 years agoada: Fix various typos in GNAT RM
Piotr Trojanek [Fri, 7 Oct 2022 10:20:55 +0000 (12:20 +0200)]
ada: Fix various typos in GNAT RM

List of unknown words in files can be produced with:

  $ cat *.rst | ispell -l |
    tr '[:upper:]' '[:lower:]' | sort | uniq | less

and can be easily filtered with eyes.

gcc/ada/

* doc/gnat_rm/implementation_defined_aspects.rst: Fix typos.
* doc/gnat_rm/implementation_defined_attributes.rst: Likewise
* doc/gnat_rm/implementation_defined_characteristics.rst: Likewise
* doc/gnat_rm/implementation_defined_pragmas.rst: Likewise
* doc/gnat_rm/standard_library_routines.rst: Likewise.
* gnat_rm.texi: Regenerate.

2 years agoada: Improve efficiency of scope stack restoration
Piotr Trojanek [Thu, 6 Oct 2022 21:42:46 +0000 (23:42 +0200)]
ada: Improve efficiency of scope stack restoration

We save/restore visibility by setting the Is_Immediately_Visible flag
and appending entities to / removing them from the tail of an element
list.

However, the Is_Immediately_Visible flag can be restored in any order,
while the element list is singly-linked and removal from the tail is
inefficient. This change removes a performance hot spot, which accounted
for up to 10% of compilation time of complex applications (e.g. QGen),
at least as measured on GNAT built with profiling support.

gcc/ada/

* sem_ch8.adb (Restore_Scope_Stack): Remove elements from the head
and not the tail of an element list.

2 years agoada: Small editorial changes to documentation comments
Ronan Desplanques [Mon, 3 Oct 2022 08:34:57 +0000 (10:34 +0200)]
ada: Small editorial changes to documentation comments

gcc/ada/

* sinfo.ads: Small editorial changes.

2 years agoada: Allow enabling a restricted set of language extensions.
Steve Baird [Fri, 30 Sep 2022 22:27:00 +0000 (15:27 -0700)]
ada: Allow enabling a restricted set of language extensions.

The -gnatX switch (and the related Extensions_Allowed pragma) is currently a
two-valued all-or-nothing option. Add support for enabling a curated subset
of language extensions without enabling others via the -gnatX switch
and for enabling all language extensions via the new -gnatX0 switch.
Similarly, the existing "ON" argument for the Extensions_Allowed pragma
now only enables the curated subset; the new argument "ALL" enables all
language extensions. The subset of language extensions currently includes
prefixed-view notation with an untagged prefix, fixed-low-bound array
subtypes, and casing on composite values.

gcc/ada/

* opt.ads: Replace Ada_Version_Type enumeration literal
Ada_With_Extensions with two literals, Ada_With_Core_Extensions
and Ada_With_All_Extensions. Update uses of the deleted literal.
Replace Extensions_Allowed function with two functions:
All_Extensions_Allowed and Core_Extensions_Allowed.
* errout.ads, errout.adb: Add Boolean parameter to
Error_Msg_GNAT_Extension to indicate whether the construct in
question belongs to the curated subset.
* exp_ch5.adb, par-ch4.adb, sem_case.adb, sem_ch3.adb:
* sem_ch4.adb, sem_ch5.adb, sem_ch8.adb: Replace calls to
Extensions_Allowed with calls to Core_Extensions_Allowed for
constructs that are in the curated subset.
* sem_attr.adb, sem_ch13.adb, sem_eval.adb, sem_util.adb: Replace
calls to Extensions_Allowed with calls to All_Extensions_Allowed
for constructs that are not in the curated subset.
* par-ch3.adb: Override default for new parameter in calls to
Error_Msg_GNAT_Extension for constructs in the curated subset.
* par-prag.adb: Add Boolean parameter to Check_Arg_Is_On_Or_Off to
also allow ALL. Set Opt.Ada_Version appropriately for ALL or ON
arguments.
* sem_prag.adb: Allowed ALL argument for an Extensions_Allowed
pragma. Set Opt.Ada_Version appropriately for ALL or ON arguments.
* switch-c.adb: The -gnatX switch now enables only the curated
subset of language extensions (formerly it enabled all of them);
the new -gnatX0 switch enables all of them.
* doc/gnat_ugn/building_executable_programs_with_gnat.rst:
Document new "-gnatX0" switch and update documentation for
"-gnatX" switch.
* doc/gnat_rm/implementation_defined_pragmas.rst: Document new ALL
argument for pragma Extensions_Allowed and update documentation
for the ON argument. Delete mention of Ada 2022 Reduce attribute
as an extension.
* gnat_rm.texi, gnat_ugn.texi: Regenerate.

2 years agoada: Generate missing object decls for adainit/adafinal registration calls
Steve Baird [Wed, 5 Oct 2022 22:16:26 +0000 (15:16 -0700)]
ada: Generate missing object decls for adainit/adafinal registration calls

A previous change on this ticket introduced calls to CUDA_Register_Function
for adainit and adafinal, but failed to introduce declarations for the
C string variables that are initialized and then passed as actual parameters
in this call. Provide the missing declarations (and, incidentally, change
the names of the two variables).

gcc/ada/

* bindgen.adb: Introduce two new string constants for the names of
the C-String variables that are assigned the names for adainit and
adafinal. Replace string literals in Gen_CUDA_Init with references
to these constants. In Gen_CUDA_Defs, generate C-String variable
declarations where these constants are the names of the variables.

2 years agoada: Support lock-free protected objects with pragma Initialize_Scalars
Piotr Trojanek [Mon, 3 Oct 2022 20:03:20 +0000 (22:03 +0200)]
ada: Support lock-free protected objects with pragma Initialize_Scalars

In general, protected subprograms are only eligible for a lock-free
expansion if they do not reference global assignable objects.

However, it seems reasonable to ignore references to variables in
System.Scalar_Values, which are generated when pragma Initialize_Scalars
is active. Such references appear, for example, when protected
subprogram has formal parameters of mode out.

gcc/ada/

* sem_ch9.adb (Satisfies_Lock_Free_Requirements): Ignore
references to global variables inserted due to pragma
Initialize_Scalars.

2 years agoada: Remove VxWorks 6 and VxWorks 653 2.x content from the UGX
Cedric Landet [Mon, 3 Oct 2022 14:04:34 +0000 (16:04 +0200)]
ada: Remove VxWorks 6 and VxWorks 653 2.x content from the UGX

Because they are not supported anymore.

gcc/ada/

* doc/gnat_rm/implementation_defined_pragmas.rst: Remove VxWorks
version 6.
* gnat_rm.texi, gnat_ugn.texi: Regenerate.

2 years agoada: Reject expanded global names in lock-free protected objects
Piotr Trojanek [Mon, 3 Oct 2022 21:16:19 +0000 (23:16 +0200)]
ada: Reject expanded global names in lock-free protected objects

Lock-free expansion of protected subprograms is only possible when there
are no references to global assignable objects. We only detected such
references when they appeared as direct names, but we must similarly
detect expanded names.

gcc/ada/

* sem_ch9.adb (Satisfies_Lock_Free_Requirements): Detect
references via expanded names.

2 years agoada: Generate host-side CUDA_Register_Function calls for device's adainit/adafinal
Steve Baird [Tue, 4 Oct 2022 21:42:56 +0000 (14:42 -0700)]
ada: Generate host-side CUDA_Register_Function calls for device's adainit/adafinal

To invoke a device-side subprogram from the host (via a CUDA_execute pragma),
the subprogram also has to be registered by calling CUDA_Register_Function.
The host-side adainit and adafinal procedures need to invoke the corresponding
device-side procedures, so corresponding CUDA_Register_Function calls need
to be generated.

gcc/ada/

* bindgen.adb
(Gen_CUDA_Init): Move existing loop body into a new local
procedure, Gen_CUDA_Register_Function_Call, and replace that loop
body with a call to this procedure. This first part is just
semantics-preserving refactoring. The second part is to add
Gen_CUDA_Register_Function_Call calls after the loop for the
device-side adainit and adafinal procedures.

2 years agoaarch64: Fix typo in aarch64-sve.md comment
Kyrylo Tkachov [Fri, 4 Nov 2022 10:08:03 +0000 (10:08 +0000)]
aarch64: Fix typo in aarch64-sve.md comment

gcc/ChangeLog:

* config/aarch64/aarch64-sve2.md: Fix typo in Cryptographic
extensions comment.

2 years agoRemove support for Intel MIC offloading
Thomas Schwinge [Mon, 17 Oct 2022 20:19:55 +0000 (22:19 +0200)]
Remove support for Intel MIC offloading

... after its deprecation in GCC 12.

* Makefile.def: Remove module 'liboffloadmic'.
* Makefile.in: Regenerate.
* configure.ac: Remove 'liboffloadmic' handling.
* configure: Regenerate.
contrib/
* gcc-changelog/git_commit.py (default_changelog_locations):
Remove 'liboffloadmic'.
* gcc_update (files_and_dependencies): Remove 'liboffloadmic'
files.
* update-copyright.py (GCCCmdLine): Remove 'liboffloadmic'
comment.
gcc/
* config.gcc [target *-intelmic-* | *-intelmicemul-*]: Remove.
* config/i386/i386-options.cc (ix86_omp_device_kind_arch_isa)
[ACCEL_COMPILER]: Remove.
* config/i386/intelmic-mkoffload.cc: Remove.
* config/i386/intelmic-offload.h: Likewise.
* config/i386/t-intelmic: Likewise.
* config/i386/t-omp-device: Likewise.
* configure.ac [target *-intelmic-* | *-intelmicemul-*]: Remove.
* configure: Regenerate.
* doc/install.texi (--enable-offload-targets=[...]): Update.
* doc/sourcebuild.texi: Remove 'liboffloadmic' documentation.
include/
* gomp-constants.h (GOMP_DEVICE_INTEL_MIC): Comment out.
(GOMP_VERSION_INTEL_MIC): Remove.
libgomp/
* libgomp-plugin.h (OFFLOAD_TARGET_TYPE_INTEL_MIC): Remove.
* libgomp.texi (OpenMP Context Selectors): Remove Intel MIC
documentation.
* plugin/configfrag.ac <enable_offload_targets>
[*-intelmic-* | *-intelmicemul-*]: Remove.
* configure: Regenerate.
* testsuite/lib/libgomp.exp (libgomp_init): Remove 'liboffloadmic'
handling.
(offload_target_to_openacc_device_type)
[$offload_target = *-intelmic*]: Remove.
(check_effective_target_offload_device_intel_mic)
(check_effective_target_offload_device_any_intel_mic): Remove.
* testsuite/libgomp.c-c++-common/on_device_arch.h
(device_arch_intel_mic, on_device_arch_intel_mic, any_device_arch)
(any_device_arch_intel_mic): Remove.
* testsuite/libgomp.c-c++-common/target-45.c: Remove
'offload_device_any_intel_mic' XFAIL.
* testsuite/libgomp.fortran/target10.f90: Likewise.
liboffloadmic/
* ChangeLog: Remove.
* Makefile.am: Likewise.
* Makefile.in: Likewise.
* aclocal.m4: Likewise.
* configure: Likewise.
* configure.ac: Likewise.
* configure.tgt: Likewise.
* doc/doxygen/config: Likewise.
* doc/doxygen/header.tex: Likewise.
* include/coi/common/COIEngine_common.h: Likewise.
* include/coi/common/COIEvent_common.h: Likewise.
* include/coi/common/COIMacros_common.h: Likewise.
* include/coi/common/COIPerf_common.h: Likewise.
* include/coi/common/COIResult_common.h: Likewise.
* include/coi/common/COISysInfo_common.h: Likewise.
* include/coi/common/COITypes_common.h: Likewise.
* include/coi/sink/COIBuffer_sink.h: Likewise.
* include/coi/sink/COIPipeline_sink.h: Likewise.
* include/coi/sink/COIProcess_sink.h: Likewise.
* include/coi/source/COIBuffer_source.h: Likewise.
* include/coi/source/COIEngine_source.h: Likewise.
* include/coi/source/COIEvent_source.h: Likewise.
* include/coi/source/COIPipeline_source.h: Likewise.
* include/coi/source/COIProcess_source.h: Likewise.
* liboffloadmic_host.spec.in: Likewise.
* liboffloadmic_target.spec.in: Likewise.
* plugin/Makefile.am: Likewise.
* plugin/Makefile.in: Likewise.
* plugin/aclocal.m4: Likewise.
* plugin/configure: Likewise.
* plugin/configure.ac: Likewise.
* plugin/libgomp-plugin-intelmic.cpp: Likewise.
* plugin/offload_target_main.cpp: Likewise.
* runtime/cean_util.cpp: Likewise.
* runtime/cean_util.h: Likewise.
* runtime/coi/coi_client.cpp: Likewise.
* runtime/coi/coi_client.h: Likewise.
* runtime/coi/coi_server.cpp: Likewise.
* runtime/coi/coi_server.h: Likewise.
* runtime/compiler_if_host.cpp: Likewise.
* runtime/compiler_if_host.h: Likewise.
* runtime/compiler_if_target.cpp: Likewise.
* runtime/compiler_if_target.h: Likewise.
* runtime/dv_util.cpp: Likewise.
* runtime/dv_util.h: Likewise.
* runtime/emulator/coi_common.h: Likewise.
* runtime/emulator/coi_device.cpp: Likewise.
* runtime/emulator/coi_device.h: Likewise.
* runtime/emulator/coi_host.cpp: Likewise.
* runtime/emulator/coi_host.h: Likewise.
* runtime/emulator/coi_version_asm.h: Likewise.
* runtime/emulator/coi_version_linker_script.map: Likewise.
* runtime/liboffload_error.c: Likewise.
* runtime/liboffload_error_codes.h: Likewise.
* runtime/liboffload_msg.c: Likewise.
* runtime/liboffload_msg.h: Likewise.
* runtime/mic_lib.f90: Likewise.
* runtime/offload.h: Likewise.
* runtime/offload_common.cpp: Likewise.
* runtime/offload_common.h: Likewise.
* runtime/offload_engine.cpp: Likewise.
* runtime/offload_engine.h: Likewise.
* runtime/offload_env.cpp: Likewise.
* runtime/offload_env.h: Likewise.
* runtime/offload_host.cpp: Likewise.
* runtime/offload_host.h: Likewise.
* runtime/offload_iterator.h: Likewise.
* runtime/offload_omp_host.cpp: Likewise.
* runtime/offload_omp_target.cpp: Likewise.
* runtime/offload_orsl.cpp: Likewise.
* runtime/offload_orsl.h: Likewise.
* runtime/offload_table.cpp: Likewise.
* runtime/offload_table.h: Likewise.
* runtime/offload_target.cpp: Likewise.
* runtime/offload_target.h: Likewise.
* runtime/offload_target_main.cpp: Likewise.
* runtime/offload_timer.h: Likewise.
* runtime/offload_timer_host.cpp: Likewise.
* runtime/offload_timer_target.cpp: Likewise.
* runtime/offload_trace.cpp: Likewise.
* runtime/offload_trace.h: Likewise.
* runtime/offload_util.cpp: Likewise.
* runtime/offload_util.h: Likewise.
* runtime/ofldbegin.cpp: Likewise.
* runtime/ofldend.cpp: Likewise.
* runtime/orsl-lite/include/orsl-lite.h: Likewise.
* runtime/orsl-lite/lib/orsl-lite.c: Likewise.
* runtime/orsl-lite/version.txt: Likewise.

2 years agolibgcc: Special-case BFD ld unwind table encodings in find_fde_tail
Florian Weimer [Fri, 4 Nov 2022 09:18:03 +0000 (10:18 +0100)]
libgcc: Special-case BFD ld unwind table encodings in find_fde_tail

BFD ld (and the other linkers) only produce one encoding of these
values.  It is not necessary to use the general
read_encoded_value_with_base decoding routine.  This avoids the
data-dependent branches in its implementation.

libgcc/

* unwind-dw2-fde-dip.c (find_fde_tail): Special-case encoding
values actually used by BFD ld.

2 years agoBetter integrate default 'sorry' 'TARGET_ASM_CONSTRUCTOR', 'TARGET_ASM_DESTRUCTOR'
Thomas Schwinge [Thu, 3 Nov 2022 16:29:13 +0000 (17:29 +0100)]
Better integrate default 'sorry' 'TARGET_ASM_CONSTRUCTOR', 'TARGET_ASM_DESTRUCTOR'

... after commit 4ee35c11fd328728c12f3e086ae016ca94624bf8
"Restore default 'sorry' 'TARGET_ASM_CONSTRUCTOR', 'TARGET_ASM_DESTRUCTOR'".
No functional change.

gcc/
* Makefile.in (OBJS): Remove 'dbxout.o'.
* config/nvptx/nvptx.cc: Don't '#include "dbxout.h"'.
* dbxout.cc: Remove.
* dbxout.h: Likewise.
* target-def.h (TARGET_ASM_CONSTRUCTOR, TARGET_ASM_DESTRUCTOR):
Default to 'default_asm_out_constructor',
'default_asm_out_destructor'.
* targhooks.cc (default_asm_out_constructor)
(default_asm_out_destructor): New.
* targhooks.h (default_asm_out_constructor)
(default_asm_out_destructor): Declare.

2 years agoRestore default 'sorry' 'TARGET_ASM_CONSTRUCTOR', 'TARGET_ASM_DESTRUCTOR'
Thomas Schwinge [Sun, 9 Oct 2022 20:39:02 +0000 (22:39 +0200)]
Restore default 'sorry' 'TARGET_ASM_CONSTRUCTOR', 'TARGET_ASM_DESTRUCTOR'

... that got lost in commit 7e0db0cdf01e9c885a29cb37415f5bc00d90c029
"STABS: remove -gstabs and -gxcoff functionality".

Previously, if a back end was not 'USE_COLLECT2', nor manually defined
'TARGET_ASM_CONSTRUCTOR', 'TARGET_ASM_DESTRUCTOR', or got pointed to the
respective 'default_[...]' functions due to 'CTORS_SECTION_ASM_OP',
'DTORS_SECTION_ASM_OP', or 'TARGET_ASM_NAMED_SECTION', it got pointed to
'default_stabs_asm_out_constructor', 'default_stabs_asm_out_destructor'.
These would emit 'sorry' for any global constructor/destructor they're
run into.

This is now gone, and thus in such a back end configuration case
'TARGET_ASM_CONSTRUCTOR', 'TARGET_ASM_DESTRUCTOR' don't get defined
anymore, and thus the subsequently following:

    #if !defined(TARGET_HAVE_CTORS_DTORS)
    # if defined(TARGET_ASM_CONSTRUCTOR) && defined(TARGET_ASM_DESTRUCTOR)
    # define TARGET_HAVE_CTORS_DTORS true
    # endif
    #endif

... doesn't define 'TARGET_HAVE_CTORS_DTORS' anymore, and thus per my
understanding, 'gcc/final.cc:rest_of_handle_final':

    if (DECL_STATIC_CONSTRUCTOR (current_function_decl)
        && targetm.have_ctors_dtors)
      targetm.asm_out.constructor (XEXP (DECL_RTL (current_function_decl), 0),
                                   decl_init_priority_lookup
                                     (current_function_decl));
    if (DECL_STATIC_DESTRUCTOR (current_function_decl)
        && targetm.have_ctors_dtors)
      targetm.asm_out.destructor (XEXP (DECL_RTL (current_function_decl), 0),
                                  decl_fini_priority_lookup
                                    (current_function_decl));

... simply does nothing anymore for a 'DECL_STATIC_CONSTRUCTOR',
'DECL_STATIC_DESTRUCTOR'.

This, effectively, means that GCC/nvptx now suddenly appears to "support"
global constructors/destructors, which means that a ton of test cases now
erroneously PASS that previously used to FAIL:

    sorry, unimplemented: global constructors not supported on this target

Of course, such support didn't magically happen due to
"STABS: remove -gstabs and -gxcoff functionality", so this is bad.  And,
corresponding execution testing then regularly FAILs (due to the global
constructor/destructor functions never being invoked), for example:

    [-UNSUPPORTED:-]{+PASS:+} gcc.dg/initpri1.c {+(test for excess errors)+}
    {+FAIL: gcc.dg/initpri1.c execution test+}

    [-UNSUPPORTED:-]{+PASS:+} g++.dg/special/conpr-1.C {+(test for excess errors)+}
    {+FAIL: g++.dg/special/conpr-1.C execution test+}

To restore the previous GCC/nvptx behavior, for traceability, this simply
restores the previous code, stripped down to the bare minimum.

gcc/
* Makefile.in (OBJS): Add 'dbxout.o'.
* config/nvptx/nvptx.cc: '#include "dbxout.h"'.
* dbxout.cc: New.
* dbxout.h: Likewise.
* target-def.h (TARGET_ASM_CONSTRUCTOR, TARGET_ASM_DESTRUCTOR):
Default to 'default_stabs_asm_out_constructor',
'default_stabs_asm_out_destructor'.

2 years agoSupport Intel AMX-FP16 ISA
Hongyu Wang [Fri, 4 Nov 2022 07:50:55 +0000 (15:50 +0800)]
Support Intel AMX-FP16 ISA

gcc/ChangeLog:

* common/config/i386/cpuinfo.h (get_available_features): Detect
amx-fp16.
* common/config/i386/i386-common.cc (OPTION_MASK_ISA2_AMX_FP16_SET,
OPTION_MASK_ISA2_AMX_FP16_UNSET): New macros.
(ix86_handle_option): Handle -mamx-fp16.
* common/config/i386/i386-cpuinfo.h (enum processor_features):
Add FEATURE_AMX_FP16.
* common/config/i386/i386-isas.h: Add ISA_NAME_TABLE_ENTRY for
amx-fp16.
* config.gcc: Add amxfp16intrin.h.
* config/i386/cpuid.h (bit_AMX_FP16): New.
* config/i386/i386-c.cc (ix86_target_macros_internal): Define
__AMX_FP16__.
* config/i386/i386-isa.def: Add DEF_PTA for AMX_FP16.
* config/i386/i386-options.cc (isa2_opts): Add -mamx-fp16.
(ix86_valid_target_attribute_inner_p): Add new ATTR.
(ix86_option_override_internal): Handle AMX-FP16.
* config/i386/i386.opt: Add -mamx-fp16.
* config/i386/immintrin.h: Include amxfp16intrin.h.
* doc/extend.texi: Document -mamx-fp16.
* doc/invoke.texi: Document amx-fp16.
* doc/sourcebuild.texi: Document amx_fp16.
* config/i386/amxfp16intrin.h: New file.

gcc/testsuite/ChangeLog:

* g++.dg/other/i386-2.C: Add -mamx-fp16.
* g++.dg/other/i386-3.C: Ditto.
* gcc.target/i386/sse-12.c: Ditto.
* gcc.target/i386/sse-13.c: Ditto.
* gcc.target/i386/sse-14.c: Ditto.
* gcc.target/i386/sse-22.c: Ditto.
* gcc.target/i386/sse-23.c: Ditto.
* lib/target-supports.exp: (check_effective_target_amx_fp16):
New proc.
* gcc.target/i386/funcspec-56.inc: Add new target attribute.
* gcc.target/i386/amx-check.h: Add AMX_FP16.
* gcc.target/i386/amx-helper.h: New file to support amx-fp16.
* gcc.target/i386/amxfp16-asmatt-1.c: New test.
* gcc.target/i386/amxfp16-asmintel-1.c: Ditto.
* gcc.target/i386/amxfp16-dpfp16ps-2.c: Ditto.

Co-authored-by: Haochen Jiang <haochen.jiang@intel.com>
2 years agoarm: Allow to override location of .gnu.sgstubs section
Torbjörn SVENSSON [Wed, 19 Oct 2022 09:31:33 +0000 (11:31 +0200)]
arm: Allow to override location of .gnu.sgstubs section

Depending on the DejaGNU board definition, the .gnu.sgstubs section
might be placed on different locations in order to suit the target.
With this patch, the start location of the section is overrideable
from the board definition with the fallback of the previously
hardcoded location.

gcc/testsuite/ChangeLog:

* gcc.target/arm/cmse/bitfield-1.c: Use overridable location.
* gcc.target/arm/cmse/bitfield-2.c: Likewise.
* gcc.target/arm/cmse/bitfield-3.c: Likewise.
* gcc.target/arm/cmse/cmse-20.c: Likewise.
* gcc.target/arm/cmse/struct-1.c: Likewise.
* gcc.target/arm/cmse/cmse.exp (cmse_sgstubs): New.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
2 years agoc++: Use in-process client when networking is disabled
Torbjörn SVENSSON [Tue, 25 Oct 2022 14:11:05 +0000 (16:11 +0200)]
c++: Use in-process client when networking is disabled

Without the patch, the output for bad-mapper-3.C would be:

/src/gcc/gcc/testsuite/g++.dg/modules/bad-mapper-3.C:2:1: error: unknown Compiled Module Interface: no such module

As this line is unexpected, the test case would fail.
The same problem can also be seen for g++.dg/modules/bad-mapper-2.C.

gcc/cp/ChangeLog:

* mapper-client.cc: Use in-process client when networking is
disabled.

gcc/testsuite/ChangeLog:

* g++.dg/modules/bad-mapper-3.C: Update dg-error pattern.

Co-Authored-By: Yvan ROUX <yvan.roux@foss.st.com>
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
2 years agoInitial Sierra Forest Support
Haochen Jiang [Fri, 4 Nov 2022 01:21:03 +0000 (09:21 +0800)]
Initial Sierra Forest Support

gcc/ChangeLog:

* common/config/i386/cpuinfo.h (get_intel_cpu):
Add Sierra Forest.
* common/config/i386/i386-common.cc
(processor_names): Add Sierra Forest.
(processor_alias_table): Ditto.
* common/config/i386/i386-cpuinfo.h
(enum processor_types): Add INTEL_SIERRAFOREST.
* config.gcc: Add -march=sierraforest.
* config/i386/driver-i386.cc (host_detect_local_cpu):
Handle Sierra Forest.
* config/i386/i386-c.cc (ix86_target_macros_internal):
Ditto.
* config/i386/i386-options.cc (m_SIERRAFOREST): New define.
(processor_cost_table): Add sierra forest.
* config/i386/i386.h (enum processor_type):
Add PROCESSOR_SIERRA_FOREST.
(PTA_SIERRAFOREST): Ditto.
* doc/extend.texi: Add sierra forest.
* doc/invoke.texi: Ditto.

gcc/testsuite/ChangeLog:

* g++.target/i386/mv16.C: Add sierra forest.
* gcc.target/i386/funcspec-56.inc: Handle new march.

2 years agoSupport Intel CMPccXADD
Haochen Jiang [Fri, 4 Nov 2022 01:20:54 +0000 (09:20 +0800)]
Support Intel CMPccXADD

gcc/ChangeLog:

* common/config/i386/cpuinfo.h (get_available_features):
Detect cmpccxadd.
* common/config/i386/i386-common.cc
(OPTION_MASK_ISA2_CMPCCXADD_SET,
OPTION_MASK_ISA2_CMPCCXADD_UNSET): New.
(ix86_handle_option): Handle -mcmpccxadd.
* common/config/i386/i386-cpuinfo.h (enum processor_features):
Add FEATURE_CMPCCXADD.
* common/config/i386/i386-isas.h: Add ISA_NAME_TABLE_ENTRY for
cmpccxadd.
* config.gcc: Add cmpccxaddintrin.h.
* config/i386/cpuid.h (bit_CMPCCXADD): New.
* config/i386/i386-builtin-types.def:
Add DEF_FUNCTION_TYPE(INT, PINT, INT, INT, INT)
and DEF_FUNCTION_TYPE(LONGLONG, PLONGLONG, LONGLONG, LONGLONG, INT).
* config/i386/i386-builtin.def (BDESC): Add new builtins.
* config/i386/i386-c.cc (ix86_target_macros_internal): Define
__CMPCCXADD__.
* config/i386/i386-expand.cc (ix86_expand_special_args_builtin):
Add new parameter to indicate constant position.
Handle INT_FTYPE_PINT_INT_INT_INT
and LONGLONG_FTYPE_PLONGLONG_LONGLONG_LONGLONG_INT.
* config/i386/i386-isa.def (CMPCCXADD): Add DEF_PTA(CMPCCXADD).
* config/i386/i386-options.cc (isa2_opts): Add -mcmpccxadd.
(ix86_valid_target_attribute_inner_p): Handle cmpccxadd.
* config/i386/i386.opt: Add option -mcmpccxadd.
* config/i386/sync.md (cmpccxadd_<mode>): New define insn.
* config/i386/x86gprintrin.h: Include cmpccxaddintrin.h.
* doc/extend.texi: Document cmpccxadd.
* doc/invoke.texi: Document -mcmpccxadd.
* doc/sourcebuild.texi: Document target cmpccxadd.
* config/i386/cmpccxaddintrin.h: New file.

gcc/testsuite/ChangeLog:

* g++.dg/other/i386-2.C: Add -mcmpccxadd.
* g++.dg/other/i386-3.C: Ditto.
* gcc.target/i386/avx-1.c: Ditto.
* gcc.target/i386/funcspec-56.inc: Add new target attribute.
* gcc.target/i386/sse-13.c: Add -mcmpccxadd.
* gcc.target/i386/sse-23.c: Ditto.
* gcc.target/i386/x86gprintrin-1.c: Ditto.
* gcc.target/i386/x86gprintrin-2.c: Ditto.
* gcc.target/i386/x86gprintrin-3.c: Ditto.
* gcc.target/i386/x86gprintrin-4.c: Ditto.
* gcc.target/i386/x86gprintrin-5.c: Ditto.
* lib/target-supports.exp (check_effective_target_cmpccxadd):
New.
* gcc.target/i386/cmpccxadd-1.c: New test.
* gcc.target/i386/cmpccxadd-2.c: Ditto.

2 years agoDaily bump.
GCC Administrator [Fri, 4 Nov 2022 00:17:58 +0000 (00:17 +0000)]
Daily bump.

2 years agoc++: Quash -Wdangling-reference for member operator* [PR107488]
Marek Polacek [Tue, 1 Nov 2022 21:05:52 +0000 (17:05 -0400)]
c++: Quash -Wdangling-reference for member operator* [PR107488]

-Wdangling-reference complains here:

  std::vector<int> v = ...;
  std::vector<int>::const_iterator it = v.begin();
  while (it != v.end()) {
    const int &r = *it++; // warning
  }

because it sees a call to
__gnu_cxx::__normal_iterator<const int*, std::vector<int> >::operator*
which returns a reference and its argument is a TARGET_EXPR representing
the result of
__gnu_cxx::__normal_iterator<const int*, std::vector<int> >::operator++
But 'r' above refers to one of the int elements of the vector 'v', not
to a temporary object.  Therefore the warning is a false positive.

I suppose code like the above is relatively common (the warning broke
cppunit-1.15.1 and a few other projects), so presumably it makes sense
to suppress the warning when it comes to member operator*.  In this case
it's defined as

      reference
      operator*() const _GLIBCXX_NOEXCEPT
      { return *_M_current; }

and I'm guessing a lot of member operator* are like that, at least when
it comes to iterators.  I've looked at _Fwd_list_iterator,
_Fwd_list_const_iterator, __shared_ptr_access, _Deque_iterator,
istream_iterator, etc, and they're all like that, so adding #pragmas
would be quite tedious.  :/

PR c++/107488

gcc/cp/ChangeLog:

* call.cc (do_warn_dangling_reference): Quash -Wdangling-reference
for member operator*.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wdangling-reference5.C: New test.

2 years agoc++: requires-expr and access checking [PR107179]
Patrick Palka [Thu, 3 Nov 2022 19:35:18 +0000 (15:35 -0400)]
c++: requires-expr and access checking [PR107179]

Like during satisfaction, we also need to avoid deferring access checks
during substitution of a requires-expr because the outcome of an access
check can determine the value of the requires-expr.  Otherwise (in
deferred access checking contexts such as within a base-clause), the
requires-expr may evaluate to the wrong result, and along the way a
failed access check may leak out from it into a non-SFINAE context and
cause a hard error (as in the below testcase).

PR c++/107179

gcc/cp/ChangeLog:

* constraint.cc (tsubst_requires_expr): Make sure we're not
deferring access checks.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-requires31.C: New test.

2 years agoAdd testcases resolved with ranger as VRP1.
Andrew MacLeod [Thu, 3 Nov 2022 17:07:33 +0000 (13:07 -0400)]
Add testcases resolved with ranger as VRP1.

gcc/testsuite/
* g++.dg/pr99966.C: New.
* gcc.dg/pr93917.c: New.
* gcc.dg/pr102650.c: New.

2 years agoc++: change -fconcepts to mean C++20 concepts
Jason Merrill [Thu, 3 Nov 2022 14:51:40 +0000 (10:51 -0400)]
c++: change -fconcepts to mean C++20 concepts

It was always weird that -fconcepts in C++17 mode meant the same thing as
-fconcepts-ts in C++20 mode; this patch harmonizes the flags so that for TS
concepts you always need to write -fconcepts-ts.

In the unlikely event anyone is still using -fconcepts in C++17 mode, they
can either fix their code to work with C++20 concepts or adjust the compiler
flag.

gcc/c-family/ChangeLog:

* c-opts.cc (c_common_post_options): -fconcepts no longer implies
-fconcepts-ts before C++20.

gcc/ChangeLog:

* doc/invoke.texi: -fconcepts no longer implies
-fconcepts-ts before C++20.

gcc/cp/ChangeLog:

* parser.cc (cp_parser_template_declaration_after_parameters): Fix
concept parsing below C++20.

gcc/testsuite/ChangeLog:

* g++.dg/concepts/auto1.C:
* g++.dg/concepts/auto3.C:
* g++.dg/concepts/auto4.C:
* g++.dg/concepts/class-deduction1.C:
* g++.dg/concepts/class5.C:
* g++.dg/concepts/class6.C:
* g++.dg/concepts/debug1.C:
* g++.dg/concepts/decl-diagnose.C:
* g++.dg/concepts/deduction-constraint1.C:
* g++.dg/concepts/diagnostic1.C:
* g++.dg/concepts/dr1430.C:
* g++.dg/concepts/equiv.C:
* g++.dg/concepts/equiv2.C:
* g++.dg/concepts/expression.C:
* g++.dg/concepts/expression2.C:
* g++.dg/concepts/expression3.C:
* g++.dg/concepts/fn-concept1.C:
* g++.dg/concepts/fn-concept2.C:
* g++.dg/concepts/fn-concept3.C:
* g++.dg/concepts/fn1.C:
* g++.dg/concepts/fn10.C:
* g++.dg/concepts/fn2.C:
* g++.dg/concepts/fn3.C:
* g++.dg/concepts/fn4.C:
* g++.dg/concepts/fn5.C:
* g++.dg/concepts/fn6.C:
* g++.dg/concepts/fn8.C:
* g++.dg/concepts/fn9.C:
* g++.dg/concepts/generic-fn-err.C:
* g++.dg/concepts/generic-fn.C:
* g++.dg/concepts/inherit-ctor1.C:
* g++.dg/concepts/inherit-ctor3.C:
* g++.dg/concepts/intro1.C:
* g++.dg/concepts/intro2.C:
* g++.dg/concepts/intro3.C:
* g++.dg/concepts/intro4.C:
* g++.dg/concepts/intro5.C:
* g++.dg/concepts/intro6.C:
* g++.dg/concepts/intro7.C:
* g++.dg/concepts/locations1.C:
* g++.dg/concepts/partial-concept-id1.C:
* g++.dg/concepts/partial-concept-id2.C:
* g++.dg/concepts/partial-spec5.C:
* g++.dg/concepts/placeholder2.C:
* g++.dg/concepts/placeholder3.C:
* g++.dg/concepts/placeholder4.C:
* g++.dg/concepts/placeholder5.C:
* g++.dg/concepts/placeholder6.C:
* g++.dg/concepts/pr65634.C:
* g++.dg/concepts/pr65636.C:
* g++.dg/concepts/pr65681.C:
* g++.dg/concepts/pr65848.C:
* g++.dg/concepts/pr67249.C:
* g++.dg/concepts/pr67595.C:
* g++.dg/concepts/pr68434.C:
* g++.dg/concepts/pr71127.C:
* g++.dg/concepts/pr71128.C:
* g++.dg/concepts/pr71131.C:
* g++.dg/concepts/pr71385.C:
* g++.dg/concepts/pr85065.C:
* g++.dg/concepts/template-parm11.C:
* g++.dg/concepts/template-parm12.C:
* g++.dg/concepts/template-parm2.C:
* g++.dg/concepts/template-parm3.C:
* g++.dg/concepts/template-parm4.C:
* g++.dg/concepts/template-template-parm1.C:
* g++.dg/concepts/var-concept1.C:
* g++.dg/concepts/var-concept2.C:
* g++.dg/concepts/var-concept3.C:
* g++.dg/concepts/var-concept4.C:
* g++.dg/concepts/var-concept5.C:
* g++.dg/concepts/var-concept6.C:
* g++.dg/concepts/var-concept7.C:
* g++.dg/concepts/var-templ2.C:
* g++.dg/concepts/var-templ3.C:
* g++.dg/concepts/variadic1.C:
* g++.dg/concepts/variadic2.C:
* g++.dg/concepts/variadic3.C:
* g++.dg/concepts/variadic4.C:
* g++.dg/cpp2a/concepts-pr65575.C:
* g++.dg/cpp2a/concepts-pr66091.C:
* g++.dg/cpp2a/concepts-pr84980.C:
* g++.dg/cpp2a/concepts-pr85265.C: Pass -fconcepts-ts.
* g++.dg/cpp2a/concepts-pr84979-2.C:
* g++.dg/cpp2a/concepts-pr84979-3.C: Same diagnostics
in C++20 and below.

2 years agoc++: constexpr error with defaulted virtual dtor [PR93413]
Patrick Palka [Thu, 3 Nov 2022 18:55:35 +0000 (14:55 -0400)]
c++: constexpr error with defaulted virtual dtor [PR93413]

We're rejecting the below testcase with

  error: 'virtual constexpr Base::~Base()' used before its definition
  error: 'virtual constexpr Derived::~Derived()' used before its definition

due to special handling in mark_used added by r181272 to defer synthesis
of virtual destructors until EOF (where we can set their linkage), which
in turn makes them effectively unusable during constexpr evaluation.

Fortunately it seems this special handling is unnecessary ever since
r208030 enabled us to tentatively set linkage of all defaulted virtual
destructors, including templated ones.  So this patch gets rid of this
special handling.

PR c++/93413

gcc/cp/ChangeLog:

* decl2.cc (mark_used): Don't defer synthesis of virtual
functions.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/constexpr-virtual21.C: New test.

2 years agoamdgcn: Fix instruction generation for exp2 and log2 operations
Kwok Cheung Yeung [Thu, 3 Nov 2022 17:19:11 +0000 (17:19 +0000)]
amdgcn: Fix instruction generation for exp2 and log2 operations

The GCN instructions for the exp2 and log2 operations are v_exp_* and v_log_*
respectively, which unfortunately do not line up with the RTL naming
convention.  To deal with this, a new set of int attributes is now used when
generating the assembly for these instructions.

2022-11-03  Kwok Cheung Yeung  <kcy@codesourcery.com>

gcc/
* config/gcn/gcn-valu.md (math_unop_insn): New attribute.
(<math_unop><mode>2, <math_unop><mode>2<exec>, <math_unop><mode>2,
<math_unop><mode>2<exec>, *<math_unop><mode>2_insn,
*<math_unop><mode>2<exec>_insn): Use math_unop_insn to generate
assembler output.

gcc/testsuite/
* gcc.target/gcn/unsafe-math-1.c: New.

2 years agoanalyzer: use std::unique_ptr for state machines from plugins
David Malcolm [Thu, 3 Nov 2022 17:47:02 +0000 (13:47 -0400)]
analyzer: use std::unique_ptr for state machines from plugins

gcc/analyzer/ChangeLog:
* analyzer.h: Use std::unique_ptr for state machines from plugins.
* engine.cc: Likewise.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/analyzer_gil_plugin.c: Use std::unique_ptr for
state machines from plugins.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoanalyzer: use std::unique_ptr for known functions
David Malcolm [Thu, 3 Nov 2022 17:47:02 +0000 (13:47 -0400)]
analyzer: use std::unique_ptr for known functions

gcc/analyzer/ChangeLog:
* analyzer.h: Use std::unique_ptr for known functions.
* engine.cc: Likewise.
* known-function-manager.cc: Likewise.
* known-function-manager.h: Likewise.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/analyzer_kernel_plugin.c: Use std::unique_ptr for
known functions.
* gcc.dg/plugin/analyzer_known_fns_plugin.c: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoanalyzer: use std::unique_ptr during bifurcation
David Malcolm [Thu, 3 Nov 2022 17:47:02 +0000 (13:47 -0400)]
analyzer: use std::unique_ptr during bifurcation

gcc/analyzer/ChangeLog:
* analysis-plan.cc: Define INCLUDE_MEMORY before including
system.h.
* analyzer-pass.cc: Likewise.
* analyzer-selftests.cc: Likewise.
* analyzer.cc: Likewise.
* analyzer.h: Use std::unique_ptr in bifurcation code.
* call-string.cc: Define INCLUDE_MEMORY before including system.h.
* complexity.cc: Likewise.
* engine.cc: Use std::unique_ptr in bifurcation code.
* exploded-graph.h: Likewise.
* known-function-manager.cc: Define INCLUDE_MEMORY before
including system.h.
* region-model-impl-calls.cc: Use std::unique_ptr in bifurcation
code.
* region-model.cc: Likewise.
* region-model.h: Likewise.
* supergraph.cc: Define INCLUDE_MEMORY before including system.h.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/analyzer_kernel_plugin.c: Include "make-unique.h".
Use std::unique_ptr in bifurcation code.
* gcc.dg/plugin/analyzer_known_fns_plugin.c: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoanalyzer: use std::unique_ptr for checker_event
David Malcolm [Thu, 3 Nov 2022 17:47:02 +0000 (13:47 -0400)]
analyzer: use std::unique_ptr for checker_event

gcc/analyzer/ChangeLog:
* call-info.cc: Use std::unique_ptr for checker_event.
* checker-path.cc: Likewise.
* checker-path.h: Likewise.
* diagnostic-manager.cc: Likewise.
* engine.cc: Likewise.
* pending-diagnostic.cc: Likewise.
* sm-signal.cc: Likewise.
* varargs.cc: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoanalyzer: use std::unique_ptr for feasibility_problems and exploded_path
David Malcolm [Thu, 3 Nov 2022 17:47:01 +0000 (13:47 -0400)]
analyzer: use std::unique_ptr for feasibility_problems and exploded_path

gcc/analyzer/ChangeLog:
* diagnostic-manager.cc: Include "make-unique.h".
Use std::unique_ptr for feasibility_problems and exploded_path.
Delete explicit saved_diagnostic dtor.
* diagnostic-manager.h: Likewise.
* engine.cc: Likewise.
* exploded-graph.h: Likewise.
* feasible-graph.cc: Likewise.
* feasible-graph.h: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoanalyzer: use std::unique_ptr for custom_edge_info pointers
David Malcolm [Thu, 3 Nov 2022 17:47:01 +0000 (13:47 -0400)]
analyzer: use std::unique_ptr for custom_edge_info pointers

gcc/analyzer/ChangeLog:
* checker-path.cc (rewind_event::rewind_event): Update for usage of
std::unique_ptr on custom_edge_info.
* engine.cc (exploded_node::on_longjmp): Likewise.
(exploded_edge::exploded_edge): Likewise.
(exploded_edge::~exploded_edge): Delete.
(exploded_graph::add_function_entry): Update for usage of
std::unique_ptr on custom_edge_info.
(exploded_graph::add_edge): Likewise.
(add_tainted_args_callback): Likewise.
(exploded_graph::maybe_create_dynamic_call): Likewise.
(exploded_graph::process_node): Likewise.
* exploded-graph.h (exploded_edge::~exploded_edge): Delete.
(exploded_edge::m_custom_info): Use std::unique_ptr.
(exploded_edge::add_edge): Likewise.
* sm-signal.cc (register_signal_handler::impl_transition): Use
make_unique.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoanalyzer: use std::unique_ptr for saved_diagnostic::m_stmt_finder
David Malcolm [Thu, 3 Nov 2022 17:47:01 +0000 (13:47 -0400)]
analyzer: use std::unique_ptr for saved_diagnostic::m_stmt_finder

gcc/analyzer/ChangeLog:
* diagnostic-manager.cc (saved_diagnostic::saved_diagnostic): Make
stmt_finder const.
(saved_diagnostic::~saved_diagnostic): Remove explicit delete of
m_stmt_finder.
(diagnostic_manager::add_diagnostic): Make stmt_finder const.
* diagnostic-manager.h (saved_diagnostic::saved_diagnostic):
Likewise.
(saved_diagnostic::m_stmt_finder): Convert to std::unique_ptr.
(diagnostic_manager::add_diagnostic): Make stmt_finder const.
* engine.cc (impl_sm_context::impl_sm_context): Likewise.
(impl_sm_context::m_stmt_finder): Likewise.
(leak_stmt_finder::clone): Convert return type to std::unique_ptr.
* exploded-graph.h (stmt_finder::clone): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoanalyzer: use std::unique_ptr for pending_diagnostic/note
David Malcolm [Thu, 3 Nov 2022 17:47:01 +0000 (13:47 -0400)]
analyzer: use std::unique_ptr for pending_diagnostic/note

gcc/analyzer/ChangeLog:
* call-info.cc: Add define of INCLUDE_MEMORY.
* call-summary.cc: Likewise.
* checker-path.cc: Likewise.
* constraint-manager.cc: Likewise.
* diagnostic-manager.cc: Likewise.
(saved_diagnostic::saved_diagnostic): Use std::unique_ptr for
param d and field m_d.
(saved_diagnostic::~saved_diagnostic): Remove explicit delete of m_d.
(saved_diagnostic::add_note): Use std::unique_ptr for
param pn.
(saved_diagnostic::get_pending_diagnostic): Update for conversion
of m_sd.m_d to unique_ptr.
(diagnostic_manager::add_diagnostic): Use std::unique_ptr for
param d.  Remove explicit deletion.
(diagnostic_manager::add_note): Use std::unique_ptr for param pn.
(diagnostic_manager::emit_saved_diagnostic): Update for conversion
of m_sd.m_d to unique_ptr.
(null_assignment_sm_context::warn): Use std::unique_ptr for
param d.  Remove explicit deletion.
* diagnostic-manager.h (saved_diagnostic::saved_diagnostic): Use
std::unique_ptr for param d.
(saved_diagnostic::add_note): Likewise for param pn.
(saved_diagnostic::m_d): Likewise.
(diagnostic_manager::add_diagnostic): Use std::unique_ptr for
param d.
(diagnostic_manager::add_note): Use std::unique_ptr for param pn.
* engine.cc: Include "make-unique.h".
(impl_region_model_context::warn): Update to use std::unique_ptr
for param, removing explicit deletion.
(impl_region_model_context::add_note): Likewise.
(impl_sm_context::warn): Update to use std::unique_ptr
for param.
(impl_region_model_context::on_state_leak): Likewise for result of
on_leak.
(exploded_node::on_longjmp): Use make_unique when creating
pending_diagnostic.
(exploded_graph::process_node): Likewise.
* exploded-graph.h (impl_region_model_context::warn): Update to
use std::unique_ptr for param.
(impl_region_model_context::add_note): Likewise.
* feasible-graph.cc: Add define of INCLUDE_MEMORY.
* pending-diagnostic.cc: Likewise.
* pending-diagnostic.h: Include analyzer.sm.h"
* program-point.cc: Add define of INCLUDE_MEMORY.
* program-state.cc: Likewise.
* region-model-asm.cc: Likewise.
* region-model-impl-calls.cc: Likewise.  Include "make-unique.h".
(region_model::impl_call_putenv): Use make_unique when creating
pending_diagnostic.
* region-model-manager.cc: Add define of INCLUDE_MEMORY.
* region-model-reachability.cc: Likewise.
* region-model.cc: Likewise.  Include "make-unique.h".
(region_model::get_gassign_result): Use make_unique when creating
pending_diagnostic.
(region_model::check_for_poison): Likewise.
(region_model::on_stmt_pre): Likewise.
(region_model::check_symbolic_bounds): Likewise.
(region_model::check_region_bounds): Likewise.
(annotating_ctxt: make_note): Use std::unique_ptr for result.
(region_model::deref_rvalue): Use make_unique when creating
pending_diagnostic.
(region_model::check_for_writable_region): Likewise.
(region_model::check_region_size): Likewise.
(region_model::check_dynamic_size_for_floats): Likewise.
(region_model::maybe_complain_about_infoleak): Likewise.
(noop_region_model_context::add_note): Use std::unique_ptr for
param.  Remove explicit deletion.
* region-model.h: Include "analyzer/pending-diagnostic.h".
(region_model_context::warn): Convert param to std::unique_ptr.
(region_model_context::add_note): Likewise.
(noop_region_model_context::warn): Likewise.
(noop_region_model_context::add_note): Likewise.
(region_model_context_decorator::warn): Likewise.
(region_model_context_decorator::add_note): Likewise.
(note_adding_context::warn): Likewise.
(note_adding_context::make_note): Likewise for return type.
(test_region_model_context::warn): Convert param to
std::unique_ptr.
* region.cc: Add define of INCLUDE_MEMORY.
* sm-fd.cc: Likewise.  Include "make-unique.h".
(fd_state_machine::check_for_fd_attrs): Use make_unique when
creating pending_diagnostics.
(fd_state_machine::on_open): Likewise.
(fd_state_machine::on_creat): Likewise.
(fd_state_machine::check_for_dup): Likewise.
(fd_state_machine::on_close): Likewise.
(fd_state_machine::check_for_open_fd): Likewise.
(fd_state_machine::on_leak): Likewise, converting return type to
std::unique_ptr.
* sm-file.cc: Add define of INCLUDE_MEMORY.  Include
"make-unique.h".
(fileptr_state_machine::on_stmt): Use make_unique when creating
pending_diagnostic.
(fileptr_state_machine::on_leak): Likewise, converting return type
to std::unique_ptr.
* sm-malloc.cc: Add define of INCLUDE_MEMORY.  Include
"make-unique.h".
(malloc_state_machine::on_stmt): Use make_unique when creating
pending_diagnostic.
(malloc_state_machine::handle_free_of_non_heap): Likewise.
(malloc_state_machine::on_deallocator_call): Likewise.
(malloc_state_machine::on_realloc_call): Likewise.
(malloc_state_machine::on_leak): Likewise, converting return type
to std::unique_ptr.
* sm-pattern-test.cc: Add define of INCLUDE_MEMORY.  Include
"make-unique.h".
(pattern_test_state_machine::on_condition): Use make_unique when
creating pending_diagnostic.
* sm-sensitive.cc: Add define of INCLUDE_MEMORY.  Include
"make-unique.h".
(sensitive_state_machine::warn_for_any_exposure): Use make_unique
when creating pending_diagnostic.
* sm-signal.cc: Add define of INCLUDE_MEMORY.  Include
"make-unique.h".
(signal_state_machine::on_stmt): Use make_unique when creating
pending_diagnostic.
* sm-taint.cc: Add define of INCLUDE_MEMORY.  Include
"make-unique.h".
(taint_state_machine::check_for_tainted_size_arg): Use make_unique
when creating pending_diagnostic.
(taint_state_machine::check_for_tainted_divisor): Likewise.
(region_model::check_region_for_taint): Likewise.
(region_model::check_dynamic_size_for_taint): Likewise.
* sm.cc: Add define of INCLUDE_MEMORY.  Include
"analyzer/pending-diagnostic.h".
(state_machine::on_leak): Move here from sm.h, changing return
type to std::unique_ptr.
* sm.h (state_machine::on_leak): Change return type to
std::unique_ptr.  Move defn of base impl to sm.cc
(sm_context::warn): Convert param d to std_unique_ptr.
* state-purge.cc: Add define of INCLUDE_MEMORY.
* store.cc: Likewise.
* svalue.cc: Likewise.
* trimmed-graph.cc: Likewise.
* varargs.cc: Likewise.  Include "make-unique.h".
(va_list_state_machine::check_for_ended_va_list): Use make_unique
when creating pending_diagnostic.
(va_list_state_machine::on_leak): Likewise, converting return type
to std::unique_ptr.
(region_model::impl_call_va_arg): Use make_unique when creating
pending_diagnostic.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/analyzer_gil_plugin.c: Add define of
INCLUDE_MEMORY.  Include "make-unique.h".
(gil_state_machine::check_for_pyobject_in_call): Use make_unique
when creating pending_diagnostic.
(gil_state_machine::on_stmt): Likewise.
(gil_state_machine::check_for_pyobject_usage_without_gil): Likewise.
* gcc.dg/plugin/analyzer_kernel_plugin.c: : Add define of
INCLUDE_MEMORY.
* gcc.dg/plugin/analyzer_known_fns_plugin.c: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoUpdate range query cache when a statement is updated.
Andrew MacLeod [Thu, 3 Nov 2022 01:37:49 +0000 (21:37 -0400)]
Update range query cache when a statement is updated.

Add an update_stmt interface to range query, and hook into it with the
ssa statement update call.

gcc/
* gimple-range.cc (gimple_ranger::update_stmt): New.
* gimple-range.h (gimple_ranger::update_stmt): New prototype.
* tree-ssa-operands.cc (update_stmt_operands): Notify range
query that stmt has changed.
* value-query.h (range_query::update_stmt): New.

gcc/testsuite/
* gcc.dg/tree-ssa/vrp-update.c: New.

2 years agoAdd gcc/make-unique.h
David Malcolm [Thu, 3 Nov 2022 14:22:47 +0000 (10:22 -0400)]
Add gcc/make-unique.h

This patch adds gcc/make-unique.h, containing a minimal C++11
implementation of make_unique (std::make_unique is C++14).

gcc/ChangeLog:
* make-unique.h: New file.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoanalyzer: fix ICE when pipe's arg isn't a pointer [PR107486]
David Malcolm [Thu, 3 Nov 2022 14:21:00 +0000 (10:21 -0400)]
analyzer: fix ICE when pipe's arg isn't a pointer [PR107486]

gcc/analyzer/ChangeLog:
PR analyzer/107486
* analyzer.cc (is_pipe_call_p): New.
* analyzer.h (is_pipe_call_p): New decl.
* region-model.cc (region_model::on_call_pre): Use it.
(region_model::on_call_post): Likewise.

gcc/testsuite/ChangeLog:
PR analyzer/107486
* gcc.dg/analyzer/pipe-pr107486.c: New test.
* gcc.dg/analyzer/pipe-void-return.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoOpenMP/Fortran: 'target update' with DT components
Tobias Burnus [Thu, 3 Nov 2022 14:03:52 +0000 (15:03 +0100)]
OpenMP/Fortran: 'target update' with DT components

OpenMP 5.0 permits to use arrays with derived type components for the list
items to the 'from'/'to' clauses of the 'target update' directive.

gcc/fortran/ChangeLog:

* openmp.cc (gfc_match_omp_clauses): Permit derived types for
the 'to' and 'from' clauses of 'target update'.
* trans-openmp.cc (gfc_trans_omp_clauses): Fixes for
derived-type changes; fix size for scalars.

libgomp/ChangeLog:

* testsuite/libgomp.fortran/target-11.f90: New test.
* testsuite/libgomp.fortran/target-13.f90: New test.

2 years agoi386: Fix uninitialized register after peephole2 conversion [PR107404]
Uros Bizjak [Thu, 3 Nov 2022 13:17:42 +0000 (14:17 +0100)]
i386: Fix uninitialized register after peephole2 conversion [PR107404]

The eliminate reg-reg move by inverting the condition of
a cmove #2 peephole2 converts the following sequence:

  473: bx:DI=[r14:DI*0x8+r12:DI]
  960: r15:DI=r8:DI
  485: {flags:CCC=cmp(r15:DI+bx:DI,bx:DI);r15:DI=r15:DI+bx:DI;}
  737: r15:DI={(geu(flags:CCC,0))?r15:DI:bx:DI}

to:

 1110: {flags:CCC=cmp(r8:DI+bx:DI,bx:DI);r8:DI=r8:DI+bx:DI;}
 1111: r15:DI=[r14:DI*0x8+r12:DI]
 1112: r15:DI={(geu(flags:CCC,0))?r8:DI:r15:DI}

Please note that(insn 1110) uses register BX, but its
initialization was eliminated.

Avoid conversion if eliminated move intialized a register, used
in the moved instruction.

2022-11-03  UroÅ¡ Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog:

PR target/107404
* config/i386/i386.md (eliminate reg-reg move by inverting the
condition of a cmove #2 peephole2): Check if eliminated move
initialized a register, used in the moved instruction.

gcc/testsuite/ChangeLog:

PR target/107404
* g++.target/i386/pr107404.C: New test.

2 years agolibstdc++: Add missing move in ranges::copy
Jonathan Wakely [Thu, 3 Nov 2022 09:17:57 +0000 (09:17 +0000)]
libstdc++: Add missing move in ranges::copy

This is needed to support a move-only output iterator when the input
iterators are specializations of __normal_iterator.

libstdc++-v3/ChangeLog:

* include/bits/ranges_algobase.h (__detail::__copy_or_move):
Move output iterator.
* testsuite/25_algorithms/copy/constrained.cc: Check copying to
move-only output iterator.

2 years agoamdgcn: Fix duplicate conditionals [PR107510]
Andrew Stubbs [Thu, 3 Nov 2022 09:55:41 +0000 (09:55 +0000)]
amdgcn: Fix duplicate conditionals [PR107510]

Just a harmless cut-and-paste issue.

PR target/107510

gcc/ChangeLog:

* config/gcn/gcn.cc (gcn_expand_reduc_scalar): Remove duplicate
UNSPEC_SMIN_DPP_SHR conditionals.

2 years agotestsuite: Fix gen-vect-34.c with vect_masked_load [PR106806]
Kewen Lin [Thu, 3 Nov 2022 06:22:45 +0000 (01:22 -0500)]
testsuite: Fix gen-vect-34.c with vect_masked_load [PR106806]

This is to fix the failure on powerpc as reported in PR106806,
the test case requires tree ifcvt pass to perform on that loop,
and it relies on masked_load support.  The fix is to guard the
expected scan with vect_masked_load effective target.

As tested on powerpc64{,le}-linux-gnu and aarch64-linux-gnu
(cfarm machine), the failures were gone.  But on
x86_64-redhat-linux (cfarm machine) the result becomes from
PASS to N/A.  I think it's expected since that machine doesn't
support AVX by default so both check_avx_available and
vect_masked_load fail, it should work fine on machines with
default AVX support, or if we adjust the current
check_avx_available with current_compiler_flags.

PR testsuite/106806

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/gen-vect-34.c: Adjust with vect_masked_load
effective target.

2 years agoc: C2x auto
Joseph Myers [Thu, 3 Nov 2022 02:53:41 +0000 (02:53 +0000)]
c: C2x auto

Implement C2x auto, a more restricted version of the C++ feature
(closer to GNU C __auto_type in terms of what's supported).

Since the feature is very close to GNU C __auto_type, much of the
implementation can be shared.  The main differences are:

* Any prior declaration of the identifier in an outer scope is
  shadowed during the initializer (whereas __auto_type leaves any such
  declaration visible until the initializer ends and the scope of the
  __auto_type declaration itself starts).  (A prior declaration in the
  same scope is undefined behavior.)

* The standard feature supports braced initializers (containing a
  single expression, optionally followed by a comma).

* The standard feature disallows the declaration from declaring
  anything that's not an ordinary identifier (thus, the initializer
  cannot declare a tag or the members of a structure or union), while
  making it undefined behavior for it to declare more than one
  ordinary identifier.  (For the latter, while I keep the existing
  error from __auto_type in the case of more than one declarator, I
  don't restrict other ordinary identifiers from being declared in
  inner scopes such as GNU statement expressions.  I do however
  disallow defining the members of an enumeration inside the
  initializer (if the enum definition has no tag, that doesn't
  actually violate a constraint), to avoid an enum type becoming
  accessible beyond where it would have been without auto.
  (Preventing new types from escaping the initializer - thus, ensuring
  that anything written with auto corresponds to something that could
  have been written without auto, modulo multiple evaluation of VLA
  size expressions when not using auto - is a key motivation for some
  restrictions on what can be declared in the initializer.)

The rule on shadowing and restrictions on other declarations in the
initializer are actually general rules for what C2x calls
underspecified declarations, a description that covers constexpr as
well as auto (in particular, this disallows a constexpr initializer
from referencing the variable being initialized).  Thus, some of the
code added for those restrictions will also be of use in implementing
C2x constexpr.

auto with a type specifier remains a storage class specifier with the
same meaning as before (i.e. a redundant storage class specifier for
use at block scope).

Note that the feature is only enabled in C2x mode (-std=c2x or
-std=gnu2x); in older modes, a declaration with auto and no type is
treated as a case of implicit int (only accepted at block scope).

Since many of the restrictions on C2x auto are specified as undefined
behavior rather than constraint violations, it would be possible to
support more features from C++ auto without requiring diagnostics (but
maybe not a good idea, if it isn't clear exactly what semantics might
be given to such a feature in a future revision of C; and
-Wc23-c2y-compat should arguably warn for any such future feature
anyway).  For now the features are limited to something close to
what's supported with __auto_type, with the differences as discussed
above between the two features.

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

gcc/c/
* c-decl.cc (in_underspecified_init, start_underspecified_init)
(finish_underspecified_init): New.
(shadow_tag_warned, parser_xref_tag, start_struct, start_enum):
Give errors inside initializers of underspecified declarations.
(grokdeclarator): Handle (erroneous) case of C2X auto on a
parameter.
(declspecs_add_type): Handle c2x_auto_p case.
(declspecs_add_scspec): Handle auto possibly setting c2x_auto_p in
C2X mode.
(finish_declspecs): Handle c2x_auto_p.
* c-parser.cc (c_parser_declaration_or_fndef): Handle C2X auto.
* c-tree.h (C_DECL_UNDERSPECIFIED): New macro.
(struct c_declspecs): Add c2x_auto_p.
(start_underspecified_init, finish_underspecified_init): New
prototypes.
* c-typeck.cc (build_external_ref): Give error for underspecified
declaration referenced in its initializer.

gcc/testsuite/
* gcc.dg/c2x-auto-1.c, gcc.dg/c2x-auto-2.c, gcc.dg/c2x-auto-3.c,
gcc.dg/c2x-auto-4.c, gcc.dg/gnu2x-auto-1.c: New tests.

2 years agoDaily bump.
GCC Administrator [Thu, 3 Nov 2022 00:17:32 +0000 (00:17 +0000)]
Daily bump.

2 years agolibstdc++: Remove more redundant union members
Jonathan Wakely [Wed, 2 Nov 2022 12:52:34 +0000 (12:52 +0000)]
libstdc++: Remove more redundant union members

We don't need these 'unused' members because they're never used, and a
union with a single variant member is fine.

libstdc++-v3/ChangeLog:

* libsupc++/eh_globals.cc (constant_init::unused): Remove.
* src/c++11/system_error.cc (constant_init::unused): Remove.
* src/c++17/memory_resource.cc (constant_init::unused): Remove.

2 years agoSupport OpenACC 'declare create' with Fortran allocatable arrays, part II [PR106643...
Thomas Schwinge [Fri, 28 Oct 2022 13:06:45 +0000 (15:06 +0200)]
Support OpenACC 'declare create' with Fortran allocatable arrays, part II [PR106643, PR96668]

PR libgomp/106643
PR fortran/96668
libgomp/
* oacc-mem.c (goacc_enter_data_internal): Support
OpenACC 'declare create' with Fortran allocatable arrays, part II.
* testsuite/libgomp.oacc-fortran/declare-allocatable-array_descriptor-1-directive.f90:
Adjust.
* testsuite/libgomp.oacc-fortran/pr106643-1.f90: New.

2 years agoSupport OpenACC 'declare create' with Fortran allocatable arrays, part I [PR106643]
Thomas Schwinge [Thu, 27 Oct 2022 19:52:07 +0000 (21:52 +0200)]
Support OpenACC 'declare create' with Fortran allocatable arrays, part I [PR106643]

PR libgomp/106643
libgomp/
* oacc-mem.c (goacc_enter_data_internal): Support
OpenACC 'declare create' with Fortran allocatable arrays, part I.
* testsuite/libgomp.oacc-fortran/declare-allocatable-1-directive.f90:
New.
* testsuite/libgomp.oacc-fortran/declare-allocatable-array_descriptor-1-directive.f90:
New.

2 years agoAdd 'libgomp.oacc-fortran/declare-allocatable-array_descriptor-1-runtime.f90'
Thomas Schwinge [Wed, 26 Oct 2022 21:47:29 +0000 (23:47 +0200)]
Add 'libgomp.oacc-fortran/declare-allocatable-array_descriptor-1-runtime.f90'

libgomp/
* testsuite/libgomp.oacc-fortran/declare-allocatable-array_descriptor-1-runtime.f90:
New.

2 years agoAdd 'libgomp.oacc-fortran/declare-allocatable-1-runtime.f90'
Thomas Schwinge [Fri, 14 Oct 2022 15:36:51 +0000 (17:36 +0200)]
Add 'libgomp.oacc-fortran/declare-allocatable-1-runtime.f90'

... which is 'libgomp.oacc-fortran/declare-allocatable-1.f90' adjusted
for missing support for OpenACC "Changes from Version 2.0 to 2.5":
"The 'declare create' directive with a Fortran 'allocatable' has new behavior".
Thus, after 'allocate'/before 'deallocate', call 'acc_create'/'acc_delete'
manually.

libgomp/
* testsuite/libgomp.oacc-fortran/declare-allocatable-1-runtime.f90:
New.

2 years agoAdd 'libgomp.oacc-fortran/declare-allocatable-1.f90'
Cesar Philippidis [Wed, 5 Apr 2017 15:23:58 +0000 (08:23 -0700)]
Add 'libgomp.oacc-fortran/declare-allocatable-1.f90'

libgomp/
* testsuite/libgomp.oacc-fortran/declare-allocatable-1.f90: New.

Co-authored-by: Thomas Schwinge <thomas@codesourcery.com>
2 years agoRISC-V: Add Zawrs ISA extension support
Christoph Müllner [Thu, 27 Oct 2022 18:42:30 +0000 (20:42 +0200)]
RISC-V: Add Zawrs ISA extension support

This patch adds support for the Zawrs ISA extension.
Zawrs has been ratified by the RISC-V BoD on Oct 20th, 2022.

Binutils support has been merged as:
  https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=eb668e50036e979fb0a74821df4eee0307b44e66

gcc/ChangeLog:

* common/config/riscv/riscv-common.cc: Add zawrs extension.
* config/riscv/riscv-opts.h (MASK_ZAWRS): New.
(TARGET_ZAWRS): New.
* config/riscv/riscv.opt: New.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
2 years agogcc: honour -ffile-prefix-map in ASM_MAP [PR93371]
Rasmus Villemoes [Wed, 2 Nov 2022 16:01:22 +0000 (10:01 -0600)]
gcc: honour -ffile-prefix-map in ASM_MAP [PR93371]

-ffile-prefix-map is supposed to be a superset of -fmacro-prefix-map
and -fdebug-prefix-map. However, when building .S or .s files, gas is
not called with the appropriate --debug-prefix-map option when
-ffile-prefix-map is used.

While the user can specify -fdebug-prefix-map when building assembly
files via gcc, it's more ergonomic to also support -ffile-prefix-map;
especially since for .S files that could contain the __FILE__ macro,
one would then also have to specify -fmacro-prefix-map.

gcc:
PR driver/93371
* gcc.cc (ASM_MAP): Honour -ffile-prefix-map.

2 years agoFix bug in frange::contains_p() for signed zeros.
Aldy Hernandez [Wed, 2 Nov 2022 11:39:45 +0000 (12:39 +0100)]
Fix bug in frange::contains_p() for signed zeros.

The contains_p() code wasn't returning true for non-singleton ranges
containing signed zeros.  With this patch we now handle:

-0.0 exists in [-3, +5.0]
+0.0 exists in [-3, +5.0]

gcc/ChangeLog:

* value-range.cc (frange::contains_p): Fix signed zero handling.
(range_tests_signed_zeros): New test.

2 years agolibstdc++: Improve ERANGE behavior for fallback FP std::from_chars
Patrick Palka [Wed, 2 Nov 2022 12:56:59 +0000 (08:56 -0400)]
libstdc++: Improve ERANGE behavior for fallback FP std::from_chars

The fallback implementation of floating-point std::from_chars (used for
formats other than binary32/64) just calls the C library's strtod family
of functions.  In case of overflow, the behavior of these functions is
rigidly specified:

  If the correct value overflows and default rounding is in effect, plus
  or minus HUGE_VAL, HUGE_VALF, or HUGE_VALL is returned (according to
  the return type and sign of the value), and the value of the macro
  ERANGE is stored in errno.

But in case of underflow, implementations are given more leeway:

  If the result underflows the functions return a value whose magnitude
  is no greater than the smallest normalized positive number in the
  return type; whether errno acquires the value ERANGE is
  implementation-defined.

Thus the fallback implementation can (and does) portably detect overflow,
but it can't portably detect underflow.  However, glibc (and presumably
other high-quality C library implementations) will reliably set errno to
ERANGE in case of underflow as well, and it'll also return the nearest
denormal number to the correct value (zero in case of true underflow),
which allows callers to succesfully parse denormal numbers.

So since we can't be perfect here, this patch takes the best effort
approach of assuming a high quality C library implementation with
respect to this underflow behavior, and refines our implementation
to try to distiguish between a denormal result and true underflow
by inspecting strtod's return value.

libstdc++-v3/ChangeLog:

* src/c++17/floating_from_chars.cc (from_chars_impl): In the
ERANGE case, distinguish between a denormal result and true
underflow by checking if the return value is 0.

2 years agolibstdc++: Remove unnecessary variant member in std::expected
Jonathan Wakely [Tue, 1 Nov 2022 13:47:24 +0000 (13:47 +0000)]
libstdc++: Remove unnecessary variant member in std::expected

Hui Xie pointed out that we don't need a dummy member in the union,
because all constructors always initialize either _M_val or _M_unex.

We still need the _M_void member of the expected<void, E>
specialization, because the constructor has to initialize something when
not using the _M_unex member.

libstdc++-v3/ChangeLog:

* include/std/expected (expected::_M_invalid): Remove.

2 years agolibstdc++: Ignore -Wignored-qualifiers warning in <variant>
Jonathan Wakely [Tue, 1 Nov 2022 11:17:35 +0000 (11:17 +0000)]
libstdc++: Ignore -Wignored-qualifiers warning in <variant>

The warning is wrong here, the qualifier serves a purpose and is not
ignored (c.f. PR c++/107492).

libstdc++-v3/ChangeLog:

* include/std/variant (__variant::_Multi_array::__untag_result):
Use pragma to suppress warning.

2 years agolibstdc++: _Bfloat16 for <compare>
Jakub Jelinek [Wed, 2 Nov 2022 12:35:53 +0000 (13:35 +0100)]
libstdc++: _Bfloat16 for <compare>

Jon pointed out that we have TODO: _Bfloat16 in <compare>.
Right now _S_fp_fmt() returns _Binary16 for _Float16, __fp16 as well
as __bf16 and it actually works because we don't have a special handling
of _Binary16.  So, either we could just document that, but I'm a little bit
afraid if HPPA or MIPS don't start supporting _Float16 and/or __bf16.
If they do, we have the
 #if defined __hppa__ || (defined __mips__ && !defined __mips_nan2008)
                  // IEEE 754-1985 allowed the meaning of the quiet/signaling
                  // bit to be reversed. Flip that to give desired ordering.
                  if (__builtin_isnan(__x) && __builtin_isnan(__y))
                    {
                      using _Int = decltype(__ix);

                      constexpr int __nantype = __fmt == _Binary32  ?  22
                                              : __fmt == _Binary64  ?  51
                                              : __fmt == _Binary128 ? 111
                                              : -1;
                      constexpr _Int __bit = _Int(1) << __nantype;
                      __ix ^= __bit;
                      __iy ^= __bit;
                    }
 #endif
code, the only one where we actually care whether something is
_Binary{32,64,128} (elsewhere we just care about the x86 and m68k 80bits
or double double or just floating point type's sizeof) and we'd need
to handle there _Binary16 and/or _Bfloat16.

So this patch uses different enum for it even when it isn't needed right
now, after all _Binary16 isn't needed either and we could just use
_Binary32...

2022-11-02  Jakub Jelinek  <jakub@redhat.com>

* libsupc++/compare (_Strong_order::_Fp_fmt): Add _Bfloat16.
(_Strong_order::_Bfloat16): New static data member.
(_Strong_order::_S_fp_fmt): Return _Bfloat16 for std::bfloat16_t.

2 years agobuiltins: Guard builtins.cc against HUGE_VAL and NAN definitions
Rainer Orth [Wed, 2 Nov 2022 09:52:59 +0000 (10:52 +0100)]
builtins: Guard builtins.cc against HUGE_VAL and NAN definitions

trunk bootstrap recently broke on Solaris like this:

/vol/gcc/src/hg/master/local/gcc/builtins.cc:2104:8: error: pasting
"CFN_BUILT_IN_" and "(" does not give a valid preprocessing token
 2104 |   case CFN_BUILT_IN_##MATHFN:   \
      |        ^~~~~~~~~~~~~
/vol/gcc/src/hg/master/local/gcc/builtins.cc:2112:3: note: in expansion of
macro 'CASE_MATHFN'
 2112 |   CASE_MATHFN(MATHFN)    \
      |   ^~~~~~~~~~~
/vol/gcc/src/hg/master/local/gcc/builtins.cc:1967:5: note: in expansion of macro 'CASE_MATHFN_FLOATN'
 1967 |     CASE_MATHFN_FLOATN (HUGE_VAL)  \

and similarly for NAN.

It turns out this happens because <math.h> is included at some point,
which (in <iso/math_c99.h>) defines

While this only happpens on Solaris right now, the same issue would be
present on other targets when <math.h> gets included somehow.

To avoid this, this patch #undef's both macros.

Bootstrapped without regressions on i386-pc-solaris2.11 and
sparc-sun-solaris2.11.

2022-11-01  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc:
* builtins.cc (mathfn_built_in_2): #undef HUGE_VAL, NAN.

2 years agolibstdc++: Shortest denormal hex std::to_chars
Jakub Jelinek [Wed, 2 Nov 2022 09:06:24 +0000 (10:06 +0100)]
libstdc++: Shortest denormal hex std::to_chars

On Fri, Oct 28, 2022 at 12:52:44PM -0400, Patrick Palka wrote:
> > The following patch on top of
> > https://gcc.gnu.org/pipermail/libstdc++/2022-October/054849.html
> > adds std::{,b}float16_t support for std::to_chars.
> > When precision is specified (or for std::bfloat16_t for hex mode even if not),
> > I believe we can just use the std::to_chars float (when float is mode
> > compatible with std::float32_t) overloads, both formats are proper subsets
> > of std::float32_t.
> > Unfortunately when precision is not specified and we are supposed to emit
> > shortest string, the std::{,b}float16_t strings are usually much shorter.
> > E.g. 1.e7p-14f16 shortest fixed representation is
> > 0.0001161 and shortest scientific representation is
> > 1.161e-04 while 1.e7p-14f32 (same number promoted to std::float32_t)
> > 0.00011610985 and
> > 1.1610985e-04.
> > Similarly for 1.38p-112bf16,
> > 0.000000000000000000000000000000000235
> > 2.35e-34 vs. 1.38p-112f32
> > 0.00000000000000000000000000000000023472271
> > 2.3472271e-34
> > For std::float16_t there are differences even in the shortest hex, say:
> > 0.01p-14 vs. 1p-22
> > but only for denormal std::float16_t values (where all std::float16_t
> > denormals converted to std::float32_t are normal), __FLT16_MIN__ and
> > everything larger in absolute value than that is the same.  Unless
> > that is a bug and we should try to discover shorter representations
> > even for denormals...
>
> IIRC for hex formatting of denormals I opted to be consistent with how
> glibc printf formats them, instead of outputting the truly shortest
> form.
>
> I wouldn't be against using the float32 overloads even for shortest hex
> formatting of float16.  The output is shorter but equivalent so it
> shouldn't cause any problems.

The following patch changes the behavior of the shortest hex denormals,
such that they are printed like normals (so for has_implicit_leading_bit
with 1p-149 instead of 0.000002p-126 etc., otherwise (Intel extended)
with the leading digit before dot being [89abcdef]).  I think for all the
supported format it is never longer, it can be equal length e.g. for
0.fffffep-126 vs. 1.fffffcp-127 but fortunately no largest subnormal
in any format has the unbiased exponent like -9, -99, -999, -9999 because
then it would be longer and often it is shorter, sometimes much shorter.

For the cases with precision it keeps the handling as is.

While for !has_implicit_leading_bit we for normals or with this patch
even denormals have really shortest representation, for other formats
we sometimes do not, but this patch doesn't deal with that (we
always use 1.NNN while we could use 1.NNN up to f.NNN and by that shortening
by the last hexit if the last hexit doesn't have least significant bit set
and unbiased exponent is not -9, -99, -999 or -9999.

2022-11-02  Jakub Jelinek  <jakub@redhat.com>

* src/c++17/floating_to_chars.cc (__floating_to_chars_hex): Drop const
from unbiased_exponent.  Canonicalize denormals such that they have
the leading bit set by shifting effective mantissa up and decreasing
unbiased_exponent.
(__floating_to_chars_shortest): Don't instantiate
__floating_to_chars_hex for float16_t either and use float instead.
* testsuite/20_util/to_chars/float.cc (float_to_chars_test_cases):
Adjust testcases for shortest hex denormals.
* testsuite/20_util/to_chars/double.cc (double_to_chars_test_cases):
Likewise.

2 years agors6000: Byte reverse V8HI on Power8 by vector rotation.
Xionghu Luo [Wed, 12 Oct 2022 02:43:38 +0000 (10:43 +0800)]
rs6000: Byte reverse V8HI on Power8 by vector rotation.

gcc/
PR target/100866
* config/rs6000/altivec.md: (*altivec_vrl<VI_char>): Named to...
(altivec_vrl<VI_char>): ...this.
* config/rs6000/vsx.md (revb_<mode>): Call vspltish and vrlh when
target is Power8 and mode is V8HI.

gcc/testsuite/
PR target/100866
* gcc.target/powerpc/pr100866-2.c: New.

2 years agoDaily bump.
GCC Administrator [Wed, 2 Nov 2022 00:17:38 +0000 (00:17 +0000)]
Daily bump.

2 years agoc++: per-scope, per-signature lambda discriminators
Nathan Sidwell [Mon, 31 Oct 2022 10:11:28 +0000 (06:11 -0400)]
c++: per-scope, per-signature lambda discriminators

This implements ABI-compliant lambda discriminators.  Not only do we
have per-scope counters, but we also distinguish by lambda signature.
Only lambdas with the same signature will need non-zero
discriminators.  As the discriminator is signature-dependent, we have
to process the lambda function's declaration before we can determine
it.  For templated and generic lambdas the signature is that of the
uninstantiated lambda -- not separate for each instantiation.

With this change, gcc and clang now produce the same lambda manglings
for all these testcases.

gcc/cp/
* cp-tree.h (LAMBDA_EXPR_SCOPE_SIG_DISCRIMINATOR): New.
(struct tree_lambda_expr): Add discriminator_sig bitfield.
(recrd_lambda_scope_sig_discriminator): Declare.
* lambda.cc (struct lambda_sig_count): New.
(lambda_discriminator): Add signature vector.
(start_lambda_scope): Adjust.
(compare_lambda_template_head, compare_lambda_sig): New.
(record_lambda_scope_sig_discriminator): New.
* mangle.cc (write_closure_type): Use the scope-sig discriminator for
ABI >= 18.  Emit abi mangling warning if needed.
* module.cc (trees_out::core_vals): Stream the new discriminator.
(trees_in::core_vals): Likewise.
* parser.cc (cp_parser_lambda_declarator_opt): Call
record_lambda_scope_sig_discriminator.
* pt.cc (tsubst_lambda_expr): Likewise.
libcc1/
* libcp1plugin.cc (plugin_start_lambda_closure_class_type):
Initialize the per-scope, per-signature discriminator.
gcc/testsuite/
* g++.dg/abi/lambda-sig1-18.C: New.
* g++.dg/abi/lambda-sig1-18vs17.C: New.
* g++.dg/cpp1y/lambda-mangle-1-18.C: New.

2 years agoconfigure: cache result of "sys/sdt.h" header check
David Seifert [Tue, 1 Nov 2022 20:27:53 +0000 (14:27 -0600)]
configure: cache result of "sys/sdt.h" header check

Use AC_CACHE_CHECK to store the result of the header check for
systemtap's "sys/sdt.h", which is similar in spirit to libstdc++'s
AC_CACHE_CHECK(..., glibcxx_cv_sys_sdt_h).

gcc/
* configure.ac: Add AC_CACHE_CHECK(..., gcc_cv_sys_sdt_h).
* configure: Regenerate.

2 years agogcc/file-prefix-map: Allow remapping of relative paths
Richard Purdie [Tue, 1 Nov 2022 19:45:08 +0000 (13:45 -0600)]
gcc/file-prefix-map: Allow remapping of relative paths

Relative paths currently aren't remapped by -ffile-prefix-map and friends.
When cross compiling with separate 'source' and 'build' directories, the same
relative paths between directories may not be available on target as compared
to build time.

In order to be able to remap these relative build paths to paths that would
work on target, resolve paths within the file-prefix-map function using
realpath().

This does cause a change of behaviour if users were previously relying upon
symlinks or absolute paths not being resolved.

Use basename to ensure plain filenames don't have paths added.

gcc/ChangeLog:

* file-prefix-map.cc (remap_filename): Allow remapping of relative paths.

2 years ago[PR tree-optimization/107490] Handle NANs in op[12]_range.
Aldy Hernandez [Tue, 1 Nov 2022 16:27:39 +0000 (17:27 +0100)]
[PR tree-optimization/107490] Handle NANs in op[12]_range.

None of the build_<OP> functions in range-op handle NANs.  This is by
design in order to force us to handle NANs specially, because
"x relop NAN" makes no sense.  This patch fixes a handful of
op[12]_range entries that weren't handling NANs.

PR tree-optimization/107490

gcc/ChangeLog:

* range-op-float.cc (foperator_unordered_lt::op1_range): Handle
NANs.
(foperator_unordered_lt::op2_range): Same.
(foperator_unordered_le::op1_range): Same.
(foperator_unordered_le::op2_range): Same.
(foperator_unordered_gt::op1_range): Same.
(foperator_unordered_gt::op2_range): Same.
(foperator_unordered_ge::op1_range): Same.
(foperator_unordered_ge::op2_range): Same.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/pr107490.c: New test.

2 years agoMake sure ssa-name is valid.
Andrew MacLeod [Tue, 1 Nov 2022 17:18:33 +0000 (13:18 -0400)]
Make sure ssa-name is valid.

PR tree-optimization/107497
* tree-vrp.cc (remove_unreachable::remove_and_update_globals):
Check that ssa-name still exists before accessing it.

2 years agoMake ranger vrp1 default.
Andrew MacLeod [Tue, 25 Oct 2022 20:42:41 +0000 (16:42 -0400)]
Make ranger vrp1 default.

Turn on ranger as the default vrp1 pass and adjust testcases.

gcc/
* params.opt (param_vrp1_mode): Make ranger default.

gcc/testsuite/
* gcc.dg/pr68217.c: Test [-INF, -INF][0, 0] instead of [-INF, 0].
* gcc.dg/tree-ssa/vrp-unreachable.c: New.  Test unreachable removal.

2 years agoRemove builtin_unreachable in VRP
Andrew MacLeod [Mon, 31 Oct 2022 19:18:00 +0000 (15:18 -0400)]
Remove builtin_unreachable in VRP

Removal of __builtin_unreachable calls were handled in an inconsistent
way.  This removes then in the VRP pass, and sets the global range
appropriately.

* tree-vrp.cc (class remove_unreachable): New.
(remove_unreachable::maybe_register_block): New.
(remove_unreachable::remove_and_update_globals): New.
(rvrp_folder::rvrp_folder): Initialize m_unreachable.
(rvrp_folder::post_fold_bb): Maybe register unreachable block.
(rvrp_folder::m_unreachable): New member.
(execute_ranger_vrp): Add final_pass flag, remove unreachables.

2 years agoAllow queries on exit block.
Andrew MacLeod [Mon, 31 Oct 2022 14:56:25 +0000 (10:56 -0400)]
Allow queries on exit block.

Ranger was not allowing the exit block to be queried for range_on_entry
or exit.  This removes that restriction.

* gimple-range-cache.cc (ranger_cache::fill_block_cache): Allow
exit block to be specified.
(ranger_cache::range_from_dom): If exit block is specified, use
the immediate predecessor instead of the dominator to start.
* gimple-range.cc (gimple_ranger::range_on_exit): Allow query
for exit block.

2 years agoIntersect with nonzero bits can indicate change incorrectly.
Andrew MacLeod [Mon, 31 Oct 2022 13:53:01 +0000 (09:53 -0400)]
Intersect with nonzero bits can indicate change incorrectly.

* value-range.cc (irange::intersect_nonzero_bits): If new
non-zero mask is the same as original, flag no change.

2 years agolibstdc++: std::from_chars std::{,b}float16_t support
Jakub Jelinek [Tue, 1 Nov 2022 12:41:57 +0000 (13:41 +0100)]
libstdc++: std::from_chars std::{,b}float16_t support

The following patch adds std::from_chars support, similarly to the
previous std::to_chars patch through APIs that use float instead of
the 16-bit floating point formats as container.
The patch uses the fast_float library and doesn't need any changes
to it, like the previous patch it introduces wrapper classes around
float that represent the float holding float16_t or bfloat16_t value,
and specializes binary_format etc. from fast_float for these classes.

The new test verifies exhaustively to_chars and from_chars afterward
results in the original value (except for nans) in all the fmt cases.

2022-11-01  Jakub Jelinek  <jakub@redhat.com>

* include/std/charconv (__from_chars_float16_t,
__from_chars_bfloat16_t): Declare.
(from_chars): Add _Float16 and __gnu_cxx::__bfloat16_t overloads.
* config/abi/pre/gnu.ver (GLIBCXX_3.4.31): Export
_ZSt22__from_chars_float16_tPKcS0_RfSt12chars_format and
_ZSt23__from_chars_bfloat16_tPKcS0_RfSt12chars_format.
* src/c++17/floating_from_chars.cc
(fast_float::floating_type_float16_t,
fast_float::floating_type_bfloat16_t): New classes.
(fast_float::binary_format<floating_type_float16_t>,
fast_float::binary_format<floating_type_bfloat16_t>): New
specializations.
(fast_float::to_float<floating_type_float16_t>,
fast_float::to_float<floating_type_bfloat16_t>,
fast_float::to_extended<floating_type_float16_t>,
fast_float::to_extended<floating_type_bfloat16_t>): Likewise.
(fast_float::from_chars_16): New template function.
(__floating_from_chars_hex): Allow instantiation with
fast_float::floating_type_{,b}float16_t.
(from_chars): Formatting fixes for float/double/long double overloads.
(__from_chars_float16_t, __from_chars_bfloat16_t): New functions.
* testsuite/20_util/to_chars/float16_c++23.cc: New test.

2 years agolibstdc++: std::to_chars std::{,b}float16_t support
Jakub Jelinek [Tue, 1 Nov 2022 12:40:05 +0000 (13:40 +0100)]
libstdc++: std::to_chars std::{,b}float16_t support

The following patch on top of
https://gcc.gnu.org/pipermail/libstdc++/2022-October/054849.html
adds std::{,b}float16_t support for std::to_chars.
When precision is specified (or for std::bfloat16_t for hex mode even if not),
I believe we can just use the std::to_chars float (when float is mode
compatible with std::float32_t) overloads, both formats are proper subsets
of std::float32_t.
Unfortunately when precision is not specified and we are supposed to emit
shortest string, the std::{,b}float16_t strings are usually much shorter.
E.g. 1.e7p-14f16 shortest fixed representation is
0.0001161 and shortest scientific representation is
1.161e-04 while 1.e7p-14f32 (same number promoted to std::float32_t)
0.00011610985 and
1.1610985e-04.
Similarly for 1.38p-112bf16,
0.000000000000000000000000000000000235
2.35e-34 vs. 1.38p-112f32
0.00000000000000000000000000000000023472271
2.3472271e-34
For std::float16_t there are differences even in the shortest hex, say:
0.01p-14 vs. 1p-22
but only for denormal std::float16_t values (where all std::float16_t
denormals converted to std::float32_t are normal), __FLT16_MIN__ and
everything larger in absolute value than that is the same.  Unless
that is a bug and we should try to discover shorter representations
even for denormals...
std::bfloat16_t has the same exponent range as std::float32_t, so all
std::bfloat16_t denormals are also std::float32_t denormals and thus
the shortest hex representations are the same.
As documented, ryu can handle arbitrary IEEE like floating point formats
(probably not wider than IEEE quad) using the generic_128 handling, but
ryu is hidden in libstdc++.so.  As only few architectures support
std::float16_t right now and some of them have special ISA requirements
for those (e.g. on i?86 one needs -msse2) and std::bfloat16_t is right
now supported only on x86 (again with -msse2), perhaps with aarch64/arm
coming next if ARM is interested, but I think it is possible that more
will be added later, instead of exporting APIs from the library to handle
directly the std::{,b}float16_t overloads this patch instead exports
functions which take a float which is a superset of those and expects
the inline overloads to promote the 16-bit formats to 32-bit, then inside
of the library it ensures they are printed right.
With the added [[gnu::cold]] attribute because I think most users
will primarily use these formats as storage formats and perform arithmetics
in the excess precision for them and print also as std::float32_t the
added support doesn't seem to be too large, on x86_64:
readelf -Ws libstdc++.so.6.0.31 | grep float16_t
   912: 00000000000ae824   950 FUNC    GLOBAL DEFAULT   13 _ZSt21__to_chars_bfloat16_tPcS_fSt12chars_format@@GLIBCXX_3.4.31
  5767: 00000000000ae4a1   899 FUNC    GLOBAL DEFAULT   13 _ZSt20__to_chars_float16_tPcS_fSt12chars_format@@GLIBCXX_3.4.31
   842: 000000000016d430   106 FUNC    LOCAL  DEFAULT   13 _ZN12_GLOBAL__N_113get_ieee_reprINS_23floating_type_float16_tEEENS_6ieee_tIT_EES3_
   865: 0000000000170980  1613 FUNC    LOCAL  DEFAULT   13
+_ZSt23__floating_to_chars_hexIN12_GLOBAL__N_123floating_type_float16_tEESt15to_chars_resultPcS3_T_St8optionalIiE.constprop.0.isra.0
  7205: 00000000000ae824   950 FUNC    GLOBAL DEFAULT   13 _ZSt21__to_chars_bfloat16_tPcS_fSt12chars_format
  7985: 00000000000ae4a1   899 FUNC    GLOBAL DEFAULT   13 _ZSt20__to_chars_float16_tPcS_fSt12chars_format
so 3568 code bytes together or so.

Tested with the attached test (which doesn't prove the shortest
representation, just prints std::{,b}float16_t and std::float32_t
shortest strings side by side, then tries to verify it can be
emitted even into the exact sized range and can't be into range
one smaller than that and tries to read what is printed
back using from_chars float32_t overload (so there could be
double rounding, but apparently there is none for the shortest strings).
The only differences printed are for NaNs, where sNaNs are canonicalized
to canonical qNaNs and as to_chars doesn't print NaN mantissa, even qNaNs
other than the canonical one are read back just as the canonical NaN.

Also attaching what Patrick wrote to generate the pow10_adjustment_tab,
for std::float16_t only 1.0, 10.0, 100.0, 1000.0 and 10000.0 are powers
of 10 in the range because __FLT16_MAX__ is 65504.0, and all of the above
are exactly representable in std::float16_t, so we want to use 0 in
pow10_adjustment_tab.

2022-11-01  Jakub Jelinek  <jakub@redhat.com>

* include/std/charconv (__to_chars_float16_t, __to_chars_bfloat16_t):
Declare.
(to_chars): Add _Float16 and __gnu_cxx::__bfloat16_t overloads.
* config/abi/pre/gnu.ver (GLIBCXX_3.4.31): Export
_ZSt20__to_chars_float16_tPcS_fSt12chars_format and
_ZSt21__to_chars_bfloat16_tPcS_fSt12chars_format.
* src/c++17/floating_to_chars.cc (floating_type_float16_t,
floating_type_bfloat16_t): New types.
(floating_type_traits<floating_type_float16_t>,
floating_type_traits<floating_type_bfloat16_t>,
get_ieee_repr<floating_type_float16_t>,
get_ieee_repr<floating_type_bfloat16_t>,
__handle_special_value<floating_type_float16_t>,
__handle_special_value<floating_type_bfloat16_t>): New specializations.
(floating_to_shortest_scientific): Handle floating_type_float16_t
and floating_type_bfloat16_t like IEEE quad.
(__floating_to_chars_shortest): For floating_type_bfloat16_t call
__floating_to_chars_hex<float> rather than
__floating_to_chars_hex<floating_type_bfloat16_t> to avoid
instantiating the latter.
(__to_chars_float16_t, __to_chars_bfloat16_t): New functions.

2 years agolibstdc++-v3: Some std::*float*_t charconv and i/ostream overloads
Jakub Jelinek [Tue, 1 Nov 2022 12:34:51 +0000 (13:34 +0100)]
libstdc++-v3: Some std::*float*_t charconv and i/ostream overloads

The following patch adds the easy part of <charconv>, <istream> and
<ostream> changes for extended floats.
In particular, for the first one only overloads where the _Float* has
the same format as float/double/long double and for the latter two
everything but the _GLIBCXX_HAVE_FLOAT128_MATH case.
For charconv, I'm not really familiar with it, I'm pretty sure
we need new libstdc++.so.6 side implementation of from_chars for
{,b}float16_t and for to_chars not really sure but for unspecified precision
if it should emit minimum characters that to_chars then can unambiguously
parse, I think it is less than in the float case.  For float128_t
{to,from}_chars I think we even have it on the library side already, just
ifdefed for powerpc64le only.
For i/o stream operator<</>>, not sure what is better, if not providing
anything at all, or doing what we in the end do if user doesn't override
the virtual functions, or use {to,from}_chars under the hood, something
else?
Besides this, the patch adds some further missed
// { dg-options "-std=gnu++2b" }
spots, I've also noticed I got the formatting wrong in some testcases
by not using spaces around VERIFY conditions and elsewhere by having
space before ( for calls.
The testsuite coverage is limited, I've added test for from_chars because
it was easy to port, but not really sure what to do about to_chars, it has
for float/double huge testcases which would be excessive to repeat.
And for i/ostream not really sure what exactly is worth testing.

2022-11-01  Jakub Jelinek  <jakub@redhat.com>

* include/std/charconv (from_chars, to_chars): Add _Float{32,64,128}
overloads for cases where those types match {float,double,long double}.
* include/std/istream (basic_istream::operator>>): Add
_Float{16,32,64,128} and __gnu_cxx::__bfloat16_t overloads.
* include/std/ostream (basic_ostream::operator<<): Add
_Float{16,32,64,128} and __gnu_cxx::__bfloat16_t overloads.
* testsuite/20_util/from_chars/8.cc: New test.
* testsuite/26_numerics/headers/cmath/nextafter_c++23.cc (test):
Formatting fixes.
* testsuite/26_numerics/headers/cmath/functions_std_c++23.cc: Add
dg-options "-std=gnu++2b".
(test_functions, main): Formatting fixes.
* testsuite/26_numerics/headers/cmath/c99_classification_macros_c++23.cc:
Add dg-options "-std=gnu++2b".