]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
8 months agolibstdc++: Deprecate useless <cxxx> compatibility headers for C++17
Jonathan Wakely [Wed, 23 Oct 2024 15:01:50 +0000 (16:01 +0100)] 
libstdc++: Deprecate useless <cxxx> compatibility headers for C++17

These headers make no sense for C++ programs, because they either define
different content to the corresponding <xxx.h> C header, or define
nothing at all in namespace std. They were all deprecated in C++17, so
add deprecation warnings to them, which can be disabled with
-Wno-deprecated. For C++20 and later these headers are no longer in the
standard at all, so compiling with _GLIBCXX_USE_DEPRECATED defined to 0
will give an error when they are included.

Because #warning is non-standard before C++23 we need to use pragmas to
ignore -Wc++23-extensions for the -Wsystem-headers -pedantic case.

One g++ test needs adjustment because it includes <ciso646>, but that
can be made conditional on the __cplusplus value without any reduction
in test coverage.

For the library tests, consolidate the std_c++0x_neg.cc XFAIL tests into
the macros.cc test, using dg-error with a { target c++98_only }
selector. This avoids having two separate test files, one for C++98 and
one for everything later. Also add tests for the <xxx.h> headers to
ensure that they behave as expected and don't give deprecated warnings.

libstdc++-v3/ChangeLog:

* doc/xml/manual/evolution.xml: Document deprecations.
* doc/html/*: Regenerate.
* include/c_compatibility/complex.h (_GLIBCXX_COMPLEX_H): Move
include guard to start of file. Include <complex> directly
instead of <ccomplex>.
* include/c_compatibility/tgmath.h: Include <cmath> and
<complex> directly, instead of <ctgmath>.
* include/c_global/ccomplex: Add deprecated #warning for C++17
and #error for C++20 if _GLIBCXX_USE_DEPRECATED == 0.
* include/c_global/ciso646: Likewise.
* include/c_global/cstdalign: Likewise.
* include/c_global/cstdbool: Likewise.
* include/c_global/ctgmath: Likewise.
* include/c_std/ciso646: Likewise.
* include/precompiled/stdc++.h: Do not include ccomplex,
ciso646, cstdalign, cstdbool, or ctgmath in C++17 and later.
* testsuite/18_support/headers/cstdalign/macros.cc: Check for
warnings and errors for unsupported dialects.
* testsuite/18_support/headers/cstdbool/macros.cc: Likewise.
* testsuite/26_numerics/headers/ctgmath/complex.cc: Likewise.
* testsuite/27_io/objects/char/1.cc: Do not include <ciso646>.
* testsuite/27_io/objects/wchar_t/1.cc: Likewise.
* testsuite/18_support/headers/cstdbool/std_c++0x_neg.cc: Removed.
* testsuite/18_support/headers/cstdalign/std_c++0x_neg.cc: Removed.
* testsuite/26_numerics/headers/ccomplex/std_c++0x_neg.cc: Removed.
* testsuite/26_numerics/headers/ctgmath/std_c++0x_neg.cc: Removed.
* testsuite/18_support/headers/ciso646/macros.cc: New test.
* testsuite/18_support/headers/ciso646/macros.h.cc: New test.
* testsuite/18_support/headers/cstdbool/macros.h.cc: New test.
* testsuite/26_numerics/headers/ccomplex/complex.cc: New test.
* testsuite/26_numerics/headers/ccomplex/complex.h.cc: New test.
* testsuite/26_numerics/headers/ctgmath/complex.h.cc: New test.

gcc/testsuite/ChangeLog:

* g++.old-deja/g++.other/headers1.C: Do not include ciso646 for
C++17 and later.

8 months agolibstdc++: Move include guards to start of headers
Jonathan Wakely [Tue, 5 Nov 2024 12:54:32 +0000 (12:54 +0000)] 
libstdc++: Move include guards to start of headers

libstdc++-v3/ChangeLog:

* include/c_compatibility/complex.h (_GLIBCXX_COMPLEX_H): Move
include guard to start of the header.
* include/c_global/ctgmath (_GLIBCXX_CTGMATH): Likewise.

8 months agolibstdc++: More user-friendly failed assertions from shared_ptr dereference
Jonathan Wakely [Wed, 30 Oct 2024 11:41:47 +0000 (11:41 +0000)] 
libstdc++: More user-friendly failed assertions from shared_ptr dereference

Currently dereferencing an empty shared_ptr prints a complicated
internal type in the assertion message:

include/bits/shared_ptr_base.h:1377: std::__shared_ptr_access<_Tp, _Lp, <anonymous>, <anonymous> >::element_type& std::__shared_ptr_access<_Tp, _Lp, <anonymous>, <anonymous> >::operator*() const [with _Tp = std::filesystem::__cxx11::recursive_directory_iterator::_Dir_stack; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic; bool <anonymous> = false; bool <anonymous> = false; element_type = std::filesystem::__cxx11::recursive_directory_iterator::_Dir_stack]: Assertion '_M_get() != nullptr' failed.

Users don't care about any of the _Lp and <anonymous> template
parameters, so this is unnecessarily verbose.

We can simplify it to something that only mentions "shared_ptr_deref"
and the element type:

include/bits/shared_ptr_base.h:1371: _Tp* std::__shared_ptr_deref(_Tp*) [with _Tp = filesystem::__cxx11::recursive_directory_iterator::_Dir_stack]: Assertion '__p != nullptr' failed.

libstdc++-v3/ChangeLog:

* include/bits/shared_ptr_base.h (__shared_ptr_deref): New
function template.
(__shared_ptr_access, __shared_ptr_access<>): Use it.

8 months agolibstdc++: Enable debug assertions for filesystem directory iterators
Jonathan Wakely [Mon, 28 Oct 2024 17:55:02 +0000 (17:55 +0000)] 
libstdc++: Enable debug assertions for filesystem directory iterators

Several member functions of filesystem::directory_iterator and
filesystem::recursive_directory_iterator currently dereference their
shared_ptr data member without checking for non-null. Because they use
operator-> and that function only uses _GLIBCXX_DEBUG_PEDASSERT rather
than __glibcxx_assert there is no assertion even when the library is
built with _GLIBCXX_ASSERTIONS defined. This means that dereferencing
invalid directory iterators gives an unhelpful segfault.

By using (*p). instead of p-> we get an assertion when the library is
built with _GLIBCXX_ASSERTIONS, with a "_M_get() != nullptr" message.

libstdc++-v3/ChangeLog:

* src/c++17/fs_dir.cc (fs::directory_iterator::operator*): Use
shared_ptr::operator* instead of shared_ptr::operator->.
(fs::recursive_directory_iterator::options): Likewise.
(fs::recursive_directory_iterator::depth): Likewise.
(fs::recursive_directory_iterator::recursion_pending): Likewise.
(fs::recursive_directory_iterator::operator*): Likewise.
(fs::recursive_directory_iterator::disable_recursion_pending):
Likewise.

8 months agoipcp don't propagate where not needed
Michal Jires [Wed, 23 Oct 2024 22:52:28 +0000 (00:52 +0200)] 
ipcp don't propagate where not needed

This patch disables propagation of ipcp information into partitions
where all instances of the node are marked to be inlined.

Motivation:
Incremental LTO needs stable values between compilations to be
effective. This requirement fails with following example:

void heavily_used_function(int);
...
heavily_used_function(__LINE__);

Ipcp creates long list of all __LINE__ arguments, and then
propagates it with every function clone, even though for inlined
functions this information is not useful.

gcc/ChangeLog:

* ipa-prop.cc (write_ipcp_transformation_info): Disable
uneeded value propagation.
* lto-cgraph.cc (lto_symtab_encoder_encode): Default values.
(lto_symtab_encoder_always_inlined_p): New.
(lto_set_symtab_encoder_not_always_inlined): New.
(add_node_to): Set always inlined.
* lto-streamer.h (struct lto_encoder_entry): New field.
(lto_symtab_encoder_always_inlined_p): New.

8 months agostore-merging: Apply --param=store-merging-max-size= in more spots [PR117439]
Jakub Jelinek [Wed, 6 Nov 2024 09:22:13 +0000 (10:22 +0100)] 
store-merging: Apply --param=store-merging-max-size= in more spots [PR117439]

Store merging assumes a merged region won't be too large.  The assumption is
e.g. in using inappropriate types in various spots (e.g. int for bit sizes
and bit positions in a few spots, or unsigned for the total size in bytes of
the merged region), in doing XNEWVEC for the whole total size of the merged
region and preparing everything in there and even that XALLOCAVEC in two
spots.  The last case is what was breaking the test below in the patch,
64MB XALLOCAVEC is just too large, but even with that fixed I think we just
shouldn't be merging gigabyte large merge groups.

We already have --param=store-merging-max-size= parameter, right now with
65536 bytes maximum (if needed, we could raise that limit a little bit).
That parameter is currently used when merging two adjacent stores, if the
size of the already merged bitregion together with the new store's bitregion
is above that limit, we don't merge those.
I guess initially that was sufficient, at that time a store was always
limited to MAX_BITSIZE_MODE_ANY_INT bits.
But later on we've added support for empty ctors ({} and even later
{CLOBBER}) and also added another spot where we merge further stores into
the merge group, if there is some overlap, we can merge various other stores
in one coalesce_immediate_stores iteration.
And, we weren't applying the --param=store-merging-max-size= parameter
in either of those cases.  So a single store can be gigabytes long, and
if there is some overlap, we can extend the region again to gigabytes in
size.

The following patch attempts to apply that parameter even in those cases.
So, if testing if it should merge the merged group with info (we've already
punted if those together are above the parameter) and some other stores,
the first two hunks just punt if that would make the merge group too large.
And the third hunk doesn't even add stores which are over the limit.

2024-11-06  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/117439
* gimple-ssa-store-merging.cc
(imm_store_chain_info::coalesce_immediate_stores): Punt if merging of
any of the additional overlapping stores would result in growing the
bitregion size over param_store_merging_max_size.
(pass_store_merging::process_store): Terminate all aliasing chains
for stores with bitregion larger than param_store_merging_max_size.

* g++.dg/opt/pr117439.C: New test.

8 months agostore-merging: Don't use sub_byte_op_p mode for empty_ctor_p unless necessary [PR117439]
Jakub Jelinek [Wed, 6 Nov 2024 09:21:09 +0000 (10:21 +0100)] 
store-merging: Don't use sub_byte_op_p mode for empty_ctor_p unless necessary [PR117439]

encode_tree_to_bitpos uses the more expensive sub_byte_op_p mode in which
it has to allocate a buffer and do various extra work like shifting the bits
etc. if bitlen or bitpos aren't multiples of BITS_PER_UNIT, or if bitlen
doesn't have corresponding integer mode.
The last case is explained later in the comments:
  /* The native_encode_expr machinery uses TYPE_MODE to determine how many
     bytes to write.  This means it can write more than
     ROUND_UP (bitlen, BITS_PER_UNIT) / BITS_PER_UNIT bytes (for example
     write 8 bytes for a bitlen of 40).  Skip the bytes that are not within
     bitlen and zero out the bits that are not relevant as well (that may
     contain a sign bit due to sign-extension).  */
