On MacOS mmap() very often does not respect the provided base address
for the shared memory segment. On the other hand the mutexes have to be
on the same (virtual) address for each process to function properly.
Therefore try a configurable number of times to get the same address for
the shared memory segment on MacOS. If that fails the user is notified
and the program terminates.
gcc/fortran/ChangeLog:
* invoke.texi: Document new environment variable GFORTRAN_IMAGE_
RESTARTS_LIMIT.
libgfortran/ChangeLog:
* caf/shmem.c (_gfortran_caf_finalize): Ensure all memory is
freeed.
* caf/shmem/allocator.c (allocator_shared_malloc): Just assert
that an index is within its bounds.
* caf/shmem/shared_memory.c (shared_memory_init): When shared
memory can not be placed at desired address, exit the image with
a certain code to let the supervisor restart the image.
(shared_memory_cleanup): Only the supervisor must unlink the shm
object.
* caf/shmem/supervisor.c (GFORTRAN_ENV_IMAGE_RESTARTS_LIMITS):
New environment variable.
(get_image_restarts_limit): Get the limit on image restarts
(accumulates over all) form the environment variable or default
to 4000.
(ensure_shmem_initialization): Add error handling.
(startWorker): Start a single worker/image.
(kill_all_images): Kill all images.
(supervisor_main_loop): When a worker/image reports a shared
memory issue just try to restart it.
* caf/shmem/thread_support.c (initialize_shared_mutex): Mark
mutex robust on plattforms that support it.
(initialize_shared_errorcheck_mutex): Same.
Cygwin's libc's pthread implementation does not support setting
pshared on mutexes and condition variables. Therefore Windows
synchronisation primitives needed to be used directly.
On MSYS2/UCRT64 fork and mmap are not available and Windows core
functionality needs to be used.
libgfortran/ChangeLog:
* caf/shmem.c (_gfortran_caf_init): Cleanup thread helper after
use.
(_gfortran_caf_finalize): Same.
(_gfortran_caf_register): Handle lock_t correctly on Windows.
(GEN_OP): Prevent warnings on non-initialized.
(_gfortran_caf_lock): Handle lock_t correctly on Windows.
(_gfortran_caf_unlock): Same.
(_gfortran_caf_random_init): Fix formatting.
(_gfortran_caf_form_team): Add more images to counter_barrier.
* caf/shmem/alloc.c: Use routines from thread_support.
* caf/shmem/allocator.c (allocator_lock): Same.
(allocator_unlock): Same.
* caf/shmem/allocator.h: Same.
* caf/shmem/collective_subroutine.c (get_collsub_buf): Same.
* caf/shmem/collective_subroutine.h: Same.
* caf/shmem/counter_barrier.c (lock_counter_barrier): Same.
(unlock_counter_barrier): Same.
(counter_barrier_init): Same.
(counter_barrier_wait): Same.
(change_internal_barrier_count): Same.
(counter_barrier_add): Same.
(counter_barrier_init_add): Only increase value w/o signaling.
(counter_barrier_get_count): Use routines from thread_support.
* caf/shmem/counter_barrier.h: Same.
(counter_barrier_init_add): New routine.
* caf/shmem/shared_memory.c: Use windows routines where
applicable.
(shared_memory_set_env): Same.
(shared_memory_get_master): Same.
(shared_memory_init): Same.
(shared_memory_cleanup): Same.
* caf/shmem/shared_memory.h: Use types from thread_support.
* caf/shmem/supervisor.c: Use windows routines where applicable.
(get_memory_size_from_envvar): Same.
(ensure_shmem_initialization): Same.
(supervisor_main_loop): Use windows process start on windows
without fork().
* caf/shmem/supervisor.h: Use types from thread_support.
* caf/shmem/sync.c (lock_table): Use routines from thread_support.
(unlock_table): Same.
(sync_init): Same.
(sync_init_supervisor): Same.
(sync_table): Same.
(lock_event): Same.
(unlock_event): Same.
(event_post): Same.
(event_wait): Same.
* caf/shmem/sync.h: Use types from thread_support.
* caf/shmem/teams_mgmt.c (update_teams_images): Use routines from
thread_support.
* caf/shmem/thread_support.c: Add synchronisation primitives for
windows.
(smax): Windows only: Max for size_t.
(get_handle): Windows only: Get the windows handle for a given
id or create a new one, if it does not exist.
(get_mutex): Windows only: Shortcut for getting a windows mutex
handle.
(get_condvar): Windows only: Same, but for condition variable.
(thread_support_init_supervisor): Windows only: Clear tracker of
allocated handle ids.
(caf_shmem_mutex_lock): Windows only: Implememtation of lock,
(caf_shmem_mutex_trylock): Windows only: trylock, and
(caf_shmem_mutex_unlock): Windows only: unlock for Windows.
(bm_is_set): Windows only: Check a bit is set in a mask.
(bm_clear_bit): Windows only: Clear a bit in a mask.
(bm_set_mask): Windows only: Set all bits in a mask.
(bm_is_none): Windows only: Check if all bits are cleared.
(caf_shmem_cond_wait): Windows only: Condition variable
implemenation fro wait,
(caf_shmem_cond_broadcast): Windows only: broadcast, and
(caf_shmem_cond_signal): Windows only: signal on Windows.
(caf_shmem_cond_update_count): Windows only: Need to know the
images participating in a condition variable.
(thread_support_cleanup): Windows only: Clean up the handles on
exit.
* caf/shmem/thread_support.h: Conditionally compile the types
as required for Windows and other OSes.
Fortran: Add a shared memory multi process coarray implementation [PR88076]
Add caf_shmem, a shared memory multi process coarray implementation. The
library adheres to the existing coarray ABI and is controlled by some
environment variables for selecting the number of images and virtual
memory size (see invoke.texi).
Co-authored by: Thomas Koenig <tkoenig@gcc.gnu.org>
Nicolas Koenig <koenigni@gcc.gnu.org>
PR fortran/88076
gcc/fortran/ChangeLog:
* invoke.texi: Add description for use.
libgfortran/ChangeLog:
* caf/libcaf.h (LIBCAF_H): Remove unused header inclusions.
* caf/caf_error.c: New file.
* caf/caf_error.h: New file.
* caf/shmem.c: New file.
* caf/shmem/alloc.c: New file.
* caf/shmem/alloc.h: New file.
* caf/shmem/allocator.c: New file.
* caf/shmem/allocator.h: New file.
* caf/shmem/collective_subroutine.c: New file.
* caf/shmem/collective_subroutine.h: New file.
* caf/shmem/counter_barrier.c: New file.
* caf/shmem/counter_barrier.h: New file.
* caf/shmem/hashmap.c: New file.
* caf/shmem/hashmap.h: New file.
* caf/shmem/shared_memory.c: New file.
* caf/shmem/shared_memory.h: New file.
* caf/shmem/supervisor.c: New file.
* caf/shmem/supervisor.h: New file.
* caf/shmem/sync.c: New file.
* caf/shmem/sync.h: New file.
* caf/shmem/teams_mgmt.c: New file.
* caf/shmem/teams_mgmt.h: New file.
* caf/shmem/thread_support.c: New file.
* caf/shmem/thread_support.h: New file.
Fortran: Fix signatures of coarray API and caf_single.
The teams argument to some functions was marked as unused in the header.
With upcoming caf_shmem this is incorrect, given the mark is repeated in
caf_single.
libgfortran/ChangeLog:
* caf/libcaf.h (_gfortran_caf_failed_images): Team attribute is
used now in some libs.
(_gfortran_caf_image_status): Same.
(_gfortran_caf_stopped_images): Same.
* caf/single.c (caf_internal_error): Use correct printf function
to handle va_list.
Fortran: Fix coarray generation for char arrays and derived types.
Fix the generation of a coarray, esp. its bounds, for char arrays.
When a scalar char array is used in a co_reduce the coarray part was
dropped.
Furthermore for class typed dummy arguments where derived types were
used as actual arguments the coarray generation is now done, too.
gcc/fortran/ChangeLog:
* trans-expr.cc (get_scalar_to_descriptor_type): Fix coarray
generation.
(copy_coarray_desc_part): New function to copy coarray dimensions.
(gfc_class_array_data_assign): Use the new function.
(gfc_conv_derived_to_class): Same.
Fortran: Small fixes of coarray routines handling and code gen.
gcc/fortran/ChangeLog:
* check.cc (gfc_check_image_status): Fix argument index of team=
argument for correct error message.
* trans-intrinsic.cc (conv_intrinsic_image_status): Team=
argument is optional and is a pointer to the team handle.
* trans-stmt.cc (gfc_trans_sync): Make images argument also a
dereferencable pointer. But treat errmsg as a pointer to a
char array like in all other functions.
gcc/testsuite/ChangeLog:
* gfortran.dg/coarray_sync_memory.f90: Adapt grep pattern for
msg being only &msg.
Matthieu Longo [Fri, 30 Jan 2026 15:53:18 +0000 (15:53 +0000)]
aarch64: remove GNU properties expectations from a BTI test
When branch protections are enabled (see -mbranch-protection), GCC tags
the output object file with metadata describing which security features
are used, allowing the GNU linker to detect incompatibilities between
objects in the same link unit.
Originally, this metadata was conveyed via GNU properties. GCC emitted a
.note.gnu.property section containing a GNU_PROPERTY_AARCH64_FEATURE_1_AND
entry.
Build Attributes v2 (OAv2) aim at replacing GNU properties, provinding
a more flexible way to express complex metadata and making easier for
tools like linkers to parse them.
Since the runtime linker only understands GNU properties, the GNU static
linker translates OAv2 attributes into GNU properties. As a result,
emitting both GNU properties and OAv2 in the same object file is redundant.
When GCC detects OAv2 support in GNU binutils, it therefore emits only
OAv2 directives.
Support for OAv2 was added in [1], along with new tests covering both
the emission/omission of GNU properties/OAv2 directives. However, an older
BTI test that checked for the presence of a GNU properties section was
left unchanged. This test now fails when GNU binutils support OAv2, as no
GNU properties are emitted.
This patch removes the expectations of the presence of GNU properties from
that BTI test.
Robin Dapp [Thu, 19 Feb 2026 14:44:38 +0000 (15:44 +0100)]
RISC-V: Consider uses for vsetvl LCM transparency. [PR122448]
Until now we didn't consider (pre-existing) uses of vsetvl's destination
registers when computing transparency for vsetvl LCM. In rare instances,
this can lead to hoisting vsetvls beyond blocks that have uses on such
registers.
We already check transparency when hoisting but here LCM computes edge
insertion points.
For vsetvl a5,zero,e16,m1 in BB 65 we have the following, not
particularly uncommon, situation:
BB 64 uses a5, so is not transparent with respect to the vsetvl.
BB 63 -> BB 65 is an edge LCM computes as earliest.
But we're not inserting the vsetvl on just that edge like in regular LCM
where we could have a new block along that edge but instead insert it at
the end of BB 63. At that point, though, the other outgoing edges and
successor blocks have to be considered as well.
The patch is two-fold. It adds a new bitmap m_reg_use_loc that keeps
track of uses of vsetvl destinations, rather than just new definitions
and adds them to the transparency bitmap. This correct LCM's
computations with respect to uses. Then, as described above, it
prevents hoisting into the target block (BB 63) if the vsetvl's
destination register is used outside of vsetvls in any other
successor (BB 64).
In regular, non-speculating LCM we would be able to just check ANTOUT but
as we are hoisting speculatively this won't work. We don't require all
successors to have a vsetvl in order to hoist it to a block.
Therefore the patch computes reaching definitions for all vsetvl's
destination registers up to their AVL uses. Knowing a block's live-in
and the reaching definitions we can deduce that a use must be non-vsetvl
and prone to clobbering.
PR target/122448
gcc/ChangeLog:
* config/riscv/riscv-vsetvl.cc (compute_reaching_defintion):
Rename...
(compute_reaching_definition): ...To this.
(pre_vsetvl::compute_vsetvl_def_data): Compute reaching
definitions for vsetvl VL -> vsetvl AVL.
(pre_vsetvl::compute_transparent): Include VL uses.
(pre_vsetvl::fuse_local_vsetvl_info): Initialize m_reg_use_loc.
(pre_vsetvl::earliest_fuse_vsetvl_info): Don't hoist if any
successor would use VL.
Karl Meakin [Thu, 11 Dec 2025 16:19:22 +0000 (16:19 +0000)]
aarch64: fix `cmpbr-3.c` tests
The assembly tests in `cmpbr-3.c` were failing when run with an old
version of `gas` which did not recognise the extension. Fix by changing
`dg-do assemble` to `dg-do compile`.
This patch fixes a very annoying problem where we emit a bogus
check_out_of_consteval_use error. The error is provoked while
processing
[: std::meta::reflect_constant_array (data) :]
The argument of a [: :] is a constant-expression = a manifestly
constant-evaluated context, so any consteval-only exprs in it
are OK. But in eval_reflect_constant_array we do get_template_parm_object
which does push_to_top_level -- so we have no scope_chain, therefore
any in_consteval_if_p and current_function_decl are cleared, so we're
not in an immediate context. As part of this get_template_parm_object,
we call cp_finish_decl -> check_initializer -> build_aggr_init ->
-> build_vec_init.
Here in build_vec_init try_const is true, but we still generate code
for the initializer like
etc. We add ++D.67757 with finish_expr_stmt which calls
convert_to_void -> check_out_of_consteval_use which causes the error
because ++D.67757's type is consteval-only. Note that what we end up using
is the simple
because we didn't see anything non-const in the initializer.
Rather than convincing check_out_of_consteval_use that we are in an
immediate context, we should only call check_out_of_consteval_use on the
outermost statement, not sub-statements like the ++D.67757 above. This
is not a complete fix though, see the FIXME.
PR c++/123662
PR c++/123611
gcc/cp/ChangeLog:
* cvt.cc (convert_to_void): Only call check_out_of_consteval_use
when stmts_are_full_exprs_p.
gcc/testsuite/ChangeLog:
* g++.dg/reflect/reflect_constant_array5.C: New test.
* g++.dg/reflect/reflect_constant_array6.C: New test.
Xi Ruoyao [Thu, 26 Feb 2026 03:55:22 +0000 (11:55 +0800)]
middle-end: extend the narrower shift amount before broadcasting it [PR 124250]
The comment above expand_vector_broadcast() states a precondition that
the mode of op must be the element mode of vmode. But when
expand_binop() called expand_vector_broadcast() to broadcast the shift
amount, it only truncated the shift amount if it's too wide, but no
action is performed if the shift amount is too narrow.
PR middle-end/124250
PR target/123807
gcc/
* optabs.cc (expand_vector_broadcast): Add a checking assert to
verify the precondition about the input modes.
(expand_binop): Extend the shift amount if it's narrower than
the element of the shifted vector.
Marek Polacek [Tue, 24 Feb 2026 18:38:48 +0000 (13:38 -0500)]
c++/reflection: members_of and cv-qual class types [PR124215]
Here when asking for the members of "^^Test const" we found nothing.
The reason is that members_of_representable_p checks whether
CP_DECL_CONTEXT != c, but if c is a type, it doesn't look at its
TYPE_MAIN_VARIANT. Fixed as per Jakub's suggestion in the PR.
PR c++/124215
gcc/cp/ChangeLog:
* reflect.cc (class_members_of): Use TYPE_MAIN_VARIANT of R.
gcc/testsuite/ChangeLog:
* g++.dg/reflect/members_of9.C: New test.
Co-authored-by: Jakub Jelinek <jakub@redhat.com> Reviewed-by: Jason Merrill <jason@redhat.com>
Yuao Ma [Wed, 25 Feb 2026 12:44:07 +0000 (20:44 +0800)]
libstdc++: complete P0493R5 with pointer support
Previous implementations of fetch_min/max only supported integers, not
handling pointers. To complete the paper, we need to implement support
for pointers as well. This patch adds the missing functionality and
test cases.
libstdc++-v3/ChangeLog:
* include/bits/atomic_base.h (__atomic_base<_PTp*>::fetch_min,
__atomic_base<_PTp*>::fetch_max,
__atomic_ref<_Pt, false, false, true>::fetch_min,
__atomic_ref<_Pt, false, false, true>::fetch_max): Define new
functions.
* include/std/atomic (atomic<_Tp*>::fetch_min,
atomic<_Tp*>::fetch_max): Likewise.
(atomic_fetch_min_explicit, atomic_fetch_max_explicit,
atomic_fetch_min, atomic_fetch_max): Change parameter from
__atomic_base<_ITp>* to atomic<_Tp>*.
* testsuite/29_atomics/atomic/pointer_fetch_minmax.cc: New test.
* testsuite/29_atomics/atomic_ref/pointer_fetch_minmax.cc: New
test.
This patch fixes the wrong code regression PR target/124194 on x86_64.
The target implements a pre-reload splitter that recognizes that
integer vector comparisons can be evaluated at compile-time when the
operands being compared are the same (register). The (admittedly rare)
case when the comparison operator is always-true, was incorrectly
handled and folded to false instead of the correct value true.
2025-02-26 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
PR target/124194
* config/i386/sse.md (*<avx512>_cmp<mode>3_dup_op): Also return
CONSTM1_RTX for the case cmp_imm == 7 (predicate TRUE).
gcc/testsuite/ChangeLog
PR target/124194
* gcc.target/i386/pr124194.c: New test case.
Roger Sayle [Thu, 26 Feb 2026 08:03:25 +0000 (08:03 +0000)]
PR c/119651: Fix some unexpected error_mark_node ICEs.
This patch resolves PR c/119651 and PR c/123472 P4 regressions.
2026-02-26 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
PR c/119651
PR c/123472
* fold-const.cc (tree_nonzero_bits): Rename the original as a
static function taking an additional precision parameter. Make
this implementation robust to error_mark_node. Preserve the
original API by checking for error_operand_p before invoking the
static helper function.
gcc/testsuite/ChangeLog
PR c/119651
PR c/123472
* gcc.dg/pr119651.c: New test case.
* gcc.dg/pr123472.c: Likewise.
H.J. Lu [Wed, 31 Dec 2025 23:14:57 +0000 (07:14 +0800)]
Add default_promote_function_mode_sign_extend
TARGET_PROMOTE_PROTOTYPES is an optimization, not an ABI requirement.
TARGET_PROMOTE_FUNCTION_MODE should be used for ABI requirement. Like
xtensa, mcore ABI requires sign extension of signed 8/16-bit integer
arguments to 32 bits and zero extension of unsigned integer 8/16-bit
arguments to 32 bits:
1. Rename xtensa_promote_function_mode to
default_promote_function_mode_sign_extend to sign-extend signed 8/16-bit
integer arguments to 32 bits and zero-extend of unsigned 8/16-bit
integer arguments to 32 bits.
2. Replace xtensa_promote_function_mode with
default_promote_function_mode_sign_extend.
3. Remove TARGET_PROMOTE_PROTOTYPES for mcore and define
TARGET_PROMOTE_FUNCTION_MODE with
default_promote_function_mode_sign_extend to properly extend 8/16-bit
arguments to 32 bits.
Targets with the same ABI requirement should define
TARGET_PROMOTE_FUNCTION_MODE with
default_promote_function_mode_sign_extend.
PR target/119979
PR target/120888
* gcc.target/xtensa/pr120888-1.c: Removed to ...
* gcc.dg/zero-extend.c: This. Enable for mcore and xtensa.
* gcc.target/xtensa/pr120888-2.c: Removed to ...
* gcc.dg/sign-extend.c: This. Enable for mcore and xtensa.
Jose E. Marchesi [Wed, 25 Feb 2026 23:43:03 +0000 (00:43 +0100)]
a68: handle Darwin's #1/NN archive members
In Darwin archives use an extension to encode the member names
off-header, in the first bytes of the contents. The name in the
header proper is then #1/NN... where NN... is an ascii-encoded number
in decimal with the length of the name, which is encoded right after
the header as part of the contents.
This patch fixes the Algol 68 module importing from archives in Darwin
by acknowledging this extension. Note that, for the moment, we don't
bother to fetch the actual member name. This can lead to poor
diagnostics, so we probably will fix that at some point.
Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
gcc/algol68/ChangeLog
* a68-imports-archive.cc (Archive_file): Handle Darwin #1/NN
archive members.
Philipp Tomsich [Mon, 23 Feb 2026 10:05:06 +0000 (11:05 +0100)]
avoid-store-forwarding: Fix sbitmap memory leak in process_store_forwarding
forwarded_bytes was allocated with sbitmap_alloc but never freed on any
of the function's return paths. Use auto_sbitmap instead, which calls
sbitmap_free in its destructor.
gcc/ChangeLog:
* avoid-store-forwarding.cc
(store_forwarding_analyzer::process_store_forwarding): Use
auto_sbitmap for forwarded_bytes to ensure it is freed on all
return paths.
Philipp Tomsich [Mon, 23 Feb 2026 11:11:07 +0000 (12:11 +0100)]
avoid-store-forwarding: Fix include order and drop cselib.h include
The header file included config.h, system.h, coretypes.h,
backend.h, and rtl.h directly, which is unconventional for GCC
headers. Strip those includes from the header and fix the include
order in the .cc file so that config.h comes first. Also remove
the unused cselib.h include.
gcc/ChangeLog:
* avoid-store-forwarding.cc: Move config.h before
avoid-store-forwarding.h; place avoid-store-forwarding.h
after rtl.h; remove unused cselib.h include.
* avoid-store-forwarding.h: Remove includes of config.h,
system.h, coretypes.h, backend.h, rtl.h.
fortran: Fix ICE in ALLOCATE of sub-objects with recursive types
The deep-copy wrapper generation for recursive allocatable array
components (PR121628) calls cgraph_node::add_new_function to register
the wrapper. During PARSING state, add_new_function calls
finalize_function which triggers ggc_collect(). This garbage
collection frees locally-computed tree nodes (COMPONENT_REFs etc.)
in caller stack frames of structure_alloc_comps that are not yet
attached to any GC-rooted structure, causing a segfault when those
nodes are subsequently accessed.
Use finalize_function with no_collect=true to skip the collection.
The GC will run at a safe point later.
PR fortran/124235
gcc/fortran/ChangeLog:
* trans-array.cc (generate_element_copy_wrapper): Use
cgraph_node::finalize_function with no_collect=true instead
of cgraph_node::add_new_function to avoid garbage collection
while caller frames hold unrooted tree nodes.
gcc/testsuite/ChangeLog:
* gfortran.dg/pr124235.f90: New test.
Signed-off-by: Christopher Albert <albert@tugraz.at>
bpf: Split expressions for proper CO-RE code generation
This patch corrects CO-RE generation for the cases where an expression
starts with a non-CO-RE access, but in the middle it requires to
generate CO-RE to correctly compute the access location.
It fixes it by splitting the expression into their CO-RE and non-CO-RE
counterparts. It performs this by walking gimple expressions, and for
each field access to which its type is a struct or union, it verifies if
both the types for the base and field are attributed similarly.
Otherwise, it splits the expression at this location by creating a
temporary variable and performing any required pointer conversions.
This smaller expressions are converted to CO-RE in the subsequent
gimple walker.
There is no way in GCC to distinguish nested struct/union definitions
from non-nested ones.
This patch simplifies code and enforces that all preserve_access_index
structs/unions would be attributed explicitly.
Previous approach was error prone as it would extend CO-RE accesses to
structures which would not be attributed.
All GCC BPF dejagnu passes tests:
# of expected passes 553
# of expected failures 6
gcc/ChangeLog:
PR target/120241
* config/bpf/core-builtins.cc
(is_attr_preserve_access): Correct for pointer types.
(maybe_get_base_for_field_expr, core_access_index_map,
core_access_clean, core_is_access_index, core_mark_as_access_index):
Remove.
(make_gimple_core_safe_access_index): Remove function.
(struct walker_data): New struct to pass data to tree walker.
(callback_should_do_core_access, should_do_core_access): Add
function to identify expressions that should not be converted to
CO-RE.
(core_make_builtins): Add callback tree walker function to
convert expressions to CO-RE.
(callback_find_next_split_location, core_should_split_expr,
find_next_split_location, gimple_core_early_split_expr): Add
function to split expressions in CO-RE and non-CO-RE
expressions.
(execute_lower_bpf_core): Adapt to new code.
* config/bpf/bpf.opt: Add option Wco-re.
* doc/invoke.texi: Add documentation for Wco-re.
Andrew Pinski [Sun, 22 Feb 2026 00:43:53 +0000 (16:43 -0800)]
fn-split: Move clobbers from the old exit bb to new call block after the call [PR110091]
After outlinining the bbs for function splitting, we move the clobbers that were in the
last bb to be after the newly calling function.
This allows for stack location sharing and more when the non split out part is inlined
into another function.
This also fixes some of the warnings about dangling-pointers because
the clobbers are now correctly handled while function splitting.
The testcases test for the cases where the dangling-pointers pointer
warnings would show up too.
Note only end of storage clobbers in this case.
Changes since v1:
* v2: Add comments and add a call to unlink_stmt_vdef/release_ssa_name.
Bootstrapped and tested on x86_64-linux-gnu.
PR tree-optimization/110091
gcc/ChangeLog:
* ipa-split.cc (split_function): Find the bb
which is used for return in the outlined function.
Move the clobbers that are at the end of that bb
to be after the new call.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/pr110091-3.c: New test.
* gcc.dg/tree-ssa/pr110091-4.c: New test.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Andrew Pinski [Sat, 21 Feb 2026 22:38:12 +0000 (14:38 -0800)]
fn-split: Insert new call after clobbers/debug stmt [PR110091]
So for function splitting when we outlined the function, we
should keep around the clobbers that were at the begining of
the bb which will be outlined. So change the last stmt
to where we split the bb for where the function call will be
to be after the clobbers.
Note we have to ignore the debug stmts here otherwise you would
get a debug comparison failure.
This also fixes some of the warnings about dangling-pointers because
the clobbers are now correctly handled while function splitting.
The testcases test for the cases where the dangling-pointers pointer
warnings would show up too.
Note only end of storage clobbers in this case.
Bootstrapped and tested on x86_64-linux-gnu.
PR tree-optimization/110091
gcc/ChangeLog:
* ipa-split.cc (split_function): Split after
the clobbers/debug stmts rather than after the labels.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/pr110091-1.c: New test.
* gcc.dg/tree-ssa/pr110091-2.c: New test.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
When TARGET_SALT is configured in the Xtensa ISA, a Boolean evaluation of
LT/GT[U] between address (GP) registers can be done in a single machine
instruction, making it easy to implement the spaceship operator by sub-
tracting one from the other result.
/* examples */
int test0(int a, int b) {
return a == b ? 0 : (a > b ? 1 : -1);
}
int test1(unsigned int a, unsigned int b) {
return a == b ? 0 : (a > b ? 1 : -1);
}
Marek Polacek [Thu, 19 Feb 2026 17:40:39 +0000 (12:40 -0500)]
c++/reflection: also walk BIND_EXPR_BODY
As discussed in
<https://gcc.gnu.org/pipermail/gcc-patches/2026-January/705756.html>,
we shouldn't walk BIND_EXPR_VARS in check_out_of_consteval_use_r, but
BIND_EXPR_BODY should still be walked.
The IF_STMT is there so that we don't emit bogus errors in "if consteval"
branches, as tested in expr12.C.
gcc/cp/ChangeLog:
* reflect.cc (check_out_of_consteval_use_r): Walk BIND_EXPR_BODY.
For IF_STMT_CONSTEVAL_P, only walk the ELSE_CLAUSE. For
IF_STMT_CONSTEXPR_P, only walk the THEN_ and ELSE_CLAUSE.
gcc/testsuite/ChangeLog:
* g++.dg/reflect/expr11.C: Test more if constexpr.
* g++.dg/reflect/expr12.C: Adjust test.
Richard Biener [Tue, 24 Feb 2026 08:53:00 +0000 (09:53 +0100)]
target/120234 - adjust vector construction costs
The following allows vectorizing the gcc.target/i386/pr111023*.c
testcases again with -m32 -msse2 by ensuring we see through a cast
when looking for vector extract sources during costing of vector construction.
This, together with the forwprop fix fixes the regression on those testcases.
PR target/120234
* config/i386/i386.cc (ix86_vector_costs::add_stmt_cost):
For constructor elements always look through a conversion.
Rewrite load and vector extraction matching to be more obvious.
Allow arbitrary conversions from the vector extract to elide
costing of a gpr<->xmm move.
Iain Sandoe [Tue, 24 Feb 2026 11:44:27 +0000 (11:44 +0000)]
libiberty, Darwin: Fix handling of file offsets.
In the case where a Mach-O object is embedded inside some container
(e.g. an archive) we must account the offset from the start of that
container when reading. In most cases, this has been done correctly.
However, we were missing the case for reading segment data. This
only showed up once we tried using archives (since regular Mach-O
objects start at the begining of the file).
Fixed thus.
libiberty/ChangeLog:
* simple-object-mach-o.c
(simple_object_mach_o_segment): Account for the offset of
this Mach-O object from the start of any container.
Andrew Pinski [Tue, 27 Jan 2026 20:19:13 +0000 (12:19 -0800)]
aarch64: early-ra: Fix handling of multi-register allocation with clobbers [PR123285]
So the problem here is while forming chains, we don't process hard register
conflicts (and ABI based ones) for allocnos which are already part of a chain.
This means sometimes we allocate a register to a color which might be clobbered
over is live range.
Processing clobbers for all allocnos don't work while forming a chain does
not work as the chain's front allocnos' candidates does not get updated.
So we need to the processing of clobbers (and ABI clobbers) before starting
to form the chains.
Changes since v1:
* v2: remove accidental hack which was there just for testing.
* v3: Move the copying of the shared part to new earlier loop too.
Fix small white space issue.
Bootstrappd and tested on aarch64-linux-gnu.
PR target/123285
gcc/ChangeLog:
* config/aarch64/aarch64-early-ra.cc (early_ra::form_chains): Process clobbers
and ABI clobbers before starting to form the chain.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/pr123285-1.c: New test.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Jonathan Yong [Tue, 17 Feb 2026 02:08:55 +0000 (02:08 +0000)]
gcc.dg/plugin: fix spurious llp64 warnings
Fixes compile tests with mingw-w64.
gcc/testsuite/ChangeLog:
* gcc.dg/plugin/taint-pr112850-precise.c:
(__kernel_ulong_t): Change unsigned long to __UINTPTR_TYPE__.
(__kernel_size_t): Change __kernel_ulong_t to __kernel_size_t.
(copy_from_user): Change unsigned long n to size_t n.
(snd_rawmidi_ioctl): Change unsigned long arg to uintptr_t arg.
* gcc.dg/plugin/taint-pr112850-too-complex.c: Ditto.
* gcc.dg/plugin/taint-pr112850-unsanitized.c: Ditto.
* gcc.dg/plugin/taint-pr112850.c: Ditto.
Sandra Loosemore [Sat, 21 Feb 2026 01:04:14 +0000 (01:04 +0000)]
doc: Fix the attribute urlifier after changes to indexing [PR88472]
Recent patches to the GCC manual have merged previously-separate
sections for function, variable, type, and statement attributes, and
created a separate index for attributes instead of putting them in the
concept index. This reorganization broke the attribute URLifier and its
self-tests. I've fixed it up and regenerated attr-urls.def.
gcc/ChangeLog
PR other/88472
* Makefile.in (ATTR_URLS_HTML_DEPS): Point at new index file.
* attr-urls.def: Regenerated.
* gcc-attribute-urlifier.cc (test_attribute_urlifier): Adjust
URLs to match formatting in the new index.
* regenerate-attr-urls.py (parse_html_line_attribute_index):
Update pattern to match formatting in the new combined index.
Don't segregate entries into separate function/variable/etc
arrays.
(INDEX_REL_PATH): Point at the new index file.
(class TestParsingIndex): Update patterns in self-tests to match
the current formatting.
Sandra Loosemore [Thu, 19 Feb 2026 18:26:32 +0000 (18:26 +0000)]
doc: Consolidate documentation for naked attribute [PR88472]
This attribute has been documented similarly in the sections for 12
different targets. I think it's time to promote this to a common
attribute and document it only once with a warning that it's not
supported everywhere.
gcc/ChangeLog
PR other/88472
* doc/extend.texi (Common Attributes): Document the "naked"
attribute here.
(ARC Attributes): Delete entry for "naked".
(ARM Attributes): Likewise.
(AVR Attributes): Likewise.
(BPF Attributes): Likewise.
(C-SKY Attributes): Likewise.
(MCORE Attributes): Delete entire section since "naked" was
the only thing listed.
(MSP430 Attributes): Delete entry for "naked".
(NDS32 Attributes): Likewise.
(RISC-V Attributes): Likewise.
(RL78 Attributes): Likewise.
(RX Attributes): Likewise.
(x86 Attributes): Likewise.
gcc/ChangeLog
PR other/88472
* doc/extend.texi (Common Attributes): Consolidate documentation
for "cold" and "hot" attributes, including the C++-specific
behavior.
(C++ Attributes): Likewise, just point to the main entry.
Sandra Loosemore [Thu, 19 Feb 2026 17:15:05 +0000 (17:15 +0000)]
doc, riscv: Tidy RISC-V attribute documentation
gcc/ChangeLog
* doc/extend.texi (RISC-V Attributes): Format and index options
for the "target" attribute consistently with the documentation
for other back ends.
Sandra Loosemore [Mon, 16 Feb 2026 23:48:24 +0000 (23:48 +0000)]
doc, loongarch: Clean up LoongArch attribute documentation
This section of the manual was in need of general tidying for grammar
and markup, as well as correcting confusion resulting from using "attribute"
to refer both to the target attribute and its individual arguments. I also
added LoongArch to the lists of targets supporting target_clones and
target_version in other sections of the manual.
gcc/ChangeLog
* doc/extend.texi (Common Attributes): Add LoongArch to lists of
targets supporting target_clones and target_version.
(LoongArch Attributes): Copy-edit for grammar and markup. Wrap
excessively long lines. Rearrange the introductory material for
the target attribute. Correct index entries for target attribute
options.
(Function Multiversioning): Add LoongArch to list of targets
supporting this feature. Fix nearby typo.
The presentation in this section previously documented and referred to
the options that could be specified in the "target" attribute string
as if they were attributes themselves, which was quite confusing. I've
straightened out the terminology and reorganized the text to put the
introductory material and examples first instead of at the end, and fixed
the markup and formatting to match what's already used for other targets
that support this attribute.
gcc/ChangeLog
* doc/extend.texi (AArch64 Attributes): Reorganize material in this
section, correct terminology and formatting.
Sandra Loosemore [Thu, 19 Feb 2026 05:37:27 +0000 (05:37 +0000)]
doc: General copy-editing in Attributes section
This patch fixes a number of copy-editing issues in the attributes
documentation that are not specifically related to the restructuring
of this section for PR88472. This includes typos, grammatical errors
like inappropriate verb tenses, switching from passive to active
voice, missing or incorrect markup, missing @noindent after examples,
hbox overflows in the PDF manual, and so on.
gcc/ChangeLog
* doc/extend.texi (Attributes): General copy-editing.
(C++ Attributes): Likewise.
Sandra Loosemore [Sat, 14 Feb 2026 22:46:54 +0000 (22:46 +0000)]
doc: Tag attributes with what they apply to [PR88472]
After merging the lists of function/variable/type/etc attributes, it
wasn't always clear what particular attributes applied to without
reading through the description. This patch adopts the practice from
the C standard of starting each attribute section with a paragraph
describing what it can apply to. In many cases this just involved
adding a paragraph break after the first sentence of the description;
others required a bit of rephrasing too.
gcc/ChangeLog
PR other/88472
* doc/extend.texi (Attributes): Start each attribute's
documentation with a short paragraph describing what it applies to.
(C++ Attributes): Likewise.
Sandra Loosemore [Wed, 18 Feb 2026 01:05:31 +0000 (01:05 +0000)]
doc: Merge function, variable, type, and statement attribute sections [PR88472]
The previous organization of the Attributes section of the manual was like
Attributes
Function Attributes
Common Function Attributes
+ various subsections by target
Variable Attributes
Common Variable Attributes
+ various subsections by target
Type Attributes
likewise
Label Attributes
Enumerator Attributes
Statement Attributes
GNU Attribute Syntax
There was a bunch of introductory text duplicated at the top of the
sections for each kind of attribute, and many attributes were listed
in multiple places -- particularly linker-related attributes like
"section" that apply to both functions and variables with the same
semantics.
The material has been reorganized by merging the corresponding
sections for each kind of attribute:
Attributes
Common Attributes
Target-Specific Attributes
+ various subsections by target
GNU Attribute Syntax
Most of the previous boilerplate introductory text for each subsection
has been discarded since it's been replaced by a general introduction
in the top-level Attributes section in a previous patch of this
series. The duplicate entries for different kinds of attributes of
the same name have been merged and in some cases I reworded things to
provide explicit context about what entities the attribute applies to.
gcc/ChangeLog
PR other/88472
* doc/extend.texi (Attributes): Merge respective subsections of
Function Attributes, Variable Attributes, Type Attributes,
Label Attributes, Enumerator Attributes, and Statement Attributes
into new sections Common Attributes and Target-Specific Attributes.
Fix cross-references.
* doc/invoke.texi: Fix cross-references.
* doc/trouble.texi: Likewise.
doc: Rewrite/reorganize discussion of attribute syntax [PR102397]
Now that GCC's default language dialect for both C and C++ includes
support for the standard attribute syntax, we should encourage users
to prefer that instead of the legacy GNU syntax, while recognizing
that there is a lot of code out there using the latter. This patch
updates the discussion in the introduction to the Attributes section
with examples showing attribute placement in both syntaxes and focuses
the syntax section on the GNU syntax only. (Users can read the C/C++
standards, programming books or tutorials, etc to learn about the
standard syntax, so we don't need to document that in detail.)
gcc/ChangeLog
PR c++/102397
* doc/extend.texi (Attributes): Rewrite and expand discussion
of standard vs legacy syntax, with several examples.
(Attribute Syntax): Rename section to...
(GNU Attribute Syntax): ...this. Prune discussion of standard
attribute syntax. Fix cross-references.
David Malcolm [Tue, 24 Feb 2026 22:16:59 +0000 (17:16 -0500)]
analyzer: fix ICE on (X + (-X)) for vectors [PR124188]
gcc/analyzer/ChangeLog:
PR analyzer/124188
* region-model-manager.cc
(region_model_manager::maybe_fold_binop): Don't attempt to fold
X + (-X) to zero for vector types.
gcc/testsuite/ChangeLog:
PR analyzer/124188
* c-c++-common/analyzer/vector-ice-pr124188.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
David Malcolm [Tue, 24 Feb 2026 22:16:58 +0000 (17:16 -0500)]
analyzer: fix ICE on division by zero [PR124195]
gcc/analyzer/ChangeLog:
PR analyzer/124195
* region-model-manager.cc
(region_model_manager::maybe_fold_binop): Bulletproof against
division by zero by returning "unknown".
* region-model.cc (region_model::get_gassign_result): Bail out for
division by zero.
* svalue.cc (svalue::maybe_get_value_range): Rename to...
(svalue::maybe_get_value_range_1): ...this.
(constant_svalue::maybe_get_value_range): Rename to...
(constant_svalue::maybe_get_value_range_1): ...this.
(unknown_svalue::maybe_get_value_range): Rename to...
(unknown_svalue::maybe_get_value_range_1): ...this.
(unaryop_svalue::maybe_get_value_range): Rename to...
(unaryop_svalue::maybe_get_value_range_1): ...this.
(binop_svalue::maybe_get_value_range): Rename to...
(binop_svalue::maybe_get_value_range_1): ...this.
* svalue.h (svalue::maybe_get_value_range): Reimplement inline,
asserting that if we get a result it is not undefined_p. Use
maybe_get_value_range_1 for the vfunc.
(svalue::maybe_get_value_range_1): Rename from above.
(constant_svalue::maybe_get_value_range): Rename to...
(constant_svalue::maybe_get_value_range_1): ...this.
(unknown_svalue::maybe_get_value_range): Rename to...
(unknown_svalue::maybe_get_value_range_1): ...this.
(unaryop_svalue::maybe_get_value_range): Rename to...
(unaryop_svalue::maybe_get_value_range_1): ...this.
(binop_svalue::maybe_get_value_range): Rename to...
(binop_svalue::maybe_get_value_range_1): ...this.
gcc/testsuite/ChangeLog:
PR analyzer/124195
* c-c++-common/analyzer/divide-by-zero-1.c: New test.
* c-c++-common/analyzer/divide-by-zero-pr124195-2.c: New test.
* gcc.dg/analyzer/divide-by-zero-pr124195-1.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
where the clobber constraint for the third alternative is 'X'.
This is supposed to express that we accept anything because we don't
need the scratch for that alternative anyway.
However, in mask_gather_load_run-11.c we create a mem
Robin Dapp [Wed, 18 Feb 2026 11:10:13 +0000 (12:10 +0100)]
RISC-V: theadvector specifics for vec_init and vec_extract. [PR124147]
The mask-mode vec_init and vec_extract expanders assume that we can
create QImode vectors with the same number of units as the mask mode
has. XTheadVector does not have fractional-LMUL modes and we ICE when
trying to expand the actual insns.
An obvioius solution would be to simply disable the autovec expanders for
TARGET_XTHEADVECTOR but exactly these optab/mode combination has no fallback
in the common expansion code. That's a known problem and should be fixed
separately in extract_bit_field_1.
For now, though, we do not need to use small modes and can go with full
vectors instead. The excess elements don't matter.
To that end, this patch uses paradoxical subregs on the source (for
vec_extract) and on the destination (for vec_init), leaving the
remaining elements undefined.
In order to obtain the right "full vector" I needed to adjust
get_m1_mode slightly. By default it returns a VLA mode so when
introducing a subreg like above we can have
(subreg:full_vector_mode (reg:small_vls_vector_mode) 0)
where full_vector_mode is a VLA mode and small_vls_vector_mode is a VLS
mode. This won't be a valid subreg so the patch adds a VLS_P
argument to get_m1_mode that returns a full VLS vector mode.
Regtested on rv64gcv_zvl512b. As I didn't have theadvector hardware
available I made the new code paths unconditional (so they are active
for regular RVV) and re-tested.
PR target/124147
gcc/ChangeLog:
* config/riscv/autovec.md: Work around fractional-LMUL modes for
TARGET_XTHEADVECTOR.
* config/riscv/riscv-protos.h (get_m1_mode): Export.
* config/riscv/riscv-v.cc (get_m1_mode): Allow to get a VLS m1
vector.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/xtheadvector/pr124147.c: New test.
Robin Dapp [Wed, 11 Feb 2026 15:32:01 +0000 (16:32 +0100)]
lra: Perform cycle detection for moves with clobber. [PR123381]
In the PR code we have the somewhat rare case that we need to reload
a vector subreg of a scalar register, (subreg:V2HI (reg:DI)).
What complicates things is that the test is compiled with
-mrvv-vector-bits=zvl, so VLS-only mode.
Unfortunately, we can still get VLA-named modes that are actually VLS
modes (i.e. that have a constant number of units).
Here, lra recognizes cycle danger, quickly switches to the memory
alternative and the resulting code is as expected - we perform a vector
load from that memory the DImode reg was spilled to.
The extra clobber here is an optimization: For modes smaller than a full
register we want to store the actual size, rather than always the full
vector size. If that mode size happens to exceed 32, instead of using an
immediate we need to move it to a register so vsetvl can consume it.
As the second mov insn above has three operands lra never checks for cycle
danger and promptly creates a cycle :) This patch loosens the conditions on
the cycle check by allowing a third operand that is a clobber.
PR rtl-optimization/123381
gcc/ChangeLog:
* lra-constraints.cc (process_alt_operands): Detect cycles in
three-operand moves with clobber.
(curr_insn_transform): Don't write back a scratch operand.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/pr123381.c: New test.
Piyush Raj [Tue, 24 Feb 2026 20:17:53 +0000 (01:47 +0530)]
contrib: add bpf-vmtest-tool to test BPF programs
This patch adds the bpf-vmtest-tool subdirectory under contrib which tests
BPF programs under a live kernel using a QEMU VM. It can build the
specified kernel version with eBPF support enabled
and stores it under $VMTEST_DIR
It can test BPF C source files and precompiled BPF object files against
the kernel verifier for errors.
When a BPF program is rejected by the kernel verifier,
the verifier logs are displayed.
The script uses vmtest (https://github.com/danobi/vmtest) to boot
the VM and run the program. By default, it uses the host's root
("/") as the VM rootfs via the 9p filesystem, so only the kernel is
replaced during testing.
Tested with Python 3.9 and above.
contrib/ChangeLog:
* bpf-vmtest-tool/README: New file.
* bpf-vmtest-tool/bpf.py: New file.
* bpf-vmtest-tool/config.py: New file.
* bpf-vmtest-tool/kernel.py: New file.
* bpf-vmtest-tool/main.py: New file.
* bpf-vmtest-tool/pyproject.toml: New file.
* bpf-vmtest-tool/tests/test_cli.py: New file.
* bpf-vmtest-tool/utils.py: New file.
* bpf-vmtest-tool/vm.py: New file.
Wilco Dijkstra [Thu, 22 Jan 2026 12:28:36 +0000 (12:28 +0000)]
AArch64: Use anchors for vector constants [PR 121240]
Enable anchors for vector constants - like FP, expand vector constants early
and place them in the constdata section. Avoid unnecessary loads by expanding
simple cases using DUP. Performance on SPECFP2017 is ~0.3% better, codesize
increases by 0.05% due to extra const data.
Eric Botcazou [Tue, 24 Feb 2026 16:42:24 +0000 (17:42 +0100)]
Ada: Fix crash on iterated element association for Ordered_Maps
This is a regression present on the mainline and 15 branch: the compiler
crashes on an iterated element association for Ordered_Maps or similar
container types, because the type of the loop variable is not computed.
gcc/ada/
PR ada/124224
* sem_aggr.adb (Resolve_Container_Aggregate): Minor tweaks.
(Resolve_Iterated_Association): Compute Typ on all paths.
gcc/testsuite/
* gnat.dg/specs/aggr12.ads: New test.
Martin Jambor [Tue, 24 Feb 2026 16:32:32 +0000 (17:32 +0100)]
contrib: Skip Clang -Wreturn-type-c-linkage in rust-fmt.h
When compiling GCC Rust FE, clang gives the following warning:
/home/worker/buildworker/tiber-gcc-clang/build/gcc/rust/ast/rust-fmt.h:403:15: warning: 'collect_pieces' has C-linkage specified, but returns incomplete type 'FFIVec<Piece>' which could be incompatible with C [-Wreturn-type-c-linkage]
/home/worker/buildworker/tiber-gcc-clang/build/gcc/rust/ast/rust-fmt.h:406:15: warning: 'clone_pieces' has C-linkage specified, but returns incomplete type 'FFIVec<Piece>' which could be incompatible with C [-Wreturn-type-c-linkage]
I have raised this with GCC Rust folk on their Zulip chat and we
agreed the warning should be filtered out, at least fornow. It is
tracked as https://github.com/Rust-GCC/gccrs/issues/4441 so it is not
forgotten but even there it seems that the outcome may be we'd just
ignore the warning forever, as far as I can tell.
contrib/ChangeLog:
2026-02-24 Martin Jambor <mjambor@suse.cz>
* filter-clang-warnings.py (skip_warning): Skip warning
-Wreturn-type-c-linkage in rust/ast/rust-fmt.h. Fix indentation of
the entry for libiberty/sha1.c.
Robert Dubner [Tue, 24 Feb 2026 14:56:01 +0000 (09:56 -0500)]
cobol: Increase PIC X(MAX) from 8192 to 2^31.
Up until these changes, temporary intermediate alphanumeric string
variables have been allocated on the stack. With the design change to
a larger limit, that's no longer practical. Such variables are now
placed on the heap, and we now have to take pains to free() that memory
when we are done with it.
gcc/cobol/ChangeLog:
* gcobc: Adjust how -fPIC is applied, and other refinements.
* gcobol.1: Documentation.
* genapi.cc (parser_statement_end): New function. Deallocates
temp char strings from the heap.
(initialize_variable_internal): Ignore temp char strings.
(compare_binary_binary): Formatting.
(parser_end_program): Formatting.
(parser_init_list): Formatting.
(parser_exit_program): Formatting.
(program_end_stuff): Formatting.
(parser_exit): Formatting.
(parser_perform_conditional): Formatting.
(perform_outofline_before_until): Formatting.
(parser_file_add): Formatting.
(mh_source_is_literalA): Formatting.
(psa_new_var_decl): Make cblc_field_t for intermediate_e
alphanumerics program-static.
(parser_symbol_add): Eliminate unnecessary code when
type!=FldConditional; change handling of intermediate_e for
FldAlphanumerics.
* genapi.h (parser_end_program): New declaration.
(parser_exit): Formatting.
(parser_exit_program): Formatting.
(parser_statement_end): New declaration.
* lexio.cc (parse_replace_pairs): Change CDF handling.
(cdftext::lex_open): Likewise.
(cdftext::process_file): Likewise.
* parse.y: Changes to MAXIMUM_ALPHA_LENGTH; refine return value
types for various intrinsic functions; some CDF handling.
* parse_ante.h (MAXLENGTH_FORMATTED_DATE): Eliminate constant.
(MAXLENGTH_FORMATTED_TIME): Likewise.
(MAXLENGTH_CALENDAR_DATE): Likewise.
(MAXLENGTH_FORMATTED_DATETIME): Likewise.
(new_alphanumeric): No longer takes a capacity.
(intrinsic_return_field): New declaration.
(struct ffi_args_t): Changed debug message.
(is_among): New declaration.
* parse_util.h (intrinsic_return_field): New function. Works with
the modified function_descrs[] table.
* scan.l: Modified scanning.
* scan_ante.h (class input_file_status_t): Likewise.
(verify_ws): Likewise.
(is_refmod): Likewise.
* symbols.cc (symbols_update): Improved comment about a debug
message.
(symbol_temporaries): New function for temporaries on the heap that
will have to be deallocated.
(symbol_temporary_alphanumerics): Likewise.
(new_temporary_impl): Eliminate MAXIMUM_ALPHA_LENGTH from template.
(new_alphanumeric): Eliminate capacity as a parameter.
* symbols.h (cbl_dialect_str): Formatting.
(MAXIMUM_ALPHA_LENGTH): Change comment and value.
(IBM_MAXIMUM_ALPHA_LENGTH): Put parentheses around "size_t(1)<<31".
(symbol_temporaries): New declaration.
(symbol_temporary_alphanumerics): New declaration.
(struct function_descr_t): New comment on ret_type.
(new_alphanumeric): New declaration.
* util.cc (class cdf_directives_t): CDF processing.
(cobol_set_indicator_column): Likewise.
(cdf_push_source_format): Likewise.
(cdf_pop_source_format): Likewise.
(parent_names): Likewise.
(cobol_filename): Likewise.
(cobol_lineno): Likewise.
(cobol_filename_restore): Likewise.
libgcobol/ChangeLog:
* intrinsic.cc (string_to_dest): Move call to
__gg__adjust_dest_size().
(__gg__char): Likewise.
(__gg__current_date): Likewise.
(__gg__formatted_current_date): Likewise.
(__gg__formatted_date): Likewise.
(__gg__formatted_datetime): Likewise.
(__gg__formatted_time): Likewise.
(change_case): Likewise.
(__gg__trim): Likewise; fix memory leak.
(__gg__reverse): Move call to __gg__adjust_dest_size().
(__gg__locale_compare): Likewise
(__gg__locale_date): Likewise
(__gg__locale_time): Likewise
(__gg__locale_time_from_seconds): Likewise
* libgcobol.cc (format_for_display_internal): Make the results of
intermediate FldNumericBin5 look nice to a human.
(init_var_both): Move call to __gg__adjust_dest_size().
(__gg__get_argc): Move call to __gg__adjust_dest_size().
(__gg__get_argv): Move call to __gg__adjust_dest_size().
(__gg__get_command_line): Move call to __gg__adjust_dest_size().
(__gg__adjust_dest_size): Properly handle intermediate_e
allocations.
(__gg__adjust_encoding): Move call to __gg__adjust_dest_size().
(__gg__module_name): Move call to __gg__adjust_dest_size().
(__gg__refer_from_string): Move call to __gg__adjust_dest_size().
(__gg__refer_from_psz): Move call to __gg__adjust_dest_size().
(__gg__convert): Move call to __gg__adjust_dest_size().
* posix/shim/lseek.cc: Changes to extended functions.
* posix/shim/open.cc (posix_opent): Likewise.
(posix_open): Likewise.
* posix/udf/posix-open.cbl: Likewise.
* posix/udf/posix-read.cbl: Likewise.
* posix/udf/posix-write.cbl: Likewise.
* xmlparse.cc (sayso): Change to debug message.
* posix/udf/posix-ftruncate.cbl: New file.
The following fixes the sign conversion check added to properly check
whether the BIT_FIELD_REF does a sign conversion on the original
vector elements instead of a conversion to the target constructor
element type. This avoids disabling all unpacking conversions.
Martin Jambor [Tue, 24 Feb 2026 10:43:32 +0000 (11:43 +0100)]
ipa-cp: Make ipcp_val_replacement_ok_p fail better
This is a small improvement to a function which verifies that the
polymorphic context IPA-CP has decided to clone for is indeed among
the known contexts collected for the specialized node. When no
context has been collected and the vector is empty, like in the case
of PR123629, the function will return false rather than ICE because of
an out of bounds vector access. That in turn also results in an
ICE, but hopefully the error will be somewhat clearer.
gcc/ChangeLog:
2026-02-23 Martin Jambor <mjambor@suse.cz>
PR ipa/123629
* ipa-cp.cc (ipcp_val_replacement_ok_p): Also verify that the
vector of known contexts has sufficient length.
Fortran: Fix diagnostic for ambiguous pointer function assignment [PR80012]
The error message for an ambiguous pointer function assignment contained a
FIXME and an embedded newline that the diagnostics printer does not handle.
Split the single gfc_error call into a gfc_error for the main diagnostic
and an inform note for the F2008 explanation, wrapped in an
auto_diagnostic_group.
PR fortran/80012
gcc/fortran/ChangeLog:
* symbol.cc (gfc_add_procedure): Split error into gfc_error and
inform using auto_diagnostic_group.
The fix for PR120505 introduced two test failures on some configurations.
This patch update the scan dump pattern in map-subarray-4.f90 to allow for
differing pointer sizes, and disable map-subarray-16.f90 when no offload device
is available.
PR fortran/120505
libgomp/ChangeLog:
* testsuite/libgomp.fortran/map-subarray-16.f90: Enable test only for
offload device.
gcc/testsuite/ChangeLog:
* gfortran.dg/gomp/map-subarray-4.f90: Update scan dumps for -m32.
Sandra Loosemore [Mon, 23 Feb 2026 16:10:01 +0000 (16:10 +0000)]
amdgcn: prefer scalar ALU instructions over vector
This patch fixes a performance regression that crept in with commit gcc-16-2237-g0eee2dd2865 ("Don't clobber VCC if we don't need to").
Removing the clobber from vector-register ALU insn pattern
alternatives seems to make LRA think those alternatives are less
costly than the scalar-register alternatives, which do need the
clobber, resulting in extra move instructions instead.
In this patch I've adjusted all the ALU patterns (not just the ones
modified by the above-mentioned commit) where the scalar-register
alternatives clobber and vector-register alternatives don't, to
slightly disparage the latter using the "?" constraint modifier.
I also fixed a related issue: the comment on addptrdi3 says the
scalar-register alternative is preferred, but it was listed after the
vector alternative, so other things being equal it would still prefer
the vector expansion. I've not changed the constraints, but simply
flipped the order of the alternatives.
Thanks to Tobias Burnus for identifying the commit that caused the
performance regression, Andrew Stubbs for making the connection between
clobbers and LRA costs, and Arsen Arsenović for setting up the benchmark
scripting I used to compare results.
gcc/ChangeLog
* config/gcn/gcn.md (addsi3): Disparage vector alternative.
(addptrdi3): Reverse order of vector and scalar alternatives
to prefer the latter.
(subsi3): Disparage vector alternatives.
(mulsi3): Likewise.
(muldi3): Likewise.
(bitunop <expander>si2): Likewise.
(vec_and_scalar_com <expander>si3): Likewise.
(vec_and_scalar_nocom <expander>si3): Likewise.
(one_cmpldi2): Likewise.
(vec_and_scalar64_com <expander>di3): Likwise.
(vec_and_scalar64_nocom <expander>di3): Likwise.
Marek Polacek [Thu, 19 Feb 2026 15:51:32 +0000 (10:51 -0500)]
c++/reflection: splices and passing ctx to finish_id_expr
In <https://gcc.gnu.org/pipermail/gcc-patches/2026-January/705175.html>
(bottom of the message) we discussed not passing ctx to finish_id_expression
so that we can get rid of the _deferring_access_checks calls.
We can avoid passing context to finish_id_expression but we can't
completely avoid the _deferring_access_checks calls, because for
address_p we need to call build_offset_ref which needs it.
gcc/cp/ChangeLog:
* parser.cc (cp_parser_splice_expression): For dependent splices return
earlier. Refactor. For address_p, build an OFFSET_REF. Don't pass
context to finish_id_expression.
* semantics.cc (finish_id_expression_1): Adjust an assert to also check
flag_reflection.
Marek Polacek [Tue, 17 Feb 2026 22:08:52 +0000 (17:08 -0500)]
c++/reflection: ICE with missing OVERLOAD [PR124150]
A function template is supposed to be wrapped in an OVERLOAD. Since
in certain cases like members_of it is not, splice makes sure to add
the OVERLOAD if needed. But it wasn't looking into TEMPLATE_ID_EXPRs
and so we ended up with a "naked" TEMPLATE_DECL and crashed.
We can add the missing OVERLOAD in eval_substitute.
PR c++/124150
gcc/cp/ChangeLog:
* reflect.cc (eval_substitute): Add an OVERLOAD around
a DECL_FUNCTION_TEMPLATE_P.
Marek Polacek [Thu, 19 Feb 2026 19:47:26 +0000 (14:47 -0500)]
c++/reflection: members_of and friend class [PR123641]
The assert in this test currently doesn't pass because .size () is 3, due to
{A, B, B} found in N, but it should only be {A, B}, because we should
skip the hidden "void N::B()".
PR c++/123641
gcc/cp/ChangeLog:
* name-lookup.cc: Move STAT_* and MAYBE_STAT_* macros from here to...
* name-lookup.h: ...here.
* reflect.cc (namespace_members_of): Use them. Skip STAT_TYPE_HIDDEN_P.
Consider the following code, assuming tiles is allocatable:
type t
integer, allocatable :: den1(:,:), den2(:,:)
end type t
[...]
!$omp target enter data map(var%tiles(1)%den2, var%tiles(1)%den1)
r16-5789-g05c2ad4a2e7104 allowed mapping several components from the same
allocatable derived type, provided they are in the right order in user code.
This patch relaxes this constraint by computing offsets and sorting to-be-mapped
components at gimplification time.
PR fortran/120505
gcc/ChangeLog:
* gimplify.cc (omp_accumulate_sibling_list): When the containing struct
is a Fortran array descriptor, sort mapped components by offset.
libgomp/ChangeLog:
* testsuite/libgomp.fortran/map-subarray-12.f90: New test.
Consider the following OMP directive, assuming tiles is allocatable:
!$omp target enter data &
!$omp map(to: chunk%tiles(1)%field%density0) &
!$omp map(to: chunk%left_rcv_buffer)
libgomp reports an illegal memory access error at runtime. This is because
density0 is referenced through tiles, which requires its descriptor to be mapped
along its content.
This patch ensures that all such intervening allocatables in a reference chain
are properly mapped. For the above example, the frontend has to create the
following three additional map clauses:
(1) is required by the gimplifier for attaching but will be removed at the end
of the pass; the inner component is explicitly to-mapped elsewhere. (2) ensures
that the array descriptor will be available at runtime to compute offsets and
strides in various dimensions. The gimplifier will turn (3) into a regular
attach of the data pointer and compute the bias.
PR fortran/120505
gcc/fortran/ChangeLog:
* trans-openmp.cc (gfc_map_array_descriptor): New function.
(gfc_trans_omp_clauses): Emit map clauses for intermediate array
descriptors.
gcc/ChangeLog:
* gimplify.cc (omp_mapped_by_containing_struct): Handle Fortran array
descriptors.
(omp_build_struct_sibling_lists): Allow attach_detach bias to be
adjusted on non-target regions.
(gimplify_adjust_omp_clauses): Remove GIMPLE-only nodes.
* tree-pretty-print.cc (dump_omp_clause): Handle
OMP_CLAUSE_MAP_SIZE_NEEDS_ADJUSTMENT and OMP_CLAUSE_MAP_GIMPLE_ONLY.
* tree.h (OMP_CLAUSE_MAP_SIZE_NEEDS_ADJUSTMENT,
OMP_CLAUSE_MAP_GIMPLE_ONLY): Define.
libgomp/ChangeLog:
* testsuite/libgomp.fortran/map-subarray-11.f90: New test.
* testsuite/libgomp.fortran/map-subarray-13.f90: New test.
* testsuite/libgomp.fortran/map-subarray-14.f90: New test.
* testsuite/libgomp.fortran/map-subarray-15.f90: New test.
* testsuite/libgomp.fortran/map-subarray-16.f90: New test.
* testsuite/libgomp.fortran/map-alloc-present-2.f90: New file.
gcc/testsuite/ChangeLog:
* gfortran.dg/gomp/map-subarray-3.f90: New test.
* gfortran.dg/gomp/map-subarray-5.f90: New test.
Tomasz Kamiński [Thu, 19 Feb 2026 12:53:01 +0000 (13:53 +0100)]
libstdc++: Harmonize mdspan operator[] and at methods.
This patch changes the implementation of operator[], to follow similar
pattern as at, where we normalize argument types and forward to single
overload. The conversion now uses __mdspan::__index_type_cast, instead
of static_assert. This introduces asserts assuring that conversion is
is value preserving.
Finally, __is_multi_index is implemented as local lambda, avoiding
the need to create a local array with copies of the arguments.
libstdc++-v3/ChangeLog:
* include/std/mdspan (__mdspan::__is_multi_index): Removed,
replaced with local lambda in mdspan::operator[].
(__mdspan::operator[]): Implement in terms of single overload
accepting index_type. Use __mdspan::__index_type_cast for type
conversion.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
Tomasz Kamiński [Thu, 19 Feb 2026 12:14:16 +0000 (13:14 +0100)]
libstdc++: Implement mdspan::at member functions from P3383R3.
This patch implements P3383R3: mdspan.at().
The mdspan::at cast only non-integral types to the index_type, before
performing the checks. This allows to detect negative value of arguments,
even if the index type is unsigned, and other values that would overflow
index_type.
libstdc++-v3/ChangeLog:
* include/std/mdspan (mdspan::at, mdspan::__index_int_t):
Define.
* testsuite/23_containers/mdspan/at.cc: New test.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
Alice Carlotti [Sun, 16 Nov 2025 05:05:30 +0000 (05:05 +0000)]
aarch64: Change default -march for SME tests
The current fallback option -march=armv9-a+sme pulls in an SVE2
dependency that isn't need in most tests. Switch to -march=armv8-a+sme
so that we test SME without SVE enabled.
gcc/testsuite/ChangeLog:
* g++.target/aarch64/sme/aarch64-sme-acle-asm.exp: Use
-march=armv8-a+sme when SME isn't already enabled.
* g++.target/aarch64/sme/aarch64-sme.exp: Ditto.
* g++.target/aarch64/sme2/aarch64-sme2-acle-asm.exp: Ditto.
* gcc.target/aarch64/sme/aarch64-sme-acle-asm.exp: Ditto.
* gcc.target/aarch64/sme/aarch64-sme.exp: Ditto.
* gcc.target/aarch64/sme2/aarch64-sme2-acle-asm.exp: Ditto.
Alice Carlotti [Tue, 30 Dec 2025 08:53:10 +0000 (08:53 +0000)]
aarch64: Adjust sme tests that require sve
Some SME tests currently require SVE to be enabled as well. Either mark
this requirement explicitly in the test file (with a pragma), or
eliminate it by modifying the test.
For some check-function-bodies tests we take both approaches - that is,
we add "+sve" to the existing test, and create a duplicate "+nosve" test
that checks for the use of __arm_get_current_vg in the prologue.
For vect-dotprod-twoway.c, the issue is that the number of
udot/sdot/whilelo instructions depends on the selected tuning option.
Pass an explicit -mtune option to preserve the expected codegen.
Alice Carlotti [Fri, 2 Jan 2026 16:58:31 +0000 (16:58 +0000)]
aarch64: Remove +sme+nosve sorry
The preceding patches have fixed support for SME without SVE enabled, so
we can now remove the "sorry" for this configuration. This allows us to
remove SVE/SVE2 from the features that are added as a workaround when
trying to process a streaming function with SME disabled.
gcc/ChangeLog:
* config/aarch64/aarch64.cc (aarch64_override_options_internal):
Remove +sme+nosve sorry, and remove SVE from nosme workaround.
* doc/invoke.texi: Remove SVE2 requirement from +sme.
Alice Carlotti [Fri, 2 Jan 2026 16:58:09 +0000 (16:58 +0000)]
aarch64: Adjust TARGET_SVE{2}
Many instructions that are currently gated on TARGET_SVE or TARGET_SVE2
are also available in streaming mode when non-streaming SVE is disabled.
The simplest way to reflect this is by updating the macros to include
"|| TARGET_STREAMING".
Any SVE/SVE2 instructions that aren't available in streaming mode
already have an explicit "&& TARGET_NONSTREAMING" in their condition, so
in this case the extra condition has no impact besides a marginal
performance loss.
There are two uses of TARGET_SVE{2} that need handling separately:
- In aarch64_adjust_generic_arch_tuning, we are using features as a
proxy for tuning decisions, in which case we should treat
non-streaming mode with SME enabled the same as if either SVE2 or
streaming mode are enabled.
- In aarch64_update_cpp_builtins, streaming mode enablement is not a
relevant condition for defining __ARM_FEATURE_* macros, so use an
explicit feature flags check instead.
gcc/ChangeLog:
* config/aarch64/aarch64-c.cc (aarch64_update_cpp_builtins):
Replace TARGET_SVE{2} with explicit feature flag checks.
* config/aarch64/aarch64.cc
(aarch64_adjust_generic_arch_tuning): Add SME to SVE2 check.
* config/aarch64/aarch64.h (TARGET_SVE): Adjust condition.
(TARGET_SVE2): Ditto.
Alice Carlotti [Tue, 30 Dec 2025 08:53:57 +0000 (08:53 +0000)]
aarch64: Use __arm_get_current_vg for CFI
We can't use the cntd instruction in non-streaming mode if SVE is not
available, so instead use __arm_get_current_vg to get the value for the
VG save slot. This is more expensive, so continue using cntd if we know
we're in streaming mode or have +sve enabled.
gcc/ChangeLog:
* config/aarch64/aarch64-sme.md (UNSPEC_GET_CURRENT_VG): New
enum value.
(aarch64_get_current_vg): New insn.
* config/aarch64/aarch64.cc (aarch64_save_callee_saves): Use
__arm_get_current_vg if cntd is unavailable.
Alice Carlotti [Tue, 30 Dec 2025 08:52:24 +0000 (08:52 +0000)]
libgcc: aarch64: Add __arm_get_current_vg
AAPCS64* specifies several runtime support routines that must be
supported by any platform that supports SME. Add __arm_get_current_vg
to libgcc to help meet this requirement. This will be used to enable
support for SME without (non-streaming) SVE.
Alice Carlotti [Fri, 2 Jan 2026 13:59:02 +0000 (13:59 +0000)]
testsuite: Improve check-function-bodies logging
When a check-function-bodies test fails, it can sometimes be hard to
identify which part of a large function regexp is causing the failure.
To aid debugging these failures, find the largest initial set of lines
that matches the function, and log this separately from the remainder of
the regexp.
Additionally, add a newline before logging the function bodies, so that
the first line has the same indentation as the rest of that function.
gcc/testsuite/ChangeLog:
* lib/scanasm.exp (check_function_body): Log matching portion
of body_regexp separately.
fortran: Initialize gfc_se in PDT component allocation [PR123949]
Add missing gfc_init_se call for the default initializer case in
ALLOCATE_PDT_COMP. The adjacent KIND/LEN block (line 11118) and
pdt_string block (line 11149) both initialize tse, but this block
left it uninitialized, causing undefined behavior when tse.ss
contained stack garbage. Exposed as an ICE in gfc_conv_constant
(trans-const.cc:425) on aarch64 with LTO bootstrap.
PR fortran/123949
gcc/fortran/ChangeLog:
* trans-array.cc (structure_alloc_comps): Add missing
gfc_init_se call in case ALLOCATE_PDT_COMP for scalar
component default initializer.
Signed-off-by: Christopher Albert <albert@tugraz.at>
Jose E. Marchesi [Mon, 23 Feb 2026 00:29:56 +0000 (01:29 +0100)]
a68: more standard prelude in Algol 68
This commit moves the contents of libga68/transput.a68.in to
libga68/standard.a68.in and removes the built-in expansion of the
L_{int,real,exp}_width standard routines.
Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
libga68/ChangeLog