]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
3 months agolibstdc++: Ensure counting_semaphore::try_acquire_for times out [PR122878]
Jonathan Wakely [Fri, 9 Jan 2026 15:29:13 +0000 (15:29 +0000)] 
libstdc++: Ensure counting_semaphore::try_acquire_for times out [PR122878]

As noted in Bug 122878 comment 2, the _M_try_acquire_for implementation
doesn't reduce the remaining timeout each time it returns from an atomic
waiting function. This means that it can wait longer than requested, or
even loop forever. If there is a spurious wake from the timed waiting
function (__wait_until_impl) it will return indicating no timeout
occurred, which means the caller will check the value and potentially
sleep again. If spurious wakes happen every time, it will just keep
sleeping in a loop forever. This is observed to actually happen on
FreeBSD 14.0-STABLE where pthread_cond_timedwait gets a spurious wake
and so never times out.

The solution in this commit is to replace the implementation of
_M_try_acquire_for with a call to _M_try_acquire_until, converting the
relative timeout to an absolute timeout against the steady clock. This
is what ends up happening anyway, because we only have a
__wait_until_impl entry point into the library internals, so
__atomic_wait_address_for already converts the relative timeout to an
absolute timeout (except for the special case of a zero-value duration,
which only checks for an update while spinning for a finite number of
iterations, and doesn't sleep).

As noted in comment 4 of the PR, this requires some changes to
_M_try_acquire which was relying on the behaviour of _M_try_acquire_for
for zero-value durations.  That behaviour is desirable for
_M_try_acquire so that it can handle short-lived contention without
failing immediately. To preserve that behaviour of _M_try_acquire it is
changed to do its own loop and to call __atomic_wait_address_for
directly with a zero duration, to do the spinloop.

libstdc++-v3/ChangeLog:

PR libstdc++/122878
* include/bits/semaphore_base.h (_M_try_acquire): Replace
_M_try_acquire_for call with explicit loop and call to
__atomic_wait_address_for.
(_M_try_acquire_for): Replace loop with call to
_M_try_acquire_until.

Co-authored-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 months agoFortran: [PR123483] Fix duplicate finalization
Jerry DeLisle [Fri, 9 Jan 2026 17:38:52 +0000 (09:38 -0800)] 
Fortran: [PR123483] Fix duplicate finalization

A duplicated call to a finalizer occured in cases where a derived type
has components, one or more of which are allocatable, and one or more
of which are finalizable. (The bug occured only if the derived type
is an extension of another type, which has defined assignment.)

New test case derived from the original report by Paul Thomas.

PR fortran/123483

gcc/fortran/ChangeLog:

* trans-array.cc (gfc_deallocate_alloc_comp): Ad the new
finalization argument and pass it to structure_alloc_comps.
* trans-array.h (gfc_deallocate_alloc_comp): Add a finalization
flag that can be passed by gfc_conv_procedure_call.
* trans-expr.cc (gfc_conv_procedure_call): Use the new
finalization flag.

gcc/testsuite/ChangeLog:

* gfortran.dg/finalize_61.f90: New test.

Signed off by: Andrew Benson <abensonca@gcc.gnu.org>

3 months agolibstdc++: Fix C++ 11 ctype when using picolibc (blank vs space)
Keith Packard [Thu, 8 Jan 2026 18:14:07 +0000 (10:14 -0800)] 
libstdc++: Fix C++ 11 ctype when using picolibc (blank vs space)

Existing toolchain builds rely on the similarity between picolibc and
newlib when building libstdc++ and use --with-newlib.

Switch to the picolibc 16-bit _ctype_wide array which provides
separate values for ctype_base::blank and ctype_base::space.

This fixes a bug where libstdc++ was including '\f', '\n', '\r' and
'\v' in the set of 'blank' chars. Afterwards, only ' ' and '\t' are in
this set, as specified by C++ 11.

libstdc++-v3/ChangeLog:

* acinclude.m4 (GLIBCXX_CONFIGURE): Add --with-picolibc.
* configure: Regenerate.
* configure.ac: Add handling for with_picolibc=yes.
* config/os/picolibc/ctype_base.h: New file.
* config/os/picolibc/ctype_configure_char.cc: New file.
* config/os/picolibc/ctype_inline.h: New file.
* config/os/picolibc/os_defines.h: New file.

Signed-off-by: Keith Packard <keithp@keithp.com>
3 months ago[PR123121, LRA]: Fix wrong rematerialization of insns with several outputs
Vladimir N. Makarov [Fri, 9 Jan 2026 15:36:29 +0000 (10:36 -0500)] 
[PR123121, LRA]: Fix wrong rematerialization of insns with several outputs

LRA in the test case, rematerialize insn with div/mod where div result
is not used.  Still div result requires ax which is used by different
pseudos at point of rematerialization and this clobbers the pseudo
value.  The patch solves the problem by constraining to single set
insns as we always rematerialize only one pseudo value.  Also there is
no sense to rematerialize div/mod as usually their latency is more
than load value from CPU cache.  The patch explicitly excludes such
insns from rematerialization.

gcc/ChangeLog:

PR rtl-optimization/123121
* lra-remat.cc (bad_for_rematerialization_p): Consider div/mod ops.
(operand_to_remat): Exclude rematerialization of insns with
multiple sets.

gcc/testsuite/ChangeLog:

PR rtl-optimization/123121
* gcc.target/i386/pr123121.c: New.

3 months agoRISC-V: Update tt-ascalon-d8's extension list [PR123492]
Peter Bergner [Fri, 9 Jan 2026 02:41:20 +0000 (20:41 -0600)] 
RISC-V: Update tt-ascalon-d8's extension list [PR123492]

The Ascalon core implements the full RVA23 profile plus a few other optional
extensions.  However, the -mcpu=tt-ascalon-d8 option doesn't enable them all.
Add the missing extensions.

2026-01-08  Peter Bergner  <bergner@tenstorrent.com>

gcc/
PR target/123492
* config/riscv/riscv-cores.def (RISCV_CORE)<tt-ascalon-d8>: Add missing
extensions via use of rva23s64 profile and adding zkr, smaia, smmpm,
smnpm, smrnmi, smstateen, ssaia, ssstrict, svadu.

Signed-off-by: Peter Bergner <bergner@tenstorrent.com>
3 months agoipa-cp: Use the VR and bits lattices for clones of non-local functions too
Martin Jambor [Wed, 7 Jan 2026 12:34:45 +0000 (13:34 +0100)] 
ipa-cp: Use the VR and bits lattices for clones of non-local functions too

Since the IPA-CP lattices for value ranges cannot hold more values and
don't have any "variable" flag, we initialize them to bottom for
non-local nodes.  However, that means we don't make use of known
information gathered in jump functions when the corresponding node is
cloned for some other reason.  This patch allows collection of the
information and only does not use them for the original non-local
nodes, while making sure that we do not propagate information through
such-non local nodes as there may be unknown calls.

gcc/ChangeLog:

2026-01-06  Martin Jambor  <mjambor@suse.cz>

* ipa-cp.h (class ipcp_bits_lattice): New members set_recipient_only,
recipient_only_p and m_recipient_only.
(class ipcp_vr_lattice): Likewise.
(ipcp_vr_lattice::init): Initialize also m_recipient_only.
* ipa-cp.cc (ipcp_bits_lattice::print): Adjust printting to also
print the new flag.
(ipcp_vr_lattice::print): Likewise.
(ipcp_vr_lattice::set_recipient_only): New function.
(ipcp_bits_lattice::set_recipient_only): Likewise.
(set_all_contains_variable): New parameter MAKE_SIMPLE_RECIPIENTS, set
bits and vr lattices to recibient only insted to bottom when it is
true.
(initialize_node_lattices): Pass true to the second parameter of
set_all_contains_variable.
(propagate_bits_across_jump_function): Treat recipient_only source
lattices like bottom.
(propagate_vr_across_jump_function): Likewise.
(ipcp_store_vr_results): Skip non-local nodes.

3 months agoipa-cp: Better opportunity evaluation and ranking
Martin Jambor [Mon, 5 Jan 2026 13:59:52 +0000 (14:59 +0100)] 
ipa-cp: Better opportunity evaluation and ranking

This modifies the decision making stage of IPA-CP in two ways:

Previously, local effects of the cloning were estimated only for the
constant that was being considered, even though the calls which bring
it also carry other constants.  With this patch, all knowsn constants
for the given subset of caller edges are considered and the heuritics
should therefore have more information and generally work better.

Also, when evaluating the opportunities for a given node, IPA-CP
previously just iterate over the parameters starting with the first
one and if any opportunity looked profitable, it was carried out and
associated calling edges were redirected, even if this precludes some
even better opportunity.  The patch tries to mitigate this by first
using the initial estimates to sort all cloning candidates and then
iterate in that order.

The one difference from the version I posted before is that I have
extended the checking assert making sure the value we clone for is
indeed used to also work for non-aggregate constants and polymorphic
contexts.

gcc/ChangeLog:

2025-12-01  Martin Jambor  <mjambor@suse.cz>

* ipa-cp.cc (good_cloning_opportunity_p): Dump a message when
bailing out early too.
(find_more_scalar_values_for_callers_subset): Rename to
find_scalar_values_for_callers_subset, collect constants regardless of
what is already in the vector.  Remove dumping.
(find_more_contexts_for_caller_subset): Rename to
find_contexts_for_caller_subset, collect contexts regardless of what
is already in the vector.  Remove dumping.
(find_aggregate_values_for_callers_subset): Rename to
find_aggregate_values_for_callers_subset_gc, implement using new
functions.
(find_aggregate_values_for_callers_subset_1): New function.
(find_aggregate_values_for_callers_subset): Likewise.
(copy_known_vectors_add_val): Removed.
(dump_reestimation_message): New function.
(decide_about_value): Remove formal parameter avals, compute it
independently, and use it to estimate local cloning effects.
(struct cloning_opportunity_ranking): New type.
(compare_cloning_opportunities): New function.
(cloning_opportunity_ranking_evaluation): Likewise.
(decide_whether_version_node): Pre-sort candidates for cloning before
really evaluating them.  Calculate context independent values only
when considering versioning for all contexts.
(ipcp_val_agg_replacement_ok_p): Renamed to
ipcp_val_replacement_ok_p, check also non-aggregate values.

gcc/testsuite/ChangeLog:

2026-01-08  Martin Jambor  <mjambor@suse.cz>

* gcc.dg/ipa/ipcp-agg-2.c: Adjust dump test.
* gcc.dg/ipa/ipcp-agg-3.c: Likewise.
* gcc.dg/ipa/ipcp-agg-4.c: Likewise.
* gcc.dg/ipa/ipcp-agg-14.c: New test.
* gcc.dg/vect/pr101145_1.c: Compile with -fno-ipa-cp.
* gcc.dg/vect/pr101145_2.c: Likewise.
* gcc.dg/vect/pr101145_3.c: Likewise.

3 months agoarm: prevent impossible tail- long-calls with static chain [PR119430]
Alexandre Oliva [Fri, 11 Jul 2025 01:21:31 +0000 (22:21 -0300)] 
arm: prevent impossible tail- long-calls with static chain [PR119430]

When a function call uses up all argument registers, and needs IP for
the static chain, there aren't any call-clobbered registers left for
reload to assign as the sibcall target, when -mlong-calls is enabled.
Use the same logic that does the job for indirect calls to prevent
tail calls in this case.

With this change, it is possible to bootstrap armv7a-linux-gnu with
both -O3 and lto, but only with both -mlong-calls and
-ffunction-sections.

Without -mlong-calls, linker veneer thunks may clobber the static
chain register set up by callers in one lto unit, preventing them from
reaching the callee in a separate lto unit.  -ffunction-sections is
required for -mlong-calls to be effective, because both caller and
callee are in the same section, and that disables long-calls when
!flag_reorder_blocks_and_partition.

gcc/ChangeLog

PR target/119430
* config/arm/arm.cc (arm_function_ok_for_sibcall): Disable
sibcalls for long-calls that use all call-clobbered
general-purpose registers, including the static chain.

3 months agos390: Fix operand modifier c
Stefan Schulze Frielinghaus [Fri, 9 Jan 2026 14:23:29 +0000 (15:23 +0100)] 
s390: Fix operand modifier c

Currently, operand modifier c truncates and extends any integer constant
to a signed 8-bit constant whereas the common code implementation just
prints the constant unmodified.  The modifier was introduced in
r0-87728-g963fc8d00baeca matching the new constraint C which ensures
that a constant is an 8-bit signed integer.

In the machine description, operand modifier c is only used for operands
with constraint C.  Therefore, there is no immediate need for some
special constant printing.

Since print_operand() is also used by output_asm_insn(), inline asm is
also affected by this.  Note, in output_asm_insn() we cannot utilize
output_addr_const() since not every CONST_INT is a valid address, i.e.,
we have up to 32-bit immediates and at most 20-bit (long) displacements.

In fact, %cN should behave the same as %N for any CONST_INT operand N,
although, this literally means that the output modifier accepts and
prints immediates which might be larger than any instruction accepts.
Though, regarding accepting or rejecting immediates, this is what
constraints et al. are for.  Therefore, align %cN and %N.

gcc/ChangeLog:

* config/s390/s390.cc (print_operand): Align %cN with %N.
* config/s390/s390.md: Remove comment.

gcc/testsuite/ChangeLog:

* gcc.target/s390/asm-constant-1.c: New test.

3 months agoEnable -fbit-tests and -fjump-tables at -Og [PR123212]
Filip Kastl [Fri, 9 Jan 2026 14:16:50 +0000 (15:16 +0100)] 
Enable -fbit-tests and -fjump-tables at -Og [PR123212]

Since GCC 15, bit test and jump table lowering was disabled for both -O0
and -Og to save compile time.  On -Og, compile time isn't *that*
critical, so this patch enables bit tests and jump tables on -Og once
again.

PR c/123212

gcc/ChangeLog:

* opts.cc: Enable -fbit-tests and -fjump-tables at -Og.

Signed-off-by: Filip Kastl <fkastl@suse.cz>
3 months agoaarch64: Add support for FEAT_F8F32MM, FEAT_F8F16MM, and FEAT_SVE_F16F32MM.
Alfie Richards [Thu, 23 Oct 2025 11:42:17 +0000 (11:42 +0000)] 
aarch64: Add support for FEAT_F8F32MM, FEAT_F8F16MM, and FEAT_SVE_F16F32MM.

Adds support for the AArch64 2024 fmmla extensions.

Note this includes a work around in the testsuite for spurious warnings
from binutils with movprfx and fmmla instructions.
(PR gas/33562).

gcc/ChangeLog:

* config/aarch64/aarch64-builtins.cc
(aarch64_expand_pragma_builtin): Add case for FMMLA.
* config/aarch64/aarch64-c.cc (aarch64_update_cpp_builtins):
Add new __ARM_FEATURE_X macros.
* config/aarch64/aarch64-simd-pragma-builtins.def
(vmmlaq_f16_mf8): New intrinsic.
(vmmlaq_f32_mf8): Likewise.
* config/aarch64/aarch64-simd.md
(@aarch64_<insn><VDQ_HSF_FMMLA:mode>): New instruction.
* config/aarch64/aarch64-sve-builtins-base.cc: Update mmla_impl
for new instructions.
* config/aarch64/aarch64-sve-builtins-shapes.cc
(struct mmla_def): Add support for the new widening forms.
* config/aarch64/aarch64-sve-builtins-sve2.def (svmmla) Add new
intrinsics.
* config/aarch64/aarch64-sve-builtins.cc (TYPES_cvt_narrow_s):
Fix comment.
* config/aarch64/aarch64-sve2.md
(@aarch64_sve2_<sve_fp_op><SVE_FULL_HSF_FMMLA:mode><VNx16QI_ONLY:mode>): New instruction.
(@aarch64_sve2_<sve_fp_op><VNx4SF_ONLY:mode><VNx8HF_ONLY:mode>): Likewise.
* config/aarch64/aarch64.h (TARGET_F8F32MM): New macro.
(TARGET_F8F16MM): Likewise.
(TARGET_SVE_F16F32MM): Likewise.
* config/aarch64/iterators.md (insn): Add fmmla entry.
(VDQ_HSF_FMMLA): New iterator.
(SVE_FULL_HSF_FMMLA): Likewise.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp:
* gcc.target/aarch64/acle/vmmlaq_f16_mf8.c: New test.
* gcc.target/aarch64/acle/vmmlaq_f32_mf8.c: New test.
* gcc.target/aarch64/sve2/acle/asm/fmmla_f8f16mm_sve2.c: New test.
* gcc.target/aarch64/sve2/acle/asm/fmmla_f8f32mm_sve2.c: New test.
* gcc.target/aarch64/sve2/acle/asm/fmmla_sve_f16f32mm.c: New test.
* gcc.target/aarch64/sve/acle/general-c/mmla_1.c: Update error messages.

3 months agoarm: always enable both simd and mve builtins
Christophe Lyon [Fri, 9 May 2025 11:42:20 +0000 (11:42 +0000)] 
arm: always enable both simd and mve builtins

We get lots of error messages when compiling arm_neon.h under
e.g. -mcpu=cortex-m55, because Neon builtins are enabled only when
!TARGET_HAVE_MVE.  This has been the case since MVE support was
introduced.

This patch uses an approach similar to what we do on aarch64, but only
partially since Neon intrinsics do not use the "new" framework.

We register all types and Neon intrinsics, whether MVE is enabled or
not, which enables to compile arm_neon.h.  However, we need to
introduce a "switcher" similar to aarch64's to avoid ICEs when LTO is
enabled: in that case, since we have to enable the MVE intrinsics, we
temporarily change arm_active_target.isa to enable MVE bits.  This
enables hooks like arm_vector_mode_supported_p and arm_array_mode to
behave as expected by the MVE intrinsics framework.  We switch back
to the previous arm_active_target.isa immediately after.

With a toolchain targetting e.g. cortex-m55,
gcc.target/arm/attr-neon3.c now compiles successfully, with only one
failure to be fixed separately:
FAIL: gcc.target/arm/attr-neon3.c check-function-bodies my1

Besides that, gcc.log is no longer full of errors messages when trying
to compile arm_neon.h if MVE is forced somehow.

gcc/ChangeLog:

* config/arm/arm-builtins.cc (arm_init_simd_builtin_types): Remove
TARGET_HAVE_MVE condition.
(class arm_target_switcher): New.
(arm_init_mve_builtins): Remove calls to
arm_init_simd_builtin_types and
arm_init_simd_builtin_scalar_types.  Switch to MVE isa flags.
(arm_init_neon_builtins): Remove calls to
arm_init_simd_builtin_types and
arm_init_simd_builtin_scalar_types.
(arm_need_mve_mode_regs): New.
(arm_need_neon_mode_regs): New.
(arm_target_switcher::arm_target_switcher): New.
(arm_target_switcher::~arm_target_switcher): New.
(arm_init_builtins): Call arm_init_simd_builtin_scalar_types and
arm_init_simd_builtin_types.  Always call arm_init_mve_builtins
and arm_init_neon_builtins.

3 months agotestsuite: Only xfail gcc/testsuite/gcc.dg/vect/pr33804.c etc. on 32-bit SPARC [PR102954]
Rainer Orth [Fri, 9 Jan 2026 13:38:16 +0000 (14:38 +0100)] 
testsuite: Only xfail gcc/testsuite/gcc.dg/vect/pr33804.c etc. on 32-bit SPARC [PR102954]

Two tests currently XPASS on 64-bit Solaris/SPARC:

XPASS: gcc.dg/vect/pr33804.c scan-tree-dump-times vect "vectorized 1 loops" 1
XPASS: gcc.dg/vect/pr33804.c scan-tree-dump-times vect "vectorizing stmts using SLP" 1

XPASS: gcc.dg/vect/slp-multitypes-3.c scan-tree-dump-times vect "vectorized 1 loops" 1
XPASS: gcc.dg/vect/slp-multitypes-3.c scan-tree-dump-times vect "vectorizing stmts using SLP" 2

Both tests are currently xfail'ed on sparc*-*-*.  The following patch
restricts that to 32-bit SPARC instead.

2026-01-05  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc/testsuite:
PR tree-optimization/102954
* gcc.dg/vect/pr33804.c (scan-tree-dump-times): Only
xfail on 32-bit SPARC.
* gcc.dg/vect/slp-multitypes-3.c: Likewise.

3 months agoUpdate copyright years.
Tonu Naks [Tue, 6 Jan 2026 09:38:06 +0000 (09:38 +0000)] 
Update copyright years.

Co-authored-by: Marc Poulhiès <poulhies@adacore.com>
3 months agoAda: Fix suboptimal copy of discriminated record to local variable (2nd try)
Eric Botcazou [Fri, 9 Jan 2026 11:27:49 +0000 (12:27 +0100)] 
Ada: Fix suboptimal copy of discriminated record to local variable (2nd try)

This happens for a discriminated record type with default discriminants, for
which GNAT allocates mutable objects with the maximum size, while trying not
to copy padding bits unnecessarily.  When the padded size is small enough to
be copied efficiently, it should nevertheless be profitable to copy them in
order to avoid a call to memcpy with a dynamic size.

This version makes sure that it is safe to read the padded size on the RHS,
which is not the case for example when the LHS is an unconstrained variable
but the RHS is a constrained object.

gcc/ada
* gcc-interface/trans.cc (gnat_to_gnu): Add comment explaining why
it is necessary to remove the padding for an object of a type with
self-referential size when it is not converted to the result type.
* gcc-interface/utils2.cc (build_binary_op) <MODIFY_EXPR>: For an
assignment between small padded objects of the same type with self-
referential size, and which have the same (constant) size, use the
padded view of the objects.

3 months agoi386: Add OPTION_MASK_ISA_64BIT to 4 non-ia32 builtins [PR123489]
Jakub Jelinek [Fri, 9 Jan 2026 11:19:26 +0000 (12:19 +0100)] 
i386: Add OPTION_MASK_ISA_64BIT to 4 non-ia32 builtins [PR123489]

The following 4 builtins have corresponding insns guarded with TARGET_64BIT
and are only used in #ifdef __x86_64__ ... #endif section of an intrin
header, so when used by hand with -m32 they ICE.

Fixed thusly.

I've additionally verified all the #ifdef __x86_64__ ... #endif guarded
builtins used in intrinsic headers and checked whether they have
OPTION_MASK_ISA_64BIT, the only other exception was __builtin_ia32_prefetchi
but I think that one is fine, as expansion in that case has
            if (TARGET_64BIT && TARGET_PREFETCHI
                && local_func_symbolic_operand (op0, GET_MODE (op0)))
              emit_insn (gen_prefetchi (op0, op2));
            else
              {
                warning (0, "instruction prefetch applies when in 64-bit mode"
                            " with RIP-relative addressing and"
                            " option %<-mprefetchi%>;"
                            " they stay NOPs otherwise");
                emit_insn (gen_nop ());
              }

2026-01-09  Jakub Jelinek  <jakub@redhat.com>

PR target/123489
* config/i386/i386-builtin.def (__builtin_ia32_cvttsd2sis64_round,
__builtin_ia32_cvttsd2usis64_round, __builtin_ia32_cvttss2sis64_round,
__builtin_ia32_cvttss2usis64_round): Require OPTION_MASK_ISA_64BIT.

* gcc.target/i386/pr123489.c: New test.

3 months agoada: Fix suboptimal copy of discriminated record to local variable
Eric Botcazou [Tue, 16 Dec 2025 11:30:14 +0000 (12:30 +0100)] 
ada: Fix suboptimal copy of discriminated record to local variable

This happens for a discriminated record type with default discriminants, for
which GNAT allocates mutable objects with the maximum size, while trying not
to copy padding bits unnecessarily.  When the padded size is small enough to
be copied efficiently, it should nevertheless be profitable to copy them in
order to avoid a call to memcpy with a dynamic size.

gcc/ada/ChangeLog:

* gcc-interface/trans.cc (gnat_to_gnu): For the LHS of an assignment
or an actual parameter of a call, do not remove the padding even for
a type of self-referential size when the padded size is small enough
to be copied efficiently.

3 months agoada: Move Save_Global_References_In_Aspects into sole caller
Eric Botcazou [Wed, 24 Dec 2025 19:35:39 +0000 (20:35 +0100)] 
ada: Move Save_Global_References_In_Aspects into sole caller

No functional changes.

gcc/ada/ChangeLog:

* sem_ch12.ads (Save_Global_References_In_Aspects): Move to...
* sem_ch12.adb (Save_Global_References_In_Aspects): Move to...
* contracts.adb (Save_Global_References_In_Contract): ...here.

3 months agoada: Improve fix for object with address clause and C++ constructor
Javier Miranda [Tue, 23 Dec 2025 19:05:33 +0000 (19:05 +0000)] 
ada: Improve fix for object with address clause and C++ constructor

Improves previous fix to handle an object that has an address clause
and it is initialized by C++ imported constructor call.

gcc/ada/ChangeLog:

* exp_ch3.adb (Expand_N_Object_Declaration): Remove previous patch
and place the call to the constructor into a compound statement
attached to the object; the compound statement will be moved to
the freezing actions of the object if the object has an address
clause.

3 months agoada: Fix crash on legality check for initialization of implicit constructor
Denis Mazzucato [Thu, 18 Dec 2025 12:34:18 +0000 (13:34 +0100)] 
ada: Fix crash on legality check for initialization of implicit constructor

This patch fixes a crash occurring during the legality check of the Initialize
aspect when the constructor is implicitly created by the compiler, e.g., the
default copy constructor. In such case, Corresponding_Spec is not available, the
Specification field must be used instead.

gcc/ada/ChangeLog:

* sem_ch13.adb (Check_Constructor_Initialization_Expression): The first
parameter of an implicit constructor comes from Specification, not
Corresponding_Spec.

3 months agoada: Fix small oversight in accessibility change
Eric Botcazou [Mon, 22 Dec 2025 09:52:01 +0000 (10:52 +0100)] 
ada: Fix small oversight in accessibility change

The change incorrectly turned a Comes_From_Source test initially done on the
type conversion node, into a test on its parent node, that is used to decide
whether to apply an accessibility check to the type conversion.

gcc/ada/ChangeLog:

* exp_ch4.adb (Expand_N_Type_Conversion): Restore Comes_From_Source
test on N itself instead of its parent node.

3 months agoada: Fix accessibility level of function calls in Ada 95
Eric Botcazou [Thu, 18 Dec 2025 23:57:28 +0000 (00:57 +0100)] 
ada: Fix accessibility level of function calls in Ada 95

This fixes the computation of the accessibility level in the default case.

gcc/ada/ChangeLog:

* accessibility.adb (Function_Call_Or_Allocator_Level): Return the
level of the subprogram in Ada 95 only in the case where the result
type is a return-by-reference type.

3 months agoada: Ada.Containers.Bounded_Indefinite_Holders follow-up.
Steve Baird [Fri, 19 Dec 2025 22:08:30 +0000 (14:08 -0800)] 
ada: Ada.Containers.Bounded_Indefinite_Holders follow-up.

Suppress warnings generated for a Bounded_Indefinite_Holders instance
when compiled for a 32-bit target. The warnings are not useful because
the construct being flagged is in code that is dead (for that instance).

gcc/ada/ChangeLog:

* libgnat/a-cbinho.ads: add Warnings pragmas.

3 months agoada: Fix fallout of latest accessibility change with -gnata
Eric Botcazou [Fri, 19 Dec 2025 17:24:45 +0000 (18:24 +0100)] 
ada: Fix fallout of latest accessibility change with -gnata

Compiling with assertion enabled may create _Wrapped_Statements functions
with access result, whose anonymous access result type is the same entity
as that of their parent function, which fools the accessibility logic.

gcc/ada/ChangeLog:

* accessibility.adb (Function_Call_Or_Allocator_Level): Adjust the
latest change to cope with _Wrapped_Statements functions.
* einfo.ads (Wrapped_Statements): Fix description.
* sem_util.adb (In_Return_Value): Fix typo in comment.

3 months agoada: Unsigned_Base_Range aspect (part 7)
Javier Miranda [Wed, 3 Dec 2025 19:37:53 +0000 (19:37 +0000)] 
ada: Unsigned_Base_Range aspect (part 7)

Add support for ELIMINATED and MINIMIZED overflow checking modes
on types with the Unsigned_Base_Range aspect (modes available
under switch -gnato).

gcc/ada/ChangeLog:

* checks.ads (Convert_From_Bignum): Add a new formal and update
documentation.
(Convert_To_Bignum): Update documentation.
* checks.adb (Is_Signed_Integer_Arithmetic_Op): Renamed as
Is_Overflow_Arithmetic_Op, and replace calls to function
Is_Signed_Integer_Type by calls to Has_Overflow_Operations.
(Apply_Arithmetic_Overflow_Minimized_Eliminated): Add support
for types with the Unsigned_Base_Range aspect.
(Apply_Divide_Checks): Replace calls to Is_Signed_Integer_Type
by calls to Has_Overflow_Operations.
(Compute_Range_For_Arithmetic_Op): Adjust comment.
(Convert_To_Bignum): Add support for types with the Unsigned_
Base_Range aspect.
(Convert_From_Bignum): Add support for result type with the
Unsigned_Base_Range aspect.
(Minimize_Eliminate_Overflows): Add support for types with the
Unsigned_Base_Range aspect.
* exp_ch4.adb (Minimized_Eliminated_Overflow_Check): Replace
call to Is_Signed_Integer_Type by call to Has_Overflow_Operations.
(Expand_Compare_Minimize_Eliminate_Overflow): Add support for types
with the Unsigned_Base_Range aspect.
(Expand_Membership_Minimize_Eliminate_Overflow): Ditto.
(Expand_N_Op_Expon): Ditto.
(Expand_Exponentiation): New subprogram.
* rtsfind.ads (RE_Id): Add RE_LLU_To_Bignum, RE_LLU_From_Bignum.
* libgnat/s-bignum.ads (LLU_To_Bignum): New subprogram.
(LLU_From_Bignum): New subprogram.
* libgnat/s-bignum.adb (LLU_To_Bignum): New subprogram.
(LLU_From_Bignum): New subprogram.
* libgnat/s-genbig.ads (From_Bignum): New overloaded functions
for Long_Long_Long_Unsigned and Long_Long_Unsigned types.
(To_Bignum): Ditto.
* libgnat/s-genbig.adb (From_Bignum): New overloaded functions
for Long_Long_Long_Unsigned and Long_Long_Unsigned types.
(To_Bignum): Ditto.
* libgnat/s-expuns.ads (Exp_Unsigned): Fix documentation.
* libgnat/s-expllu.ads (Exp_Long_Long_Unsigned): Ditto.
* libgnat/s-explllu.ads (Exp_Long_Long_Long_Unsigned): Add missing
documentation.

3 months agoada: Reimplement AI12-0345, AI12-0372 and implement AI12-0402
Eric Botcazou [Thu, 11 Dec 2025 15:14:32 +0000 (16:14 +0100)] 
ada: Reimplement AI12-0345, AI12-0372 and implement AI12-0402

The first two are binding interpretations, so apply to Ada 2012, and have
been only partially implemented.  The third is Ada 2022 and has not been
implemented, but is very convenient to tame the effects of the first two.

They mostly pertain to explicitly aliased parameters and to adjusting the
rules determining the master of a function call, so that the RM 6.4.1(6.4)
legality rule is applied judiciously.

The change also does some housekeeping work in the implementation of static
accessibility checks, plugging a few loopholes: in Ada 2005 for objects of
anonymous access types, in Ada 2005 and 2012 for conversions between access
types done in extended return statements, and in Ada 2012 for explicitly
aliased parameters.

gcc/ada/ChangeLog:

* accessibility.ads (Is_Special_Aliased_Formal_Access): Delete.
* accessibility.adb (Is_Special_Aliased_Formal_Access): Likewise.
(Accessibility_Level.Innermost_Master_Scope_Depth): Look for non-
package bodies and statements directly.
(Accessibility_Level.Function_Call_Or_Allocator_Level): For a
function call in a return context, return the extra level of the
master of the call only for dynamic checks.
(Accessibility_Level) <N_Defining_Identifier>: Always return the
library level for an explicitly aliased parameter in the context
of a return from the subprogram where it is declared.
* exp_ch4.adb (Expand_N_Allocator): Test manually whether the
context is a return statement instead of calling In_Return_Value.
(Expand_N_Type_Conversion): Do not apply accessibility checks to
actuals of a tagged type in a synthesized subprogram call.
* sem_attr.adb (Resolve_Attribute) <Access>: Remove specific test
for explicitly aliased parameters.
* sem_ch4.adb: Remove clauses for Accessibility package.
(Analyze_Call): Do not apply static accessibility checks here...
* sem_res.adb (Resolve_Actuals): ...but here instead.  Implement
a generalized form of AI12-0402.
(Valid_Conversion): Apply static accessibility checks in extended
return statements too.
* sem_util.ads (In_Return_Value): Adjust description.
(Is_Master): Delete.
* sem_util.adb (Is_Explicitly_Aliased): Reindent.
(In_Return_Value): Reimplement.
(Is_Master): Delete.

3 months agoada: Add quickfixes for -gnawk warnings
Viljar Indus [Fri, 12 Dec 2025 13:18:02 +0000 (15:18 +0200)] 
ada: Add quickfixes for -gnawk warnings

gcc/ada/ChangeLog:

* errout.adb (Insert): New function to create an insertion fix.
(Deletion): New function to create a deletion fix.
* errout.ads: Likewise.
* sem_warn.adb (Create_Add_Constant_Fix): New function to create
a fix for adding a constant qualifier for a variable declaration.
(Change_In_Out_To_In_Fix): New function to create a fix for
convertinting an in out parameter direction to a an in direction.

Co-authored-by: Eric Botcazou <ebotcazou@adacore.com>
3 months agoada: Update GNAT RM after implementing Indefinite_Holders
Tonu Naks [Wed, 17 Dec 2025 12:06:32 +0000 (12:06 +0000)] 
ada: Update GNAT RM after implementing Indefinite_Holders

gcc/ada/ChangeLog:

* doc/gnat_rm/implementation_of_ada_2022_features.rst: update
AI12-0350, add AI12-0254.
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.

3 months agoada: Set thread description on Windows
Ronan Desplanques [Tue, 16 Dec 2025 14:28:48 +0000 (15:28 +0100)] 
ada: Set thread description on Windows

On Windows, the tasking runtime now calls SetThreadDescription on the
underlying system threads with the task images as argument.

gcc/ada/ChangeLog:

* adaint.c (__gnat_set_thread_description): New function.
* libgnarl/s-taprop__mingw.adb (Enter_Task): Set thread description.
* rtinit.c (__gnat_runtime_initialize): Set up function pointer.
* mingw32.h (HRESULT, pSetThreadDescription): New.

3 months agoada: Fix parameterless constructors
Denis Mazzucato [Mon, 8 Dec 2025 13:09:12 +0000 (14:09 +0100)] 
ada: Fix parameterless constructors

This patch fix support for parameterless constructors. Specifically, it forbids calling the
parameterless constructor when no explicit one has been declared, and when the parameterless one has
been explicitly removed.

Furthermore, by freezing constructors as predefined operations, it is now possible to use them in
global object declarations right after the record type declaration.

gcc/ada/ChangeLog:

* exp_ch3.adb (Build_Init_Procedure): Remove call to constructors.
(Build_Default_Simple_Initialization): Implicit call to parameterless constructors in new
allocations.
(Expand_Freeze_Record_Type): Freeze constructors as we would freeze predefined operations.
(Constructor_Freeze): Freeze all constructors.
* sem_attr.adb (Analyze_Attribute): Handle missing parameterless constructors.
* sem_ch3.adb: The default constructor is now called parameterless.
* sem_util.adb (Find_Matching_Constructor): Return the constructor
matching the given condition. Before it was just checking its
existence.
(Has_Copy_Constructor): Move it upward to maintain alphabetic
order of utility subprograms.
(Has_Parameterless_Constructor): The default constructor is now called parameterless.
(Has_Explicit_Constructor): New utility to check for constructors
defined by the user. Used to understand if an implicit
parameterless constructor exists.
(Is_Copy_Constructor): Refactor easier control flow.
(Is_Parameterless_Constructor): New utility to check if a constructor has a profile
compatible with the parameterless constructor.
* sem_util.ads: Likewise.

3 months agoada: Update -gnatwk error messages with Diagnostic_Id-s
Viljar Indus [Wed, 3 Dec 2025 09:49:45 +0000 (11:49 +0200)] 
ada: Update -gnatwk error messages with Diagnostic_Id-s

Add new entries to the Diagnostic_Id-s and entries to the diagnostic
repository for error messages that are activated by -gnatwk.

gcc/ada/ChangeLog:

* errid-diagnostic_repository.ads: Update the diagnostic repository.
* errid-switch_repository.ads: Update the switch repository.
* errid.ads: Add new Diagnostic_Id-s.
* sem_warn.adb (Check_References): Add Diagnostic_Id-s for
error messages triggered by -gnatwk.

3 months agoada: Add diagnostic entry consistency checks
Viljar Indus [Mon, 8 Dec 2025 11:26:54 +0000 (13:26 +0200)] 
ada: Add diagnostic entry consistency checks

Verify that every diagnostic that has a switch also has the same
diagnostic marked as one of the diagnostics for that same switch.

Additionally verify that for every diagnostic marked for a switch
these diagnostics have the same switch marked as its switch.

gcc/ada/ChangeLog:

* errid.adb (Check_Diagnostic_To_Switch_Consistency): New subprogram
for checking the consistency of diagnostics.
(Check_Switch_To_Diagnostic_Consistency) New subprogram for checking
the consistency of switches.
(Add_All_Diagnostic_Rules): Check diagnostic consitency.
(Add_All_Switch_Rules): Check switch consitency.

3 months agoada: Print gnat diagnostics with the gnat command
Viljar Indus [Tue, 25 Nov 2025 12:46:08 +0000 (14:46 +0200)] 
ada: Print gnat diagnostics with the gnat command

Remove the support for printing the diagnostic report
in the compiler when -gnatd_E is used. Instead print it
when the "gnat --diagnostics" command is used.

gcc/ada/ChangeLog:

* debug.adb: remove use case for -gnatd_E
* errout.adb (Output_Messages): remove printing of
the diagnostic repository when -gnatd_E is used.
* gnatcmd.adb: Add support for printing the diagnostic repository.

3 months agoada: Add support for printing switches in the SARIF report
Viljar Indus [Tue, 25 Nov 2025 12:45:29 +0000 (14:45 +0200)] 
ada: Add support for printing switches in the SARIF report

Previously the report for all of the available diagnostics
and switches was given in a custom JSON format. This patch
merges the two reports and includes them in a special SARIF
report where all of the diagnostics and switches are presented
as switches in the rules section of the report. Switches and
diagnostics are linked with each other through the relationship
node. Diagnostic rules will have a superset relation to a switch
rule and a Switch rule will have a subset relation to each of its
diagnostic rules.

In order to facilitate those changes the errid and errsw packages were
reorganized. Now errid will have the definitions for both all of the
Diagnostic_Id-s and Switch_Id-s. The two new subpackages for errid -
Diagnostic_Repository and Switch_Repository will hold the repository
information that will be presented in the SARIF report.

gcc/ada/ChangeLog:

* errid-diagnostic_repository.ads: New package for storing
information about diagnostics.
* errid-switch_repository.adb: New package for storing
information about switches.
* errid-switch_repository.ads: Likewise.
* errid.adb: Move common methods related to Diagnostic_Id-s and
Switch_Id-s to this pacakge.
* errid.ads: Likewise.
* errout.adb (Add_Unique_Diagnostics_And_Switches): New method
for gathering all of the unique Diagnostic_Id-s and Switch_Id-s
among all of the error messages.
(Output_Messages): Use the new SARIF printer interface for printing
the report.
* erroutc-sarif_emitter.adb (Print_Relationship): New method for
printing relationship nodes.
(Print_Rule): Support printing switches as rules. Add support
for printing relationship nodes under rules. Remove brackets around
the rule name.
(Print_Runs): Add a printer argument to pass all of the switches
and diagnostics as rules in the SARIF report.
(Print_Tool): Likewise.
(Free): New method.
(Get_Unique_Rules): Removed.
(Print_Result): Remove brackets around the rule name.
(Print_Rules): Print switches as rules.
* erroutc-sarif_emitter.ads (SARIF_Printer): New record type for
storing and passing all of the diagnostic and switch information
around in the SARIF printer.
(Report_Kind): New type for indicating the different reports the
SARIF emitter can produce.
(Free): New method for releasing all of the dynamically allocated
memory.
(Print_SARIF_Report): Add a SARIF_Printer argument.
* erroutc.adb (Get_Human_Id): Removed.
(Get_Switch): Removed.
(Get_Doc_Switch): Simplify code.
* erroutc.ads: (Get_Human_Id): Removed.
(Get_Switch): Removed.
* errsw.adb: Replaced by errid-switch_repository.adb.
* errsw.ads: Replaced by errid-switch_repository.ads.
* errutil.adb: Remove dependecy to errsw pacakge.
* par-endh.adb: Fix whitespace.
* gcc-interface/Make-lang.in: Update the dependencies.
* gcc-interface/Makefile.in: Likewise.

3 months agoada: Implement From_Address attribute
Steve Baird [Tue, 9 Dec 2025 22:14:53 +0000 (14:14 -0800)] 
ada: Implement From_Address attribute

Add support for the GNAT-defined From_Address attribute.

gcc/ada/ChangeLog:

* doc/gnat_rm/implementation_defined_attributes.rst: Document the
From_Address attribute.
* exp_attr.adb (Expand_N_Attribute_Reference): Implement expansion
of a From_Address attribute reference.
* sem_attr.adb (Analyze_Attribute): Implement analysis of a
From_Address attribute reference.
(Eval_Attribute): A From_Address attribute reference cannot be
statically evaluated.
* snames.ads-tmpl: Declare Name_From_Address and Attribute_From_Address.
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.

3 months agoada: new legality checks for Super and Initialize aspect specifications
Steve Baird [Wed, 26 Nov 2025 00:14:52 +0000 (16:14 -0800)] 
ada: new legality checks for Super and Initialize aspect specifications

An expression provided as part of a Super or Initialize aspect specification
is not allowed to reference the constructed object (that is, the first
parameter of the constructor procedure).

gcc/ada/ChangeLog:

* sem_ch13.adb (Analyze_Aspect_Specifications): Add new legality
checks for Super and Initialize aspect specifications, implemented
by calling a new local procedure,
Check_Constructor_Initialization_Expression.

3 months agoada: Implement Ada.Containers.Bounded_Indefinite_Holders.
Steve Baird [Wed, 5 Nov 2025 22:13:16 +0000 (14:13 -0800)] 
ada: Implement Ada.Containers.Bounded_Indefinite_Holders.

Implement the predefined unit Ada.Containers.Bounded_Indefinite_Holders.

gcc/ada/ChangeLog:

* Makefile.rtl: add entry for new unit
* impunit.adb: add entry for new unit
* libgnat/a-cbinho.adb: new file with body for new unit
* libgnat/a-cbinho.ads: new file with spec for new unit
* libgnat/a-coboho.ads: add comment
* libgnat/a-undesu.ads: add Preelaborate aspect specification,
as per AI22-0050.

3 months agoada: Fix missing warning for unused use clause with use clause for child package
Eric Botcazou [Mon, 15 Dec 2025 09:48:05 +0000 (10:48 +0100)] 
ada: Fix missing warning for unused use clause with use clause for child package

The -gnatwu switch does not give any warning for a unused use clause when a
use clause for a child package is present.  It turns out that there are many
occurrences in the compiler itself!

gcc/ada/ChangeLog:

PR ada/123003
* accessibility.adb: Remove unused clauses.
* aspects.adb: Likewise.
* checks.adb: Likewise.
* comperr.adb: Likewise.
* contracts.adb: Likewise.
* cstand.adb: Likewise.
* debug_a.adb: Likewise.
* errout.adb: Likewise.
* eval_fat.adb: Likewise.
* exp_aggr.adb: Likewise.
* exp_atag.adb: Likewise.
* exp_attr.adb: Likewise.
* exp_cg.adb: Likewise.
* exp_ch11.adb: Likewise.
* exp_ch12.adb: Likewise.
* exp_ch13.adb: Likewise.
* exp_ch2.adb: Likewise.
* exp_ch3.adb: Likewise.
* exp_ch4.adb: Likewise.
* exp_ch5.adb: Likewise.
* exp_ch6.adb: Likewise.
* exp_ch7.adb: Likewise.
* exp_ch8.adb: Likewise.
* exp_ch9.adb: Likewise.
* exp_code.adb: Likewise.
* exp_dbug.adb: Likewise.
* exp_disp.adb: Likewise.
* exp_dist.adb: Likewise.
* exp_fixd.adb: Likewise.
* exp_imgv.adb: Likewise.
* exp_intr.adb: Likewise.
* exp_pakd.adb: Likewise.
* exp_prag.adb: Likewise.
* exp_put_image.adb: Likewise.
* exp_sel.adb: Likewise.
* exp_smem.adb: Likewise.
* exp_spark.adb: Likewise.
* exp_strm.adb: Likewise.
* exp_tss.adb: Likewise.
* exp_unst.adb: Likewise.
* exp_util.adb: Likewise.
* exp_util.ads: Likewise.
* expander.adb: Likewise.
* freeze.adb: Likewise.
* frontend.adb: Likewise.
* ghost.adb: Likewise.
* gnat1drv.adb: Likewise.
* gnat_cuda.adb: Likewise.
* impunit.adb: Likewise.
* inline.adb: Likewise.
* itypes.adb: Likewise.
* itypes.ads: Likewise.
* layout.adb: Likewise.
* lib.adb: Likewise.
* libgnarl/s-tasuti.adb: Likewise.
* live.adb: Likewise.
* local_restrict.adb: Likewise.
* mutably_tagged.adb: Likewise.
* nlists.adb: Likewise.
* par.adb: Likewise.
* par_sco.adb: Likewise.
* pprint.adb: Likewise.
* repinfo.adb: Likewise.
* restrict.adb: Likewise.
* rtsfind.adb: Likewise.
* scil_ll.adb: Likewise.
* scn.adb: Likewise.
* sem.adb: Likewise.
* sem_aggr.adb: Likewise.
* sem_attr.adb: Likewise.
* sem_aux.adb: Likewise.
* sem_case.adb: Likewise.
* sem_cat.adb: Likewise.
* sem_ch10.adb: Likewise.
* sem_ch11.adb: Likewise.
* sem_ch12.adb: Likewise.
* sem_ch13.adb: Likewise.
* sem_ch2.adb: Likewise.
* sem_ch3.adb: Likewise.
* sem_ch4.adb: Likewise.
* sem_ch5.adb: Likewise.
* sem_ch6.adb: Likewise.
* sem_ch7.adb: Likewise.
* sem_ch9.adb: Likewise.
* sem_dim.adb: Likewise.
* sem_disp.adb: Likewise.
* sem_dist.adb: Likewise.
* sem_elab.adb: Likewise.
* sem_elim.adb: Likewise.
* sem_eval.adb: Likewise.
* sem_intr.adb: Likewise.
* sem_mech.adb: Likewise.
* sem_prag.adb: Likewise.
* sem_res.adb: Likewise.
* sem_scil.adb: Likewise.
* sem_smem.adb: Likewise.
* sem_type.adb: Likewise.
* sem_util.adb: Likewise.
* sem_util.ads: Likewise.
* sem_warn.adb: Likewise.
* sinput.adb: Likewise.
* sprint.adb: Likewise.
* strub.adb: Likewise.
* style.adb: Likewise.
* styleg.adb: Likewise.
* tbuild.adb: Likewise.
* tbuild.ads: Likewise.
* treepr.adb: Likewise.
* uname.adb: Likewise.
* sem_ch8.adb: Likewise.
(Mark_Use_Clauses.Mark_Use_Package): Do not recurse on the prefix
for a package given by an expanded name.

3 months agoada: Tech debt: clean up miscellaneous VAST issues
Bob Duff [Thu, 11 Dec 2025 19:22:50 +0000 (14:22 -0500)] 
ada: Tech debt: clean up miscellaneous VAST issues

Clean up various issues found while working on VAST.

Fix uses of Token_Node, which was used in cases where it was documented
as undefined, leading to strange behavior with respect to setting Parent
nodes.

Obey the comment about Validate_Subprogram_Calls in frontend.adb,
"this work will be done by VAST". Remove conditionals on
Debug_Flag_Underscore_XX.

gcc/ada/ChangeLog:

* debug.adb: Remove doc for gnatd_X; no longer used.
* einfo.ads: Minor comment improvement.
* exp_ch3.adb: Minor reformatting.
* exp_ch6.adb (Check_BIP_Actuals): Export.
(Validate_Subprogram_Calls): Move to Vast.
* exp_ch6.ads (Check_BIP_Actuals): Export.
* exp_ch7.adb (Make_Init_Call): Remove obsolete Set_Assignment_OK.
* frontend.adb: Move Validate_Subprogram_Calls call to VAST,
as the comment suggested.
* par.adb: Minor comment improvements.
* par-ch13.adb (Get_Aspect_Specifications):
Misc cleanup, including removal of redundant setting
of Aspects, and changing multiple 'if's to 'case'.
* par-ch4.adb (P_Simple_Name_Resync): Do not refer to Token_Node
when it is documented as not defined.
* par-ch6.adb: Minor comment improvement.
* par-util.adb (Bad_Spelling_Of): After setting Token from
identifier to keyword, destroy Token_Node, so it doesn't get
accidentally used.
* scans.adb (Save_Scan_State, Restore_Scan_State):
Put these in logical order. Make sure we're not saving
and restoring bogus information in Token_Node.
* scans.ads: Fix incorrect comment.
* scn.ads: Minor comment improvements. Do not duplicate (wrong)
information from Scans.
* scng.adb: Set Token_Node to Empty initially, so we don't
accidentally refer to bogus information from previous tokens.
* scng.ads: Minor comment improvement (remove information
about one actual from comment on the formal).
* sem_aux.ads (Initialization_Suppressed):
Minor comment improvement.
* sem_ch6.adb: Remove usage of Debug_Flag_Underscore_XX.
This code is pretty well tested by now, and anyway, it's
only called from within pragmas Assert.
* sem_util.adb (Enter_Name): Minor cleanup.
* sprint.adb (Dump_Generated_Only): Fix incorrect comment.
* vast.adb: Misc cleanup. Enable assertion about
Errout.Compilation_Errors (should be False if back end
is enabled).
(Validate_Subprogram_Calls): Move here from frontend.adb.
Move call to it here from frontend.adb.

3 months agoada: Compiler crash on ill-formed container indexing
Gary Dismukes [Fri, 5 Dec 2025 01:00:19 +0000 (01:00 +0000)] 
ada: Compiler crash on ill-formed container indexing

The compiler blows up when analyzing an illegal indexing of a container
object (such as a vector) when the indexing expression has the form of
a named actual parameter and the name given for the parameter does not
match the name of the index formal of the corresponding indexing function
that the compiler identifies for doing the generalized indexing.

gcc/ada/ChangeLog:

* sem_ch4.adb (Try_Container_Indexing): Conditionalize last actual of
call to Error_Msg_NE to avoid blowup on N_Parameter_Association actuals.

3 months agoada: Change 'Size of formal unconstrained discriminated in out parameters
Eric Botcazou [Wed, 10 Dec 2025 20:40:27 +0000 (21:40 +0100)] 
ada: Change 'Size of formal unconstrained discriminated in out parameters

When the discriminated type is declared with default discriminants, it is
definite, so objects of the type can be declared without constraints, are
thus unconstrained, and are allocated with the maximum size by GNAT.

When these objects are passed as actuals of formal in out parameters, it
makes sense for the 'Size computed for them from within the subprogram to
also be the above "unconstrained" size instead of the "constrained" size
computed from the value of the discriminants present in them.

gcc/ada/ChangeLog:

* exp_attr.adb (Expand_Size_Attribute): If the attribute is applied
to a formal parameter allocated with an extra Constrained parameter,
use the value of the latter to choose between the "unconstrained" or
the "constrained" size of the formal parameter.

3 months agoada: Warn on untagged record type equality under Ada 83/95 modes
Javier Miranda [Wed, 10 Dec 2025 12:08:32 +0000 (12:08 +0000)] 
ada: Warn on untagged record type equality under Ada 83/95 modes

Compiling under Ada 83 or Ada 95 mode, the warning reported under
-gnatw_q is triggered by the compiler when a user-defined "=" on
an untagged record type U is not used to compare a component C
(of type U) of an outer record R.

The warning is reported because it may be surprising that, under
Ada 83 and Ada 95 modes, 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_ch4.adb (Expand_Composite_Equality): Under Ada83 and Ada95
modes, and compiling under -gnatw_q, search for an user-defined
equality and report a warning if found since it will not be called.

3 months agoada: Restore previous mapping for Ada to Win32 task priorities
Piotr Trojanek [Wed, 3 Dec 2025 23:48:43 +0000 (00:48 +0100)] 
ada: Restore previous mapping for Ada to Win32 task priorities

This patch restores previous mapping of Ada to Win32 task priorities used
when no pragma Task_Dispatching_Policy (FIFO_Within_Priorities) is present
(except for wrong mapping to values that can only be used for processes
with REALTIME_PRIORITY_CLASS).

The new mapping is consistent with the one used when that pragma is present
and provides distinct values for priorities in range of Default_Priority +/- 2.

gcc/ada/ChangeLog:

* libgnat/system-mingw.ads (Underlying_Priorities): Restore previous
mapping with distinct values around Default_Priority.

3 months agoada: Implement copy constructors
Denis Mazzucato [Wed, 19 Nov 2025 13:13:35 +0000 (14:13 +0100)] 
ada: Implement copy constructors

This patch implements the copy constructor as a particular type of constructor
that copies its second parameter "From" into the first implicit "Self"
parameter. The copy constructor is called via the 'Make attribute and is always
available for tagged types.

Internally, when missing an implicit copy constructor with default behavior is
generated. Sometimes, when its behavior wouldn't differ from the default
byte-wise copy, no entity is actually generated. In this case, whenever the copy
constructor is called via the 'Make attribute, the call is rewritten simply as
its parameter "From".

gcc/ada/ChangeLog:

* exp_attr.adb (Expand_N_Attribute_Reference): Do not expand copy
constructor calls when unnecessary.
* exp_ch3.adb
(Build_Implicit_Copy_Constructor): If necessary, build the implicit copy
constructor as part of the initialization procedures of its type.
(Expand_N_Object_Declaration): Add implicit 'Make attribute calls for
objects that may need construction.
* exp_ch6.adb (Make_Parent_Constructor_Call): Constructor's procedure
calls should be only generated from expansion of the 'Make attribute as
there is hidden logic to handle copy constructors.
* sem_attr.adb (Analyze_Attribute): Emit a specific error message if a
non-copy constructor is called but no constructor is defined.
* sem_ch13.adb (Analyze_Aspect_Specifications): The Ekind of the
implicitly generated copy constructor is not a subprogram body.
* sem_ch4.adb (Extended_Primitive_Ops): Extend the operation list that
can be called via prefix notation to include constructors.
* sem_ch6.adb (Check_For_Primitive_Subprogram): Skip constructors for
primitive analysis.
* sem_util.adb (Has_Matching_Constructor): Generic function to
check for the existence of a constructor matching a given
condition.
(Has_Copy_Constructor): Check whether a type has an implicit or explicit
copy constructor.
(Has_Default_Constructor): Use Has_Matching_Constructor.
(Is_Copy_Constructor): Check whether a subprogram is a copy constructor.
(Is_Copy_Constructor_Call): Check whether an attribute call is call to a
copy constructor.
* sem_util.ads: Add specs for copy constructor utility functions.
* snames.ads-tmpl (Snames): Add names Self and From.

3 months agoada: Move detection of anonymous access types in expansion of Old attributes
Martin Clochard [Mon, 3 Nov 2025 09:19:08 +0000 (10:19 +0100)] 
ada: Move detection of anonymous access types in expansion of Old attributes

Expansion of the Old attribute with anonymous access type is treated
as a special case as the implicit constants need to be declared the
same way as for conditionally evaluated Old attributes. However, this
was implemented in a way that produced evaluation guards even when
the attribute was supposed to be unconditionally evaluated.

gcc/ada/ChangeLog:

* exp_attr.adb (Expand_N_Attribute_Reference): For Old attribute,
detect the anonymous access type case explicitly instead of
implicitly within in Eligible_For_Conditional_Evaluation.
* sem_util.ads: (Eligible_For_Conditional_Evaluation): Do not
return True on anonymous access types. This was also breaking usage
outside expansion (legality checks for Old).
* sem_util.adb: (Conditional_Evaluation_Condition): Special case
of no determiners for anonymous access types is no longer possible.

3 months agoada: Change syntax for destructors extension
Ronan Desplanques [Tue, 2 Dec 2025 11:48:04 +0000 (12:48 +0100)] 
ada: Change syntax for destructors extension

This patch replaces aspect-based version of the destructors extension
with a new version that uses the "direct attribute definition" syntax
that was recently introduced by the constructors extension.

gcc/ada/ChangeLog:

* snames.ads-tmpl: Make "Destructor" an attribute name.
* snames.adb-tmpl: Allow direct attribute definition for Destructor.
* gen_il-fields.ads (Destructor): New field.
(Is_Destructor): Remove.
* gen_il-gen-gen_entities.adb: (Destructor): New field.
(Is_Destructor): Remove.
* einfo.ads (Destructor): Document new field.
(Is_Destructor): Remove documentation.
* aspects.ads (Aspect_Destructor): Remove.
* exp_attr.adb (Expand_N_Attribute_Reference): Adapt after aspect
removal.
* exp_ch7.adb (Build_Finalize_Statements): Adapt to new destructor
representation.
* freeze.adb (Freeze_Entity): Remove obsolete check.
* sem_attr.adb (Analyze_Attribute, Eval_Attribute): Adapt to new
attribute.
* sem_ch13.adb (Analyze_Aspect_Specifications,
Check_Aspect_At_End_Of_Declarations): Adapt after aspect removal.
* sem_ch6.adb (Analyze_Direct_Attribute_Definition): Add handling
of Destructor attribute.
(Can_Be_Destructor_Of): New function.
* doc/gnat_rm/gnat_language_extensions.rst: Adapt documentation to
new syntax.
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.

3 months agoada: Update gnat-llvm debugging documentation
Tom Tromey [Mon, 1 Dec 2025 21:18:07 +0000 (14:18 -0700)] 
ada: Update gnat-llvm debugging documentation

This updates the gnat-llvm debugging documentation to reflect the
current status.

gcc/ada/ChangeLog:

* doc/gnat_ugn/building_executable_programs_with_gnat.rst
(GNATLLVM): Update debugging documentation.
* gnat_ugn.texi: Regenerate.

3 months agoada: Rename Find_Hook_Context function
Eric Botcazou [Mon, 17 Nov 2025 20:18:28 +0000 (21:18 +0100)] 
ada: Rename Find_Hook_Context function

The hook moniker is an obsolete reference to the previous implementation of
object finalization, which used hooks (and counters) to manage the objects.

gcc/ada/ChangeLog:

* exp_util.ads (Find_Hook_Context): Rename to...
(Find_Master_Context): ...this and alphabetize.
* exp_util.adb (Find_Master_Context): Rename to...
(Find_Master_Context): ...this and alphabetize.
* exp_ch4.adb (Insert_Conditional_Object_Declaration): Adjust to
above renaming.
(Process_Transients_In_Expression): Likewise.

3 months agoada: Fix missing diagnostic with "T'Constructor" syntax
Ronan Desplanques [Tue, 2 Dec 2025 09:58:48 +0000 (10:58 +0100)] 
ada: Fix missing diagnostic with "T'Constructor" syntax

Before this patch, procedures of the form "T'Constructor" without
separate specs were incorrectly accepted in some cases. This patch fixes
the issue.

gcc/ada/ChangeLog:

* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Check direct
attribute definitions for specs.

3 months agoada: Adjust SPARK RM rule numbers for new handling of Async_Writers
Piotr Trojanek [Thu, 20 Nov 2025 22:29:15 +0000 (23:29 +0100)] 
ada: Adjust SPARK RM rule numbers for new handling of Async_Writers

A SPARK RM rule 7.1.2(14) about Async_Writes being implicitly initialized is
now removed; adjust references to subsequent rules in comments.

gcc/ada/ChangeLog:

* sem_prag.adb (Analyze_Pragma): Adjust references in comments for
pragma Side_Effects and Volatile_Function.

3 months agoada: Spurious warning on untagged record type equality
Javier Miranda [Thu, 27 Nov 2025 17:56:08 +0000 (17:56 +0000)] 
ada: Spurious warning on untagged record type equality

The frontend reports a spurious warning when the type of some
component of an untagged record type is a private record type
that has an user-defined equality operator and the sources
are compiled enabling warnings for ignored equality operators
(that is, switch -gnatdw_q).

The warning is spurious because it must not be reported when
the full type declaration of the private type is a record type.

gcc/ada/ChangeLog:

* exp_ch3.adb (Build_Untagged_Record_Equality): Add missing
support for incomplete and private types.

3 months agoada: Fix crash when checking ghost levels of call arguments
Viljar Indus [Thu, 27 Nov 2025 09:07:19 +0000 (11:07 +0200)] 
ada: Fix crash when checking ghost levels of call arguments

We should avoid the check if the called entity cannot have formals

gcc/ada/ChangeLog:

* einfo-utils.adb (Can_Have_Formals): New function for checking
if the entity can support formals.
* einfo-utils.ads (Can_Have_Formals): Likewise.
* ghost.adb (Check_Procedure_Call_Argument_Levels): Avoid checking
the type of the formal if the called entity cannot hold formals.

3 months agoada: Fix fallout of recent change related to task activation
Eric Botcazou [Wed, 26 Nov 2025 15:20:39 +0000 (16:20 +0100)] 
ada: Fix fallout of recent change related to task activation

The Move_Activation_Chain routine is not available in all runtime libraries.

gcc/ada/ChangeLog:

* exp_ch6.adb (Expand_N_Extended_Return_Statement): Do not call
Move_Activation_Chain if it is not available in the runtime library.

3 months agoada: Fix Ultimate_Overlaid_Entity to match the SPARK RM semantics
Claire Dross [Tue, 25 Nov 2025 16:40:31 +0000 (17:40 +0100)] 
ada: Fix Ultimate_Overlaid_Entity to match the SPARK RM semantics

The Ultimate_Overlaid_Entity function should return the root of the
last precisely supported address clause as per the definition in the
SPARK RM.

gcc/ada/ChangeLog:

* sem_util.ads (Overlaid_Entity): Return the root of the address
clause of an object if it is precisely supported in SPARK.
* sem_util.adb (Ultimate_Overlaid_Entity): Use Overlaid_Entity to
match the SPARK RM semantics.
* sem_prag.adb (Analyze_Global_Item): Only check for overlays on
variables.
(Analyze_Initialization_Item): Likewise.
(Analyze_Input_Item): Likewise.

3 months agoada: Find overlying with slices
Piotr Trojanek [Tue, 25 Nov 2025 10:29:28 +0000 (11:29 +0100)] 
ada: Find overlying with slices

A recent change removed rewriting of address of a slice into address of first
component of a slice. Now we need to explicitly detect overlying with slices.
Together, both changes cause warnings to be emitted when slice of a constant
object is overlaid by a variable.

gcc/ada/ChangeLog:

* sem_util.adb (Find_Overlaid_Entity): Detect overlying with slice.

3 months agoada: Allow component clauses for certain record components with discriminants
Ronan Desplanques [Mon, 24 Nov 2025 08:55:56 +0000 (09:55 +0100)] 
ada: Allow component clauses for certain record components with discriminants

Before this patch, the compiler rejected record representation clauses
when a component has a subtype with a non-static discriminant constraint.
This is a somewhat coarse-grained since the size of such a component can
be constant relatively to the discriminant. One such case in particular
is when the component subtype is an unchecked union.

This patch makes the compiler accept the unchecked union case.

gcc/ada/ChangeLog:

* freeze.adb (Size_Known): Modify rejection condition.

3 months agoada: Fix premature finalization caused by predicate check on aggregate component
Eric Botcazou [Mon, 24 Nov 2025 17:08:10 +0000 (18:08 +0100)] 
ada: Fix premature finalization caused by predicate check on aggregate component

The predicate check may cause the creation of a temporary when it is applied
to a function call and the temporary will be finalized, so any assignment of
the temporary must be followed by an adjustment of the target.

gcc/ada/ChangeLog:

* exp_ch5.adb (Expand_N_Assignment_Statement): If a predicate check
made on the RHS forced the capture of a function call to remove its
side effects, demote No_Ctrl_Actions into No_Finalize_Actions on the
N_Assignment_Statement node.

3 months agoada: Make Exp_Ch9.Build_Task_Allocate_Block a function
Eric Botcazou [Sat, 22 Nov 2025 14:19:28 +0000 (15:19 +0100)] 
ada: Make Exp_Ch9.Build_Task_Allocate_Block a function

This streamlines the code in the callers.  No functional changes.

gcc/ada/ChangeLog:

* exp_ch9.ads (Build_Task_Allocate_Block): Change to function and
remove first formal parameter.
* exp_ch9.adb (Build_Task_Allocate_Block): Likewise.  Return an
anonymous list of nodes.
* exp_aggr.adb (Convert_Aggr_In_Allocator): Adjust to above change.
* exp_ch4.adb (Expand_N_Allocator): Likewise.
* exp_ch6.adb (Make_Build_In_Place_Call_In_Allocator): Likewise.

3 months agoada: Do not inline calls to ghost functions
Piotr Trojanek [Mon, 24 Nov 2025 13:38:32 +0000 (14:38 +0100)] 
ada: Do not inline calls to ghost functions

Instead of detecting exceptions by inlined ghost function calls we simply
prevent ghost functions from being inlined. This change only affects SPARK.

gcc/ada/ChangeLog:

* inline.adb (Build_Body_To_Inline): Do not inline ghost functions.

3 months agoada: Update compiler sample output in user's guide
Ronan Desplanques [Mon, 24 Nov 2025 11:08:58 +0000 (12:08 +0100)] 
ada: Update compiler sample output in user's guide

The error messages displayed in the modified example were changed in
GNAT a while ago, but the example itself had not been updated.

This patch also tweaks the reStructuredText markup in the example.

gcc/ada/ChangeLog:

* doc/gnat_ugn/building_executable_programs_with_gnat.rst: Update
example.
* gnat-style.texi: Regenerate.
* gnat_ugn.texi: Regenerate.

3 months agoada: Give consistent error message for invalid prefix in select component
Eric Botcazou [Thu, 20 Nov 2025 22:25:15 +0000 (23:25 +0100)] 
ada: Give consistent error message for invalid prefix in select component

This gives a consistent error message for an invalid prefix in all the cases
where the prefix has been found to be the name of an entity.

gcc/ada/ChangeLog:

* sem_ch4.adb (Analyze_Selected_Component): Give a specific error
message for an invalid prefix that is the dereference of a name.
* sem_ch8.adb (Find_Selected_Component): Give a consistent error
message for the name of an invalid prefix.

3 months agoc++/modules: Mark implicit using-directive for imported unnamed namespace as imported...
Nathaniel Shead [Thu, 8 Jan 2026 09:38:43 +0000 (20:38 +1100)] 
c++/modules: Mark implicit using-directive for imported unnamed namespace as imported [PR123393]

The assertion failure in the PR is due to the implicit using-directive
for the anonymous namespace not being considered imported, because
make_namespace_finish calls add_using_namespace without propagating
'from_import'.

PR c++/123393

gcc/cp/ChangeLog:

* name-lookup.cc (make_namespace_finish): Pass from_import to
add_using_namespace.

gcc/testsuite/ChangeLog:

* g++.dg/modules/namespace-18_a.C: New test.
* g++.dg/modules/namespace-18_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
3 months agobugzilla: remove `gcc-bugs@` mailing list address
Ben Boeckel [Sat, 11 Oct 2025 02:01:03 +0000 (22:01 -0400)] 
bugzilla: remove `gcc-bugs@` mailing list address

Bugzilla is preferred today. Use a URL that gives context about
gathering information prior to actually filing a bug at Bugzilla.

ChangeLog:

* config-ml.in: Replace gcc-bugs@ with bug reporting link.
* symlink-tree: Replace gcc-bugs@ with bug reporting link.

fixincludes/ChangeLog:

* README: Replace gcc-bugs@ with bug reporting link.

gcc/testsuite/ChangeLog:

* lib/file-format.exp: Replace gcc-bugs@ with bug reporting link.

libcpp/ChangeLog:

* configure: Regenerate.
* configure.ac: Replace gcc-bugs@ with bug reporting link.

libdecnumber/ChangeLog:

* configure: Regenerate.
* configure.ac: Replace gcc-bugs@ with bug reporting link.

3 months agoifcvt: Reject inner floating modes of a subreg for noce_try_cond_zero_arith [PR123491]
Andrew Pinski [Fri, 9 Jan 2026 02:58:57 +0000 (18:58 -0800)] 
ifcvt: Reject inner floating modes of a subreg for noce_try_cond_zero_arith [PR123491]

Like the check that was added in r16-6374-g2680785a6d14d7d78550edb8361f3b47eb5c4cb6,
except this is for the new code that was added with r16-6436-g92f2a86794ad88d773b102.
Basically the code only expects to work with scalar integer modes but forgot
to check that.

Pushed as obvious after bootstrap/test on x86_64-linux-gnu.

PR rtl-optimization/123491
gcc/ChangeLog:

* ifcvt.cc (noce_try_cond_zero_arith): Reject non-scalar
integer modes for the inner mode of the subreg.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
3 months agolibiberty/testsuite: make test-pexecute's -t option a little more useful
Jan Beulich [Fri, 9 Jan 2026 07:30:58 +0000 (08:30 +0100)] 
libiberty/testsuite: make test-pexecute's -t option a little more useful

Printing the program name twice doesn't really provide much value.

libiberty/

* testsuite/test-pexecute.c (main): Adjust a tracing fprintf().

3 months ago[PR target/121778] Improving rotation detection
Shreya Munnangi [Fri, 9 Jan 2026 04:29:38 +0000 (21:29 -0700)] 
[PR target/121778] Improving rotation detection

In this PR we're getting code like this out of the gimple optimizers:

>   _1 = a_4(D) << 63;
>   _2 = a_4(D) >> 1;
>   _3 = _2 ^ 1;
>   _5 = _1 | _3;

Note the XOR in that sequence.  It spoils our ability to recognize the
rotation.  As a result we get code like this for rv64gcb:

>         srli    a5,a0,1
>         xori    a5,a5,1
>         slli    a0,a0,63
>         or      a0,a5,a0

We can reassociate the operations when the XOR only flips bits resulting from
the right or left shift, but not both.  So after reassociation in gimple we
get:

>   _1 = a_2(D) r>> 1;
>   _3 = _1 ^ 1;

Which results in:

>         rori    a0,a0,1
>         xori    a0,a0,1

We don't bother with the transformation when the XOR is flipping a bit known to
be zero (ie, a high bit of the result of the right shift or a low bit on the
result of the left shift).  For those cases we already figure out that the XOR
is just an IOR and the right things already "just happen".

This triggered some code generation changes on the SH (not surprising because
this BZ was derived from an older SH BZ).  It doesn't seem to significantly
improve the SH code, though it does turn a cmp/pz + rotate through carry with a
rotate + xor with immediate.    That may be a latency win on the SH, I really
don't know.

Shreya did the bulk of the work here.  My contribution was the sister pattern
which has the XOR on the other operand and testcase development.

Bootstrapped and regression tested on x86 & riscv.  Also tested across the
various embedded targets without any regressions.

PR target/121778
gcc/
* match.pd: Add pattern to recognize rotate with one or more
bits flipped via xor.
* config/sh/sh.md (*rotcl); New variant which handles the output
we get after the match.pd change above.

gcc/testsuite/
* gcc.target/riscv/pr121778.c: New test.

Co-Authored-By: Jeff Law <jeffrey.law@oss.qualcomm.com>
3 months ago[RISC-V] Clamp long reservations to 7c
Jeff Law [Fri, 9 Jan 2026 04:14:18 +0000 (21:14 -0700)] 
[RISC-V] Clamp long reservations to 7c

So I've been noticing the cycle time for a native build/test on the
Pioneer and BPI rising over the last many months.  I've suspected a pain
point is likely genautomata due to long reservations in the DFAs.
Trying to describe a 30+ cycle bubble in the pipeline just isn't useful
and causes the DFA to blow up.

This is time to build insn-automata.cc using an optimized genautomata
using my skylake server cross compiling to riscv64. The baseline is what
we have today.  Then I clamped the reservations (but not the latency) to
7c.  7c is arbitrary, but known not to blow up the DFA.  I fixed the BPI
first, then the Andes 23 and so-on.

Baseline     52s
BPI          52s
Andes-23     45s
Andes-25     16s
Andes-45     16s
Generic      15s
Mips-8700    15s
Sifive-7     13s
Final        13s

That's a significant improvement, though I probably wouldn't go forward
with just that improvement.  It's less than a minute and skylake systems
aren't exactly new anymore...

Let's try that with an unoptimized genautomata.  I often build that way
when debugging.

Baseline    343s
Final        79s

So that's saving ~4m on my skylake server for a common build. Given I
use ccache, that 4m is often a significant amount of the build time.  So
this feels like a better motivating example.

But I'm really after bringing down bootstrap cycle times on the BPI and
Pioneer.  So let's see what the BPI does.  For an optimized genautomata
we get (not testing all the intermediate steps):

Baseline     310s
Final:       110s

Not bad.  And if we look at unoptimized genautomata:

Baseline:   2196s
Final:       553s

Now we can see why bootstrap times have crept up meaningfully. That's
~27 minutes out of a 9hr bootstrap time on the BPI (pure bootstrap, no
testing).  The effect is more pronounced on the Pioneer where the
improvement is 30+ minutes on a 4hr bootstrap time (each core is slower,
but there's 8x as many cores).

Tested on riscv{32,64}-elf and bootstrapped on the Pioneer (regression
testing in progress).  I'll wait for pre-commit CI to do its thing.

gcc/
* config/riscv/andes-23-series.md: Clamp reservations to 7c.
* config/riscv/andes-25-series.md: Likewise.
* config/riscv/andes-45-series.md: Likewise.
* config/riscv/generic.md: Likewise.
* config/riscv/mips-p8700.md: Likewise.
* config/riscv/sifive-7.md: Likewise.
* config/riscv/spacemit-x60.md: Likewise.

3 months ago[Bug gcov-profile/123019][V3] Fix Virtual SSA ICE
Kugan Vivekanandarajah [Fri, 9 Jan 2026 00:59:27 +0000 (11:59 +1100)] 
[Bug gcov-profile/123019][V3] Fix Virtual SSA ICE

The bug is a stale Virtual SSA VDEF on calls to functions that have
been marked const or pure.

pure_const pass analyzes function rocksdb::y::y() and determines it has no side
effects and marks it as const.

At this point, existing call sites to y::y() in other functions still have:
   # .MEM_12 = VDEF <.MEM_11>   rocksdb::y::y (&l, _9);
The VDEF indicates the call modifies memory but now that y::y() is const,
this VDEF is stale

Later passes  after feedback_fnsplit SSA verification fails. Added fixup.

gcc/ChangeLog:

2026-01-07  Kugan Vivekanandarajah  <kvivekananda@nvidia.com>

PR gcov-profile/123019
* auto-profile.cc (auto_profile): Call execute_fixup_cfg.

Signed-off-by: Kugan Vivekanandarajah <kvivekananda@nvidia.com>
3 months ago[PR ipa/123383][v2] ICE speculative call sequence has speculative_id 256 out of range
Kugan Vivekanandarajah [Fri, 9 Jan 2026 00:58:33 +0000 (11:58 +1100)] 
[PR ipa/123383][v2] ICE speculative call sequence has speculative_id 256 out of range

Fix by checking lto_stmt_uid in get_next_speculative_id.

gcc/ChangeLog:

2026-01-07  Kugan Vivekanandarajah  <kvivekananda@nvidia.com>

PR ipa/123383
* cgraph.cc (cgraph_edge::get_next_speculative_id): Check
lto_stmt_uid in get_next_speculative_id.

gcc/testsuite/ChangeLog:

2026-01-07  Kugan Vivekanandarajah  <kvivekananda@nvidia.com>

PR ipa/123383
* g++.dg/pr123383.C: New test.
co-authored-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>

Signed-off-by: Kugan Vivekanandarajah <kvivekananda@nvidia.com>
3 months agostmt: Fix up parse_input_constraint [PR111817]
Jakub Jelinek [Thu, 8 Jan 2026 22:05:58 +0000 (23:05 +0100)] 
stmt: Fix up parse_input_constraint [PR111817]

The following invalid testcase ICEs, because we:
1) for some strange reason ignore invalid punctuations in
   parse_output_constraint, which has just
        default:
          if (!ISALPHA (*p))
            break;
   compared to parse_input_constraint
      default:
        if (! ISALPHA (constraint[j]))
          {
            error ("invalid punctuation %qc in constraint", constraint[j]);
            return false;
          }
   Haven't touched this because I fear it could break real-world code
2) the checking whether = or + is first in the output constraint is
   a warning only:
      if (p != constraint)
        warning (0, "output constraint %qc for operand %d "
                 "is not at the beginning",
                 *p, operand_num);