Now, we've later added empty_ctor_p support, either {} CONSTRUCTOR
or {CLOBBER}, which doesn't use native_encode_expr at all, just memset,
so that case doesn't need those fancy games unless bitlen or bitpos
aren't multiples of BITS_PER_UNIT (unlikely, but let's pretend it is
possible).

The following patch makes us use the fast path even for empty_ctor_p
which occupy full bytes, we can just memset that in the provided buffer and
don't need to XALLOCAVEC another buffer.

This patch in itself fixes the testcase from the PR (which was about using
huge XALLLOCAVEC), but I want to do some other changes, to be posted in a
next patch.

2024-11-06  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/117439
* gimple-ssa-store-merging.cc (encode_tree_to_bitpos): For
empty_ctor_p use !sub_byte_op_p even if bitlen doesn't have an
integral mode.

8 months agoFortran: F2008 passing of internal procs to a proc pointer [PR117434]
Paul Thomas [Wed, 6 Nov 2024 07:17:25 +0000 (07:17 +0000)] 
Fortran: F2008 passing of internal procs to a proc pointer [PR117434]

2024-11-06  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/117434
* interface.cc (gfc_compare_actual_formal): Skip 'Expected a
procedure pointer error' if the formal argument typespec has an
interface and the type of the actual arg is BT_PROCEDURE.

gcc/testsuite/
PR fortran/117434
* gfortran.dg/proc_ptr_54.f90: New test. This is temporarily
compile-only until one one seven four five five is fixed.
* gfortran.dg/proc_ptr_55.f90: New test.
* gfortran.dg/proc_ptr_56.f90: New test.

8 months agoi386: Add OPTION_MASK_ISA2_EVEX512 for some AVX512 instructions.
Hu, Lin1 [Tue, 5 Nov 2024 07:49:57 +0000 (15:49 +0800)] 
i386: Add OPTION_MASK_ISA2_EVEX512 for some AVX512 instructions.

gcc/ChangeLog:

PR target/117304
* config/i386/i386-builtin.def: Add OPTION_MASK_ISA2_EVEX512 for some
AVX512 512-bits instructions.

gcc/testsuite/ChangeLog:

PR target/117304
* gcc.target/i386/pr117304-1.c: New test.

8 months agoIntel MOVRS tests: Also scan (%e.x)
H.J. Lu [Wed, 6 Nov 2024 00:14:04 +0000 (08:14 +0800)] 
Intel MOVRS tests: Also scan (%e.x)

Since x32 uses (%reg32), instead of (%r.x), also scan (%e.x).

* gcc.target/i386/avx10_2-512-movrs-1.c: Also scan (%e.x).
* gcc.target/i386/avx10_2-movrs-1.c: Likewise.
* gcc.target/i386/movrs-1.c: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
8 months agogcc.target/i386/apx-ndd.c: Also scan (%edi)
H.J. Lu [Tue, 5 Nov 2024 23:44:24 +0000 (07:44 +0800)] 
gcc.target/i386/apx-ndd.c: Also scan (%edi)

Since x32 uses (%edi), instead of (%rdi), also scan (%edi).

* gcc.target/i386/apx-ndd.c: Also scan (%edi).

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
8 months agoDaily bump.
GCC Administrator [Wed, 6 Nov 2024 00:18:35 +0000 (00:18 +0000)] 
Daily bump.

8 months agofortran: dynamically allocate error_buffer [PR117442]
David Malcolm [Tue, 5 Nov 2024 23:30:39 +0000 (18:30 -0500)] 
fortran: dynamically allocate error_buffer [PR117442]

PR fortran/117442 reports a crash on exit of f951 when configured
with --enable-gather-detailed-mem-stats.

The crash happens if any diagnostics were ever buffered into
error_buffer.  The root cause is that error_buffer is statically
allocated and thus has a non-trivial destructor called at exit.
If error_buffer's diagnostic_buffer ever buffered anything, then
a diagnostic_per_format_buffer will have been created for the
buffer per-output-sink, and the destructors for these call
into the mem-stats subsystem, which has already beeen cleaned up.

The simplest fix is to allocate error_buffer on the heap, rather
that statically, which fixes the crash.

There's a comment about error_buffer:

  /* pp_error_buffer is statically allocated.  This simplifies memory
     management when using gfc_push/pop_error. */

added by Manu in r6-1748-g5862c189c2c3c2 while fixing PR fortran/66528.
The comment appears to be out of date.  I've tested maxerrors.f90 under
valgrind, and it's clean with the patch.

gcc/fortran/ChangeLog:
PR fortran/117442
* error.cc (error_buffer): Convert to a pointer so it can be
heap-allocated.
(gfc_error_now): Update for error_buffer being heap-allocated.
(gfc_clear_error): Likewise.
(gfc_error_flag_test): Likewise.
(gfc_error_check): Likewise.
(gfc_push_error): Likewise.
(gfc_pop_error): Likewise.
(gfc_diagnostics_init): Allocate error_buffer on the heap, rather
than statically.
(gfc_diagnostics_finish): Delete error_buffer.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
8 months agomatch: Fix comment for `X != 0 ? X + ~0 : 0` transformation
Andrew Pinski [Sun, 3 Nov 2024 20:19:46 +0000 (12:19 -0800)] 
match: Fix comment for `X != 0 ? X + ~0 : 0` transformation

Just a small coment fix, the `(` was in the wrong location,
making it look it was transforming into `(X - X) != 0`
rather than `X - (X != 0)`.

Pushed as obvious after a quick build for x86_64-linux-gnu.

gcc/ChangeLog:

* match.pd (X != 0 ? X + ~0 : 0): Fix comment.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
8 months agotestsuite: arm: Use effective-target for pr68620 and pr78041 tests
Torbjörn SVENSSON [Thu, 31 Oct 2024 18:00:36 +0000 (19:00 +0100)] 
testsuite: arm: Use effective-target for pr68620 and pr78041 tests

gcc/testsuite/ChangeLog:

* gcc.target/arm/pr68620.c: Use effective-target arm_neon.
* gcc.target/arm/pr78041.c: Use effective-target arm_arch_v7a.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
8 months agotestsuite: arm: Relax register selection [PR116623]
Torbjörn SVENSSON [Sat, 19 Oct 2024 16:08:01 +0000 (18:08 +0200)] 
testsuite: arm: Relax register selection [PR116623]

Since r15-1619-g3b9b8d6cfdf, test5 and test8 fails due to that "ip"
might be used and r3 might be moved to another register for later
dereference.

gcc/testsuite/ChangeLog:

PR testsuite/116623
* gcc.target/arm/mve/dlstp-compile-asm-2.c: Align test5 and
test8 with changes in r15-1619-g3b9b8d6cfdf.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
8 months agotestsuite: arm: Use effective-target for pr98636.c test
Torbjörn SVENSSON [Fri, 1 Nov 2024 10:11:26 +0000 (11:11 +0100)] 
testsuite: arm: Use effective-target for pr98636.c test

The test case assumes that -mfp16-format=alternative is accepted for the
target, but not all targets support this flag. One such target is
Cortex-M85 that does support FP16, but not the alternative format.

gcc/testsuite/ChangeLog:

* gcc.target/arm/pr98636.c: Use effective-target
arm_fp16_alternative.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
8 months agoc: gimplefe: Only allow an identifier before ? [PR117445]
Andrew Pinski [Tue, 5 Nov 2024 07:42:29 +0000 (23:42 -0800)] 
c: gimplefe: Only allow an identifier before ? [PR117445]

Since r13-707-g68e0063397ba82, COND_EXPR/VEC_COND_EXPR has not
allowed a comparison as the first operand but the gimple front-end
was not updated for this change and you would error out later on.
An assert was added with r15-4791-gb60031e8f9f8fe which meant an ICE
would happen from the gimple FE.
This removes support for parsing of the `?:` expressions except for an
identifier.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/c/ChangeLog:

PR c/117445
* gimple-parser.cc (c_parser_gimple_statement): Remove
support for comparisons before the querry (`?`) token.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
8 months agoPR target/117449: Restrict vector rotate match and split to pre-reload
Kyrylo Tkachov [Tue, 5 Nov 2024 13:10:22 +0000 (05:10 -0800)] 
PR target/117449: Restrict vector rotate match and split to pre-reload

The vector rotate splitter has some logic to deal with post-reload splitting
but not all cases in aarch64_emit_opt_vec_rotate are post-reload-safe.
In particular the ROTATE+XOR expansion for TARGET_SHA3 can create RTL that
can later be simplified to a simple ROTATE post-reload, which would then
match the insn again and try to split it.
So do a clean split pre-reload and avoid going down this path post-reload
by restricting the insn_and_split to can_create_pseudo_p ().

Bootstrapped and tested on aarch64-none-linux.

Signed-off-by: Kyrylo Tkachov <ktkachov@nvidia.com>
gcc/

PR target/117449
* config/aarch64/aarch64-simd.md (*aarch64_simd_rotate_imm<mode>):
Match only when can_create_pseudo_p ().
* config/aarch64/aarch64.cc (aarch64_emit_opt_vec_rotate): Assume
can_create_pseudo_p ().

gcc/testsuite/

PR target/117449
* gcc.c-torture/compile/pr117449.c: New test.

8 months agotestsuite: Fix up gcc.target/powerpc/safe-indirect-jump-3.c test [PR117444]
Peter Bergner [Tue, 5 Nov 2024 16:30:46 +0000 (10:30 -0600)] 
testsuite: Fix up gcc.target/powerpc/safe-indirect-jump-3.c test [PR117444]

The test safe-indirect-jump-3.c FAILs on powerpc64le-linux with the change
in jump table generation behavior with commit r15-4756-g06bc3a734e8890,
since it is compiled without optimization and expects jump tables to be
generated.  Add an explicit -fjump-tables to dg-options to get the old
behavior back.

2024-11-05  Peter Bergner  <bergner@linux.ibm.com>

gcc/testsuite/
PR testsuite/117444
* gcc.target/powerpc/safe-indirect-jump-3.c: Add -fjump-tables to
dg-options.

8 months agoc++: allow array mem-init with -fpermissive [PR116634]
Jason Merrill [Mon, 4 Nov 2024 22:48:46 +0000 (17:48 -0500)] 
c++: allow array mem-init with -fpermissive [PR116634]

We've accidentally accepted this forever (at least as far back as 4.7), but
it's always been ill-formed; this was PR59465.  And we didn't accept it for
scalar types.  But rather than switch to a hard error for this code, let's
give a permerror so affected code can continue to work with -fpermissive.

PR c++/116634

gcc/cp/ChangeLog:

* init.cc (can_init_array_with_p): Allow PR59465 case with
permerror.

gcc/testsuite/ChangeLog:

* g++.dg/diagnostic/aggr-init1.C: Expect warning with -fpermissive.
* g++.dg/init/array62.C: Adjust diagnostic.
* g++.dg/init/array63.C: Adjust diagnostic.
* g++.dg/init/array64.C: Adjust diagnostic.

