]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
103 min agoc++: uninitialized TARGET_EXPR and constexpr [PR120684] master trunk
Jason Merrill [Wed, 2 Jul 2025 22:03:57 +0000 (18:03 -0400)] 
c++: uninitialized TARGET_EXPR and constexpr [PR120684]

In r15-7532 for PR118856 I introduced a TARGET_EXPR with a
TARGET_EXPR_INITIAL of void_node to express that no initialization is done.
And indeed evaluating that doesn't store a value for the TARGET_EXPR_SLOT
variable.

But then at the end of the full-expression, destroy_value stores void_node
to express that its lifetime has ended.  If we evaluate the same
full-expression again, global_ctx->values still holds the void_node, causing
confusion when we try to destroy it again.  So clear out any value before
evaluating a TARGET_EXPR_INITIAL of void_type.

PR c++/120684
PR c++/118856

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_constant_expression) [TARGET_EXPR]: Clear
the value first if is_complex.

gcc/testsuite/ChangeLog:

* g++.dg/cpp23/range-for10.C: New test.

5 hours agoDaily bump.
GCC Administrator [Thu, 3 Jul 2025 00:17:51 +0000 (00:17 +0000)] 
Daily bump.

10 hours agox86-64: Add RDI clobber to tls_global_dynamic_64 patterns
H.J. Lu [Tue, 1 Jul 2025 09:17:06 +0000 (17:17 +0800)] 
x86-64: Add RDI clobber to tls_global_dynamic_64 patterns

*tls_global_dynamic_64_<mode> uses RDI as the __tls_get_addr argument.
Add RDI clobber to tls_global_dynamic_64 patterns to show it.

PR target/120908
* config/i386/i386.cc (legitimize_tls_address): Pass RDI to
gen_tls_global_dynamic_64.
* config/i386/i386.md (*tls_global_dynamic_64_<mode>): Add RDI
clobber and use it to generate LEA.
(@tls_global_dynamic_64_<mode>): Add a clobber.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
11 hours agoRISC-V: testsuite: Skip tests providing -march/-mcpu for ILP32E/ILP64E ABIs
Dimitar Dimitrov [Fri, 20 Jun 2025 17:57:15 +0000 (20:57 +0300)] 
RISC-V: testsuite: Skip tests providing -march/-mcpu for ILP32E/ILP64E ABIs

Some test cases explicitly set -march or -mcpu with extensions which
are not compatible with the E ABI variants.  This leads to spurious
errors when toolchain has been configured for RV32E base ISA and
ILP32E ABI:
  cc1: error: ILP32E ABI does not support the 'D' extension

Also, test gcc.target/riscv/rvv/base/pr119164.c implicitly requires
rv64 since it explicitly selects -march=rv64gcv_zvl256b:
  cc1: error: ABI requires '-march=rv32'

Testing done:
 - Ensured cross riscv64-unknown-linux-gnu has no difference in test
   output with and without the patch.
 - For riscv32-unknown-elf  there are no new failures. Test case pr119164.c
   no longer fails and is now marked as unsupported.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/mcpu-xt-c908.c: Disable for E ABI variants.
* gcc.target/riscv/mcpu-xt-c908v.c: Ditto.
* gcc.target/riscv/mcpu-xt-c910.c: Ditto.
* gcc.target/riscv/mcpu-xt-c910v2.c: Ditto.
* gcc.target/riscv/mcpu-xt-c920.c: Ditto.
* gcc.target/riscv/mcpu-xt-c920v2.c: Ditto.
* gcc.target/riscv/pr118241.c: Ditto.
* gcc.target/riscv/pr120223.c: Ditto.
* gcc.target/riscv/rvv/base/pr119164.c: Disable for E ABI variants
and for 32-bit ISA.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
12 hours ago[PATCH] [RISC-V] Fix shift type for RVV interleaved stepped patterns [PR120356]
Alexey Merzlyakov [Wed, 2 Jul 2025 17:29:00 +0000 (11:29 -0600)] 
[PATCH] [RISC-V] Fix shift type for RVV interleaved stepped patterns [PR120356]

It corrects the shift type of interleaved stepped patterns for const vector
expanding in LRA. The shift instruction was initially LSHIFTRT, and it seems
still should be the same type for both LRA and other cases.

PR target/120356

gcc/ChangeLog:

* config/riscv/riscv-v.cc
(expand_const_vector_interleaved_stepped_npatterns):
Fix ASHIFT to LSHIFTRT insn.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/pr120356.c: New test.

12 hours agolibstdc++: Use hidden friends for __normal_iterator operators
Jonathan Wakely [Wed, 27 Nov 2024 20:58:29 +0000 (20:58 +0000)] 
libstdc++: Use hidden friends for __normal_iterator operators

As suggested by Jason, this makes all __normal_iterator operators into
friends so they can be found by ADL and don't need to be separately
exported in module std.

The operator<=> comparing two iterators of the same type is removed
entirely, instead of being made a hidden friend. That overload was added
by r12-5882-g2c7fb16b5283cf to deal with unconstrained operator
overloads found by ADL, as defined in the testsuite_greedy_ops.h header.
We don't actually test that case as there's no unconstrained <=> in that
header, and it doesn't seem reasonable for anybody to define such an
operator<=> in C++20 when they should constrain their overloads properly
(e.g. using a requires-clause). The homogeneous operator<=> overloads
added for reverse_iterator and move_iterator could also be removed, but
that's not part of this commit.

I also had to reorder the __attribute__((always_inline)) and
[[nodiscard]] attributes on the pre-c++20 operators, because Clang won't
allow [[foo]] after __attribute__((bar)) on a friend function:

<source>:4:36: error: an attribute list cannot appear here
    4 |     __attribute__((always_inline)) [[nodiscard]] friend bool
      |                                    ^~~~~~~~~~~~~

libstdc++-v3/ChangeLog:

* include/bits/stl_iterator.h (__normal_iterator): Make all
non-member operators hidden friends, except ...
(operator<=>(__normal_iterator<I,C>, __normal_iterator<I,C>)):
Remove.
* src/c++11/string-inst.cc: Remove explicit instantiations of
operators that are no longer templates.
* src/c++23/std.cc.in (__gnu_cxx): Do not export operators for
__normal_iterator.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
16 hours agoDo not query further vector epilogues after a masked epilogue
Richard Biener [Wed, 2 Jul 2025 11:44:59 +0000 (13:44 +0200)] 
Do not query further vector epilogues after a masked epilogue

When doing --param vect-partial-vector-usage=1 we'd continue querying
the target whether it wants more vector epilogues, but when it comes
back with a suggestion we then might iterate endlessly.  Do not
even ask the target when we decided for the last epilogue to be
one with partial vectors.

PR tree-optimization/120927
* tree-vect-loop.cc (vect_analyze_loop): Stop querying
further epilogues after one with partial vectors.

18 hours agolibstdc++: make range view ctors explicit (P2711) [PR119744]
Nathan Myers [Tue, 1 Jul 2025 00:01:10 +0000 (20:01 -0400)] 
libstdc++: make range view ctors explicit (P2711) [PR119744]

Make range view constructors explicit, per P2711. Technically, this
is a breaking change, but it is unlikely to break any production
code, as reliance on non-explicit construction is unidiomatic..

libstdc++-v3/ChangeLog
PR libstdc++/119744
* include/std/ranges: View ctors become explicit.

26 hours agoi386: Change Diamond Rapids feature detect when model number could not be distinguished
Haochen Jiang [Tue, 1 Jul 2025 06:02:36 +0000 (14:02 +0800)] 
i386: Change Diamond Rapids feature detect when model number could not be distinguished

We will use AMX-FP8 for DMR since it is a smaller and more unique feature.

gcc/ChangeLog:

* config/i386/driver-i386.cc (host_detect_local_cpu): Change
to AMX-FP8 for Diamond Rapids.

29 hours agoDaily bump.
GCC Administrator [Wed, 2 Jul 2025 00:19:39 +0000 (00:19 +0000)] 
Daily bump.

33 hours agoUse the counted_by attribute of pointers in array bound checker.
Qing Zhao [Mon, 16 Jun 2025 21:08:32 +0000 (21:08 +0000)] 
Use the counted_by attribute of pointers in array bound checker.

Current array bound checker only instruments ARRAY_REF, and the INDEX
information is the 2nd operand of the ARRAY_REF.

When extending the array bound checker to pointer references with
counted_by attributes, the hardest part is to get the INDEX of the
corresponding array ref from the offset computation expression of
the pointer ref.  I.e.

Given an OFFSET expression, and the ELEMENT_SIZE,
get the index expression from the OFFSET.
For example:
  OFFSET:
   ((long unsigned int) m * (long unsigned int) SAVE_EXPR <n>) * 4
  ELEMENT_SIZE:
   (sizetype) SAVE_EXPR <n> * 4
get the index as (long unsigned int) m.

gcc/c-family/ChangeLog:

* c-gimplify.cc (is_address_with_access_with_size): New function.
(ubsan_walk_array_refs_r): Instrument an INDIRECT_REF whose base
address is .ACCESS_WITH_SIZE or an address computation whose base
address is .ACCESS_WITH_SIZE.
* c-ubsan.cc (ubsan_instrument_bounds_pointer_address): New function.
(struct factor_t): New structure.
(get_factors_from_mul_expr): New function.
(get_index_from_offset): New function.
(get_index_from_pointer_addr_expr): New function.
(is_instrumentable_pointer_array_address): New function.
(ubsan_array_ref_instrumented_p): Change prototype.
Handle MEM_REF in addtional to ARRAY_REF.
(ubsan_maybe_instrument_array_ref): Handle MEM_REF in addtional
to ARRAY_REF.

gcc/testsuite/ChangeLog:

* gcc.dg/ubsan/pointer-counted-by-bounds-2.c: New test.
* gcc.dg/ubsan/pointer-counted-by-bounds-3.c: New test.
* gcc.dg/ubsan/pointer-counted-by-bounds-4.c: New test.
* gcc.dg/ubsan/pointer-counted-by-bounds-5.c: New test.
* gcc.dg/ubsan/pointer-counted-by-bounds.c: New test.

33 hours agoUse the counted_by attribute of pointers in builtinin-object-size.
Qing Zhao [Mon, 16 Jun 2025 20:58:40 +0000 (20:58 +0000)] 
Use the counted_by attribute of pointers in builtinin-object-size.

gcc/ChangeLog:

* tree-object-size.cc (access_with_size_object_size): Update comments
for pointers with .ACCESS_WITH_SIZE.
(collect_object_sizes_for): Propagate size info through GIMPLE_ASSIGN
for pointers with .ACCESS_WITH_SIZE.

gcc/testsuite/ChangeLog:

* gcc.dg/pointer-counted-by-4-char.c: New test.
* gcc.dg/pointer-counted-by-4-float.c: New test.
* gcc.dg/pointer-counted-by-4-struct.c: New test.
* gcc.dg/pointer-counted-by-4-union.c: New test.
* gcc.dg/pointer-counted-by-4.c: New test.
* gcc.dg/pointer-counted-by-5.c: New test.
* gcc.dg/pointer-counted-by-6.c: New test.
* gcc.dg/pointer-counted-by-7.c: New test.

33 hours agoExtend "counted_by" attribute to pointer fields of structures. Convert a pointer...
Qing Zhao [Mon, 16 Jun 2025 17:54:24 +0000 (17:54 +0000)] 
Extend "counted_by" attribute to pointer fields of structures. Convert a pointer reference with counted_by attribute to .ACCESS_WITH_SIZE.

For example:

struct PP {
  size_t count2;
  char other1;
  char *array2 __attribute__ ((counted_by (count2)));
  int other2;
} *pp;

specifies that the "array2" is an array that is pointed by the
pointer field, and its number of elements is given by the field
"count2" in the same structure.

gcc/c-family/ChangeLog:

* c-attribs.cc (handle_counted_by_attribute): Accept counted_by
attribute for pointer fields.

gcc/c/ChangeLog:

* c-decl.cc (verify_counted_by_attribute): Change the 2nd argument
to a vector of fields with counted_by attribute. Verify all fields
in this vector.
(finish_struct): Collect all the fields with counted_by attribute
to a vector and pass this vector to verify_counted_by_attribute.
* c-typeck.cc (build_counted_by_ref): Handle pointers with counted_by.
Add one more argument, issue error when the pointee type is a structure
or union including a flexible array member.
(build_access_with_size_for_counted_by): Handle pointers with counted_by.
(handle_counted_by_for_component_ref): Call build_counted_by_ref
with the new prototype.

gcc/ChangeLog:

* doc/extend.texi: Extend counted_by attribute to pointer fields in
structures. Add one more requirement to pointers with counted_by
attribute.

gcc/testsuite/ChangeLog:

* gcc.dg/flex-array-counted-by.c: Update test.
* gcc.dg/pointer-counted-by-1.c: New test.
* gcc.dg/pointer-counted-by-2.c: New test.
* gcc.dg/pointer-counted-by-3.c: New test.
* gcc.dg/pointer-counted-by.c: New test.

33 hours agoFortran: fix minor issues with coarrays
Harald Anlauf [Tue, 1 Jul 2025 19:41:53 +0000 (21:41 +0200)] 
Fortran: fix minor issues with coarrays

gcc/fortran/ChangeLog:

* coarray.cc (check_add_new_component): Treat pure and elemental
intrinsic functions the same as non-intrinsic ones.
(create_caf_add_data_parameter_type): Fix front-end memleaks.
* trans-intrinsic.cc (conv_caf_func_index): Likewise.

33 hours agocobol: Respect error in cobol.install-common.
James K. Lowden [Tue, 1 Jul 2025 17:51:44 +0000 (13:51 -0400)] 
cobol: Respect error in cobol.install-common.

If GCOBOL_INSTALL_NAME fails to install, do not install GCOBC_INSTALL_NAME.

gcc/cobol/ChangeLog:

* Make-lang.in: Use && instead of semicolon between commands.

35 hours agolibstdc++: Use ranges::iter_move in ranges::remove_if [PR120789]
Patrick Palka [Tue, 1 Jul 2025 17:43:12 +0000 (13:43 -0400)] 
libstdc++: Use ranges::iter_move in ranges::remove_if [PR120789]

PR libstdc++/120789

libstdc++-v3/ChangeLog:

* include/bits/ranges_algo.h (__remove_if_fn::operator()): Use
ranges::iter_move(iter) instead of std::move(*iter).
* testsuite/25_algorithms/remove_if/120789.cc: New test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
35 hours agolibstdc++: Use ranges::iter_move in ranges::unique [PR120789]
Patrick Palka [Tue, 1 Jul 2025 17:43:09 +0000 (13:43 -0400)] 
libstdc++: Use ranges::iter_move in ranges::unique [PR120789]

PR libstdc++/120789

libstdc++-v3/ChangeLog:

* include/bits/ranges_algo.h (__unique_fn::operator()): Use
ranges::iter_move(iter) instead of std::move(*iter).
* testsuite/25_algorithms/unique/120789.cc: New test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
36 hours agotestsuite: Fix up gcc.target/powerpc/builtin_altivec_tr_stxvr_runnable.c test (test...
Jakub Jelinek [Tue, 1 Jul 2025 17:37:39 +0000 (19:37 +0200)] 
testsuite: Fix up gcc.target/powerpc/builtin_altivec_tr_stxvr_runnable.c test (test UB) [PR120919]

In my reading of the test and the instructions emitted by the
builtins, it invokes UB 4 times, each time overwriting one byte
after some variable (sc, then ss, then si and then sll).
If we are lucky, like at -O0 -mcpu=power10, there is just padding
there or something that doesn't make the tests fail, if unlucky
like with -O0 -mcpu=power10 -fstack-protector-strong,
&sc + 1 == &expected_sc
and so it overwrites the expected_sc variable.
The test fails when testing with
RUNTESTFLAGS="--target_board=unix/'{,-fstack-protector-strong}'"
on power10.

The following patch fixes that by using arrays of 2 elements, so that
the overwriting of 1 byte happens to the part of the same variable.

2025-07-01  Jakub Jelinek  <jakub@redhat.com>

PR testsuite/120919
* gcc.target/powerpc/builtin_altivec_tr_stxvr_runnable.c (main): Change
sc, ss, si and sll vars from scalars to arrays of 2 elements,
initialize and test just the first one though.

36 hours agoPR modula2/120912: Request for a procedure to obtain a file from an IOChan
Gaius Mulley [Tue, 1 Jul 2025 17:21:15 +0000 (18:21 +0100)] 
PR modula2/120912: Request for a procedure to obtain a file from an IOChan

This patch introduces the procedure GetFile into the supplementary
ISO style library IOChanUtils.

gcc/m2/ChangeLog:

PR modula2/120912
* gm2-libs-iso/IOChanUtils.def (GetFile): New procedure function.
* gm2-libs-iso/IOChanUtils.mod (GetFile): New procedure function.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
36 hours agoAda: Fix assertion failure for Finalizable aspect on tagged type
Eric Botcazou [Tue, 1 Jul 2025 17:17:06 +0000 (19:17 +0200)] 
Ada: Fix assertion failure for Finalizable aspect on tagged type

This fixes an assertion failure for the Finalizable aspect applied on a
tagged type with discriminant-dependent component.

gcc/ada/
PR ada/120705
* exp_ch6.adb (Needs_BIP_Collection): Always return False if the
type has relaxed finalization.

gcc/testsuite/
* gnat.dg/specs/finalizable2.ads: New test.

37 hours agocobol: Repair printf format of size_t.
Robert Dubner [Tue, 1 Jul 2025 16:02:21 +0000 (12:02 -0400)] 
cobol: Repair printf format of size_t.

gcc/cobol/ChangeLog:

* parse.y: printf() of size_t is %zu, not %ld.

38 hours agos390: Add -fno-stack-protector to 3 tests
Jakub Jelinek [Tue, 1 Jul 2025 15:33:32 +0000 (17:33 +0200)] 
s390: Add -fno-stack-protector to 3 tests

In Fedora/RHEL we usually test with
make check RUNTESTFLAGS="--target_board=unix/'{,-fstack-protector-strong}'"
because -fstack-protector-strong is used when building pretty much all the
packages.

In the past Marek Polacek has committed tweaks to various tests to make
them PASS in such testing, see e.g. r14-6276 or r14-2200.
These 3 tests FAIL with -fstack-protector-strong on s390x because they
use check-function-bodies and aren't prepared for the extra
-fstack-protector-{strong,all} extra code in the prologue/epilogue.

The following patch should fix that.

2025-07-01  Jakub Jelinek  <jakub@redhat.com>

* gcc.target/s390/vector/vec-abs-emu.c: Add -fno-stack-protector
to dg-options.
* gcc.target/s390/vector/vec-max-emu.c: Likewise.
* gcc.target/s390/vector/vec-min-emu.c: Likewise.

38 hours agocobol: Update test case for intrinsic function syntax.
Robert Dubner [Tue, 1 Jul 2025 15:07:18 +0000 (11:07 -0400)] 
cobol: Update test case for intrinsic function syntax.

gcc/testsuite/ChangeLog:

* cobol.dg/group2/Intrinsics_without_FUNCTION_keyword__2_.cob:
Append INTRINSIC keyword.

40 hours agoc++: Fix up cp_build_array_ref COND_EXPR handling [PR120471]
Jakub Jelinek [Tue, 1 Jul 2025 13:28:10 +0000 (15:28 +0200)] 
c++: Fix up cp_build_array_ref COND_EXPR handling [PR120471]

The following testcase is miscompiled since the introduction of UBSan,
cp_build_array_ref COND_EXPR handling replaces
(cond ? a : b)[idx] with cond ? a[idx] : b[idx], but if there are
SAVE_EXPRs inside of idx, they will be evaluated just in one of the
branches and the other uses uninitialized temporaries.

Fixed by keeping doing what it did if idx doesn't have side effects
and is invariant.  Otherwise if op1/op2 are ARRAY_TYPE arrays with
invariant addresses or pointers with invariant values, use
SAVE_EXPR <op0>, SAVE_EXPR <idx>, SAVE_EXPR <op0> as a new condition
and SAVE_EXPR <idx> instead of idx for the recursive calls.
Otherwise punt, but if op1/op2 are ARRAY_TYPE, furthermore call
cp_default_conversion on array, so that COND_EXPR with ARRAY_TYPE doesn't
survive in the IL until expansion.

2025-07-01  Jakub Jelinek  <jakub@redhat.com>

PR c++/120471
gcc/
* tree.h (address_invariant_p): New function.
* tree.cc (address_invariant_p): New function.
(tree_invariant_p_1): Use it for ADDR_EXPR handling.  Formatting
tweak.
gcc/cp/
* typeck.cc (cp_build_array_ref) <case COND_EXPR>: If idx is not
INTEGER_CST, don't optimize the case (but cp_default_conversion on
array early if it has ARRAY_TYPE) or use
SAVE_EXPR <op0>, SAVE_EXPR <idx>, SAVE_EXPR <op0> as new op0 depending
on flag_strong_eval_order and whether op1 and op2 are arrays with
invariant address or tree invariant pointers.  Formatting fixes.
gcc/testsuite/
* g++.dg/ubsan/pr120471.C: New test.
* g++.dg/parse/pr120471.C: New test.

40 hours agoAArch64 SIMD: convert mvn+shrn into mvni+subhn
Remi Machet [Tue, 1 Jul 2025 12:45:04 +0000 (13:45 +0100)] 
AArch64 SIMD: convert mvn+shrn into mvni+subhn

Add an optimization to aarch64 SIMD converting mvn+shrn into mvni+subhn when
possible, which allows for better optimization when the code is inside a loop
by using a constant.

The conversion is based on the fact that for an unsigned integer:
  -x = ~x + 1 => ~x = -1 - x
thus '(u8)(~x >> imm)' is equivalent to '(u8)(((u16)-1 - x) >> imm)'.

For the following function:
uint8x8_t neg_narrow_v8hi(uint16x8_t a) {
  uint16x8_t b = vmvnq_u16(a);
  return vshrn_n_u16(b, 8);
}

Without this patch the assembly look like:
not v0.16b, v0.16b
shrn v0.8b, v0.8h, 8

After the patch it becomes:
mvni v31.4s, 0
subhn v0.8b, v31.8h, v0.8h

Bootstrapped and regtested on aarch64-linux-gnu.

Signed-off-by: Remi Machet <rmachet@nvidia.com>
gcc/ChangeLog:

* config/aarch64/aarch64-simd.md (*shrn_to_subhn_<mode>): Add pattern
converting mvn+shrn into mvni+subhn.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/simd/shrn2subhn.c: New test.

42 hours agoFortran: Ensure arguments in coarray call get unique components in add_data [PR120847]
Andre Vehreschild [Fri, 27 Jun 2025 13:31:21 +0000 (15:31 +0200)] 
Fortran: Ensure arguments in coarray call get unique components in add_data [PR120847]

PR fortran/120847

gcc/fortran/ChangeLog:

* coarray.cc (check_add_new_comp_handle_array): Make the count
of components static to be able to create more than one.  Create
an array component only for array expressions.

gcc/testsuite/ChangeLog:

* gfortran.dg/coarray/coindexed_7.f90: New test.

43 hours agolibstdc++: Implement default_accessor from mdspan.
Luc Grosheintz [Mon, 30 Jun 2025 07:23:16 +0000 (09:23 +0200)] 
libstdc++: Implement default_accessor from mdspan.

libstdc++-v3/ChangeLog:

* include/std/mdspan (default_accessor): New class.
* src/c++23/std.cc.in: Register default_accessor.
* testsuite/23_containers/mdspan/accessors/default.cc: New test.
* testsuite/23_containers/mdspan/accessors/default_neg.cc: New test.

Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
43 hours agotestsuite: Fix up pr119318.c test for big-endian [PR120082]
Jakub Jelinek [Tue, 1 Jul 2025 09:58:28 +0000 (11:58 +0200)] 
testsuite: Fix up pr119318.c test for big-endian [PR120082]

The test is not endianess clean, x[0] is supposed to be ((__int128)0x19)<<32
on little endian - 0x19 is in the second vector elt - but ((__int128)0x19)<<64
on big endian.  I've added also verification of int and __int128 sizes just
in case we have say 16-bit or 64-bit int target with __int128 type, or
pdp endian gets __int128 support.

2025-07-01  Jakub Jelinek  <jakub@redhat.com>

PR ipa/119318
PR testsuite/120082
* gcc.dg/ipa/pr119318.c (main): Expect different result on big endian
from little endian, on unexpected endianness or int/int128 sizes don't
test anything.  Formatting fixes.

43 hours agotestsuite: i386: Fix gcc.target/i386/preserve-none-1.c on Solaris/x86
Rainer Orth [Tue, 1 Jul 2025 09:47:58 +0000 (11:47 +0200)] 
testsuite: i386: Fix gcc.target/i386/preserve-none-1.c on Solaris/x86

The new gcc.target/i386/preserve-none-1.c test currently FAILs on
Solaris/x86:

FAIL: gcc.target/i386/preserve-none-1.c scan-assembler-not movq

It needs -fomit-frame-pointer which this patch adds.

Tested on i386-pc-solaris2.11 and x86_64-pc-linux-gnu.

2025-06-27  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc/testsuite:
* gcc.target/i386/preserve-none-1.c (dg-options): Add
-fomit-frame-pointer.

44 hours agotestsuite: i386: Fix g++.target/i386/memset-pr101366-1.C etc. on Solaris/x86
Rainer Orth [Tue, 1 Jul 2025 09:31:00 +0000 (11:31 +0200)] 
testsuite: i386: Fix  g++.target/i386/memset-pr101366-1.C etc. on Solaris/x86

Several new tests from

commit d073bb6cfc219d4b6c283a0b527ee88b42e640e0
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Mar 18 18:43:10 2021 -0700

    x86: Update memcpy/memset inline strategies for -mtune=generic

FAIL on Solaris/x86:

FAIL: g++.target/i386/memset-pr101366-1.C   check-function-bodies _Z4TestPc
FAIL: g++.target/i386/memset-pr101366-2.C   check-function-bodies _Z4TestPc
FAIL: g++.target/i386/memset-pr108585-1a.C   check-function-bodies _Z6squarei
FAIL: g++.target/i386/memset-pr108585-1b.C   check-function-bodies _Z6squarei
FAIL: g++.target/i386/memset-pr118276-1a.C   check-function-bodies _Z22makeDefaultConstructedv
FAIL: g++.target/i386/memset-pr118276-1b.C   check-function-bodies _Z22makeDefaultConstructedv
FAIL: g++.target/i386/memset-pr118276-1c.C   check-function-bodies _Z22makeDefaultConstructedv
FAIL: gcc.target/i386/memset-pr70308-1a.c check-function-bodies foo
FAIL: gcc.target/i386/memset-pr70308-1b.c check-function-bodies foo
FAIL: gcc.target/i386/memset-strategy-25.c check-function-bodies foo
FAIL: gcc.target/i386/memset-strategy-28.c check-function-bodies foo
FAIL: gcc.target/i386/memset-strategy-29.c check-function-bodies foo
FAIL: gcc.target/i386/memset-strategy-30.c check-function-bodies foo
FAIL: gcc.target/i386/pr92080-17.c check-function-bodies foo

The issue is the same as in

https://gcc.gnu.org/pipermail/gcc-patches/2025-March/679330.html

All the tests need -fasynchronous-unwind-tables -fdwarf2-cfi-asm, some
also -fomit-frame-pointer and -mno-stackrealign.

Tested on i386-pc-solaris2.11 and x86_64-pc-linux-gnu.

2025-06-25  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc/testsuite:
* g++.target/i386/memset-pr101366-1.C (dg-options): Add
-fasynchronous-unwind-tables -fdwarf2-cfi-asm.
* g++.target/i386/memset-pr101366-2.C: Likewise.
* g++.target/i386/memset-pr118276-1a.C: Likewise.
* g++.target/i386/memset-pr118276-1b.C: Likewise.
* g++.target/i386/memset-pr118276-1c.C: Likewise.
* gcc.target/i386/memset-pr70308-1a.c: Likewise.
* gcc.target/i386/memset-strategy-25.c: Likewise.
* gcc.target/i386/memset-strategy-28.c: Likewise.
* gcc.target/i386/memset-strategy-29.c: Likewise.
* gcc.target/i386/memset-strategy-30.c: Likewise.
* gcc.target/i386/pr92080-17.c: Likewise.
* gcc.target/i386/memset-pr70308-1b.c: Likewise.  Also add
-fomit-frame-pointer.
* g++.target/i386/memset-pr108585-1a.C:  (dg-options): Add
-fasynchronous-unwind-tables -fdwarf2-cfi-asm.  Also add
-mno-stackrealign -fomit-frame-pointer.
* g++.target/i386/memset-pr108585-1b.C: Likewise.

44 hours agotailc: Handle musttail in case of non-cleaned-up cleanups, especially ASan related...
Jakub Jelinek [Tue, 1 Jul 2025 09:26:45 +0000 (11:26 +0200)] 
tailc: Handle musttail in case of non-cleaned-up cleanups, especially ASan related [PR120608]

The following testcases FAIL at -O0 -fsanitize=address.  The problem is
we end up with something like
  _26 = foo (x_24(D)); [must tail call]
  // predicted unlikely by early return (on trees) predictor.
  finally_tmp.3_27 = 0;
  goto <bb 5>; [INV]
...
  <bb 5> :
  # _6 = PHI <_26(3), _23(D)(4)>
  # finally_tmp.3_8 = PHI <finally_tmp.3_27(3), finally_tmp.3_22(4)>
  .ASAN_MARK (POISON, &c, 4);
  if (finally_tmp.3_8 == 1)
    goto <bb 7>; [INV]
  else
    goto <bb 6>; [INV]

  <bb 6> :
<L4>:
  finally_tmp.4_31 = 0;
  goto <bb 8>; [INV]
...
  <bb 8> :
  # finally_tmp.4_9 = PHI <finally_tmp.4_31(6), finally_tmp.4_30(7)>
  .ASAN_MARK (POISON, &b, 4);
  if (finally_tmp.4_9 == 1)
    goto <bb 9>; [INV]
  else
    goto <bb 10>; [INV]
...
  <bb 10> :
  # _7 = PHI <_6(8), _34(9)>
  .ASAN_MARK (POISON, &a, 4);

  <bb 11> :
<L11>:
  return _7;
before the sanopt pass.  This is -O0, we don't try to do forward
propagation, jump threading etc.  And what is worse, the sanopt
pass lowers the .ASAN_MARK calls that the tailc/musttail passes
already handle into somewthing that they can't easily pattern match.

The following patch fixes that by
1) moving the musttail pass 2 passes earlier (this is mostly just
   for -O0/-Og, for normal optimization levels musttail calls are
   handled in the tailc pass), i.e. across the sanopt and cleanup_eh
   passes
2) recognizes these finally_tmp SSA_NAME assignments, PHIs using those
   and GIMPLE_CONDs deciding based on those both on the backwards
   walk (when we start from the edges to EXIT) and forwards walk
   (when we find a candidate tail call and process assignments
   after those up to the return statement).  For backwards walk,
   ESUCC argument has been added which is either NULL for the
   noreturn musttail case, or the succ edge through which we've
   reached bb and if it sees GIMPLE_COND with such comparison,
   based on the ESUCC and comparison it will remember which later
   edges to ignore later on and which bb must be walked up to the
   start during tail call discovery (the one with the PHI).
3) the move of musttail pass across cleanup_eh pass resulted in
   g++.dg/opt/pr119613.C regressions but moving cleanup_eh before
   sanopt doesn't work too well, so I've extended
   empty_eh_cleanup to also handle resx which doesn't throw
   externally

I know moving a pass on release branches feels risky, though the
musttail pass is only relevant to functions with musttail calls,
so something quite rare and only at -O0/-Og (unless one e.g.
disables the tailc pass).

2025-07-01  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/120608
* passes.def (pass_musttail): Move before pass_sanopt.
* tree-tailcall.cc (empty_eh_cleanup): Handle GIMPLE_RESX
which doesn't throw externally through recursion on single
eh edge (if any and cnt still allows that).
(find_tail_calls): Add ESUCC, IGNORED_EDGES and MUST_SEE_BBS
arguments.  Handle GIMPLE_CONDs for non-simplified cleanups with
finally_tmp temporaries both on backward and forward walks, adjust
recursive call.
(tree_optimize_tail_calls_1): Adjust find_tail_calls callers.

* c-c++-common/asan/pr120608-3.c: New test.
* c-c++-common/asan/pr120608-4.c: New test.
* g++.dg/asan/pr120608-3.C: New test.
* g++.dg/asan/pr120608-4.C: New test.

44 hours agoFortran: Fix non-conformable corank on this_image ref [PR120843]
Andre Vehreschild [Fri, 27 Jun 2025 12:39:13 +0000 (14:39 +0200)] 
Fortran: Fix non-conformable corank on this_image ref [PR120843]

PR fortran/120843

gcc/fortran/ChangeLog:

* resolve.cc (resolve_operator): Report inconsistent coranks
only when not referencing this_image.
(gfc_op_rank_conformable): Treat coranks as inconformable only
when a coindex other then implicit this_image is used.

gcc/testsuite/ChangeLog:

* gfortran.dg/coarray/coindexed_6.f90: New test.

44 hours agoaarch64: Sync `aarch64-sys-regs.def' with Binutils.
Ezra Sitorus [Tue, 1 Jul 2025 08:22:05 +0000 (10:22 +0200)] 
aarch64: Sync `aarch64-sys-regs.def' with Binutils.