3) parse_input_constraint parses also the corresponding output constraint
   if the input constraint has a number as the only variant, but
   even the comment removed in the following patch explains that it
   doesn't work correctly and skips the first character; now, usually
   that is not a big deal because if the first character of the output
   constraint is = or + as it should, then the checking doesn't do anything;
   but as 2) is just a warning, we accept it and then we fail to check it
4) far later on we parse the whole output constraint when input constraint
   refers to it and assert it succeeds, which it doesn't due to 1), 2) and 3)

The following patch fixes the 3) spot, when switching to the output
constraint, instead of setting j = 0; and break; (== continue;) so that it
first does j += CONSTRAINT_LEN (constraint[0], constraint+0) and thus
usually starts at second, sometimes third character of the output constraint
it uses goto before the loop which sets j = 0; and doesn't do the j += ...

2026-01-08  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/111817
* stmt.cc (parse_input_constraint): For matching construct, goto
before the loop without changing j instead of break.  Remove comment
about that problem.

* c-c++-common/pr111817.c: New test.

3 months agoRISC-V: -mrvv-max-lmul=conv-dynamic [PR122846].
Robin Dapp [Wed, 10 Dec 2025 18:02:11 +0000 (19:02 +0100)] 
RISC-V: -mrvv-max-lmul=conv-dynamic [PR122846].