9 months agoDeprecate the ARM simulator
Nick Clifton [Tue, 5 Nov 2024 13:04:36 +0000 (13:04 +0000)] 
Deprecate the ARM simulator

The ARM simulator is no longer able to simulator modern ARM cores, so it
is being deprecated.  Once this change has been active for a while - and
assuming that no problems have been found - the ARm simulator codebase
will be removed.

2024-11-05  Nick Clifton  <nickc@redhat.com>

* configure.ac: Add sim to noconfigdirs for ARM targets.
* configure: Regenerate.

9 months agoc++: Fix crash during NRV optimization with invalid input [PR117099, PR117129]
Simon Martin [Tue, 5 Nov 2024 09:44:34 +0000 (10:44 +0100)] 
c++: Fix crash during NRV optimization with invalid input [PR117099, PR117129]

PR117099 and PR117129 are ICEs upon invalid code that happen when NRVO
is activated, and both due to the fact that we don't consistently set
current_function_return_value to error_mark_node upon error in
finish_return_expr.

This patch fixes this inconsistency which fixes both cases since we skip
calling finalize_nrv when current_function_return_value is
error_mark_node.

PR c++/117099
PR c++/117129

gcc/cp/ChangeLog:

* typeck.cc (check_return_expr): Upon error, set
current_function_return_value to error_mark_node.

gcc/testsuite/ChangeLog:

* g++.dg/parse/crash78.C: New test.
* g++.dg/parse/crash78a.C: New test.
* g++.dg/parse/crash79.C: New test.

9 months agoc++: Don't crash upon invalid placement new operator [PR117101]
Simon Martin [Tue, 5 Nov 2024 09:16:39 +0000 (10:16 +0100)] 
c++: Don't crash upon invalid placement new operator [PR117101]

We currently crash upon the following invalid code (notice the "void
void**" parameter)

=== cut here ===
using size_t = decltype(sizeof(int));
void *operator new(size_t, void void **p) noexcept { return p; }
int x;
void f() {
    int y;
    new (&y) int(x);
}
=== cut here ===

The problem is that in this case, we end up with a NULL_TREE parameter
list for the new operator because of the error, and (1) coerce_new_type
wrongly complains about the first parameter type not being size_t,
(2) std_placement_new_fn_p blindly accesses the parameter list, hence a
crash.

This patch does NOT address #1 since we can't easily distinguish between
a new operator declaration without parameters from one with erroneous
parameters (and it's not worth the risk to refactor and break things for
an error recovery issue) hence a dg-bogus in new52.C, but it does
address #2 and the ICE by simply checking the first parameter against
NULL_TREE.

It also adds a new testcase checking that we complain about new
operators with no or invalid first parameters, since we did not have
any.

PR c++/117101

gcc/cp/ChangeLog:

* init.cc (std_placement_new_fn_p): Check first_arg against
NULL_TREE.

gcc/testsuite/ChangeLog:

* g++.dg/init/new52.C: New test.
* g++.dg/init/new53.C: New test.

9 months agoc++: Defer -fstrong-eval-order processing to template instantiation time [PR117158]
Simon Martin [Tue, 5 Nov 2024 09:07:42 +0000 (10:07 +0100)] 
c++: Defer -fstrong-eval-order processing to template instantiation time [PR117158]

Since r10-3793-g1a37b6d9a7e57c, we ICE upon the following valid code
with -std=c++17 and above

=== cut here ===
struct Base {
  unsigned int *intarray;
};
template <typename T> struct Sub : public Base {
  bool Get(int i) {
    return (Base::intarray[++i] == 0);
  }
};
=== cut here ===

The problem is that from c++17 on, we use -fstrong-eval-order and need
to wrap the array access expression into a SAVE_EXPR. We do so at
template declaration time, and end up calling contains_placeholder_p
with a SCOPE_REF, that it does not handle well.

This patch fixes this by deferring the wrapping into SAVE_EXPR to
instantiation time for templates, when the SCOPE_REF will have been
turned into a COMPONENT_REF.

PR c++/117158

gcc/cp/ChangeLog:

* typeck.cc (cp_build_array_ref): Only wrap array expression
into a SAVE_EXPR at template instantiation time.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1z/eval-order13.C: New test.
* g++.dg/parse/crash77.C: New test.

9 months agotestsuite: fix testcase pr110279-1.c
Di Zhao [Tue, 5 Nov 2024 04:28:54 +0000 (12:28 +0800)] 
testsuite: fix testcase pr110279-1.c

The test case is for targets that support FMA. Previously
the "target" selector is missed in dg-final command.

gcc/testsuite/ChangeLog:
PR tree-optimization/110279
* gcc.dg/pr110279-1.c: add target selector.

9 months agoSupport vector float_extend from __bf16 to float.
liuhongt [Thu, 24 Oct 2024 06:51:20 +0000 (23:51 -0700)] 
Support vector float_extend from __bf16 to float.

It's supported by vector permutation with zero vector.

gcc/ChangeLog:

* config/i386/i386-expand.cc
(ix86_expand_vector_bf2sf_with_vec_perm): New function.
* config/i386/i386-protos.h
(ix86_expand_vector_bf2sf_with_vec_perm): New Declare.
* config/i386/mmx.md (extendv2bfv2sf2): New expander.
* config/i386/sse.md (extend<sf_cvt_bf16_lower><mode>2):
Ditto.
(VF1_AVX512BW): New mode iterator.
(sf_cvt_bf16): Add V4SF.
(sf_cvt_bf16_lower): New mode attr.

gcc/testsuite/ChangeLog:

* gcc.target/i386/avx512bw-extendbf2sf.c: New test.
* gcc.target/i386/sse2-extendbf2sf.c: New test.

9 months agoSupport vector float_truncate for SF to BF.
liuhongt [Wed, 23 Oct 2024 07:51:00 +0000 (00:51 -0700)] 
Support vector float_truncate for SF to BF.

Generate native instruction whenever possible, otherwise use vector
permutation with odd indices.

gcc/ChangeLog:

* config/i386/i386-expand.cc
(ix86_expand_vector_sf2bf_with_vec_perm): New function.
* config/i386/i386-protos.h
(ix86_expand_vector_sf2bf_with_vec_perm): New declare.
* config/i386/mmx.md (truncv2sfv2bf2): New expander.
* config/i386/sse.md (truncv4sfv4bf2): Ditto.
(truncv8sfv8bf2): Ditto.
(truncv16sfv16bf2): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/i386/avx512bf16-truncsfbf.c: New test.
* gcc.target/i386/avx512bw-truncsfbf.c: New test.
* gcc.target/i386/ssse3-truncsfbf.c: New test.

9 months agoc++: Mark replaceable global operator new/delete with const std::nothrow_t& argument...
Jakub Jelinek [Tue, 5 Nov 2024 07:58:28 +0000 (08:58 +0100)] 
c++: Mark replaceable global operator new/delete with const std::nothrow_t& argument as DECL_IS_REPLACEABLE_OPERATOR [PR117370]

cxx_init_decl_processing predeclares 12 out of the 20 replaceable global
new/delete operators and sets DECL_IS_REPLACEABLE_OPERATOR on those.
But it doesn't handle the remaining 8, in particular
void* operator new(std::size_t, const std::nothrow_t&) noexcept;
void* operator new[](std::size_t, const std::nothrow_t&) noexcept;
void operator delete(void*, const std::nothrow_t&) noexcept;
void operator delete[](void*, const std::nothrow_t&) noexcept;
void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) noexcept;
void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) noexcept;
void operator delete(void*, std::align_val_t, const std::nothrow_t&) noexcept;
void operator delete[](void*, std::align_val_t, const std::nothrow_t&) noexcept;

The following patch sets that flag during grok_op_properties for those, so
that they don't need to be predeclared.
The patch doesn't fix the whole PR, as some work is needed on the CDDCE side
too, unlike the throwing operator new case the if (ptr) conditional around
operator delete isn't removed by VRP and so we need to handle conditional
delete for unconditional new.

2024-11-05  Jakub Jelinek  <jakub@redhat.com>

PR c++/117370
* cp-tree.h (is_std_class): Declare.
* constexpr.cc (is_std_class): New function.
(is_std_allocator): Use it.
* decl.cc (grok_op_properties): Mark global replaceable
operator new/delete operators with const std::nothrow_t & last
argument with DECL_IS_REPLACEABLE_OPERATOR.

9 months agoi386: Handling exception input of __builtin_ia32_prefetch. [PR117416]
Hu, Lin1 [Mon, 4 Nov 2024 06:52:56 +0000 (14:52 +0800)] 
i386: Handling exception input of __builtin_ia32_prefetch. [PR117416]

op1 should be between 0 and 2. Add an error handler, and op3 should be 0
or 1, raise a warning, when op3 is an invalid value.

gcc/ChangeLog:

PR target/117416
* config/i386/i386-expand.cc (ix86_expand_builtin): Raise warning when
op1 isn't in range of [0, 2] and set op1 as const0_rtx, and raise
warning when op3 isn't in range of [0, 1].

gcc/testsuite/ChangeLog:

PR target/117416
* gcc.target/i386/pr117416-1.c: New test.
* gcc.target/i386/pr117416-2.c: Ditto.

9 months agomiddle-end/117433 - ICE with gimple BLKmode reg copy
Richard Biener [Mon, 4 Nov 2024 10:39:05 +0000 (11:39 +0100)] 
middle-end/117433 - ICE with gimple BLKmode reg copy

