platform/upstream/gcc.git
2 years agotarget/106219 - proprly mark builtins pure via ix86_add_new_builtins
Richard Biener [Thu, 7 Jul 2022 08:46:01 +0000 (10:46 +0200)]
target/106219 - proprly mark builtins pure via ix86_add_new_builtins

The target optimize pragma path to initialize extra target specific
builtins missed handling of the pure_p flag which in turn causes
extra clobber side-effects of gather builtins leading to unexpected
issues downhill.

PR target/106219
* config/i386/i386-builtins.cc (ix86_add_new_builtins): Properly
set DECL_PURE_P.

* g++.dg/pr106219.C: New testcase.

2 years agotestsuite: Fix incorrect -mfloat128-type option
Jonathan Wakely [Wed, 6 Jul 2022 18:11:05 +0000 (19:11 +0100)]
testsuite: Fix incorrect -mfloat128-type option

This test currently fails with an error about -mfloat128-type being an
invalid option, which is not what it's supposed to be testing:

XFAIL: gcc.target/powerpc/ppc-fortran/pr80108-1.f90   -O  (test for excess errors)
Excess errors:
xgcc: error: unrecognized command-line option '-mfloat128-type'; did you mean '-mfloat128'?

With this change we get the error that the comment says it expects:

XFAIL: gcc.target/powerpc/ppc-fortran/pr80108-1.f90   -O  (test for excess errors)
Excess errors:
f951: Error: power9 target option is incompatible with '-mcpu=<xxx>' for <xxx> less than power9
f951: Error: '-mfloat128' requires VSX support
f951: Error: '-m64' requires a PowerPC64 cpu

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/ppc-fortran/pr80108-1.f90: Change
-mfloat128-type to -mfloat128.

2 years agoSpeed up LC SSA rewrite more
Richard Biener [Thu, 7 Jul 2022 07:29:55 +0000 (09:29 +0200)]
Speed up LC SSA rewrite more

In many cases loops have only one exit or a variable is only live
across one of the exits.  In this case we know that all uses
outside of the loop will be dominated by the single LC PHI node
we insert.  If that holds for all variables requiring LC SSA PHIs
then we can simplify the update_ssa process, avoiding the
(iterated) dominance frontier computations.

* tree-ssa-loop-manip.cc (add_exit_phis_var): Return the
number of LC PHIs inserted.
(add_exit_phis): Return whether any variable required
multiple LC PHI nodes.
(rewrite_into_loop_closed_ssa_1): Use TODO_update_ssa_no_phi
when possible.

2 years agoSpeed up LC SSA rewrite
Richard Biener [Thu, 7 Jul 2022 07:00:00 +0000 (09:00 +0200)]
Speed up LC SSA rewrite

The following avoids collecting all loops exit blocks into bitmaps
and computing the union of those up the loop tree possibly repeatedly.
Instead we make sure to do this only once for each loop with a
definition possibly requiring a LC phi node plus make sure to
leverage recorded exits to avoid the intermediate bitmap allocation.

* tree-ssa-loop-manip.cc (compute_live_loop_exits): Take
the def loop exit block bitmap as argument instead of
re-computing it here.
(add_exit_phis_var): Adjust.
(loop_name_cmp): New function.
(add_exit_phis): Sort variables to insert LC PHI nodes
after definition loop, for each definition loop compute
the exit block bitmap once.
(get_loops_exit): Remove.
(rewrite_into_loop_closed_ssa_1): Do not pre-record
all loop exit blocks into bitmaps.  Record loop exits
if required.

2 years agoMips: Fix the ASAN shadow offset hook for the n32 ABI
Dimitrije Milosevic [Wed, 6 Jul 2022 17:58:20 +0000 (01:58 +0800)]
Mips: Fix the ASAN shadow offset hook for the n32 ABI

gcc/ChangeLog:

* config/mips/mips.cc (mips_asan_shadow_offset): Reformat
to handle the N32 ABI.
* config/mips/mips.h (SUBTARGET_SHADOW_OFFSET): Remove
the macro, as it is not needed anymore.

2 years agolibsanitizer: Cherry-pick 5d8077565e41 from upstream
Dimitrije Milosevic [Wed, 6 Jul 2022 17:55:23 +0000 (01:55 +0800)]
libsanitizer: Cherry-pick 5d8077565e41 from upstream

5d8077565e41: [MIPS][AddressSanitizer] Resolve build issues for the n32 ABI

2 years agoDaily bump.
GCC Administrator [Thu, 7 Jul 2022 00:16:46 +0000 (00:16 +0000)]
Daily bump.

2 years agoRestore 'GOMP_offload_unregister_ver' functionality
Thomas Schwinge [Tue, 5 Jul 2022 16:23:15 +0000 (18:23 +0200)]
Restore 'GOMP_offload_unregister_ver' functionality

The recent commit 683f11843974f0bdf42f79cdcbb0c2b43c7b81b0
"OpenMP: Move omp requires checks to libgomp" changed the
'GOMP_offload_register_ver' interface but didn't change
'GOMP_offload_unregister_ver' accordingly, so we're no longer
actually unregistering.

gcc/
* config/gcn/mkoffload.cc (process_obj): Clarify 'target_data' ->
'[...]_data'.
* config/nvptx/mkoffload.cc (process): Likewise.
libgomp/
* target.c (GOMP_offload_register_ver): Clarify 'target_data' ->
'data'.
(GOMP_offload_unregister_ver): Likewise.  Fix up 'target_data'.

2 years agoDefine 'OMP_REQUIRES_[...]', 'GOMP_REQUIRES_[...]' in a single place
Thomas Schwinge [Tue, 5 Jul 2022 09:04:46 +0000 (11:04 +0200)]
Define 'OMP_REQUIRES_[...]', 'GOMP_REQUIRES_[...]' in a single place

Clean up for recent commit 683f11843974f0bdf42f79cdcbb0c2b43c7b81b0
"OpenMP: Move omp requires checks to libgomp".

gcc/
* omp-general.h (enum omp_requires): Use 'GOMP_REQUIRES_[...]'.
include/
* gomp-constants.h (OMP_REQUIRES_[...]): Update comment.

2 years agodiagnostics: Honor #pragma GCC diagnostic in the preprocessor [PR53431]
Lewis Hyatt [Tue, 5 Jul 2022 21:15:28 +0000 (17:15 -0400)]
diagnostics: Honor #pragma GCC diagnostic in the preprocessor [PR53431]

As discussed on PR c++/53431, currently, "#pragma GCC diagnostic" does
not always take effect for diagnostics generated by libcpp. The reason
is that libcpp itself does not interpret this pragma and only sends it on
to the frontend, hence the pragma is only honored if the frontend
arranges for it. The C frontend does process the pragma immediately
(more or less) after seeing the token, so things work fine there. The PR
points out that it doesn't work for C++, because the C++ frontend
doesn't handle anything until it has read all the tokens from
libcpp. The underlying problem is not C++-specific, though, and for
instance, gcc -E has the same issue.

This commit fixes the PR by adding the concept of an early pragma handler that
can be registered by frontends, which gives them a chance to process
diagnostic pragmas from libcpp before it is too late for them to take
effect. The C++ and preprocess-only frontends are modified to use early
pragmas and correct the behavior.

gcc/c-family/ChangeLog:

PR preprocessor/53920
PR c++/53431
* c-common.cc (c_option_is_from_cpp_diagnostics): New function.
* c-common.h (c_option_is_from_cpp_diagnostics): Declare.
(c_pp_stream_token): Declare.
* c-ppoutput.cc (init_pp_output): Refactor logic about skipping
pragmas to...
(should_output_pragmas): ...here. New function.
(token_streamer::stream): Support handling early pragmas.
(do_line_change): Likewise.
(c_pp_stream_token): New function.
* c-pragma.cc (struct pragma_diagnostic_data): New helper class.
(pragma_diagnostic_lex_normal): New function. Moved logic for
interpreting GCC diagnostic pragmas here.
(pragma_diagnostic_lex_pp): New function for parsing diagnostic pragmas
directly from libcpp.
(handle_pragma_diagnostic): Refactor into helper function...
(handle_pragma_diagnostic_impl): ...here.  New function.
(handle_pragma_diagnostic_early): New function.
(handle_pragma_diagnostic_early_pp): New function.
(struct pragma_ns_name): Renamed to...
(struct pragma_pp_data): ...this.  Add new "early_handler" member.
(c_register_pragma_1): Support early pragmas in the preprocessor.
(c_register_pragma_with_early_handler): New function.
(c_register_pragma): Support the new early handlers in struct
internal_pragma_handler.
(c_register_pragma_with_data): Likewise.
(c_register_pragma_with_expansion): Likewise.
(c_register_pragma_with_expansion_and_data): Likewise.
(c_invoke_early_pragma_handler): New function.
(c_pp_invoke_early_pragma_handler): New function.
(init_pragma): Add early pragma support for diagnostic pragmas.
* c-pragma.h (struct internal_pragma_handler): Add new early handler
members.
(c_register_pragma_with_early_handler): Declare.
(c_invoke_early_pragma_handler): Declare.
(c_pp_invoke_early_pragma_handler): Declare.

gcc/cp/ChangeLog:

PR c++/53431
* parser.cc (cp_parser_pragma_kind): Move earlier in the file.
(cp_lexer_handle_early_pragma): New function.
(cp_lexer_new_main): Support parsing and handling early pragmas.
(c_parse_file): Adapt to changes in cp_lexer_new_main.

gcc/testsuite/ChangeLog:

PR preprocessor/53920
PR c++/53431
* c-c++-common/pragma-diag-11.c: New test.
* c-c++-common/pragma-diag-12.c: New test.
* c-c++-common/pragma-diag-13.c: New test.

2 years agod: Merge upstream dmd 56589f0f4, druntime 651389b5, phobos 1516ecad9.
Iain Buclaw [Wed, 6 Jul 2022 17:45:28 +0000 (19:45 +0200)]
d: Merge upstream dmd 56589f0f4, druntime 651389b5, phobos 1516ecad9.

D front-end changes:

    - Import latest bug fixes to mainline.

D runtime changes:

    - Import latest bug fixes to mainline.

Phobos changes:

    - Import latest bug fixes to mainline.

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd 56589f0f4.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime 651389b5.
* src/MERGE: Merge upstream phobos 1516ecad9.

2 years agod: Build the D sources in the front-end with -fno-exceptions
Iain Buclaw [Fri, 1 Jul 2022 15:40:18 +0000 (17:40 +0200)]
d: Build the D sources in the front-end with -fno-exceptions

