platform/upstream/gcc.git
22 months agoFortran: error recovery for bad deferred character length assignment [PR104314]
Harald Anlauf [Thu, 15 Sep 2022 20:06:53 +0000 (22:06 +0200)]
Fortran: error recovery for bad deferred character length assignment [PR104314]

gcc/fortran/ChangeLog:

PR fortran/104314
* resolve.cc (deferred_op_assign): Do not try to generate temporary
for deferred character length assignment if types do not agree.

gcc/testsuite/ChangeLog:

PR fortran/104314
* gfortran.dg/pr104314.f90: New test.

Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
22 months agofloat.h: Do not define INFINITY for C2x when infinities not supported
Joseph Myers [Thu, 15 Sep 2022 20:10:42 +0000 (20:10 +0000)]
float.h: Do not define INFINITY for C2x when infinities not supported

C2x has changed the rules for defining INFINITY in <float.h> so it is
no longer defined when float does not support infinities, instead of
being defined to an expression that overflows at translation time.
Thus, make the definition conditional on __FLT_HAS_INFINITY__ (this is
already inside a C2x-conditional part of <float.h>, because previous C
standard versions only had this macro in <math.h>).

Bootstrapped with no regressions for x86_64-pc-linux-gnu.  Also did a
spot test of the case of no infinities supported by building cc1 for
vax-netbsdelf and testing compiling the new c2x-float-11.c test with
it.

gcc/
* ginclude/float.h (INFINITY): Define only if
[__FLT_HAS_INFINITY__].

gcc/testsuite/
* gcc.dg/c2x-float-2.c: Require inff effective-target.
* gcc.dg/c2x-float-11.c: New test.

22 months agolibstdc++: Tweak TSan annotations for std::atomic<shared_ptr<T>>
Jonathan Wakely [Thu, 15 Sep 2022 15:57:30 +0000 (16:57 +0100)]
libstdc++: Tweak TSan annotations for std::atomic<shared_ptr<T>>

Do not use the __tsan_mutex_not_static flag for annotation functions
where it's not a valid flag.  Also use the try_lock and try_lock_failed
flags to more precisely annotate the CAS loop used to acquire a lock.

libstdc++-v3/ChangeLog:

* include/bits/shared_ptr_atomic.h (_GLIBCXX_TSAN_MUTEX_PRE_LOCK):
Replace with ...
(_GLIBCXX_TSAN_MUTEX_TRY_LOCK): ... this, add try_lock flag.
(_GLIBCXX_TSAN_MUTEX_TRY_LOCK_FAILED): New macro using
try_lock_failed flag
(_GLIBCXX_TSAN_MUTEX_POST_LOCK): Rename to ...
(_GLIBCXX_TSAN_MUTEX_LOCKED): ... this.
(_GLIBCXX_TSAN_MUTEX_PRE_UNLOCK): Remove invalid flag.
(_GLIBCXX_TSAN_MUTEX_POST_UNLOCK): Remove invalid flag.
(_Sp_atomic::_Atomic_count::lock): Use new macros.

22 months agolibstdc++: Implement ranges::chunk_by_view from P2443R1
Patrick Palka [Thu, 15 Sep 2022 17:16:51 +0000 (13:16 -0400)]
libstdc++: Implement ranges::chunk_by_view from P2443R1

libstdc++-v3/ChangeLog:

* include/bits/ranges_algo.h (__adjacent_find_fn, adjacent_find):
Move to ...
* include/bits/ranges_util.h: ... here.
* include/std/ranges (chunk_by_view): Define.
(chunk_by_view::_Iterator): Define.
(__detail::__can_chunk_by_view): Define.
(_ChunkBy, chunk_by): Define.
* testsuite/std/ranges/adaptors/chunk_by/1.cc: New test.

22 months agolibstdc++: [_GLIBCXX_INLINE_VERSION] Fix test dg-prune-output
François Dumont [Wed, 14 Sep 2022 17:14:48 +0000 (19:14 +0200)]
libstdc++: [_GLIBCXX_INLINE_VERSION] Fix test dg-prune-output

libstdc++-v3/ChangeLog:

* testsuite/20_util/is_complete_or_unbounded/memoization_neg.cc:
Adapt dg-prune-output to _GLIBCXX_INLINE_VERSION mode.

22 months agolibstdc++: [_GLIBCXX_INLINE_VERSION] Cleanup gnu-versioned-namespace.ver
François Dumont [Wed, 14 Sep 2022 17:11:51 +0000 (19:11 +0200)]
libstdc++: [_GLIBCXX_INLINE_VERSION] Cleanup gnu-versioned-namespace.ver

Remove expressions for symbols in std::__detail::__8 namespace, they are obsolete since
version namespace applies only at std:: level, not at sub-levels.

libstdc++-v3/ChangeLog:

* config/abi/pre/gnu-versioned-namespace.ver: Remove obsolete std::__detail::__8
symbols.

22 months agoMAINTAINERS: Add myself to Write After Approval
Torbjörn SVENSSON [Thu, 15 Sep 2022 12:42:13 +0000 (14:42 +0200)]
MAINTAINERS: Add myself to Write After Approval

ChangeLog:

* MAINTAINERS (Write After Approval): Add myself.

22 months agotree-optimization/106922 - PRE and virtual operand translation
Richard Biener [Thu, 15 Sep 2022 11:33:23 +0000 (13:33 +0200)]
tree-optimization/106922 - PRE and virtual operand translation

PRE implicitely keeps virtual operands at the blocks incoming version
but the explicit updating point during PHI translation fails to trigger
when there are no PHIs at all in a block.  Later lazy updating then
fails because of a too lose block check.  A similar issues plagues
reference invalidation when checking the ANTIC_OUT to ANTIC_IN
translation.  The following fixes both and makes the lazy updating
work.

The diagnostic testcase unfortunately requires boost so the
testcase is the one I reduced for a missed optimization in PRE.
The testcase fails with -m32 on x86_64 because we optimize too
much before PRE which causes PRE to not trigger so we fail to
eliminate a full redundancy.  I'm going to open a separate bug
for this.  Hopefully the !lp64 selector is good enough.

PR tree-optimization/106922
* tree-ssa-pre.cc (translate_vuse_through_block): Only
keep the VUSE if its def dominates PHIBLOCK.
(prune_clobbered_mems): Rewrite logic so we check whether
a value dies in a block when the VUSE def doesn't dominate it.

* g++.dg/tree-ssa/pr106922.C: New testcase.

22 months agoMove void_list_node init to common code
Richard Biener [Wed, 14 Sep 2022 13:59:37 +0000 (15:59 +0200)]
Move void_list_node init to common code

All frontends replicate this, so move it.

gcc/
* tree.cc (build_common_tree_nodes): Initialize void_list_node
here.

gcc/ada/
* gcc-interface/trans.cc (gigi): Do not initialize void_list_node.

gcc/c-family/
* c-common.h (build_void_list_node): Remove.
* c-common.cc (c_common_nodes_and_builtins): Do not initialize
void_list_node.

gcc/c/
* c-decl.cc (build_void_list_node): Remove.

gcc/cp/
* decl.cc (cxx_init_decl_processing): Inline last
build_void_list_node call.
(build_void_list_node): Remove.

gcc/d/
* d-builtins.cc (d_build_c_type_nodes): Do not initialize
void_list_node.

gcc/fortran/
* f95-lang.cc (gfc_init_decl_processing): Do not initialize
void_list_node.

gcc/go/
* go-lang.cc (go_langhook_init): Do not initialize
void_list_node.

gcc/jit/
* dummy-frontend.cc (jit_langhook_init): Do not initialize
void_list_node.

gcc/lto/
* lto-lang.cc (lto_build_c_type_nodes): Do not initialize
void_list_node.

22 months agoFix c-c++-common/gomp/target-50.c test
Julian Brown [Thu, 15 Sep 2022 12:01:28 +0000 (12:01 +0000)]
Fix c-c++-common/gomp/target-50.c test

The expected scan dump output for this test will change after the
following patch is committed:

  https://gcc.gnu.org/pipermail/gcc-patches/2022-September/601558.html

But for now, this patch reverts to the old expected pattern so the test
passes. I will apply as obvious.

2022-09-15  Julian Brown  <julian@codesourcery.com>

gcc/testsuite/
* c-c++-common/gomp/target-50.c: Modify scan pattern.

22 months agoFix c-c++-common/goacc/mdc-2.c and g++.dg/goacc/mdc.C tests
Julian Brown [Thu, 15 Sep 2022 11:32:36 +0000 (11:32 +0000)]
Fix c-c++-common/goacc/mdc-2.c and g++.dg/goacc/mdc.C tests

These testsuite hunks got left attached to the wrong patch in the series
I just posted. I will apply as obvious.

2022-09-15  Julian Brown  <julian@codesourcery.com>

gcc/testsuite/
* c-c++-common/goacc/mdc-2.c: Update expected errors.
* g++.dg/goacc/mdc.C: Likewise.

22 months agors6000: Using pli(paddi) and rotate to build 64bit constants
Jiufu Guo [Mon, 5 Sep 2022 05:36:10 +0000 (13:36 +0800)]
rs6000: Using pli(paddi) and rotate to build 64bit constants

Hi,

Test cases are updated/added, and code is refined as the comments in the
review for previous version:
https://gcc.gnu.org/pipermail/gcc-patches/2022-September/600768.html

As mentioned in PR106550, since pli could support 34bits immediate, we could
use less instructions(3insn would be ok) to build 64bits constant with pli.

For example, for constant 0x020805006106003, we could generate it with:
asm code1:
pli 9,101736451 (0x6106003)
sldi 9,9,32
paddi 9,9, 2130000 (0x0208050)

or asm code2:
pli 10, 2130000
pli 9, 101736451
rldimi 9, 10, 32, 0

The asm code2 would be better.
This patch generates the asm code2 in split1 pass, this patch also supports
to generate asm code1 when splitter is only after RA.

This patch pass boostrap and regtest on ppc64. P10 testing is running.
Thanks for any comments!

BR,
Jeff(Jiufu)

PR target/106550

gcc/ChangeLog:

* config/rs6000/rs6000.cc (rs6000_emit_set_long_const): Use pli.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr106550.c: New test.
* gcc.target/powerpc/pr106550_1.c: New test.

22 months agoDaily bump.
GCC Administrator [Thu, 15 Sep 2022 00:17:35 +0000 (00:17 +0000)]
Daily bump.

22 months agolibstdc++: Add TSan annotations to std::atomic<shared_ptr<T>>
Jonathan Wakely [Wed, 14 Sep 2022 18:11:22 +0000 (19:11 +0100)]
libstdc++: Add TSan annotations to std::atomic<shared_ptr<T>>

This adds annotations to std::atomic<shared_ptr<T>> to enable TSan to
understand the custom locking. Without this, TSan reports data races for
accesses to the _M_ptr member, even though those are correctly
synchronized using atomic operations on the tagged pointer.

libstdc++-v3/ChangeLog:

* include/bits/shared_ptr_atomic.h (_GLIBCXX_TSAN_MUTEX_DESTROY)
(_GLIBCXX_TSAN_MUTEX_PRE_LOCK, _GLIBCXX_TSAN_MUTEX_POST_LOCK)
(_GLIBCXX_TSAN_MUTEX_PRE_UNLOCK, _GLIBCXX_TSAN_MUTEX_POST_UNLOCK)
(_GLIBCXX_TSAN_MUTEX_PRE_SIGNAL, _GLIBCXX_TSAN_MUTEX_POST_SIGNAL):
Define macros for TSan annotation functions.
(_Sp_atomic::_Atomic_count): Add annotations.

22 months agolibstdc++: Add missing <new> header to <bits/stl_tempbuf.h>
Jonathan Wakely [Wed, 14 Sep 2022 14:52:44 +0000 (15:52 +0100)]
libstdc++: Add missing <new> header to <bits/stl_tempbuf.h>

This is needed for std::nothrow and the nothrow operator new overload,
so should be included explicitly.

libstdc++-v3/ChangeLog:

* include/bits/stl_tempbuf.h: Include <new>.

22 months agolibstdc++: Add comment to 17_intro/names.cc test
Jonathan Wakely [Wed, 14 Sep 2022 13:16:25 +0000 (14:16 +0100)]
libstdc++: Add comment to 17_intro/names.cc test

libstdc++-v3/ChangeLog:

* testsuite/17_intro/names.cc: Explain why poison pragma can't
be used.

22 months agolibstdc++: Add assertion to std::promise::set_exception (LWG 2276)
Jonathan Wakely [Wed, 14 Sep 2022 13:03:19 +0000 (14:03 +0100)]
libstdc++: Add assertion to std::promise::set_exception (LWG 2276)

Without this assertion, the shared state is made ready, but contains
neither a value nor an exception. Add an assertion to prevent users from
accessing a value that was never initialized in the shared state.

libstdc++-v3/ChangeLog:

* include/std/future
(_State_baseV2::__setter(exception_ptr&, promise&)): Add
assertion for LWG 2276 precondition.
* testsuite/30_threads/promise/members/set_exception_neg.cc:
New test.