When we end up expanding a SSA name copy with BLKmode regs which can
happen for vectors, possibly wrapped in a NOP-conversion or
a PAREN_EXPR and we are not optimizing we can end up with two
BLKmode MEMs that expand_gimple_stmt_1 doesn't properly handle
when expanding, trying to emit_move_insn them.  Looking at store_expr
which what expand_gimple_stmt_1 is really doing reveals a lot of
magic that's missing.  It eventually falls back to emit_block_move
(store_expr isn't exported), so this is what I ended up using here
given I think we'll only have BLKmode "registers" for vectors.

PR middle-end/117433
* cfgexpand.cc (expand_gimple_stmt_1): Use emit_block_move
when moving temp to BLKmode target.

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

9 months agoaarch64: remove falkor-tag-collision-avoidance pass
Andrew Pinski [Thu, 31 Oct 2024 17:54:21 +0000 (17:54 +0000)] 
aarch64: remove falkor-tag-collision-avoidance pass

This code is not well tested and there is only a single testcase
(gcc.target/aarch64/pr94530.c) which only enables this code but it
is testing to make sure there is no ICE.

The falkor cores have not been supported from Qualcomm from 2019 or so
either. And I don't have a way to test these cores internally either.

Bootstrapped and tested on aarch64-linux-gnu.

gcc/ChangeLog:

* config/aarch64/aarch64-passes.def: Don't add pass_tag_collision_avoidance.
* config/aarch64/aarch64-protos.h (make_pass_tag_collision_avoidance): Remove.
* config/aarch64/aarch64-tuning-flags.def (RENAME_LOAD_REGS): Remove.
* config/aarch64/tuning_models/qdf24xx.h (qdf24xx_tunings): Set tuning flags to
AARCH64_EXTRA_TUNE_NONE.
* config/aarch64/falkor-tag-collision-avoidance.cc: Removed.
* config/aarch64/t-aarch64 (falkor-tag-collision-avoidance.o): Remove.
* config.gcc (aarch64*-*-*): Remove falkor-tag-collision-avoidance.o from extra_objs.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
9 months agoaarch64: Remove scheduling models for falkor and saphira
Andrew Pinski [Thu, 31 Oct 2024 17:40:50 +0000 (17:40 +0000)] 
aarch64: Remove scheduling models for falkor and saphira

These 2 qualcomm cores have been long gone in that Qualcomm has not
supported since at least 2019. Removing them will make it easier I think
to change the insn type attributes instead of keeping them up todate.

Note this does not remove the cores, just the schedule models.

Bootstrapped and tested on aarch64-linux-gnu.

gcc/ChangeLog:

* config/aarch64/aarch64-cores.def (falkor): Use cortex-a57 scheduler.
(saphira): Likewise.
* config/aarch64/aarch64.md: Don't include falkor.md and saphira.md.
* config/aarch64/falkor.md: Removed.
* config/aarch64/saphira.md: Removed.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
9 months agoi386: Utilize VCOMSBF16 for BF16 Comparisons with AVX10.2
Levy Hsu [Wed, 9 Oct 2024 08:38:57 +0000 (16:38 +0800)] 
i386: Utilize VCOMSBF16 for BF16 Comparisons with AVX10.2

This patch enables the use of the VCOMSBF16 instruction from AVX10.2 for
efficient BF16 comparisons.

gcc/ChangeLog:

* config/i386/i386-expand.cc (ix86_expand_branch): Handle BFmode
when TARGET_AVX10_2_256 is enabled.
(ix86_prepare_fp_compare_args): Use SSE_FLOAT_MODE_SSEMATH_OR_HFBF_P.
(ix86_expand_fp_movcc): Ditto.
(ix86_expand_fp_compare): Handle BFmode under IX86_FPCMP_COMI.
* config/i386/i386.cc (ix86_multiplication_cost): Use
SSE_FLOAT_MODE_SSEMATH_OR_HFBF_P.
(ix86_division_cost): Ditto.
(ix86_rtx_costs): Ditto.
(ix86_vector_costs::add_stmt_cost): Ditto.
* config/i386/i386.h (SSE_FLOAT_MODE_SSEMATH_OR_HF_P): Rename to ...
(SSE_FLOAT_MODE_SSEMATH_OR_HFBF_P): ...this, and add BFmode.
* config/i386/i386.md (*cmpibf): New define_insn.

gcc/testsuite/ChangeLog:

* gcc.target/i386/avx10_2-comibf-1.c: New test.
* gcc.target/i386/avx10_2-comibf-2.c: Ditto.

9 months agoHandle T_HRESULT types in CodeView records
Mark Harmstone [Sat, 2 Nov 2024 15:31:12 +0000 (15:31 +0000)] 
Handle T_HRESULT types in CodeView records

Follow MSVC in having a special type value, T_HRESULT, for (signed)
longs that have been typedef'd with the name "HRESULT". This is so that
the debugger can display user-friendly constant names when debugging COM
code.

gcc/
* dwarf2codeview.cc (get_type_num_typedef): New function.
(get_type_num): Call get_type_num_typedef.
* dwarf2codeview.h (T_HRESULT): Define.

9 months agoWrite LF_POINTER CodeView types for pointers to member functions or data
Mark Harmstone [Fri, 1 Nov 2024 00:38:44 +0000 (00:38 +0000)] 
Write LF_POINTER CodeView types for pointers to member functions or data

Translate DW_TAG_ptr_to_member_type DIEs into special extended
LF_POINTER CodeView types.

gcc/
* dwarf2codeview.cc (struct codeview_custom_type): Add new fields to
lf_pointer struct in union.
(write_lf_pointer): Write containing_class and ptr_to_mem_type if
applicable.
(get_type_num_subroutine_type): Write correct containing_class_type if
this is a pointer to a member function.
(get_type_num_ptr_to_member_type): New function.
(get_type_num): Call get_type_num_ptr_to_member_type.
* dwarf2codeview.h (CV_PTR_MODE_MASK, CV_PTR_MODE_PMEM): Define.
(CV_PTR_MODE_PMFUNC, CV_PMTYPE_D_Single, CV_PMTYPE_F_Single): Likewise.

9 months agoWrite LF_BCLASS records in CodeView struct definitions
Mark Harmstone [Thu, 29 Aug 2024 01:35:37 +0000 (02:35 +0100)] 
Write LF_BCLASS records in CodeView struct definitions

When writing the CodeView type definition for a struct, translate
DW_TAG_inheritance DIEs into LF_BCLASS records, to record which other
structs this one inherits from.

gcc/
* dwarf2codeview.cc (enum cv_leaf_type): Add LF_BCLASS.
(struct codeview_subtype): Add lf_bclass to union.
(write_cv_padding): Add declaration.
(write_lf_fieldlist): Handle LF_BCLASS records.
(add_struct_inheritance): New function.
(get_type_num_struct): Call add_struct_inheritance.

9 months agoc++/modules: Merge default arguments [PR99274]
Nathaniel Shead [Mon, 12 Aug 2024 00:57:39 +0000 (10:57 +1000)] 
c++/modules: Merge default arguments [PR99274]

When merging a newly imported declaration with an existing declaration
we don't currently propagate new default arguments, which causes issues
when modularising header units.  This patch adds logic to propagate
default arguments to existing declarations on import, and error if the
defaults do not match.

PR c++/99274

gcc/cp/ChangeLog:

* module.cc (trees_in::is_matching_decl): Merge default
arguments.
* tree.cc (cp_tree_equal) <AGGR_INIT_EXPR>: Handle unification
of AGGR_INIT_EXPRs with new VAR_DECL slots.

gcc/testsuite/ChangeLog:

* g++.dg/modules/lambda-7.h: Skip ODR-violating declaration when
testing ODR deduplication.
* g++.dg/modules/lambda-7_b.C: Note we're testing ODR
deduplication.
* g++.dg/modules/default-arg-1_a.H: New test.
* g++.dg/modules/default-arg-1_b.C: New test.
* g++.dg/modules/default-arg-2_a.H: New test.
* g++.dg/modules/default-arg-2_b.C: New test.
* g++.dg/modules/default-arg-3.h: New test.
* g++.dg/modules/default-arg-3_a.H: New test.
* g++.dg/modules/default-arg-3_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
9 months agoc++/modules: Handle location exhaustion in write_location [PR105443]
Nathaniel Shead [Mon, 4 Nov 2024 16:08:54 +0000 (03:08 +1100)] 
c++/modules: Handle location exhaustion in write_location [PR105443]

The 'location_t' type currently only stores a limited number of distinct
locations.  In some cases, if many modules are imported that sum up to a
large number of locations, we may run out of room to represent new
locations for these imported declarations.  In such a case, any new
declarations from the affected modules simply get given a location of
"the module interface as a whole".

'write_location' sometimes gets confused when this happens: it finds that
the location is a location we've noted to get streamed out, but it's
inconsistent whether it's an ordinary location from the current module
or an imported location from a different module.  This causes
random-looking locations to be associated with these declarations, and
occasionally (checking-only) ICEs.

This patch fixes the issue by first checking whether an ordinary
location represents a module (rather than a location inside a module);
if so, we instead write the location of the point that we imported this
module.  This will continue recursively in case the importing location
also was not able to be stored.

We only need to handle this in the IS_ORDINARY_LOC case: even for
locations originally within macro expansions, the remapping logic for
location exhaustion will make them look like ordinary locs again.

This is a relatively expensive addition, so this new check only occurs
if we've noted resource exhaustion has occurred while preparing imported
line maps, or in checking builds.

PR c++/105443

gcc/cp/ChangeLog:

* module.cc (loc_spans::locs_exhausted_p): New field.
(loc_spans::loc_spans): Initialise it.
(loc_spans::locations_exhausted_p): New function.
(module_state::read_prepare_maps): Move inform into...
(loc_spans::report_location_exhaustion): ...this new function.
(module_state::write_location): Check for writing module
locations stored due to resource exhaustion.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
9 months agoDaily bump.
GCC Administrator [Tue, 5 Nov 2024 00:19:52 +0000 (00:19 +0000)] 
Daily bump.

9 months agosimulate-thread tests: Silence gdb debuginfod warning
H.J. Lu [Mon, 4 Nov 2024 22:22:00 +0000 (06:22 +0800)] 
simulate-thread tests: Silence gdb debuginfod warning

When gdb defaults to use debuginfod, gdb warns simulate-thread tests:

spawn gdb -nx -nw -batch -x /export/gnu/import/git/gitlab/x86-gcc/gcc/testsuite/gcc.dg/simulate-thread/simulate-thread.gdb ./atomic-load-int.exe
Breakpoint 1 at 0x4005cc: file /export/gnu/import/git/gitlab/x86-gcc/gcc/testsuite/gcc.dg/simulate-thread/atomic-load-int.c, line 97.

This GDB supports auto-downloading debuginfo from the following URLs:
  <https://debuginfod.fedoraproject.org/>
Enable debuginfod for this session? (y or [n]) [answered N; input not from terminal]
Debuginfod has been disabled.
To make this setting permanent, add 'set debuginfod enabled off' to .gdbinit.

Silence gdb warning by setting DEBUGINFOD_URLS to "" and restore it if
it exists.

PR testsuite/117300
* g++.dg/simulate-thread/simulate-thread.exp: Set DEBUGINFOD_URLS
to "" and restore it if it exists.
* gcc.dg/simulate-thread/simulate-thread.exp: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
9 months agolibstdc++: Remove workaround for modules issue [PR113814]
Nathaniel Shead [Mon, 4 Nov 2024 22:37:23 +0000 (09:37 +1100)] 
libstdc++: Remove workaround for modules issue [PR113814]

The modules bug requiring this workaround was fixed with commit
r15-4862-g815e48e3d42231.

PR testsuite/113710
PR c++/113814

libstdc++-v3/ChangeLog:

* include/bits/stl_pair.h: Remove workaround.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
9 months agoguality tests: Silence gdb debuginfod warning
H.J. Lu [Sat, 26 Oct 2024 21:51:18 +0000 (05:51 +0800)] 
guality tests: Silence gdb debuginfod warning

When gdb defaults to use debuginfod, gdb warns guality tests:

Spawning: gdb -nx -nw -quiet -batch -x pr36728-2.gdb ./pr36728-2.exe
spawn gdb -nx -nw -quiet -batch -x pr36728-2.gdb ./pr36728-2.exe
Breakpoint 1 at 0x4004ba: file /export/gnu/import/git/gitlab/x86-gcc/gcc/testsuite/gcc.dg/guality/pr36728-2.c, line 18.

This GDB supports auto-downloading debuginfo from the following URLs:
  <https://debuginfod.fedoraproject.org/>
Enable debuginfod for this session? (y or [n]) [answered N; input not from terminal]
Debuginfod has been disabled.
To make this setting permanent, add 'set debuginfod enabled off' to .gdbinit.

After 'set debuginfod enabled off' is added to ~/.gdbinit, gdb warning
doesn't go away since -nx option ignores ~/.gdbinit.  Silence gdb warning
by setting DEBUGINFOD_URLS to "" and restore if it exists.

PR testsuite/117300
* g++.dg/guality/guality.exp: Set DEBUGINFOD_URLS to "" and
restore it if it exists.
* gcc.dg/guality/guality.exp: Likewise.
* gfortran.dg/guality/guality.exp: Likewise.

Co-authored-by: Andrew Pinski <quic_apinski@quicinc.com>
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
9 months ago[PATCH v2 2/2] RISC-V: Disable by pieces for vector setmem length > UNITS_PER_WORD
Craig Blackmore [Mon, 4 Nov 2024 20:57:20 +0000 (13:57 -0700)] 
[PATCH v2 2/2] RISC-V: Disable by pieces for vector setmem length > UNITS_PER_WORD

For fast unaligned access targets, by pieces uses up to UNITS_PER_WORD
size pieces resulting in more store instructions than needed.  For
example gcc.target/riscv/rvv/base/setmem-2.c:f1 built with
`-O3 -march=rv64gcv -mtune=thead-c906`:
```
f1:
        vsetivli        zero,8,e8,mf2,ta,ma
        vmv.v.x v1,a1
        vsetivli        zero,0,e32,mf2,ta,ma
        sb      a1,14(a0)
        vmv.x.s a4,v1
        vsetivli        zero,8,e16,m1,ta,ma
        vmv.x.s a5,v1
        vse8.v  v1,0(a0)
        sw      a4,8(a0)
        sh      a5,12(a0)
        ret
```

The slow unaligned access version built with `-O3 -march=rv64gcv` used
15 sb instructions:
```
f1:
        sb      a1,0(a0)
        sb      a1,1(a0)
        sb      a1,2(a0)
        sb      a1,3(a0)
        sb      a1,4(a0)
        sb      a1,5(a0)
        sb      a1,6(a0)
        sb      a1,7(a0)
        sb      a1,8(a0)
        sb      a1,9(a0)
        sb      a1,10(a0)
        sb      a1,11(a0)
        sb      a1,12(a0)
        sb      a1,13(a0)
        sb      a1,14(a0)
        ret
```

After this patch, the following is generated in both cases:
```
f1:
        vsetivli        zero,15,e8,m1,ta,ma
        vmv.v.x v1,a1
        vse8.v  v1,0(a0)
        ret
```

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_use_by_pieces_infrastructure_p):
New function.
(TARGET_USE_BY_PIECES_INFRASTRUCTURE_P): Define.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/pr113469.c: Expect mf2 setmem.
* gcc.target/riscv/rvv/base/setmem-2.c: Update f1 to expect
straight-line vector memset.
* gcc.target/riscv/rvv/base/setmem-3.c: Likewise.