As discussed in the patchwork sync this patch adds a dynamic LMUL mode
that sets the LMUL to the ratio of largest/smallest type size in a loop,
with the maximum being LMUL8.

This is supposed to imitate what other architectures implicitly do by
vec_unpack_hi/lo.  I have done cursory testing and obviously more
coverage would be preferred.

PR target/122846

gcc/ChangeLog:

* config/riscv/riscv-opts.h (enum rvv_max_lmul_enum): Add
RVV_CONV_DYNAMIC.
(TARGET_MAX_LMUL): Ditto.
* config/riscv/riscv-string.cc (use_vector_stringop_p): Use
LMUL1 for RVV_CONV_DYNAMIC.
(expand_rawmemchr): Ditto.
(expand_strcmp): Ditto.
(check_vectorise_memory_operation): Ditto.
* config/riscv/riscv-vector-costs.cc (get_smallest_mode):
New function.
(compute_lmul_from_conversion_ratio): Calculate LMUL from
largest/smallest type.
(costs::has_unexpected_spills_p): Split.
(costs::compute_live_ranges_and_lmul): Compute smallest type and
call new function.
(costs::cleanup_live_range_data): New function.
(costs::compute_conversion_dynamic_lmul): New function.
(costs::record_potential_unexpected_spills): Use new function.
(costs::better_main_loop_than_p): Allow appropriate LMUL.
* config/riscv/riscv-vector-costs.h: Declare.
* config/riscv/riscv.opt: New option
-mrvv-max-lmul=conv-dynamic.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/dyn-lmul-conv-1.c: New test.
* gcc.target/riscv/rvv/autovec/dyn-lmul-conv-2.c: New test.
* gcc.target/riscv/rvv/autovec/pr122846.c: New test.