This patch updates `aarch64-sys-regs.def', bringing it into sync with
the Binutils source after this change:
https://sourceware.org/pipermail/binutils/2025-March/139894.html

gcc/ChangeLog:

* config/aarch64/aarch64-sys-regs.def: Copy from Binutils.

45 hours agoada: Restore consistent rounding of 'Value for ordinary fixed-point types
Eric Botcazou [Mon, 26 May 2025 10:21:02 +0000 (12:21 +0200)] 
ada: Restore consistent rounding of 'Value for ordinary fixed-point types

This restores the rounding of the first scaled divide operation applied to
the extra digits, which yields more consistent results for smalls that are
reciprocal of integers.

gcc/ada/ChangeLog:

* libgnat/s-valuef.adb (Integer_to_Fixed): Restore rounding of the
first scaled divide operation.

45 hours agoada: Fix ALI elaboration flags for ghost compilation units
Piotr Trojanek [Thu, 22 May 2025 14:46:17 +0000 (16:46 +0200)] 
ada: Fix ALI elaboration flags for ghost compilation units

When GNAT was compiling a ghost unit, the ALI file wrongly suggested that this
unit includes elaboration code, which caused linking errors to non-existing
elaboration counters. This was because elaboration code is only detected in
Gigi, which is skipped for ignored ghost units, because we don't generate
object code for them

gcc/ada/ChangeLog:

* gnat1drv.adb (Gnat1drv): Do minimal decoration of the spec and body
of an ignored ghost compilation unit.

45 hours agoada: Remove unused variables from the binder generation routine
Piotr Trojanek [Thu, 22 May 2025 10:16:18 +0000 (12:16 +0200)] 
ada: Remove unused variables from the binder generation routine

Remove leftovers from zero cost exception handling; semantics is unaffected.

gcc/ada/ChangeLog:

* ali.ads (Unit_Record): Fix grammar in comment.
* bindgen.adb (Num_Elab_Calls, Num_Primary_Stacks): Remove counters
that were only incremented and never actually used.

45 hours agoada: Disallow underscore before exponent
Tonu Naks [Thu, 22 May 2025 13:07:08 +0000 (13:07 +0000)] 
ada: Disallow underscore before exponent

Underscore is allowed only between digits. The current implementattion
was considering 'E' as a digit even if it was not in the range of
Base and could denote exponent only.

gcc/ada/ChangeLog:

* libgnat/s-valuer.adb (Scan_Decimal_Digits,
Scan_Integral_Digits): fix condition for rejecting
underscore.

45 hours agoada: Fix couple of issues in System.Value_D.Integer_To_Decimal function
Eric Botcazou [Wed, 21 May 2025 13:15:48 +0000 (15:15 +0200)] 
ada: Fix couple of issues in System.Value_D.Integer_To_Decimal function

The first issue is that the function would wrongly raise Constraint_Error
on the edge case where Val = 2**(Int'Size - 1) and Minus is not set.

The second issue is that the function takes a long time to deal with huge
negative exponents.

The change also contains minor consistency fixes for its counterpart that
is present in System.Value_F, namely Integer_To_Fixed.

gcc/ada/ChangeLog:

* libgnat/s-valued.adb (Integer_To_Decimal): Deal specifically with
Val = 2**(Int'Size - 1) if Minus is not set.  Exit the loops when V
saturates to 0 in the case of (huge) negative exponents.  Use Base
instead of B consistently in unsigned computations.
* libgnat/s-valuef.adb (Integer_To_Fixed): Use Base instead of B
consistently in unsigned computations.

45 hours agoada: Do minimal expansion of fixedpoint operations for GNATprove
Piotr Trojanek [Wed, 21 May 2025 14:17:12 +0000 (16:17 +0200)] 
ada: Do minimal expansion of fixedpoint operations for GNATprove

A minimal expansion of fixedpoint operations is needed for GNATprove, because
the subsequent resolution of type conversion relies on this expansion being
done.

gcc/ada/ChangeLog:

* exp_ch4.adb (Fixup_Universal_Fixed_Operation): Move to spec.
* exp_ch4.ads (Fixup_Universal_Fixed_Operation): Move from body.
* exp_spark.adb (Expand_SPARK): Call a fixup expansion routine.

45 hours agoada: Fix for compiler crash on function return with Relaxed_Finalization parts
Gary Dismukes [Tue, 20 May 2025 00:16:25 +0000 (00:16 +0000)] 
ada: Fix for compiler crash on function return with Relaxed_Finalization parts

The compiler crashes on compiling a return statement of a function whose result
type has a component whose type is specified with Relaxed_Finalization. The
compiler was attempting to retrieve a nonexistent BIP_Collection extra formal
from the enclosing function, which may not exist in the case of result types
with Relaxed_Finalization.

gcc/ada/ChangeLog:

* exp_ch3.adb (Build_Heap_Or_Pool_Allocator): Test not Has_Relaxed_Finalization
as a guard against retrieving BIP_Collection formal (and related code).

45 hours agoada: Warn on untagged record type equality
Javier Miranda [Fri, 16 May 2025 17:59:43 +0000 (17:59 +0000)] 
ada: Warn on untagged record type equality

The frontend reports a warning when no component of an untagged
record type U is a record type, and the type C of some of its
components has defined its user-defined equality operator "=".

The warning is reported because it may be surprising that, following
RM 4.5.2 (24/3), the predefined "=" of the component type C takes
precedence over its user-defined "=" when objects of the record
type R are compared.

gcc/ada/ChangeLog:

* exp_ch3.adb (Build_Untagged_Record_Equality): Report the
warning when no component of an untagged record type U is a
record type, and the type C of some of its components has
defined its user-defined equality operator "=".
* exp_ch4.adb (Expand_Composite_Equality): Report the warning
calling Warn_On_Ignored_Equality_Operator.
* sem_warn.ads (Warn_On_Ignored_Equality_Operator): New subprogram.
* sem_warn.adb (Warn_On_Ignored_Equality_Operator): Factorize code
reporting the warning.

45 hours agoada: Reduce the likelihood of overflow in Tanh
Tonu Naks [Mon, 19 May 2025 17:20:41 +0000 (17:20 +0000)] 
ada: Reduce the likelihood of overflow in Tanh

gcc/ada/ChangeLog:

* libgnat/a-ngelfu.adb: conditional computation of X^2

45 hours agoada: Split the unit System.Case_Utilities into two parts.
Steve Baird [Mon, 21 Apr 2025 22:28:39 +0000 (15:28 -0700)] 
ada: Split the unit System.Case_Utilities into two parts.

The package System.Case_Utilities provides some subprograms that do not make
use of the secondary stack and some that do. When compiling in a context
where no secondary stack support is provided, this makes the entire package
unusable (and similarly for any other package that withs this package).
Split the package into two packages named Case_Utilities_NSS and Case_Utilities
(NSS is for "no secondary stack"). The first package declares the
subprograms that do not need secondary stack support. The second package
declares the remaining subprograms, as well as renamings of everything declared
in the first part. A client that continues to reference Case_Utilities is
largely unaffected by this change. But if we change a client to reference
Case_Utilities_NSS instead, that removes an obstacle that would otherwise
prevent using that client unit in a no-secondary-stack-support environment.
We then make that change to the body of package System.Val_Util.

gcc/ada/ChangeLog:

* Makefile.rtl: Add entry for new unit's object file.
* libgnat/s-casuti.adb: Remove bodies of subprograms that were moved
to the new unit.
* libgnat/s-casuti.ads: Replace (with renamings) declarations for
subprograms that moved to the new unit.
* libgnat/s-cautns.adb: Body for new unit (a new source file).
* libgnat/s-cautns.ads: Spec for new unit (a new source file).
* libgnat/s-valuti.adb: Use the new unit instead of the old one.
* gcc-interface/Make-lang.in: Add entries for new unit's object file.
* gcc-interface/Makefile.in: Likewise.

45 hours agoada: Compiler fails on unchecked deallocation for constrained protected subtype
Gary Dismukes [Fri, 16 May 2025 23:11:26 +0000 (23:11 +0000)] 
ada: Compiler fails on unchecked deallocation for constrained protected subtype

The compiler fails with an error or Assert_Failure when calling
an instantiation of Unchecked_Deallocation that has been instantiated
with a constrained subtype of a discriminated protected type.

gcc/ada/ChangeLog:

* sem_ch3.adb (Constrain_Corresponding_Record): Inherit Class_Wide_Type on the
created constrained subtype.

45 hours agoada: Add GNAT LLVM selection in GPR project file.
Artur Pietrek [Mon, 19 May 2025 12:33:28 +0000 (14:33 +0200)] 
ada: Add GNAT LLVM selection in GPR project file.

gcc/ada/ChangeLog:

* doc/gnat_ugn/building_executable_programs_with_gnat.rst: add
GNAT LLVM explicit selection in GPR file
* gnat_ugn.texi: Regenerate.

45 hours agoada: Small tweak to latest change
Eric Botcazou [Fri, 16 May 2025 23:20:19 +0000 (01:20 +0200)] 
ada: Small tweak to latest change

Unlike RTE, RTU_Entity alone does not cause the unit to be loaded.

gcc/ada/ChangeLog:

* exp_ch7.adb (Shift_Address_For_Descriptor): Add dummy variable
to make sure that System_Storage_Elements is loaded.

45 hours agoada: Add "continue" GNAT extension
Ronan Desplanques [Fri, 16 May 2025 08:47:06 +0000 (10:47 +0200)] 
ada: Add "continue" GNAT extension

This extension adds "continue" as a nonreserved keyword, and this is the
first occurrence of a nonreserved keyword in GNAT, which causes this
patch to add unusual overload resolution code.

New node kinds are introduced, but since they are entirely transformed
into existing constructs during expansion, back ends that don't turn off
expansion do not need to be updated.

gcc/ada/ChangeLog:

* doc/gnat_rm/gnat_language_extensions.rst: Document new extension.
* gen_il-fields.ads (Opt_Field_Enum): Add new fields.
* gen_il-types.ads (N_Loop_Flow_Statement, N_Continue_Statement): New
node kinds.
* gen_il-gen-gen_nodes.adb (N_Loop_Flow_Statement): New abstract node
kind.
(N_Continue_Statement): New node kind.
(N_Exit_Statement): Reparent below N_Loop_Flow_Statement.
* sinfo.ads (N_Continue_Statement): Add description.
* sinfo-utils.ads (Loop_Flow_Keyword): New function.
* sinfo-utils.adb (Loop_Flow_Keyword): New function.
* gen_il-gen-gen_entities.adb (E_Loop): Add new field.
* einfo.ads (Continue_Mark): Document new field.
* sprint.adb (Sprint_Node_Actual): Update for new node kind.
* snames.ads-tmpl: Add new keyword.
* par-ch5.adb (P_Continue_Statement, Parse_Loop_Flow_Statement): New
functions.
(P_Sequence_Of_Statements): Handle continue statements.
(P_Exit_Statement): Use Parse_Loop_Flow_Statement.
* sem.adb (Analyze): Handle new node kind.
* sem_ch5.adb (Analyze_Loop_Flow_Statement): New function.
(Analyze_Continue_Statement): New procedure.
(Analyze_Exit_Statement): Use new Analyze_Loop_Flow_Statement function.
* sem_ch5.ads (Analyze_Continue_Statement): New procedure.
* expander.adb (Expand): Handle new node kind.
* exp_ch5.ads (Expand_N_Continue_Statement): New procedure.
* exp_ch5.adb (Expand_Loop_Flow_Statement): New procedure.
(Expand_N_Continue_Statement): New procedure.
(Expand_N_Exit_Statement): Use new Expand_Loop_Flow_Statement
procedure.
(Build_Formal_Container_Iteration): Always reuse original loop entity.
* gnat_rm.texi: Regenerate.

45 hours agoada: Disable -gnatR2 output in case of object renamings
Bob Duff [Fri, 16 May 2025 13:04:48 +0000 (09:04 -0400)] 
ada: Disable -gnatR2 output in case of object renamings

Such output was unnecessary, and in some cases harmful.
In particular, we generate renamings in the expanded
code for protected types, with internally-generated names,
which could be confusing to the user. In addition, in the
JSON output (-gnatR2j), these generated renamings could have
duplicate source locatations, which confused SPARK.

gcc/ada/ChangeLog:

* repinfo.adb (List_Entities):
Disable output in case of object renamings.

45 hours agoada: Correct comment in s-valuen.ads
Aleksandra Pasek [Thu, 15 May 2025 21:40:55 +0000 (21:40 +0000)] 
ada: Correct comment in s-valuen.ads

gcc/ada/ChangeLog:

* libgnat/s-valuen.ads: Correct comment.

45 hours agoada: include string.h
Alexandre Oliva [Thu, 15 May 2025 03:07:03 +0000 (00:07 -0300)] 
ada: include string.h

__gnat_install_handler calls strncmp when __HANDLE_VXSIM_SC is
defined, so string.h needs to be included, and gcc-14 enforces this
requirement.

gcc/ada/ChangeLog:

* init.c: Include string.h.

45 hours agoada: Drop the chapter listing implemented Ada 2012 AI's
Tonu Naks [Wed, 14 May 2025 13:51:25 +0000 (13:51 +0000)] 
ada: Drop the chapter listing implemented Ada 2012 AI's

We support Ada 2012 fully. The chapter is out of date
and would serve no purpose if it was up to date.

gcc/ada/ChangeLog:

* doc/gnat_rm.rst: remove ref to 2012 chapter
* doc/gnat_rm/about_this_guide.rst: remove ref to 2012 chapter
* doc/gnat_rm/compatibility_and_porting_guide.rst: update list of
supported versions
* doc/gnat_rm/implementation_of_ada_2012_features.rst: delete
* doc/gnat_rm/specialized_needs_annexes.rst: update list of
supported versions
* gnat_rm.texi: Regenerate.

45 hours agoada: Replace references for GLADE with PolyORB
Tonu Naks [Wed, 14 May 2025 14:16:19 +0000 (14:16 +0000)] 
ada: Replace references for GLADE with PolyORB

gcc/ada/ChangeLog:

* doc/gnat_rm/implementation_advice.rst: remove GLADE
* doc/gnat_rm/implementation_defined_characteristics.rst: remove GLADE
* doc/gnat_rm/specialized_needs_annexes.rst: remove GLADE
* doc/gnat_rm/the_gnat_library.rst: remove GLADE
* gnat_rm.texi: Regenerate.

45 hours agoada: use __builtin_alloca for alloca on vxworks
Alexandre Oliva [Tue, 13 May 2025 02:23:14 +0000 (23:23 -0300)] 
ada: use __builtin_alloca for alloca on vxworks

Several adaint.c functions call alloca, but vxworks doesn't declare
it.  Use the GCC builtin.

gcc/ada/ChangeLog:

* adaint.c [__vxworks] (alloca): Redirect to builtin.

45 hours agoada: freeze.adb: do not emit error on non-aligned component in CodePeer_Mode
Ghjuvan Lacambre [Fri, 9 May 2025 09:20:18 +0000 (11:20 +0200)] 
ada: freeze.adb: do not emit error on non-aligned component in CodePeer_Mode

These errors hinder analysis of non-GNAT code and are not useful to the
user as CodePeer does not care about alignment.

gcc/ada/ChangeLog:

* freeze.adb (Freeze_Record_Type): Check for CodePeer_Mode.

45 hours agoada: Move aspects when instantiating subprograms as compilation units
Piotr Trojanek [Fri, 9 May 2025 15:31:39 +0000 (17:31 +0200)] 
ada: Move aspects when instantiating subprograms as compilation units

When rewriting N_Subprogram_Instantiation into wrapper packages we must move
the original aspect specifications to the wrapper packages, as otherwise they
will be only accessible via Original_Node. This is similar to how we move
aspect specifications for expression functions and many other constructs.

gcc/ada/ChangeLog:

* sem_ch12.adb (Analyze_Subprogram_Instantiation): Move aspects when
instantiating subprogram as a library unit.

45 hours agoada: Remove useless subexpressions
Ronan Desplanques [Fri, 9 May 2025 08:15:09 +0000 (10:15 +0200)] 
ada: Remove useless subexpressions

The subexpressions this patch removes were clearly useless given the
test for "No (Scheme)" in a preceding condition.

gcc/ada/ChangeLog:

* exp_ch5.adb (Expand_N_Loop_Statement): Remove useless subexpressions.

45 hours agoada: Document sanitizers in mixed-language applications
Jose Ruiz [Fri, 9 May 2025 15:24:33 +0000 (17:24 +0200)] 
ada: Document sanitizers in mixed-language applications

gcc/ada/ChangeLog:

* doc/gnat_ugn/gnat_and_program_execution.rst: Add the
documentation about benefits of using sanitizers in
mixed-language applications.
* gnat_ugn.texi: Regenerate.

45 hours agoada: Handle Warnings_As_Errors the same way.
Viljar Indus [Fri, 2 May 2025 10:04:55 +0000 (13:04 +0300)] 
ada: Handle Warnings_As_Errors the same way.

There are multiple scenarios where warnings can be turned into
errors. However internally they should always be handled the
same way and we should not rely on additional counters and variables
to handle the different behaviours.

These different types of converted warnings have however been
emitted differently historically. This information is stored in
the Warn_Err attribute which now stores the reason for the conversion
so that the printers know how to handle those scenarios.

Based on the reason these warnings are printed in different ways:
* If converted by pragma Warning_As_Error then it should print the
message with an error prefix and a [warning-as-error] tag.
* If it is a run time warning converted by -gnatwE then the message
should be printed with just an error prefix.
* if the warning was converted by -gnatwe then the message should be
printed with a warning prefix.

gcc/ada/ChangeLog:

* atree.ads (Compile_Time_Pragma_Warnings): Removed.
* errout.adb (Initialize): Remove initialization for
Compile_Time_Pragma_Warnings.
(Error_Msg_Internal): Use Warning_As_Error_Kind in the
Error_Msg_Object. Set its value based on the reason the
warning was changed to an error.
(Write_JSON_Span): Adjust the code for Warn_Err.
(Output_Messages): Update the calculation for actual warnings
and errors by just using Warnings_Treated_As_Errors.
(Set_Msg_Text): Simply mark that we are dealing with a
run time message here. Move the code for the Warning_Mode to
Error_Msg_Internal.
* erroutc-pretty_emitter.adb (Write_Error_Msg_Line): Adjust the code
for Warn_Err. Use the Warn_As_Err_Tag token.
* erroutc.adb (Compilation_Errors): Simplify the implementation so
that it only checks for errors and warnings treated as errors.
(Decrease_Error_Msg_Count): Remove the count for
Compile_Time_Pragma_Warnings.
(dmsg): Adjust the code for changes to Warn_Err.
(Increase_Error_Msg_Count): Likewise and remove the count for
Compile_Time_Pragma_Warnings.
(Output_Msg_Text): Warnings converted to error by the
Warning_As_Error pragma and -gnatwE now use the error prefix
in their messages but only warnings changed by the pragma get
the [warning-as-error] tag.
(Output_Text_Within): Adjust the variable name for
Is_Runtime_Raise_Msg.
(Write_Error_Summary): Adjust printing of warnings so that it
just uses the counts for Warnings_Detected and
Warnings_Treated_As_Errors.
* erroutc.ads (Is_Runtime_Raise): renamed to Is_Runtime_Raise_Msg.
(Warning_As_Error_Kind): New type for marking the warning message
is treated as an error which also captures the reason for the
change. Historically each of the reasons will have a different way
of displaying the warning message.
(Error_Msg_Object.Warn_Err): Change type to Warning_As_Error_Kind.
(Kind_To_String): Warnings treated as errors originating from
the pragma or -gnatwE will return error where as warnings
originating from -gnatwe will return warning.
(Compilation_Errors): Update the documentation.
(Warn_As_Err_Tag): Constant string to be used when printing warnings
as errors.
* errutil.adb (Error_Msg): Adjust the code for Warn_Err.

45 hours agoada: Fix wrong finalization of constrained subtype of unconstrained array type
Eric Botcazou [Tue, 6 May 2025 17:03:19 +0000 (19:03 +0200)] 
ada: Fix wrong finalization of constrained subtype of unconstrained array type

Dynamically allocated objects of a constrained subtype of an unconstrained
array type with a controlled component type have not been properly finalized
since the first rewrite of the finalization machinery more than a decade
ago.  The reason is that the Finalize_Address routine is that of the base
type, which is unconstrained, and thus requires the bounds, which are not
present for the subtype in the allocation.

This is fixed by setting Is_Constr_Array_Subt_With_Bounds for allocators the
same way it is set for object declarations.  The rest is just refactoring.

gcc/ada/ChangeLog:

* exp_ch7.adb (Shift_Address_For_Descriptor): New function.
(Make_Address_For_Finalize): Call above function.
(Make_Finalize_Address_Stmts): Likewise.
* exp_util.ads (Is_Constr_Array_Subt_Of_Unc_With_Controlled): New
predicate.
* exp_util.adb (Is_Constr_Array_Subt_Of_Unc_With_Controlled): Ditto.
(Remove_Side_Effects): Call above predicate.
* sem_ch3.adb (Analyze_Object_Declaration): Likewise.
* sem_ch4.adb (Analyze_Allocator): Allocate the bounds by setting
Is_Constr_Array_Subt_With_Bounds when appropriate.

45 hours agoada: Dispatching call with mutably tagged objects
Javier Miranda [Tue, 6 May 2025 17:41:51 +0000 (17:41 +0000)] 
ada: Dispatching call with mutably tagged objects

The compiler rejects performing a dispatching call using the
prefix notation when the prefix of the call is a mutably
tagged class-wide type object.

gcc/ada/ChangeLog:

* sem_ch4.adb (Try_Object_Operation): Handle mutably tagged
class-wide type prefix.

45 hours agoada: Improve Warning_Treated_As_Error
Viljar Indus [Mon, 5 May 2025 07:06:56 +0000 (10:06 +0300)] 
ada: Improve Warning_Treated_As_Error

gcc/ada/ChangeLog:

* errout.adb (Error_Msg_Internal): Use the new
Warning_Treated_As_Error function.
* erroutc.adb (Get_Warning_Option): Add new version of this
function that operates on the Error_Msg_Object directly instead
of the Error_Id. Update the existing function to call the new
version interanlly.
(Get_Warning_Tag): Likewise.
(Warning_Treated_As_Error): Add a new method that combines the
checks for the error message itself and its tag.
* erroutc.ads (Get_Warning_Option): Add new spec.
(Get_Warning_Option): Likewise.
(Get_Warning_Option): Likewise.

45 hours agoada: Remove Count_Compile_Time_Pragma_Warnings
Viljar Indus [Wed, 30 Apr 2025 11:00:49 +0000 (14:00 +0300)] 
ada: Remove Count_Compile_Time_Pragma_Warnings

Use a live counter Compile_Time_Pragma_Warnings to keep track of
those messages instead of using a method to count them in the end.

gcc/ada/ChangeLog:

* atree.ads: Add Compile_Time_Pragma_Warnings for counting
compile time warnings.
* errout.adb (Initialize): Initialize Compile_Time_Pragma_Warnings.
(Output_Messages): Use Compile_Time_Pragma_Warnings instead of
Count_Compile_Time_Pragma_Warnings.
* erroutc.adb (Compilation_Errors): Likewise.
(Count_Compile_Time_Pragma_Warnings): Removed.
(Decrease_Error_Msg_Count): Update Compile_Time_Pragma_Warnings.
(Increase_Error_Msg_Count): Likewise.
(Write_Error_Summary): Use Compile_Time_Pragma_Warnings instead of
Count_Compile_Time_Pragma_Warnings.
* erroutc.ads (Count_Compile_Time_Pragma_Warnings): Removed.

45 hours agoada: Use common routine to handle warning counting
Viljar Indus [Wed, 30 Apr 2025 10:53:03 +0000 (13:53 +0300)] 
ada: Use common routine to handle warning counting

gcc/ada/ChangeLog:

* errout.adb (Delete_Warning_And_Continuations): Use
Decrease_Error_Msg_Count to update the message counts.
(Delete_Warning): Likewise.
(To_Be_Removed): Likewise.

45 hours agoada: Mark errors that are removed as deleted
Viljar Indus [Wed, 30 Apr 2025 10:50:27 +0000 (13:50 +0300)] 
ada: Mark errors that are removed as deleted

gcc/ada/ChangeLog:

* errout.adb (Remove_Warning_Messages): Mark removed messages as
deleted.
* erroutc.adb (Purge_Messages): Likewise.

45 hours agoada: Remove spurious warnings about No_Exception_Propagation in GNATprove mode
Martin Clochard [Tue, 6 May 2025 13:59:16 +0000 (15:59 +0200)] 
ada: Remove spurious warnings about No_Exception_Propagation in GNATprove mode

gcc/ada/ChangeLog:

* frontend.adb (Frontend): do not override GNATprove's setting for
Warn_On_Non_Local_Exception

45 hours agoada: Remove dead assignment
Eric Botcazou [Tue, 6 May 2025 07:03:44 +0000 (09:03 +0200)] 
ada: Remove dead assignment

The assignment sets the Etype of a node to itsef.

gcc/ada/ChangeLog:

* sem_ch4.adb (Analyze_Allocator): Do not set Etype to itself.

45 hours agoada: Fix wrong finalization of constrained array derived from unconstrained
Eric Botcazou [Mon, 5 May 2025 14:59:13 +0000 (16:59 +0200)] 
ada: Fix wrong finalization of constrained array derived from unconstrained

The bug had been present for dynamically allocated objects since the first
rewrite of the finalization machinery more than a decade ago, and was then
propagated to statically declared objects by the recent rewrite.

gcc/ada/ChangeLog:

* exp_util.adb (Finalize_Address): Do not go to the root type for
array types.

45 hours agoada: Get rid of multiple roundings for 'Value of ordinary fixed-point types
Eric Botcazou [Wed, 30 Apr 2025 07:56:42 +0000 (09:56 +0200)] 
ada: Get rid of multiple roundings for 'Value of ordinary fixed-point types

They are used to minimize the error after every operation, but they can be
eliminated by increasing the precision of the input value, which avoids the
unwanted effects of multiple roundings.

gcc/ada/ChangeLog:

* libgnat/s-valuer.ads (System.Value_R): Remove Round parameter.
(Scan_Raw_Real): Replace Extra with Extra2 and adjust the comment.
(Value_Raw_Real): Likewise.
* libgnat/s-valuer.adb (Round_Extra): Delete.
(Scan_Decimal_Digits): Replace Extra with Extra2 and adjust the
implementation.
(Scan_Integral_Digits): Replace Extra with Extra2 and Extra_Rounded
with Extra2_Filled and adjust the implementation.
(Scan_Raw_Real): Replace Extra with Extra2 and adjust the
implementation.
(Value_Raw_Real): Likewise.
* libgnat/s-valrea.adb (Impl): Remove actual for Round formal.
* libgnat/s-valued.adb (Impl): Likewise.
(Integer_to_Decimal): Replace Extra with Extra2 and adjust the
implementation.  Rename Unsigned_To_Signed to To_Signed.
(Scan_Decimal): Replace Extra with Extra2 and adjust the
implementation.
(Value_Decimal): Likewise.
* libgnat/s-valuef.adb (Impl): Remove actual for Round formal.
(Integer_to_Fixed): Replace Extra with Extra2 and adjust the
implementation.  Rename Unsigned_To_Signed to To_Signed.  Only
round the last scaled divide operation.
(Scan_Fixed): Replace Extra with Extra2 and adjust the
implementation.
(Value_Fixed): Likewise.

45 hours agoada: Clarify numeric parsing code
Ronan Desplanques [Mon, 5 May 2025 09:37:00 +0000 (11:37 +0200)] 
ada: Clarify numeric parsing code

This patch rephrases some code in System.Value_R to make it easier to
read.

gcc/ada/ChangeLog:

* libgnat/s-valuer.adb (Scan_Decimal_Digits, Scan_Integral_Digits):
Minor rephrasing.

45 hours agoada: Set ekind of loop parameters earlier
Ronan Desplanques [Wed, 16 Apr 2025 10:33:11 +0000 (12:33 +0200)] 
ada: Set ekind of loop parameters earlier

gcc/ada/ChangeLog:

* sem_ch5.adb (Analyze_Loop_Parameter_Specification): Set ekind
earlier.

45 hours agoada: Small cleanup in the finalization machinery
Eric Botcazou [Thu, 1 May 2025 23:10:36 +0000 (01:10 +0200)] 
ada: Small cleanup in the finalization machinery

The generic finalization machinery and the finalization machinery for
transient objects disagree on which controlled objects should be finalized
indirectly, i.e. through an access value: the former only considers return
objects of (selected) function calls, whereas the latter considers all
objects designated by a reference, which means that it must be careful
about not finalizing them twice.

The discrepancy does not seem to cause problems in practice, but is awkward
and creates additional work for the finalization machinery for transient
objects, as well as code duplication.

gcc/ada/ChangeLog:

* exp_util.ads (Is_Finalizable_Access): New predicate.
(Is_Non_BIP_Func_Call): Delete.
(Is_Secondary_Stack_BIP_Func_Call): Likewise.
* exp_util.adb (Is_Finalizable_Access): New predicate.
(Initialized_By_Aliased_BIP_Func_Call): Delete.
(Initialized_By_Reference): Likewise.
(Is_Aliased): Only consider the nontransient object serviced by
the transient scope.
(Is_Part_Of_BIP_Return_Statement): Minor tweak.
(Is_Finalizable_Transient): Remove calls to Initialized_By_Reference
and Initialized_By_Aliased_BIP_Func_Call.
Call Is_Finalizable_Access for access objects.
(Is_Non_BIP_Func_Call): Delete.
(Is_Secondary_Stack_BIP_Func_Call): Likewise.
(Requires_Cleanup_Actions): Call Is_Finalizable_Access for access
objects.
(Side_Effect_Free): Return True for N_Reference.
* exp_ch7.adb (Build_Finalizer.Process_Declarations): Call
Is_Finalizable_Access for access objects.

45 hours agoada: Fix wrong finalization of temporary constrained array of controlled type
Eric Botcazou [Fri, 2 May 2025 13:32:54 +0000 (15:32 +0200)] 
ada: Fix wrong finalization of temporary constrained array of controlled type

This regression has been introduced by the rewrite of the finalization
machinery, which now requires a specific handling of constrained array
types with controlled component and an unconstrained first subtype.

gcc/ada/ChangeLog:

* exp_util.adb (Is_Expression_Of_Func_Return): New predicate.
(Is_Related_To_Func_Return): Call Is_Expression_Of_Func_Return.
(Remove_Side_Effects): Generate a temporary for a function call
that returns a constrained array type with controlled component
and an unconstrained first subtype.

45 hours agoada: Remove wrong optimization in frontend inlining of procedure calls
Piotr Trojanek [Tue, 29 Apr 2025 08:34:04 +0000 (10:34 +0200)] 
ada: Remove wrong optimization in frontend inlining of procedure calls

When using obsolete frontend inlining (switch -gnatN), we must always rewrite
the procedure call into a single block node. Otherwise, the copy-back of
parameters passed by-copy is inserted before the inlined procedure body, which
causes wrong code to be generated.

gcc/ada/ChangeLog:

* inline.adb (Rewrite_Procedure_Call): Replace with a simple rewriting
of procedure call into a single block node, i.e. remove broken
optimization.
* sem_util.adb (Next_Actual): Adapt GNATprove-specific code that peeks
into inlined calls.

45 hours agoada: Minor fix in handling of inherited Pre/Post'Class aspect
Martin Clochard [Tue, 29 Apr 2025 09:36:19 +0000 (11:36 +0200)] 
ada: Minor fix in handling of inherited Pre/Post'Class aspect

Mapping of calls to primitive functions in Pre/Post'Class aspects
inherited by derived types was only testing against controlling formals
of the parent subprogram. This lead to missing some calls, because formals
could be rewritten to that of the derived subprogram before the test
happens.

gcc/ada/ChangeLog:

* exp_util.adb (Is_Controlling_Formal_Ref): test scope against
derived subprogram as well.

45 hours agoada: Fix detecting Compilation_Errors
Viljar Indus [Mon, 28 Apr 2025 10:35:21 +0000 (13:35 +0300)] 
ada: Fix detecting Compilation_Errors

Subprogram Compilation_Errors is used to check whether any
errors have been detected during the compilation process. It
relies on Total_Errors_Detected and Warnings_Treated_As_Errors
counts. Total_Erros_Detected are updated immidiatelly after
the error objects have been created. Warnings_Treated_As_Errors
were updated only when the messages are being printed.

This leads to a situation where we do not have the correct count
of Warnings_Treated_As_Errors unless the errors have been printed.

gcc/ada/ChangeLog:

* errout.adb (Error_Msg_Internal): Relocate Warn_As_Err propagation
to Increase_Error_Msg_Counti.
(Delete_Warning_And_Continuations): Update
Warnings_Treated_As_Errors count.
(Delete_Warning): Likewise.
(To_Be_Removed): Likewise.
* erroutc.adb (Increase_Error_Msg_Count): Count warnings treated
as errors here and perform the propagation of this property to
the parent message.
(Output_Msg_Text): Remove counting of warnings as errors from
here.
(Decrease_Error_Msg_Count): Update Warnings_Treated_As_Errors
count.

45 hours agolibphobos: Fully enable Darwin/i386 support
Rainer Orth [Tue, 1 Jul 2025 08:22:06 +0000 (10:22 +0200)] 
libphobos: Fully enable Darwin/i386 support

I recently noticed that libphobos isn't enable by default on 32-bit
Darwin with the target triples determined by config.guess.  E.g. on a
Darwin 15 system the target triple is something like
i386-apple-darwin15.6.0 while configure.tgt only matches
i?86-*-darwin1[2-7].

This patch also allows such minor and micro versions.

Tested on i386-apple-darwin15.6.0.

2025-06-30  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

libphobos:
* configure.tgt <i?86-*-darwin1[2-7]>: Also consider minor
versions supported.

45 hours agoFix "void debug (const tree_node *ptr)"
H.J. Lu [Tue, 1 Jul 2025 00:14:09 +0000 (08:14 +0800)] 
Fix "void debug (const tree_node *ptr)"

Calling "debug (const tree_node *ptr)" does nothing.  Change it to
call debug_tree so that we can do this in gdb:

(gdb) whatis type
type = const_tree
(gdb) call debug (type)
 <real_type 0x7fffe982f2a0 float sizes-gimplified SF
    size <integer_cst 0x7fffe98204e0 type <integer_type 0x7fffe98280a8 bitsizetype> constant 32>
    unit-size <integer_cst 0x7fffe98204f8 type <integer_type 0x7fffe9828000 sizetype> constant 4>
    align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fffe982f2a0 precision:32
    pointer_to_this <pointer_type 0x7fffe982f930>>
(gdb)

PR debug/120902
* print-tree.cc (debug with const tree_node *): Call debug_tree
instead of debug.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
45 hours agogcc: middle-end opt for trigonometric pi-based functions builtins
Yuao Ma [Tue, 1 Jul 2025 07:50:28 +0000 (09:50 +0200)] 
gcc: middle-end opt for trigonometric pi-based functions builtins

This patch partially handled PR118592.

This patch builds upon r16-710-g591d3d02664c7b and r16-711-g89935d56f768b4.  It
introduces middle-end optimizations, such as constant folding, for our
trigonometric pi-based function built-ins.

gcc/ChangeLog:
* fold-const-call.cc (fold_const_call_ss): Constant fold for
single arg pi-based trigonometric builtins.
(fold_const_call_sss): Constant fold for double arg pi-based
trigonometric builtins.
* fold-const.cc (negate_mathfn_p): asinpi/atanpi is odd func.
(tree_call_nonnegative_warnv_p): acospi always non-neg,
asinpi/atanpi non-neg iff arg non-neg.
* tree-call-cdce.cc (can_test_argument_range): Add acospi/asinpi.
(edom_only_function): Add acospi/asinpi/cospi/sinpi.
(get_no_error_domain): Add acospi/asinpi.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp (foldable_pi_based_trigonometry): New
effective target.
* gcc.dg/torture/builtin-math-9.c: New test.

Signed-off-by: Yuao Ma <c8ef@outlook.com>
2 days ago[testsuite] restore default action from dfp.exp [PR120631]
Alexandre Oliva [Tue, 1 Jul 2025 00:27:15 +0000 (21:27 -0300)] 
[testsuite] restore default action from dfp.exp [PR120631]

dfp.exp tests for dfprt before deciding whether to default to run or
compile, and the PR120631 tests override that without checking for
dfprt.  Rework them to avoid attempting to link and run programs
when dfp runtime support isn't available.

for  gcc/testsuite/ChangeLog

PR middle-end/120631
* gcc.dg/dfp/pr120631.c: Drop overrider of dg-do default action.
* gcc.dg/dfp/bitint-9.c: Likewise.
* gcc.dg/dfp/bitint-10.c: Likewise.

2 days agoDaily bump.
GCC Administrator [Tue, 1 Jul 2025 00:19:55 +0000 (00:19 +0000)] 
Daily bump.

2 days agocobol: Revise diagnostic linemap management.
James K. Lowden [Mon, 30 Jun 2025 20:51:49 +0000 (16:51 -0400)] 
cobol: Revise diagnostic linemap management.

Update linemap filename before location in both parsers.  Rely on
parser to update linemap. Lexer maintains location. Various small
syntax corrections and extensions.

PR cobol/120772
PR cobol/120779
PR cobol/120790
PR cobol/120791
PR cobol/120794

gcc/cobol/ChangeLog:

* gcobc: Supply -fPIC for shared objects.
* genapi.cc (linemap_add): Delete empty macro.
(parser_enter_file): Do not call linemap_add.
(parser_leave_file): Same.
* gengen.cc (location_from_lineno): Remove function.
* lexio.cc (parse_replacing_term): Allow empty term.
(cdftext::process_file): Always append to output.
(cdftext::segment_line): Output #line directives.
* lexio.h (struct span_t): Count lines in span.
* parse.y: Revamp REPOSITORY, and minor syntax extensions.
* parse_ante.h (input_file_status_notify): Update linemap filename before location.
(intrinsic_token_of): Declare.
(parser_move_carefully): Support MOVE pointer.
* parse_util.h (intrinsic_token_of): New function.
* scan.l: New EOF logic, accept NOT=, own yylloc and yylineno.
* scan_ante.h (class enter_leave_t): Do not store newline count.
(cdf_location_set): Remove declaration.
(ydfltype_of): New function.
(update_location): Accept location parameter.
(reset_location): New function.
(YY_USER_ACTION): Use update_location().
(YY_USER_INIT): Update CDF location.
(verify_ws): New function.
(wait_for_the_child): Removed.
* symbols.h (cobol_fileline_set): return line number.
* util.cc (valid_move): Use range-based for loop.
(struct input_file_t): Remove line_map pointer.
(class unique_stack): New peek() member function.
(cobol_lineno_save): Rename to overload cobol_lineno().
(cobol_lineno): Replaces cobol_lineno_save().
(cobol_filename): Return void.
(location_from_lineno): New function used by genapi.cc.
(cdf_location_set): Remove.
(matched_length): No change.
(cobol_fileline_set): Return line number.
(fisspace): Remove extra semicolon.
(fisprint): Same.
* util.h (cobol_filename_restore): Return void.
(cobol_lineno_save): Remove declaration.
(cobol_lineno): Declare.

2 days ago[committed] [PR rtl-optimization/120242] Fix SUBREG_PROMOTED_VAR_P after ext-dce...
Jeff Law [Mon, 30 Jun 2025 20:38:33 +0000 (14:38 -0600)] 
[committed] [PR rtl-optimization/120242] Fix SUBREG_PROMOTED_VAR_P after ext-dce's actions

I've gone back and forth of these problems multiple times.  We have two passes,
ext-dce and combine which eliminate extensions using totally different
mechanisms.

ext-dce looks for cases where the state of upper bits in an object aren't
observable and if they aren't observable, then eliminates extensions which set
those bits.

combine looks for cases where we know the state of the upper bits and can prove
an extension is just setting those bits to their prior value.  Combine also
looks for cases where the precise extension isn't really important, just the
knowledge that the upper bits are zero or sign extended from a narrower mode
is needed.

Combine relies heavily on the SUBREG_PROMOTED_VAR state to do its job.  If the
actions of ext-dce (or any other pass for that matter) make
SUBREG_PROMOTED_VAR's state inconsistent with combine's expectations, then
combine can end up generating incorrect code.

--

When ext-dce eliminates an extension and turns it into a subreg copy (without
any known SUBREG_PROMOTED_VAR state).  Since we can no longer guarantee the
destination object has any known extension state, we scurry around and wipe
SUBREG_PROMOTED_VAR state for the destination object.

That's fine and dandy, but ultimately insufficient.  Consider if the
destination of the optimized extension was used as a source in a simple copy
insn.  Furthermore assume that the destination of that copy is used within a
SUBREG expression with SUBREG_PROMOTED_VAR set.  ext-dce's actions have
clobbered the SUBREG_PROMOTED_VAR state on the destination of that copy, albeit
indirectly.

This patch addresses this problem by taking the set of pseudos directly
impacted by ext-dce's actions and expands that set by building a transitive
closure for pseudos connected via copies.  We then scurry around finding
SUBREG_PROMOTED_VAR state to wipe for everything in that expanded set of
pseudos.  Voila, everything just works.

--

The other approach here would be to further expand the liveness sets inside
ext-dce.  That's a simpler path forward, but ultimately regresses the quality
of codes we do care about.

One good piece of news is that with the transitive closure bits in place, we
can eliminate a bit of the live set expansion we had in place for
SUBREG_PROMOTED_VAR objects.

--

So let's take one case of the 5 that have been reported.

In ext-dce we have this insn:

> (insn 29 27 30 3 (set (reg:DI 134 [ al_lsm.9 ])
>         (zero_extend:DI (subreg:HI (reg:DI 162) 0))) "j.c":17:17 552 {*zero_extendhidi2_bitmanip}
>      (expr_list:REG_DEAD (reg:DI 162)
>         (nil)))

There are reachable uses of (reg 134):

> (insn 49 47 52 6 (set (mem/c:HI (lo_sum:DI (reg/f:DI 186)
>                 (symbol_ref:DI ("al") [flags 0x86]  <var_decl 0x7ffff73c2da8 al>)) [2 al+0 S2 A16])
>         (subreg/s/v:HI (reg:DI 134 [ al_lsm.9 ]) 0)) 279 {*movhi_internal}
>      (expr_list:REG_DEAD (reg/f:DI 186)
>         (nil)))Obviously safe if we were to remove the extension.

> (insn 52 49 53 6 (set (reg:DI 176)
>         (and:DI (reg:DI 134 [ al_lsm.9 ])
>             (const_int 5 [0x5]))) "j.c":21:12 106 {*anddi3}
>      (expr_list:REG_DEAD (reg:DI 134 [ al_lsm.9 ])
>         (nil)))
> (insn 53 52 56 6 (set (reg:SI 177 [ _8 ])
>         (zero_extend:SI (subreg:HI (reg:DI 176) 0))) "j.c":21:12 551 {*zero_extendhisi2_bitmanip}
>      (expr_list:REG_DEAD (reg:DI 176)
>         (nil))) Safe to remove the extension as we only read the low 16 bits from the destination register (reg 176) in insn 53.

> (insn 27 26 29 3 (set (reg:DI 162)
>         (sign_extend:DI (plus:SI (subreg/s/v:SI (reg:DI 134 [ al_lsm.9 ]) 0)
>                 (const_int 1 [0x1])))) "j.c":17:17 8 {addsi3_extended}
>      (expr_list:REG_DEAD (reg:DI 134 [ al_lsm.9 ])
>         (nil)))
> (insn 29 27 30 3 (set (reg:DI 134 [ al_lsm.9 ])
>         (zero_extend:DI (subreg:HI (reg:DI 162) 0))) "j.c":17:17 552 {*zero_extendhidi2_bitmanip}
>      (expr_list:REG_DEAD (reg:DI 162)
>         (nil)))

Again, not as obvious as the first case, but we only read the low 16 bits from
(reg 162) in insn 29.  So those upper bits in (reg 134) don't matter.

> (insn 26 92 27 3 (set (reg:DI 144 [ ivtmp.17 ])
>         (reg:DI 134 [ al_lsm.9 ])) 277 {*movdi_64bit}
>      (nil))
> (insn 30 29 31 3 (set (reg:DI 135 [ al.2_3 ])
>         (sign_extend:DI (subreg/s/v:HI (reg:DI 144 [ ivtmp.17 ]) 0))) "j.c":17:9 558 {*extendhidi2_bitmanip}
>      (expr_list:REG_DEAD (reg:DI 144 [ ivtmp.17 ])
>         (nil)))Also safe in isolation.  But worth noting that if we remove the extension at insn 29, then the promoted status on (reg:DI 144) in insn 30 is no longer valid.

Setting aside the promoted state of (reg:DI 144) at insn 30 for a minute, let's
look into combine.

> (insn 26 92 27 3 (set (reg:DI 144 [ ivtmp.17 ])
>         (reg:DI 134 [ al_lsm.9 ])) 277 {*movdi_64bit}
>      (nil))   [ ... ]
> (insn 30 29 31 3 (set (reg:DI 135 [ al.2_3 ])
>         (sign_extend:DI (subreg/s/v:HI (reg:DI 144 [ ivtmp.17 ]) 0))) "j.c":17:9 558 {*extendhidi2_bitmanip}
>      (expr_list:REG_DEAD (reg:DI 144 [ ivtmp.17 ])
>         (nil)))
> (jump_insn 31 30 32 3 (set (pc)
>         (if_then_else (eq (reg:DI 135 [ al.2_3 ])
>                 (const_int 0 [0]))
>             (label_ref:DI 41)
>             (pc))) "j.c":4:55 371 {*branchdi}
>      (int_list:REG_BR_PROB 536870913 (nil))
>  -> 41)

Combine will do its thing on insns 30/31.  Essentially the sign extension is
not necessary in this context, assuming the promoted subreg status in insn 30
-- the equality test doesn't really care about the kind of extension, just
knowing the value is extended is enough to safely elide the extension.

And now we've come to the crux the problem.  That promotion state needs to be
adjusted.  The new ext-dce code will see that copy at insn 26 and add (reg 144)
to the set of registers that need promotion state wiped.  And everything is
happy after that.

The other cases are similar in nature.

--

This has been bootstrapped and regression tested on x86_64 and aarch64.
Variants have bootstrapped & regression tested on several other platforms and
it's survived testing on the crosses as well.

Pushing to the trunk...

PR rtl-optimization/120242
PR rtl-optimization/120627
PR rtl-optimization/120736
PR rtl-optimization/120813
gcc/

* ext-dce.cc (ext_dce_process_uses): Remove some cases where we
unnecessarily expanded live sets for promoted subregs.
(expand_changed_pseudos): New function.
(reset_subreg_promoted_p): Use it.

gcc/testsuite/

* gcc.dg/torture/pr120242.c: New test.
* gcc.dg/torture/pr120627.c: Likewise.
* gcc.dg/torture/pr120736.c: Likewise.
* gcc.dg/torture/pr120813.c: Likewise.

2 days ago[RISC-V] Correct CFA notes for stack-clash protection [PR120714]
Alexey Merzlyakov [Mon, 30 Jun 2025 19:58:29 +0000 (13:58 -0600)] 
[RISC-V] Correct CFA notes for stack-clash protection [PR120714]

Fixes incorrect SP-addresses used in CFA notes for the stack probes
unrelative to the frame's top. It applied to the RISC-V targets code
generation when the stack-clash protection is enabled.

PR target/120714
gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_allocate_and_probe_stack_space):
Fix SP-addresses in REG_CFA_DEF_CFA notes for stack-clash case.

gcc/testsuite/ChangeLog:

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

2 days agoanalyzer: use nullptr rather than NULL
David Malcolm [Mon, 30 Jun 2025 19:05:20 +0000 (15:05 -0400)] 
analyzer: use nullptr rather than NULL

Modernization; no functional change intended.

gcc/analyzer/ChangeLog:
* access-diagram.cc: Use nullptr rather than NULL where
appropriate.
* analyzer-language.cc: Likewise.
* analyzer-language.h: Likewise.
* analyzer-logging.h: Likewise.
* analyzer-pass.cc: Likewise.
* analyzer.cc: Likewise.
* bounds-checking.cc: Likewise.
* call-details.cc: Likewise.
* call-string.cc: Likewise.
* call-string.h: Likewise.
* call-summary.cc: Likewise.
* checker-event.cc: Likewise.
* common.h: Likewise.
* constraint-manager.cc: Likewise.
* constraint-manager.h: Likewise.
* diagnostic-manager.cc: Likewise.
* engine.cc: Likewise.
* exploded-graph.h: Likewise.
* function-set.cc: Likewise
* infinite-recursion.cc: Likewise
* inlining-iterator.h: Likewise
* kf.cc: Likewise
* known-function-manager.cc: Likewise
* pending-diagnostic.cc: Likewise
* program-point.cc: Likewise
* program-point.h: Likewise
* program-state.cc: Likewise
* program-state.h: Likewise
* record-layout.cc: Likewise
* region-model-asm.cc: Likewise
* region-model-manager.cc: Likewise
* region-model-manager.h: Likewise
* region-model-reachability.cc: Likewise
* region-model.cc: Likewise
* region-model.h: Likewise
* region.cc: Likewise
* region.h: Likewise
* sm-fd.cc: Likewise
* sm-malloc.cc: Likewise
* sm-pattern-test.cc: Likewise
* sm-signal.cc: Likewise
* sm-taint.cc: Likewise
* sm.cc: Likewise
* sm.h: Likewise
* state-purge.cc: Likewise
* state-purge.h: Likewise
* store.cc: Likewise
* store.h: Likewise
* supergraph.cc: Likewise
* supergraph.h: Likewise
* svalue.cc: Likewise
* svalue.h: Likewise
* varargs.cc: Likewise

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 days agodiagnostics: use nullptr rather than NULL
David Malcolm [Mon, 30 Jun 2025 19:05:14 +0000 (15:05 -0400)] 
diagnostics: use nullptr rather than NULL

Modernization; no functional change intended.

gcc/ChangeLog:
* diagnostic-color.cc: Use nullptr rather than NULL.
* diagnostic-format-sarif.cc: Likewise.
* diagnostic-format-text.cc: Likewise.
* diagnostic-macro-unwinding.cc: Likewise.
* diagnostic-path-output.cc: Likewise.
* diagnostic-path.cc: Likewise.
* diagnostic-show-locus.cc: Likewise.
* diagnostic-spec.cc: Likewise.
* diagnostic.cc: Likewise.
* lazy-diagnostic-path.cc: Likewise.
* simple-diagnostic-path.cc: Likewise.
* tree-diagnostic-client-data-hooks.cc: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 days agodiagnostics: convert diagnostic_event::meaning enums to enum class
David Malcolm [Mon, 30 Jun 2025 19:05:07 +0000 (15:05 -0400)] 
diagnostics: convert diagnostic_event::meaning enums to enum class

Modernization; no functional change intended.

gcc/analyzer/ChangeLog:
* checker-event.cc (function_entry_event::get_meaning): Convert
diagnostic_event::meaning enums to enum class.
(cfg_edge_event::get_meaning): Likewise.
(call_event::get_meaning): Likewise.
(return_event::get_meaning): Likewise.
(start_consolidated_cfg_edges_event::get_meaning): Likewise.
(inlined_call_event::get_meaning): Likewise.
(warning_event::get_meaning): Likewise.
* sm-fd.cc (fd_diagnostic::get_meaning_for_state_change):
Likewise.
* sm-file.cc (file_diagnostic::get_meaning_for_state_change):
Likewise.
* sm-malloc.cc (malloc_diagnostic::get_meaning_for_state_change):
Likewise.
* sm-sensitive.cc
(exposure_through_output_file::get_meaning_for_state_change):
Likewise.
* sm-taint.cc (taint_diagnostic::get_meaning_for_state_change):
Likewise.
* varargs.cc
(va_list_sm_diagnostic::get_meaning_for_state_change): Likewise.

gcc/ChangeLog:
* diagnostic-format-sarif.cc
(sarif_builder::maybe_make_kinds_array): Convert
diagnostic_event::meaning enums to enum class.
* diagnostic-path-output.cc (path_label::get_text): Likewise.
* diagnostic-path.cc
(diagnostic_event::meaning::maybe_get_verb_str): Likewise.
(diagnostic_event::meaning::maybe_get_noun_str): Likewise.
(diagnostic_event::meaning::maybe_get_property_str): Likewise.
* diagnostic-path.h (diagnostic_event::verb): Likewise.
(diagnostic_event::noun): Likewise.
(diagnostic_event::property): Likewise.
(diagnostic_event::meaning): Likewise.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/analyzer_gil_plugin.cc
(gil_diagnostic::get_meaning_for_state_change): Convert
diagnostic_event::meaning enums to enum class.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 days agodiagnostics: remove "json" output format
David Malcolm [Mon, 30 Jun 2025 19:04:55 +0000 (15:04 -0400)] 
diagnostics: remove "json" output format

The "json" output format for diagnostics was deprecated in GCC 15, with
advice to users seeking machine-readable diagnostics from GCC to use
SARIF instead.

This patch eliminates it from GCC 16, simplifying the diagnostics
subsystem somewhat.

Note that the Ada frontend seems to have its own implementation of this
in errout.adb (Output_JSON_Message), and documented in
gnat_ugn.texi.  This patch does not touch Ada.

gcc/ChangeLog:
* Makefile.in (OBJS-libcommon): Drop diagnostic-format-json.o.
* common.opt (fdiagnostics-format=): Drop
"json|json-stderr|json-file".
(diagnostics_output_format): Drop values "json", "json-stderr",
and "json-file".
* diagnostic-format-json.cc: Delete file.
* diagnostic-format.h
(diagnostic_output_format_init_json_stderr): Delete.
(diagnostic_output_format_init_json_file): Delete.
* diagnostic.cc (diagnostic_output_format_init): Delete cases for
DIAGNOSTICS_OUTPUT_FORMAT_JSON_STDERR and
DIAGNOSTICS_OUTPUT_FORMAT_JSON_FILE.
* diagnostic.h (DIAGNOSTICS_OUTPUT_FORMAT_JSON_STDERR): Delete.
(DIAGNOSTICS_OUTPUT_FORMAT_JSON_FILE): Delete.
* doc/invoke.texi: Remove references to json output format.
* doc/ux.texi: Likewise.
* selftest-run-tests.cc (selftest::run_tests): Drop call to
deleted selftest::diagnostic_format_json_cc_tests.
* selftest.h (selftest::diagnostic_format_json_cc_tests): Delete.

gcc/testsuite/ChangeLog:
* c-c++-common/analyzer/out-of-bounds-diagram-1-json.c: Deleted test.
* c-c++-common/diagnostic-format-json-1.c: Deleted test.
* c-c++-common/diagnostic-format-json-2.c: Deleted test.
* c-c++-common/diagnostic-format-json-3.c: Deleted test.
* c-c++-common/diagnostic-format-json-4.c: Deleted test.
* c-c++-common/diagnostic-format-json-5.c: Deleted test.
* c-c++-common/diagnostic-format-json-file-1.c: Deleted test.
* c-c++-common/diagnostic-format-json-stderr-1.c: Deleted test.
* c-c++-common/pr106133.c: Deleted test.
* g++.dg/pr90462.C: Deleted test.
* gcc.dg/plugin/diagnostic-test-paths-3.c: Deleted test.
* gcc.dg/plugin/plugin.exp (plugin_test_list): Remove deleted
test.
* gfortran.dg/diagnostic-format-json-1.F90: Deleted test.
* gfortran.dg/diagnostic-format-json-2.F90: Deleted test.
* gfortran.dg/diagnostic-format-json-3.F90: Deleted test.
* gfortran.dg/diagnostic-format-json-pr105916.F90: Deleted test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 days agoRegenerate common.opt.urls
Mark Wielaard [Mon, 30 Jun 2025 17:05:36 +0000 (19:05 +0200)] 
Regenerate common.opt.urls

When -fauto-profile-inlining was added it was documented, but
common.opt.urls wasn't regenerated.

Fixes: aaf55e09b3d9 ("Add -fauto-profile-inlining")
gcc/ChangeLog:

* common.opt.urls: Regenerate.

2 days agoAda: Provide fallback for GNATMAKE_FOR_BUILD Makefile variable
Eric Botcazou [Mon, 30 Jun 2025 16:57:27 +0000 (18:57 +0200)] 
Ada: Provide fallback for GNATMAKE_FOR_BUILD Makefile variable

The variable is set only at the top level.

gcc/ada/
PR ada/120106
* Make-generated.in (GNATMAKE_FOR_BUILD): Define.

2 days agoivopts: Fix scan-assembler-not regexes for aarch64/sve test
Christopher Bazley [Mon, 30 Jun 2025 15:59:56 +0000 (16:59 +0100)] 
ivopts: Fix scan-assembler-not regexes for aarch64/sve test

The test added by r16-1671-ge7ff8e8d77df74 passed despite using
regular expressions that would never match real assembly language
output from the compiler. Because the regular expressions were not
expected to match, and didn't, this was not noticeable; however,
it also made that part of the test useless.

The regular expressions have been fixed. Verified that the fixed
regular expressions do match assembly language output produced by
the compiler before the changes to ivopts in commit e7ff8e8d77d,
but do not match assembly language output produced by the compiler
after the changes to ivopts.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/sve/adr_7.c: Fix regular expressions.

2 days agoRISC-V: Add test for vec_duplicate + vssubu.vv combine case 1 with GR2VR cost 0,...
Pan Li [Fri, 27 Jun 2025 01:09:08 +0000 (09:09 +0800)] 
RISC-V: Add test for vec_duplicate + vssubu.vv combine case 1 with GR2VR cost 0, 1 and 2

Add asm dump check test for vec_duplicate + vssubu.vv combine to
vssubu.vx, with the GR2VR cost is 0, 1 and 2.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vx_vf/vx-4-u16.c: Add asm check
for vssubu.vx combine.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-4-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-4-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-4-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-5-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-5-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-5-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-5-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-6-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-6-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-6-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-6-u8.c: Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 days agoRISC-V: Add test for vec_duplicate + vssubu.vv combine case 0 with GR2VR cost 0,...
Pan Li [Fri, 27 Jun 2025 01:06:38 +0000 (09:06 +0800)] 
RISC-V: Add test for vec_duplicate + vssubu.vv combine case 0 with GR2VR cost 0, 2 and 15

Add asm dump check and run test for vec_duplicate + vssubu.vv
combine to vssubu.vx, with the GR2VR cost is 0, 2 and 15.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u16.c: Add asm check.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_binary.h: Add test
helper macros.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_binary_data.h: Add test
data for run test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vssub-run-1-u16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vssub-run-1-u32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vssub-run-1-u64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vssub-run-1-u8.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 days agoRISC-V: Reconcile the existing test due to cost model change
Pan Li [Fri, 27 Jun 2025 03:35:18 +0000 (11:35 +0800)] 
RISC-V: Reconcile the existing test due to cost model change

The cost model change will make the default cost of vx to 2, thus
reconcile the asm check for this change.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_trunc-1-u16.c:
Update the asm check due to cost model change.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_trunc-1-u32.c:
Diito.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_trunc-1-u8.c:
Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 days agoRISC-V: Combine vec_duplicate + vssubu.vv to vssubu.vx on GR2VR cost
Pan Li [Fri, 27 Jun 2025 01:02:03 +0000 (09:02 +0800)] 
RISC-V: Combine vec_duplicate + vssubu.vv to vssubu.vx on GR2VR cost

This patch would like to combine the vec_duplicate + vssubu.vv to the
vssubu.vx.  From example as below code.  The related pattern will depend
on the cost of vec_duplicate from GR2VR.  Then the late-combine will
take action if the cost of GR2VR is zero, and reject the combination
if the GR2VR cost is greater than zero.

Assume we have example code like below, GR2VR cost is 0.

  #define DEF_VX_BINARY(T, FUNC)                                      \
  void                                                                \
  test_vx_binary (T * restrict out, T * restrict in, T x, unsigned n) \
  {                                                                   \
    for (unsigned i = 0; i < n; i++)                                  \
      out[i] = FUNC (in[i], x);                                       \
  }

  T sat_sub(T a, T b)
  {
    return (a - b) & (-(T)(a >= b));
  }

  DEF_VX_BINARY(uint32_t, sat_sub)

Before this patch:
  10   │ test_vx_binary_or_int32_t_case_0:
  11   │     beq a3,zero,.L8
  12   │     vsetvli a5,zero,e32,m1,ta,ma
  13   │     vmv.v.x v2,a2
  14   │     slli    a3,a3,32
  15   │     srli    a3,a3,32
  16   │ .L3:
  17   │     vsetvli a5,a3,e32,m1,ta,ma
  18   │     vle32.v v1,0(a1)
  19   │     slli    a4,a5,2
  20   │     sub a3,a3,a5
  21   │     add a1,a1,a4
  22   │     vssubu.vv v1,v1,v2
  23   │     vse32.v v1,0(a0)
  24   │     add a0,a0,a4
  25   │     bne a3,zero,.L3

After this patch:
  10   │ test_vx_binary_or_int32_t_case_0:
  11   │     beq a3,zero,.L8
  12   │     slli    a3,a3,32
  13   │     srli    a3,a3,32
  14   │ .L3:
  15   │     vsetvli a5,a3,e32,m1,ta,ma
  16   │     vle32.v v1,0(a1)
  17   │     slli    a4,a5,2
  18   │     sub a3,a3,a5
  19   │     add a1,a1,a4
  20   │     vssubu.vx v1,v1,a2
  21   │     vse32.v v1,0(a0)
  22   │     add a0,a0,a4
  23   │     bne a3,zero,.L3

gcc/ChangeLog:

* config/riscv/riscv-v.cc (expand_vx_binary_vec_vec_dup): Add
new case US_MINUS.
* config/riscv/riscv.cc (riscv_rtx_costs): Ditto.
* config/riscv/vector-iterators.md: Add new op us_minus.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 days agoada: Fix Execution_Successful value with exceptions
Viljar Indus [Thu, 24 Apr 2025 10:14:40 +0000 (13:14 +0300)] 
ada: Fix Execution_Successful value with exceptions

Store the Exit_Code value and use that to generate
the Exceution_Successful value in the SARIF report.

gcc/ada/ChangeLog:

* comperr.adb (Compiler_Abort): Pass the exit code in calls to
Output_Messages.
* errout.adb (Output_Messages): Add new parameter for the
Exit_Code and store its value.
* errout.ads (Output_Messages): Likewise.
* erroutc-sarif_emitter.adb (Print_Invocations): Set
Execution_Successful based on the exit code.
* erroutc.ads (Exit_Code): Store the exit code value.
* gnat1drv.adb (Gnat1drv): Pass the exit code in calls to
Output_Messages.
* prepcomp.adb (Parse_Preprocessing_Data_File, Prpare_To_Preprocess):
Likewise.

2 days agoada: Refine use of Has_Exit
Ronan Desplanques [Tue, 29 Apr 2025 08:26:50 +0000 (10:26 +0200)] 
ada: Refine use of Has_Exit

The description of the Has_Exit field in Einfo makes it pretty clear
that it can only be meaningful for loop entities. It was however defined
in all entities until this patch, which restricts this field to E_Loop.

gcc/ada/ChangeLog:

* gen_il-gen-gen_entities.adb (Gen_Entities): Tweak Has_Exit.

2 days agoada: Make class-wide Max_Size_In_Storage_Elements return a large value
Bob Duff [Tue, 29 Apr 2025 17:12:44 +0000 (13:12 -0400)] 
ada: Make class-wide Max_Size_In_Storage_Elements return a large value

Max_Size_In_Storage_Elements is supposed to return a value greater or
equal to what is passed for any heap allocation for an object of the
type. For a tagged type T, we don't know the allocation size for
descendants; therefore T'Class'Max_Size_In_Storage_Elements should
return a huge number. In particular, it now returns Storage_Count'Last,
which is greater than any possible heap allocation.

Previously, T'Class'Max_Size_In_Storage_Elements was returning
the same value as T'Max_Size_In_Storage_Elements, which was
wrong.

gcc/ada/ChangeLog:

* exp_attr.adb (Attribute_Max_Size_In_Storage_Elements):
Return Storage_Count'Last converted to universal_integer.

2 days agoada: Add documentation of implemented Ada 2022 features
Tonu Naks [Fri, 28 Mar 2025 12:41:29 +0000 (12:41 +0000)] 
ada: Add documentation of implemented Ada 2022 features

gcc/ada/ChangeLog:

* doc/gnat_rm.rst: add entry point for the new chapter
* doc/gnat_rm/about_this_guide.rst: add reference to the new
chapter
* doc/gnat_rm/implementation_of_ada_2022_features.rst: new file
* doc/gnat_rm/implementation_of_ada_2012_features.rst: update
explanation about RM references
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.

2 days agoada: Reuse Snames classification of reserved words
Ronan Desplanques [Tue, 29 Apr 2025 12:34:47 +0000 (14:34 +0200)] 
ada: Reuse Snames classification of reserved words

Before this patch, Check_Future_Keyword had hardcoded lists of what
reserved words were introduced in what versions of the Ada language
specification. This patch makes it use the classification in Snames
instead.

gcc/ada/ChangeLog:

* par-util.adb (Check_Future_Keyword): Use Snames subtypes. Extend
comment.

2 days agoada: Remove obsolete comment
Ronan Desplanques [Mon, 28 Apr 2025 16:04:42 +0000 (18:04 +0200)] 
ada: Remove obsolete comment

This patch removes a comment that was left over when an exception
declaration was removed.

gcc/ada/ChangeLog:

* sem_ch5.adb (Analyze_Loop_Statement): Remove obsolete comment.