9 months ago[PATCH v2 1/2] RISC-V: Make vectorized memset handle more cases
Craig Blackmore [Mon, 4 Nov 2024 20:55:19 +0000 (13:55 -0700)] 
[PATCH v2 1/2] RISC-V: Make vectorized memset handle more cases

`expand_vec_setmem` only generated vectorized memset if it fitted into a
single vector store of at least (TARGET_MIN_VLEN / 8) bytes.  Also,
without dynamic LMUL the operation was always TARGET_MAX_LMUL even if it
would have fitted a smaller LMUL.

Allow vectorized memset to be generated for smaller lengths and smaller
LMUL by switching to using use_vector_string_op.  Smaller LMUL can be
seen in setmem-3.c:f3.  Smaller lengths will be seen after the second
patch in this series which selectively disables by pieces.

gcc/ChangeLog:

* config/riscv/riscv-string.cc
(use_vector_stringop_p): Add comment.
(expand_vec_setmem): Use use_vector_stringop_p instead of
check_vectorise_memory_operation.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/setmem-3.c: Expect smaller lmul.

9 months agolibgccjit: Add convert vector
Antoni Boucher [Sat, 14 May 2022 21:24:29 +0000 (17:24 -0400)] 
libgccjit: Add convert vector

gcc/jit/ChangeLog:

* docs/topics/compatibility.rst (LIBGCCJIT_ABI_30): New ABI tag.
* docs/topics/expressions.rst: Document gcc_jit_context_convert_vector.
* jit-playback.cc (convert_vector): New method.
* jit-playback.h: New method.
* jit-recording.cc (recording::context::new_convert_vector,
recording::convert_vector::replay_into,
recording::convert_vector::visit_children,
recording::convert_vector::make_debug_string,
recording::convert_vector::write_reproducer): New methods.
* jit-recording.h (class convert_vector): New class.
(context::new_convert_vector): New method.
* libgccjit.cc (gcc_jit_context_convert_vector): New function.
* libgccjit.h (gcc_jit_context_convert_vector): New function.
* libgccjit.map: New function.

gcc/testsuite/ChangeLog:

* jit.dg/all-non-failing-tests.h: New test.
* jit.dg/test-convert-vector.c: New test.

9 months agodiagnostics: update leading comment for class diagnostic_context
David Malcolm [Mon, 4 Nov 2024 19:48:23 +0000 (14:48 -0500)] 
diagnostics: update leading comment for class diagnostic_context

No functional change intended.

gcc/ChangeLog:
* diagnostic.h (class diagnostic_context): Update leading comment.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
9 months agodiagnostics: cleanups to opts-diagnostic.cc
David Malcolm [Mon, 4 Nov 2024 19:48:23 +0000 (14:48 -0500)] 
diagnostics: cleanups to opts-diagnostic.cc

No functional change intended.

gcc/ChangeLog:
* opts-diagnostic.cc: Apply renamings throughout for clarity: from
"name" and "format_name" to "scheme_name", from "m_format" to
"m_scheme_name", and from "handler" to "scheme_handler".
(output_factory::scheme_handler::get_handler): Pass name by const
reference.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
9 months agolibgccjit: Add gcc_jit_global_set_readonly
Antoni Boucher [Tue, 24 May 2022 21:45:01 +0000 (17:45 -0400)] 
libgccjit: Add gcc_jit_global_set_readonly

gcc/jit/ChangeLog:

* docs/topics/compatibility.rst (LIBGCCJIT_ABI_29): New ABI tag.
* docs/topics/expressions.rst: Document gcc_jit_global_set_readonly.
* jit-playback.cc (global_new_decl, new_global,
new_global_initialized): New parameter readonly.
* jit-playback.h (global_new_decl, new_global,
new_global_initialized): New parameter readonly.
* jit-recording.cc (recording::global::replay_into): Use
m_readonly.
(recording::global::write_reproducer): Dump reproducer for
gcc_jit_global_set_readonly.
* jit-recording.h (get_readonly, set_readonly): New methods.
(m_readonly): New attribute.
* libgccjit.cc (gcc_jit_global_set_readonly): New function.
(gcc_jit_block_add_assignment): Check that we don't assign to a
readonly variable.
* libgccjit.h (gcc_jit_global_set_readonly): New function.
(LIBGCCJIT_HAVE_gcc_jit_global_set_readonly): New define.
* libgccjit.map: New function.

gcc/testsuite/ChangeLog:

* jit.dg/all-non-failing-tests.h: Mention test-readonly.c.
* jit.dg/test-error-assign-readonly.c: New test.
* jit.dg/test-readonly.c: New test.

9 months agotestsuite: arm: Force hard ABI for pr51534.c test
Torbjörn SVENSSON [Thu, 31 Oct 2024 17:54:30 +0000 (18:54 +0100)] 
testsuite: arm: Force hard ABI for pr51534.c test

The test case is written in a way that it should be using hard float
ABI, but the use of -mfloat-abi=hard could be overriden by
dg-add-options arm_neon. Ensure that -mfloat-abi=hard is always after.

gcc/testsuite/ChangeLog:

* gcc.target/arm/pr51534.c: Ensure -mfloat-abi=hard is used.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
9 months agotestsuite: arm: Use effective-target for data-intrinsics-assembly test
Torbjörn SVENSSON [Sat, 19 Oct 2024 17:55:51 +0000 (19:55 +0200)] 
testsuite: arm: Use effective-target for data-intrinsics-assembly test

The expected assembler in the test case assumes -marm, so explicily
require it.

gcc/testsuite/ChangeLog:

* gcc.target/arm/acle/data-intrinsics-assembly.c: Use
effective-target arm_arch_v6_arm.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
9 months agotestsuite: arm: Relax cbranch tests to accept inverted branches
Torbjörn SVENSSON [Sat, 19 Oct 2024 15:54:59 +0000 (17:54 +0200)] 
testsuite: arm: Relax cbranch tests to accept inverted branches

Similar to PR113502, but for non-aarch64 test.
The test started to fail after r14-7243-gafac1bd3365.

gcc/testsuite/ChangeLog:

* gcc.target/arm/vect-early-break-cbranch.c: Ignore exact
branch.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
9 months agotestsuite: arm: Update expected asm in armv8_2-fp16-neon-2.c
Torbjörn SVENSSON [Thu, 24 Oct 2024 18:06:21 +0000 (20:06 +0200)] 
testsuite: arm: Update expected asm in armv8_2-fp16-neon-2.c

With the changes in r15-1579-g792f97b44ff, the test_vmul_n_16x8 function
does not contain any vdup.16 q* r* instruction with -mfloat-abi=softfp.

The differnce between r15-1578-g5185274c76c and r15-1579-g792f97b44ff
with -mfloat-abi=softfp for the function is:
        .global test_vmul_n_16x8
        .syntax unified
        .arm
        .type   test_vmul_n_16x8, %function
 test_vmul_n_16x8:
        @ args = 4, pretend = 0, frame = 0
        @ frame_needed = 0, uses_anonymous_args = 0
        @ link register save eliminated.
        vmov    d16, r0, r1  @ v8hf
        vmov    d17, r2, r3
-       ldrh    r3, [sp]        @ __fp16
-       vdup.16 q9, r3
+       vld1.16 {d18[], d19[]}, [sp]
        vmul.f16        q8, q9, q8
        vmov    r0, r1, d16  @ v8hf
        vmov    r2, r3, d17
        bx      lr
        .size   test_vmul_n_16x8, .-test_vmul_n_16x8

gcc/testsuite/ChangeLog:

* gcc.target/arm/armv8_2-fp16-neon-2.c: Expect 3 vdup.16 q* r*
when in arm_hf_eabi else 2.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
9 months agolibgccjit: Add count zeroes builtins to ensure_optimization_builtins_exist
Antoni Boucher [Fri, 9 Feb 2024 02:48:27 +0000 (21:48 -0500)] 
libgccjit: Add count zeroes builtins to ensure_optimization_builtins_exist

gcc/jit/ChangeLog:

* jit-builtins.cc (ensure_optimization_builtins_exist): Add
missing builtins.

9 months agoada: Move special case for null string literal from frontend to backend
Piotr Trojanek [Tue, 15 Oct 2024 08:53:47 +0000 (10:53 +0200)] 
ada: Move special case for null string literal from frontend to backend