3 months agoFix compile failure on systems not supporting gthreads.
Thomas Koenig [Thu, 8 Jan 2026 20:35:27 +0000 (21:35 +0100)] 
Fix compile failure on systems not supporting gthreads.

I just realized that it is possible to run a check by #undef - ing
 __GTHREADS_CXX0X in async.h.  Doing so promptly found another syntax
 error, which this version of the patch fixes.

PR libfortran/123446
PR libfortran/119136

libgfortran/ChangeLog:

* io/async.h: DEBUG_ASYNC needs gtreads support.
(LOCK_UNIT): Only lock when there is pthreads support and it is active.
Otherwise, just set unit->self to 1.
(UNLOCK_UNIT): Only unlock when there is pthreads support and it is active.
Otherwise, just set unit->self to 0.
(TRYLOCK_UNIT): Only try locking when thee is pthreads support and it is
active.  Otherwise, return unit->self.
(OWN_THREAD_ID): New macro.
* io/io.h: gfc_unit's self is an int when there is no gthreads support.
* io/unit.c (check_for_recursive): Check for equality of unit which
locked to OWN_THREAD_ID.

3 months ago__builtin_counted_by_ref should be extended to support pointers after the counted_by...
Qing Zhao [Thu, 8 Jan 2026 15:01:04 +0000 (15:01 +0000)] 
__builtin_counted_by_ref should be extended to support pointers after the counted_by attribute is extended to pointers inside structures.