The D front-end does not use exceptions, but it still requires RTTI for
some lowerings of convenience language features.  Enforce it with by
building with `-fno-exceptions'.

gcc/d/ChangeLog:

* Make-lang.in (NOEXCEPTION_DFLAGS): Define.
(ALL_DFLAGS): Add NO_EXCEPTION_DFLAGS.

2 years agoanalyzer: add testcase of using closed fd without warning.
Immad Mir [Wed, 6 Jul 2022 16:08:27 +0000 (21:38 +0530)]
analyzer: add testcase of using closed fd without warning.

This patch adds a testcase for passing a closed fd to a function
that does not emit any warning.

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/fd-4.c: Add a new testcase to demonstrate
passsing of a closed file descriptor to a function that does
not emit any warning.

Signed-off-by: Immad Mir <mirimmad@outlook.com>
2 years agoanalyzer: reorder initialization of state m_invalid in sm-fd.cc [PR106184]
Immad Mir [Wed, 6 Jul 2022 16:07:14 +0000 (21:37 +0530)]
analyzer: reorder initialization of state m_invalid in sm-fd.cc [PR106184]

This patch reorders the initialization of state m_invalid in sm-fd.cc
so that the order of initializers is same as the ordering of the fields
in the class decl.

gcc/analyzer/ChangeLog:
PR analyzer/106184
* sm-fd.cc (fd_state_machine): Change ordering of initialization
of state m_invalid so that the order of initializers is same as
the ordering of the fields in the class decl.

Signed-off-by: Immad Mir <mirimmad@outlook.com>
2 years agoanalyzer: show close event for use_after_close diagnostic
Immad Mir [Wed, 6 Jul 2022 16:05:53 +0000 (21:35 +0530)]
analyzer: show close event for use_after_close diagnostic

This patch saves the "close" event in use_after_close diagnostic
and shows it where possible.

gcc/analyzer/ChangeLog:
* sm-fd.cc (use_after_close): save the "close" event and
show it where possible.

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/fd-4.c (test_3): change the message note to conform to the
changes in analyzer/sm-fd.cc
(test_4): Likewise.

Signed-off-by: Immad Mir <mirimmad@outlook.com>
2 years ago[Ada] Simplify regular expression that matches 8 consecutive digits
Piotr Trojanek [Thu, 9 Jun 2022 10:05:21 +0000 (12:05 +0200)]
[Ada] Simplify regular expression that matches 8 consecutive digits

Makefile cleanup; behaviour is unaffected.

gcc/ada/

* gcc-interface/Make-lang.in (ada/generated/gnatvsn.ads):
Simplify regular expression. The "interval expression",
i.e. \{8\} is part of the POSIX regular expressions, so it
should not be a problem for modern implementations of sed.

2 years ago[Ada] Update comment after recent changes wrt. secondary stack & tagged types
Eric Botcazou [Thu, 9 Jun 2022 16:49:10 +0000 (18:49 +0200)]
[Ada] Update comment after recent changes wrt. secondary stack & tagged types

gcc/ada/

* gcc-interface/trans.cc (gnat_to_gnu): Update comment.

2 years ago[Ada] Improve code generated for aggregates of VFA type
Eric Botcazou [Tue, 7 Jun 2022 19:46:04 +0000 (21:46 +0200)]
[Ada] Improve code generated for aggregates of VFA type

This avoids using a full access for constants internally generated from
assignments of aggregates with a Volatile_Full_Access type.

gcc/ada/

* gcc-interface/gigi.h (simple_constant_p): Declare.
* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Variable>: Strip
the qualifiers from the type of a simple constant.
(simple_constant_p): New predicate.
* gcc-interface/trans.cc (node_is_atomic): Return true for objects
with atomic type except for simple constants.
(node_is_volatile_full_access): Return false for simple constants
with VFA type.

2 years ago[Ada] Fix crash on aliased renaming of unconstrained array
Eric Botcazou [Fri, 3 Jun 2022 08:02:56 +0000 (10:02 +0200)]
[Ada] Fix crash on aliased renaming of unconstrained array

gcc/ada/

* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Variable>: Create a
local constant holding the underlying GNAT type of the object.  Do
not fiddle with the object size for an unconstrained array.

2 years ago[Ada] Small tweak to gnat_to_gnu_subprog_type
Eric Botcazou [Tue, 24 May 2022 08:01:13 +0000 (10:01 +0200)]
[Ada] Small tweak to gnat_to_gnu_subprog_type

No functional changes.

gcc/ada/

* gcc-interface/decl.cc (gnat_to_gnu_subprog_type): Constify a
local variable and move a couple of others around.

2 years ago[Ada] Do not give warnings for compiler-generated entities by default
Eric Botcazou [Mon, 23 May 2022 23:39:08 +0000 (01:39 +0200)]
[Ada] Do not give warnings for compiler-generated entities by default

gcc/ada/

* gcc-interface/trans.cc (gnat_gimplify_expr) <SAVE_EXPR>: New case.

2 years ago[Ada] Document the various function return mechanisms
Eric Botcazou [Thu, 16 Jun 2022 11:22:18 +0000 (13:22 +0200)]
[Ada] Document the various function return mechanisms

gcc/ada/

* exp_ch6.adb (Function return mechanisms): New paragraph.

2 years ago[Ada] Deferred constant considered as not preelaborable
Yannick Moy [Thu, 16 Jun 2022 12:14:56 +0000 (14:14 +0200)]
[Ada] Deferred constant considered as not preelaborable

Fix detection of non-preelaborable constructs for checking SPARK
elaboration rules, which was tagging deferred constant declarations as
not preelaborable.

gcc/ada/

* sem_util.adb (Is_Non_Preelaborable_Construct): Fix for
deferred constants.

2 years ago[Ada] Indexing error when calling GNAT.Regpat.Match
Justin Squirek [Wed, 15 Jun 2022 02:03:48 +0000 (02:03 +0000)]
[Ada] Indexing error when calling GNAT.Regpat.Match

This patch corrects an error in the compiler whereby a buffer sizing
error fails to get raised when compiling a regex expression with an
insufficiently sized Pattern_Matcher as the documentation indicated.
This, in turn, could lead to indexing errors when attempting to call
Match with the malformed regex program buffer.

gcc/ada/

* libgnat/s-regpat.adb, libgnat/s-regpat.ads (Compile): Add a
new defaulted parameter Error_When_Too_Small to trigger an
error, if specified true, when Matcher is too small to hold the
compiled regex program.

2 years ago[Ada] Spurious non-callable warning on prefixed call in class condition
Justin Squirek [Wed, 15 Jun 2022 01:14:31 +0000 (01:14 +0000)]
[Ada] Spurious non-callable warning on prefixed call in class condition

This patch corrects an error in the compiler whereby a function call in
prefix notation within a class condition causes a spurious error
claiming the name in the call is a non-callable entity when there exists
a type extension in the same unit extended with a component featuring
the same name as the function in question.

gcc/ada/

* sem_ch4.adb (Analyze_Selected_Component): Add condition to
avoid interpreting derived type components as candidates for
selected components in preanalysis of inherited class
conditions.

2 years ago[Ada] Support ghost generic formal parameters
Yannick Moy [Fri, 10 Jun 2022 15:18:23 +0000 (17:18 +0200)]
[Ada] Support ghost generic formal parameters

This adds support in GNAT for ghost generic formal parameters, as
included in SPARK RM 6.9.

gcc/ada/

* ghost.adb (Check_Ghost_Context): Delay checking for generic
associations.
(Check_Ghost_Context_In_Generic_Association): Perform ghost
checking in analyzed generic associations.
(Check_Ghost_Formal_Procedure_Or_Package): Check SPARK RM
6.9(13-14) for formal procedures and packages.
(Check_Ghost_Formal_Variable): Check SPARK RM 6.9(13-14) for
variables.
* ghost.ads: Declarations for the above.
* sem_ch12.adb (Analyze_Associations): Apply delayed checking
for generic associations.
(Analyze_Formal_Object_Declaration): Same.
(Analyze_Formal_Subprogram_Declaration): Same.
(Instantiate_Formal_Package): Same.
(Instantiate_Formal_Subprogram): Same.
(Instantiate_Object): Same.  Copy ghost aspect to newly declared
object for actual for IN formal object. Use new function
Get_Enclosing_Deep_Object to retrieve root object.
(Instantiate_Type): Copy ghost aspect to declared subtype for
actual for formal type.
* sem_prag.adb (Analyze_Pragma): Recognize new allowed
declarations.
* sem_util.adb (Copy_Ghost_Aspect): Copy the ghost aspect
between nodes.
(Get_Enclosing_Deep_Object): New function to return enclosing
deep object (or root for reachable part).
* sem_util.ads (Copy_Ghost_Aspect): Same.
(Get_Enclosing_Deep_Object): Same.
* libgnat/s-imageu.ads: Declare formal subprograms as ghost.
* libgnat/s-valuei.ads: Same.
* libgnat/s-valuti.ads: Same.

2 years ago[Ada] Missing error on tagged type conversion
Javier Miranda [Tue, 10 May 2022 17:18:30 +0000 (17:18 +0000)]
[Ada] Missing error on tagged type conversion

The compiler does not report an error on a type conversion to/from a
tagged type whose parent type is an interface type and there is no
relationship between the source and target types. This bug has been
dormant since January/2016.

This patch also improves the text of errors reported on interface type
conversions suggesting how to fix these errors.

gcc/ada/

* sem_res.adb (Resolve_Type_Conversion): Code cleanup since the
previous static check has been moved to Valid_Tagged_Conversion.
(Valid_Tagged_Conversion): Fix the code checking conversion
to/from interface types since incorrectly returns True when the
parent type of the operand type (or the target type) is an
interface type; add missing static checks on interface type
conversions.

2 years ago[Ada] Handle secondary stack memory allocations alignment
Marc Poulhiès [Thu, 2 Jun 2022 07:52:21 +0000 (09:52 +0200)]
[Ada] Handle secondary stack memory allocations alignment

To accomodate cases where objects allocated on the secondary stack
needed a more constrained alignement than Standard'Maximum_Alignement,
the alignment for all allocations in the full runtime were forced on to
be aligned on Standard'Maximum_Alignement*2. This changes removes this
workaround and correctly handles the over-alignment in all runtimes.

This change modifies the SS_Allocate procedure to accept a new Alignment
parameter and to dynamically realign the pointer returned by the memory
allocation (Allocate_* functions or dedicated stack allocations for
zfp/cert).

It also simplifies the 0-sized allocations by not allocating any memory
if pointer is already correctly aligned (already the case in cert and
zfp runtimes).

gcc/ada/

* libgnat/s-secsta.ads (SS_Allocate): Add new Alignment
parameter.
(Memory_Alignment): Remove.
* libgnat/s-secsta.adb (Align_Addr): New.
(SS_Allocate): Add new Alignment parameter. Realign pointer if
needed. Don't allocate anything for 0-sized allocations.
* gcc-interface/utils2.cc (build_call_alloc_dealloc_proc): Add
allocated object's alignment as last parameter to allocation
invocation.

2 years ago[Ada] Cleanup use of local scalars in GNAT.Socket.Get_Address_Info
Piotr Trojanek [Tue, 14 Jun 2022 11:47:27 +0000 (13:47 +0200)]
[Ada] Cleanup use of local scalars in GNAT.Socket.Get_Address_Info

A cleanup opportunity spotted while working on improved detection of
uninitialised local scalar objects.

gcc/ada/

* libgnat/g-socket.adb (Get_Address_Info): Reduce scope of the
Found variable; avoid repeated assignment inside the loop.

2 years ago[Ada] Vxworks7* - Makefile.rtl rtp vs rtp-smp cleanup
Doug Rupp [Wed, 8 Jun 2022 20:32:51 +0000 (13:32 -0700)]
[Ada] Vxworks7* - Makefile.rtl rtp vs rtp-smp cleanup

Only smp runtimes are built for vxworks7*, even though the -smp suffix
is removed during install. Therefore, in general, the build macros for
the non-smp runtimes are superfluous except on the legacy ppc-vxworks6
target where both the smp and non-smp runtime are built.  Lastly, an
error message is added if a runtime build is commanded that doesn't
exist, rather then letting the build mysteriously fail.

gcc/ada/

* Makefile.rtl [arm,aarch64 vxworks7]: Remove rtp and kernel
build macros and set an error variable if needed.
[x86,x86_vxworks7]: Likewise.
[ppc,ppc64]: Set an error variable if needed.
(rts-err): New phony Makefile target.
(setup-rts): Depend on rts-err.

2 years ago[Ada] Fix incorrect itype sharing for case expression in limited type return
Eric Botcazou [Sat, 11 Jun 2022 11:05:39 +0000 (13:05 +0200)]
[Ada] Fix incorrect itype sharing for case expression in limited type return

The compiler aborts with an internal error in gigi, but the problem is an
itype incorrectly shared between several branches of an if_statement that
has been created for a Build-In-Place return.

Three branches of this if_statement contain an allocator statement and
the latter two have been obtained as the result of calling New_Copy_Tree
on the first; now the initialization expression of the first had also been
obtained as the result of calling New_Copy_Tree on the original tree, and
these chained calls to New_Copy_Tree run afoul of an issue with the copy
of itypes after the rewrite of an aggregate as an expression with actions.

Fixing this issue looks quite delicate, so this fixes the incorrect sharing
by replacing the chained calls to New_Copy_Tree with repeated calls on the
original expression, which is more elegant in any case.

gcc/ada/

* exp_ch3.adb (Make_Allocator_For_BIP_Return): New local function.
(Expand_N_Object_Declaration): Use it to build the three allocators
for a Build-In-Place return with an unconstrained type.  Update the
head comment after other recent changes.

2 years ago[Ada] Remove old vxworks from Makefile.rtl - e500 port.
Doug Rupp [Thu, 2 Jun 2022 15:38:50 +0000 (08:38 -0700)]
[Ada] Remove old vxworks from Makefile.rtl - e500 port.

The powerpc e500 port has been LTS'd

gcc/ada/

* libgnat/system-vxworks7-e500-kernel.ads: Remove.
* libgnat/system-vxworks7-e500-rtp-smp.ads: Likewise.
* libgnat/system-vxworks7-e500-rtp.ads: Likewise.

2 years ago[Ada] Incorrect emptying of CUDA global subprograms
Justin Squirek [Fri, 10 Jun 2022 12:16:17 +0000 (12:16 +0000)]
[Ada] Incorrect emptying of CUDA global subprograms

This patch corrects an error in the compiler whereby no
Corresponding_Spec was set for emptied CUDA global subprograms - leading
to a malformed tree.

gcc/ada/

* gnat_cuda.adb (Empty_CUDA_Global_Subprogram): Set
Specification and Corresponding_Spec to match the original
Kernel_Body.

2 years ago[Ada] Remove explicit call to Make_Unchecked_Type_Conversion
Piotr Trojanek [Thu, 9 Jun 2022 20:01:06 +0000 (22:01 +0200)]
[Ada] Remove explicit call to Make_Unchecked_Type_Conversion

Respect a comment in sinfo.ads, which says: "Unchecked type conversion
nodes should be created by calling Tbuild.Unchecked_Convert_To, rather
than by directly calling Nmake.Make_Unchecked_Type_Conversion."

No test appears to be affected by this change, so this is just a
cleanup.

gcc/ada/

* exp_ch6.adb (Build_Static_Check_Helper_Call): Replace explicit
call to Make_Unchecked_Type_Conversion with a call to
Unchecked_Convert_To.
* tbuild.adb (Unchecked_Convert_To): Fix whitespace.

2 years ago[Ada] Restore accidentally removed part of a comment about unset references
Piotr Trojanek [Thu, 9 Jun 2022 21:23:46 +0000 (23:23 +0200)]
[Ada] Restore accidentally removed part of a comment about unset references

Fix an unintentionally removed comment.

gcc/ada/

* sem_res.adb (Resolve_Actuals): Restore first sentence of a
comment.

2 years ago[Ada] Fix spurious error for aggregate with box component choice
Eric Botcazou [Wed, 8 Jun 2022 11:14:46 +0000 (13:14 +0200)]
[Ada] Fix spurious error for aggregate with box component choice

It comes from the Volatile_Full_Access (or Atomic) aspect: the aggregate is
effectively analyzed/resolved twice and this does not work.  It is fixed by
calling Is_Full_Access_Aggregate before resolution.

gcc/ada/

* exp_aggr.adb (Expand_Record_Aggregate): Do not call
Is_Full_Access_Aggregate here.
* freeze.ads (Is_Full_Access_Aggregate): Delete.
* freeze.adb (Is_Full_Access_Aggregate): Move to...
(Freeze_Entity): Do not call Is_Full_Access_Aggregate here.
* sem_aggr.adb (Is_Full_Access_Aggregate): ...here
(Resolve_Aggregate): Call Is_Full_Access_Aggregate here.

2 years agoanalyzer: fix uninit false positive with -ftrivial-auto-var-init= [PR106204]
David Malcolm [Wed, 6 Jul 2022 11:27:45 +0000 (07:27 -0400)]
analyzer: fix uninit false positive with -ftrivial-auto-var-init= [PR106204]

-fanalyzer handles -ftrivial-auto-var-init= by special-casing
IFN_DEFERRED_INIT to be a no-op, so that e.g.:

  len_2 = .DEFERRED_INIT (4, 2, &"len"[0]);

is treated as a no-op, so that len_2 is still uninitialized after the
stmt.

PR analyzer/106204 reports that -fanalyzer gives false positives from
-Wanalyzer-use-of-uninitialized-value on locals that have their address
taken, due to e.g.:

  _1 = .DEFERRED_INIT (4, 2, &"len"[0]);
  len = _1;

where -fanalyzer leaves _1 uninitialized, and then complains about
the assignment to "len".

Fixed thusly by suppressing the warning when assigning from such SSA
names.

gcc/analyzer/ChangeLog:
PR analyzer/106204
* region-model.cc (within_short_circuited_stmt_p): Move extraction
of assign_stmt to caller.
(due_to_ifn_deferred_init_p): New.
(region_model::check_for_poison): Move extraction of assign_stmt
from within_short_circuited_stmt_p to here.  Share logic with
call to due_to_ifn_deferred_init_p.

gcc/testsuite/ChangeLog:
PR analyzer/106204
* gcc.dg/analyzer/torture/uninit-pr106204.c: New test.
* gcc.dg/analyzer/uninit-pr106204.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoc++: dependent conversion operator lookup [PR106179]
Jason Merrill [Tue, 5 Jul 2022 21:05:47 +0000 (17:05 -0400)]
c++: dependent conversion operator lookup [PR106179]

This testcase demonstrates that my assumption that we would only be
interested in a class template lookup if the template-id is followed by ::
was wrong.

PR c++/106179
PR c++/106024

gcc/cp/ChangeLog:

* parser.cc (cp_parser_lookup_name): Remove :: requirement
for using unqualified lookup result.

gcc/testsuite/ChangeLog:

* g++.dg/template/operator16.C: New test.

2 years agoDaily bump.
GCC Administrator [Wed, 6 Jul 2022 00:16:33 +0000 (00:16 +0000)]
Daily bump.

2 years agocompiler: propagate array length error marker farther
Ian Lance Taylor [Sun, 3 Jul 2022 21:37:23 +0000 (14:37 -0700)]
compiler: propagate array length error marker farther

Fixes golang/go#53639

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/415936

2 years agocompiler: better error message for unknown package name
Ian Lance Taylor [Mon, 4 Jul 2022 19:20:36 +0000 (12:20 -0700)]
compiler: better error message for unknown package name

Fixes golang/go#51237

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/415994

2 years agolibstdc++: testsuite: why cast getpid result
Alexandre Oliva [Tue, 5 Jul 2022 22:07:32 +0000 (19:07 -0300)]
libstdc++: testsuite: why cast getpid result

Add a comment next to the getpid call to explain why the typecast is
needed.

for  libstdc++-v3/ChangeLog

* testsuite/util/testsuite_fs.h (nonexistent_path): Explain
why we need the typecast.

2 years agoc-family: Prevent -Wformat warnings with u8 strings [PR105626]
Marek Polacek [Tue, 5 Jul 2022 18:22:26 +0000 (14:22 -0400)]
c-family: Prevent -Wformat warnings with u8 strings [PR105626]

The <https://gcc.gnu.org/pipermail/gcc/2022-May/238679.html> thread
seems to have concluded that -Wformat shouldn't warn about

  printf((const char*) u8"test %d\n", 1);

saying "format string is not an array of type 'char'".  This code
is not an aliasing violation, and there are no I/O functions for u8
strings, so the const char * cast is OK and shouldn't be disregarded.

PR c++/105626

gcc/c-family/ChangeLog:

* c-format.cc (check_format_arg): Don't emit -Wformat warnings with
u8 strings.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wformat-char8_t-1.C: New test.

2 years agoProvide a relation verification mechanism.
Andrew MacLeod [Tue, 5 Jul 2022 14:54:26 +0000 (10:54 -0400)]
Provide a relation verification mechanism.

Provide a relation oracle API which validates a relation between 2 ranges.
This allows relation queries that are symbolicly true to be overridden
by range specific information.  ie. x == x is true symbolically, but for
floating point a NaN may invalidate this assumption.

* value-relation.cc (relation_to_code): New vector.
(relation_oracle::validate_relation): New.
(set_relation): Allow ssa1 == ssa2 to be registered.
* value-relation.h (validate_relation): New prototype.
(query_relation): Make internal variant protected.

2 years agoDoubleword version of and;cmp to not;test optimization on x86.
Roger Sayle [Tue, 5 Jul 2022 17:06:13 +0000 (18:06 +0100)]
Doubleword version of and;cmp to not;test optimization on x86.

This patch extends the earlier and;cmp to not;test optimization to also
perform this transformation for TImode on TARGET_64BIT and DImode on -m32,
One motivation for this is that it's a step to fixing the current failure
of gcc.target/i386/pr65105-5.c on -m32.

A more direct benefit for x86_64 is that the following code:

int foo(__int128 x, __int128 y)
{
  return (x & y) == y;
}

improves with -O2 from 15 instructions:

        movq    %rdi, %r8
        movq    %rsi, %rax
        movq    %rax, %rdi
        movq    %r8, %rsi
        movq    %rdx, %r8
        andq    %rdx, %rsi
        andq    %rcx, %rdi
        movq    %rsi, %rax
        movq    %rdi, %rdx
        xorq    %r8, %rax
        xorq    %rcx, %rdx
        orq     %rdx, %rax
        sete    %al
        movzbl  %al, %eax
        ret

to the slightly better 13 instructions:

        movq    %rdi, %r8
        movq    %rsi, %rax
        movq    %r8, %rsi
        movq    %rax, %rdi
        notq    %rsi
        notq    %rdi
        andq    %rdx, %rsi
        andq    %rcx, %rdi
        movq    %rsi, %rax
        orq     %rdi, %rax
        sete    %al
        movzbl  %al, %eax
        ret

2022-07-05  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
* config/i386/i386.cc (ix86_rtx_costs) <COMPARE>: Provide costs
for double word comparisons and tests (comparisons against zero).
* config/i386/i386.md (*test<mode>_not_doubleword): Split DWI
and;cmp into andn;cmp $0 as a pre-reload splitter.
(*andn<dwi>3_doubleword_bmi): Use <dwi> instead of <mode> in name.
(*<any_or><dwi>3_doubleword): Likewise.

gcc/testsuite/ChangeLog
* gcc.target/i386/testnot-3.c: New test case.

2 years agoUNSPEC_PALIGNR optimizations and clean-ups on x86.
Roger Sayle [Tue, 5 Jul 2022 17:00:00 +0000 (18:00 +0100)]
UNSPEC_PALIGNR optimizations and clean-ups on x86.

This patch is a follow-up to Hongtao's fix for PR target/105854.  That
fix is perfectly correct, but the thing that caught my eye was why is
the compiler generating a shift by zero at all.  Digging deeper it
turns out that we can easily optimize __builtin_ia32_palignr for
alignments of 0 and 64 respectively, which may be simplified to moves
of the highpart and lowpart respectively.

After adding optimizations to simplify the 64-bit DImode palignr, I
started to add the corresponding optimizations for vpalignr (i.e.
128-bit).  The first oddity is that sse.md uses TImode and a special
SSESCALARMODE iterator, rather than V1TImode, and indeed the comment
above SSESCALARMODE hints that this should be "dropped in favor of
VIMAX_AVX2_AVX512BW".  Hence this patch includes the migration of
<ssse3_avx2>_palignr<mode> to use VIMAX_AVX2_AVX512BW, basically
using V1TImode instead of TImode for 128-bit palignr.

This patch has been tested on x86_64-pc-linux-gnu with make bootstrap
and make -k check, both with and without --target_board=unix{-,32},
with no new failures.  Ok for mainline?

2022-07-05  Roger Sayle  <roger@nextmovesoftware.com>
    Hongtao Liu  <hongtao.liu@intel.com>

gcc/ChangeLog
* config/i386/i386-builtin.def (__builtin_ia32_palignr128): Change
CODE_FOR_ssse3_palignrti to CODE_FOR_ssse3_palignrv1ti.
* config/i386/i386-expand.cc (expand_vec_perm_palignr): Use V1TImode
and gen_ssse3_palignv1ti instead of TImode.
* config/i386/sse.md (SSESCALARMODE): Delete.
(define_mode_attr ssse3_avx2): Handle V1TImode instead of TImode.
(<ssse3_avx2>_palignr<mode>): Use VIMAX_AVX2_AVX512BW as a mode
iterator instead of SSESCALARMODE.
(ssse3_palignrdi): Optimize cases where operands[3] is 0 or 64,
using a single move instruction (if required).

gcc/testsuite/ChangeLog
* gcc.target/i386/ssse3-palignr-2.c: New test case.

2 years agoPR rtl-optimization/96692: ((A|B)^C)^A using andn with -mbmi on x86.
Roger Sayle [Tue, 5 Jul 2022 16:55:53 +0000 (17:55 +0100)]
PR rtl-optimization/96692: ((A|B)^C)^A using andn with -mbmi on x86.

This patch addresses PR rtl-optimization/96692 on x86_64, by providing
a set of combine splitters to convert the three operation ((A|B)^C)^D
into a two operation sequence using andn when either A or B is the same
register as C or D.  This is essentially a reassociation problem that's
only a win if the target supports an and-not instruction (as with -mbmi).

Hence for the new test case:

int f(int a, int b, int c)
{
    return (a ^ b) ^ (a | c);
}

GCC on x86_64-pc-linux-gnu wth -O2 -mbmi would previously generate:

        xorl    %edi, %esi
        orl     %edx, %edi
        movl    %esi, %eax
        xorl    %edi, %eax
        ret

but with this patch now generates:

        andn    %edx, %edi, %eax
        xorl    %esi, %eax
        ret

2022-07-05  Roger Sayle  <roger@nextmovesoftware.com>
    UroÅ¡ Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog
PR rtl-optimization/96692
* config/i386/i386.md (define_split): Split ((A | B) ^ C) ^ D
as (X & ~Y) ^ Z on target BMI when either C or D is A or B.

gcc/testsuite/ChangeLog
PR rtl-optimization/96692
* gcc.target/i386/bmi-andn-4.c: New test case.

2 years agoc++: Prune ordinary locations
Nathan Sidwell [Fri, 24 Jun 2022 12:57:42 +0000 (05:57 -0700)]
c++: Prune ordinary locations

Like macro locations, we only need to emit ordinary location
information for locations emitted into the CMI. This adds a hash table
noting which ordinary lines are needed.  These are then sorted and
(sufficiently) adjacent lines are coalesced to a single map.  There is
a tradeoff here, allowing greater separation reduces the number of
line maps, but increases the number of locations.  It appears allowing
2 or 3 intervening lines is the sweet spot, and this patch chooses 2.

Compiling a hello-world #includeing <iostream> in it's GMF gives a
reduction in number of locations of 5 fold, but an increase in number
of maps about 4 fold.  Examining one of the xtreme-header tests we
halve the number of locations and increase the number of maps by 9
fold.

Module interfaces that emit no entities (or macros, if a header-unit),
will now have no location tables.

gcc/cp/
* module.cc
(struct ord_loc_info, ord_loc_traits): New.
(ord_loc_tabke, ord_loc_remap): New globals.
(struct location_map_info): Delete.
(struct module_state_config): Rename ordinary_loc_align to
loc_range_bits.
(module_for_ordinary_loc): Adjust.
(module_state::note_location): Note ordinary locations,
return bool.
(module_state::write_location): Adjust ordinary location
streaming.
(module_state::read_location): Likewise.
(module_state::write_init_maps): Allocate ord_loc_table.
(module_state::write_prepare_maps): Reimplement ordinary
map preparation.
(module_state::read_prepare_maps): Adjust.
(module_state::write_ordinary_maps): Reimplement.
(module_state::write_macro_maps): Adjust.
(module_state::read_ordinary_maps): Reimplement.
(module_state::write_macros): Adjust.
(module_state::write_config): Adjust.
(module_state::read_config): Adjust.
(module_state::write_begin): Adjust.
(module_state::read_initial): Adjust.
gcc/testsuite/
* g++.dg/modules/loc-prune-1.C: Adjust.
* g++.dg/modules/loc-prune-4.C: New.
* g++.dg/modules/pr98718_a.C: Adjust.
* g++.dg/modules/pr98718_b.C: Adjust.
* g++.dg/modules/pr99072.H: Adjust.

2 years agotree-optimization/106198 - CFG cleanup vs LC SSA
Richard Biener [Tue, 5 Jul 2022 12:14:49 +0000 (14:14 +0200)]
tree-optimization/106198 - CFG cleanup vs LC SSA

This is another case like PR106182 where for the 2nd testcase in
the bug there are no removed or discovered loops but still changing
loop exits invalidates LC SSA and it is not enough to just scan for
uses in the blocks that changed loop depth.  One might argue that
if we'd include former exit destinations we'd pick up the original
LC SSA use but for virtuals on block merging we'd have propagated
those out (while for regular uses we insert copies).  CFG cleanup
can also be entered with loops needing fixup so any heuristics
based on loop structure are bound to fail.

PR tree-optimization/106198
* tree-cfgcleanup.cc (repair_loop_structures): Always do a
full LC SSA rewrite but only if any blocks changed loop
depth.

* gcc.dg/pr106198.c: New testcase.

2 years agoRemove dead loop-based LC SSA rewrite
Richard Biener [Tue, 5 Jul 2022 12:09:36 +0000 (14:09 +0200)]
Remove dead loop-based LC SSA rewrite

The following removes the now unused per-loop path in LC SSA rewrite.

* tree-ssa-loop-manip.cc (find_uses_to_rename_def): Remove.
(find_uses_to_rename_in_loop): Likewise.
(rewrite_into_loop_closed_ssa_1): Remove loop parameter and
uses.
(rewrite_into_loop_closed_ssa): Adjust.

2 years agotree-optimization/106186 - propagate out virtual LC PHI nodes properly
Richard Biener [Tue, 5 Jul 2022 09:38:52 +0000 (11:38 +0200)]
tree-optimization/106186 - propagate out virtual LC PHI nodes properly

The code to remove LC PHI nodes in clean_up_loop_closed_phi does not handle
virtual operands because may_propagate_copy generally returns false
for them.  The following copies the merge_blocks variant for
dealing with them.

This fixes a missed jump threading in gcc.dg/auto-init-uninit-4.c
which manifests in bogus uninit diagnostics.

PR tree-optimization/106186
* tree-ssa-propagate.cc (clean_up_loop_closed_phi):
Properly handle virtual PHI nodes.

2 years agotree-optimization/106196 - properly update virtual SSA for vector stores
Richard Biener [Tue, 5 Jul 2022 08:43:42 +0000 (10:43 +0200)]
tree-optimization/106196 - properly update virtual SSA for vector stores

The following properly handles aggregate returns of the const marked
STORE_LANES internal function to update virtual SSA form on-the-fly
rather than relying on a costly virtual SSA rewrite.

PR tree-optimization/106196
* tree-vect-stmts.cc (vect_finish_stmt_generation): Properly
handle aggregate returns of calls for VDEF updates.

* gcc.dg/torture/pr106196.c: New testcase.

2 years agoMaintain LC SSA when doing SVE vectorization
Richard Biener [Mon, 4 Jul 2022 12:58:41 +0000 (14:58 +0200)]
Maintain LC SSA when doing SVE vectorization

The final loop IV use after the loop has that not in LC SSA
(and inserts not simplified _2 = _3 - 0 stmts).  In particular
since it splits the exit edge when there's a virtual PHI in the
destination it breaks virtual LC SSA form (but likely also
non-virtual).

The following properly inserts LC PHIs instead.

2022-07-04  Richard Biener  <rguenther@suse.de>

* tree-vect-loop-manip.cc (vect_set_loop_condition_normal):
Maintain LC SSA.

2 years agotestsuite: fix array type in two_plus_gigs test
Alexandre Oliva [Tue, 5 Jul 2022 09:12:28 +0000 (06:12 -0300)]
testsuite: fix array type in two_plus_gigs test

The array element type for the two_plus_gigs test was mistakely put in
as int rather than char.

for  gcc/testsuite/ChangeLog

* lib/target-supports.exp (check_effective_target_two_plus_gigs):
Fix array element type.  Reported by Hans-Peter Nilsson.

2 years agolibstdc++: testsuite: cast getpid result
Alexandre Oliva [Tue, 5 Jul 2022 09:12:27 +0000 (06:12 -0300)]
libstdc++: testsuite: cast getpid result

On vxworks, in kernel mode, getpid's return type is a pointer type, so
std::to_string on it fails overload resolution.  Restore the type cast
from the original patch that suggested adding the pid.

for  libstdc++-v3/ChangeLog

* testsuite/util/testsuite_fs.h (nonexistent_path): Convert
the getpid result to an integral type.

2 years ago[Ada] Warn about obsolete uses of renamed Ada 83 packages
Piotr Trojanek [Thu, 19 May 2022 18:42:42 +0000 (20:42 +0200)]
[Ada] Warn about obsolete uses of renamed Ada 83 packages

Ada 83 packages like Unchecked_Conversion or Text_IO are obsolete since
Ada 95. GNAT now warns about their uses when warnings on obsolescent
featured (Annex J) is active.

gcc/ada/

* doc/gnat_ugn/building_executable_programs_with_gnat.rst
(Warning Message Control): Update description of switch -gnatwj.
* gnat_ugn.texi: Regenerate.
* sem_ch10.adb (Analyze_With_Clause): Warn on WITH clauses for
obsolete renamed units; in Ada 83 mode do not consider
predefined renamings to be obsolete.

gcc/testsuite/

* gnat.dg/renaming1.adb: Update WITH clause.
* gnat.dg/renaming1.ads: Likewise.
* gnat.dg/warn29.adb: Likewise.

2 years ago[Ada] Couple of small cleanups for Cloned_Subtype
Eric Botcazou [Wed, 8 Jun 2022 22:24:34 +0000 (00:24 +0200)]
[Ada] Couple of small cleanups for Cloned_Subtype

No functional changes.

gcc/ada/

* exp_util.adb (Make_Subtype_From_Expr): Do not set field to Empty.
* sem_util.adb (Visit_Itype): Remove ??? comment.

2 years ago[Ada] Remove kludge for validity checks on Long_Float type
Piotr Trojanek [Mon, 6 Jun 2022 21:23:32 +0000 (23:23 +0200)]
[Ada] Remove kludge for validity checks on Long_Float type

This patch reverts a fix for a spurious warning for validity checks on
type Long_Float. This fix was dubious (as it was only affecting
Long_Float and not Float) and apparently is no longer needed.

Cleanup related to improved detection of uninitialised scalar objects.

gcc/ada/

* sem_attr.adb (Note_Possible_Modification): Revert a
special-case for validity checks on Long_Float type.
* snames.ads-tmpl (Name_Attr_Long_Float): Remove name added
exclusively for the mentioned fix.

2 years ago[Ada] Remove repeated setting of Never_Set_In_Source
Piotr Trojanek [Wed, 8 Jun 2022 18:52:48 +0000 (20:52 +0200)]
[Ada] Remove repeated setting of Never_Set_In_Source

Formal parameters have their flag Never_Set_In_Source set at the
beginning of Process_Formals routine (regardless of the parameter mode).
There is no need to set it again when Process_Formals calls
Set_Formal_Mode (for parameters of mode IN OUT and OUT).

Code cleanup related to improved detection of uninitialised objects;
behaviour is unaffected.

gcc/ada/

* sem_ch6.adb (Set_Formal_Mode): Remove unnecessary setting of
Never_Set_In_Source.

2 years ago[Ada] Reorder processing of default expressions to avoid repeated calls
Piotr Trojanek [Wed, 8 Jun 2022 18:49:57 +0000 (20:49 +0200)]
[Ada] Reorder processing of default expressions to avoid repeated calls

Code cleanup related to improved detection of uninitialised objects;
semantics is unaffected.

gcc/ada/

* sem_ch6.adb (Process_Formals): Avoid repeated calls to
Expression.

2 years ago[Ada] Remove redundant protection against empty lists
Piotr Trojanek [Wed, 8 Jun 2022 14:58:18 +0000 (16:58 +0200)]
[Ada] Remove redundant protection against empty lists

Calls to First on No_List intentionally return Empty node, so explicit
guards against No_List are unnecessary. Code cleanup; semantics is
unaffected.

gcc/ada/

* exp_code.adb (Setup_Asm_IO_Args): Remove guard against No_List.
* par_sco.adb (Process_Decisions): Likewise.
* sem_ch13.adb (Check_Component_List): Likewise.
* sem_ch6.adb (FCL): Likewise.

2 years ago[Ada] qnx-7.1: ACATS cxag001 failure on qnx - realpath
Doug Rupp [Wed, 8 Jun 2022 14:39:16 +0000 (07:39 -0700)]
[Ada] qnx-7.1: ACATS cxag001 failure on qnx - realpath

The implementation of __gnat_full_name uses the CRTL realpath, however
this function returns a null string so use the default implementation
instead.

gcc/ada/

* cstreams.c (__gnat_full_name) [QNX]: Remove block.

2 years ago[Ada] Remove use of a global name buffer when locating a file
Piotr Trojanek [Fri, 25 Mar 2022 23:13:28 +0000 (00:13 +0100)]
[Ada] Remove use of a global name buffer when locating a file

Code cleanup; semantics is unaffected.

gcc/ada/

* osint.adb (Locate_File): Use Name_Find with a parameter and
not with a global buffer.

2 years ago[Ada] Reuse Get_Pragma_Arg to handle pragma argument associations
Piotr Trojanek [Tue, 7 Jun 2022 11:19:35 +0000 (13:19 +0200)]
[Ada] Reuse Get_Pragma_Arg to handle pragma argument associations

Code cleanup related to looking at pragma Thread_Local_Storage.
Semantics is unaffected.

gcc/ada/

* exp_ch3.adb (Build_Init_Statements): Reuse Get_Pragma_Arg.
* exp_prag.adb (Arg_N): Likewise.

2 years ago[Ada] Fix spurious error on object renaming with ghost type
Yannick Moy [Tue, 7 Jun 2022 09:00:56 +0000 (11:00 +0200)]
[Ada] Fix spurious error on object renaming with ghost type

Renaming of an object of ghost type leads to a spurious error.  Now
fixed.

gcc/ada/

* ghost.adb (Is_OK_Ghost_Context): Detect ghost type inside object
renaming.

2 years ago[Ada] Misc cleanup related to finalization
Bob Duff [Mon, 6 Jun 2022 17:22:39 +0000 (13:22 -0400)]
[Ada] Misc cleanup related to finalization

This patch cleans up some code issues found while working on
finalization, and adds some debugging aids.

gcc/ada/

* exp_ch7.adb: Change two constants Is_Protected_Body and
Is_Prot_Body to be Is_Protected_Subp_Body; these are not true
for protected bodies, but for protected subprogram bodies.
(Expand_Cleanup_Actions): No need to search for
Activation_Chain_Entity; just use Activation_Chain_Entity.
* sem_ch8.adb (Find_Direct_Name): Use Entyp constant.
* atree.adb, atree.ads, atree.h, nlists.adb, nlists.ads
(Parent): Provide nonoverloaded versions of Parent, so that they
can be easily found in the debugger.
* debug_a.adb, debug_a.ads: Clarify that we're talking about the
-gnatda switch; switches are case sensitive.  Print out the
Chars field if appropriate, which makes it easier to find things
in the output.
(Debug_Output_Astring): Simplify. Also fix an off-by-one
bug ("for I in Vbars'Length .." should have been "for I in
Vbars'Length + 1 ..").  Before, it was printing Debug_A_Depth +
1 '|' characters if Debug_A_Depth > Vbars'Length.

2 years ago[Ada] Remove repeated analysis for pragma Thread_Local_Storage
Piotr Trojanek [Mon, 6 Jun 2022 13:27:38 +0000 (15:27 +0200)]
[Ada] Remove repeated analysis for pragma Thread_Local_Storage

When analysing pragma Thread_Local_Storage its argument is analysed by
the call to Check_Arg_Is_Library_Level_Local_Name. There is no need to
reanalyse it. Code cleanup; behaviour is not affected.

gcc/ada/

* sem_prag.adb (Analyze_Pragma): Remove unnecessary call to
Analyze.

2 years ago[Ada] Annotate GNAT.Sockets with No_Return aspects
Piotr Trojanek [Mon, 6 Jun 2022 14:41:32 +0000 (16:41 +0200)]
[Ada] Annotate GNAT.Sockets with No_Return aspects

Opportunity for extra annotations spotted while fixing detection of
unreachable code that follows calls to procedures annotated with
No_Return.

gcc/ada/

* libgnat/g-socket.adb (Raise_Host_Error): Add No_Return aspect.
(Raise_GAI_Error): Likewise.
* libgnat/g-socket.ads (Raise_Socket_Error): Likewise.

2 years ago[Ada] Cleanup repeated code for aggregate constraints checks
Piotr Trojanek [Mon, 6 Jun 2022 12:01:35 +0000 (14:01 +0200)]
[Ada] Cleanup repeated code for aggregate constraints checks

Code cleanup related to examining uses of Check_Unset_Reference for
improved detection of uninitialised scalar objects. Semantics is
unaffected.

gcc/ada/

* sem_util.adb (Aggregate_Constraint_Checks): Fix whitespace;
refactor repeated code; replace a ??? comment with an
explanation based on the comment for the routine spec.

2 years ago[Ada] Fix comments mentioning ancient flags related to objects references
Piotr Trojanek [Mon, 6 Jun 2022 11:02:28 +0000 (13:02 +0200)]
[Ada] Fix comments mentioning ancient flags related to objects references

Flag May_Be_Modified under go a series of renamings between 1996 and
2002.  It was changed to Not_Assigned, then to Not_Source_Assigned and
finally to Never_Set_In_Source. Fix remaining references in comments.

gcc/ada/

* sem_util.ads (Note_Possible_Modification): Fix occurrence of
May_Be_Modified in comment.
* sem_warn.ads (Check_Unset_Reference): Fix occurrence of
Not_Assigned in comment.

2 years ago[Ada] Spurious error on qualified prefix in Pack.Func'Result
Yannick Moy [Mon, 23 May 2022 12:27:41 +0000 (14:27 +0200)]
[Ada] Spurious error on qualified prefix in Pack.Func'Result

When using a qualified name such as Pack.Func as the prefix of a 'Result
attribute reference, the prefix is not fully resolved and may contain a
chain of homonyms. Look for the expected function in the homonym chain
instead of issuing an error if the first one is not the expected one.

gcc/ada/

* sem_attr.adb (Analyze_Attribute): Take into account the
possibility of homonyms.

2 years ago[Ada] Perform object rewriting as renaming only in the expander
Eric Botcazou [Mon, 6 Jun 2022 08:50:23 +0000 (10:50 +0200)]
[Ada] Perform object rewriting as renaming only in the expander

The rewriting as renaming optimization for object declarations is done
partly during analysis, guarded with Expander_Active, and partly during
expansion, so it makes sense to do it entirely during expansion.

This merges the two cases and removes obsolete or unnecessary conditions
guarding the transformation in the process.

gcc/ada/

* exp_ch3.adb (Expand_N_Object_Declaration): Rewrite as a renaming
for any nonaliased local object with nominal unconstrained subtype
originally initialized with the result of a function call that has
been rewritten as the dereference of a reference to the result.
* sem_ch3.adb (Analyze_Object_Declaration): Do not do it here

2 years ago[Ada] Remove exception propagation during bootstrap
Arnaud Charlet [Sat, 4 Jun 2022 10:44:13 +0000 (10:44 +0000)]
[Ada] Remove exception propagation during bootstrap

To help the bootstrap path, we want to keep the compiler free from any
exception propagation during bootstrap. This has been broken recently in
various places.

Also introduce a way to more easily detect such breakage via the
-DNO_EXCEPTION_PROPAGATION which can now be used as part of BOOT_CFLAGS.

gcc/ada/

* exp_imgv.adb (Build_Enumeration_Image_Tables): Also disable
perfect hash in GNAT_Mode.
* raise-gcc.c (__gnat_Unwind_RaiseException): Add support for
disabling exception propagation.
* sem_eval.adb (Compile_Time_Known_Value): Update comment and
remove wrong call to Check_Error_Detected.
* sem_prag.adb (Check_Loop_Pragma_Grouping, Analyze_Pragma):
Remove exception propagation during bootstrap.

2 years ago[Ada] Fix dangling bounds for array result of BIP functions
Eric Botcazou [Fri, 3 Jun 2022 08:27:33 +0000 (10:27 +0200)]
[Ada] Fix dangling bounds for array result of BIP functions

The implementation of the build-in-place return protocol for functions
whose result type is an unconstrained array type generates dangling
references to local bounds built on the stack for the result as soon as
these bounds are not static.  The reason is that the implementation
treats the return object, either explicitly present in the source or
synthesized by the compiler, as a regular constrained object until very
late in the game, although it needs to be ultimately rewritten as the
renaming of the dereference of an allocator with unconstrained designated
type in order for the bounds to be part of the allocation.

Recently a partial fix was implemented for the case where the result is an
aggregate, by preventing the return object from being expanded after it has
been analyzed.  However, it does not work for the general case of extended
return statements, because the statements therein are still analyzed with
the constrained version of the return object so, after it is changed into
the unconstrained renaming, this yields (sub)type mismatches.

Therefore this change goes the other way around: it rolls back the partial
fix and instead performs the transformation of the return object into the
unconstrained renaming during the expansion of its declaration, in other
words before statements referencing it, if any, are analyzed, thus ensuring
that they see the final version of the object.

gcc/ada/

* exp_aggr.adb (Expand_Array_Aggregate): Remove obsolete code.
Delay the expansion of aggregates initializing return objects of
build-in-place functions.
* exp_ch3.ads (Ensure_Activation_Chain_And_Master): Delete.
* exp_ch3.adb (Ensure_Activation_Chain_And_Master): Fold back to...
(Expand_N_Object_Declaration): ...here.
Perform the expansion of return objects of build-in-place functions
here instead of...
* exp_ch6.ads (Is_Build_In_Place_Return_Object): Declare.
* exp_ch6.adb (Expand_N_Extended_Return_Statement): ...here.
(Is_Build_In_Place_Result_Type): Alphabetize.
(Is_Build_In_Place_Return_Object): New predicate.
* exp_ch7.adb (Enclosing_Function): Delete.
(Process_Object_Declaration): Tidy up handling of return objects.
* sem_ch3.adb (Analyze_Object_Declaration): Do not decorate and
freeze the actual type if it is the same as the nominal type.
* sem_ch6.adb: Remove use and with clauses for Exp_Ch3.
(Analyze_Function_Return): Analyze again all return objects.
(Create_Extra_Formals): Do not force the definition of an Itype
if the subprogram is a compilation unit.

2 years ago[Ada] Remove unnecessary dead code after calls to nonreturning procedures
Piotr Trojanek [Thu, 2 Jun 2022 15:32:15 +0000 (17:32 +0200)]
[Ada] Remove unnecessary dead code after calls to nonreturning procedures

A new warning about unreachable code that follows calls to procedures
with No_Return would flag some dead defensive code. Comments next to
this code suggest that it was added to please some ancient version of
the compiler, but recent releases of GNAT do not require such a code.

gcc/ada/

* gnatls.adb (Corresponding_Sdep_Entry): Remove dead return
statement in defensive path; there is another return statement
for a normal execution of this routine, so rule Ada RM 6.5(5),
which requires function to have at least one return statement is
still satisfied.
(Gnatls): Remove dead, call to nonreturning Exit_Program after
Output_License_Information which itself does not return.
* libgnat/a-exstat.adb (Bad_EO): Remove raise statement that was
meant to please some ancient version of GNAT.
* libgnat/g-awk.adb (Raise_With_Info): Likewise.
* sem_attr.adb (Check_Reference): Remove dead return statement;
rule Ada RM 6.5(5), which requires function to have at least one
return statement is still satisfied.
(Analyze_Attribute): Remove dead exit statement.
(Check_Reference): Same as above.
* sem_ch12.adb (Instantiate_Formal_Package): Remove dead raise
statement; it was inconsistent with other calls to
Abandon_Instantiation, which are not followed by a raise
statement.
* sem_prag.adb (Process_Convention): Remove dead defensive
assignment.
(Interrupt_State): Remove dead defensive exit statement.
(Do_SPARK_Mode): Likewise.
* sfn_scan.adb (Scan_String): Remove dead defensive assignment.

2 years ago[Ada] Remove return statements after procedure calls that don't return
Piotr Trojanek [Thu, 2 Jun 2022 15:22:42 +0000 (17:22 +0200)]
[Ada] Remove return statements after procedure calls that don't return

A new warning about unreachable code that follows calls to procedures
with No_Return would flag many unnecessary return statements. Those
returns statements were applied inconsistently, so this patch is
actually more a style cleanup.

gcc/ada/

* sem_attr.adb, sem_prag.adb: Remove dead return statements
after calls to Error_Attr, Error_Pragma, Error_Pragma_Arg and
Placement_Error. All these calls raise exceptions that are
handled to gently recover from errors.

2 years ago[Ada] Combine system.ads files - vxworks6 constants.
Doug Rupp [Thu, 2 Jun 2022 20:39:02 +0000 (13:39 -0700)]
[Ada] Combine system.ads files - vxworks6 constants.

Systemitize Word_Size and Memory_Size declarations rather than hard code
with numerical values or OS specific Long_Integer size.

gcc/ada/

* libgnat/system-vxworks-ppc-kernel.ads (Word_Size): Compute
based on Standard'Word_Size.
(Memory_Size): Compute based on Word_Size.
* libgnat/system-vxworks-ppc-rtp-smp.ads: Likewise.
* libgnat/system-vxworks-ppc-rtp.ads: Likewise.

2 years ago[Ada] Fix clearly unintentional dead analysis of attribute Code_Address
Piotr Trojanek [Thu, 2 Jun 2022 15:15:22 +0000 (17:15 +0200)]
[Ada] Fix clearly unintentional dead analysis of attribute Code_Address

A new warning about unreachable code that follows calls to procedures
with No_Return would flag a clearly unintentional dead call to
Set_Address_Taken in analysis of Code_Address attribute.

This patch resurrects the dead code, which is worth fixing regardless of
the new warning.

gcc/ada/

* sem_attr.adb (Analyze_Attribute): Move call to
Set_Address_Taken so that it is executed when the prefix
attribute is legal.

2 years ago[Ada] Cleanup in error about unreachable code
Piotr Trojanek [Mon, 30 May 2022 22:29:43 +0000 (00:29 +0200)]
[Ada] Cleanup in error about unreachable code

Cleanup only; behaviour is unaffected.

gcc/ada/

* sem_ch5.adb (Check_Unreachable_Code): Avoid explicit use of
Sloc; this should also help when we finally use Source_Span for
prettier error messages.

2 years ago[Ada] Remove redundant guards in detection of unreachable code
Piotr Trojanek [Mon, 30 May 2022 22:29:28 +0000 (00:29 +0200)]
[Ada] Remove redundant guards in detection of unreachable code

Routine Check_Unreachable_Code is only called on nodes belonging to a
list of statements (and it wouldn't make sense to call it on anything
else).

gcc/ada/

* sem_ch5.adb (Check_Unreachable_Code): Remove redundant guard;
the call to Present wasn't needed either.

2 years ago[Ada] Remove redundant guard for call to List_Length with a No_List
Piotr Trojanek [Sun, 29 May 2022 16:06:22 +0000 (18:06 +0200)]
[Ada] Remove redundant guard for call to List_Length with a No_List

Code cleanup related to a new detection of uninitialised local scalar
objects; semantics is unaffected.

gcc/ada/

* sem_ch5.adb (Analyze_Block_Statement): Call to List_Length with
No_List is safe and will return zero.

2 years ago[Ada] Add RM reference to check for functions without a return statement
Piotr Trojanek [Thu, 2 Jun 2022 13:16:44 +0000 (15:16 +0200)]
[Ada] Add RM reference to check for functions without a return statement

Add comment to explain why we have an error and not just a warning.

gcc/ada/

* sem_ch6.adb (Check_Missing_Return): Add reference to an RM rule.

2 years ago[Ada] Remove comment about a long gone formal verification mode
Piotr Trojanek [Thu, 2 Jun 2022 13:10:46 +0000 (15:10 +0200)]
[Ada] Remove comment about a long gone formal verification mode

Remove outdated a comment about the very first SPARK experiments
in GNAT.

gcc/ada/

* sem_ch6.adb (Check_Missing_Return): Remove outdated comment.

2 years ago[Ada] Remove unimplemented convert_addresses declaration
Dmitriy Anisimkov [Thu, 2 Jun 2022 06:50:07 +0000 (12:50 +0600)]
[Ada] Remove unimplemented convert_addresses declaration

convert_addresses is declared in adaint.h but is never referenced, so
remove it.

gcc/ada/

* adaint.h (convert_addresses): Remove function declaration.

2 years ago[Ada] Remove old vxworks6 from Makefile.rtl
Doug Rupp [Thu, 12 May 2022 19:35:37 +0000 (12:35 -0700)]
[Ada] Remove old vxworks6 from Makefile.rtl

Pre vxworks7 code excepting legacy vxworks6 code is removed from
Makefile.rtl and unused files are deleted.

gcc/ada/

* Makefile.rtl (*vxworks*): Remove most pre-vxworks7 code.
* vxworks-arm-link.spec: Remove.
* vxworks-e500-link.spec: Likewise.
* vxworks-smp-arm-link.spec: Likewise.
* vxworks-smp-e500-link.spec: Likewise.
* vxworks-smp-x86-link.spec: Likewise.
* libgnat/system-vxworks-arm-rtp-smp.ads: Likewise.
* libgnat/system-vxworks-arm-rtp.ads: Likewise.
* libgnat/system-vxworks-arm.ads: Likewise.
* libgnat/system-vxworks-e500-kernel.ads: Likewise.
* libgnat/system-vxworks-e500-rtp-smp.ads: Likewise.
* libgnat/system-vxworks-e500-rtp.ads: Likewise.
* libgnat/system-vxworks-x86-kernel.ads: Likewise.
* libgnat/system-vxworks-x86-rtp-smp.ads: Likewise.
* libgnat/system-vxworks-x86-rtp.ads: Likewise.

2 years agovect: Use sdot for a fallback implementation of usdot
Richard Sandiford [Tue, 5 Jul 2022 07:53:10 +0000 (08:53 +0100)]
vect: Use sdot for a fallback implementation of usdot

Following a suggestion from Tamar, this patch adds a fallback
implementation of usdot using sdot.  Specifically, for 8-bit
input types:

   acc_2 = DOT_PROD_EXPR <a_unsigned, b_signed, acc_1>;

becomes:

   tmp_1 = DOT_PROD_EXPR <64, b_signed, acc_1>;
   tmp_2 = DOT_PROD_EXPR <64, b_signed, tmp_1>;
   acc_2 = DOT_PROD_EXPR <a_unsigned - 128, b_signed, tmp_2>;

on the basis that (x-128)*y + 64*y + 64*y.  Doing the two 64*y
operations first should give more time for x to be calculated,
on the off chance that that's useful.

gcc/
* tree-vect-patterns.cc (vect_convert_input): Expect the input
type to be signed for optab_vector_mixed_sign.  Update the vectype
at the same time as type.
(vect_recog_dot_prod_pattern): Update accordingly.  If usdot isn't
available, try sdot instead.
* tree-vect-loop.cc (vect_is_emulated_mixed_dot_prod): New function.
(vect_model_reduction_cost): Model the cost of implementing usdot
using sdot.
(vectorizable_reduction): Likewise.  Skip target support test
for lane reductions.
(vect_emulate_mixed_dot_prod): New function.
(vect_transform_reduction): Use it to emulate usdot via sdot.

gcc/testsuite/
* gcc.dg/vect/vect-reduc-dot-9.c: Reduce target requirements
from i8mm to dotprod.
* gcc.dg/vect/vect-reduc-dot-10.c: Likewise.
* gcc.dg/vect/vect-reduc-dot-11.c: Likewise.
* gcc.dg/vect/vect-reduc-dot-12.c: Likewise.
* gcc.dg/vect/vect-reduc-dot-13.c: Likewise.
* gcc.dg/vect/vect-reduc-dot-14.c: Likewise.
* gcc.dg/vect/vect-reduc-dot-15.c: Likewise.
* gcc.dg/vect/vect-reduc-dot-16.c: Likewise.
* gcc.dg/vect/vect-reduc-dot-17.c: Likewise.
* gcc.dg/vect/vect-reduc-dot-18.c: Likewise.
* gcc.dg/vect/vect-reduc-dot-19.c: Likewise.
* gcc.dg/vect/vect-reduc-dot-20.c: Likewise.
* gcc.dg/vect/vect-reduc-dot-21.c: Likewise.
* gcc.dg/vect/vect-reduc-dot-22.c: Likewise.

2 years agotree-optimization/106182 - LC SSA after CFG cleanup
Richard Biener [Mon, 4 Jul 2022 13:03:33 +0000 (15:03 +0200)]
tree-optimization/106182 - LC SSA after CFG cleanup

The testcase shows that when cleaning up the CFG we can end up
with broken LC SSA (for virtual operands with the testcase).  The
case here involves deleting a loop after which it is not enough
to scan the blocks with changed loop depth for SSA uses that need
to be rewritten.  So make fix_loop_sturcture return the sum of
the number of new loops and the number of deleted loops.

PR tree-optimization/106182
* loop-init.cc (fix_loop_structure): Return the number
of newly discovered plus the number of deleted loops.
* tree-cfgcleanup.cc (repair_loop_structures): Adjust
variable name.

* gcc.dg/torture/pr106182.c: New testcase.

2 years agoDaily bump.
GCC Administrator [Tue, 5 Jul 2022 00:16:36 +0000 (00:16 +0000)]
Daily bump.

2 years agogcc.dg/analyzer/allocation-size-1..5.c: Fix for 32-bit newlib targets
Hans-Peter Nilsson [Mon, 4 Jul 2022 17:22:17 +0000 (19:22 +0200)]
gcc.dg/analyzer/allocation-size-1..5.c: Fix for 32-bit newlib targets

See gcc/config/newlib-stdint.h, where targets that have
LONG_TYPE_SIZE == 32, get INT32_TYPE defined to "long int".
INT32_TYPE ends up in the target int32_t.

Thus the tests failed for 32-bit newlib targets due to related
warning messages being matched to "aka int" where the emitted
message for these targets have "aka long int".

Tested cris-elf, committed as obvious.

gcc/testsuite:
* gcc.dg/analyzer/allocation-size-1.c,
gcc.dg/analyzer/allocation-size-2.c,
gcc.dg/analyzer/allocation-size-3.c,
gcc.dg/analyzer/allocation-size-4.c,
gcc.dg/analyzer/allocation-size-5.c: Handle int32_t being "long int".

2 years agoOpenMP/Fortran: Add support for OpenMP 5.2 linear clause syntax
Tobias Burnus [Mon, 4 Jul 2022 19:50:23 +0000 (21:50 +0200)]
OpenMP/Fortran: Add support for OpenMP 5.2 linear clause syntax

Fortran part to C/C++
commit r13-1002-g03b71406323ddc065b1d7837d8b43b17e4b048b5

gcc/fortran/ChangeLog:

* gfortran.h (gfc_omp_namelist): Update by creating 'linear' struct,
move 'linear_op' as 'op' to id and add 'old_modifier' to it.
* dump-parse-tree.cc (show_omp_namelist): Update accordingly.
* module.cc (mio_omp_declare_simd): Likewise.
* trans-openmp.cc (gfc_trans_omp_clauses): Likewise.
* openmp.cc (resolve_omp_clauses): Likewise; accept new-style
'val' modifier with do/simd.
(gfc_match_omp_clauses): Handle OpenMP 5.2 linear clause syntax.

libgomp/ChangeLog:

* libgomp.texi (OpenMP 5.2): Mark linear-clause change as 'Y'.

gcc/testsuite/ChangeLog:

* c-c++-common/gomp/linear-4.c: New test.
* gfortran.dg/gomp/linear-2.f90: New test.
* gfortran.dg/gomp/linear-3.f90: New test.
* gfortran.dg/gomp/linear-4.f90: New test.
* gfortran.dg/gomp/linear-5.f90: New test.
* gfortran.dg/gomp/linear-6.f90: New test.
* gfortran.dg/gomp/linear-7.f90: New test.
* gfortran.dg/gomp/linear-8.f90: New test.

Co-authored-by: Jakub Jelinek <jakub@redhat.com>
2 years agoMisc conversions to vrange.
Aldy Hernandez [Mon, 4 Jul 2022 15:32:07 +0000 (17:32 +0200)]
Misc conversions to vrange.

The following converts a handful of places that were irange centric.

Tested on x86-64 Linux.

gcc/ChangeLog:

* gimple-range-fold.cc
(fold_using_range::range_of_ssa_name_with_loop_info): Restrict the
call to SCEV for irange supported types.
(fold_using_range::range_of_builtin_int_call): Convert to vrange.
* gimple-range.cc (gimple_ranger::prefill_stmt_dependencies): Same.
* tree-ssa-dom.cc (cprop_operand): Same.

2 years agomiddle-end: Support ABIs that pass FP values as wider integers.
Roger Sayle [Mon, 4 Jul 2022 15:45:47 +0000 (16:45 +0100)]
middle-end: Support ABIs that pass FP values as wider integers.

Sorry for the long delay getting back to this, but after deeper
investigation, it turns out that Jeff Law's tingling spider senses
that the original patch wasn't updating everywhere that was required
were spot on.  Although my nvptx testing showed no problems with -O2,
compiling the same tests with -O0 found several additional assertion
ICEs (exactly where he'd predicted they'd be).

Here's a revised patch that updates five locations (up from the
previous two).  Finding any remaining locations (if any) might be
easier once folks are able to test things on their targets.  This
also implements Jeff's suggestion to factor the common code into
helper routines.

2022-07-04  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
PR target/104489
* calls.cc (precompute_register_parameters): Allow promotion
of floating point values to be passed in wider integer modes
by calling new convert_float_to_wider_int.
(expand_call): Allow floating point results to be returned in
wider integer modes by calling new convert wider_int_to_float.
* cfgexpand.cc (expand_value_return): Allow backends to promote
a scalar floating point return value to a wider integer mode
by calling new convert_float_to_wider_int.
* expr.cc (convert_float_to_wider_int): New function.
(convert_wider_int_to_float): Likewise.
(expand_expr_real_1) <expand_decl_rtl>: Allow backends to promote
scalar FP PARM_DECLs to wider integer modes, by calling new
convert_wider_int_to_float.
* expr.h (convert_modes): Name arguments for improved documentation.
(convert_float_to_wider_int): Prototype new function here.
(convert_wider_int_to_float): Likewise.
* function.cc (assign_parm_setup_stack): Allow floating point
values to be passed on the stack as wider integer modes by
calling new convert_wider_int_to_float.

2 years agoFix typo in recent code to add stack recursion limit to the Rust demangler.
Nick Clifton [Mon, 4 Jul 2022 15:31:18 +0000 (16:31 +0100)]
Fix typo in recent code to add stack recursion limit to the Rust demangler.

libiberty
* rust-demangle.c (demangle_const): Add a missing goto pass_return
at the end of the function.

2 years agotree-sra: Fix union handling in build_reconstructed_reference
Martin Jambor [Fri, 1 Jul 2022 18:57:18 +0000 (20:57 +0200)]
tree-sra: Fix union handling in build_reconstructed_reference

As the testcase in PR 105860 shows, the code that tries to re-use the
handled_component chains in SRA can be horribly confused by unions,
where it thinks it has found a compatible structure under which it can
chain the references, but in fact it found the type it was looking
for elsewhere in a union and generated a write to a completely wrong
part of an aggregate.

I don't remember whether the plan was to support unions at all in
build_reconstructed_reference but it can work, to an extent, if we
make sure that we start the search only outside the outermost union,
which is what the patch does (and the extra testcase verifies).

gcc/ChangeLog:

2022-07-01  Martin Jambor  <mjambor@suse.cz>

PR tree-optimization/105860
* tree-sra.cc (build_reconstructed_reference): Start expr
traversal only just below the outermost union.

gcc/testsuite/ChangeLog:

2022-07-01  Martin Jambor  <mjambor@suse.cz>

PR tree-optimization/105860
* gcc.dg/tree-ssa/alias-access-path-13.c: New test.
* gcc.dg/tree-ssa/pr105860.c: Likewise.

2 years agoRevert update-ssa assert in vectorizer
Richard Biener [Mon, 4 Jul 2022 11:53:24 +0000 (13:53 +0200)]
Revert update-ssa assert in vectorizer

The following reverts the just added assert that virtual SSA does not
need updating.  It instead goes for a select whitelist of transforms
known to be prone to difficulties with virtual SSA update.

* tree-vect-loop-manip.cc (vect_do_peeling): Revert assert
and update virtual SSA form again.  Assert we do so for
a known set of transforms only.
* tree-vectorizer.h (vec_info::any_known_not_updated_vssa): New.
* tree-vect-stmts.cc (vectorizable_load): When vectorizing
using load-lanes allow virtual SSA update.

2 years agoOpenMP: Move omp requires checks to libgomp
Tobias Burnus [Mon, 4 Jul 2022 11:51:02 +0000 (13:51 +0200)]
OpenMP: Move omp requires checks to libgomp

Handle reverse_offload, unified_address, and unified_shared_memory
requirements in libgomp by saving them alongside the offload table.
When the device lto1 runs, it extracts the data for mkoffload. The
latter than passes the value on to GOMP_offload_register_ver.

lto1 (either the host one, with -flto [+ ENABLE_OFFLOADING], or in the
offload-device lto1) also does the the consistency check is done,
erroring out when the 'omp requires' clause use is inconsistent.

For all in-principle supported devices, if a requirement cannot be fulfilled,
the device is excluded from the (supported) devices list. Currently, none of
those requirements are marked as supported for any of the non-host devices.

gcc/c/ChangeLog:

* c-parser.cc (c_parser_omp_target_data, c_parser_omp_target_update,
c_parser_omp_target_enter_data, c_parser_omp_target_exit_data): Set
OMP_REQUIRES_TARGET_USED.
(c_parser_omp_requires): Remove sorry.

gcc/ChangeLog:

* config/gcn/mkoffload.cc (process_asm): Write '#include <stdint.h>'.
(process_obj): Pass omp_requires_mask to GOMP_offload_register_ver.
(main): Ask lto1 to obtain omp_requires_mask and pass it on.
* config/nvptx/mkoffload.cc (process, main): Likewise.
* lto-cgraph.cc (omp_requires_to_name): New.
(input_offload_tables): Save omp_requires_mask.
(output_offload_tables): Read it, check for consistency,
save value for mkoffload.
* omp-low.cc (lower_omp_target): Force output_offloadtables
call for OMP_REQUIRES_TARGET_USED.

gcc/cp/ChangeLog:

* parser.cc (cp_parser_omp_target_data,
cp_parser_omp_target_enter_data, cp_parser_omp_target_exit_data,
cp_parser_omp_target_update): Set OMP_REQUIRES_TARGET_USED.
(cp_parser_omp_requires): Remove sorry.

gcc/fortran/ChangeLog:

* openmp.cc (gfc_match_omp_requires): Remove sorry.
* parse.cc (decode_omp_directive): Don't regard 'declare target'
as target usage for 'omp requires'; add more flags to
omp_requires_mask.

include/ChangeLog:

* gomp-constants.h (GOMP_VERSION): Bump to 2.
(GOMP_REQUIRES_UNIFIED_ADDRESS, GOMP_REQUIRES_UNIFIED_SHARED_MEMORY,
GOMP_REQUIRES_REVERSE_OFFLOAD, GOMP_REQUIRES_TARGET_USED):
New defines.

libgomp/ChangeLog:

* libgomp-plugin.h (GOMP_OFFLOAD_get_num_devices): Add
omp_requires_mask arg.
* plugin/plugin-gcn.c (GOMP_OFFLOAD_get_num_devices): Likewise;
return -1 when device available but omp_requires_mask != 0.
* plugin/plugin-nvptx.c (GOMP_OFFLOAD_get_num_devices): Likewise.
* oacc-host.c (host_get_num_devices, host_openacc_get_property):
Update call.
* oacc-init.c (resolve_device, acc_init_1, acc_shutdown_1,
goacc_attach_host_thread_to_device, acc_get_num_devices,
acc_set_device_num, get_property_any): Likewise.
* target.c (omp_requires_mask): New global var.
(gomp_requires_to_name): New.
(GOMP_offload_register_ver): Handle passed omp_requires_mask.
(gomp_target_init): Handle omp_requires_mask.
* libgomp.texi (OpenMP 5.0): Update requires impl. status.
(OpenMP 5.1): Add a missed item.
(OpenMP 5.2): Mark linear-clause change as supported in C/C++.
* testsuite/libgomp.c-c++-common/requires-1-aux.c: New test.
* testsuite/libgomp.c-c++-common/requires-1.c: New test.
* testsuite/libgomp.c-c++-common/requires-2-aux.c: New test.
* testsuite/libgomp.c-c++-common/requires-2.c: New test.
* testsuite/libgomp.c-c++-common/requires-3-aux.c: New test.
* testsuite/libgomp.c-c++-common/requires-3.c: New test.
* testsuite/libgomp.c-c++-common/requires-4-aux.c: New test.
* testsuite/libgomp.c-c++-common/requires-4.c: New test.
* testsuite/libgomp.c-c++-common/requires-5-aux.c: New test.
* testsuite/libgomp.c-c++-common/requires-5.c: New test.
* testsuite/libgomp.c-c++-common/requires-6.c: New test.
* testsuite/libgomp.c-c++-common/requires-7-aux.c: New test.
* testsuite/libgomp.c-c++-common/requires-7.c: New test.
* testsuite/libgomp.fortran/requires-1-aux.f90: New test.
* testsuite/libgomp.fortran/requires-1.f90: New test.

liboffloadmic/ChangeLog:

* plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_get_num_devices):
Return -1 when device available but omp_requires_mask != 0.

gcc/testsuite/ChangeLog:

* c-c++-common/gomp/requires-4.c: Update dg-*.
* c-c++-common/gomp/reverse-offload-1.c: Likewise.
* c-c++-common/gomp/target-device-ancestor-2.c: Likewise.
* c-c++-common/gomp/target-device-ancestor-3.c: Likewise.
* c-c++-common/gomp/target-device-ancestor-4.c: Likewise.
* c-c++-common/gomp/target-device-ancestor-5.c: Likewise.
* gfortran.dg/gomp/target-device-ancestor-3.f90: Likewise.
* gfortran.dg/gomp/target-device-ancestor-4.f90: Likewise.
* gfortran.dg/gomp/target-device-ancestor-5.f90: Likewise.
* gfortran.dg/gomp/target-device-ancestor-2.f90: Likewise. Move
post-FE checks to ...
* gfortran.dg/gomp/target-device-ancestor-2a.f90: ... this new file.
* gfortran.dg/gomp/requires-8.f90: Update as we don't regard
'declare target' for the 'requires' usage requirement.

Co-authored-by: Chung-Lin Tang <cltang@codesourcery.com>
Co-authored-by: Thomas Schwinge <thomas@codesourcery.com>
2 years agoKeep virtual SSA up-to-date in vectorizer
Richard Biener [Mon, 4 Jul 2022 10:36:05 +0000 (12:36 +0200)]
Keep virtual SSA up-to-date in vectorizer

The following removes a FIXME where we fail(ed) to keep virtual
SSA up-to-date, patching up the remaining two cases I managed to
trigger.  I've left an assert so that we pick up cases arising
for the cases I wasn't able to trigger.

2022-07-04  Richard Biener  <rguenther@suse.de>

* tree-vect-loop-manip.cc (vect_do_peeling): Assert that
no SSA update is needed instead of updating virtual SSA
form.
* tree-vect-stmts.cc (vectorizable_load): For hoisted
invariant load use the loop entry virtual use.
For emulated gather loads use the virtual use of the
original stmt like vect_finish_stmt_generation would do.

2 years agogcc-descr: by default show revision for HEAD
Martin Liska [Mon, 4 Jul 2022 10:13:44 +0000 (12:13 +0200)]
gcc-descr: by default show revision for HEAD

I've made the mistake multiple times while doing a bisection.
One would expect that gcc-descr w/o an argument would print
revision for the current HEAD and not master.
Thus change it.

contrib/ChangeLog:

* git-descr.sh: By default print revision for HEAD.

2 years agoFix crash on circular array types with -fdump switches
Eric Botcazou [Mon, 4 Jul 2022 10:16:38 +0000 (12:16 +0200)]
Fix crash on circular array types with -fdump switches

Such questionable arrays types can occur in Ada.

gcc/
* tree-pretty-print.cc (dump_generic_node) <ARRAY_TYPE>: Add guard
for direct circularity.

2 years agoUse default lower bound for vector types in debug info
Eric Botcazou [Mon, 4 Jul 2022 10:14:03 +0000 (12:14 +0200)]
Use default lower bound for vector types in debug info

Vector types are represented as array types with DW_AT_GNU_vector attribute
in the debug info and a range [0 .. TYPE_VECTOR_SUBPARTS - 1].  Now that's
obviously skewed toward the C family of languages, therefore the attached
patch changes the lower bound to the default for the language of the CU.

gcc/
* dwarf2out.cc (gen_array_type_die): Use the default lower bound of
the language for vector types.