Previously the lower bound of string literals indexed by non-static
integer types was artificially set to 1 in the frontend. This was to
avoid an overflow in calculation of a null string size by the GCC
backend, which was causing an excessively large binary object file.

However, setting the lower bound to 1 was problematic for GNATprove,
which could not easily retrieve the lower bound of string literals.

This patch avoids the overflow in GCC by recognizing null string literal
subtypes in Gigi.

gcc/ada/ChangeLog:

* gcc-interface/decl.cc (gnat_to_gnu_entity): Recognize null
string literal subtypes and set their bounds to 1 .. 0.

9 months agoada: Remove special case for the size of a string literal subtype
Piotr Trojanek [Tue, 15 Oct 2024 08:01:32 +0000 (10:01 +0200)] 
ada: Remove special case for the size of a string literal subtype

Apparently we no longer need to ignore string literal subtypes case
when validating size of a type entity.

Code cleanup; behavior appears to be unaffected.

gcc/ada/ChangeLog:

* gcc-interface/decl.cc (gnat_to_gnu_entity): Remove special
case for string literal subtypes.

9 months agoada: Fix ancient typo in process_decls
Eric Botcazou [Fri, 11 Oct 2024 20:40:29 +0000 (22:40 +0200)] 
ada: Fix ancient typo in process_decls

It has gone unnoticed for decades because it changes nothing in practice.

gcc/ada/ChangeLog:

* gcc-interface/trans.cc (process_decls): Remove tests on Nkind that
contain a typo and would be redundant if written correctly.

9 months agoada: Split Library_Unit using multiple wrappers
Bob Duff [Thu, 17 Oct 2024 16:04:45 +0000 (12:04 -0400)] 
ada: Split Library_Unit using multiple wrappers

The Library_Unit field was used for all sorts of different purposes,
which led to confusing code.

This patch splits Library_Unit into much more specific wrapper
subprograms that should be called instead of [Set_]Library_Unit.
Predicates and pragmas Assert are used to catch misuses of these.
We document the semantics, especially "surprising" cases (e.g.
internally-generated with clauses can refer to package bodies).

This change does not fix gigi, codepeer, spark, or llvm
to use the new wrappers; so far, they are used only in
the GNAT front end.

gcc/ada/ChangeLog:

* sinfo.ads (Library_Unit): Rewrite documentation. Note that
the "??? not (always) true..." comment was not true;
the Subunit_Parent never points to the spec.
(N_Compilation_Unit): Improve documentation. The Aux_ node
was not created to solve the mentioned problems; it was
created because the size of nodes was limited.
Misc doc improvements.
* sinfo-utils.ads: Add new wrappers for Library_Unit field.
Use subtypes with predicates for the parameters.
(First_Real_Statement): Still used in codepeer.
* sinfo-utils.adb: Add new wrappers for Library_Unit field,
with suitable assertions.
* sem_prag.adb: Use new field wrapper names.
(Matching_Name): New name for Same_Name to avoid
potential confusion with the other function with the
same name (Sem_Util.Same_Name), which is also called
in this same file.
(Matching_Convention): Change Same_Convention to match
Matching_Name.
* sem_util.ads (Same_Name): Improve comments; the old comment
implied that it works for all names, which was not true.
* sem_util.adb: Use new field wrapper names.
* gen_il-gen.adb: Rename N_Unit_Body to be N_Lib_Unit_Body.
Plain "unit" is ambiguous in Ada (library unit, compilation
unit, program unit, etc).
Add new union types N_Lib_Unit_Declaration and
N_Lib_Unit_Renaming_Declaration.
* gen_il-gen-gen_nodes.adb (Compute_Ranges): Raise exception
earlier (it is already raised later, in Verify_Type_Table).
Add a comment explaining why it might be raised.
* gen_il-types.ads: Rename N_Unit_Body to be N_Lib_Unit_Body, and add
new N_Lib_Unit_Declaration and N_Lib_Unit_Renaming_Declaration.
* einfo.ads: Fix obsolete comment (was left over from before
the "variable-sized nodes").
* exp_ch7.adb: Use new field wrapper names.
* exp_disp.adb: Use new field wrapper names.
* exp_unst.adb: Use new field wrapper names.
* exp_util.adb: Use new field wrapper names.
* fe.h: Add new field wrapper names. These are currently not
used in gigi, but this change prepares for using them in
gigi.
* inline.adb: Use new field wrapper names.
* lib.adb: Use new field wrapper names.
Comment improvements.
* lib-load.adb: Use new field wrapper names.
Minor cleanup.
* lib-writ.adb: Use new field wrapper names.
* live.adb: Use new field wrapper names.
* par-load.adb: Use new field wrapper names.
Comment improvements. Minor cleanup.
* rtsfind.adb: Use new field wrapper names.
* sem.adb: Use new field wrapper names.
* sem_ch10.adb: Use new field wrapper names.
Comment improvements. Minor cleanup.
* sem_ch12.adb: Use new field wrapper names.
* sem_ch7.adb: Use new field wrapper names.
* sem_ch8.adb: Use new field wrapper names.
* sem_elab.adb: Use new field wrapper names.
Comment improvements.
* errout.adb (Output_Source_Line): Fix blowup in some
obscure cases, where List_Pragmas is not fully set up.

9 months agoada: Improve Unbounded_Wide_String performance
Nicolas Roche [Wed, 16 Oct 2024 09:56:35 +0000 (11:56 +0200)] 
ada: Improve Unbounded_Wide_String performance

Improve performance of iteration using Element function.
Improve performance of Append.

gcc/ada/ChangeLog:

* libgnat/a-stwiun__shared.adb: Restructure code to inline only
the most common cases. Remove whenever possible runtime checks.
* libgnat/a-stwiun__shared.ads: Add Inline => True to Append
variants and Element.

9 months agoada: Improve performance of Unbounded_Wide_Wide_String
Nicolas Roche [Wed, 25 Sep 2024 11:21:04 +0000 (13:21 +0200)] 
ada: Improve performance of Unbounded_Wide_Wide_String

Improve performance of iteration using Element function.
Improve performance of Append.

gcc/ada/ChangeLog:

* libgnat/a-stzunb__shared.adb: Restructure code to inline only
the most common cases. Remove whenever possible runtime checks.
* libgnat/a-stzunb__shared.ads: Add Inline => True to Append
variants and Element.

9 months agoada: Improve Unbounded_String performance
Nicolas Roche [Wed, 25 Sep 2024 10:31:14 +0000 (12:31 +0200)] 
ada: Improve Unbounded_String performance

Improve performance of iteration using Element function.
Improve performance of Append.

gcc/ada/ChangeLog:

* libgnat/a-strunb__shared.adb: Restructure code to inline only
the most common cases. Remove whenever possible runtime checks.
* libgnat/a-strunb__shared.ads: Add Inline => True to Append
variants and Element.

9 months agoada: Initial implementation of Extended_Access aspect (FE portion only)
Steve Baird [Wed, 17 Jul 2024 22:21:01 +0000 (15:21 -0700)] 
ada: Initial implementation of Extended_Access aspect (FE portion only)

The Extended_Access aspect can be specified to be True for certain
access-to-unconstrained-array-subtype types. Such extended access types
can designate objects that a normal general access type (with the same
designated subtype) cannot, such as a slice of an aliased array object
or an object that is represented without contiguous bounds information.

gcc/ada/ChangeLog:

* aspects.ads: Add Aspect_Extended_Access to Aspect_Id
enumeration.
* par-prag.adb: Add Pragma_Extended_Access to list of pragmas that
get no interesting processing in the parser.
* sem_attr.adb: Relax legality checks on Access/Unchecked_Access
attribute references if access type is Extended_Access.
* sem_ch12.adb (Validate_Access_Type_Instance): For an instance of
a generic with a formal access type, check that formal and actual
agree with with respect to Extended_Access aspect.
* sem_prag.adb (Analyze_Pragma): Add analysis code for pragma
Extended_Access. Set Pragma_Extended_Access element in Sig_Flags
aggregate.
* sem_prag.ads: Set Pragma_Extended_Access element in
Aspect_Specifying_Pragma aggregate.
* sem_res.adb (Valid_Conversion): Disallow
extended-to-not-extended access conversion.
* sem_util.adb (Is_Extended_Access_Access_Type): Implement new
function.
(Is_Aliased_View): If (and only if) the new Boolean For_Extended
parameter is True, then a slice of an aliased non-bitpacked array
is aliased, a constrained nominal subtype does not force a result
of False, and a dereference of an extended access value is
aliased. The last point is somewhat subtle. This is how we prevent
covert fat-to-nonfat type conversions via things like
"Not_Extended_Type'(Extended_Ptr.all'Access)" or passing
Extended_Ptr.all as an actual parameter corresponding to an
explicitly aliased formal parameter.
* sem_util.ads (Is_Extended_Access_Type): Declare new function.
(Is_Aliased_View): Add new defaults-False parameter For_Extended.
* snames.ads-tmpl: Declare Name_Extended_Access Name_Id constant
and Pragma_Extended_Access Pragma_Id enumeration literal.

9 months agoada: Avoid unused with warning with Extend_System
Viljar Indus [Wed, 16 Oct 2024 09:01:38 +0000 (12:01 +0300)] 
ada: Avoid unused with warning with Extend_System

When the Extend_System pragma is used then we are supposed
to check the extended system for referenced entities. Otherwise
we would get an incorrect unused with warning.

This was previously done on body files but it should also be
done specs as well.

gcc/ada/ChangeLog:

* sem_warn.adb (Check_One_Unit): When a system extension is
present always check entities from that unit before marking
the unit unreferenced.

9 months agoada: Fix crash on default value with nested iterated component associations
Eric Botcazou [Wed, 16 Oct 2024 07:05:55 +0000 (09:05 +0200)] 
ada: Fix crash on default value with nested iterated component associations

The problem is that the freeze node for the type of the element ends up in
the component list of the record type declared with the default value.

gcc/ada/ChangeLog:

PR ada/113036
* freeze.adb (Freeze_Expression): Deal with freezing actions coming
from within nested internal loops present in spec expressions.

9 months agoada: Propagate resolution status from Resolve_Iterated_Component_Association
Eric Botcazou [Tue, 15 Oct 2024 19:41:45 +0000 (21:41 +0200)] 
ada: Propagate resolution status from Resolve_Iterated_Component_Association

The resolution status of Resolve_Aggr_Expr is lost when the routine is
invoked indirectly from Resolve_Iterated_Component_Association.

gcc/ada/ChangeLog:

* sem_aggr.adb (Resolve_Iterated_Component_Association): Change to
function returning Boolean and return the result of the call made
to Resolve_Aggr_Expr.
(Resolve_Array_Aggregate): Return failure status if the call to
Resolve_Iterated_Component_Association returns false.

9 months agoada: Remove dead code in Resolve_Iterated_Component_Association
Eric Botcazou [Tue, 15 Oct 2024 13:18:05 +0000 (15:18 +0200)] 
ada: Remove dead code in Resolve_Iterated_Component_Association

It dates back to when analysis was performed on a copy of the expression.