gcc/c/ChangeLog:

* c-parser.cc (has_counted_by_object): Support pointers.
(get_counted_by_ref): Support pointers.
(c_parser_postfix_expression): Support pointers.

gcc/ChangeLog:

* doc/extend.texi: Update doc to support pointers inside structures.

gcc/testsuite/ChangeLog:

* gcc.dg/builtin-counted-by-ref.c: Update test case.
* gcc.dg/builtin-counted-by-ref-2.c: New test.
* gcc.dg/builtin-counted-by-ref-3.c: New test.

3 months agoIntroduce x86_64-linux-gnuabi32
Olivier Hainque [Thu, 8 Jan 2026 17:17:30 +0000 (14:17 -0300)] 
Introduce x86_64-linux-gnuabi32

Enable a 32-bit "native" toolchain on x86_64-*-linux-gnu and
x86_64-*-mingw32, i.e., one that targets -m32 by default, despite
supporting and potentially running in 64-bit mode, by appending abi32
to the triplet, and/or by setting the default ABI to 32 or m32.
Adjust libada and gnattools build machinery to support this
configuration in both bootstrap and non-bootstrap modes.

Co-Authored-By: Alexandre Oliva <oliva@adacore.com>
for  gcc/ChangeLog

* config.gcc [x86_64-*-*]: Match *abi32 target, default to m32
abi.  Accept 32 or m32 for --with-abi.