22 months agolibstdc++: Document LWG 1203 API change in manual
Jonathan Wakely [Wed, 14 Sep 2022 12:48:25 +0000 (13:48 +0100)]
libstdc++: Document LWG 1203 API change in manual

libstdc++-v3/ChangeLog:

* doc/xml/manual/intro.xml: Document LWG 1203.
* doc/html/*: Regenerate.

22 months agolibstdc++: Add pretty printer for std::stringstreams
Philipp Fent [Tue, 6 Sep 2022 21:24:29 +0000 (23:24 +0200)]
libstdc++: Add pretty printer for std::stringstreams

To display (o-,i-)stringstreams in the common case, we just print the
underlying stringbuf, without the many ios_base members. In the
unconventional case that the underlying streambuf was redirected, we
report the redirected target.

Signed-off-by: Philipp Fent <fent@in.tum.de>
libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/printers.py (access_streambuf_ptrs):
New helper function.
(StdStringBufPrinter, StdStringStreamPrinter): New printers.
(build_libstdcxx_dictionary): Register stringstream printers.
* testsuite/libstdc++-prettyprinters/debug.cc: Check string
streams.
* testsuite/libstdc++-prettyprinters/simple.cc: Likewise.
* testsuite/libstdc++-prettyprinters/simple11.cc: Likewise.

22 months agofrange: add both zeros to ranges when there's the possiblity of equality.
Aldy Hernandez [Wed, 14 Sep 2022 06:11:54 +0000 (08:11 +0200)]
frange: add both zeros to ranges when there's the possiblity of equality.

Every time there's equality at play, we must be careful that any
equality with zero matches both -0.0 and +0.0 when honoring signed
zeros.

We were doing this correctly for the == and != op1_range operators
(albeit inefficiently), but aren't doing it at all when building >=
and <=.  This fixes the oversight.

There is change in functionality here for the build_* functions.

This is the last "simple" patch I submit before overhauling NAN and
sign tracking.  And that will likely be after Cauldron because it will need
further testing (lapack, ppc64le, -ffinite-math-only, etc).

Regstrapped on x86-64 Linux, plus I ran selftests for
-ffinite-math-only.

gcc/ChangeLog:

* range-op-float.cc (frange_add_zeros): New.
(build_le): Call frange_add_zeros.
(build_ge): Same.
(foperator_equal::op1_range): Same.
(foperator_not_equal::op1_range): Same.

22 months agoPass full range to build_* in range-op-float.cc
Aldy Hernandez [Wed, 14 Sep 2022 06:01:16 +0000 (08:01 +0200)]
Pass full range to build_* in range-op-float.cc

The build_<relop> helper functions in range-op-float.cc take the
actual value from the operand's endpoint, but this value could be
deduced from the operand itself therefore cleaning up the call site.
This also reduces the potential of mistakenly passing the wrong bound.

No functional changes.

Regstrapped on x86-64 Linux, plus I ran selftests for
-ffinite-math-only.

gcc/ChangeLog:

* range-op-float.cc (build_le): Accept frange instead of number.
(build_lt): Same.
(build_ge): Same.
(build_gt): Same.
(foperator_lt::op1_range): Pass full range to build_*.
(foperator_lt::op2_range): Same.
(foperator_le::op1_range): Same.
(foperator_le::op2_range): Same.
(foperator_gt::op1_range): Same.
(foperator_gt::op2_range): Same.
(foperator_ge::op1_range): Same.
(foperator_ge::op2_range): Same.

22 months agoUse frange::set_nan() from the generic frange::set().
Aldy Hernandez [Wed, 14 Sep 2022 06:29:54 +0000 (08:29 +0200)]
Use frange::set_nan() from the generic frange::set().

This patch cleans up the frange::set() code by passing all things NAN
to frange::set_nan().

No functional changes.

Regstrapped on x86-64 Linux, plus I ran selftests for
-ffinite-math-only.

gcc/ChangeLog:

* value-range.cc (frange::set): Use set_nan.
* value-range.h (frange::set_nan): Inline code originally in
set().

22 months agoProvide cleaner set_nan(), clear_nan(), and update_nan() methods.
Aldy Hernandez [Wed, 14 Sep 2022 04:58:35 +0000 (06:58 +0200)]
Provide cleaner set_nan(), clear_nan(), and update_nan() methods.

set_* has a very specific meaning for irange's and friends.  Methods
prefixed with set_* are setters clobbering the existing range.  As
such, the current set_nan() method is confusing in that it's not
actually setting a range to a NAN, but twiddling the NAN flags for an
existing frange.

This patch replaces set_nan() with an update_nan() to set the flag,
and clear_nan() to clear it.  This makes the code clearer, and though
the confusing tristate is still there, it will be removed in upcoming
patches.

Also, there is now an actual set_nan() method to set the range to a
NAN.  This replaces two out of class functions doing the same thing.
In future patches I will also add the ability to create a NAN with a
specific sign, but doing so now would be confusing because we're not
tracking NAN signs.

We should also submit set_signbit to the same fate, but it's about to
get removed.

No functional changes.

Regstrapped on x86-64 Linux, plus I ran selftests for
-ffinite-math-only.

gcc/ChangeLog:

* range-op-float.cc (frange_set_nan): Remove.
(build_lt): Use set_nan, update_nan, clear_nan.
(build_gt): Same.
(foperator_equal::op1_range): Same.
(foperator_not_equal::op1_range): Same.
(foperator_lt::op1_range): Same.
(foperator_lt::op2_range): Same.
(foperator_le::op1_range): Same.
(foperator_le::op2_range): Same.
(foperator_gt::op1_range): Same.
(foperator_gt::op2_range): Same.
(foperator_ge::op1_range): Same.
(foperator_ge::op2_range): Same.
(foperator_unordered::op1_range): Same.
(foperator_ordered::op1_range): Same.
* value-query.cc (range_query::get_tree_range): Same.
* value-range.cc (frange::set_nan): Same.
(frange::update_nan): Same.
(frange::union_): Same.
(frange::intersect): Same.
(range_tests_nan): Same.
(range_tests_signed_zeros): Same.
(range_tests_signbit): Same.
(range_tests_floats): Same.
* value-range.h (class frange): Add update_nan and clear_nan.
(frange::set_nan): New.

22 months agoMinor fixes to frange.
Aldy Hernandez [Wed, 14 Sep 2022 05:49:55 +0000 (07:49 +0200)]
Minor fixes to frange.

Following are a series of cleanups to the frange code in preparation
for a much more invasive patch rewriting the NAN and sign tracking
bits.  Please be patient, as I'm trying to break everything up into
small chunks instead of dropping a mondo patch removing the NAN and
sign tristate handling.

No functional changes.

Regstrapped on x86-64 Linux, plus I ran selftests for
-ffinite-math-only.

gcc/ChangeLog:

* value-query.cc (range_query::get_tree_range): Remove check for overflow.
* value-range-pretty-print.cc (vrange_printer::visit): Move read
of type until after undefined_p is checked.
* value-range.cc (frange::set): Remove asserts for REAL_CST.
(frange::contains_p): Tidy up.
(range_tests_nan):  Add comment.
* value-range.h (frange::type): Check for undefined_p.
(frange::set_undefined): Remove set of endpoints.

22 months agoOpenMP/OpenACC: mapping group list-handling improvements
Julian Brown [Tue, 6 Sep 2022 22:34:38 +0000 (22:34 +0000)]
OpenMP/OpenACC: mapping group list-handling improvements

This patch adjusts OpenMP/OpenACC clause list handling in a couple of
places, in preparation for the following mapping-clause expansion rework
patch. Firstly mapping groups are removed as a whole in the C and C++
front-ends when an error is detected, which avoids leaving "badly-formed"
mapping clause groups in the list.

Secondly, reindexing of the omp_mapping_group hashmap (during
omp_build_struct_sibling_lists) has been reimplemented, fixing some
tricky corner-cases where mapping groups are removed from a list at the
same time as it is being reordered.

Thirdly, code to check if a different clause on the same directive maps
the whole of a struct that we have a component mapping for (for example)
has been outlined, removing a bit of code duplication.

2022-09-13  Julian Brown  <julian@codesourcery.com>

gcc/
* gimplify.cc (omp_group_last): Allow GOMP_MAP_ATTACH_DETACH after
GOMP_MAP_STRUCT (for reindexing).
(omp_gather_mapping_groups): Reimplement using...
(omp_gather_mapping_groups_1): This new function.  Stop processing at
GATHER_SENTINEL.
(omp_group_base): Allow GOMP_MAP_TO_PSET without any following node.
(omp_index_mapping_groups): Reimplement using...
(omp_index_mapping_groups_1): This new function.  Handle
REINDEX_SENTINEL.
(omp_reindex_mapping_groups, omp_mapped_by_containing_struct): New
functions.
(omp_tsort_mapping_groups_1): Adjust handling of base group being the
same as current group.  Use omp_mapped_by_containing_struct.
(omp_build_struct_sibling_lists): Use omp_mapped_by_containing_struct
and omp_reindex_mapping_groups.  Robustify group deletion for reordered
lists.
(gimplify_scan_omp_clauses): Update calls to
omp_build_struct_sibling_lists.

gcc/c/
* c-typeck.cc (c_finish_omp_clauses): Remove whole mapping node group
on error.

gcc/cp/
* semantics.cc (finish_omp_clauses): Likewise.

22 months agoOpenMP/OpenACC struct sibling list gimplification extension and rework
Julian Brown [Wed, 16 Feb 2022 17:15:39 +0000 (09:15 -0800)]
OpenMP/OpenACC struct sibling list gimplification extension and rework

This patch refactors struct sibling-list processing in gimplify.cc, and
adjusts some related mapping-clause processing in the Fortran FE and
omp-low.cc accordingly.

2022-09-13  Julian Brown  <julian@codesourcery.com>

gcc/fortran/
* trans-openmp.cc (gfc_trans_omp_clauses): Don't create
GOMP_MAP_TO_PSET mappings for class metadata, nor GOMP_MAP_POINTER
mappings for POINTER_TYPE_P decls.

gcc/
* gimplify.cc (gimplify_omp_var_data): Remove GOVD_MAP_HAS_ATTACHMENTS.
(GOMP_FIRSTPRIVATE_IMPLICIT): Renumber.
(insert_struct_comp_map): Refactor function into...
(build_omp_struct_comp_nodes): This new function.  Remove list handling
and improve self-documentation.
(extract_base_bit_offset): Remove BASE_REF, OFFSETP parameters.  Move
code to strip outer parts of address out of function, but strip no-op
conversions.
(omp_mapping_group): Add DELETED field for use during reindexing.
(omp_strip_components_and_deref, omp_strip_indirections): New functions.
(omp_group_last, omp_group_base): Add GOMP_MAP_STRUCT handling.
(omp_gather_mapping_groups): Initialise DELETED field for new groups.
(omp_index_mapping_groups): Notice DELETED groups when (re)indexing.
(omp_siblist_insert_node_after, omp_siblist_move_node_after,
omp_siblist_move_nodes_after, omp_siblist_move_concat_nodes_after): New
helper functions.
(omp_accumulate_sibling_list): New function to build up GOMP_MAP_STRUCT
node groups for sibling lists. Outlined from gimplify_scan_omp_clauses.
(omp_build_struct_sibling_lists): New function.
(gimplify_scan_omp_clauses): Remove struct_map_to_clause,
struct_seen_clause, struct_deref_set.  Call
omp_build_struct_sibling_lists as pre-pass instead of handling sibling
lists in the function's main processing loop.
(gimplify_adjust_omp_clauses_1): Remove GOVD_MAP_HAS_ATTACHMENTS
handling, unused now.
* omp-low.cc (scan_sharing_clauses): Handle pointer-type indirect
struct references, and references to pointers to structs also.

gcc/testsuite/
* g++.dg/goacc/member-array-acc.C: New test.
* g++.dg/gomp/member-array-omp.C: New test.
* g++.dg/gomp/target-3.C: Update expected output.
* g++.dg/gomp/target-lambda-1.C: Likewise.
* g++.dg/gomp/target-this-2.C: Likewise.
* c-c++-common/goacc/deep-copy-arrayofstruct.c: Move test from here.
* c-c++-common/gomp/target-50.c: New test.

libgomp/
* testsuite/libgomp.oacc-c-c++-common/deep-copy-15.c: New test.
* testsuite/libgomp.oacc-c-c++-common/deep-copy-16.c: New test.
* testsuite/libgomp.oacc-c++/deep-copy-17.C: New test.
* testsuite/libgomp.oacc-c-c++-common/deep-copy-arrayofstruct.c: Move
test to here, make "run" test.

22 months agotree-optimization/106938 - cleanup abnormal edges after inlining
Richard Biener [Wed, 14 Sep 2022 11:53:56 +0000 (13:53 +0200)]
tree-optimization/106938 - cleanup abnormal edges after inlining

After inlining and IPA transforms we run fixup_cfg to fixup CFG
effects in other functions.  But that fails to clean abnormal
edges from non-pure/const calls which might no longer be necessary
when ->calls_setjmp is false.  The following ensures this happens
and refactors things so we call EH/abnormal cleanup only on the
last stmt in a block.

PR tree-optimization/106938
* tree-cfg.cc (execute_fixup_cfg): Purge dead abnormal
edges for all last stmts in a block.  Do EH cleanup
only on the last stmt in a block.

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

22 months ago[PR106936] Remove assert from get_value_range.
Aldy Hernandez [Wed, 14 Sep 2022 12:48:36 +0000 (14:48 +0200)]
[PR106936] Remove assert from get_value_range.

This assert was put here to make sure that the legacy
get_value_range() wasn't being called on stuff that legacy couldn't
handle (floats, etc), because the result would ultimately be copied
into a value_range_equiv.

In this case, simplify_casted_cond() is calling it on an offset_type
which is neither an integer nor a pointer.  However, range_of_expr
happily punted on it, and then the fallthru code set the range to
VARYING.  As value_range_equiv can store VARYING types of anything
(including types it can't handle), this is fine.

The easiest thing to do is remove the assert.  If someone from the non
legacy world tries to get a non integer/pointer range here, it's going
to blow up anyhow because the temporary in get_value_range is
int_range_max.

PR tree-optimization/106936

gcc/ChangeLog:

* value-query.cc (range_query::get_value_range): Remove assert.

gcc/testsuite/ChangeLog:

* g++.dg/tree-ssa/pr106936.C: New test.

22 months agoDrop unused variable
Jan-Benedict Glaw [Wed, 14 Sep 2022 12:16:52 +0000 (14:16 +0200)]
Drop unused variable

With the "STABS: remove -gstabs and -gxcoff functionality" patch, a left-over
`start` variable remained unused:

/usr/lib/gcc-snapshot/bin/g++  -fno-PIE -c   -g -O2   -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE   -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common  -DHAVE_CONFIG_H -I. -I. -I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -I../../gcc/gcc/../libcody  -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc/gcc/../libbacktrace   -o mips.o -MT mips.o -MMD -MP -MF ./.deps/mips.TPo ../../gcc/gcc/config/mips/mips.cc
../../gcc/gcc/config/mips/mips.cc: In function 'void mips_option_override()':
../../gcc/gcc/config/mips/mips.cc:20021:10: error: unused variable 'start' [-Werror=unused-variable]
20021 |   int i, start, regno, mode;
      |          ^~~~~

2022-09-14  Jan-Benedict Glaw  <jbglaw@lug-owl.de>

gcc/
* config/mips/mips.cc (mips_option_override): Drop unused variable.

22 months agoOpenMP 5.0: Clause ordering for OpenMP 5.0 (topological sorting by base pointer)
Julian Brown [Fri, 30 Jul 2021 16:15:18 +0000 (09:15 -0700)]
OpenMP 5.0: Clause ordering for OpenMP 5.0 (topological sorting by base pointer)

This patch reimplements the omp_target_reorder_clauses function in
anticipation of supporting "deeper" struct mappings (that is, with
several structure dereference operators, or similar).

The idea is that in place of the (possibly quadratic) algorithm in
omp_target_reorder_clauses that greedily moves clauses containing
addresses that are subexpressions of other addresses before those other
addresses, we employ a topological sort algorithm to calculate a proper
order for map clauses. This should run in linear time, and hopefully
handles degenerate cases where multiple "levels" of indirect accesses
are present on a given directive.

The new method also takes care to keep clause groups together, addressing
the concerns raised in:

  https://gcc.gnu.org/pipermail/gcc-patches/2021-May/570501.html

To figure out if some given clause depends on a base pointer in another
clause, we strip off the outer layers of the address expression, and check
(via a tree_operand_hash hash table we have built) if the result is a
"base pointer" as defined in OpenMP 5.0 (1.2.6 Data Terminology). There
are some subtleties involved, however:

 - We must treat MEM_REF with zero offset the same as INDIRECT_REF.
   This should probably be fixed in the front ends instead so we always
   use a canonical form (probably INDIRECT_REF). The following patch
   shows one instance of the problem, but there may be others:

   https://gcc.gnu.org/pipermail/gcc-patches/2021-May/571382.html

 - Mapping a whole struct implies mapping each of that struct's
   elements, which may be base pointers. Because those base pointers
   aren't necessarily explicitly referenced in the directive in question,
   we treat the whole-struct mapping as a dependency instead.

2022-09-13  Julian Brown  <julian@codesourcery.com>

gcc/
* gimplify.cc (is_or_contains_p, omp_target_reorder_clauses): Delete
functions.
(omp_tsort_mark): Add enum.
(omp_mapping_group): Add struct.
(debug_mapping_group, omp_get_base_pointer, omp_get_attachment,
omp_group_last, omp_gather_mapping_groups, omp_group_base,
omp_index_mapping_groups, omp_containing_struct,
omp_tsort_mapping_groups_1, omp_tsort_mapping_groups,
omp_segregate_mapping_groups, omp_reorder_mapping_groups): New
functions.
(gimplify_scan_omp_clauses): Call above functions instead of
omp_target_reorder_clauses, unless we've seen an error.
* omp-low.cc (scan_sharing_clauses): Avoid strict test if we haven't
sorted mapping groups.

gcc/testsuite/
* g++.dg/gomp/target-lambda-1.C: Adjust expected output.
* g++.dg/gomp/target-this-3.C: Likewise.
* g++.dg/gomp/target-this-4.C: Likewise.

22 months agotestsuite/s390: Add -mzarch to ifcvt test cases.
Robin Dapp [Tue, 6 Sep 2022 06:56:04 +0000 (08:56 +0200)]
testsuite/s390: Add -mzarch to ifcvt test cases.

Add missing -mzarch to ifcvt test cases.

gcc/testsuite/ChangeLog:

* gcc.target/s390/ifcvt-one-insn-bool.c: Add -mzarch.
* gcc.target/s390/ifcvt-one-insn-char.c: Dito.
* gcc.target/s390/ifcvt-two-insns-bool.c: Dito.
* gcc.target/s390/ifcvt-two-insns-int.c: Dito.
* gcc.target/s390/ifcvt-two-insns-long.c: Add -mzarch and change
long into long long.

22 months agotestsuite/s390: Fix vperm-rev testcases.
Robin Dapp [Wed, 31 Aug 2022 07:21:45 +0000 (09:21 +0200)]
testsuite/s390: Fix vperm-rev testcases.

Add -save-temps and tabs for matching.

gcc/testsuite/ChangeLog:

* gcc.target/s390/vector/vperm-rev-z14.c: Add -save-temps.
* gcc.target/s390/vector/vperm-rev-z15.c: Likewise.

22 months agoDisallow pointer operands for |, ^ and partly & [PR106878]
Jakub Jelinek [Wed, 14 Sep 2022 10:36:36 +0000 (12:36 +0200)]
Disallow pointer operands for |, ^ and partly & [PR106878]

My change to match.pd (that added the two simplifications this patch
touches) results in more |/^/& assignments with pointer arguments,
but since r12-1608 we reject pointer operands for BIT_NOT_EXPR.

Disallowing them for BIT_NOT_EXPR and allowing for BIT_{IOR,XOR,AND}_EXPR
leads to a match.pd maintainance nightmare (see one of the patches in the
PR), so either we want to allow pointer operand on BIT_NOT_EXPR (but then
we run into issues e.g. with the ranger which expects it can emulate
BIT_NOT_EXPR ~X as - 1 - X which doesn't work for pointers which don't
support MINUS_EXPR), or the following patch disallows pointer arguments
for all of BIT_{IOR,XOR,AND}_EXPR with the exception of BIT_AND_EXPR
with INTEGER_CST last operand (for simpler pointer realignment).
I had to tweak one reassoc optimization and the two match.pd
simplifications.

2022-09-14  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/106878
* tree-cfg.cc (verify_gimple_assign_binary): Disallow pointer,
reference or OFFSET_TYPE BIT_IOR_EXPR, BIT_XOR_EXPR or, unless
the second argument is INTEGER_CST, BIT_AND_EXPR.
* match.pd ((type) X op CST -> (type) (X op ((type-x) CST)),
(type) (((type2) X) op Y) -> (X op (type) Y)): Punt for
POINTER_TYPE_P or OFFSET_TYPE.
* tree-ssa-reassoc.cc (optimize_range_tests_cmp_bitwise): For
pointers cast them to pointer sized integers first.

* gcc.c-torture/compile/pr106878.c: New test.

22 months agotree-optimization/106934 - avoid BIT_FIELD_REF of bitfields
Richard Biener [Wed, 14 Sep 2022 07:00:35 +0000 (09:00 +0200)]
tree-optimization/106934 - avoid BIT_FIELD_REF of bitfields

The following avoids creating BIT_FIELD_REF of bitfields in
update-address-taken.  The patch doesn't implement punning to
a full precision integer type but leaves a comment according to
that.

PR tree-optimization/106934
* tree-ssa.cc (non_rewritable_mem_ref_base): Avoid BIT_FIELD_REFs
of bitfields.
(maybe_rewrite_mem_ref_base): Likewise.

* gfortran.dg/pr106934.f90: New testcase.

22 months agoCheck another epilog variable peeling case in vectorizable_nonlinear_induction.
liuhongt [Tue, 13 Sep 2022 05:25:24 +0000 (13:25 +0800)]
Check another epilog variable peeling case in vectorizable_nonlinear_induction.

in vectorizable_nonlinear_induction, r13-2503-gc13223b790bbc5 prevent variable peeling by
only checking LOOP_VINFO_MASK_SKIP_NITERS (loop_vinfo). But when
"!vect_use_loop_mask_for_alignment_p (loop_vinfo) &&
LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) < 0", vectorizer will
still do variable peeling for epilog, and it hits gcc_assert in
vect_peel_nonlinear_iv_init.

gcc/ChangeLog:

PR tree-optimization/106905
* tree-vect-loop.cc (vectorizable_nonlinear_induction): Return
false when !vect_use_loop_mask_for_alignment_p (loop_vinfo) &&
LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) < 0.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr106905.c: New test.
* gcc.target/ia64/pr106905.c: New test.

22 months agotestsuite: gluefile file need to be prefixed
Torbjörn SVENSSON [Wed, 14 Sep 2022 05:22:27 +0000 (07:22 +0200)]
testsuite: gluefile file need to be prefixed

When the status wrapper is used, the gluefile need to be prefixed with
-Wl, in order for the test cases to have the dump files with the
expected names.

2022-09-14  Torbjörn SVENSSON  <torbjorn.svensson@foss.st.com>

gcc/testsuite/
PR target/95720
* lib/g++.exp: Moved gluefile block to after flags have been
  prefixed for the target_compile call.
* lib/gcc.exp: Likewise.
* lib/wrapper.exp: Reset adjusted state flag.

Co-Authored-By: Yvan ROUX <yvan.roux@foss.st.com>
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
22 months agoDaily bump.
GCC Administrator [Wed, 14 Sep 2022 00:18:07 +0000 (00:18 +0000)]
Daily bump.

22 months agoPR target/106877: Robustify reg-stack to malformed asm.
Roger Sayle [Tue, 13 Sep 2022 18:49:20 +0000 (19:49 +0100)]
PR target/106877: Robustify reg-stack to malformed asm.

This patch resolves PR target/106877 an ICE-on-invalid inline-asm
regression.  An innocent upstream change means that the test case
from PR inline-asm/84683 now hits a different assert in reg-stack.cc's
move_for_stack_reg.  Fixed by duplicating Jakub's solution to PR 84683
https://gcc.gnu.org/pipermail/gcc-patches/2018-March/495193.html at
this second (similar) gcc_assert.

2022-09-13  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
PR target/106877
* reg-stack.cc (move_for_stack_reg): Check for any_malformed_asm
in gcc_assert.

gcc/testsuite/ChangeLog
PR target/106877
* g++.dg/ext/pr106877.C: New test case.

22 months agolibgomp: Appease some static analyzers [PR106906]
Jakub Jelinek [Tue, 13 Sep 2022 17:00:02 +0000 (19:00 +0200)]
libgomp: Appease some static analyzers [PR106906]

While icv_addr[1] = false; assignments where icv_addr has void *
element type is correct and matches how it is used (in those cases
the void * pointer is then cast to bool and used that way), there is no
reason not to add explicit (void *) casts there which are there already
for (void *) true.  And, there is in fact even no point in actually
doing those stores at all because we set that pointer to NULL a few
lines earlier.  So, this patch adds the explicit casts and then
comments those out to show intent.

2022-09-13  Jakub Jelinek  <jakub@redhat.com>

PR libgomp/106906
* env.c (get_icv_member_addr): Cast false to void * before assigning
it to icv_addr[1], and comment the whole assignment out.

22 months agolibstdc++: Implement ranges::slide_view from P2442R1
Patrick Palka [Tue, 13 Sep 2022 15:18:16 +0000 (11:18 -0400)]
libstdc++: Implement ranges::slide_view from P2442R1

This also implements the LWG 3711 and 3712 changes to slide_view.

libstdc++-v3/ChangeLog:

* include/std/ranges (__detail::__slide_caches_nothing): Define.
(__detail::__slide_caches_last): Define.
(__detail::__slide_caches_first): Define.
(slide_view): Define.
(enable_borrowed_range<slide_view>): Define.
(slide_view::_Iterator): Define.
(slide_view::_Sentinel): Define.
(views::__detail::__can_slide_view): Define.
(views::_Slide, views::slide): Define.
* testsuite/std/ranges/adaptors/slide/1.cc: New test.

22 months agolibstdc++: Implement ranges::chunk_view from P2442R1
Patrick Palka [Tue, 13 Sep 2022 15:18:14 +0000 (11:18 -0400)]
libstdc++: Implement ranges::chunk_view from P2442R1

This also implements the LWG 3707, 3710 and 3712 changes to chunk_view.

libstdc++-v3/ChangeLog:

* include/std/ranges (__detail::__div_ceil): Define.
(chunk_view): Define.
(chunk_view::_OuterIter): Define.
(chunk_view::_OuterIter::value_type): Define.
(chunk_view::_InnerIter): Define.
(chunk_view<_Vp>): Define partial specialization for forward
ranges.
(enable_borrowed_range<chunk_view>): Define.
(chunk_view<_Vp>::_Iterator): Define.
(views::__detail::__can_chunk_view): Define.
(views::_Chunk, views::chunk): Define.
* testsuite/std/ranges/adaptors/chunk/1.cc: New test.

22 months agolibstdc++: Implement LWG 3569 changes to join_view::_Iterator
Patrick Palka [Tue, 13 Sep 2022 15:18:07 +0000 (11:18 -0400)]
libstdc++: Implement LWG 3569 changes to join_view::_Iterator

libstdc++-v3/ChangeLog:

* include/std/ranges (join_view::_Iterator::_M_satisfy):
Adjust resetting _M_inner as per LWG 3569.
(join_view::_Iterator::_M_inner): Wrap in std::optional
as per LWG 3569.
(join_view::_Iterator::_Iterator): Relax constraints as
per LWG 3569.
(join_view::_Iterator::operator*): Adjust as per LWG 3569.
(join_view::_Iterator::operator->): Likewise.
(join_view::_Iterator::operator++): Likewise.
(join_view::_Iterator::operator--): Likewise.
(join_view::_Iterator::iter_move): Likewise.
(join_view::_Iterator::iter_swap): Likewise.
* testsuite/std/ranges/adaptors/join.cc (test14): New test.

22 months agolibstdc++: Avoid -Wparentheses warning with debug iterators
Patrick Palka [Tue, 13 Sep 2022 14:41:47 +0000 (10:41 -0400)]
libstdc++: Avoid -Wparentheses warning with debug iterators

I noticed compiling e.g. std/ranges/adaptors/join.cc with
-D_GLIBCXX_DEBUG -Wsystem-headers -Wall gives the warning:

  gcc/libstdc++-v3/include/debug/safe_iterator.h:477:9: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]

libstdc++-v3/ChangeLog:

* include/debug/safe_iterator.h (_GLIBCXX_DEBUG_VERIFY_OPERANDS):
Add parentheses to avoid -Wparentheses warning.

22 months agoc++: remove single-parameter version of mark_used
Patrick Palka [Tue, 13 Sep 2022 14:18:58 +0000 (10:18 -0400)]
c++: remove single-parameter version of mark_used

gcc/cp/ChangeLog:

* cp-tree.h (mark_used): Remove single-parameter overload.  Add
default argument to the two-parameter overload.
* decl2.cc (mark_used): Likewise.

22 months agoc++: two-parameter version of cxx_constant_value
Patrick Palka [Tue, 13 Sep 2022 14:01:29 +0000 (10:01 -0400)]
c++: two-parameter version of cxx_constant_value

Since some callers need the complain parameter but not the object
parameter, let's introduce and use an overload of cxx_constant_value
that omits the latter.

gcc/cp/ChangeLog:

* cp-tree.h (cxx_constant_value): Define two-parameter version
that omits the object parameter.
* decl.cc (build_explicit_specifier): Omit NULL_TREE object
argument to cxx_constant_value.
* except.cc (build_noexcept_spec): Likewise.
* pt.cc (expand_integer_pack): Likewise.
(fold_targs_r): Likewise.
* semantics.cc (finish_if_stmt_cond): Likewise.

22 months agoc++: some missing-SFINAE fixes
Patrick Palka [Tue, 13 Sep 2022 13:48:04 +0000 (09:48 -0400)]
c++: some missing-SFINAE fixes

It looks like we aren't respecting SFINAE for:

  * an invalid/non-constant conditional explicit-specifier
  * a non-constant conditional noexcept-specifier
  * a non-constant argument to __integer_pack

This patch fixes these in the usual way, by passing complain and
propagating error_mark_node appropriately.

gcc/cp/ChangeLog:

* decl.cc (build_explicit_specifier): Pass complain to
cxx_constant_value.
* except.cc (build_noexcept_spec): Likewise.
* pt.cc (expand_integer_pack): Likewise.
(tsubst_function_decl): Propagate error_mark_node returned
from build_explicit_specifier.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1z/noexcept-type26.C: New test.
* g++.dg/cpp2a/explicit19.C: New test.
* g++.dg/ext/integer-pack6.C: New test.

22 months agoRevert "xtensa: Implement new target hook: TARGET_CONSTANT_OK_FOR_CPROP_P"
Max Filippov [Tue, 13 Sep 2022 11:28:16 +0000 (04:28 -0700)]
Revert "xtensa: Implement new target hook: TARGET_CONSTANT_OK_FOR_CPROP_P"

This reverts commit 936efcac733fe49e5ea9e636403e5941f24ff1b3.

22 months agors6000: Fix the check of bif argument number [PR104482]
Kewen Lin [Tue, 13 Sep 2022 09:14:23 +0000 (04:14 -0500)]
rs6000: Fix the check of bif argument number [PR104482]

As PR104482 shown, it's one regression about the handlings when
the argument number is more than the one of built-in function
prototype.  The new bif support only catches the case that the
argument number is less than the one of function prototype, but
it misses the case that the argument number is more than the one
of function prototype.  Because it uses "n != expected_args",
n is updated in

   for (n = 0; !VOID_TYPE_P (TREE_VALUE (fnargs)) && n < nargs;
        fnargs = TREE_CHAIN (fnargs), n++)

, it's restricted to be less than or equal to expected_args with
the guard !VOID_TYPE_P (TREE_VALUE (fnargs)), so it's wrong.

The fix is to use nargs instead, also move the checking hunk's
location ahead to avoid useless further scanning when the counts
mismatch.

PR target/104482

gcc/ChangeLog:

* config/rs6000/rs6000-c.cc (altivec_resolve_overloaded_builtin): Fix
the equality check for argument number, and move this hunk ahead.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr104482.c: New test.

22 months agors6000: Handle unresolved overloaded builtin [PR105485]
Kewen.Lin [Tue, 13 Sep 2022 09:13:59 +0000 (04:13 -0500)]
rs6000: Handle unresolved overloaded builtin [PR105485]

PR105485 exposes that new builtin function framework doesn't handle
unresolved overloaded builtin function well.  With new builtin
function support, we don't have builtin info for any overloaded
rs6000_gen_builtins enum, since they are expected to be resolved to
one specific instance.  So when function rs6000_gimple_fold_builtin
faces one unresolved overloaded builtin, the access for builtin info
becomes out of bound and gets ICE then.

We should not try to fold one unresolved overloaded builtin there
and as the previous support we should emit one error message during
expansion phase like "unresolved overload for builtin ...".

PR target/105485

gcc/ChangeLog:

* config/rs6000/rs6000-builtin.cc (rs6000_gimple_fold_builtin): Add
the handling for unresolved overloaded builtin function.
(rs6000_expand_builtin): Likewise.

gcc/testsuite/ChangeLog:

* g++.target/powerpc/pr105485.C: New test.

22 months agors6000: Suggest unroll factor for loop vectorization
Kewen Lin [Tue, 13 Sep 2022 09:13:10 +0000 (04:13 -0500)]
rs6000: Suggest unroll factor for loop vectorization

Commit r12-6679-g7ca1582ca60dc8 made vectorizer accept one
unroll factor to be applied to vectorization factor when
vectorizing the main loop, it would be suggested by target
when doing costing.

This patch introduces function determine_suggested_unroll_factor
for rs6000 port, to make it be able to suggest the unroll factor
for a given loop being vectorized.  Referring to aarch64 port
and basing on the analysis on SPEC2017 performance evaluation
results, it mainly considers these aspects:
  1) unroll option and pragma which can disable unrolling for the
     given loop;
  2) simple hardware resource model with issued non memory access
     vector insn per cycle;
  3) aggressive heuristics when iteration count is unknown:
     - reduction case to break cross iteration dependency;
     - emulated gather load;
  4) estimated iteration count when iteration count is unknown;

With this patch, SPEC2017 performance evaluation results on
Power8/9/10 are listed below (speedup pct.):

  * Power10
    - O2: all are neutral (excluding some noises);
    - Ofast: 510.parest_r +6.67%, the others are neutral
             (use ... for the followings);
    - Ofast + unroll: 510.parest_r +5.91%, ...
    - Ofast + LTO + PGO: 510.parest_r +3.00%, ...
    - Ofast + cheap vect cost: 510.parest_r +6.23%, ...
    - Ofast + very-cheap vect cost: all are neutral;

  * Power9
    - Ofast: 510.parest_r +8.73%, 538.imagick_r +11.18%
             (likely noise), 500.perlbench_r +1.84%, ...

  * Power8
    - Ofast: 510.parest_r +5.43%, ...;

This patch also introduces one documented parameter
rs6000-vect-unroll-limit= similar to what aarch64 proposes,
by evaluating on P8/P9/P10, the default value 4 is slightly
better than the other choices like 2 and 8.

It also parameterizes two other values as undocumented
parameters for future tweaking.  One parameter is
rs6000-vect-unroll-issue, it's to simply model hardware
resource for non memory access vector instructions to avoid
excessive unrolling, initially I tried to use the value in
the hook rs6000_issue_rate, but the evaluation showed it's
bad, so I evaluated different values 2/4/6/8 on P8/P9/P10 at
Ofast, the results showed the default value 4 is good enough
on these different architectures.  For a record, choice 8
could make 510.parest_r's gain become smaller or gone on
P8/P9/P10; choice 6 could make 503.bwaves_r degrade by more
than 1% on P8/P10; and choice 2 could make 538.imagick_r
degrade by 3.8%.  The other parameter is
rs6000-vect-unroll-reduc-threshold.  It's mainly inspired by
510.parest_r and tweaked as it, evaluating with different
values 0/1/2/3 for the threshold, it showed value 1 is the
best choice.  For a record, choice 0 could make 525.x264_r
degrade by 2% and 527.cam4_r degrade by 2.95% on P10,
548.exchange2_r degrade by 1.41% and 527.cam4_r degrade by
2.54% on P8; choice 2 and bigger values could make
510.parest_r's gain become smaller.

gcc/ChangeLog:

* config/rs6000/rs6000.cc (class rs6000_cost_data): Add new members
m_nstores, m_reduc_factor, m_gather_load and member function
determine_suggested_unroll_factor.
(rs6000_cost_data::update_target_cost_per_stmt): Update for m_nstores,
m_reduc_factor and m_gather_load.
(rs6000_cost_data::determine_suggested_unroll_factor): New function.
(rs6000_cost_data::finish_cost): Use determine_suggested_unroll_factor.
* config/rs6000/rs6000.opt (rs6000-vect-unroll-limit): New parameter.
(rs6000-vect-unroll-issue): Likewise.
(rs6000-vect-unroll-reduc-threshold): Likewise.
* doc/invoke.texi (rs6000-vect-unroll-limit): Document new parameter.

22 months agomiddle-end/106909 - CTRL altering flag after folding
Richard Biener [Tue, 13 Sep 2022 06:59:41 +0000 (08:59 +0200)]
middle-end/106909 - CTRL altering flag after folding

The following makes sure to clear the CTRL altering flag when
folding emits a __builitin_unreachable in place of a virtual call
which now might become a trap.

PR middle-end/106909
* gimple-fold.cc (gimple_fold_call): Clear the ctrl-altering
flag of a unreachable call.

22 months agotree-optimization/106913 - ICE with -da and -Wuninitialized
Richard Biener [Tue, 13 Sep 2022 06:46:51 +0000 (08:46 +0200)]
tree-optimization/106913 - ICE with -da and -Wuninitialized

The following avoids setting and not clearing an auto_bb_flag
on EXIT_BLOCK which we don't verify for such stale flags but
dump_bb_info still asserts on them.

PR tree-optimization/106913
* tree-ssa-uninit.cc (warn_uninitialized_vars): Do not set
ft_reachable on EXIT_BLOCK.

22 months agoaarch64: Vector move fixes for +nosimd
Richard Sandiford [Tue, 13 Sep 2022 08:28:49 +0000 (09:28 +0100)]
aarch64: Vector move fixes for +nosimd

This patch fixes various issues around the handling of vectors
and (particularly) vector structures with +nosimd.  Previously,
passing and returning structures would trigger an ICE, since:

* we didn't allow the structure modes to be stored in FPRs

* we didn't provide +nosimd move patterns

* splitting the moves into word-sized pieces (the default
  strategy without move patterns) doesn't work because the
  registers are doubleword sized.

The patch is a bit of a hodge-podge since a lot of the handling of
moves, register costs, and register legitimacy is so interconnected.
It didn't seem feasible to split things further.

Some notes:

* The patch recognises vector and tuple modes based on TARGET_FLOAT
  rather than TARGET_SIMD, and instead adds TARGET_SIMD to places
  that really do need the vector ISA.  This is necessary for the
  modes to be handled correctly in register arguments and returns.

* The 64-bit (DREG) STP peephole required TARGET_SIMD but the
  LDP peephole didn't.  I think the LDP one is right, since
  DREG moves could involve GPRs as well as FPRs.

* The patch keeps the existing choices of instructions for
  TARGET_SIMD, just in case they happen to be better than FMOV
  on some uarches.

* Before the patch, +nosimd Q<->Q moves of 128-bit scalars went via
  a GPR, thanks to a secondary reload pattern.  This approach might
  not be ideal, but there's no reason that 128-bit vectors should
  behave differently from 128-bit scalars.  The patch therefore
  extends the current scalar approach to vectors.

* Multi-vector LD1 and ST1 require TARGET_SIMD, so the TARGET_FLOAT
  structure moves need to use LDP/STP and LDR/STR combinations
  instead.  That's also what we do for big-endian even with
  TARGET_SIMD, so most of the code was already there.  The patterns
  for structures of 64-bit vectors are identical, but the patterns
  for structures of 128-bit vectors need to cope with the lack of
  128-bit Q<->Q moves.

  It isn't feasible to move multi-vector tuples via GPRs, so the
  patch moves them via memory instead.  This contaminates the port
  with its first secondary memory reload.

gcc/

* config/aarch64/aarch64.cc (aarch64_classify_vector_mode): Use
TARGET_FLOAT instead of TARGET_SIMD.
(aarch64_vectorize_related_mode): Restrict ADVSIMD handling to
TARGET_SIMD.
(aarch64_hard_regno_mode_ok): Don't allow tuples of 2 64-bit vectors
in GPRs.
(aarch64_classify_address): Treat little-endian structure moves
like big-endian for TARGET_FLOAT && !TARGET_SIMD.
(aarch64_secondary_memory_needed): New function.
(aarch64_secondary_reload): Handle 128-bit Advanced SIMD vectors
in the same way as TF, TI and TD.
(aarch64_rtx_mult_cost): Restrict ADVSIMD handling to TARGET_SIMD.
(aarch64_rtx_costs): Likewise.
(aarch64_register_move_cost): Treat a pair of 64-bit vectors
separately from a single 128-bit vector.  Handle the cost implied
by aarch64_secondary_memory_needed.
(aarch64_simd_valid_immediate): Restrict ADVSIMD handling to
TARGET_SIMD.
(aarch64_expand_vec_perm_const_1): Likewise.
(TARGET_SECONDARY_MEMORY_NEEDED): New macro.
* config/aarch64/iterators.md (VTX): New iterator.
* config/aarch64/aarch64.md (arches): Add fp_q as a synonym of simd.
(arch_enabled): Adjust accordingly.
(@aarch64_reload_mov<TX:mode>): Extend to...
(@aarch64_reload_mov<VTX:mode>): ...this.
* config/aarch64/aarch64-simd.md (mov<mode>): Require TARGET_FLOAT
rather than TARGET_SIMD.
(movmisalign<mode>): Likewise.
(load_pair<DREG:mode><DREG2:mode>): Likewise.
(vec_store_pair<DREG:mode><DREG2:mode>): Likewise.
(load_pair<VQ:mode><VQ2:mode>): Likewise.
(vec_store_pair<VQ:mode><VQ2:mode>): Likewise.
(@aarch64_split_simd_mov<mode>): Likewise.
(aarch64_get_low<mode>): Likewise.
(aarch64_get_high<mode>): Likewise.
(aarch64_get_half<mode>): Likewise.  Canonicalize to a move for
lowpart extracts.
(*aarch64_simd_mov<VDMOV:mode>): Require TARGET_FLOAT rather than
TARGET_SIMD.  Use different w<-w and r<-w instructions for
!TARGET_SIMD.  Disable immediate moves for !TARGET_SIMD but
add an alternative specifically for w<-Z.
(*aarch64_simd_mov<VQMOV:mode>): Require TARGET_FLOAT rather than
TARGET_SIMD.  Likewise for the associated define_splits.  Disable
FPR moves and immediate moves for !TARGET_SIMD but add an alternative
specifically for w<-Z.
(aarch64_simd_mov_from_<mode>high): Require TARGET_FLOAT rather than
TARGET_SIMD.  Restrict the existing alternatives to TARGET_SIMD
but add a new r<-w one for !TARGET_SIMD.
(*aarch64_get_high<mode>): New pattern.
(load_pair_lanes<mode>): Require TARGET_FLOAT rather than TARGET_SIMD.
(store_pair_lanes<mode>): Likewise.
(*aarch64_combine_internal<mode>): Likewise.  Restrict existing
w<-w, w<-r and w<-m alternatives to TARGET_SIMD but add a new w<-r
alternative for !TARGET_SIMD.
(*aarch64_combine_internal_be<mode>): Likewise.
(aarch64_combinez<mode>): Require TARGET_FLOAT rather than TARGET_SIMD.
Remove bogus arch attribute.
(*aarch64_combinez_be<mode>): Likewise.
(@aarch64_vec_concat<mode>): Require TARGET_FLOAT rather than
TARGET_SIMD.
(aarch64_combine<mode>): Likewise.
(aarch64_rev_reglist<mode>): Likewise.
(mov<mode>): Likewise.
(*aarch64_be_mov<VSTRUCT_2D:mode>): Extend to TARGET_FLOAT &&
!TARGET_SIMD, regardless of endianness.  Extend associated
define_splits in the same way, both for this pattern and the
ones below.
(*aarch64_be_mov<VSTRUCT_2Qmode>): Likewise.  Restrict w<-w
alternative to TARGET_SIMD.
(*aarch64_be_movoi): Likewise.
(*aarch64_be_movci): Likewise.
(*aarch64_be_movxi): Likewise.
(*aarch64_be_mov<VSTRUCT_4QD:mode>): Extend to TARGET_FLOAT
&& !TARGET_SIMD, regardless of endianness.  Restrict w<-w alternative
to TARGET_SIMD for tuples of 128-bit vectors.
(*aarch64_be_mov<VSTRUCT_4QD:mode>): Likewise.
* config/aarch64/aarch64-ldpstp.md: Remove TARGET_SIMD condition
from DREG STP peephole.  Change TARGET_SIMD to TARGET_FLOAT in
the VQ and VP_2E LDP and STP peepholes.

gcc/testsuite/
* gcc.target/aarch64/ldp_stp_20.c: New test.
* gcc.target/aarch64/ldp_stp_21.c: Likewise.
* gcc.target/aarch64/ldp_stp_22.c: Likewise.
* gcc.target/aarch64/ldp_stp_23.c: Likewise.
* gcc.target/aarch64/ldp_stp_24.c: Likewise.
* gcc.target/aarch64/movv16qi_1.c (gpr_to_gpr): New function.
* gcc.target/aarch64/movv8qi_1.c (gpr_to_gpr): Likewise.
* gcc.target/aarch64/movv16qi_2.c: New test.
* gcc.target/aarch64/movv16qi_3.c: Likewise.
* gcc.target/aarch64/movv2di_1.c: Likewise.
* gcc.target/aarch64/movv2x16qi_1.c: Likewise.
* gcc.target/aarch64/movv2x8qi_1.c: Likewise.
* gcc.target/aarch64/movv3x16qi_1.c: Likewise.
* gcc.target/aarch64/movv3x8qi_1.c: Likewise.
* gcc.target/aarch64/movv4x16qi_1.c: Likewise.
* gcc.target/aarch64/movv4x8qi_1.c: Likewise.
* gcc.target/aarch64/movv8qi_2.c: Likewise.
* gcc.target/aarch64/movv8qi_3.c: Likewise.
* gcc.target/aarch64/vect_unary_2.c: Likewise.

22 months agoaarch64: Disassociate ls64 from simd
Richard Sandiford [Tue, 13 Sep 2022 08:28:48 +0000 (09:28 +0100)]
aarch64: Disassociate ls64 from simd

The ls64-related move expanders and splits required TARGET_SIMD.
That isn't necessary, since the 64-byte values are stored entirely
in GPRs.  (The associated define_insn was already correct.)

I wondered about moving the patterns to aarch64.md, but it wasn't
clear-cut.

gcc/
* config/aarch64/aarch64-simd.md (movv8di): Remove TARGET_SIMD
condition.  Likewise for the related define_split.  Tweak formatting.

gcc/testsuite/
* gcc.target/aarch64/acle/ls64_asm_2.c: New test.

22 months agolibgomp.texi: move item from gcn to nvptx
Tobias Burnus [Tue, 13 Sep 2022 07:08:57 +0000 (09:08 +0200)]
libgomp.texi: move item from gcn to nvptx

I misplaced one remark into 'gcn' instead of 'nvptx' in
commit r13-2625-g6b43f556f392a7165582aca36a19fe7389d995b2

libgomp/ChangeLog:

* libgomp.texi (gcn): Move misplaced -march=sm_30 remark to ...
(nvptx): ... here.

22 months agoDaily bump.
GCC Administrator [Tue, 13 Sep 2022 00:18:20 +0000 (00:18 +0000)]
Daily bump.

22 months agoc++: remove '_sfinae' suffix from functions
Patrick Palka [Mon, 12 Sep 2022 21:55:53 +0000 (17:55 -0400)]
c++: remove '_sfinae' suffix from functions

The functions

  abstract_virtuals_error
  cxx_constant_value
  get_target_expr
  instantiate_non_dependent_expr
  require_complete_type

are each just a non-SFINAE-enabled wrapper for the corresponding
SFINAE-enabled version that's suffixed by '_sfinae'.  But this suffix is
at best redundant since a 'complain' parameter already broadly conveys
that a function is SFINAE-enabled, and having two such versions of a
function is less concise than just using a default argument for 'complain'
(and arguably no less mistake prone).

So this patch squashes the two versions of each of the above functions
by adding a default 'complain' argument to the SFINAE-enabled version
whose '_sfinae' suffix we then remove.

gcc/cp/ChangeLog:

* call.cc (build_conditional_expr): Adjust calls to
'_sfinae'-suffixed functions.
(build_temp): Likewise.
(convert_like_internal): Likewise.
(convert_arg_to_ellipsis): Likewise.
(build_over_call): Likewise.
(build_cxx_call): Likewise.
(build_new_method_call): Likewise.
* constexpr.cc (cxx_eval_outermost_constant_expr): Likewise.
(cxx_constant_value_sfinae): Rename to ...
(cxx_constant_value): ... this.  Document its default arguments.
(fold_non_dependent_expr): Adjust function comment.
* cp-tree.h (instantiate_non_dependent_expr_sfinae): Rename to ...
(instantiate_non_dependent_expr): ... this.  Give its 'complain'
parameter a default argument.
(get_target_expr_sfinae, get_target_expr): Likewise.
(require_complete_type_sfinae, require_complete_type): Likewise.
(abstract_virtuals_error_sfinae, abstract_virtuals_error):
Likewise.
(cxx_constant_value_sfinae, cxx_constant_value): Likewise.
* cvt.cc (build_up_reference): Adjust calls to '_sfinae'-suffixed
functions.
(ocp_convert): Likewise.
* decl.cc (build_explicit_specifier): Likewise.
* except.cc (build_noexcept_spec): Likewise.
* init.cc (build_new_1): Likewise.
* pt.cc (expand_integer_pack): Likewise.
(instantiate_non_dependent_expr_internal): Adjust function
comment.
(instantiate_non_dependent_expr): Rename to ...
(instantiate_non_dependent_expr_sfinae): ... this.  Document its
default argument.
(tsubst_init): Adjust calls to '_sfinae'-suffixed functions.
(fold_targs_r): Likewise.
* semantics.cc (finish_compound_literal): Likewise.
(finish_decltype_type): Likewise.
(cp_build_bit_cast): Likewise.
* tree.cc (build_cplus_new): Likewise.
(get_target_expr): Rename to ...
(get_target_expr_sfinae): ... this.  Document its default
argument.
* typeck.cc (require_complete_type): Rename to ...
(require_complete_type_sfinae): ... this.  Document its default
argument.
(cp_build_array_ref): Adjust calls to '_sfinae'-suffixed
functions.
(convert_arguments): Likewise.
(cp_build_binary_op): Likewise.
(build_static_cast_1): Likewise.
(cp_build_modify_expr): Likewise.
(convert_for_initialization): Likewise.
* typeck2.cc (abstract_virtuals_error): Rename to ...
(abstract_virtuals_error_sfinae): ... this. Document its default
argument.
(build_functional_cast_1): Adjust calls to '_sfinae'-suffixed
functions.

22 months agoc++: template-id arguments are evaluated [PR101906]
Patrick Palka [Tue, 7 Jun 2022 18:19:53 +0000 (14:19 -0400)]
c++: template-id arguments are evaluated [PR101906]

Here we're neglecting to clear cp_unevaluated_operand when substituting
into the arguments of the alias template-id 'skip<(T(), 0), T>' with T=A,
which means cp_unevaluated_operand remains set during mark_used for
A::A() and so we don't synthesize it.  Later constant evaluation for
the substituted template argument '(A(), 0)' (from coerce_template_parms)
fails with "'constexpr A::A()' used before its definition" since it was
never synthesized.

This doesn't happen with a class template because tsubst_aggr_type
clears cp_unevaluated_operand during substitution thereof.  But since
template arguments are generally manifestly constant-evaluated, which in
turn are evaluated even in an unevaluated operand, we should be clearing
cp_unevaluated_operand more broadly whenever substituting into any set
of template arguments.  To that end this patch makes us clear it during
tsubst_template_args.

PR c++/101906

gcc/cp/ChangeLog:

* pt.cc (tsubst_template_args): Set cp_evaluated here.
(tsubst_aggr_type): Not here.

gcc/testsuite/ChangeLog:

* g++.dg/template/evaluated1.C: New test.
* g++.dg/template/evaluated1a.C: New test.
* g++.dg/template/evaluated1b.C: New test.
* g++.dg/template/evaluated1c.C: New test.

22 months agoc++: auto member function and auto variable [PR106893]
Jason Merrill [Mon, 12 Sep 2022 17:47:34 +0000 (13:47 -0400)]
c++: auto member function and auto variable [PR106893]

As with PR105623, we need to call mark_single_function sooner to
resolve the type of a BASELINK.

PR c++/106893
PR c++/90451

gcc/cp/ChangeLog:

* decl.cc (cp_finish_decl): Call mark_single_function.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1y/auto-fn65.C: New test.

22 months agoc++: cast to array of unknown bound [PR93259]
Jason Merrill [Mon, 12 Sep 2022 18:14:24 +0000 (14:14 -0400)]
c++: cast to array of unknown bound [PR93259]

We already know to treat a variable of array-of-unknown-bound type as
dependent, we should do the same for arr{}.

PR c++/93259

gcc/cp/ChangeLog:

* pt.cc (type_dependent_expression_p): Treat a compound
literal of array-of-unknown-bound type like a variable.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/initlist-array17.C: New test.

22 months agoxtensa: Implement new target hook: TARGET_CONSTANT_OK_FOR_CPROP_P
Takayuki 'January June' Suwa [Sun, 11 Sep 2022 11:51:15 +0000 (20:51 +0900)]
xtensa: Implement new target hook: TARGET_CONSTANT_OK_FOR_CPROP_P

This patch implements new target hook TARGET_CONSTANT_OK_FOR_CPROP_P in
order to exclude CONST_INTs that cannot fit into a MOVI machine instruction
from cprop.

gcc/ChangeLog:

* config/xtensa/xtensa.cc (TARGET_CONSTANT_OK_FOR_CPROP_P):
New macro definition.
(xtensa_constant_ok_for_cprop_p):
Implement the hook as mentioned above.

22 months agolibstdc++: Add already-accepted <ranges> testcase [PR106320]
Patrick Palka [Mon, 12 Sep 2022 19:05:04 +0000 (15:05 -0400)]
libstdc++: Add already-accepted <ranges> testcase [PR106320]

Although PR106320 affected only the 10 and 11 branches, and the testcase
from there is already correctly accepted on trunk and the 12 branch, we
still should add the testcase to trunk/12 too for inter-branch consistency.

PR libstdc++/106320

libstdc++-v3/ChangeLog:

* testsuite/std/ranges/adaptors/join.cc (test13): New test.

22 months agoc++: lambda capture of array with deduced bounds [PR106567]
Jason Merrill [Mon, 12 Sep 2022 16:59:46 +0000 (12:59 -0400)]
c++: lambda capture of array with deduced bounds [PR106567]

We can't use the type of an array variable directly if we haven't deduced
its length yet.

PR c++/106567

gcc/cp/ChangeLog:

* lambda.cc (type_deducible_expression_p): Check
array_of_unknown_bound_p.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/lambda/lambda-array4.C: New test.

22 months agoc++: Refer to internal linkage for -Wsubobject-linkage [PR86491]
Jonathan Wakely [Thu, 30 Jun 2022 16:53:26 +0000 (17:53 +0100)]
c++: Refer to internal linkage for -Wsubobject-linkage [PR86491]

Since C++11 relaxed the requirement for template arguments to have
external linkage, it's possible to get -Wsubobject-linkage warnings
without using any anonymous namespaces. This confuses users when they
get diagnostics that refer to an anonymous namespace that doesn't exist
in their code.

This changes the diagnostic to say "has internal linkage" for C++11 and
later, if the type isn't actually a member of the anonymous namespace.
Making that distinction involved renaming the current decl_anon_ns_mem_p to
something that better expresses its semantics.

For C++98 template arguments declared with 'static' are ill-formed
anyway, so the only way this warning can arise is via anonymous
namespaces. That means the existing wording is accurate for C++98 and so
we can keep it.

PR c++/86491

gcc/cp/ChangeLog:

* decl2.cc (constrain_class_visibility): Adjust wording of
-Wsubobject-linkage for cases where anonymous
namespaces aren't used.
* tree.cc (decl_anon_ns_mem_p): Now only true for actual anonymous
namespace members, rename old semantics to...
(decl_internal_context_p): ...this.
* cp-tree.h, name-lookup.cc, pt.cc: Adjust.

gcc/testsuite/ChangeLog:

* g++.dg/warn/anonymous-namespace-3.C: Use separate dg-warning
directives for C++98 and everything else.
* g++.dg/warn/Wsubobject-linkage-5.C: New test.

22 months agostdatomic.h: Do not define ATOMIC_VAR_INIT for C2x
Joseph Myers [Mon, 12 Sep 2022 14:34:26 +0000 (14:34 +0000)]
stdatomic.h: Do not define ATOMIC_VAR_INIT for C2x

The <stdatomic.h> macro ATOMIC_VAR_INIT, previously declared obsolete,
is removed completely in C2x; disable it for C2x in GCC's
implementation.  (Although ATOMIC_* are reserved names for this
header, disabling the macro for C2x still seems appropriate.)

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

gcc/
* ginclude/stdatomic.h [defined __STDC_VERSION__ &&
__STDC_VERSION__ > 201710L] (ATOMIC_VAR_INIT): Do not define.

gcc/testsuite/
* gcc.dg/atomic/c2x-stdatomic-var-init-1.c: New test.

22 months agonvptx/mkoffload.cc: Warn instead of error when reverse offload is not possible
Tobias Burnus [Mon, 12 Sep 2022 13:25:13 +0000 (15:25 +0200)]
nvptx/mkoffload.cc: Warn instead of error when reverse offload is not possible

Reverse offload requests at least -misa=sm_35; with this patch, a warning
instead of an error is shown, still permitting reverse offload for all
other configured device types. This is achieved by not calling
GOMP_offload_register_ver (and stopping generating pointless 'static const char'
variables, once known.)

The tool_name as progname changes adds "nvptx " and "gcn " to the
"mkoffload: warning/error:" diagnostic.

gcc/ChangeLog:

* config/nvptx/mkoffload.cc (process): Replace a fatal_error by
a warning + not enabling offloading if -misa=sm_30 prevents
reverse offload.
(main): Use tool_name as progname for diagnostic.
* config/gcn/mkoffload.cc (main): Likewise.

libgomp/ChangeLog:

* libgomp.texi (Offload-Target Specifics: nvptx): Document
that reverse offload requires >= -march=sm_35.
* testsuite/libgomp.c-c++-common/requires-4.c: Build for nvptx
with -misa=sm_35.
* testsuite/libgomp.c-c++-common/requires-5.c: Likewise.
* testsuite/libgomp.c-c++-common/requires-6.c: Likewise.
* testsuite/libgomp.c-c++-common/reverse-offload-1.c: Likewise.
* testsuite/libgomp.fortran/reverse-offload-1.f90: Likewise.
* testsuite/libgomp.c/reverse-offload-sm30.c: New test.

22 months agofrange::set_signbit: Avoid changing sign when already in the correct sign.
Aldy Hernandez [Mon, 12 Sep 2022 11:04:02 +0000 (13:04 +0200)]
frange::set_signbit: Avoid changing sign when already in the correct sign.

We should avoid pessimizing the signbit when it's already correct.  In
this particular case we were trying to change the signbit to "unknown",
when it was obviously negative.

This test is actually slated for removal with my upcoming revamp of the
signbit and NAN tracking, per the conversations regarding tristate.  The
signbit will be removed in favor of keeping track of it in the range
itself, and NAN will just be a pair of boolean flags.  However, I don't
plan to disturb the tree until after Cauldron.

Tested on x86-64 Linux including mpfr tests.  Also tested selftests with
-ffinite-math-only on x86-64 as well as on a cross to pdp11-aout.

gcc/ChangeLog:

* value-range.cc (frange::set_signbit): Avoid changing sign when
already in the correct sign.

22 months agoxtensa: gcc: fix builtin_apply return value
Max Filippov [Sun, 11 Sep 2022 00:31:07 +0000 (17:31 -0700)]
xtensa: gcc: fix builtin_apply return value

xtensa may use up to 4 registers to return a value from a function, but
recognition of only one register in the xtensa_function_value_regno_p
and missing untyped_call pattern result in that only one register is
saved by the __builtin_apply and returned by the __builtin_apply_return.

gcc/
* config/xtensa/xtensa.cc (xtensa_function_value_regno_p):
Recognize all 4 return registers.
* config/xtensa/xtensa.h (GP_RETURN_REG_COUNT): New definition.
* config/xtensa/xtensa.md (untyped_call): New pattern.

22 months agolibstdc++: Fix comments in tests to match code
Jonathan Wakely [Mon, 12 Sep 2022 11:02:29 +0000 (12:02 +0100)]
libstdc++: Fix comments in tests to match code

libstdc++-v3/ChangeLog:

* testsuite/19_diagnostics/error_code/cons/lwg3629.cc: Fix
comments.
* testsuite/19_diagnostics/error_condition/cons/lwg3629.cc:
Likewise.

22 months agolibgomp.texi: Impl. status fix/addition
Tobias Burnus [Mon, 12 Sep 2022 10:30:04 +0000 (12:30 +0200)]
libgomp.texi: Impl. status fix/addition

libgomp/ChangeLog:

* libgomp.texi (OpenMP 5.1 Impl. Status): Add two new minor items.
(OpenMP 5.2 Impl. Status): Improve omp/omx/ompx wording.

22 months agodoc: Fix typo in documentation of __float128 suffix
Jonathan Wakely [Mon, 12 Sep 2022 09:40:10 +0000 (10:40 +0100)]
doc: Fix typo in documentation of __float128 suffix

gcc/ChangeLog:

* doc/extend.texi (Floating Types): Fix "_float128" typo.

22 months agogcov: Respect triplet when looking for gcov
Torbjörn SVENSSON [Fri, 9 Sep 2022 10:19:27 +0000 (12:19 +0200)]
gcov: Respect triplet when looking for gcov

When testing a cross toolchain outside the build tree, the binary name
for gcov is prefixed with the triplet.

gcc/testsuite/ChangeLog:

* g++.dg/gcov/gcov.exp: Respect triplet when looking for gcov.
* gcc.misc-tests/gcov.exp: Likewise.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
22 months agolibstdc++: Outline the overlapping case of string _M_replace into a separate function...
Jakub Jelinek [Mon, 12 Sep 2022 09:31:11 +0000 (11:31 +0200)]
libstdc++: Outline the overlapping case of string _M_replace into a separate function [PR105329]

The following patch is partially a workaround for bogus warnings
when the compiler isn't able to fold _M_disjunct call into constant
false, but also an optimization attempt - assuming _M_disjunct (__s)
is rare, the patch should shrink code size for the common case and
use library or for non-standard instantiations an out of line
function to handle the rare case.

2022-09-12  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/105329
* acinclude.m4 (libtool_VERSION): Change to 6:31:0.
* config/abi/pre/gnu.ver (GLIBCXX_3.4.21): Don't export
std::basic_string methods with name length of 15.
(GLIBCXX_3.4.31): Export std::basic_string::_M_replace_cold.
* testsuite/util/testsuite_abi.cc (check_version): Handle
GLIBCXX_3.4.31.
* include/bits/basic_string.h (std::basic_string::_M_replace_cold):
Declare.
* include/bits/basic_string.tcc (std::basic_string::_M_replace_cold):
Define and export even for C++20.
(std::basic_string::_M_replace): Use __builtin_expect, outline
the overlapping case to _M_replace_cold.
* configure: Regenerated.

22 months agolibgomp: Fix up icv-6.c [PR106894]
Jakub Jelinek [Mon, 12 Sep 2022 08:48:19 +0000 (10:48 +0200)]
libgomp: Fix up icv-6.c [PR106894]

The thing is,
make check
or
make check RUNTESTFLAGS="c.exp='icv-6.c' c++.exp='icv-6.c'"
in libgomp obj dir work fine, but
make -j32 -k check RUNTESTFLAGS="c.exp='icv-6.c' c++.exp='icv-6.c'"
fails.
The thing is that the testcase as written relies on OMP_NUM_THREADS not being
set in environment (as it takes priority over OMP_NUM_THREADS_ALL for the
host).
So, if either a user has OMP_NUM_THREADS=42 in the environment by himself, or
when doing make check with -jN, we trigger:
          if test $$num_cpus -gt 8 && test -z "$$OMP_NUM_THREADS"; then \
            OMP_NUM_THREADS=8; export OMP_NUM_THREADS; \
            echo @@@ libgomp OMP_NUM_THREADS adjusted to 8 because of parallel
make check and too many CPUs; \
          fi; \
in libgomp/testsuite/Makefile.am and so the test fails.

2022-09-12  Jakub Jelinek  <jakub@redhat.com>

PR libgomp/106894
* testsuite/libgomp.c-c++-common/icv-6.c: Include string.h.
(main): Avoid tests for which corresponding non-_ALL suffixed variable
is in the environment, or for OMP_NUM_TEAMS on the device
OMP_NUM_TEAMS_DEV_?.

22 months ago[Ada] Fix immediate assertion failure with -gnatd.1
Eric Botcazou [Thu, 1 Sep 2022 14:21:07 +0000 (16:21 +0200)]
[Ada] Fix immediate assertion failure with -gnatd.1

The switch enables the front-end unnesting pass.

gcc/ada/

* gcc-interface/decl.cc (gnat_to_gnu_entity): Relax assertion when
front-end unnesting is enabled.

22 months ago[Ada] Storage_Error raised analyzing type with call in its range constraint
Justin Squirek [Tue, 6 Sep 2022 14:35:53 +0000 (14:35 +0000)]
[Ada] Storage_Error raised analyzing type with call in its range constraint

This patch corrects a problem in the compiler whereby the determination of
scope levels during the generation of accessibility checks for function calls
within range constraints leads to a compiler crash due to the type not being
fully analyzed at the point in which its scope depth must be obtained.

gcc/ada/

* sem_util.adb
(Innermost_Master_Scope_Depth): Detect and handle case where scope
depth is not set on an enclosing scope.

22 months ago[Ada] Improve CUDA host-side and device-side binder support
Steve Baird [Wed, 7 Sep 2022 21:15:46 +0000 (14:15 -0700)]
[Ada] Improve CUDA host-side and device-side binder support

On the host-side, the binder now generates CUDA_Execute pragmas to
invoke initialization and finalization on the device-side. The
front end's expansion of these pragmas includes references to
entities declared in package CUDA.Internal. Generate a with-clause so
that unit will be available.

gcc/ada/

* bindgen.adb: When the binder is invoked for the host, generate a
"with CUDA.Internal;" with clause.

22 months ago[Ada] Sync documentation of junk names with code
Piotr Trojanek [Tue, 6 Sep 2022 22:19:19 +0000 (00:19 +0200)]
[Ada] Sync documentation of junk names with code

The list of junk entity names for which warnings are suppressed has been
recently modified, so update the documentation accordingly.

gcc/ada/

* doc/gnat_rm/implementation_defined_pragmas.rst
(Pragma Unreferenced): Sync description with
Sem_Warn.Has_Junk_Name routine.
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.

22 months ago[Ada] Reject 'Valid_Scalars on Unchecked_Union regardless of privacy
Piotr Trojanek [Tue, 6 Sep 2022 18:11:35 +0000 (20:11 +0200)]
[Ada] Reject 'Valid_Scalars on Unchecked_Union regardless of privacy

Attribute Valid_Scalars applied to prefix with an unchecked union
component causes a legitimate crash in the backend. It was already
rejected in the frontend for prefixes of a public type; now it is
rejected in the frontend regardless of the type privacy.

gcc/ada/

* sem_attr.adb (Analyze_Attribute [Valid_Scalars]): Move check for
unchecked union before checks for private and public types.

22 months ago[Ada] Improve CUDA host-side and device-side binder support
Steve Baird [Fri, 2 Sep 2022 18:31:26 +0000 (11:31 -0700)]
[Ada] Improve CUDA host-side and device-side binder support

Use switches (one already existing, one newly added here) to indicate to
the binder that CUDA support code is to be generated for either the
host side or for the device side. Add an invocation of Adainit on the
device side from Adainit on the host side; similarly for Adafinal.

gcc/ada/

* bindgen.adb: When the binder is invoked for the host, it
declares imported subprograms corresponding to the Adainit and
Adafinal routines on the device. Declare string constants and
expression functions for the Ada source names and the link names
of these routines. Generate these subprogram declarations (and
accompanying Import pragmas) in Gen_CUDA_Defs. Generate
CUDA_Execute pragmas to call these subprograms from the host in
Gen_Adafinal and Gen_CUDA_Init. When the binder is invoked for the
device, include a CUDA_Global aspect declaration in the
declarations of Adainit and Adafinal and use the aforementioned
link names in the Export pragmas generated for those two routines.
* debug.adb: Update comments about "d_c" and "d_d" switches.
* opt.ads: Declare new Boolean variable,
Enable_CUDA_Device_Expansion. This complements the existing
Enable_CUDA_Expansion variable, which is used to enable host-side
CUDA expansion. The new variable enables device-side CUDA
expansion. It is currently never set during compilation; it is
only set via a binder switch.
* switch-b.adb
(scan_debug_switches): Add new use of the "-d_d" binder switch.
The new switch and the variable Opt.Enabled_CUDA_Device_Expansion
follow the existing pattern of the "-d_c" switch and the variable
Opt.Enabled_CUDA_Expansion. Flag error if both "-d_c" and "-d_d"
are specified.

22 months ago[Ada] Temporary tweak new expansion of contracts
Eric Botcazou [Mon, 5 Sep 2022 15:51:34 +0000 (17:51 +0200)]
[Ada] Temporary tweak new expansion of contracts

In the case of a function, the new expansion of contracts makes use of an
extended return statement to store the result of the function in the return
object while the post-conditions are evaluated.

Unfortunately GNAT does not elide the copy of the return object for extended
return statements for the time being, so this scheme incurs an extra copy of
the return value on the primary or secondary stack, as well as an additional
pair of calls to Adjust/Finalize when the return type needs finalization.

This temporarily changes the expansion to use a block statement containing a
renaming, which does not incur the extra copy provided that it is manually
adjusted to be recognized by the existing "tail call" optimization present
in the Expand_Simple_Function_Return routine.

gcc/ada/

* contracts.adb (uild_Subprogram_Contract_Wrapper): Remove useless
local variable. In the case of a function, replace the extended
return statement by a block statement declaring a renaming of the
call to the local subprogram after removing side effects manually.
(Expand_Subprogram_Contract): Adjust description accordingly.
* exp_ch6.adb (Expand_Ctrl_Function_Call): Rewrite obsolete
comment and do not apply the transformation twice.
* sem_attr.adb (Analyze_Attribute_Old_Result): Now expect a block
statement instead of an extended return statement.

22 months ago[Ada] Special-case printing of SPARK_Mode in error messages
Piotr Trojanek [Mon, 5 Sep 2022 13:12:42 +0000 (15:12 +0200)]
[Ada] Special-case printing of SPARK_Mode in error messages

For error messages with inserted names that include acronyms like SPARK
or CPP, we want to preserve the casing. The list of special-cased named
is currently the same as in gnatpp.

gcc/ada/

* erroutc.adb (Set_Msg_Insertion_Name): Special-case printing with
acronyms.

22 months ago[Ada] Justify false alarm from CodePeer analysis of GNAT
Yannick Moy [Mon, 5 Sep 2022 14:19:36 +0000 (16:19 +0200)]
[Ada] Justify false alarm from CodePeer analysis of GNAT

Branch is determined as dead following a test always False by
CodePeer analysis, which is incorrect. Justify this false alarm
with an appropriate pragma Annotate.

gcc/ada/

* libgnat/s-imagei.adb (Image_Integer): Add justification.

22 months ago[Ada] Cleanup routine for handling SPARK_Mode kinds
Piotr Trojanek [Mon, 5 Sep 2022 12:59:30 +0000 (14:59 +0200)]
[Ada] Cleanup routine for handling SPARK_Mode kinds

Code cleanup; semantics is unaffected.

gcc/ada/

* sem_prag.adb (Get_SPARK_Mode_Type): Fix header box; replace
chained IF with a CASE statement.

22 months ago[Ada] Accept explicit SPARK_Mode Auto as configuration pragma
Yannick Moy [Mon, 5 Sep 2022 10:20:18 +0000 (12:20 +0200)]
[Ada] Accept explicit SPARK_Mode Auto as configuration pragma

An explicit value of Auto is now accepted for a configuration pragma
SPARK_Mode, as a way to exempt a unit from complete adherence to
SPARK rules when using a global configuration pragma file where
SPARK_Mode=>On is specified.

gcc/ada/

* sem_prag.adb (Analyze_Pragma): Accept SPARK_Mode=>Auto as
configuration pragma.
(Get_SPARK_Mode): Make the value for Auto explicit.
* snames.ads-tmpl (Name_Auto): Add name.

22 months ago[Ada] Remove SPARK containers from GNAT documentation
Joffrey Huguet [Fri, 2 Sep 2022 12:38:19 +0000 (14:38 +0200)]
[Ada] Remove SPARK containers from GNAT documentation

This patch removes documentation on the SPARK containers,
now under the spark2014 repository.

gcc/ada/

* doc/gnat_rm/the_gnat_library.rst: Remove paragraphs about SPARK
containers.
* gnat_rm.texi, gnat_ugn.texi: Regenerate.

22 months ago[Ada] Reject use in SPARK of Asm intrinsics for code insertions
Yannick Moy [Fri, 2 Sep 2022 08:40:56 +0000 (10:40 +0200)]
[Ada] Reject use in SPARK of Asm intrinsics for code insertions

SPARK does not allow code insertions. This applies also to
calls to Asm intrinsics defined in System.Machine_Code.

gcc/ada/

* libgnat/s-maccod.ads: Mark package as SPARK_Mode Off.

22 months ago[Ada] Add C declaration for Opt.Unnest_Subprogram_Mode
Eric Botcazou [Thu, 1 Sep 2022 14:15:06 +0000 (16:15 +0200)]
[Ada] Add C declaration for Opt.Unnest_Subprogram_Mode

gcc/ada/

* fe.h (Unnest_Subprogram_Mode): Declare.

22 months ago[Ada] Internal error compiling formal instance of generic with Initial_Condition
Steve Baird [Tue, 30 Aug 2022 23:04:02 +0000 (16:04 -0700)]
[Ada] Internal error compiling formal instance of generic with Initial_Condition

Prevent the compiler from failing with an internal error in some cases involving
an instance of a generic which takes as a formal parameter an instance of a
second generic, where the second generic has an Initial_Condition aspect
specification.

gcc/ada/

* contracts.adb
(Analyze_Package_Contract): Do not analyze the contract of a
temporary package created just to check conformance of an actual
package.

22 months ago[Ada] Replace SPARK containers implementation by Compile_Time_Error
Joffrey Huguet [Tue, 30 Aug 2022 16:00:35 +0000 (18:00 +0200)]
[Ada] Replace SPARK containers implementation by Compile_Time_Error

The SPARK containers are now maintained under the spark2014 repository.
This change replaces the implementation of SPARK containers by a
pragma Compile_Time_Error, pointing the users WITHing the libraries
to their new location.

gcc/ada/

* Makefile.rtl: Remove SPARK containers filenames.
* impunit.adb: Remove SPARK containers packages names.
* libgnat/a-cfdlli.adb, libgnat/a-cfdlli.ads: Remove content and
add pragma Compile_Time_Error with suitable message.
* libgnat/a-cfhama.adb, libgnat/a-cfhama.ads: Likewise.
* libgnat/a-cfhase.adb, libgnat/a-cfhase.ads: Likewise.
* libgnat/a-cfidll.adb, libgnat/a-cfidll.ads: Likewise.
* libgnat/a-cfinse.adb, libgnat/a-cfinse.ads: Likewise.
* libgnat/a-cfinve.adb, libgnat/a-cfinve.ads: Likewise.
* libgnat/a-cforma.adb, libgnat/a-cforma.ads: Likewise.
* libgnat/a-cforse.adb, libgnat/a-cforse.ads: Likewise.
* libgnat/a-cofove.adb, libgnat/a-cofove.ads: Likewise.
* libgnat/a-cofuma.adb, libgnat/a-cofuma.ads: Likewise.
* libgnat/a-cofuse.adb, libgnat/a-cofuse.ads: Likewise.
* libgnat/a-cofuve.adb, libgnat/a-cofuve.ads: Likewise.
* libgnat/a-cofuba.adb, libgnat/a-cofuba.ads: Remove package.

gcc/testsuite/

* gnat.dg/aspect2.adb: Removed.
* gnat.dg/aspect2.ads: Removed.
* gnat.dg/config_pragma1.adb: Removed.
* gnat.dg/config_pragma1_pkg.ads: Removed.
* gnat.dg/equal8.adb: Removed.
* gnat.dg/equal8.ads: Removed.
* gnat.dg/equal8_pkg.ads: Removed.
* gnat.dg/formal_containers.adb: Removed.
* gnat.dg/iter1.adb: Removed.
* gnat.dg/iter1.ads: Removed.

22 months ago[Ada] Fix validity checking on renamed Old attribute prefix
Piotr Trojanek [Mon, 8 Aug 2022 14:10:36 +0000 (16:10 +0200)]
[Ada] Fix validity checking on renamed Old attribute prefix

Prefix of attribute Old is captured either as an object renaming or as
an object declaration. This is now taken into account when applying
validity checks.

gcc/ada/

* exp_attr.adb (Expand_N_Attribute_Reference [Attribute_Old]):
Adapt to object declaration being rewritten into object renaming.

22 months ago[Ada] Tech debt: Expansion of contracts
Justin Squirek [Wed, 31 Aug 2022 14:52:11 +0000 (14:52 +0000)]
[Ada] Tech debt: Expansion of contracts

This patch modifies the expansion of contracts such that the statements
and declarations of a subprogram with post-execution checks get moved to
a local internally generated subprogram which the original subprogram
calls directly followed by the required post-execution checks.

This differs from the current implementation which requires delicate
machinary which coordinates with the finalization process to emulate the
desired behavior within the "at end" procedure.

gcc/ada/

* contracts.adb, contracts.ads
(Analyze_Pragmas_In_Declarations): Added to aid in the new
expansion model so that pragmas relating to contracts can get
processed early before the rest of the subprogram containing them.
(Build_Subprogram_Contract_Wrapper): Created to do the majority of
expansion for postconditions. It builds a local wrapper with the
statements and declarations within a given subprogram.
(Is_Prologue_Renaming): Moved out from Process_Preconditions to be
used generally within the contracts package.
(Build_Entry_Contract_Wrapper): Moved from exp_ch7.
(Expand_Subprogram_Contract): Add new local variable Decls to
store expanded declarations needed for evaluation of contracts.
Call new wrapper building procedure and modify comments to match
new expansion model.
(Get_Postcond_Enabled): Deleted.
(Get_Result_Object_For_Postcond): Deleted.
(Get_Return_Success_For_Postcond): Deleted.
(Process_Contract_Cases): Add new parameter to store declarations.
(Process_Postconditions): Add new parameter to store declarations.
(Process_Preconditions): Add new parameter to store declarations.
Add code to move entry-call prologue renamings
* einfo.ads: Document new field Wrapped_Statements and modify
comment for Postconditions_Proc.
* exp_attr.adb
(Analyze_Attribute): Modify expansion of the 'Old attribute to
recognize new expansion model and use Wrapped_Statements instead
of Postconditions_Proc.
* exp_ch6.adb
(Add_Return): Remove special expansion for postconditions.
(Expand_Call): Modify condition checking for calls to access
subprogram wrappers to handle new expansion models.
(Expand_Call_Helper): Remove special expansion for postconditions.
(Expand_Non_Function_Return): Remove special expansion for
postconditions.
(Expand_Simple_Function_Return): Remove special expansion for
postconditions.
* exp_ch7.adb
(Build_Finalizer): Deleted, but replaced by code in
Build_Finalizer_Helper
(Build_Finalizer_Helper): Renamed to Build_Finalizer, and special
handling of 'Old objects removed.
* exp_ch9.adb
(Build_Contract_Wrapper): Renamed and moved to contracts package.
* exp_prag.adb
(Expand_Pragma_Contract_Cases): Delay analysis of contracts since
they now instead get analyzed as part of the wrapper generation
instead of after analysis of their corresponding subprogram's
body.
(Expand_Pragma_Check): Label expanded if-statements which come
from the expansion of assertion statements as
Comes_From_Check_Or_Contract.
* freeze.adb
(Freeze_Entity): Add special case to avoid freezing when a freeze
node gets generated as part of the expansion of a postcondition
check.
* gen_il-gen-gen_nodes.adb: Add new flag
Comes_From_Check_Or_Contract.
* gen_il-fields.ads: Add new field Wrapped_Statements. Add new
flag Comes_From_Check_Or_Contract.
* gen_il-gen-gen_entities.adb: Add new field Wrapped_Statements.
* ghost.adb
(Is_OK_Declaration): Replace Name_uPostconditions with
Name_uWrapped_Statements.
(Is_OK_Statement): Simplify condition due to the loss of
Original_Node as a result of the new expansion model of contracts
and use new flag Comes_From_Check_Or_Contract in its place.
* inline.adb
(Declare_Postconditions_Result): Replace Name_uPostconditions with
Name_uWrapped_Statements.
(Expand_Inlined_Call): Replace Name_uPostconditions with
Name_uWrapped_Statements.
* lib.adb, lib.ads
(ipu): Created to aid in debugging.
* lib-xref.adb
(Generate_References): Remove special handling for postcondition
procedures.
* sem_attr.adb
(Analyze_Attribute_Old_Result): Add new context in which 'Old can
appear due to the changes in expansion. Replace
Name_uPostconditions with Name_uWrapped_Statements.
(Result): Replace Name_uPostconditions with
Name_uWrapped_Statements.
* sem_ch11.adb
(Analyze_Handled_Statements): Remove check to exclude warnings on
useless assignments within postcondition procedures since
postconditions no longer get isolated into separate subprograms.
* sem_ch6.adb
(Analyze_Generic_Subprogram_Body): Modify expansion of generic
subprogram bodies so that contracts (and their associated pragmas)
get analyzed first.
(Analyze_Subprogram_Body_Helper): Remove global HSS variable due
to the HSS of the body potentially changing during the expansion
of contracts. In cases where it was used instead directly call
Handled_Statement_Sequence. Modify expansion of subprogram bodies
so that contracts (and their associated pragmas) get analyzed
first.
(Check_Missing_Return): Create local HSS variable instead of using
a global one.
(Move_Pragmas): Use new pragma table instead of an explicit list.
* sem_elab.adb
(Is_Postconditions_Proc): Deleted since the new scheme of
expansion no longer divides postcondition checks to a separate
subprogram and so cannot be easily identified (similar to
pre-condition checks).
(Info_Call): Remove info printing for _Postconditions subprograms.
(Is_Assertion_Pragma_Target): Remove check for postconditions
procedure
(Is_Bridge_Target): Remove check for postconditions procedure.
(Get_Invocation_Attributes): Remove unneeded local variables and
check for postconditions procedure.
(Output_Call): Remove info printing for _Postconditions
subprograms.
* sem_prag.adb, sem_prag.ads: Add new Pragma table for pragmas
significant to subprograms, along with tech-debt comment.
(Check_Arg_Is_Local_Name): Modified to recognize the new
_Wrapped_Statements internal subprogram and the new expansion
model.
(Relocate_Pragmas_To_Body): Replace Name_uPostconditions with
Name_uWrapped_Statements.
* sem_res.adb
(Resolve_Entry_Call): Add conditional to detect both contract
based wrappers of entries, but also wrappers generated as part of
general contract expansion (e.g. local postconditions
subprograms).
* sem_util.adb
(Accessibility_Level): Verify 'Access is not taken based on a
component of a function result.
(Has_Significant_Contracts): Replace Name_uPostconditions with
Name_uWrapped_Statements.
(Same_Or_Aliased_Subprogram): Add conditional to detect and obtain
the original subprogram based on the new concept of
"postcondition" wrappers.
* sinfo.ads: Add documentation for new flag
Comes_From_Check_Or_Contract.
* snames.ads-tmpl: Remove Name_uPostconditions and add
Name_uWrapped_Statements

22 months ago[Ada] Fix oversight in implementation of unnesting
Eric Botcazou [Wed, 31 Aug 2022 12:39:08 +0000 (14:39 +0200)]
[Ada] Fix oversight in implementation of unnesting

The pass would traverse generic subprogram bodies, which are not expanded,
thus stumbling on unexpected nodes.

gcc/ada/

* exp_unst.adb (Unnest_Subprograms.Search_Subprograms): Skip the
subprogram bodies that are not to be unnested.

22 months ago[Ada] Syntax error in Ada 2022 array aggregate causes bug box
Steve Baird [Mon, 29 Aug 2022 21:55:14 +0000 (14:55 -0700)]
[Ada] Syntax error in Ada 2022 array aggregate causes bug box

Check for the case where a user writes "in" instead of "of" in an
aggregate like "[for E in Some_Array when Some_Filter (E) => E]".

gcc/ada/

* sem_aggr.adb
(Resolve_Array_Aggregate): Generate an appropriate error message
in the case where an error in the source code leads to an
N_Iterated_Element_Association node in a bad context.

22 months ago[Ada] Initialize a local variable to avoid a CodePeer warning
Steve Baird [Mon, 29 Aug 2022 22:33:45 +0000 (15:33 -0700)]
[Ada] Initialize a local variable to avoid a CodePeer warning

gcc/ada/

* sem_ch4.adb
(Analyze_Selected_Component): Initialize the local variable Comp
to avoid having CodePeer generate an uninitialized variable
warning.

22 months ago[Ada] bugbox referencing INOX prefixed view of primitive op of modular type
Steve Baird [Mon, 29 Aug 2022 20:26:30 +0000 (13:26 -0700)]
[Ada] bugbox referencing INOX prefixed view of primitive op of modular type

The -gnatX switch enables naming a prefixed view of a subprogram with an
untagged prefix. Compiling such a reference where the prefix is of a modular
type could result in an internal compiler error.

gcc/ada/

* sem_ch4.adb
(Analyze_Selected_Component): Avoid initializing the local
variable Comp if the variable is not going to be subsequently
referenced. This is a correctness issue because the call to
First_Entity can fail.

22 months ago[Ada] Lock_Free aspect takes precedence over Ceiling_Locking locking policy
Steve Baird [Thu, 25 Aug 2022 21:56:55 +0000 (14:56 -0700)]
[Ada] Lock_Free aspect takes precedence over Ceiling_Locking locking policy

Allow the Lock_Free aspect of a protected type to be True (but only by
explicit specification) if Ceiling_Locking locking policy has been specified.
Clarify that the Lock_Free aspect takes precedence over the Ceiling_Locking
policy in that case.

gcc/ada/

* sem_ch9.adb
(Satisfies_Lock_Free_Requirements): If Ceiling_Locking locking
policy has been specified, then either return False (if Lock_Free
was not explicitly specified) or generate a warning that ceiling
locking will not be implemented for this protected unit (if
Lock_Free was explicitly specified). Generate an error message (in
addition to returning False) if an explicit Lock_Free aspect
specification is rejected because atomic primitives are not
supported on the given target.
* doc/gnat_rm/implementation_defined_pragmas.rst: Clarify that the
Lock_Free aspect for a protected unit takes precedence over the
Ceiling_Locking locking policy in the case where both apply.
* gnat_rm.texi: Regenerate.

22 months ago[Ada] Do not mark user parameters of protected subprograms as artificial
Eric Botcazou [Wed, 24 Aug 2022 19:52:32 +0000 (21:52 +0200)]
[Ada] Do not mark user parameters of protected subprograms as artificial

This occurs because protected subprograms are not translated directly into
object code but first rewritten as a pair of subprograms by the front-end.

gcc/ada/

* exp_ch9.adb (Build_Protected_Spec): Tidy up and propagate the
Comes_From_Source flag onto the new formal parameters.
* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Do not check
references for subprograms generated for protected subprograms.

22 months ago[Ada] Fix issues with compiling ACATS test for user-defined literals
Gary Dismukes [Fri, 19 Aug 2022 22:40:05 +0000 (18:40 -0400)]
[Ada] Fix issues with compiling ACATS test for user-defined literals

The draft ACATS test (which we developed) for the Ada 2022 feature of
user-defined literals has compile-time problems that are fixed with this
set of changes.  Two of these involve the resolution of named numbers
in the context where an implicit literal conversion can occur, and for
equality when a literal or named number is an operand. Furthermore,
the compiler can hang in some cases when a numeric literal is used
in a context where the expected type is a type derived two levels
down from a tagged type that specifies a literal aspect.

gcc/ada/

* sem_res.adb
(Resolve_Equality_Op): Add handling for equality ops with
user-defined literal operands.
* sem_util.ads
(Is_User_Defined_Literal): Update spec comment to indicate
inclusion of named number cases.
* sem_util.adb
(Corresponding_Primitive_Op): Rather than following the chain of
ancestor subprograms via Alias and Overridden_Operation links, we
check for matching profiles between primitive subprograms of the
descendant type and the ancestor subprogram (by calling a new
nested function Profile_Matches_Ancestor). This prevents the
compiler from hanging due to circular linkages via those fields
that can occur between inherited and overriding subprograms
(which might indicate a latent bug, but one that may be rather
delicate to resolve).
(Profile_Matches_Ancestor): New nested subprogram to compare the
profile of a primitive subprogram with the profile of a candidate
ancestor subprogram.
(Is_User_Defined_Literal): Also return True in cases where the
node N denotes a named number (E_Name_Integer and E_Named_Real).

22 months ago[Ada] Remove a no-longer-correct comment
Steve Baird [Wed, 24 Aug 2022 16:11:02 +0000 (09:11 -0700)]
[Ada] Remove a no-longer-correct comment

Remove a comment about the former use of the -gnatd9 switch (that switch is
now unused).

gcc/ada/

* debug.adb: remove a comment.