gcc/ada/ChangeLog:

* sem_aggr.adb (Resolve_Iterated_Component_Association): Move up
declaration of Expr and remove dead code from older processing.

9 months agoada: Update documentation for -gnatVxx switches
Viljar Indus [Tue, 15 Oct 2024 10:49:07 +0000 (13:49 +0300)] 
ada: Update documentation for -gnatVxx switches

Imporve the wording to explicitly state which options are turned on
by -gnatVa and that -gnatVd is enabled by default.

It can be somewhat hard to decifer that information from the old
wording. Especially when compared to -gnatWxx switches where there
is an elaborate scheme for describing those properties.

gcc/ada/ChangeLog:

* usage.adb: Update the wording for -gnatVa and -gnatVd.

9 months agoada: Tweak description of new predicate
Eric Botcazou [Mon, 14 Oct 2024 07:54:55 +0000 (09:54 +0200)] 
ada: Tweak description of new predicate

The existing comment is a bit too vague.

gcc/ada/ChangeLog:

* exp_aggr.ads (Is_Two_Pass_Aggregate): Beef up comment.

9 months agoada: Display message on reproducer generation failure
Ronan Desplanques [Mon, 14 Oct 2024 08:15:11 +0000 (10:15 +0200)] 
ada: Display message on reproducer generation failure

Before this patch, nothing was reported to the user when an exception
was raised during generation of a minimal reproducer. This patch fixes
this.

gcc/ada/ChangeLog:

* comperr.adb (Compiler_Abort): Display message in exception handler.

9 months agoada: Missing runtime check in interpolated string
Javier Miranda [Tue, 15 Oct 2024 09:32:43 +0000 (09:32 +0000)] 
ada: Missing runtime check in interpolated string

When the type imposed by the context for an interpolated string is
constrained, the compiler silently omits adding a runtime check.

gcc/ada/ChangeLog:

* exp_ch2.adb (Expand_N_Interpolated_String_Literal): Use the
base type of the type imposed by the context for building the
interpolated string image; required to allow the expander adding
the missing runtime check when the target type is constrained.
(Apply_Static_Length_Check): New subprogram.

9 months agoada: Add CHERI variant of full secondary stack allocator
Daniel King [Mon, 14 Oct 2024 09:09:28 +0000 (10:09 +0100)] 
ada: Add CHERI variant of full secondary stack allocator

gcc/ada/ChangeLog:

* Makefile.rtl: Use s-secsta__cheri.adb on Morello CheriBSD.
* libgnat/s-secsta__cheri.adb: New file.

9 months agoada: CheriBSD: add SIGPROT handler
Daniel King [Mon, 14 Oct 2024 09:08:26 +0000 (10:08 +0100)] 
ada: CheriBSD: add SIGPROT handler

gcc/ada/ChangeLog:

* libgnarl/s-intman__cheribsd.adb: Add SIGPROT to interrupt list.

9 months agoada: Add Invocation node to the SARIF report
Viljar Indus [Fri, 11 Oct 2024 13:34:36 +0000 (16:34 +0300)] 
ada: Add Invocation node to the SARIF report

Add an invocation node to the SARIF report that contains the
command line use to activate gnat and whether the execution was
successful or not.

gcc/ada/ChangeLog:

* diagnostics-sarif_emitter.adb (Print_Runs): Add printing for
the invocation node that consists of a single invocations that
is composed of the commandLine and executionSuccessful attributes.

9 months agoada: Add Schema to the SARIF report
Viljar Indus [Fri, 11 Oct 2024 10:19:04 +0000 (13:19 +0300)] 
ada: Add Schema to the SARIF report

gcc/ada/ChangeLog:

* diagnostics-sarif_emitter.adb (Print_SARIF_Report): Add a
Schema field to the SARIF report.

9 months agoada: Tweak CPU affinity handling
Ronan Desplanques [Fri, 11 Oct 2024 12:54:15 +0000 (14:54 +0200)] 
ada: Tweak CPU affinity handling

The primary motivation for this change is making the taskset command
line tool work as expected for tasking programs that don't use features
from section D.16 of the Ada reference manual. A couple of components
are added to the ATCB record to make it possible to tell values that
come from explicit aspects and subprogram calls from values that are
inherited from activating tasks.

gcc/ada/ChangeLog:

* libgnarl/s-mudido__affinity.adb (Unchecked_Set_Affinity): Set new
ATCB component.
* libgnarl/s-taprop__linux.adb (Create_Task): Only set CPU affinity
when required.
(Requires_Affinity_Change): New subprogram.
(Set_Task_Affinity): Likewise.
* libgnarl/s-tarest.adb (Create_Restricted_Task): Adapt to
Initialize_ATCB change.
* libgnarl/s-taskin.adb (Initialize_ATCB): Update parameter list.
Record whether aspects were explicitly specified.
* libgnarl/s-taskin.ads (Common_ATCB): Add component.
* libgnarl/s-tassta.adb (Create_Task): Update call to Initialize_ATCB.
* libgnarl/s-tporft.adb (Register_Foreign_Thread): Likewise.

9 months agoada: Fix error message for pragma First_Controlling_Parameter
Raphaël AMIARD [Fri, 11 Oct 2024 13:56:45 +0000 (15:56 +0200)] 
ada: Fix error message for pragma First_Controlling_Parameter

gcc/ada/ChangeLog:

* sem_prag.adb (Analyze_Pragma): Fix format for second line of
warning (should be a continuation line)

9 months agoada: Build and runtime support for CheriBSD
Daniel King [Fri, 13 Sep 2024 15:15:32 +0000 (16:15 +0100)] 
ada: Build and runtime support for CheriBSD

SIGPROT is a new signal on CheriBSD that signals a CHERI protection violation.
The full runtime converts these to the appropriate Ada exception declared in
Interfaces.CHERI.Exceptions.

gcc/ada/ChangeLog:

* Makefile.rtl: Build support for Morello CheriBSD.
* libgnarl/s-intman__cheribsd.adb: New file for CheriBSD.
* libgnarl/s-osinte__cheribsd.ads: New file for CheriBSD.

9 months agoada: Refactor exception declarations from Interfaces.CHERI to separate package
Daniel King [Mon, 23 Sep 2024 09:50:13 +0000 (10:50 +0100)] 
ada: Refactor exception declarations from Interfaces.CHERI to separate package

Exception declarations require elaboration on the full run-time to
register the exceptions. The package Interfaces.CHERI, however, is
used on bare-metal targets during early initialization, before
elaboration and is therefore marked No_Elaboration_Code_All.
Refactoring the exception declarations to a separate package allows
the common CHERI bindings to be used in such contexts.

gcc/ada/ChangeLog:

* libgnat/i-cheri.ads: Remove exception declarations.
* libgnat/i-cheri-exceptions.ads: New file.

9 months agoada: Fix alignment of pthread_mutex_t
Daniel King [Fri, 13 Sep 2024 15:16:52 +0000 (16:16 +0100)] 
ada: Fix alignment of pthread_mutex_t

On most targets the alignment of unsigned long is the same as pointer
alignment, but on CHERI targets pointers have larger alignment (16 bytes
compared to 8 bytes). pthread_mutex_t needs the same alignment as
System.Address to account for CHERI targets.

gcc/ada/ChangeLog:

* libgnat/s-oslock__posix.ads: Fix alignment of pthread_mutex_t
for CHERI targets.

9 months agoada: Move formal hash tables from gnat repository to the SPARK library
Claire Dross [Thu, 10 Oct 2024 14:51:13 +0000 (16:51 +0200)] 
ada: Move formal hash tables from gnat repository to the SPARK library

The formal containers have been part of the SPARK library for some
time now. However, some units used only by these containers are still
part of the gnat repository. Move them to the SPARK library.

gcc/ada/ChangeLog:

* Makefile.rtl: Remove references to moved units.
* libgnat/a-chtgfk.adb: Removed.
* libgnat/a-chtgfk.ads: Removed.
* libgnat/a-chtgfo.adb: Removed.
* libgnat/a-chtgfo.ads: Removed.
* libgnat/a-cohata.ads (Generic_Formal_Hash_Table_Types): Removed.

9 months agoada: Add doc for deep delta aggregates
Raphaël AMIARD [Mon, 23 Sep 2024 09:00:34 +0000 (11:00 +0200)] 
ada: Add doc for deep delta aggregates

gcc/ada/ChangeLog:

* doc/gnat_rm/gnat_language_extensions.rst: Adjust documentation.
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.

9 months agoada: Fix internal error on alignment clause for type declared in generic unit
Eric Botcazou [Thu, 10 Oct 2024 11:06:12 +0000 (13:06 +0200)] 
ada: Fix internal error on alignment clause for type declared in generic unit

The front-end raises Program_Error on an alignment clause for a type in a
generic unit that references the alignment of another type in the unit.

gcc/ada/ChangeLog:

PR ada/117051
* freeze.adb (Freeze_Entity): Call the layout procedure on subtypes
declared in a generic unit when they are static.

9 months agoada: Minor tweaks in comments
Eric Botcazou [Wed, 9 Oct 2024 22:12:05 +0000 (00:12 +0200)] 
ada: Minor tweaks in comments

They are related to the special support for text encoding on Windows.

gcc/ada/ChangeLog:

* adaint.c: Replace initialize.c with rtinit.c in comment.
* sysdep.c (__gnat_set_mode): Fix reference in comment.
* libgnat/i-cstrea.ads (Content_Encoding): Adjust comment.

9 months agoada: Correction to disable self-referential with_clauses
Bob Duff [Wed, 9 Oct 2024 11:25:14 +0000 (07:25 -0400)] 
ada: Correction to disable self-referential with_clauses

Follow-on to previous change "Disable self-referential with_clauses",
which caused some regressions. Remove useless use clauses referring
to useless self-referential with'ed packages. This is necessary
because in some cases, such use clauses cause the compiler to
crash or give spurious errors.

In addition, enable the warning on self-referential with_clauses.

gcc/ada/ChangeLog:

* sem_ch10.adb (Analyze_With_Clause): In the case of a
self-referential with clause, if there is a subsequent use clause
for the same package (which is necessarily useless), remove it from
the context clause. Reenable the warning.

9 months agoada: Missing precondition runtime check in inherited primitive
Javier Miranda [Tue, 8 Oct 2024 18:33:37 +0000 (18:33 +0000)] 
ada: Missing precondition runtime check in inherited primitive

When a derived tagged type implements interface types in addition
to deriving from its parent type, and a primitive inherited from
its parent type corresponds to an inherited primitive that has
class-wide preconditions, then the generated code fails to check
the class-wide preconditions inherited from the interface primitive.

gcc/ada/ChangeLog:

* einfo.ads (Is_Dispatch_Table_Wrapper): Complete documentation.
* exp_ch6.adb (Install_Class_Preconditions_Check): Dispatch table
wrappers do not require installing the check since it is performed
by the caller.
(Class_Preconditions_Subprogram): Use new predicate Is_LSP_Wrapper.
* freeze.adb (Check_Inherited_Conditions): Rename Postcond_Wrappers to
Condition_Wrappers to handle implicitly inherited subprograms that
implement pre-/postconditions inherited from interface primitives.
Use new predicate Is_LSP_Wrapper.
* sem_disp.adb (Check_Dispatching_Operation): Complete assertion to
handle functions returning class-wide types.
* exp_util.ads (Is_LSP_Wrapper): New subprogram.
* exp_util.adb (Is_LSP_Wrapper): New subprogram.
* contracts.adb (Process_Spec_Postconditions): Use Is_LSP_Wrapper.
(Process_Inherited_Conditions): Use Is_LSP_Wrapper.
* sem_ch6.adb (New_Overloaded_Entity): Use Is_LSP_Wrapper.
* sem_util.adb (Nearest_Class_Condition_Subprogram): Use Is_LSP_Wrapper.

9 months agoada: Fix visibility of Taft amendment types
Piotr Trojanek [Tue, 8 Oct 2024 20:52:38 +0000 (22:52 +0200)] 
ada: Fix visibility of Taft amendment types

When uninstalling private package declarations we must mark Taft
amendment types hidden, just like we mark other types.

Looking at previous revisions of this code, it is quite clear that this
bug comes from a code evolution and marking types should happen in all
ELSE branches of the enclosing IF statement.

gcc/ada/ChangeLog:

* sem_ch7.adb (Uninstall_Declarations): Mark Taft amendment
types like we mark other types declared in private package
declarations.

9 months agoada: Minor whitespace tuning
Piotr Trojanek [Fri, 27 Sep 2024 15:53:29 +0000 (17:53 +0200)] 
ada: Minor whitespace tuning

Code cleanup.

gcc/ada/ChangeLog:

* exp_ch4.adb (Expand_N_Op_Multiply): Remove extra whitespace.

9 months agoada: Avoid run-time conversion of 0 from Int to Uint
Piotr Trojanek [Fri, 27 Sep 2024 15:53:29 +0000 (17:53 +0200)] 
ada: Avoid run-time conversion of 0 from Int to Uint

Code cleanup and tiny performance improvement; semantics is unaffected.

gcc/ada/ChangeLog:

* exp_ch4.adb (Expand_N_Op_Subtract): Replace numeric literal
with universal integer constant, just like it is done in
expansion of addition operator.

9 months agoada: Assignment local variable only when it is used
Piotr Trojanek [Fri, 27 Sep 2024 14:56:52 +0000 (16:56 +0200)] 
ada: Assignment local variable only when it is used

Code cleanup; semantics is unaffected.

gcc/ada/ChangeLog:

* sem_res.adb (In_Decl): Rename and move local variable where
it is used.

9 months agoada: Add null exclusion to avoid run-time checks
Piotr Trojanek [Fri, 27 Sep 2024 14:56:37 +0000 (16:56 +0200)] 
ada: Add null exclusion to avoid run-time checks

By declaring access parameter with non-null qualifier, the compiler
should avoid generating run-time checks in debug builds, resulting in
a tiny performance improvement.

Code cleanup; semantics is unaffected.

gcc/ada/ChangeLog:

* sem_res.adb (Type_In_P): Add non-null qualifier.

9 months agoada: Resolve intrinsic operators without homonyms
Piotr Trojanek [Fri, 27 Sep 2024 08:47:29 +0000 (10:47 +0200)] 
ada: Resolve intrinsic operators without homonyms

Intrinsic operators are resolved by rewriting into a corresponding
operator from the Standard package. Traversing homonyms just to find the
corresponding operator was not particularly efficient; also, for the
binary "-" it was finding the unary "-".

There appears to be no difference in compiler behavior, but the new code
should be more efficient and finding the correct operator seems to make
more sense.

gcc/ada/ChangeLog:

* sem_res.adb (Resolve_Intrinsic_Operator)
(Resolve_Intrinsic_Unary_Operator): Replace traversals of
homonyms with a direct lookup.

9 months agoada: Fix asymmetry in resolution of unary intrinsic operators
Piotr Trojanek [Thu, 26 Sep 2024 06:40:28 +0000 (08:40 +0200)] 
ada: Fix asymmetry in resolution of unary intrinsic operators

Resolution of binary and unary intrinsic operators differed when
expansion was inactive. In particular, this affected GNATprove
handling of Ada.Real_Time."abs" operator. This patch makes unary
resolution behave like binary resolution.

gcc/ada/ChangeLog:

* sem_res.adb (Resolve_Intrinsic_Unary_Operator): Disable when
expansion is inactive.

9 months agoPR 117048: simplify-rtx: Simplify (X << C1) [+,^] (X >> C2) into ROTATE
Kyrylo Tkachov [Mon, 4 Nov 2024 15:25:16 +0000 (07:25 -0800)] 
PR 117048: simplify-rtx: Simplify (X << C1) [+,^] (X >> C2) into ROTATE

This is, in effect, a reapplication of de2bc6a7367aca2eecc925ebb64cfb86998d89f3
fixing the compile-time hog in var-tracking due to calling simplify_rtx
on the two arms of the rotation before detecting the ROTATE.
That is not necessary.

simplify-rtx can transform (X << C1) | (X >> C2) into ROTATE (X, C1) when
C1 + C2 == mode-width.  But the transformation is also valid for PLUS and XOR.
Indeed GIMPLE can also do the fold.  Let's teach RTL to do it too.

The motivating testcase for this is in AArch64 intrinsics:

uint64x2_t G2(uint64x2_t a, uint64x2_t b) {
    uint64x2_t c = veorq_u64(a, b);
    return veorq_u64(vaddq_u64(c, c), vshrq_n_u64(c, 63));
}

which I was hoping to fold to a single XAR (a ROTATE+XOR instruction) but
GCC was failing to detect the rotate operation for two reasons:
1) The combination of the two arms of the expression is done under XOR rather
than IOR that simplify-rtx currently supports.
2) The ASHIFT operation is actually a (PLUS X X) operation and thus is not
detected as the LHS of the two arms we require.

The patch fixes both issues.  The analysis of the two arms of the rotation
expression is factored out into a common helper simplify_rotate_op which is
then used in the PLUS, XOR, IOR cases in simplify_binary_operation_1.

The check-assembly testcase for this is added in the following patch because
it needs some extra AArch64 backend work, but I've added self-tests in this
patch to validate the transformation.

Bootstrapped and tested on aarch64-none-linux-gnu

Signed-off-by: Kyrylo Tkachov <ktachov@nvidia.com>
PR target/117048
* simplify-rtx.cc (extract_ashift_operands_p): Define.
(simplify_rotate_op): Likewise.
(simplify_context::simplify_binary_operation_1): Use the above in
the PLUS, IOR, XOR cases.
(test_vector_rotate): Define.
(test_vector_ops): Use the above.

9 months agotarget: Fix asm codegen for vfpclasss* and vcvtph2* instructions
Antoni Boucher [Mon, 23 Sep 2024 22:58:47 +0000 (18:58 -0400)] 
target: Fix asm codegen for vfpclasss* and vcvtph2* instructions

This only happens when using -masm=intel.

gcc/ChangeLog:
PR target/116725
* config/i386/sse.md: Fix asm generation.

gcc/testsuite/ChangeLog:
PR target/116725
* gcc.target/i386/pr116725.c: Add test using those AVX builtins.

9 months agoDon't call invert on VARYING.
Andrew MacLeod [Sat, 2 Nov 2024 14:26:24 +0000 (10:26 -0400)] 
Don't call invert on VARYING.

When all cases go to one label and resul in a VARYING value, we can't
invert that value to remove all values from the default case. Simply
check for this case and set the default to UNDEFINED.

PR tree-optimization/117398
gcc/
* gimple-range-edge.cc (gimple_outgoing_range::calc_switch_ranges):
Check for VARYING and don't call invert () on it.

gcc/testsuite/
* gcc.dg/pr117398.c: New.

9 months agoRevert "PR 117048: simplify-rtx: Simplify (X << C1) [+,^] (X >> C2) into ROTATE"
Kyrylo Tkachov [Mon, 4 Nov 2024 13:04:59 +0000 (14:04 +0100)] 
Revert "PR 117048: simplify-rtx: Simplify (X << C1) [+,^] (X >> C2) into ROTATE"

This reverts commit de2bc6a7367aca2eecc925ebb64cfb86998d89f3.

9 months agoaarch64: Fix incorrect LS64 documentation
Richard Sandiford [Mon, 4 Nov 2024 12:23:24 +0000 (12:23 +0000)] 
aarch64: Fix incorrect LS64 documentation

As Yuta Mukai pointed out, the manual wrongly said that LS64 is
enabled by default for Armv8.7-A and above, and for Armv9.2-A
and above.  LS64 is not mandatory at any architecture level
(and the code correctly implemented that).

I think this was a leftover from an early version of the spec.

gcc/
* doc/invoke.texi: Fix documentation of LS64 so that it's
not implied by Armv8.7-A or Armv9.2-A.

9 months agoaarch64: Add support for FUJITSU-MONAKA (-mcpu=fujitsu-monaka) CPU
Yuta Mukai [Mon, 4 Nov 2024 12:23:24 +0000 (12:23 +0000)] 
aarch64: Add support for FUJITSU-MONAKA (-mcpu=fujitsu-monaka) CPU

This patch adds initial support for FUJITSU-MONAKA CPU.
The cost model will be corrected in the future.

2024-11-04  Yuta Mukai  <mukai.yuta@fujitsu.com>

gcc/ChangeLog:

* config/aarch64/aarch64-cores.def (AARCH64_CORE): Add fujitsu-monaka.
* config/aarch64/aarch64-tune.md: Regenerate.
* config/aarch64/aarch64.cc: Include fujitsu-monaka tuning model.
* doc/invoke.texi: Document -mcpu=fujitsu-monaka.
* config/aarch64/tuning_models/fujitsu_monaka.h: New file.

9 months agolibstdc++: Fix up 117406.cc test [PR117406]
Jakub Jelinek [Mon, 4 Nov 2024 11:29:01 +0000 (12:29 +0100)] 
libstdc++: Fix up 117406.cc test [PR117406]

Christophe mentioned in bugzilla that the test FAILs on aarch64,
I'm not including <climits> and use INT_MAX.
Apparently during my testing I got it because the test preinclude
-include bits/stdc++.h
and that includes <climits>, dunno why that didn't happen on aarch64.
In any case, either I can add #include <climits>, or because the
test already has #include <limits> I've changed uses of INT_MAX
with std::numeric_limits<int>::max(), that should be the same thing.
But if you prefer
 #include <climits>
I can surely add that instead.

2024-11-04  Jakub Jelinek  <jakub@redhat.com>

PR libstdc++/117406
* testsuite/26_numerics/headers/cmath/117406.cc: Use
std::numeric_limits<int>::max() instead of INT_MAX.

9 months agoMove vect_update_inits_of_drs
Richard Biener [Thu, 31 Oct 2024 11:58:02 +0000 (12:58 +0100)] 
Move vect_update_inits_of_drs

Move vect_update_inits_of_drs to after setting up the epilog
metadata.

* tree-vect-loop.cc (update_epilogue_loop_vinfo): Update
DR inits after adjusting the epilog metadata.