for  gcc/ada/ChangeLog

* gcc-interface/Make-lang.in (m32_target): Set.
(not_m32_target, native_target, native_gnattools1): Set.
(ADA_TOOLS_FLAGS_TO_PASS, gnattools): Handle x86_64 natives
defaulting to -m32 as cross for gnattools.
* gcc-interface/Makefile.in (target_cpu): Set to i686 for
x86_64 configurations defaulting to -m32.

for  gnattools/ChangeLog

* configure.ac (default_gnattools_target): Use gnattools-cross
when not bootstrapping x86_64 configurations defaulting to
-m32.
* configure: Rebuild.

3 months agodoc: Fix typo in documentation of -flang-info-module-cmi
Jonathan Wakely [Thu, 8 Jan 2026 10:52:59 +0000 (10:52 +0000)] 
doc: Fix typo in documentation of -flang-info-module-cmi

gcc/ChangeLog:

* doc/invoke.texi (C++ Dialect Options): Fix typo in
documentation of -flang-info-module-cmi.

3 months ago[PATCH v6 1/1] Add --with-multi-buildlist configure option
Aleksandar Rakic [Thu, 8 Jan 2026 15:56:23 +0000 (08:56 -0700)] 
[PATCH v6 1/1] Add --with-multi-buildlist configure option

