Nathaniel Shead [Fri, 13 Mar 2026 06:31:52 +0000 (17:31 +1100)]
libcpp: Handle macro locations in linemap_location_from_module_p [PR124466]
The testcase crashed because in warn-spec-5_b.C we were writing
diagnostic classifications for pops but not for the things they were
ignoring. We should have been writing neither, as they all came from an
imported location, but linemap_location_from_module_p was returning
false for locations that originated from macros in a module.
PR c++/124466
libcpp/ChangeLog:
* line-map.cc (linemap_location_from_module_p): Resolve loc in
case it's a macro location.
gcc/testsuite/ChangeLog:
* g++.dg/modules/warn-spec-5_a.C: New test.
* g++.dg/modules/warn-spec-5_b.C: New test.
* g++.dg/modules/warn-spec-5_c.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
Jason Merrill [Thu, 5 Mar 2026 22:54:30 +0000 (17:54 -0500)]
c++: contracts and -fimplicit-constexpr
Several of the contracts tests were failing with -fimplicit-constexpr. Some
of this was just needing to handle some additional tree codes, but there
were more significant issues with the handling of failed contracts in
speculative (i.e. non-manifestly-constant-evaluated) constant evaluation,
leading to additional errors and/or emitting a constant value despite its
evaluation involving a failed contract.
I've addressed this by making non-MCE evaluation silently fail (and so fall
back to run-time evaluation) if we encountered a contract that is not known
to be satisfied. We could consider an optional warning if we encounter a
predicate that evaluates to false, but that seems like a follow-on
enhancement.
The gdc.test/runnable/dbitfieldsdm.d test FAILs on SPARC:
FAIL: gdc.test/runnable/dbitfieldsdm.d execution test
As described in the PR, it dies with SIGBUS due to an unaligned access,
which doesn't work on a strict-alignment CPU.
However, the test has a comment
Note that this test is for win32 only
and should already be disabled on various systems:
DISABLED: win32mscoff win64 linux freebsd osx
The DISABLED annotation isn't handled by the gdc DejaGnu framework and
there's no support for the usual dg-* annotations, so this patch removes
the test.
Tested on sparc-sun-solaris2.11 and i386-pc-solaris2.11.
[PR124041, PR124439, LRA]: Check hard_regno_mode_ok for hard reg subreg to satisfy reg constraint
Patch for PR124041 resulted in wrong code generation and in new
PR124439 as the patch prevented equivalence substitution when
equivalence initialization insn was removed.
This patch implements another fix for PR124041 and this fixes
PR124439.
gcc/ChangeLog:
PR rtl-optimization/124041
PR rtl-optimization/124439
* lra-constraints.cc (process_alt_operands): Check hard reg subreg
mode by hard_regno_mode_ok.
(curr_insn_transform): Always subsitute equivalence for hard reg
subreg.
Tomasz Kamiński [Tue, 10 Mar 2026 14:57:35 +0000 (15:57 +0100)]
libstdc++: Properly handle forwarding references in __mdspan::__index_type_cast.
The _OIndexType template parameter will maybe deduced to reference, when
invoked from constructor and operator[]/at (after r16-7645-g66e60479e97640)
accepting array or span. We need to use forward for class-type and
remove_cvref_t for is_integral checks.
This resolves LWG4020: extents::index-cast weirdness.
libstdc++-v3/ChangeLog:
* include/std/mdspan (__mdspan::__index_type_cast): Handle
forwarding referene and use forward for class types.
* testsuite/23_containers/mdspan/int_like.h (ConstLValueInt)
(CustomIndexKind::ConstLValue): Define.
(CustomIndexType): Handle CustomIndexKind::ConstLValue.
* testsuite/23_containers/mdspan/at.cc: Test with ConstLValueInt.
* testsuite/23_containers/mdspan/extents/custom_integer.cc: Likewise.
* testsuite/23_containers/mdspan/mdspan.cc: Likewise.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
Richard Biener [Wed, 18 Mar 2026 09:15:00 +0000 (10:15 +0100)]
tree-optimization/124555 - guard abs patterns for vector support
The following adds missing vector support checks to abs producing
match.pd patterns. The g++.dg/absvect.C shows that we previously
then lowered this to non-vector unless you add -msse4 on x86_64
at least.
PR tree-optimization/124555
* match.pd ((A - B) >=/> 0 ? (A - B) : (B - A) -> abs (A - B)):
Guard the vector case with target_supports_op_p checks.
((A - B) <=/< 0 ? (A - B) : (B - A) -> -abs (A - B)): Likewise.
((type)A >=/> 0 ? A : -A -> abs (A)): Likewise.
((type)A <=/< 0 ? A : -A -> -abs (A)): Likewise.
* gcc.dg/torture/pr124555.c: New testcase.
* g++.dg/absvect.C: Restrict dump scan to x86-64 and force
-msse4 there.
Dhruv Chawla [Mon, 12 Jan 2026 12:07:03 +0000 (04:07 -0800)]
AutoFDO: Add --print-autofdo-gcov-version
This option prints the current version of GCOV that is being used by the
AutoFDO infrastructure. This avoids the need to bump the number across
multiple files in the build system for future increments to it.
* Makefile.in (all.fda): Add `--print-autofdo-gcov-version` to
profile_merger invocation.
* auto-profile.cc (AUTO_PROFILE_VERSION): Move from here ...
* auto-profile.h (AUTO_PROFILE_VERSION): ... to here.
* common.opt: Add -print-autofdo-gcov-version and
--print-autofdo-gcov-version.
* doc/invoke.texi: Document the options.
* gcc.cc: Add include for auto-profile.h.
(driver_handle_option): Add OPT_print_autofdo_gcov_version.
(driver::maybe_print_and_exit): Handle the option.
gcc/c/ChangeLog:
* Make-lang.in (cc1.fda): Add `--print-autofdo-gcov-version` to
profile_merger invocation.
(create_fdas_for_cc1): Add `--print-autofdo-gcov-version` to
create_gcov invocations.
gcc/cp/ChangeLog:
* Make-lang.in (cc1plus.fda): Add `--print-autofdo-gcov-version` to
profile_merger invocation.
(create_fdas_for_cc1plus): Add `--print-autofdo-gcov-version` to
create_gcov invocations.
gcc/lto/ChangeLog:
* Make-lang.in (lto1.fda): Add `--print-autofdo-gcov-version` to
profile_merger invocation.
(create_fdas_for_lto1): Add `--print-autofdo-gcov-version` to
create_gcov invocations.
gcc/testsuite/ChangeLog:
* lib/profopt.exp: Invoke $GCC_UNDER_TEST with
`--print-autofdo-gcov-version` before running create_gcov to get
the GCOV version.
Arsen Arsenović [Fri, 13 Feb 2026 11:19:52 +0000 (11:19 +0000)]
libgomp/gcn: cache kernel argument allocations
On AMD GCN, for each kernel that we execute on the GPUs, the vast
majority of the time preparing the kernel for execution is spent in
memory allocation and deallocation for the kernel arguments. Out of the
total execution time of run_kernel, which is the GCN plugin function
that actually performs launching a kernel, ~83.5% of execution time is
spent in these (de)allocation routines.
Obviously, then, these calls should be elliminated. However, it is not
possible to avoid needing to allocate kernel arguments.
To this end, this patch implements a cache of kernel argument
allocations.
We expect this cache to be of size T where T is the maximum number of
kernels being launched in parallel. This should be a fairly small
number, as there isn't much benefit to (or, to my awareness, real world
code that) executing very many kernels in parallel.
In my experiments (with BabelStream, though this should by no means be
improvements specific to it as run_kernel is used for all kernels and
branches very little), this was able to cut the non-kernel-wait runtime
of run_kernel by a factor of 5.5x.
libgomp/ChangeLog:
* plugin/plugin-gcn.c (struct kernel_dispatch): Add a field to
hold a pointer to the allocation cache node this dispatch is
holding for kernel arguments, replacing kernarg_address.
(print_kernel_dispatch): Print the allocation pointer from that
node as kernargs address.
(struct agent_info): Add in an allocation cache field.
(alloc_kernargs_on_agent): New function. Pulls kernel arguments
from the cache, or, if no appropriate node is found, allocates
new ones.
(create_kernel_dispatch): Use alloc_kernargs_on_agent to
allocate kernargs.
(release_kernel_dispatch): Use release_alloc_cache_node to
release kernargs.
(run_kernel): Update usages of kernarg_address to use the kernel
arguments cache node.
(GOMP_OFFLOAD_fini_device): Clean up kernargs cache.
(GOMP_OFFLOAD_init_device): Initialize kernargs cache.
* alloc_cache.h: New file.
* testsuite/libgomp.c/alloc_cache-1.c: New test.
Jakub Jelinek [Wed, 18 Mar 2026 07:59:26 +0000 (08:59 +0100)]
testsuite: Fix up a few tests for i686-linux
Some of these tests need -Wno-psabi to pass on ia32, forwprop-43.c
uses the vect* effective targets which rely on vect.exp added options
but doesn't provide those (added -msse2 for ia32).
And lastly, part-vect-absnegbf.c is a really weird test, it needs
at least -msse2 to pass on ia32 obviously (otherwise it is an error
to even use __bf16 or _Float16), but doesn't use -mavx512bf16 but
has avx512bf16 runtime check. No idea what was meant, perhaps we
need 2 copies of the test, one with plain -msse2 and just requiring
sse2 at runtime and another wiht -mavx512bf16 requiring that? Just
added -msse2 for now.
2026-03-18 Jakub Jelinek <jakub@redhat.com>
* gcc.dg/tree-ssa/forwprop-42.c: Add -Wno-psabi to dg-options.
* gcc.dg/tree-ssa/forwprop-43.c: Likewise. For ia32 add -msse2 as
dg-additional-options.
* gcc.dg/torture/pr65270-3.c: Add -Wno-psabi to dg-options.
* gcc.target/i386/part-vect-absnegbf.c: Add -msse2 to dg-options.
Jakub Jelinek [Wed, 18 Mar 2026 07:41:13 +0000 (08:41 +0100)]
onfigure: Partial fix for the {gas,gnu_ld}{,_flag} breakage [PR124547]
Here is a partial fix for the PR124547 breakages.
Setting {gas,gnu_ld}_flag to no when user didn't specify any of
--with{,out}-gnu-{as,ld} nor --with-gnu-{as,ld}={yes,no} seems wrong
when we want to later override it based on
# Check if we are using GNU ld if not already set.
if test -z "$gnu_ld_flag"; then
if $gcc_cv_ld --version 2>/dev/null | grep GNU > /dev/null; then
gnu_ld_flag=yes
else
gnu_ld_flag=no
fi
fi
or
# Check if we are using GNU as if not already set.
if test -z "$gas_flag"; then
if $gcc_cv_as --version 2>/dev/null | grep GNU > /dev/null; then
gas_flag=yes
else
gas_flag=no
fi
fi
So, this patch unsets it if not explicitly specified so that the later
overriding works.
On x86_64-linux it restores the auto-host.h and Makefile differences:
-LD_VERSION_SCRIPT_OPTION =
-LD_SONAME_OPTION =
+LD_VERSION_SCRIPT_OPTION = --version-script
+LD_SONAME_OPTION = -soname
and
-#define HAVE_AS_IX86_GOT32X 0
+#define HAVE_AS_IX86_GOT32X 1
#endif
-#define HAVE_AS_IX86_TLSLDM 0
+#define HAVE_AS_IX86_TLSLDM 1
-#define HAVE_AS_IX86_TLS_GET_ADDR_GOT 0
+#define HAVE_AS_IX86_TLS_GET_ADDR_GOT 1
-/* #undef HAVE_LD_DEMANGLE */
+#define HAVE_LD_DEMANGLE 1
I agree with Andreas in the PR that after including config.gcc configure
should be using gas and gnu_ld vars rather than gas_flag and gnu_ld_flag,
but this patch doesn't implement that (yet). I think to do that,
it would need to move the
AS_VAR_SET_IF(gcc_cv_as,, [
AC_MSG_CHECKING(Solaris assembler)
# Check if we are using GNU as if not already set.
and
AC_MSG_CHECKING(Solaris linker)
# Identify the linker which will work hand-in-glove with the newly
# Check if we are using GNU ld if not already set.
hunks in configure.ac from where they are to before config.gcc inclusion,
and sed s/\(gnu_ld\|gas\)_flag/\1/g after the config.gcc inclusion.
I can prepare/test the patch tomorrow, but IMHO this patch is a good start.
2026-03-18 Jakub Jelinek <jakub@redhat.com>
PR bootstrap/124547
* configure.ac (--with-gnu-ld): Set gnu_ld_flag= instead of
gnu_ld_flag=no if not explicitly specified.
(--with-gnu-as): Similarly for gas_flag.
(DEFAULT_ASSEMBLER): Use wording without GNU as whenever gas_flag
is not yes rather than when it is no.
* configure: Regenerate.
Richard Biener [Tue, 17 Mar 2026 14:27:38 +0000 (15:27 +0100)]
Fix leak of edge vector in IPA CP
The following makes gather_edges_for_value return an auto_vec,
simplifying the single caller decide_about_value and fixing the
leak of the callers vector upon early return.
* ipa-cp.cc (gather_edges_for_value): Return an auto_vec.
(decide_about_value): Simplify, fixing leak of callers.
Prachi Godbole [Wed, 18 Mar 2026 05:24:00 +0000 (22:24 -0700)]
[PATCH] ipa-reorder-for-locality - Fix PR123749 avoid creating new partition if no more nodes left to process
This patch fixes PR123749 which caused by an empty partition created in WPA
partitioning pass as a result of -fipa-reorder-for-locality creating one.
This also fixes an indentation issue.
Bootstrapped and regtested on aarch64-none-linux-gnu. OK for mainline?
Jakub Jelinek [Wed, 18 Mar 2026 05:36:15 +0000 (06:36 +0100)]
c++: Fix up reflect/init11.C on cdtor_returns_this targets [PR124474]
On arm*-linux-gnueabi init11.C emits extra diagnostics which the testcase
doesn't expect.
E.g. it emits
init11.C: At global scope:
init11.C:19:13: error: function of consteval-only type must be declared ‘consteval’
19 | constexpr C() : i{} {} // { dg-error "function of consteval-only type must be declared .consteval." }
| ^
init11.C: In constructor ‘constexpr C::C()’:
init11.C:19:24: error: consteval-only expressions are only allowed in a constant-evaluated context
19 | constexpr C() : i{} {} // { dg-error "function of consteval-only type must be declared .consteval." }
| ^
while on most other targets only the first error from these and not
the second is emitted.
This is because of targetm.cxx.cdtor_returns_this (), the error is emitted
on the constructor declaration and then again during
check_out_of_consteval_use on its body, when walking RETURN_EXPR (which
normally isn't there).
The following patch arranges diagnostics parity.
Though, as I wrote in the PR, I wonder if it makes sense to report
any errors on bodies of functions for which we've already diagnosed
function of consteval-only type must be declared ‘consteval’.
Especially for methods of consteval-only types, any use of this keyword
will result in an extra error (sure, only the first occurrence in a
function). But even if a function has only some other consteval-only
argument and that argument is used somewhere in the body. Though, wonder
if it is worth trying to improve that now when we don't know if
consteval-only will not be removed completely or changed significantly.
2026-03-18 Jakub Jelinek <jakub@redhat.com>
PR c++/124474
* reflect.cc (check_out_of_consteval_use_r): Don't walk subtrees
of RETURN_EXPR on cdtor_returns_this targets in cdtors.
Jonathan Wakely [Tue, 17 Mar 2026 15:37:24 +0000 (15:37 +0000)]
libstdc++: Fix some non-uglified names
Jakub wrote a plugin which identified some non-reserved names being used
in our headers. The "count" one is actually a reserved name (there's
std::set::count and std::count and std::bitset::count) but we might as
well uglify it when used as a function parameter name. I think the "ext"
ones must have happened when moving function definitions from fs_path.cc
to fs_path.h and I forgot to change them.
The __cond::wait and __cond::wait_recursive member functions are using
non-reserved names, so that should be changed too, but this patch
doesn't fix that. I don't think we use the __gnu_cxx::__cond type in any
headers, so maybe that should just be moved into libsupc++/guard.cc or a
new header which is not installed and only used while building the
library.
Jonathan Wakely [Fri, 13 Mar 2026 17:11:04 +0000 (17:11 +0000)]
libstdc++: Optimize __uninitialized_copy_a for std::deque iterators [PR124463]
I reimplemented uninitialized_copy and uninitialized_move in r15-4473-g3abe751ea86e34 so that they no longer delegate to std::copy,
but that meant that they were no longer optimized for std::deque
iterators, leading to performance regressions for operations on a
std::deque with trivial element types. This adds new overloads of
__uninitialized_copy_a and __uninitialized_move_a to handle std::deque
iterators, restoring the lost performance.
There are also overloads of std::fill for deque iterators which are no
longer used for std::uninitialized_fill. This does not add replacements
for those, so there will still be lost performance for std::deque
operations that depend on std::uninitialized_fill. Similarly, inserting
or assigning from istreambuf_iterator into a std::deque no longer uses
the std::copy overloads for those types, and that isn't fixed by this
patch either.
libstdc++-v3/ChangeLog:
PR libstdc++/124463
* include/bits/deque.tcc (__uninitialized_copy_a): Define
overloads for input and output iterators being std::deque
iterators, and for only the output iterator being a std::deque
iterator.
(__uninitialized_move_a): Overload for input and output
iterators being std::deque iterators.
* include/bits/stl_uninitialized.h (__uninitialized_copy_a)
(__uninitialized_move_a): Declare overloads for std::deque
iterators.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Marek Polacek [Tue, 17 Mar 2026 16:34:28 +0000 (12:34 -0400)]
c++/reflection: add var tmpl to inform_tree_category [PR124493]
Modifying the recently added crash22.C test to use a variable template
shows that inform_tree_category doesn't say reflection of what we
actually got. With this patch we say:
• but 'Y<T>' is a variable template
crash23.C:6:13:
6 | constexpr T Y{};
| ^
I couldn't figure out a test for alias templates so I'm not adding
that now.
Alice Carlotti [Thu, 12 Mar 2026 17:45:37 +0000 (17:45 +0000)]
aarch64: Disallow movprfx before revd
An architectural relaxation in 2024 (listed in the "Known issues in
Issue K.a" of the Arm ARM) removed support for revd to be prefixed by a
movprfx instruction. This patch removes this (now invalid) codegen.
The patch also makes identical changes to each revd* testsuite file.
Interestingly, this actually improves codegen for one of the three
functions.
The redundant-store tracking introduced in ec5349c37af replaced a
safe bitmap_bit_in_range_p check (which bailed on any overlap) with
bitmap_all_bits_in_range_p (which only removed fully redundant stores).
This broke "last writer wins" semantics for partially overlapping
stores: when an earlier store's BFI was applied after the base store's
value, it overwrote bytes that should have belonged to the later store.
Restore the original overlap check from 1d8de1e93ea: bail out of the
optimization when any bit in a store's byte range is already claimed
by a later store in program order. Remove the now-unnecessary
redundant-store tracking (redundant_stores, store_ind_to_remove).
gcc/ChangeLog:
PR rtl-optimization/124476
* avoid-store-forwarding.cc
(store_forwarding_analyzer::process_store_forwarding): Replace
bitmap_all_bits_in_range_p with bitmap_any_bit_in_range_p and
return false on partial overlap. Remove redundant-store vectors
and their associated removal, dump, and deletion logic.
gcc/testsuite/ChangeLog:
PR rtl-optimization/124476
* gcc.dg/pr124476.c: New test.
Marek Polacek [Mon, 16 Mar 2026 01:18:17 +0000 (21:18 -0400)]
c++/reflection: add test for ICE with ^^decltype [PR124494]
This test with invalid ^^decltype crashes. finish_decltype_type
got a USING_DECL because they sometimes aren't stripped when
using -freflection. We should give an error like we do for TYPE_DECL,
otherwise finish_decltype_type returns NULL_TREE and eventually we
crash in cp_parser_qualifying_entity after calling cp_parser_decltype.
Fixed by r16-8132 which moved the cp_preserve_using_decl overriding.
Marek Polacek [Sun, 15 Mar 2026 21:05:57 +0000 (17:05 -0400)]
c++/reflection: bogus error with targ and using-decl [PR124472]
Here we emit a bogus "type/value mismatch" error because
convert_template_argument gets a USING_DECL instead of an expected
TYPE_DECL. When we are parsing a reflect-expression we set
cp_preserve_using_decl not to strip USING_DECLs. The flag should
probably go, subject to 124169, but meanwhile we can at least move
overriding cp_preserve_using_decl below, just before the call to
cp_parser_lookup_name_simple, where it actually matters. The wrong
error comes from _reflection_name -> _nested_name_specifier_opt
which happens before cp_parser_identifier.
PR c++/124472
gcc/cp/ChangeLog:
* parser.cc (cp_parser_reflection_name): Move the
cp_preserve_using_decl overriding below, before
cp_parser_lookup_name_simple.
Marek Polacek [Fri, 13 Mar 2026 20:25:00 +0000 (16:25 -0400)]
c++/reflection: ICE with invalid splice-spec-spec [PR124493]
This is a crash on invalid [:X:]<args> where [:X:] doesn't
designate a template. Like in cp_parser_template_id, we should
check that we have an appropriate template before calling
finish_template_type on it.
PR c++/124493
gcc/cp/ChangeLog:
* pt.cc (tsubst) <case TEMPLATE_ID_EXPR>: Check that templ is
either DECL_TYPE_TEMPLATE_P or DECL_TEMPLATE_TEMPLATE_PARM_P.
gcc/testsuite/ChangeLog:
* g++.dg/reflect/crash19.C: New test.
* g++.dg/reflect/crash22.C: New test.
Richard Biener [Tue, 17 Mar 2026 12:54:37 +0000 (13:54 +0100)]
Fix uninitialized LOOP_VINFO_LOOP_IV_COND
With uncounted loop support we can leave LOOP_VINFO_LOOP_IV_COND
uninitialized but that's accessed from vect_stmt_relevant_p,
unlikely to match by chance, but the following fixes it nevertheless.
* tree-vect-loop.cc (_loop_vec_info::_loop_vec_info):
Initialize loop_iv_cond given it's no longer always
initialized ...
(vect_create_loop_vinfo): ... here. Fix formatting.
Richard Biener [Fri, 13 Mar 2026 12:11:56 +0000 (13:11 +0100)]
tree-optimization/122380 - avoid PRE/hoisting of incompatible access-path
This decouples the PRE reference IL from the VN hash tables, following
the corresponding PR103037 fix for nary expressions in r12-7389 to avoid
correctness issues regarding to access paths when inserting expressions.
Unfortunately this makes existing workarounds for alignment and alias
mismatches ineffective so those have to be re-implemented. Instead
of going back to implement canonexpr() during the ANTIC dataflow the
following does this at insertion time, hoping all relevant reaching
expressions will survive. A convenient place to do this is
sorted_array_from_bitmap_set, the actual magic worker is 'prefer',
for the moment handling alignment and innermost access size only,
as those are the cases we have test coverage. In particular the
access path difference seen in this PR is not covered - it is enough
to fix the AVAIL_OUT computation in compute_avail for this.
Where the old fixup code massaged the expressions the new code selects
from existing expressions or as fallback makes sure to not perform
code insertion when two incompatible expressions met.
PR tree-optimization/122380
* tree-ssa-sccvn.h (copy_reference_ops_from_ref): Declare.
(vn_reference_compute_hash): Likewise.
(vn_reference_eq): Add parameter indicating lexical equivalence,
defaulted to false.
* tree-ssa-sccvn.cc (vn_reference_eq): Likewise.
(print_vn_reference_ops): Print alias type and alignment.
(vn_reference_compute_hash): Export.
(copy_reference_ops_from_ref): Likewise.
* tree-ssa-pre.cc (pre_expr_d::equal): Use lexical equivalence.
(get_or_alloc_expr_for_reference): Also get value-id, upon
zero assign a new value-id if the expression is unknown.
(expr_cmp): New helper.
(prefer): Likewise.
(pre_expr_DFS): Get expression exclusion bitmap and honor it.
(sorted_array_from_bitmap_set): If done for insertion, do limited
canonexpr() via pairwise prefer on expression pairs with the same
value, populating an exclution bitmap.
(phi_translate_1): Do not use the VN hashtable expressions
or insert there. Instead maintain a PRE view of expressions.
(clean): Adjust.
(do_hoist_insertion): Likewise.
(insert): Likewise.
(compute_avail): Use gimple_could_trap_p_1
on the original stmt rather than vn_reference_may_trap on
the VN leader. Use the original stmt operands for the PRE
view of reference expressions, only use the value number from the VN
tables. Remove no longer effective workarounds for semantically
different references with same value.
(fini_pre): Release operand vectors for PRE IL reference
expressions.
* g++.dg/torture/pr122380.C: New testcase.
* gcc.dg/torture/pr65270-3.c: Likewise.
* gcc.dg/tree-ssa/ssa-pre-30.c: XFAIL.
Yangyu Chen [Mon, 2 Mar 2026 07:09:05 +0000 (15:09 +0800)]
i386: Fix ICE with target_clones inlining
When a target_clones function is inlined, the resolver function's
assembler name must be properly registered in the symbol table.
Using SET_DECL_ASSEMBLER_NAME only updates the tree node without
notifying the symbol table, which can lead to an ICE during IPA
inlining when the assembler name hash becomes inconsistent.
Replace SET_DECL_ASSEMBLER_NAME with symtab->change_decl_assembler_name
in make_resolver_func to properly update the symbol table's assembler
name mapping.
This only happens on x86, other targets already uses
symtab->change_decl_assembler_name.
Fixes: b500cd2634 ("x86: fmv: Refactor FMV name mangling.")
gcc/ChangeLog:
* config/i386/i386-features.cc (make_resolver_func): Use
symtab->change_decl_assembler_name instead of
SET_DECL_ASSEMBLER_NAME to properly update the symbol table.
Tomasz Kamiński [Tue, 17 Mar 2026 08:34:37 +0000 (09:34 +0100)]
libstdc++: Fix is_explict checks in extents test.
The condition was checking if extents<int, ...> is convertible to index_type,
and not the reverse. This patch tests implicit conversion from braced
initializer list (to cover multiple arguments) and is_convertible in case of
single index.
libstdc++-v3/ChangeLog:
* testsuite/23_containers/mdspan/extents/ctor_ints.cc: Updated
is_explicit, and added more test cases.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
fortran: Preserve scalar class pointers in OpenMP privatization [PR120286]
OpenMP privatization currently treats scalar class pointers like owned
polymorphic class objects. In the worker cleanup for private/firstprivate
class pointers, the generated code finalizes and frees ptr._data even though
the clause only copied pointer association status from a shared target.
Fix this in gfc_omp_clause_copy_ctor and gfc_omp_clause_dtor by unwrapping
saved descriptors first and by recognizing class-pointer container types
locally in those hooks. That keeps scalar class pointers on the
association-only path without changing the broader polymorphic mapping
classification used for OpenMP warnings and deep mapping.
Add a runtime regression test for the original private(ptr) crash plus a
firstprivate(ptr) association check.
gcc/fortran/ChangeLog:
PR fortran/120286
* trans-openmp.cc (gfc_is_class_pointer_type): New helper.
(gfc_omp_clause_copy_ctor): Unwrap saved descriptors before
deciding whether privatization should preserve only pointer
association. Handle scalar class pointers on that path too.
(gfc_omp_clause_dtor): Likewise.
gcc/testsuite/ChangeLog:
PR fortran/120286
* gfortran.dg/pr120286.f90: New test.
Signed-off-by: Christopher Albert <albert@tugraz.at>
Marek Polacek [Sun, 15 Mar 2026 20:27:51 +0000 (16:27 -0400)]
c++/reflection: fix ICE on invalid splice [PR124496]
Just an ICE-on-invalid, but while writing tests for 123237 my
typos would result in this crash often enough to prompt me to
go ahead and fix it.
We crash here because we are asserting that we've emitted hard
errors when cp_parser_splice_specifier returns error_mark_node
even when parsing tentatively. In the crash20.C case we have
[:R<T>:] where we interpret the < as a "less than" operator and
expect that T will produce a primary expression, which it does
not. But cp_parser_error won't emit any errors yet.
PR c++/124496
gcc/cp/ChangeLog:
* parser.cc (cp_parser_splice_specifier): Use NULL_TREE instead of
NULL.
(cp_parser_splice_expression): Don't assert seen_error() when not
committed to tentative parse.
gcc/testsuite/ChangeLog:
* g++.dg/reflect/crash20.C: New test.
* g++.dg/reflect/crash21.C: New test.
Andrew Pinski [Sun, 15 Mar 2026 06:36:56 +0000 (23:36 -0700)]
c++: Fix ICE with error mark for an attribute [PR124307]
After r16-6808-g4b0e94b394fa38, we started to ICE when the
std_attrs was error_mark_node. This fixes the problem by
checking if it was an error_mark_node before looking for
annotations.
Bootstrapped and tested on x86_64-linux-gnu with no regressions.
Changes since v1:
* v2: Move the check for error mark earlier.
* v3: small formating changes.
PR c++/124307
gcc/cp/ChangeLog:
* parser.cc (cp_parser_base_specifier): Check for
error mark like checking for non-nullness on the
attribute.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/alignas24.C: New test.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Jonathan Wakely [Wed, 11 Mar 2026 21:05:13 +0000 (21:05 +0000)]
libstdc++: Add module initialization functions to the library [PR124268]
This ensures that the module init functions are present in libstdc++.so
and libstdc++.a, so that users of the std and std.compat modules don't
need to manually link to std.o and/or std.compat.o in addition to
compiling the CMIs.
This also adds a clean-local target to remove the generated interface
units and manifest, and the gcm.cache directory for the CMIs.
libstdc++-v3/ChangeLog:
PR libstdc++/124268
* config/abi/pre/gnu.ver: Export symbols.
* src/Makefile.am: Add libmodulesconvenience.la to libstdc++
link.
* src/Makefile.in: Regenerate.
* src/c++23/Makefile.am: Create libmodulesconvenience.la
and populate it with std.o and std.compat.o interface units.
Add clean-local target.
* src/c++23/Makefile.in: Regenerate.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Jonathan Wakely [Thu, 12 Mar 2026 15:15:57 +0000 (15:15 +0000)]
libstdc++: Make ranges::distance work with volatile iterators (LWG 4242)
This implements LWG 4242 which was approved in Sofia 2025.
I don't think the change from static_cast<const decay_t<I>&> to just
static_cast<decay_t<I>> is observable, but it doesn't hurt. What fixes
the problem identified in the issue is the is_array_v check, which
avoids the static_cast entirely for volatile-qualified iterators.
libstdc++-v3/ChangeLog:
* include/bits/ranges_base.h (distance(It&&, Sent)): Only decay
arrays to pointers when the type is actually an array, as per
LWG 4242.
* testsuite/24_iterators/range_operations/distance.cc: Add test
for LWG 4242.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Marek Polacek [Fri, 13 Mar 2026 17:00:46 +0000 (13:00 -0400)]
c++: fix for printing std::meta::info [PR124489]
When printing the diagnostics in this test, we're saying
"constexprstd::meta::info dm" which misses a space. We
should use pp_cxx_ws_string which does pp_c_maybe_whitespace
when printing "std::meta::info".
PR c++/124489
gcc/cp/ChangeLog:
* error.cc (dump_type) <case NULLPTR_TYPE>: Use pp_cxx_ws_string
instead of pp_string.
<case META_TYPE>: Likewise.
Jonathan Wakely [Wed, 11 Mar 2026 11:41:56 +0000 (11:41 +0000)]
libstdc++: Rewrite test for compare_exchange padding
Change the struct to ensure there is a padding byte between the members,
which was previously not the case for byte-aligned targets such as
cris-elf.
Add a new helper function to verify that the padding bits in a struct S
and in the std::atomic<S> are zero, without needing to disable SRA. Then
rewrite the test in terms of that helper, so we check directly that the
atomic object has the correct value and has no padding bits. Previously
we loaded a value (with -fno-tree-sra to hopefully preserve padding) and
then just using memcmp on that value to see if it was bitwise identical
to another value, but didn't actually check the members were correct or
that the padding was clear.
Also add a loop around the weak compare-exchange, to tolerate spurious
failures as described in
https://gcc.gnu.org/pipermail/gcc-patches/2026-March/710289.html
libstdc++-v3/ChangeLog:
* testsuite/29_atomics/atomic/compare_exchange_padding.cc:
Rewrite to be robust against spurious failures of weak compare
exchange, and to check padding bits more directly.
Jonathan Wakely [Mon, 9 Mar 2026 12:15:19 +0000 (12:15 +0000)]
libstdc++: Improve diagnostics for std::allocator<incomplete type>
Using requires { sizeof(T); } in __new_allocator::allocate gives a
better diagnostic when the static_assert fails.
We can also reduce the total number of diagnostics due to invalid
sizeof(T) and alignof(T) by using the same requires-expression to make
the body of the function a discarded statement when the static_assert
already failed. This fixes a regression in diagnostic quality due to
making __new_allocator::allocate constexpr in r16-7271-g7197d0cce70525,
which caused a cascade of seven errors instead of just one for
std::allocator<incomplete-type>().allocate(1).
libstdc++-v3/ChangeLog:
* include/bits/allocator.h (allocator::allocate): Use specific
feature test macro for constexpr allocate and deallocate. Make
consteval path a discarded statement if sizeof(T) is ill-formed.
* include/bits/new_allocator.h (__new_allocator::allocate): Use
requires-expression for static_cast. Make function body a
discarded stament if sizeof(T) is ill-formed. Use if-constexpr
for alignment checks.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
I originally just added the test to the 15 branch with the backports for
those commits, but richi pointed out in the PR that we should have it on
trunk too, so this adds it to the trunk.
gcc/testsuite/ChangeLog:
PR middle-end/124491
* gcc.target/aarch64/torture/pr124491.c: New test.
Richard Biener [Mon, 16 Mar 2026 08:55:26 +0000 (09:55 +0100)]
tree-optimization/124528 - UB from SCEV
SCEV has a long-standing issue in that it negates the addend of
a subtraction within a SSA cycle without considering UB from
negating of the most negative value. The following tries to
rectify this.
PR tree-optimization/124528
* tree-scalar-evolution.cc (scev_dfs::add_to_evolution):
Perform the negation in an unsigned type if we cannot make
sure it will not cause UB.
Kito Cheng [Mon, 16 Mar 2026 09:00:43 +0000 (17:00 +0800)]
RISC-V: Document big-endian support as experimental
The RISC-V big-endian ABI is not yet stable, add a note to the
-mbig-endian option documentation to warn users that support is
experimental and could change in incompatible ways.
gcc/ChangeLog:
* doc/invoke.texi: Add experimental warning for RISC-V
big-endian support.
Paul Thomas [Mon, 16 Mar 2026 08:20:20 +0000 (08:20 +0000)]
Fortran: Regression in gfc_convert_to_structure_constructor [PR93832]
2026-03-16 Paul Thomas <pault@gcc.gnu.org>
Steve Kargl <kargls@comcast.net>
gcc/fortran
PR fortran/93832
* array.cc (resolve_array_bound): Emit error and return false
if bound expression is derived type or class.
* primary.cc (gfc_convert_to_structure_constructor): Do not
dereference NULL in character component test. Define 'shorter'
and use it help cure one of several whitespace issues.
gcc/testsuite/
PR fortran/93832
* gfortran.dg/pr93832.f90: New test.
Paul Thomas [Mon, 16 Mar 2026 07:23:49 +0000 (07:23 +0000)]
Fortran: Fix segfault due to class actual in parentheses [PR105168]
2026-03-16 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/105168
* trans-expr.cc (gfc_conv_class_to_class): If the argument expr
is not a class type use the parent tree if that is a class.
(gfc_conv_procedure_call): If the argument expression is not a
variable, shift the bounds to give unity lbounds.
(gfc_trans_arrayfunc_assign): Return NULL_TREE instead of NULL.
gcc/testsuite/
PR fortran/105168
* gfortran.dg/pr105168.f90: New test.
Jakub Jelinek [Mon, 16 Mar 2026 07:06:52 +0000 (08:06 +0100)]
c++: Fix up sb as condition instantiation error-recovery [PR120039]
The following two testcases ICE during instantation.
Normally for the artificial var used for structured binding as condition
(which has NULL DECL_NAME) there is a DECL_EXPR which registers local
specialization and so tsubst_expr works fine.
But if there are errors while parsing the initializer, the VAR_DECL
has still NULL_TREE DECL_NAME, but error_mark_node TREE_TYPE and
when tsubst_expr is called on it, it falls back to calling lookup_name
(NULL_TREE) and ICEs on that.
The following patch fixes it by not calling lookup_name if DECL_NAME is
NULL.
2026-03-16 Jakub Jelinek <jakub@redhat.com>
PR c++/120039
PR c++/122559
* pt.cc (tsubst_expr) <case VAR_DECL>: Don't call lookup_name on
DECL_NAME (t) if it is NULL_TREE.
* g++.dg/cpp26/decomp28.C: New test.
* g++.dg/cpp26/decomp29.C: New test.
xtensa: constantsynth: Add new 2-insns synthesis method
This patch adds a new 2-instructions constant synthesis method:
- A positive integer value that, despite left-shifting the leading 0 bits,
becomes a negative number that still fits into a signed 12-bit
=> "MOVI(.N) Ax, simm12" + "SRLI Ax, Ax, 1...10"
fortran: Fix use-after-free in CLASS component error recovery [PR124482]
The error recovery added in r16-8021 (PR106946) freed CLASS container
symbols when removing invalid CLASS components from a derived type.
However, gfc_build_class_symbol reuses existing containers when multiple
components share the same class type and attributes. Freeing the
container for a failed component also invalidated it for previously
committed components, causing a use-after-free detectable with valgrind
and manifesting as a SEGV on Solaris/SPARC.
Fix by deferring CLASS container cleanup until after all failed
components are unlinked, then freeing the container only if no remaining
component still references it.
gcc/fortran/ChangeLog:
PR fortran/124482
* decl.cc (gfc_match_data_decl): Defer CLASS container cleanup
until after all failed components are unlinked. Check remaining
component list before freeing a shared container.
Signed-off-by: Christopher Albert <albert@tugraz.at>
François Dumont [Sat, 14 Mar 2026 13:34:29 +0000 (14:34 +0100)]
libstdc++: [_GLIBCXX_DEBUG] _M_invalidate_if incompatible with C++20 [PR124444]
__gnu_cxx::__scoped_lock cannot be instantiated in a C++20 constexpr function. Use
an intermediate method to avoid this situation.
libstdc++-v3/ChangeLog:
PR libstdc++/124444
* include/debug/safe_sequence.h (_Safe_sequence::_M_invalidate_if_impl): New.
(_Safe_sequence::_M_invalidate_if): Call later if not __is_constant_evaluated.
* include/debug/safe_sequence.tcc: Rename _M_invalidate_if into
_M_invalidate_if_impl and remove C++20 constexpr.
Jakub Jelinek [Sat, 14 Mar 2026 19:48:28 +0000 (20:48 +0100)]
c++: Ensure proper ordering of annotations in grokdeclarator [PR124399]
For the cases in the new test like
[[=1]] int a [[=2]], b [[=3]];
we want to order the =1 annotation before =2 or =3 because
https://eel.is/c++draft/meta.reflection#annotation-2.sentence-2
and =1 precedes =2 and =3.
The way we merge the attribute lists in grokdeclarator is done
for speed and memory efficiency though, so we attr_chainon
*attrlist (i.e. =1 above) after declarator->std_attributes
(i.e. =2 or =3 above). That has the advantage that we can keep
sharing the earlier *attrlist between multiple declarations, each one
will have its custom attributes at the start (if any) and then
a shared tail with the shared ones.
The following patch fixes it by checking if annotations are in
both lists (otherwise we keep doing what we've been doing before).
If they are in both, we chainon them the other way but of course
need to copy_list to unshare the shared one for that.
2026-03-14 Jakub Jelinek <jakub@redhat.com>
PR c++/124399
* decl.cc (grokdeclarator): If both *attrlist and
declarator->std_attributes list contain annotations, chainon
declarator->std_attributes to tail of copy_list (*attrlist)
rather than *attrlist to tail of declarator->std_attributes.
* g++.dg/reflect/annotations12.C: Uncomment two tests, remove
temporary test added until that is fixed.
* g++.dg/reflect/annotations13.C: New test.
Jose E. Marchesi [Sat, 14 Mar 2026 15:58:53 +0000 (16:58 +0100)]
a68: fix float standard conversion routine
This commit fixes the implementation of the `float' standard
conversion routine, by amending a typo that originates in the Revised
Report. It also makes the routine to properly handle short short and
short int arguments.
Signed-off-by: Jose E. Marchesi <jemarch@gnu.org
libga68/ChangeLog
* standard.a68.in (float): Fix typo from RR and handle short* int
arguments properly.
Jose E. Marchesi [Sat, 14 Mar 2026 15:57:08 +0000 (16:57 +0100)]
a68: fix string and character multiplication
This patch fixes the string operator for string and character
multiplication, to adjust to the semantics specified by the RR. In
particular, multiplying by a negative number or zero must result in
the empty string.
Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
gcc/algol68/ChangeLog
* a68-low-strings.cc (a68_string_mult): Adjust to RR semantics for
negative or zero factor argument.
* ga68.texi (String operators): Adjust documentation accordingly.
gcc/testsuite/ChangeLog
* algol68/execute/mult-char-1.a68: Multiplying a char or string by
negative or zero factor results in the empty string.
* algol68/execute/mult-string-3.a68: Likewise.
* algol68/execute/mult-string-2.a68: Likewise.
* algol68/execute/mult-string-1.a68: Likewise.
Matthias Klose [Sat, 14 Mar 2026 12:23:47 +0000 (13:23 +0100)]
Ada: Fix libgnat.so link failure on systems with older glibc
It's a regression present on all active branches for older glibc versions,
where dladdr is still in the libdl.so library, and not included in libc.so
as in newer glibc versions.
Nathaniel Shead [Sat, 14 Mar 2026 00:25:47 +0000 (11:25 +1100)]
c++/modules: Fix crash on implicit redeclaration of ABI class types [PR124485]
The crash in the given testcase occurs because the fix for PR122053, r16-4228-gfa6544ef5f50a824cabeda4906453d4545fbf66f, added a call to
lazy_load_pending when doing push_tag, to prevent ICEs at least when
types are textually redefined in lieu of full PR99000 support.
But this means that we might not have loaded the declarations of the ABI
types in lookup_elaborated_type to merge them there yet, but still have
them by the time we get to check_module_override, causing errors, and
then an ICE because tinfo_base_init is not prepared for xref_tag to
fail.
It turns out that doing the lazy load in pushtag is too late; we replace
the decl, but we don't replace the type, and then we end up returning
the type that we were building anyway rather than the type we were
hoping to match against.
The reason I'd done it there originally is because that's the earliest
we have a decl to do lazy_load_pendings with, but it seems that instead
we should have another interface to lazy_load_pendings that can be used
if you already know the name and namespace of the entity that you're
keying too.
PR c++/124485
gcc/cp/ChangeLog:
* cp-tree.h (lazy_load_pendings): Declare new overload.
* module.cc (lazy_load_pendings): Define it.
* name-lookup.cc (lookup_elaborated_type): Load pending entities
with given name before doing namespace-scope lookup.
(pushtag): Remove no-longer-needed pending load.
gcc/testsuite/ChangeLog:
* g++.dg/modules/class-8_b.C: Adjusted expected behaviour.
* g++.dg/modules/pr124485_a.C: New test.
* g++.dg/modules/pr124485_b.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
Jakub Jelinek [Sat, 14 Mar 2026 08:52:42 +0000 (09:52 +0100)]
c++: Fix up partial instantiation of structured binding packs [PR124456]
The following testcase ICEs during partial instantiation of structured
binding pack. tsubst_pack_expansion assumed DECL_VALUE_EXPR
in that case will be TREE_VEC containing what should be expanded.
But when the initializer of the structured bindings is still type dependent,
we know neither the size of the sb pack nor its content, cp_finish_decomp
in that case doesn't set DECL_VALUE_EXPR to a TREE_VEC at all, but to
ARRAY_REF of the base and index within the structured binding (and pack if
any).
tsubst_pack_expansion can set arg_pack to NULL_TREE and in that case
else
{
/* We can't substitute for this parameter pack. We use a flag as
well as the missing_level counter because function parameter
packs don't have a level. */
gcc_assert (processing_template_decl || is_auto (parm_pack)
|| args == NULL_TREE);
unsubstituted_packs = true;
}
will trigger and later on in the function unsubstituted_packs is handled
properly.
So, the following patch makes sure to set arg_pack to NULL_TREE in that
case.
2026-03-14 Jakub Jelinek <jakub@redhat.com>
PR c++/124456
* pt.cc (tsubst_pack_expansion): For structured binding pack
with type dependent pack set arg_pack to NULL_TREE.
Nathaniel Shead [Fri, 13 Mar 2026 15:23:09 +0000 (02:23 +1100)]
c++/modules: Support loading a lazy member while trying to declare it [PR124478]
The testcase shows an issue where we end up indirectly loading a
special member function while we're attempting to lazily declare it.
This causes errors in the install_implicit_member because
CLASSTYPE_LAZY* has been cleared, so it assumes that the member exists
already.
There are a few options to approach this issue:
1. Remove the error when we fail with install_implicit_member, and just
silently assume that a case like this is happening. This should be
safe, but could make it harder to understand future issues in this
area.
2. Put all implicitly declared special members on the pending list for
the class type, and add calls to lazy_load_pendings at the start of
lazily_declare_fn and check if the functions have now been
provided. But this could unnecessarily bloat out the pending tables
as aggregate types used in lots of modules will add their special
members to every module's pending table.
3. Detect exactly this special case in implicitly_declare_fn and halt
processing. This should only impact lazily_declare_fn, but makes its
API more complex.
This patch takes option three. Just because we know that the function
has been lazily declared somewhere else doesn't mean we can easily find
its declaration, however; luckily nothing actually uses the return type
of lazily_declare_fn, so we can change that to void instead and save on
some effort.
PR c++/124478
gcc/cp/ChangeLog:
* cp-tree.h (lazily_declare_fn): Make return type void.
* method.cc (is_lazy_special_member): New function.
(implicitly_declare_fn): Bail early if we lazy loaded the member
we're trying to declare.
(lazily_declare_fn): Likewise.
gcc/testsuite/ChangeLog:
* g++.dg/modules/imp-member-6_a.C: New test.
* g++.dg/modules/imp-member-6_b.C: New test.
* g++.dg/modules/imp-member-6_c.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
Andrew Pinski [Sat, 14 Mar 2026 00:09:49 +0000 (17:09 -0700)]
testsuite: make the prevent tailcall in pr17377.c more robust
With improvements (not actually implemented yet but shows up with LLVM),
the call in pr17377.c to prevent a tail call does not work. So
to make it more robust, we need to mark the variable x as being volatile.
Pushed as obvious after testing on x86_64-linux-gnu.
gcc/testsuite/ChangeLog:
* gcc.c-torture/execute/pr17377.c: Mark global variable x
as volatile.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
But that new instruction no longer traps as it is load from the stack. So later on
purge_dead_edges removes the REG_EH_REGION note and the edge to the eh landing pad
but this is during find_many_sub_basic_blocks in split3 and nothing then removes the
unreachable basic blocks.
To fix this, instead of depending on a later pass to clean this up, cprop_hardreg
should call purge_all_dead_edges if non-call exceptions were enabled and then
also call cleanup_cfg (to remove the unreachable blocks).
Bootstrapped and tested on x86_64-linux-gnu and lightly tested for aarch64-linux-gnu.
PR rtl-optimization/124454
gcc/ChangeLog:
* regcprop.cc (pass_cprop_hardreg::execute): If something
changed and non-call exceptions is on, call purge_all_dead_edges
and cleanup_cfg.
gcc/testsuite/ChangeLog:
* gcc.dg/pr124454-1.c: New test.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Jakub Jelinek [Fri, 13 Mar 2026 20:58:46 +0000 (21:58 +0100)]
libcpp: Fix up -MP for - input [PR105412]
For -MP we used to emit something like below in GCC 9 and earlier:
touch a.h; echo '#include "a.h"' | ./cc1 -quiet -E -M -MP -
-: /usr/include/stdc-predef.h a.h
/usr/include/stdc-predef.h:
a.h:
but since r10-205 we emit instead just
touch a.h; echo '#include "a.h"' | ./cc1 -quiet -E -M -MP -
-: /usr/include/stdc-predef.h a.h
a.h:
i.e. the rule for /usr/include/stdc-predef.h is removed. Similarly
with -nostdinc:
touch a.h; echo '#include "a.h"' | ./cc1 -quiet -E -nostdinc -M -MP -
-: a.h
a.h:
r10-205 changed that to:
touch a.h; echo '#include "a.h"' | ./cc1 -quiet -E -nostdinc -M -MP -
-: a.h
a.h:
The rationale for the change was
https://gcc.gnu.org/legacy-ml/gcc-patches/2019-05/msg00323.html
where after the mkdeps.cc reimplementation it started ICEing on
- input (file->path[0] is "" in that case).
The problem is that by leaving out the "" dependency (which we then
in some cases indeed ignore) the -MP printing
if (CPP_OPTION (pfile, deps.phony_targets))
for (unsigned i = 1; i < d->deps.size (); i++)
fprintf (fp, "%s:\n", munge (d->deps[i]));
starts at d->deps[1] unconditionally and so ignores the first dependency
even when it is not the main file.
So, either we could just revert the r10-205 change and ensure we don't
ICE on it and keep ignoring it when it should be ignored, or the
following patch fixes it by not adding the "" dep, but remembering that
in that case we should start iterating from i = 0; and not from i = 1;
2026-03-13 Jakub Jelinek <jakub@redhat.com>
PR preprocessor/105412
* files.cc (_cpp_stack_file): Call deps_add_dep even on
empty file path.
* mkdeps.cc (class mkdeps): Add first_phony_dep member.
(mkdeps::mkdeps ()): Initialize it to 1.
(deps_add_dep): When called first with "" argument, decrease
d->first_phony_dep to 0.
(make_write): For -MP iterate from d->first_phony_dep
rather than 1.
[PR117182, LRA]: Move point of skipping postponed insn
Working on PR117182 I found that a pseudo generated for save/restore
value around call is changed by equivalence which is constant as we
propagate equivalence for such pseudos to generate a better code. The
constant substitutes output of the save insn which can be changed to
memory containing constant by reload insn. We don't want this. The
patch fixes this.
gcc/ChangeLog:
PR target/117182
* lra-constraints.cc (curr_insn_transform): Don't change an output
operand by constant or invariant equivalence.
Andre Vieira [Fri, 13 Mar 2026 15:31:18 +0000 (15:31 +0000)]
arm: Add support for _BitInt(N)
This patch adds support for C23's _BitInt feature to the arm port.
gcc/ChangeLog:
* config/arm/arm.cc (TARGET_C_BITINT_TYPE_INFO): New Macro.
(arm_return_in_memory): Return true for any _BitInt(N) where N > 64.
(arm_needs_doubleword_align): Return true for any _BitInt(N) where N > 32.
(arm_bitint_type_info): New.
* config/arm/arm-protos.h (arm_bitint_type_info): New declaration.
libgcc/ChangeLog:
* config/arm/libgcc-bpabi.ver: Add new symbols.
* config/arm/t-softfp: Enable use of floatbitinthf and pass necessary options to build fp16.
Saurabh Jha [Thu, 12 Mar 2026 11:57:26 +0000 (11:57 +0000)]
aarch64: mingw: Fix _ARM_PCS_AAPCS64 [PR122953]
Windows platforms do not support the default procedure calling standard,
AAPCS64. So _ARM_PCS_AAPCS64 should not be set for Windows targets.
This fixes the setting of __ARM_PCS_AAPCS64 by making it conditional on
non-Windows targets.
PR target/122953
gcc/ChangeLog:
* config/aarch64/aarch64-c.cc
(TARGET_AARCH64_MS_ABI): Explicitly set it to 0 if not on mingw.
(aarch64_define_unconditional_macros): Remove __ARM_PCS_AAPCS64
from here.
(aarch64_update_cpp_builtins): Define __ARM_PCS_AAPCS64 if not
on Windows ABI.
---
Hey,
Regression tested on aarch64-linux-gnu and found no regressions.
Built for arch64-w64-mingw32, ran target dependent tests, and
found no regressions.
Jakub Jelinek [Fri, 13 Mar 2026 13:13:44 +0000 (14:13 +0100)]
tree-profile: Formatting fixes
On Fri, Mar 13, 2026 at 11:12:54AM +0100, Jørgen Kvalsvik wrote:
> > Note, big parts of tree-profile.cc now use some weird formatting, not GCC
> > style, indentation by 4 columns instead of 2, { on the same column as line
> > above it instead of 2 columns to the right, etc. I think it would be nice
> > to get that incrementally fixed.
>
> Yeah, since writing the MC/DC support it I've changed my setup to properly
> apply the GNU style, but I haven't wanted to make too much noise with
> patches for it. I can change the style incrementally whenever I pass over
> this, or maybe even a single pass that fixes all of it.
Given that it is so different from GNU style, incrementally adjusting it is
hard, if done incrementally it would mean usually reformat whole function
rather than just a few lines in it.
So I think it is better to change it once.
Here is my attempt to do so, fixed what I saw.
2026-03-13 Jakub Jelinek <jakub@redhat.com>
* tree-profile.cc (struct conds_ctx): Formatting fixes.
Rename B1, B2, G1, G2 and G3 members to b1, b2, g1, g2 and g3.
Adjust all uses.
(topological_cmp, topological_src_cmp, index_of, single_p,
single_edge, contract_edge_up): Formatting fixes.
(struct outcomes): Likewise.
(conditional_succs, condition_index, condition_uid,
masking_vectors, emit_assign, emit_bitwise_op): Likewise.
(make_top_index_visit, make_top_index): Likewise. Rename
L argument to l.
(paths_between): Formatting fixes.
(struct condcov): Likewise.
(cov_length, cov_blocks, cov_masks, cov_maps, cov_free): Likewise.
(find_conditions): Likewise. Don't start warning_at message with
uppercase letter.
(struct counters): Formatting fixes.
(find_counters, resolve_counter, resolve_counters,
instrument_decisions): Likewise.
(init_ic_make_global_vars): Comment formatting fixes.
(gimple_init_gcov_profiler): Formatting fixes.
Jakub Jelinek [Fri, 13 Mar 2026 13:11:57 +0000 (14:11 +0100)]
testsuite: Fix up gcc.dg/analyzer/ice-pr124375-1.c for 32-bit targets [PR124375]
On Wed, Mar 11, 2026 at 08:51:03PM -0400, David Malcolm wrote:
> * gcc.dg/analyzer/ice-pr124375-1.c: New test.
Unfortunately this test FAILs on i686-linux (and guess all
other sizeof (int) == sizeof (__PTRDIFF_TYPE__) targets).
The problem is that on x86_64-linux the warning is indeed emitted on the
__printf_buffer_offset = __printf_buffer_spec /* { dg-warning "stack-based buffer over-read" } */
line but on i686-linux (or x86_64-linux with -m32) on the
: step0_jumps[' '];
line. I think the difference is due to a useless cast missing on the latter
(int and __PTRDIFF_TYPE__ are either the same or uselessly compatible, so
there is no extra cast stmt which holds some particular location).
On lp64 the above is (int)(__print_buffer_spec ? &&do_form_unknown - &&do_form_unknown
: (__PTRDIFF_TYPE__) step0_jumps[' ']);
So, either we would need to expect this dg-warning for say lp64 only and
expect a dg-warning on the other line for ilp32 (but what to do for
non-lp64/ilp32 targets?), or limit the test to lp64 only, or the following
patch just forces it onto one line (we regularly go over the 80 line limit
in the testsuite, often by a lot) and then it really doesn't matter on which
column the warning is emitted.
Tested on x86_64-linux and i686-linux by making sure the pre r16-8019
still ICEd on it (both 64-bit and 32-bit) and that latest trunk warns
on the right line with both.
2026-03-13 Jakub Jelinek <jakub@redhat.com>
PR analyzer/124375
* gcc.dg/analyzer/ice-pr124375-1.c (__printf_buffer): Put the whole ?:
expression on a single line.
Jørgen Kvalsvik [Fri, 13 Mar 2026 09:45:26 +0000 (10:45 +0100)]
Count non-complex incoming edges [PR124462]
This is really a gcov/instrumentation bug, but it was filed under ipa.
We did filter out incoming complex edges, but didn't account for the
case where a block has multiple incoming edges without actually being a
conditional outcome. We also need to check that we have >= 2 incoming
edges after filtering out the complex ones to make sure it is a (short
circuiting) before we try to compute the masking table.
PR ipa/124462
gcc/ChangeLog:
* tree-profile.cc (masking_vectors): Skip blocks with less than
2 non-complex incoming edges.
* config/xtensa/xtensa.cc (constantsynth_pass1):
Change the comparison between src and SET_SRC(pat) to be performed
using rtx_equal_p rather than between references (pointer values)
directly, and adjust the destination of changes in validate_change
to eliminate the need to call gen_rtx_SET.
(constantsynth_pass2):
Fill in missing spacing in one place and changes dump file output
slightly.
xtensa: Rename/reduce from split_DI_SF_DF_const to convert_SF_const in 'xt_largeconst2'
The order in which split_DI_SF_DF_const in the target-specific pass
'xt_largeconst2' is processed has been changed to be after split2, so
that the splitting of D[IF]mode assignments to S[IF]mode by the split
parts of movd[if]_internal MD patterns is now performed earlier.
Therefore, in split_DI_SF_DF_const, there is no need to split the
allocation of the D[IF]mode constant, and only the function to change
the allocation of the SFmode constant to SImode remains.
This patch reduces the functionality of split_DI_SF_DF_const as
described above and renames it to convert_SF_const.
gcc/ChangeLog:
* config/xtensa/xtensa.cc (xtensa_split_operand_pair)
Move the common code from the split part of movd[if]_internal
MD patterns into this function, since this function is only
called from the split part of that patterns.
Also, during non-debug optimization, re-register new literal
pool entries with the split values themselves instead of
splitting the memory reference of the source numeric constant
placed in the pool.
(split_DI_SF_DF_const):
Rename to convert_SF_const and remove the split function of
D[IF]mode constant assignment.
(do_largeconst2):
Change the call from split_DI_SF_DF_const to convert_SF_const.
* config/xtensa/xtensa.md (movdi_internal, movdf_internal):
Reduce their split parts to just a call to xtensa_split_operand_pair.
xtensa: Minor changes to FPreg_neg_scaled_simm12b in 'xt_largeconst2'
Having a non-zero finite REAL_VALUE_TYPE is equivalent to having it be
normal, because REAL_VALUE_TYPE can only be zero, normal, infinity, or
NaN (see gcc/real.h).
gcc/ChangeLog:
* config/xtensa/xtensa.cc (FPreg_neg_scaled_simm12b_1):
Change the test to determine whether REAL_VALUE_TYPE is a non-
zero finite value to whether it is normal.
(FPreg_neg_scaled_simm12b):
Place the call to FPreg_neg_scaled_simm12b_1 last in the
expression to improve performance, and change the dump file
output slightly.
xtensa: Split target-specific pass 'xt_largeconst' into two
Previously, in 1eefa6e0c84e3008ed7ac44d08a8e5206038fb33 and a series of
subsequent commits, we added a target-specific optimization pass
'xt_largeconst' right after postreload to convert assignments of numeric
constants that don't fit into immediate fields to a more efficient
implementation than the standard one (references to literal pool entries),
if available.
However, the processes performed in this pass are a mixture of essential
and optional ones (such as optimizations), which is not good in terms of
structure or execution efficiency. Additionally, large numeric constant
assignments may be emitted after this pass, for example during stack frame
construction in function prologue.
To address these issues, this patch splits the processing in this pass
into two parts:
- places the mandatory processing (i.e., restoring delegitimized forms
of large numeric constant assignments to valid ones) immediately after
postreload, and
- places the rest, optional processing (i.e., optimizations) immediately
before regrename, which a reasonable location after pro_and_epilogue
and before sched2.
gcc/ChangeLog:
* config/xtensa/xtensa-passes.def (pass_xtensa_largeconst):
Rename to pass_xtensa_largeconst1.
(pass_xtensa_largeconst2): New target-specific pass.
* config/xtensa/xtensa-protos.h (make_pass_xtensa_largeconst):
Rename to make_pass_xtensa_largeconst1.
(make_pass_xtensa_largeconst2): New function prototype.
* config/xtensa/xtensa.cc (litpool_set_src_1):
Change to process large numeric constant assignments to DImode
as well as [SH]Imode.
(do_largeconst):
Rename it to do_largeconst1 and leave only the mandatory insn
transformation process.
(do_largeconst2): New function that inherits the optional insn
transformation processes from the old do_largeconst.
(rest_of_handle_largeconst):
Rename to rest_of_handle_largeconst1 and change to call
do_largeconst1.
(rest_of_handle_largeconst2): New function that calls
do_largeconst2.
(pass_data_xtensa_largeconst)
Rename to pass_data_xtensa_largeconst1.
(pass_xtensa_largeconst):
Rename to pass_xtensa_largeconst1 and change to call
rest_of_handle_largeconst1.
(pass_data_xtensa_largeconst2): New opt_pass data.
(pass_xtensa_largeconst2):
New rtl_opt_pass that runs rest_of_handle_largeconst2 when non-
debug optimizations are enabled.
(make_pass_xtensa_largeconst):
Rename to make_pass_xtensa_largeconst1.
(make_pass_xtensa_largeconst2): New function definition.
Jakub Jelinek [Fri, 13 Mar 2026 08:16:26 +0000 (09:16 +0100)]
i386: Fix up movrs<mode> suffix for -masm=intel [PR124461]
For movrs<mode> the insn was using insn suffix unconditionally, so
movrsl or movrsq even for -masm=intel, when gas expects movrs and derives
what size of insn it is from the operands.
There is no movrs effective target, so I've just used dg-do compile with
scan-assembler to test it instead of dg-do assemble.
2026-03-13 Jakub Jelinek <jakub@redhat.com>
PR target/124461
* config/i386/i386.md (movrs<mode>): Use <imodesuffix> only for
-masm=att, not for -masm=intel.
Jakub Jelinek [Fri, 13 Mar 2026 08:15:11 +0000 (09:15 +0100)]
c++: Include 26 in make check-c++-all
I'm not regularly using make check-c++-all (using
GXX_TESTSUITE_STDS=98,11,14,17,20,23,26 instead), so this is just
from curiosity.
I wonder if it is a good idea to leave 26 out (whether it is intentional
or not). I know impcx includes 26 plus -fimplicit-constexpr, but e.g.
given r16-7990 some tests will not be tested at all for 26 in that case and
others will test different behavior.
Jakub Jelinek [Fri, 13 Mar 2026 08:13:09 +0000 (09:13 +0100)]
c++: Fix up *display_string_of on anon union member [PR124388]
{,u8}display_string_of was printing any unnamed FIELD_DECL as
%T::<unnamed bit-field>, but anon union member is also unnamed and
is not a bit-field.
Fixed by printing %T::<anonymous union> for anon union NSDM and
%T::<unnamed member> for anything else unnamed (e.g. anon struct NSDM).
2026-03-13 Jakub Jelinek <jakub@redhat.com>
PR c++/124388
* reflect.cc (eval_display_string_of): Only print <unnmamed bit-field>
for DECL_UNNAMED_BIT_FIELD, for anon union print <anonymous union>,
otherwise print <unnamed member>.
* g++.dg/reflect/display_string_of1.C (S, NS5::S): Add
union { int a; }. Add static_assertions that the unnamed non-static
data member is printed as <unnamed member>.
* g++.dg/reflect/u8display_string_of1.C (S, NS5::S): Add
union { int a; }. Add static_assertions that the unnamed non-static
data member is printed as <unnamed member>.
fortran: Fix OpenMP iterator depend lowering for component arrays [PR102459]
When lowering an OpenMP depend clause with an iterator expression such as
x(j)%a, the front end currently looks only at the first REF_ARRAY to
decide between scalar-reference lowering and array-descriptor lowering.
For x(j)%a that first ref is the scalar base element x(j), but the full
expression is still the rank-1 component array a.
As a result, the code calls gfc_conv_expr_reference on an array-valued
expression, which later reaches gfc_conv_scalarized_array_ref without a
scalarizer state and ICEs.
Fix this by choosing the lowering path from the rank of the full
expression. Rank-zero expressions still use gfc_conv_expr_reference,
while array-valued expressions are lowered through gfc_conv_expr_descriptor.
Apply the same adjustment to the analogous depobj helper and add a
regression test for task depend clauses covering both x(j)%a and the
scalar control case x(j)%a(1).
gcc/fortran/ChangeLog:
PR fortran/102459
* trans-openmp.cc (gfc_trans_omp_clauses): Choose the scalar
reference path from the full expression rank rather than the first
array reference.
(gfc_trans_omp_depobj): Likewise.
gcc/testsuite/ChangeLog:
PR fortran/102459
* gfortran.dg/pr102459.f90: New test.
Signed-off-by: Christopher Albert <albert@tugraz.at>
Fortran: Allow task-reduction allocatable scalars without outer ref [PR102596]
OpenMP task reduction lowering can call gfc_omp_clause_default_ctor for
an allocatable scalar with outer == NULL_TREE. That is valid for scalar
allocatables that only need fresh storage allocation and do not need a
copied descriptor or allocatable-component walk.
The Fortran hook asserted unconditionally on outer != NULL_TREE, so
reduction(task, +:r) with an allocatable scalar ICEd during omplower.
Fix this by requiring outer only for the cases that actually use it:
descriptor-based allocatables and types with allocatable components.
Keep the assertion for those cases and allow NULL outer for plain scalar
allocatables. Add a regression test for the allocatable task-reduction
case.
gcc/fortran/ChangeLog:
PR fortran/102596
* trans-openmp.cc (gfc_omp_clause_default_ctor): Only require an
outer reference when the constructor path actually uses it.
gcc/testsuite/ChangeLog:
PR fortran/102596
* gfortran.dg/pr102596.f90: New test.
Signed-off-by: Christopher Albert <albert@tugraz.at>
Nathaniel Shead [Sun, 22 Feb 2026 15:20:38 +0000 (02:20 +1100)]
c++/reflection: Support members_of and imported namespace-scope names [PR124200]
namespace_members_of needs to iterate over all VECTOR_BINDINGs
for the given namespace, and handle deduplication.
PR c++/124200
gcc/cp/ChangeLog:
* name-lookup.h (walk_namespace_bindings): Declare.
* name-lookup.cc (walk_namespace_bindings): New function.
* reflect.cc (namespace_members_of): Use it.
gcc/testsuite/ChangeLog:
* g++.dg/modules/reflect-2_a.H: New test.
* g++.dg/modules/reflect-2_b.C: New test.
* g++.dg/modules/reflect-2_c.C: New test.
* g++.dg/modules/reflect-3_a.H: New test.
* g++.dg/modules/reflect-3_b.C: New test.
* g++.dg/modules/reflect-3_c.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Co-authored-by: Thomas Berger <loki+gcc@loki.codes> Reviewed-by: Jason Merrill <jason@redhat.com> Reviewed-by: Marek Polacek <polacek@redhat.com>