This patch introduces a new configure-time option --with-multi-buildlist
to allow fine-grained control over which multilib variants are built.

The option accepts a path to a file containing a list of multilib
directories to be included in the build.  Each line in the file should
contain a single multilib directory name, matching those generated by
the compiler's --print-multi-lib output.

This mechanism is target-independent and enables users to reduce build
time and binary size by excluding unnecessary multilib variants.  It is
especially useful for embedded targets with constrained environments or
vendor-specific requirements.

The option is propagated to both host and target configuration stages,
and used in config-ml.in and gcc/Makefile.in to filter the multilib
list.

Documentation for this feature is added to gcc/doc/install.texi.

/ChangeLog

* config-ml.in: Use with_multi_buildlist to build multidirs.
Skip configuration for subdir returned by
--print-multi-directory.
* configure: Regenerate.
* configure.ac: Source target-specific configuration fragment
for GCC. Pass through with_multi_buildlist to host and target.

gcc/ChangeLog

* Makefile.in: Add with_multi_buildlist for multilib
configuration control. Pass an additional argument to
genmultilib indicating whether --with-multi-buildlist is set
(true or false). Use with_multi_buildlist to filter
multilib directories in fixinc_list.
* configure: Regenerate.
* configure.ac: Restrict the installed fixedincludes multilibs.
* configure.tgt: New file.
* doc/install.texi: Add --with-multi-buildlist configure option
for multilib filtering.
* genmultilib: Document the new eleventh argument indicating
whether --with-multi-buildlist configure option is set (true or
false). Update argument parsing to include this flag before
enable_multilib. Modify reuse rule validation:
- Keep the original error for reuse of nonexistent multilibs
when --with-multi-buildlist is not used.
- Suppress the error only when the new configure option is
active, allowing reuse rules to reference multilibs that are
intentionally excluded from the build.

Signed-off-by: Robert Suchanek <robert.suchanek@imgtec.com>
Signed-off-by: Chao-ying Fu <cfu@mips.com>
Signed-off-by: Aleksandar Rakic <aleksandar.rakic@htecgroup.com>
3 months ago[PATCH 2/2] ia64: Expand MAX_VECT_LEN to 16
Tomas Glozar [Thu, 8 Jan 2026 15:42:01 +0000 (08:42 -0700)] 
[PATCH 2/2] ia64: Expand MAX_VECT_LEN to 16

MAX_VECT_LEN is set to 8 on ia64, which is lower than on all other
targets, where it is 16 at minimum.

Some of the machine modes of ia64 are internally 16-byte wide,
causing stringop-overflow to be unhappy when checking a loop in
ia64_vectorize_vec_perm_const(). This causes bootstrap to fail.

Make stringop-overflow happy by raising the length to 16.

gcc/ChangeLog:

* config/ia64/ia64.cc (MAX_VECT_LEN): Set to 16 from 8.

3 months agoRe: [PATCH] match: Check else value compatibility [PR123268].
Robin Dapp [Thu, 8 Jan 2026 15:35:52 +0000 (08:35 -0700)] 
Re: [PATCH] match: Check else value compatibility [PR123268].

In PR123268 we transform x * { 0 or 1, 0 or 1, ... } into
x & { 0 or -1, 0 or -1, ...} which is a match.pd pattern.

We start out with
  vect_b_28.48_48 = .COND_LEN_MUL ({ -1, -1, -1, -1 }, a, b, { 0.0, 0.0, 0.0, 0.0 }, 4, 0);
and simplify to

_67 = .COND_LEN_AND ({ -1, -1, -1, -1 }, _60, { 4294967295, 0, 0, 0 }, { 0.0, 0.0, 0.0, 0.0 }, 4, 0);

where the operation type is int but the else value (that we just copied
over from the original op) is still float.

In order to catch that, this patch checks if the operation type and the
else value type are compatible while reassembling the conditional
operation.

PR target/123268
gcc/ChangeLog:

* gimple-match-exports.cc (convert_conditional_op): Check if
orig_op->type and type of else value match.

3 months agoMAINTAINERS: add myself to write after approval
Karl Meakin [Mon, 1 Dec 2025 14:31:56 +0000 (14:31 +0000)] 
MAINTAINERS: add myself to write after approval

ChangeLog:

* MAINTAINERS: Add myself to write after approval.

3 months agovect: Generalise vect_add_slp_permutation [PR122793]
Richard Sandiford [Fri, 12 Dec 2025 17:40:54 +0000 (17:40 +0000)] 
vect: Generalise vect_add_slp_permutation [PR122793]

The problem seems to be with a packing permutation:

    op0[4] op0[5] op0[6] op0[7]

and with the identity_offset parameter to vect_add_slp_permutation.

Both the repeating_p and !repeating_p paths correctly realise that this
permutation reduces to an identity.  But the !repeating_p path ends up with
first_node and second_node both set to the second VEC_PERM_EXPR operand
(since that path works elementwise, and since no elements are taken from
the first input).  Therefore, the call:

      vect_add_slp_permutation (vinfo, gsi, node, first_def,
second_def, mask_vec, mask[0]);

works regardless of whether vect_add_slp_permutation picks first_def or
second_def.  In that sense, the parameters to vect_add_slp_permutation are
already “canonical”.

The repeating_p path instead passes vector 2N as first_def and vector 2N+1
as second_def, with mask[0] indicating the position of the identity within
the concatenation of first_def and second_def.  However,
vect_add_slp_permutation doesn't expect this and instead ignores the
identity_offset parameter.

PR tree-optimization/122793
* tree-vect-slp.cc (vect_add_slp_permutation): Document the existing
identity_offset parameter.  Handle identities that take from the
second input rather than the first.

* gcc.dg/vect/vect-pr122793.c: New testcase.

Co-authored-by: Richard Biener <rguenther@suse.de>
3 months agotree-optimization/123310 - wrong aggregate copy VN
Richard Biener [Thu, 8 Jan 2026 12:08:57 +0000 (13:08 +0100)] 
tree-optimization/123310 - wrong aggregate copy VN

There's a typo in the check against unknown offset when processing
an aggregate copy during VN, leading to wrong lookup.

PR tree-optimization/123310
* tree-ssa-sccvn.cc (vn_reference_lookup_3): Properly
test against unknown offset.

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

3 months agoContainerfile for base forge actions
Pietro Monteiro [Thu, 8 Jan 2026 12:31:40 +0000 (07:31 -0500)] 
Containerfile for base forge actions

Build autoconf and automake and add autoregen.py from
https://sourceware.org/git/builder.git

Add forge action to build container images.

ChangeLog:

* .forgejo/workflows/build-containers.yaml: New file.

contrib/ChangeLog:

* ci-containers/README: New file.
* ci-containers/autoregen/Containerfile: New file.
* ci-containers/autoregen/autoregen.py: New file.
* ci-containers/build-image.sh: New file.

Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
3 months agotree-optimization/123298 - fix backedge detection for VN alias walk
Richard Biener [Thu, 8 Jan 2026 09:10:25 +0000 (10:10 +0100)] 
tree-optimization/123298 - fix backedge detection for VN alias walk

When trying to skip a virtual PHI during an alias walk we have to
direct a possible VN translation hook to not use valueization when
walking a backedge.  But this backedge detection was overly
optimistic, not honoring irreducible regions.  The following hookizes
the backedge detection so VN can properly flag edges that are back
with respect to its particular CFG traversal.

PR tree-optimization/123298
* tree-ssa-alias.h (get_continuation_for_phi): Take a gphi *,
add is_backedge hook argument.
(walk_non_aliased_vuses): Add is_backedge hook argument.
* tree-ssa-alias.cc (maybe_skip_until): Adjust.
(get_continuation_for_phi): Use new hook to classify an
edge into the PHI as backedge.
(walk_non_aliased_vuses): Adjust.
* gimple-lower-bitint.cc (bitint_dom_walker::before_dom_children):
Likewise.
* ipa-prop.cc (determine_known_aggregate_parts): Likewise.
* tree-ssa-scopedtables.cc (avail_exprs_stack::lookup_avail_expr):
Likewise.
* tree-ssa-pre.cc (translate_vuse_through_block): Likewise.
* tree-ssa-sccvn.cc (vn_bb_to_rpo): Make BB to RPO order
mapping accessible from new hook.
(do_rpo_vn_1): Likewise.
(vn_is_backedge): New hook to classify edge.
(vn_reference_lookup_pieces): Adjust.
(vn_reference_lookup): Likewise.

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

3 months agoMore verbose dumping on missed vector optabs
Richard Biener [Thu, 8 Jan 2026 08:32:19 +0000 (09:32 +0100)] 
More verbose dumping on missed vector optabs

The following changes 'no optab' to mention which tree code and
vector type we were looking for and adds 'shift' to the instances
of this message emitted from vectorizable_shift.

* tree-vect-stmts.cc (vectorizable_shift): Improve missing
optab or optab support messages.
(vectorizable_operation): Likewise.

3 months agos390: Remove volatile check from constraints A[QRST]
Stefan Schulze Frielinghaus [Thu, 8 Jan 2026 10:20:54 +0000 (11:20 +0100)] 
s390: Remove volatile check from constraints A[QRST]

Logical operations like *x &= -10 may be folded to a single
storage-and-immediate instruction NI which accesses only the least
significant byte of *x.

Similarly but still distinct operations like *x &= *y may be implemented
via storage-and-storage instruction NC which loads and stores one byte
after another of operands.

Since volatile objects must be accessed by a single load/store of the
entire object, those optimizations must be rejected in case of volatile
memory operands.  An exception to this are 16-byte load/stores which are
implemented by two operations (in case of non-atomic operands).

Previously, multi-letter constraints A[QRST] were intended to reject
volatile memory operands.  However, during LRA, if a memory constraint
is not satisfiable, as a last resort, LRA tries reloading the address.
This, of course, doesn't fix the issue and during checking we finally
bail out in case of a winning alternative.

Fixed by enforcing non-volatile memory operands via conditions of
instruction patterns which is done in s390_logical_operator_ok_p() for
all AND/IOR/XOR instructions by this patch.  By removing the volatile
check in constraints A[QRST] this fixes tests
gcc.dg/torture/float128-basic.c, float64x-basic.c,
fp-int-convert-float128-ieee.c, fp-int-convert-float64x.c,
fp-int-convert-long-double.c which started failing after r16-5947.

gcc/ChangeLog:

* config/s390/s390.cc (s390_logical_operator_ok_p): Test for
volatile memory.
(s390_mem_constraint): Remove volatile condition.
* config/s390/s390.md (*andc_split_<mode>): Test for volatile
memory.

gcc/testsuite/ChangeLog:

* gcc.target/s390/narrow-logical-op-1.c: New test.

3 months agotestsuite: Fix up pr123319.c [PR123319]
Jakub Jelinek [Thu, 8 Jan 2026 09:37:20 +0000 (10:37 +0100)] 
testsuite: Fix up pr123319.c [PR123319]

The testcase committed as gcc.dg/pr123319.c was x86_64 specific due to
immintrin.h include and use of _mm_avg_pu8 & __m64.  Furthermore, it
failed even on ia32 due to using SSE ISA stuff without -msse.

The following patch fixes that by moving that test to gcc.target/i386/,
adding -msse, adding comment with PR number, adding -msse to dg-options
and adding a new generic test written by Andrew Pinski as gcc.dg/pr123319.c.

Tested on x86_64-linux with
make check-gcc RUNTESTFLAGS='--target_board=unix\{-m32,-m32/-mno-sse,-m64\} dg.exp=pr123319.c i386.exp=pr123319.c'
both with current cc1 and cc1 from 2 days ago where everything ICEd.

2026-01-08  Jakub Jelinek  <jakub@redhat.com>
    Andrew Pinski  <andrew.pinski@oss.qualcomm.com>

PR tree-optimization/123319
* gcc.dg/pr123319.c: Replace test with target independent one.  Move
previous test to ...
* gcc.target/i386/pr123319.c: ... here.  Add comment with PR number,
add -msse to dg-options, move immintrin.h include right after stdint.h
include.

3 months agotestsuite: Add testcase for already fixed test [PR121675]
Jakub Jelinek [Thu, 8 Jan 2026 08:47:38 +0000 (09:47 +0100)] 
testsuite: Add testcase for already fixed test [PR121675]

This test was miscompiled due to stale REG_UNUSED vs. single_set,
fixed with r16-6062-ge1b8d097297.

2026-01-08  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/121675
* gcc.dg/pr121675.c: New test.

3 months agolibstdc++: Use tree-dump-gimple in variant constant init tests.
Tomasz Kamiński [Wed, 7 Jan 2026 16:24:55 +0000 (17:24 +0100)] 
libstdc++: Use tree-dump-gimple in variant constant init tests.

Use of scan-assembler-dem for matching against debug symbols, turned out to not
be portable, as they representation in assembly output differs between platforms:
arm use 60 columns limit, emitting multiple rows, and some platforms may encode
them using base64.

We use tree-dump-gimple instead, that outputs a constructor name portably,
allowing us to simply match for invocation of constructor for given type, as each
variable has different type.

To use scan-tree-dump(-not) we load scantree.exp file and it's dependency
scandump.exp from gcc/testsuite/lib.

libstdc++-v3/ChangeLog:

* testsuite/20_util/variant/constinit.cc: Use scan-tree-dump
for matching of constructor.
* testsuite/20_util/variant/constinit_compat.cc: Likewise.
* testsuite/lib/libstdc++.exp: Load scantree.exp and scandump.exp.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 months agomiddle-end/123107 - avoid invalid vector folding
Richard Biener [Wed, 7 Jan 2026 12:18:42 +0000 (13:18 +0100)] 
middle-end/123107 - avoid invalid vector folding

We fold (v >> CST) == { 0, 0.. } into v < { 0, 0.. } but fail to
validate that's valid for the target.  The following adds such check,
making sure to apply after IPA (due to offloading) and only when
the original form wasn't valid for the target (like before vector
lowering) or when the new form is.  In particular in this case
we have an equality compare resulting in a non-vector which we
can handle, but a similar LT/GT is never handled.

PR middle-end/123107
* fold-const.cc (fold_binary_loc): Guard (v >> CST) == { 0, 0.. }
to v < { 0, 0.. } folding.

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

3 months agoFortran: Fix namelist with use association and renaming
Steve Kargl [Thu, 8 Jan 2026 05:09:50 +0000 (21:09 -0800)] 
Fortran: Fix namelist with use association and renaming

The previous commit for this PR fails on FreeBSD. The fix here
is the original provided by the author. The test case remains
unchanged.

PR fortran/123321

gcc/fortran/ChangeLog:

* trans-io.cc (transfer_namelist_element):  Adjust the
conditions determining when to use the local name or
the var name to build the object name.

3 months agoFortran: Fix namelist with use association and renaming
Steve Kargl [Wed, 7 Jan 2026 23:14:23 +0000 (15:14 -0800)] 
Fortran: Fix namelist with use association and renaming

PR fortran/123012

gcc/fortran/ChangeLog:

* trans-io.cc (transfer_namelist_element): Adjust the
conditions determining when to use the local name or
the var name to build the object name.

gcc/testsuite/ChangeLog:

* gfortran.dg/namelist_99.f90: New test.

3 months agovect/ifcvt: Don't factor out VEC_PERM_EXPR with constant masks [PR123382]
Andrew Pinski [Sat, 3 Jan 2026 19:32:02 +0000 (11:32 -0800)] 
vect/ifcvt: Don't factor out VEC_PERM_EXPR with constant masks [PR123382]

VEC_PERM_EXPR is another special case expression where constants can mean
something different from non-constant.
So if we have:
```
  if (_5 != 0) goto <bb 4>; else goto <bb 5>;
  <bb 4>
  t_15 = VEC_PERM_EXPR <t_12, t_12, { 3, 3, 2, 3 }>;
  goto <bb 6>; [100.00%]
  <bb 5>
  t_14 = VEC_PERM_EXPR <t_12, t_12, { 0, 0, 2, 3 }>;
  <bb 6>
  # t_7 = PHI <t_15(4), t_14(5)>
```
We can't factor out the VEC_PERM_EXPR here since the type
of the vector constant can be different from the type of
the other operands. This is unlike the operand is not a
constant, the mask has to be an integral type which is
similar to the other operands.

Changes since v1:
 * v2: Expand comment on why we should reject this.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/123382

gcc/ChangeLog:

* tree-if-conv.cc: Reject VEC_PERM_EXPR for factoring
if it is the mask and they are constant.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr123382-1.c: New test.
* gcc.dg/torture/pr123382-2.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
3 months agocse: Small boolization of follow_jumps argument to cse_find_path
Andrew Pinski [Mon, 22 Dec 2025 02:08:51 +0000 (18:08 -0800)] 
cse: Small boolization of follow_jumps argument to cse_find_path

Just a small patch to change follow_jumps to bool since it is used as a bool.

gcc/ChangeLog:

* cse.cc (cse_find_path): Change follow_jumps to bool.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
3 months agoDaily bump.
GCC Administrator [Thu, 8 Jan 2026 00:16:32 +0000 (00:16 +0000)] 
Daily bump.

3 months agoFortran: [PDT]Fix ICE in tree check and memory leaks[PR90218, PR123071]
Paul Thomas [Wed, 7 Jan 2026 16:14:12 +0000 (16:14 +0000)] 
Fortran: [PDT]Fix ICE in tree check and memory leaks[PR90218, PR123071]

2026-01-07  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/123071
* resolve.cc (resolve_typebound_function): If a generic
typebound procedure is marked as overridable and all the
specific procedures are non-overridable, it is safe to resolve
the compcall.

PR fortran/90218
* trans-array.cc (gfc_trans_array_constructor_value): PDT
structure constructor elements must be finalized.
(trans_array_constructor): Set 'finalize_required' for PDT
constructors.
* trans-decl.cc (gfc_get_symbol_decl): PDT initialization is
required in contained namespaces as long as the parent is not
a module.
(gfc_init_default_pdt): Delete the stmtblock_t argument. Assign
a variable 'value' expression using gfc_trans_assignment.
Simplifiy the logic around the call to gfc_init_default_dt. In
both cases return a tree expression or null tree.
(gfc_trans_deferred_vars): Only call gfc_allocate_pdt_comp if
gfc_init_default_pdt returns null tree.
* trans-expr.cc (gfc_trans_alloc_subarray_assign): Add a static
stmtblock_t pointer 'final_block'. Free 'dest' data pointer and
add to final_block.
(gfc_conv_structure): Set 'final_block' to the se's finalblock.
(gfc_trans_assignment_1): Do not deallocate PDT array ctrs.
trans-stmt.cc (gfc_trans_allocate): Also deallocate PDT expr3
allocatable components.
(gfc_trans_deallocate): Add PDT deallocation to se.pre instead
of block.
* trans-stmt.cc (gfc_trans_allocate): Free the allocatable
components of a PDT expr3.
(gfc_trans_deallocate): Add 'tmp' to se.pre rather than block.

gcc/testsuite/
PR fortran/90218
* gfortran.dg/pdt_79.f03: Used uninitialized warning and change
tree scan for 'mapped_tensor.j' to 'Pdttensor_t_4.2.j'.
* gfortran.dg/pdt_80.f03: New test.

3 months ago[PATCH 1/2] ia64: Fix zero_call_used_regs for PRs [PR121535]
Tomas Glozar [Wed, 7 Jan 2026 16:02:15 +0000 (09:02 -0700)] 
[PATCH 1/2] ia64: Fix zero_call_used_regs for PRs [PR121535]

ia64 uses default_zero_call_used_regs(), which uses emit_move_insn()
to zero out registers. ia64 predicate registers use BImode, which is not
supported by emit_move_insn().

Implement ia64_zero_call_used_regs() to zero PRs by manually emitting
a CCImode move. default_zero_call_used_regs() is then called to handle
the remaining registers.

PR target/121535

gcc/ChangeLog:

* config/ia64/ia64.cc (TARGET_ZERO_CALL_USED_REGS): Override
function with target-specific one.
(struct gcc_target): Move to end of file.
(ia64_zero_call_used_regs): Add target-specific function.

gcc/testsuite/ChangeLog:

* gcc.target/ia64/pr121535.c: New test.

Signed-off-by: Tomas Glozar <tglozar@gmail.com>
3 months ago[PATCH] ia64: properly include libunwind support during configuration
Xinhui Yang [Wed, 7 Jan 2026 15:59:01 +0000 (08:59 -0700)] 
[PATCH] ia64: properly include libunwind support during configuration

By using the test `with_system_libunwind', libgcc can use either
in-house implementation or reference external libunwind symbols.
However, this breaks the static libgcc.a library, as in t-linux it
references unwind-compat.c, which turns some _Unwind_* symbols into
references of the corresponding symbols in libunwind, but libunwind does
not exist in some conditions (e.g. bootstrapping a toolchain). The
linker complains about `missing version node for symbol', since it can
not find the symbol it is referring to.

The unwind-compat.c module should only exist, if system libunwind is
being used. Also GCC itself should add -lunwind only if this condition
is met, too.

Implementing better control for whether to embed unwind implementation
into libgcc to fix this issue.

gcc/
* config.gcc: limit -lunwind usage by testing if the system
libunwind is being used.

libgcc/
* config.host (ia64): include unwind-compat only if the system
libunwind is being used.

* config/ia64/t-linux-libunwind: include libgcc symver definition
for libgcc symbols, since it bears the same role as t-linux
(except libunwind); Include fde-glibc.c since the unwind
implementation requires _Unwind_FindTableEntry in this file.

* config/ia64/unwind-ia64.c: protect _Unwind_FindTableEntry inside
inihbit_libc ifndefs to allow it to build with newlib or
without proper headers.

3 months agoarm: add test for recent combine fix [PR121773]
Richard Earnshaw [Wed, 7 Jan 2026 15:46:40 +0000 (15:46 +0000)] 
arm: add test for recent combine fix [PR121773]

This adds and arm-specific executable test for the recent fix for PR
rtl-optimization/121773 based on the failing code in the original PR.

gcc/testsuite/ChangeLog:

PR rtl-optimization/121773
* gcc.target/arm/pr121773.c: New test.

3 months ago[committed] Use compact form to update stack pointer in libgcc
Vladimir Vishniakov [Wed, 7 Jan 2026 15:48:11 +0000 (08:48 -0700)] 
[committed] Use compact form to update stack pointer in libgcc

libgcc/
* config/v850/lib1funcs.S (__return_r26_r31): Use compact
add form to adjust stack pointer.
(__save_r27_r31): Likewise.
(__save_r29_r31): Likewise.
(__save_r31): Likewise.
(__return_r27_r31): Likewise.
(__return_r28_r31): Likewise.
(__return_r29_r31): Likewise.
(__return_r31): Likewise.
(__return_r2_r31): Likewise.

3 months agoLoongArch: guard SImode simple shift and arithmetic expansions with can_create_pseudo...
Xi Ruoyao [Wed, 31 Dec 2025 01:52:35 +0000 (09:52 +0800)] 
LoongArch: guard SImode simple shift and arithmetic expansions with can_create_pseudo_p [PR 123320]

As we have hardware instructions for those operations, developers will
reasonably assume they can emit them even after reload.  But on LA64 we
are expanding them using pseudos to reduce unneeded sign extensions,
breaking such an expectation and causing ICE like PR 123320.

Only create the pseudo when can_create_pseudo_p () to fix such cases.

PR target/123320

gcc

* config/loongarch/loongarch.md (<optab><mode>3): Only expand
using psuedos when can_create_pseudo_p ().
(addsi3): Likewise.

gcc/testsuite

* gcc.target/loongarch/la64/pr123320.c: New test.