]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
57 min agoDarwin: Handle string constants specially when asan is enabled. master trunk
Iain Sandoe [Sat, 9 Aug 2025 07:19:08 +0000 (08:19 +0100)] 
Darwin: Handle string constants specially when asan is enabled.

The Darwin ABI uses a different section for string constants when
address sanitizing is enabled.  This adds defintions of the asan-
specific sections and switches string constants to the correct
section.

It also makes the string constant symbols linker-visible when
asan is enabled, but not otherwise.

gcc/ChangeLog:

* config/darwin-sections.def (asan_string_section,
asan_globals_section, asan_liveness_section): New.
* config/darwin.cc (objc_method_decl): Use asan sections
when asan is enabled.
(darwin_encode_section_info): Alter string constant
linker visibility depending on asan.
(machopic_select_section): Use the asan sections when
asan is enabled.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/darwin-cfstring-3.c: Adjust for amended
string labels.
* g++.dg/torture/darwin-cfstring-3.C: Likewise.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
62 min ago[RISC-V][PR target/121160] Avoid bogus force_reg call
Jeff Law [Wed, 13 Aug 2025 17:17:02 +0000 (11:17 -0600)] 
[RISC-V][PR target/121160] Avoid bogus force_reg call

When we canonicalize the comparison for a czero sequence we need to handle both
integer and fp comparisons.  Furthermore, within the integer space we want to
make sure we promote any sub-word objects to a full word.

All that is working fine.  After promotion we then force the value into a
register if it is not a register or constant already.   The idea is not to have
to special case subregs in subsequent code.  This works fine except when we're
presented with a floating point object that would be a subword.  (subreg:SF
(reg:SI)) on rv64 for example.

So this tightens up that force_reg step.   Bootstapped and regression tested on
riscv64-linux-gnu and tested on  riscv32-elf and riscv64-elf.

Pushing to the trunk after pre-commit verifies no regressions.

Jeff

PR target/121160
gcc/
* config/riscv/riscv.cc (canonicalize_comparands); Tighten check for
forcing value into a GPR.

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

110 min agoforwprop: Move check of limit first [PR121474]
Andrew Pinski [Wed, 13 Aug 2025 16:19:42 +0000 (09:19 -0700)] 
forwprop: Move check of limit first [PR121474]

This is the first step in handling the review part of:
https://gcc.gnu.org/pipermail/gcc-patches/2025-August/692091.html
'''
Oh, as we now do alias walks in forwprop maybe we should make this
conditional and do
this not for all pass instances, since it makes forwprop possibly a lot slower?
'''

The check of the limit was after the alias check which could slow down things.
This moves the check of the limit to begining of the if.

Bootstrapped and tested on x86_64-linux-gnu.

Pushed as obvious.

PR tree-optimization/121474
gcc/ChangeLog:

* tree-ssa-forwprop.cc (optimize_aggr_zeroprop): Move the check
for limit before the alias check.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 hours agoRegenerate libgcobol/configure
Mark Wielaard [Wed, 13 Aug 2025 15:53:10 +0000 (17:53 +0200)] 
Regenerate libgcobol/configure

Use autoconf 2.69 to regenerate libgcobol/configure

Fixes: 9992c0a0e1b4 ("cobol: Bring EBCDIC NumericDisplay variables into IBM compliance.")
libgcobol/ChangeLog:

* configure: Regenerate.

2 hours agocobol: Implement and use faster __gg__packed_to_binary() routine.
Robert Dubner [Wed, 13 Aug 2025 15:17:05 +0000 (11:17 -0400)] 
cobol: Implement and use faster __gg__packed_to_binary() routine.

The new routine uses table lookups more effectively, and avoids __int128
arithmetic until necessary.

gcc/cobol/ChangeLog:

* genutil.cc (get_binary_value): Use the new routine.

libgcobol/ChangeLog:

* libgcobol.cc (get_binary_value_local): Use the new routine.
* stringbin.cc (int_from_string): Removed.
(__gg__packed_to_binary): Implement new routine.
* stringbin.h (__gg__packed_to_binary): Likewise.

3 hours agoc++: fix typo in comment
Benjamin Wu [Wed, 13 Aug 2025 14:48:34 +0000 (10:48 -0400)] 
c++: fix typo in comment

gcc/cp/ChangeLog:

* lex.cc (init_operators): Fix typo.

5 hours agoIntroduce SLP_TREE_PERMUTE_P
Richard Biener [Wed, 13 Aug 2025 11:53:41 +0000 (13:53 +0200)] 
Introduce SLP_TREE_PERMUTE_P

The following wraps SLP_TREE_CODE checks against VEC_PERM_EXPR
(the only relevant code) in a new SLP_TREE_PERMUTE_P predicate.
Most places guard against SLP_TREE_REPRESENTATIVE being NULL.

* tree-vectorizer.h (SLP_TREE_PERMUTE_P): New.
* tree-vect-slp-patterns.cc (linear_loads_p): Adjust.
(vect_detect_pair_op): Likewise.
(addsub_pattern::recognize): Likewise.
* tree-vect-slp.cc (vect_print_slp_tree): Likewise.
(vect_gather_slp_loads): Likewise.
(vect_is_slp_load_node): Likewise.
(optimize_load_redistribution_1): Likewise.
(vect_optimize_slp_pass::is_cfg_latch_edge): Likewise.
(vect_optimize_slp_pass::internal_node_cost): Likewise.
(vect_optimize_slp_pass::start_choosing_layouts): Likewise.
(vect_optimize_slp_pass::backward_cost): Likewise.
(vect_optimize_slp_pass::forward_pass): Likewise.
(vect_optimize_slp_pass::get_result_with_layout): Likewise.
(vect_optimize_slp_pass::materialize): Likewise.
(vect_optimize_slp_pass::dump): Likewise.
(vect_optimize_slp_pass::decide_masked_load_lanes): Likewise.
(vect_update_slp_vf_for_node): Likewise.
(vect_slp_analyze_node_operations_1): Likewise.
(vect_schedule_slp_node): Likewise.
(vect_schedule_scc): Likewise.
* tree-vect-stmts.cc (vect_analyze_stmt): Likewise.
(vect_transform_stmt): Likewise.
(vect_is_simple_use): Likewise.

5 hours agoRemove use of STMT_VINFO_DEF_TYPE in vect_analyze_stmt
Richard Biener [Wed, 13 Aug 2025 12:43:28 +0000 (14:43 +0200)] 
Remove use of STMT_VINFO_DEF_TYPE in vect_analyze_stmt

This removes a use of STMT_VINFO_DEF_TYPE.

* tree-vect-stmts.cc (vect_analyze_stmt): Use
SLP_TREE_DEF_TYPE instead of STMT_VINFO_DEF_TYPE.

7 hours agoFold GATHER_SCATTER_*_P into vect_memory_access_type
Richard Biener [Tue, 12 Aug 2025 11:34:30 +0000 (13:34 +0200)] 
Fold GATHER_SCATTER_*_P into vect_memory_access_type

The following splits up VMAT_GATHER_SCATTER into
VMAT_GATHER_SCATTER_LEGACY, VMAT_GATHER_SCATTER_IFN and
VMAT_GATHER_SCATTER_EMULATED.  The main motivation is to reduce
the uses of (full) gs_info, but it also makes the kind representable
by a single entry rather than the ifn and decl tristate.

The strided load with gather case gets to use VMAT_GATHER_SCATTER_IFN,
since that's what we end up checking.

* tree-vectorizer.h (vect_memory_access_type): Replace
VMAT_GATHER_SCATTER with three separate access types,
VMAT_GATHER_SCATTER_LEGACY, VMAT_GATHER_SCATTER_IFN and
VMAT_GATHER_SCATTER_EMULATED.
(mat_gather_scatter_p): New predicate.
(GATHER_SCATTER_LEGACY_P): Remove.
(GATHER_SCATTER_IFN_P): Likewise.
(GATHER_SCATTER_EMULATED_P): Likewise.
* tree-vect-stmts.cc (check_load_store_for_partial_vectors):
Adjust.
(get_load_store_type): Likewise.
(vect_get_loop_variant_data_ptr_increment): Likewise.
(vectorizable_store): Likewise.
(vectorizable_load): Likewise.
* config/i386/i386.cc (ix86_vector_costs::add_stmt_cost):
Likewise.
* config/riscv/riscv-vector-costs.cc
(costs::need_additional_vector_vars_p): Likewise.
* config/aarch64/aarch64.cc (aarch64_detect_vector_stmt_subtype):
Likewise.
(aarch64_vector_costs::count_ops): Likewise.
(aarch64_vector_costs::add_stmt_cost): Likewise.

10 hours agoSimplify vect_supportable_dr_alignment API
Richard Biener [Tue, 12 Aug 2025 13:47:06 +0000 (15:47 +0200)] 
Simplify vect_supportable_dr_alignment API

The gather_scatter_info pointer is only used as flag, so pass down
a flag.

* tree-vectorizer.h (vect_supportable_dr_alignment): Pass
a bool instead of a pointer to gather_scatter_info.
* tree-vect-data-refs.cc (vect_supportable_dr_alignment):
Likewise.
* tree-vect-stmts.cc (get_load_store_type): Adjust.

12 hours agoFortran: Use associated TBP subroutine not found [PR89092]
Paul Thomas [Wed, 13 Aug 2025 06:16:31 +0000 (07:16 +0100)] 
Fortran: Use associated TBP subroutine not found [PR89092]

2025-08-13  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/89092
* resolve.cc (was_declared): Add subroutine attribute.

gcc/testsuite/
PR fortran/89092
* gfortran.dg/pr89092.f90: New test.

15 hours agoLoongArch: Define hook TARGET_COMPUTE_PRESSURE_CLASSES[PR120476].
Lulu Cheng [Wed, 13 Aug 2025 03:04:35 +0000 (11:04 +0800)] 
LoongArch: Define hook TARGET_COMPUTE_PRESSURE_CLASSES[PR120476].

The rtx cost value defined by the target backend affects the
calculation of register pressure classes in the IRA, thus affecting
scheduling.  This may cause program performance degradation.
For example, OpenSSL 3.5.1 SHA512 and SPEC CPU 2017 exchange_r.

This problem can be avoided by defining a set of register pressure
classes in the target backend instead of using the default IRA to
automatically calculate them.

gcc/ChangeLog:

PR target/120476
* config/loongarch/loongarch.cc
(loongarch_compute_pressure_classes): New function.
(TARGET_COMPUTE_PRESSURE_CLASSES): Define.

15 hours agoLoongArch: Add support for _BitInt [PR117599]
Yang Yujie [Sat, 2 Aug 2025 09:16:23 +0000 (17:16 +0800)] 
LoongArch: Add support for _BitInt [PR117599]

This patch adds support for C23's _BitInt for LoongArch.

From the LoongArch psABI[1]:

> _BitInt(N) objects are stored in little-endian order in memory
> and are signed by default.
>
> For N ≤ 64, a _BitInt(N) object have the same size and alignment
> of the smallest fundamental integral type that can contain it.
> The unused high-order bits within this containing type are filled
> with sign or zero extension of the N-bit value, depending on whether
> the _BitInt(N) object is signed or unsigned. The _BitInt(N) object
> propagates its signedness to the containing type and is laid out
> in a register or memory as an object of this type.
>
> For N > 64, _BitInt(N) objects are implemented as structs of 64-bit
> integer chunks. The number of chunks is the smallest even integer M
> so that M * 64 ≥ N. These objects are of the same size of the struct
> containing the chunks, but always have 16-byte alignment. If there
> are unused bits in the highest-ordered chunk that contains used
> bits, they are defined as the sign- or zero- extension of the used
> bits depending on whether the _BitInt(N) object is signed or
> unsigned. If an entire chunk is unused, its bits are undefined.

[1] https://github.com/loongson/la-abi-specs

PR target/117599

gcc/ChangeLog:

* config/loongarch/loongarch.h: Define a PROMOTE_MODE case for
small _BitInts.
* config/loongarch/loongarch.cc (loongarch_promote_function_mode):
Same.
(loongarch_bitint_type_info): New function.
(TARGET_C_BITINT_TYPE_INFO): Declare.

libgcc/ChangeLog:

* config/loongarch/t-softfp-tf: Enable _BitInt helper functions.
* config/loongarch/t-loongarch: Same.
* config/loongarch/libgcc-loongarch.ver: New file.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/bitint-alignments.c: New test.
* gcc.target/loongarch/bitint-args.c: New test.
* gcc.target/loongarch/bitint-sizes.c: New test.

15 hours agoLoongArch: Prioritize target-specific makefile fragments
Yang Yujie [Sat, 2 Aug 2025 09:14:25 +0000 (17:14 +0800)] 
LoongArch: Prioritize target-specific makefile fragments

libgcc/ChangeLog:

* config.host: Remove unused code. Include LoongArch-specific
tmake_files after the OS-specific ones.

15 hours ago[RISC-V][PR target/121113] Handle HFmode in various insn reservations
Jeff Law [Wed, 13 Aug 2025 02:29:50 +0000 (20:29 -0600)] 
[RISC-V][PR target/121113] Handle HFmode in various insn reservations

So this is a minor bug in a few DFA descriptions such as the Xiangshan and a
couple of the SiFive descriptions.

While Xiangshan covers every insn type, some of the reservations check the mode
of the operation.   Concretely the fdiv/fsqrt unit reservations vary based on
the mode.  They handled DF/SF, but not HF (the relevant iterators don't include
BF).

This patch just adds HF support with the same characteristics as SF. Those who
know these designs better could perhaps improve the reservation, but this at
least keeps us from aborting.

I did check the other published DFAs for mode dependent reservations. That's
show I found the p400/p600 issue.

Tested in my tester, waiting for CI to render its verdict before pushing.

PR target/121113
gcc/
* config/riscv/sifive-p400.md: Handle HFmode for fdiv/fsqrt.
* config/riscv/sifive-p600.md: Likewise.
* config/riscv/xiangshan.md: Likewise.

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

15 hours agocobol: Implement faster zoned decimal to binary conversion.
Robert Dubner [Wed, 13 Aug 2025 02:13:59 +0000 (22:13 -0400)] 
cobol: Implement faster zoned decimal to binary conversion.

Replace " value *= 10; value += digit" routines with a new one that does two
digits at a time and avoids __int128 calculations until they are necessary.

These changes also clean up the conversion behavior when a digit is not valid.

gcc/cobol/ChangeLog:

* genutil.cc (get_binary_value): Use the new routine.

libgcobol/ChangeLog:

* libgcobol.cc (int128_to_field): Use the new routine.
(get_binary_value_local): Use the new routine.
(format_for_display_internal): Formatting.
(__gg__get_file_descriptor): Likewise.
* stringbin.cc (string_from_combined): Formatting.
(packed_from_combined): Likewise.
(int_from_string): New routine.
(__gg__numeric_display_to_binary): Likewise.
* stringbin.h (__gg__numeric_display_to_binary): Likewise.

16 hours agotestsuite: fix jit.dg/test-error-impossible-must-tail-call.c [PR119783]
David Malcolm [Wed, 13 Aug 2025 01:46:41 +0000 (21:46 -0400)] 
testsuite: fix jit.dg/test-error-impossible-must-tail-call.c [PR119783]

I added this test back in r7-934-g15c671a79ca66d, but it looks like
r15-2125-g81824596361cf4 changed the error message.

gcc/testsuite/ChangeLog:
PR testsuite/119783
jit.dg/test-error-impossible-must-tail-call.c
* jit.dg/test-error-impossible-must-tail-call.c (verify_code):
Check that we get a suitable-looking error message, but don't
try to specify exactly what the message is.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
16 hours agojit: don't use &vect[0] in libgccjit++.h [PR121516]
David Malcolm [Wed, 13 Aug 2025 01:46:41 +0000 (21:46 -0400)] 
jit: don't use &vect[0] in libgccjit++.h [PR121516]

gcc/jit/ChangeLog:
PR jit/121516
* libgccjit++.h (context::new_struct_type): Replace use of
&fields[0] with fields.data ().
(context::new_function): Likewise for params.
(context::new_rvalue): Likewise for elements.
(context::new_call): Likewise for args.
(block::end_with_switch): Likewise for cases.
(block::end_with_extended_asm_goto): Likewise for goto_blocks.
(context::new_struct_ctor): Likewise for fields and values.
(context::new_array_ctor): Likewise for values.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
17 hours agox86: Convert integer constant to mode of move
H.J. Lu [Tue, 12 Aug 2025 12:19:24 +0000 (05:19 -0700)] 
x86: Convert integer constant to mode of move

For

(set (reg/v:DI 106 [ k ])
     (const_int 3000000000 [0xb2d05e00]))
...
(set (reg:V4SI 115 [ _13 ])
     (vec_duplicate:V4SI (subreg:SI (reg/v:DI 106 [ k ]) 0)))
...
(set (reg:V2SI 118 [ _9 ])
     (vec_duplicate:V2SI (subreg:SI (reg/v:DI 106 [ k ]) 0)))

we should generate

(set (reg:SI 125)
     (const_int -1294967296 [0xffffffffb2d05e00]))
(set (reg:V4SI 124)
     (vec_duplicate:V4SI (reg:VSI 125))
...
(set (reg:V4SI 115 [ _13 ])
     (reg:V4SI 124)
...
(set (reg:V2SI 118 [ _9 ])
     (subreg:V2SI (reg:V4SI 124))

by converting integer constant to mode of move.

gcc/

PR target/121497
* config/i386/i386-features.cc (ix86_broadcast_inner): Convert
integer constant to mode of move

gcc/testsuite/

PR target/121497
* gcc.target/i386/pr121497.c: New test.

Co-authored-by: Liu, Hongtao <hongtao.liu@intel.com>
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
18 hours agoDaily bump.
GCC Administrator [Wed, 13 Aug 2025 00:19:57 +0000 (00:19 +0000)] 
Daily bump.

18 hours agoRISC-V: RISC-V: Add test for vec_duplicate + vmerge.vvm combine with GR2VR cost 0...
Pan Li [Mon, 4 Aug 2025 01:54:34 +0000 (09:54 +0800)] 
RISC-V: RISC-V: Add test for vec_duplicate + vmerge.vvm combine with GR2VR cost 0, 1 and 15

Add asm dump check and run test for vec_duplicate + vmerge.vvm
combine to vmerge.vxm, with the GR2VR cost is 0, 2 and 15.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vx_vf/vx_binary.h: Add test
helper macros.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_binary_data.h: Add test
data for run test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-merge-1-i16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-merge-1-i32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-merge-1-i64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-merge-1-i8.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-merge-2-i16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-merge-2-i32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-merge-2-i64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-merge-2-i8.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-merge-3-i16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-merge-3-i32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-merge-3-i64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-merge-3-i8.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmerge-run-1-i16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmerge-run-1-i32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmerge-run-1-i64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_vmerge-run-1-i8.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
18 hours agoRISC-V: Combine vec_duplicate + vmerge.vv to vmerge.vx on GR2VR cost
Pan Li [Mon, 11 Aug 2025 13:22:08 +0000 (21:22 +0800)] 
RISC-V: Combine vec_duplicate + vmerge.vv to vmerge.vx on GR2VR cost

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

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

  #define DEF_VX_MERGE_0(T)                                      \
  void                                                           \
  test_vx_merge_##T##_case_0 (T * restrict out, T * restrict in, \
                              T x,  unsigned n)                  \
  {                                                              \
    for (unsigned i = 0; i < n; i++)                             \
      {                                                          \
        if (i % 2 == 0)                                          \
          out[i] = x;                                            \
        else                                                     \
          out[i] = in[i];                                        \
      }                                                          \
  }

  DEF_VX_MERGE_0(int32_t)

Before this patch:
  11   │     beq a3,zero,.L8
  12   │     vsetvli a5,zero,e32,m1,ta,ma
  13   │     vmv.v.x v2,a2
  ...
  16   │ .L3:
  17   │     vsetvli a5,a3,e32,m1,ta,ma
  ...
  22   │     vmerge.vvm v1,v1,v2,v0
  ...
  25   │     bne a3,zero,.L3

After this patch:
  11   │     beq a3,zero,.L8
  ...
  14   │ .L3:
  15   │     vsetvli a5,a3,e32,m1,ta,ma
  ...
  20   │     vmerge.vxm v1,v1,a2,v0
  ...
  23   │     bne a3,zero,.L3

gcc/ChangeLog:

* config/riscv/autovec-opt.md (*merge_vx_<mode>): Add new
pattern to combine the vmerge.vxm.

Signed-off-by: Pan Li <pan2.li@intel.com>
20 hours agoRISC-V: Expand const_vector with 2 elts per pattern.
Robin Dapp [Mon, 4 Aug 2025 09:09:50 +0000 (11:09 +0200)] 
RISC-V: Expand const_vector with 2 elts per pattern.

Hi,

In PR121334 we are asked to expand a const_vector of size 4 with
poly_int elements.  It has 2 elts per pattern so is neither a
const_vector_duplicate nor a const_vector_stepped.

We don't allow this kind of constant in legitimate_constant_p but expr
apparently still wants us to expand it under certain conditions.

This patch implements a basic expander for such kinds of patterns.
As slide1up is used to build the individual vectors it also adds
a helper function expand_slide1up.

I regtested on rv64gcv_zvl512b but unfortunately the newly created pattern is
not even executed.  I tried some variations of the original code but didn't
manage to trigger it.

Regards
 Robin

PR target/121334

gcc/ChangeLog:

* config/riscv/riscv-v.cc (expand_slide1up): New function.
(expand_vector_init_trailing_same_elem): Use new function.
(expand_const_vector_onestep): New function.
(expand_const_vector): Uew expand_slide1up.
(expand_vector_init_merge_repeating_sequence): Ditto.
(shuffle_off_by_one_patterns): Ditto.

gcc/testsuite/ChangeLog:

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

31 hours agoLoongArch: macro instead enum for base abi type
mengqinggang [Fri, 8 Aug 2025 08:22:59 +0000 (16:22 +0800)] 
LoongArch: macro instead enum for base abi type

enum can't be used in #if.
For #if expression, identifiers that are not macros,
which are all considered to be the number zero.

This patch may fix https://sourceware.org/bugzilla/show_bug.cgi?id=32776.

gcc/ChangeLog:

* config/loongarch/loongarch-def.h (ABI_BASE_LP64D): New macro.
(ABI_BASE_LP64F): New macro.
(ABI_BASE_LP64S): New macro.
(N_ABI_BASE_TYPES): New macro.

31 hours agoCleanup SLP decision during loop analysis
Richard Biener [Tue, 12 Aug 2025 09:00:54 +0000 (11:00 +0200)] 
Cleanup SLP decision during loop analysis

The following refactors the now misleading slp_done_for_suggested_uf
and slp states kept during vectorizer loop analysis.

* tree-vect-loop.cc (vect_analyze_loop_2): Change
slp_done_for_suggested_uf to a boolean
single_lane_slp_done_for_suggested_uf.  Change slp
to force_single_lane boolean.
(vect_analyze_loop_1): Adjust similarly.

32 hours agofwprop: Don't propagate asms [PR121253]
Richard Sandiford [Tue, 12 Aug 2025 09:21:47 +0000 (10:21 +0100)] 
fwprop: Don't propagate asms [PR121253]

For the reasons explained in the comment, fwprop shouldn't even
try to propagate an asm definition.

gcc/
PR rtl-optimization/121253
* fwprop.cc (forward_propagate_into): Don't propagate asm defs.

gcc/testsuite/
PR rtl-optimization/121253
* gcc.target/aarch64/pr121253.c: New test.

33 hours agotree-optimization/121509 - failure to detect unvectorizable loop
Richard Biener [Tue, 12 Aug 2025 07:51:54 +0000 (09:51 +0200)] 
tree-optimization/121509 - failure to detect unvectorizable loop

With the hybrid stmt detection no longer working as a gate-keeper
to detect unhandled stmts we have to, and can, detect those earlier.
The appropriate place is vect_mark_stmts_to_be_vectorized where
for trivially relevant PHIs we can stop analyzing when the PHI
wasn't classified as a known def during vect_analyze_scalar_cycles.

PR tree-optimization/121509
* tree-vect-stmts.cc (vect_mark_stmts_to_be_vectorized):
Fail early when we detect a relevant but not handled PHI.

* gcc.dg/vect/pr121509.c: New testcase.

34 hours agotree-optimization/121514 - ICE with recent VN improvement
Richard Biener [Tue, 12 Aug 2025 07:00:48 +0000 (09:00 +0200)] 
tree-optimization/121514 - ICE with recent VN improvement

When inserting a compensation stmt during VN we are making sure to
register the result for the original stmt into the hashtable so
VN iteration has the chance to converge and we avoid inserting
another copy each time.  But the implementation doesn't work for
non-SSA name values, and is also not necessary for constants since
we did not insert anything for them.  The following appropriately
guards the calls to vn_nary_op_insert_stmt as was already done
in one place.

PR tree-optimization/121514
* tree-ssa-sccvn.cc (visit_nary_op): Only call
vn_nary_op_insert_stmt for SSA name result.

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

34 hours agoforwprop: Fix non-call exceptions some more with copy prop for aggregates [PR121494]
Andrew Pinski [Mon, 11 Aug 2025 20:47:30 +0000 (20:47 +0000)] 
forwprop: Fix non-call exceptions some more with copy prop for aggregates [PR121494]

Note this conflicts with my not yet approved patch for copy prop for aggregates into
function arguments (I will get back to that soon).

So the problem here is that I assumed if:
*a = decl1;
would not cause an exception that:
decl2 = *a;
would cause not cause one too.

I was wrong, in some cases where the Ada front-end marks `*a` in the store
as TREE_THIS_NOTRAP (due to knowing never be null or some other cases).
So that means when we prop decl1 into the statement storing decl2, we need to
mark that statement as possible to cleanup for eh.

Bootstraped and tested on x86_64-linux-gnu.
Also tested on x86_64-linux-gnu with a hack to force generate LC constant decls in the gimplifier.

PR tree-optimization/121494
gcc/ChangeLog:

* tree-ssa-forwprop.cc (optimize_agr_copyprop): Mark the bb of the use
stmt if needed for eh cleanup.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
35 hours agoDo not set STMT_VINFO_VECTYPE for non-dataref stmts
Richard Biener [Mon, 11 Aug 2025 09:22:47 +0000 (11:22 +0200)] 
Do not set STMT_VINFO_VECTYPE for non-dataref stmts

Now that all STMT_VINFO_VECTYPE uses from vectorizable_* have been
pruged there's no longer a need to have STMT_VINFO_VECTYPE set.
We still rely on it being present on data-ref stmts and there it
can differ between different SLP instances when doing BB vectorization.
The following removes the setting from vect_analyze_stmt and
vect_transform_stmt.

Note the following clears STMT_VINFO_VECTYPE from pattern stmts (the
vector type should have moved to the SLP tree by this time).

* tree-vect-stmts.cc (vect_analyze_stmt): Only set
STMT_VINFO_VECTYPE for dataref SLP representatives.
Clear it for others and do not restore the original value.
(vect_transform_stmt): Likewise.

35 hours agoPass down vector type to avoid STMT_VINFO_VECTYPE on reduc-info
Richard Biener [Mon, 11 Aug 2025 13:38:41 +0000 (15:38 +0200)] 
Pass down vector type to avoid STMT_VINFO_VECTYPE on reduc-info

The following passes down the vector type to functions instead of
querying it from the reduc-info stmt-info.

* tree-vect-loop.cc (get_initial_defs_for_reduction):
Get vector type as argument.
(vect_find_reusable_accumulator): Likewise.
(vect_transform_cycle_phi): Adjust.

35 hours agoDo not use STMT_VINFO_VECTYPE in vectorizable_reduction
Richard Biener [Mon, 11 Aug 2025 09:20:41 +0000 (11:20 +0200)] 
Do not use STMT_VINFO_VECTYPE in vectorizable_reduction

There's one use of STMT_VINFO_VECTYPE in vectorizable_reduction
where I'm only 99% sure which SLP_TREE_VECTYPE to replace it with
(vectorizable_reduction needs a lot of post-only-SLP TLC).  The
following replaces it with the hopefully appropriate one.

* tree-vect-loop.cc (vectorizable_reduction): Replace
STMT_VINFO_VECTYPE use with SLP_TREE_VECTYPE.

35 hours agotree-optimization/121493 - another missed VN with aggregate copy
Richard Biener [Mon, 11 Aug 2025 08:42:47 +0000 (10:42 +0200)] 
tree-optimization/121493 - another missed VN with aggregate copy

This is another case where opportunistically handling a first
aggregate copy where we failed to match up the refs exactly
(as we don't insert missing handling components) yields to a
failure in the second aggregate copy that we visit.  Add another
fixup to deal with such situations, in-line with that present
opportunistic handling.

PR tree-optimization/121493
* tree-ssa-sccvn.cc (vn_reference_lookup_3): Opportunistically
strip components with known offset.

* gcc.dg/tree-ssa/ssa-fre-109.c: New testcase.

35 hours agoRestrict aggregate copy VN generalization
Richard Biener [Mon, 11 Aug 2025 12:43:58 +0000 (14:43 +0200)] 
Restrict aggregate copy VN generalization

The following avoids ending up with a MEM_REF as component to apply.

* tree-ssa-sccvn.cc (vn_reference_lookup_3): When we fail to
match up the two base MEM_REFs, fail.

36 hours agofortran: add optional lower arg to c_f_pointer
Yuao Ma [Thu, 7 Aug 2025 14:35:17 +0000 (22:35 +0800)] 
fortran: add optional lower arg to c_f_pointer

This patch adds support for the optional lower argument in intrinsic
c_f_pointer specified in Fortran 2023. Test cases and documentation have also
been updated.

gcc/fortran/ChangeLog:

* check.cc (gfc_check_c_f_pointer): Check lower arg legitimacy.
* intrinsic.cc (add_subroutines): Teach c_f_pointer about lower arg.
* intrinsic.h (gfc_check_c_f_pointer): Add lower arg.
* intrinsic.texi: Update lower arg for c_f_pointer.
* trans-intrinsic.cc (conv_isocbinding_subroutine): Add logic handle lower.

gcc/testsuite/ChangeLog:

* gfortran.dg/c_f_pointer_shape_tests_7.f90: New test.
* gfortran.dg/c_f_pointer_shape_tests_8.f90: New test.
* gfortran.dg/c_f_pointer_shape_tests_9.f90: New test.

Signed-off-by: Yuao Ma <c8ef@outlook.com>
38 hours agoImprove initial code generation for addsi/adddi
Shreya Munnangi [Tue, 12 Aug 2025 03:42:50 +0000 (21:42 -0600)] 
Improve initial code generation for addsi/adddi

This is a patch primarily from Shreya, though I think she cribbed some
code from Philipp that we had internally within Ventana and I made some
minor adjustments as well.

So the basic idea here is similar to her work on logical ops --
specifically when we can generate more efficient code at expansion time,
then do so.  In some cases the net is better code; in other cases we
lessen reliance on mvconst_internal and finally it provides
infrastructure that I think will help address an issue Paul Antoine
reported a little while back.

The most obvious case is using paired addis from initial code generation
for some constants.  It will also use a shNadd insn when the cost to
synthesize the original value is higher than the right-shifted value.
Finally it will negate the constant and use "sub"  if the negated
constant is cheaper than the original constant.

There's more work to do in here, particularly WRT 32 bit objects for
rv64.  Shreya is looking at that right now.  There may also be cases
where another shNadd or addi would be profitable.  We haven't really
explored those cases in any detail, while there may be cases to handle,
it's unclear how often they occur in practice.

I don't want to remove the define_insn_and_split for the paired addi
cases yet.  I think that likely happens as a side effect of fixing Paul
Antoine's issue.

Bootstrapped and regression tested on a BPI & Pioneer box.  Will
obviously wait for the pre-commit tester before moving forward.

Jeff
PR target/120603
gcc/
* config/riscv/riscv-protos.h (synthesize_add): Add prototype.
* config/riscv/riscv.cc (synthesize_add): New function.
* config/riscv/riscv.md (addsi3): Allow any constant as operands[2]
in the expander.  Force the constant into a register as needed for
TARGET_64BIT.  Use synthesize_add for !TARGET_64BIT.
(*adddi3): Renamed from adddi3.
(adddi3): New expander.  Use synthesize_add.

gcc/testsuite
* gcc.target/riscv/add-synthesis-1.c: New test.

Co-authored-by: Jeff Law <jlaw@ventanamicro.com>
Co-authored-by: Philipp Tomsich <philipp.tomsich@vrull.eu>
40 hours agocobol: Bring EBCDIC NumericDisplay variables into IBM compliance.
Robert Dubner [Tue, 12 Aug 2025 00:56:38 +0000 (20:56 -0400)] 
cobol: Bring EBCDIC NumericDisplay variables into IBM compliance.

The internal representation of Numeric Display (ND) zoned decimal variables
when operating in EBCDIC mode has been brought into compliance with IBM
conventions.  This requires changes to data input, data output, internal
conversion of zoned decimal to binary, and variable assignment.

gcc/cobol/ChangeLog:

* genapi.cc (compare_binary_binary): Formatting.
(cobol_compare): Formatting.
(mh_numeric_display): Rewrite "move ND to ND" algorithm.
(initial_from_initial): Proper initialization of EBCDIC ND variables.
* genmath.cc (fast_add): Delete comment.
* genutil.cc (get_binary_value): Modify for updated EBCDIC.

libgcobol/ChangeLog:

* common-defs.h (NUMERIC_DISPLAY_SIGN_BIT): New comment; new constant.
(EBCDIC_MINUS): New constant.
(EBCDIC_PLUS): Likewise.
(EBCDIC_ZERO): Likewise.
(EBCDIC_NINE): Likewise.
(PACKED_NYBBLE_PLUS): Likewise.
(PACKED_NYBBLE_MINUS): Likewise.
(PACKED_NYBBLE_UNSIGNED): Likewise.
(NUMERIC_DISPLAY_SIGN_BIT_ASCII): Likewise.
(NUMERIC_DISPLAY_SIGN_BIT_EBCDIC): Likewise.
(SEPARATE_PLUS): Likewise.
(SEPARATE_MINUS): Likewise.
(ZONED_ZERO): Likewise.
(ZONE_SIGNED_EBCDIC): Likewise.
* configure: Regenerate.
* libgcobol.cc (turn_sign_bit_on): Handle new EBCDIC sign convention.
(turn_sign_bit_off): Likewise.
(is_sign_bit_on): Likewise.
(int128_to_field): EBCDIC NumericDisplay conversion.
(get_binary_value_local): Likewise.
(format_for_display_internal): Likewise.
(normalize_id): Likewise.
(__gg__inspect_format_1): Convert EBCDIC negative numbers to positive.
* stringbin.cc (packed_from_combined): Quell cppcheck warning.

gcc/testsuite/ChangeLog:

* cobol.dg/group2/ALLOCATE_Rule_8_OPTION_INITIALIZE_with_figconst.out:
Change test for updated handling of Numeric Display variables.

41 hours agoDaily bump.
GCC Administrator [Tue, 12 Aug 2025 00:20:17 +0000 (00:20 +0000)] 
Daily bump.

42 hours agoaarch64: Fix condition accepted by mov<ALLI>cc
Richard Henderson [Fri, 8 Aug 2025 01:01:26 +0000 (01:01 +0000)] 
aarch64: Fix condition accepted by mov<ALLI>cc

Reject QI/HImode conditions, which would require extension in
order to compare.  Fixes

z.c:10:1: error: unrecognizable insn:
   10 | }
      | ^
(insn 23 22 24 2 (set (reg:CC 66 cc)
        (compare:CC (reg:HI 128)
            (reg:HI 127))) "z.c":6:6 -1
     (nil))
during RTL pass: vregs

gcc:
* config/aarch64/aarch64.md (mov<ALLI>cc): Accept MODE_CC
conditions directly; reject QI/HImode conditions.

gcc/testsuite:
* gcc.target/aarch64/cmpbr-3.c: New.
* gcc.target/aarch64/ifcvt_multiple_sets_rewire.c: Simplify
test for csel by ignoring the actual registers used.

42 hours agoaarch64: CMPBR branches must be invertable
Richard Henderson [Thu, 7 Aug 2025 22:48:52 +0000 (22:48 +0000)] 
aarch64: CMPBR branches must be invertable

Restrict the immediate range to the intersection of LT/GE and GT/LE
so that cfglayout can invert the condition to redirect any branch.

gcc:
PR target/121388
* config/aarch64/aarch64.cc (aarch64_cb_rhs): Restrict the
range of LT/GE and GT/LE to their intersections.
* config/aarch64/aarch64.md (*aarch64_cb<INT_CMP><GPI>): Unexport.
Use cmpbr_imm_predicate instead of aarch64_cb_rhs.
* config/aarch64/constraints.md (Uc1): Accept 0..62.
(Uc2): Remove.
* config/aarch64/iterators.md (cmpbr_imm_predicate): New.
(cmpbr_imm_constraint): Update to match aarch64_cb_rhs.
* config/aarch64/predicates.md (aarch64_cb_reg_i63_operand): New.
(aarch64_cb_reg_i62_operand): New.

gcc/testsuite:
PR target/121388
* gcc.target/aarch64/cmpbr.c (u32_x0_ult_64): XFAIL.
(i32_x0_slt_64, u64_x0_ult_64, i64_x0_slt_64): XFAIL.
* gcc.target/aarch64/cmpbr-2.c: New.

42 hours agoaarch64: Consider TARGET_CMPBR in rtx costs
Richard Henderson [Mon, 4 Aug 2025 12:47:05 +0000 (22:47 +1000)] 
aarch64: Consider TARGET_CMPBR in rtx costs

gcc:
* config/aarch64/aarch64.cc (aarch64_if_then_else_costs):
Use aarch64_cb_rhs to match CB insns.

42 hours agoaarch64: Fix gcc.target/aarch64/cmpbr.c enable
Richard Henderson [Wed, 6 Aug 2025 20:37:38 +0000 (20:37 +0000)] 
aarch64: Fix gcc.target/aarch64/cmpbr.c enable

gcc/testsuite:
* gcc.target/aarch64/cmpbr.c: Only compile, not assemble,
since we want to scan the assembly.

42 hours agoaarch64: Remove cc clobber from *aarch64_tbz<LTGE><ALLI>1
Richard Henderson [Thu, 7 Aug 2025 04:51:02 +0000 (04:51 +0000)] 
aarch64: Remove cc clobber from *aarch64_tbz<LTGE><ALLI>1

There is a conflict between aarch64_tbzltdi1 and aarch64_cbltdi
with respect to pnum_clobbers, resulting in a recog failure:

0xa1fffe fancy_abort(char const*, int, char const*)
        ../../gcc/diagnostics/context.cc:1640
0x81340e patch_jump_insn
        ../../gcc/cfgrtl.cc:1303
0xc0eafe redirect_branch_edge
        ../../gcc/cfgrtl.cc:1330
0xc0f372 cfg_layout_redirect_edge_and_branch
        ../../gcc/cfgrtl.cc:4736
0xbfb6b9 redirect_edge_and_branch(edge_def*, basic_block_def*)
        ../../gcc/cfghooks.cc:391
0x1fa9310 try_forward_edges
        ../../gcc/cfgcleanup.cc:561
0x1fa9310 try_optimize_cfg
        ../../gcc/cfgcleanup.cc:2931
0x1fa9310 cleanup_cfg(int)
        ../../gcc/cfgcleanup.cc:3143
0x1fe11e8 rest_of_handle_cse
        ../../gcc/cse.cc:7591
0x1fe11e8 execute
        ../../gcc/cse.cc:7622

The simplest solution is to remove the clobber from aarch64_tbz.
This removes the possibility of expansion via TST+B.cond, which
will merely fall back to TBNZ+B on shorter branches.

gcc:
PR target/121385
* config/aarch64/aarch64.md (*aarch64_tbz<LTGE><ALLI>1): Remove
cc clobber and expansion via TST+Bcond.

gcc/testsuite:
PR target/121385
* gcc.target/aarch64/cmpbr-1.c: New.

42 hours agoaarch64: Disable TARGET_CMPBR with aarch64_track_speculation
Richard Henderson [Mon, 4 Aug 2025 11:47:57 +0000 (21:47 +1000)] 
aarch64: Disable TARGET_CMPBR with aarch64_track_speculation

With -mtrack-speculation, CC_REGNUM must be used at every
conditional branch.

gcc:
* config/aarch64/aarch64.h (TARGET_CMPBR): False when
aarch64_track_speculation is true.

42 hours agoaarch64: Fix aarch64_split_imm24 patterns
Richard Henderson [Wed, 6 Aug 2025 09:21:55 +0000 (09:21 +0000)] 
aarch64: Fix aarch64_split_imm24 patterns

Both patterns used !reload_completed as a condition, which is
questionable at best.  The branch pattern failed to include a
clobber of CC_REGNUM.  Both problems were unlikely to trigger
in practice, due to how the optimization pipeline is organized,
but let's fix them anyway.

gcc:
* config/aarch64/aarch64.cc (aarch64_gen_compare_split_imm24): New.
* config/aarch64/aarch64-protos.h: Update.
* config/aarch64/aarch64.md (*aarch64_bcond_wide_imm<GPI>): Use it.
Add match_scratch and cc clobbers.  Use match_operator instead of
iterator expansion.
(*compare_cstore<GPI>_insn): Likewise.

42 hours agoaarch64: Rename and improve aarch64_split_imm24
Richard Henderson [Tue, 5 Aug 2025 21:17:33 +0000 (21:17 +0000)] 
aarch64: Rename and improve aarch64_split_imm24

Two of the three uses of aarch64_imm24 included the important follow-up
tests vs aarch64_move_imm and aarch64_plus_operand.  Lack of the exclusion
within aarch64_if_then_else_costs produced incorrect costing.

Since aarch64_split_imm24 has already matched a non-negative CONST_INT,
drill down from aarch64_plus_operand to aarch64_uimm12_shift.

gcc:
* config/aarch64/predicates.md (aarch64_split_imm24): Rename from
aarch64_imm24; exclude aarch64_move_imm and aarch64_uimm12_shift.
* config/aarch64/aarch64.md (*aarch64_bcond_wide_imm<GPI>):
Update for aarch64_split_imm24.
(*compare_cstore<GPI>_insn): Likewise.
* config/aarch64/aarch64.cc (aarch64_if_then_else_costs): Likewise.

42 hours agoaarch64: Fix gcs save/restore_stack_nonlocal
Richard Henderson [Thu, 7 Aug 2025 09:37:36 +0000 (09:37 +0000)] 
aarch64: Fix gcs save/restore_stack_nonlocal

The save/restore_stack_nonlocal patterns passed a DImode rtx to
gen_tbranch_neqi3 for a QImode compare.  But since we're seeding
r16 with 1, GCSEnabled will clear the only set bit in r16, so we
can use CBNZ instead of TBNZ.

gcc:
* config/aarch64/aarch64.md (tbranch_<EQL><SHORT>3): Remove.
(save_stack_nonlocal): Use aarch64_gen_compare_zero_and_branch.
(restore_stack_nonlocal): Likewise.

gcc/testsuite:
* gcc.target/aarch64/gcs-nonlocal-3.c: Match cbnz.

42 hours agoaarch64: Use aarch64_gen_compare_zero_and_branch in aarch64_restore_za
Richard Henderson [Mon, 4 Aug 2025 12:02:42 +0000 (22:02 +1000)] 
aarch64: Use aarch64_gen_compare_zero_and_branch in aarch64_restore_za

With -mtrack-speculation, the pattern that was directly expanded by
aarch64_restore_za is disabled.  Use the helper function instead.

gcc:
* config/aarch64/aarch64.cc
(aarch64_gen_compare_zero_and_branch): Export.
* config/aarch64/aarch64-protos.h
(aarch64_gen_compare_zero_and_branch): Declare it.
* config/aarch64/aarch64-sme.md (aarch64_restore_za): Use it.
* config/aarch64/aarch64.md (*aarch64_cbz<EQL><GPI>): Unexport.

42 hours agoaarch64: Reorg aarch64_if_the_else_costs, conditional branch
Richard Henderson [Tue, 5 Aug 2025 20:58:36 +0000 (20:58 +0000)] 
aarch64: Reorg aarch64_if_the_else_costs, conditional branch

gcc:
* config/aarch64/aarch64.cc (aarch64_if_the_else_costs): Reorg to
include the cost of inner within TBZ sign-bit test, only match
CBZ/CBNZ with valid modes, and both for the aarch64_imm24 test.

42 hours agoaarch64: Remove an indentation level from aarch64_if_then_else_costs
Richard Henderson [Tue, 5 Aug 2025 20:38:21 +0000 (20:38 +0000)] 
aarch64: Remove an indentation level from aarch64_if_then_else_costs

gcc:
* config/aarch64/aarch64.cc (aarch64_if_then_else_costs): Remove
else after return and re-indent.

42 hours agoaarch64: Fix spelling of BRANCH_LEN_N_1KiB
Richard Henderson [Mon, 4 Aug 2025 03:00:52 +0000 (13:00 +1000)] 
aarch64: Fix spelling of BRANCH_LEN_N_1KiB

One kilobyte not one kilobit.

gcc:
* config/aarch64/aarch64.md (BRANCH_LEN_N_1KiB): Rename
from BRANCH_LEN_N_1Kib.

43 hours agoc++: Quoting in -fmodules-mapper
Nicolas Werner [Sun, 3 Aug 2025 14:38:08 +0000 (16:38 +0200)] 
c++: Quoting in -fmodules-mapper

Users might be using a space in their build directory path. To allow
specifying such a root for the module mapper started by GCC, we need the
command to allow quotes. Previously quoting a path passed to the module
mapper was not possible, so replace the custom argv parsing with
the argv parsing logic from libiberty, that supports fairly standard
shell quoting using single and double quotes.

The primary purpose of this patch is to allow passing paths with spaces
to the --root parameter of the module mapper.

No test is included as spaces in build directories are tricky cross
platform. The patch was tested manually on my system.

gcc/cp/ChangeLog:

* mapper-client.cc (spawn_mapper_program): change argv parsing

Signed-off-by: Nicolas Werner <nicolas.werner@hotmail.de>
45 hours agoUpdate gcc .po files
Joseph Myers [Mon, 11 Aug 2025 20:53:40 +0000 (20:53 +0000)] 
Update gcc .po files

* be.po, da.po, de.po, el.po, es.po, fi.po, fr.po, hr.po, id.po,
ja.po, ka.po, nl.po, ru.po, sr.po, sv.po, tr.po, uk.po, vi.po,
zh_CN.po, zh_TW.po: Update.

45 hours agoFortran: gfortran rejects procedure binding on PDT [PR121398]
Paul Thomas [Mon, 11 Aug 2025 20:34:07 +0000 (21:34 +0100)] 
Fortran: gfortran rejects procedure binding on PDT [PR121398]

2025-08-11  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/121398
* resolve.cc (check_pdt_args): New function.
(check_generic_tbp_ambiguity): Use it to ensure that args to
typebound procedures that do not have the same declared type as
the containing derived type have 'pass1/2' set to null. This
avoids false ambiguity errors.
(resolve_typebound_procedure): Do not generate a wrong type
error for typebound procedures marked as pass if they are of a
different declared type to the containing pdt_type.

gcc/testsuite/
PR fortran/121398
* gfortran.dg/pdt_generic_1.f90: New test.

46 hours agoD: Adjust the code-gen for a string constant.
Iain Sandoe [Mon, 11 Aug 2025 19:41:15 +0000 (20:41 +0100)] 
D: Adjust the code-gen for a string constant.

In this function, we are generating a string constant but do so with
a mismatch between the actual string length and the length specified
in the type.  This causes Darwin, at least, to place the string in an
unexpected section (since the parameters do not match, it is rejected
as a cstring).

Use build_string_literal() to construct a consistent null-terminated
string.

gcc/d/ChangeLog:

* d-codegen.cc (build_filename_from_loc): Use
build_string_literal() to build a null-terminated string for
the filename.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2 days agoforwprop: Recongize a store of integral zero for optimize_aggr_zeroprop.
Andrew Pinski [Wed, 30 Jul 2025 23:44:56 +0000 (16:44 -0700)] 
forwprop: Recongize a store of integral zero for optimize_aggr_zeroprop.

While looking into the gimple level after optimization of the highway code
from google, I noticed in .optimized we still have:
```
  MEM <vector(8) short int> [(short int *)&a] = { 0, 0, 0, 0, 0, 0, 0, 0 };
  D.4398 = a;
  a ={v} {CLOBBER(eos)};
  D.4389 = D.4398;
  D.4390 = D.4389;
  D.4361 = D.4390;
  D.4195 = D.4361;
  return D.4195;
```
Note this is with SRA disabled since I noticed there is better code generation with
SRA disabled but that is a different story and I will get to that later on.

Which could be just optimized to a single store of `{}` .

The reason why the optimize_agr_copyprop does not handle the above is there was clobbers
inbetween the store in the last forwprop pass and currently don't copy after the first use.
While optimize_aggr_zeroprop does handle copying over clobbers just fine.

So this allows the recognization of the store to a to be like a memset to optimize_aggr_zeroprop
and then the result just falls through.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* tree-ssa-forwprop.cc (optimize_aggr_zeroprop): Recognize stores
of integer_zerop as memset of 0.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/copy-prop-aggr-zero-1.c: New test.
* gcc.dg/torture/copy-prop-aggr-zero-2.c: New test.
* gcc.dg/tree-ssa/copy-prop-aggregate-zero-1.c: New test.
* gcc.dg/tree-ssa/copy-prop-aggregate-zero-2.c: New test.
* gcc.dg/tree-ssa/copy-prop-aggregate-zero-3.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2 days agoDon't run tests requiring "B" on designs without "B"
Jeff Law [Mon, 11 Aug 2025 14:13:51 +0000 (08:13 -0600)] 
Don't run tests requiring "B" on designs without "B"

So I resurrected our milkv pioneer over the weekend.  While we had the
tell-tale signs of PCIE switch issues, it actually appears that the NMVE drive
was failing.  I had an NVME that was going to be installed in a different
system, so I threw it into the Pioneer as a last ditch effort to get it
functional again.  Voila!  It's a happy camper (so far).

Naturally I don't like manual testing, so cobbled together a new target for my
tester.  I forgot to update one field when doing that and as a result it picked
up testsuite prior test results from the job that runs on the BPI.

So comparing test results from a BPI to the Pioneer wouldn't normally be
interesting.  We'd expect to see a whole bunch of tests disappear as the
Pioneer doesn't have all kinds of extensions that the BPI does (and that does
indeed happen).

As it turns out we have a handful of tests which need bitmanip to run, but
which don't restrict themselves to only run on appropriate hardware.  So we
might as well fix that.

Given the Pioneer/BPI take 6/24 hours to cycle through respectively I just spot
checked the testsuite changes. Pushing to the trunk.

gcc/
* doc/sourcebuild.texi: Add riscv_b_ok and riscv_v_ok target selectors.

gcc/testsuite/
* lib/target-supports.exp (check_effective_target_riscv_b_ok): New.
* gcc.target/riscv/pr116085.c: Use new target selector.
* gcc.target/riscv/pr117690.c: Use new target selector.
* gcc.target/riscv/pr120333.c: Use new target selector.
* gcc.target/riscv/zba-shNadd-10.c: Use new target selector.

2 days agotree-optimization/121488 - improve BIT_FIELD_REF lookup in VN
Richard Biener [Mon, 11 Aug 2025 07:42:09 +0000 (09:42 +0200)] 
tree-optimization/121488 - improve BIT_FIELD_REF lookup in VN

When a BIT_FIELD_REF lookup combined with a defining load RHS results
in a wrongly typed result, try looking up or inserting a VIEW_CONVERT_EXPR
to the desired type.

PR tree-optimization/121488
* tree-ssa-sccvn.cc (visit_nary_op): If the BIT_FIELD_REF
result is of wrong type, try a VIEW_CONVERT_EXPR around it.

* gcc.dg/tree-ssa/ssa-fre-108.c: New testcase.

2 days agotree-optimization/121362 - fixup thinko in earlier change
Richard Biener [Mon, 11 Aug 2025 08:46:12 +0000 (10:46 +0200)] 
tree-optimization/121362 - fixup thinko in earlier change

The following fixes the index guards on the component stripping
loops, I swapped them it seems.

PR tree-optimization/121362
* tree-ssa-sccvn.cc (vn_reference_lookup_3): Swap index
guards on component stripping loops.

2 days agoRISC-V: Add testcase for scalar unsigned SAT_MUL form 2
Pan Li [Fri, 1 Aug 2025 02:46:58 +0000 (10:46 +0800)] 
RISC-V: Add testcase for scalar unsigned SAT_MUL form 2

Add run and asm check test cases for scalar unsigned
SAT_MUL form 2.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/sat/sat_arith.h: Add test helper macros.
* gcc.target/riscv/sat/sat_u_mul-3-u16.c: New test.
* gcc.target/riscv/sat/sat_u_mul-3-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-3-u64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-3-u8.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-3-u16.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-3-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-3-u64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-3-u8.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 days agoWidening-Mul: Support unsigned scalar SAT_MUL 2
Pan Li [Fri, 1 Aug 2025 02:42:23 +0000 (10:42 +0800)] 
Widening-Mul: Support unsigned scalar SAT_MUL 2

For mul_overflow api, we will have PHI node similar as below:

  _6 = .MUL_OVERFLOW (a_4(D), b_5(D));
  _2 = IMAGPART_EXPR <_6>;
  if (_2 != 0)
    goto <bb 4>; [35.00%]
  else
    goto <bb 3>; [65.00%]

  <bb 3> [local count: 697932184]:
  _1 = REALPART_EXPR <_6>;

  <bb 4> [local count: 1073741824]:
  # _3 = PHI <18446744073709551615(2), _1(3)>

Based on the help of match.pd pattern match, the widening-mul will
try to convert it to below:

  _3 = .SAT_MUL (a_4(D), b_5(D));

gcc/ChangeLog:

* tree-ssa-math-opts.cc (match_saturation_mul): Add new func
to emit IFN_SAT_MUL if matched.
(math_opts_dom_walker::after_dom_children): Try to match
the phi node for SAT_MUL.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 days agoMatch: Add form 2 for unsigned SAT_MUL
Pan Li [Fri, 1 Aug 2025 02:37:58 +0000 (10:37 +0800)] 
Match: Add form 2 for unsigned SAT_MUL

This patch would like to try to match the the unsigned
SAT_MUL form 2, aka below:

  #define DEF_SAT_U_MUL_FMT_2(T)               \
  T __attribute__((noinline))                  \
  sat_u_mul_##T##_fmt_2 (T a, T b)             \
  {                                            \
    T result;                                  \
    if (__builtin_mul_overflow(a, b, &result)) \
      return -1;                               \
    else                                       \
      return result;                           \
  }

While T is uint8_t, uint16_t, uint32_t and uint64_t.

gcc/ChangeLog:

* match.pd: Add form 2 for unsigned SAT_MUL.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 days agoRISC-V: Refactor the vec_duplicate cost on gpr/fpr2vr-cost param
Pan Li [Wed, 6 Aug 2025 14:13:26 +0000 (22:13 +0800)] 
RISC-V: Refactor the vec_duplicate cost on gpr/fpr2vr-cost param

The previous cost value for vec_duplicate almost bases on the operators
like add/minus.  The rtx_cost function try to match them case by case
and find if it has vec_duplicate, then update the cost values.

It is Ok when we initially add it but looks confused/redundant as more
and more operators are involved.  As Robin's suggestion, we only care
about the sub-rtx has vec_duplicate or not, instead of take care of
it by operators.

Thus, this PR would like to refactor that and get rid of the operators
when compute the vec_duplicate cost.

The below test suites are passed for this patch series.
* The rv64gcv fully regression test.

gcc/ChangeLog:

* config/riscv/riscv.cc (get_vector_binary_rtx_cost): Remove.
(riscv_rtx_costs): Refactor to serach vec_duplicate on the
sub rtx.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/binop/vadd-rv32gcv-nofm.c: Update
asm check due to above change.
* gcc.target/riscv/rvv/autovec/binop/vadd-rv64gcv-nofm.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vmul-rv32gcv-nofm.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vmul-rv64gcv-nofm.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vsub-rv32gcv-nofm.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vsub-rv64gcv-nofm.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_copysign-rv32gcv.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_copysign-rv64gcv.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fadd-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fadd-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fadd-3.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fadd-4.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma-3.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma-4.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma-5.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fma_fnma-6.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fmax-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fmax-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fmax-3.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fmax-4.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fmax_zvfh-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fmax_zvfh-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fmax_zvfh-3.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fmax_zvfh-4.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fmin-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fmin-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fmin-3.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fmin-4.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fmin_zvfh-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fmin_zvfh-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fmin_zvfh-3.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fmin_zvfh-4.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms-3.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms-4.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms-5.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fms_fnms-6.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fmul-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fmul-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fmul-3.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fmul-4.c: Ditto.
* gcc.target/riscv/rvv/autovec/cond/cond_fmul-5.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-3-f16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-3-f32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-3-f64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-6-i16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-6-i8.c: Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 days agoarm: Fix operand check for __arm_{mrrc{2},mcrr{2]} intrinsics [PR 121464]
Andre Vieira [Mon, 11 Aug 2025 08:49:18 +0000 (09:49 +0100)] 
arm: Fix operand check for __arm_{mrrc{2},mcrr{2]} intrinsics [PR 121464]

Fix the bound checking for the opc1  operand of the following intrinsics:
  __arm_mcrr
  __arm_mcrr2
  __arm_mrrc
  __arm_mrrc2

gcc/ChangeLog:

PR target/121464
* config/arm/arm.md (arm_<mrrc>, arm_<mcrr>): Fix operand check.

gcc/testsuite/ChangeLog:

PR target/121464
* gcc.target/arm/acle/mcrr.c: Update testcase.
* gcc.target/arm/acle/mcrr2.c: Likewise.
* gcc.target/arm/acle/mrrc.c: Likewise.
* gcc.target/arm/acle/mrrc2.c: Likewise.

2 days agosimplify-rtx: Distribute some non-narrowing subregs [PR121306]
Richard Sandiford [Mon, 11 Aug 2025 08:24:10 +0000 (09:24 +0100)] 
simplify-rtx: Distribute some non-narrowing subregs [PR121306]

In g:965564eafb721f8000013a3112f1bba8d8fae32b I'd added code
to try distributing non-widening subregs through logic ops,
in cases where that would eliminate a term of the logic op.

For "reasons", this indirectly caused combine to generate:

  (set (zero_extract:SI (reg/v:SI 101 [ a ])
  (const_int 8 [0x8])
  (const_int 8 [0x8]))
      (not:SI (sign_extract:SI (reg:SI 107 [ b ])
      (const_int 8 [0x8])
      (const_int 8 [0x8]))))

instead of:

  (set (zero_extract:SI (reg/v:SI 101 [ a ])
  (const_int 8 [0x8])
  (const_int 8 [0x8]))
      (subreg:SI (not:QI (subreg:QI (sign_extract:SI (reg:SI 107 [ b ])
      (const_int 8 [0x8])
      (const_int 8 [0x8])) 0)) 0))

for some tests that were intended to match x86's *one_cmplqi_ext<mode>_1
(see g:a58d770fa1d17ead3c38417b299cce3f19f392db).  However, other more
direct ways of generating the pattern continued to have the unsimplified
(subreg:SI (not:QI (subreg:QI (...:SI ...)))) structure, since that
structure wasn't the focus of the original patch.

This patch tries to tackle that simplification head-on.  It's another
case of distributing subregs, but this time for non-narrowing rather
than non-widening subregs.  We already do the same distribution for
word_mode:

  /* Attempt to simplify WORD_MODE SUBREGs of bitwise expressions.  */
  if (outermode == word_mode
      && (GET_CODE (op) == IOR || GET_CODE (op) == XOR || GET_CODE (op) == AND)
      && SCALAR_INT_MODE_P (innermode))
    {
      rtx op0 = simplify_subreg (outermode, XEXP (op, 0), innermode, byte);
      rtx op1 = simplify_subreg (outermode, XEXP (op, 1), innermode, byte);
      if (op0 && op1)
return simplify_gen_binary (GET_CODE (op), outermode, op0, op1);
    }

which g:0340177d54d08b6375391ba164a878e6a596275e extended to NOT.
For word_mode, there are (reasonably) no restrictions on the inner
mode other than that it is an integer.  Doing word_mode logic ops
should be at least as efficient as subword logic ops (if the target
provides subword ops at all).  And word_mode logic ops should be
cheaper than multi-word logic ops.

But here we need the distribution for SImode rather than word_mode
(DImode).  The patch therefore extends the word_mode distributions
to non-narrowing subregs in which the two modes occupy the same
number of words.  This should hopefully be relatively conservative.
It prevents the new rule from going away from word_mode, and attempting
to convert (say) a QImode subreg of a word_mode AND into a QImode AND.
It should be suitable for both CISCy and RISCy targets, including
those that define WORD_REGISTER_OPERATIONS.

The patch also fixes some overlong lines in related code.

gcc/
PR rtl-optimization/121306
* simplify-rtx.cc (simplify_context::simplify_subreg): Distribute
non-narrowing integer-to-integer subregs through logic ops,
in a similar way to the existing word_mode handling.

2 days agoFix comment typos
Jakub Jelinek [Mon, 11 Aug 2025 07:04:19 +0000 (09:04 +0200)] 
Fix comment typos

This patch fixes some comment typos, singe -> single and unsinged -> unsigned.

2025-08-11  Jakub Jelinek  <jakub@redhat.com>

gcc/
* tree-cfg.cc (find_case_label_for_value): Fix comment typo,
singe-valued -> single-valued.
* config/arc/arc.md: Fix comment typos, unsinged -> unsigned.
gcc/fortran/
* gfortran.h (gfc_case): Fix comment typo, singe -> single.
gcc/testsuite/
* g++.dg/warn/template-1.C: Fix comment typo, unsinged -> unsigned.
* gcc.target/powerpc/builtins-2-p9-runnable.c (main): Likewise.
* gcc.dg/graphite/id-30.c: Likewise.

2 days agoc++: Fix up handling of name independent structured binding packs [PR117783]
Jakub Jelinek [Mon, 11 Aug 2025 07:02:38 +0000 (09:02 +0200)] 
c++: Fix up handling of name independent structured binding packs [PR117783]

I've realized I haven't added testsuite coverage for name independent
structured binding packs.  And the
  auto [i, ..._, j] = T {};
  auto [k, ..._, l] = T {};
case shows a problem with that.  The elements of the structured binding
pack have #i appended to their names, so for the _ case e.g. _#0, _#1
etc. (to print something useful in diagnostics, perhaps debug info later
on).  The above is valid though as long as one doesn't use _ (which is
ambiguous), but we were emitting errors on redeclaration of _#0, _#1
etc.

The following patch uses DECL_NAME (decl) = NULL_TREE; for the
name independent decl case so that the false positive redeclaration
errors aren't emitted.

2025-08-11  Jakub Jelinek  <jakub@redhat.com>

PR c++/117783
* decl.cc (set_sb_pack_name): For name independent decls
just clear DECL_NAME instead of appending #i to it.

* g++.dg/cpp26/name-independent-decl11.C: New test.

2 days agoc++: Implement mangling for structured binding packs [PR117783]
Jakub Jelinek [Mon, 11 Aug 2025 06:54:57 +0000 (08:54 +0200)] 
c++: Implement mangling for structured binding packs [PR117783]

On Wed, Aug 06, 2025 at 11:53:55AM -0700, Jason Merrill wrote:
> The Clang mangling of the underlying variable seems fine, just mentioning
> the bound names; we can't get mangling collisions between pack and non-pack
> versions of the same name.
>
> But It looks like they use .N discriminators for the individual elements,
> which is wrong because . is reserved for implementation details.  But I'd
> think it should be fine to use [<discriminator>] instead.

If you want the whole structured bindings to be mangled normally as if the
pack isn't a pack and the individual vars of the structured binding pack
mangled as multiple occurrences of the named entities, the following
patch does that.

2025-08-11  Jakub Jelinek  <jakub@redhat.com>

PR c++/117783
* decl.cc (cp_finish_decomp): Don't sorry on tuple static
structured bindings with a pack, instead temporarily reset
DECL_NAME of the individual vars in the pack to the name
of the pack for cp_finish_decl time and force mangling.

* g++.dg/cpp26/decomp19.C: Don't expect sorry on tuple static
structured bindings with a pack.
* g++.dg/cpp26/decomp26.C: New test.

2 days agoc++: Fix structured binding redeclaration error recovery [PR121442]
Jakub Jelinek [Mon, 11 Aug 2025 06:53:26 +0000 (08:53 +0200)] 
c++: Fix structured binding redeclaration error recovery [PR121442]

My C++26 P2686R4 PR117784 caused ICE on the following testcase.
While the earlier conditions guarantee decl2 is not error_mark_node,
decl can be (that is used when something erroneous has been seen earlier
and the whole structured bindings will be ignored after parsing).

So, the following patch avoids the copying of constexpr/constinit flags
if decl is error_mark_node.

2025-08-11  Jakub Jelinek  <jakub@redhat.com>

PR c++/121442
* parser.cc (cp_parser_decomposition_declaration): Don't copy
DECL_DECLARED_CONST{EXPR,INIT}_P bits from decl to decl2 if
decl is error_mark_node.

* g++.dg/cpp1z/decomp65.C: New test.

2 days agoDaily bump.
GCC Administrator [Mon, 11 Aug 2025 00:16:52 +0000 (00:16 +0000)] 
Daily bump.

3 days agoAdd -mgrow-frame-downwards
Matthew Fortune [Sun, 10 Aug 2025 17:20:30 +0000 (11:20 -0600)] 
Add -mgrow-frame-downwards

Grow the local frame down instead of up for mips16 code size.

By growing the frame downwards we get spill slots created at the lowest
address rather than highest address in a local frame. The benefit being
that when the frame is large the spill slots can still be accessed using
a 16bit instruction whereas it is less important for large local
variables to be accessed using short instructions as they are (probably)
accessed less frequently.

This is default on for MIPS16.

gcc/
* config/mips/mips.h (FRAME_GROWS_DOWNWARD) Allow the frame to
grow downwards for mips16 when -mgrow-frame-downwards is set.
* config/mips/mips.opt: Add -mgrow-frame-downwards option.

3 days agovarasm: Redo mergeable section support [PR121438]
Andrew Pinski [Thu, 7 Aug 2025 19:18:38 +0000 (12:18 -0700)] 
varasm: Redo mergeable section support [PR121438]

We increased the switch conversion array decl alignment
for better mergeability but it turns out that we increase
the alignment on targets which don't support mergeable sections
(e.g. NVPTX). Also after the fix for PR 121394, it becomes
obvious that we can place any sized into the mergeable section
instead of increasing the alignment.
This implements that and now also fixes PR 121438 as we don't
need to increase the alignment for the mergeable decls that
were being created by the C++ front-end.

Bootstrapped and tested on x86_64-linux-gnu.

PR middle-end/121438
PR middle-end/121444
gcc/ChangeLog:

* output.h (MAX_ALIGN_MERGABLE): Rename to ...
(MAX_MERGEABLE_BITSIZE): This.
* tree-switch-conversion.cc (switch_conversion::build_one_array): Don't
increase the alignment.
* varasm.cc (mergeable_string_section): Use MAX_MERGEABLE_BITSIZE
instead of MAX_ALIGN_MERGABLE. Also replace `/ 8` with `/ BITS_PER_UNIT`.
(mergeable_constant_section): Select the mergeable section based on
the bitsize rather than the alignment. Make sure the align is less
than the entity size.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
3 days agovarasm: Ensure each variable in mergeable section is the entity size [PR121394]
Andrew Pinski [Thu, 7 Aug 2025 18:44:21 +0000 (11:44 -0700)] 
varasm: Ensure each variable in mergeable section is the entity size [PR121394]

Now there are mergeable sections which have an entity size, we can place
decls (constants) that are smaller in size in these sections.
An example is an `long double` which has a size of 12 bytes on i686 and is
placed in the 16 bytes shareable section.

For an example with the following C++ code:
```
std::initializer_list<long double> a = {0.3l};
```

We place the constant array in the .rodata.cst16 section but we don't add a padding to 16 bytes.
```
        .section        .rodata.cst16,"aM",@progbits,16
        .align 16
        .type   _ZGR1a_, @object
        .size   _ZGR1a_, 12
_ZGR1a_:
        .long   -1717986918
        .long   -1717986919
        .long   16381
        .text
```
GAS has a workaround added to do the padding but other assemblers don't.
The gas workaround was added with https://sourceware.org/legacy-ml/binutils/2002-11/msg00615.html .
Now for the constant pool, GCC does emit a `.align` to padd out the size correctly.
This was done in r0-46282-gf41115930523b3.
The same padding should be done when emitting a variable contents when in a mergeable section.

This patch implements the padding and we now get an addition `.zero 4` which pads out the section.

Bootstrapped and tested on x86_64-linux-gnu.

PR middle-end/121394
gcc/ChangeLog:

* varasm.cc (assemble_variable_contents): Pad out
mergeable sections if needed.
(output_constant_pool_1): Change the padding to be explicit
zeroing for mergeable sections.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
3 days agoRegenerate configure files
H.J. Lu [Sun, 10 Aug 2025 14:56:51 +0000 (07:56 -0700)] 
Regenerate configure files

Regenerate configure files after

commit 8a3ad190c14789cde0b03142760b14b5675e8b39
Author: Ijaz, Abdul B <abdul.b.ijaz@intel.com>
Date:   Sun Aug 10 08:33:30 2025 -0600

    config: Handle dash in library name for AC_LIB_LINKAGEFLAGS_BODY

gcc/

* configure: Regenerated.

libcpp/

* configure: Regenerated.

libgcobol/

* configure: Regenerated.

libstdc++-v3/

* configure: Regenerated.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
3 days agoconfig: Handle dash in library name for AC_LIB_LINKAGEFLAGS_BODY
Ijaz, Abdul B [Sun, 10 Aug 2025 14:33:30 +0000 (08:33 -0600)] 
config: Handle dash in library name for AC_LIB_LINKAGEFLAGS_BODY

For a library with dash in the name like yaml-cpp the AC_LIB_LINKAGEFLAGS_BODY
function generates a with_libname_type argument variable name with a dash but
this results in configure error.  Since dashes are not allowed in the variable
name.

This change handles such cases and in case input library for the
AC_LIB_HAVE_LINKFLAGS has dash then it replaces it with the underscore "_".

Example of an error for yaml-cpp library before the change using gcc config
scripts in gdb:
gdb/gdb/configure: line 22868: with_libyaml-cpp_type=auto: command not found

After having underscore for this variable name:

checking whether to use yaml-cpp... yes
checking for libyaml-cpp... yes
checking how to link with libyaml-cpp... -lyaml-cpp

config/ChangeLog:

* lib-link.m4: Handle dash in the library name for
AC_LIB_LINKFLAGS_BODY.

3 days agoasm-hard-reg-6.c: Adjust scan for x86 with ia32, lp64 and x32
H.J. Lu [Sat, 9 Aug 2025 21:55:19 +0000 (14:55 -0700)] 
asm-hard-reg-6.c: Adjust scan for x86 with ia32, lp64 and x32

Since i?86 and x86_64 GCC can generate codes for ia32, x32 and lp64, adjust
asm-hard-reg-6.c scan for x86 with ia32, lp64 and x32.

PR testsuite/121205
* gcc.dg/asm-hard-reg-6.c: Adjust scan for x86 with ia32, lp64 and
x32.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
3 days agoasm-hard-reg-5.c: Compile for x86 !ia32
H.J. Lu [Sat, 9 Aug 2025 21:54:06 +0000 (14:54 -0700)] 
asm-hard-reg-5.c: Compile for x86 !ia32

Since i?86 and x86_64 GCC can generate codes for ia32, x32 and lp64,
compile asm-hard-reg-5.c for x86 !ia32.

PR testsuite/121205
* gcc.dg/asm-hard-reg-5.c: Compile for x86 !ia32.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
3 days agoasm-hard-reg-4.c: Compile for x86 with -msse2 and scan x86
H.J. Lu [Sat, 9 Aug 2025 21:51:41 +0000 (14:51 -0700)] 
asm-hard-reg-4.c: Compile for x86 with -msse2 and scan x86

Since i?86 and x86_64 GCC can generate codes for ia32, x32 and lp64,
compile asm-hard-reg-4.c for x86 with -msse2 and scan x86

PR testsuite/121205
* gcc.dg/asm-hard-reg-4.c: Compile with -msse2 for x86 and scan
x86.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
3 days agoasm-hard-reg-2.c: Compile for x86 !ia32 and scan x86
H.J. Lu [Sat, 9 Aug 2025 21:49:19 +0000 (14:49 -0700)] 
asm-hard-reg-2.c: Compile for x86 !ia32 and scan x86

Since i?86 and x86_64 GCC can generate codes for ia32, x32 and lp64,
compile asm-hard-reg-2.c for x86 !ia32 and scan x86.

PR testsuite/121205
* gcc.dg/asm-hard-reg-2.c: Compile for x86 !ia32 and scan x86.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
3 days agoasm-hard-reg-1.c: Adjust scan for x86 with ia32, x32 and lp64
H.J. Lu [Sat, 9 Aug 2025 21:44:36 +0000 (14:44 -0700)] 
asm-hard-reg-1.c: Adjust scan for x86 with ia32, x32 and lp64

Since i?86 and x86_64 GCC can generate codes for ia32, x32 and lp64, adjust
asm-hard-reg-1.c scan for x86 with ia32, x32 and lp64.

PR testsuite/121205
* gcc.dg/asm-hard-reg-1.c: Adjust scan for x86 with ia32, x32 and
lp64.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
3 days agotestsuite: i386: Fix gcc.target/i386/pr90579.c when PIE is enabled [PR118885]
Harish Sadineni [Sun, 10 Aug 2025 12:28:00 +0000 (20:28 +0800)] 
testsuite: i386: Fix gcc.target/i386/pr90579.c when PIE is enabled [PR118885]

When gcc build with --enable-deafult-pie the following tests
were getting failed:
 FAIL: gcc.target/i386/pr90579.c scan-assembler vaddsd\tr\\+40
 FAIL: gcc.target/i386/pr90579.c scan-assembler vaddsd\tr\\+32
 FAIL: gcc.target/i386/pr90579.c scan-assembler vaddsd\tr\\+24
 FAIL: gcc.target/i386/pr90579.c scan-assembler vaddsd\tr\\+16

PR target/118885

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr90579.c: add -fno-pie to dg-options
to fix tests when PIE is enabled.

Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
3 days agotestsuite: handle-multiline-outputs must allow both cc1 and cc1.exe
Torbjörn SVENSSON [Thu, 17 Jul 2025 12:27:08 +0000 (14:27 +0200)] 
testsuite: handle-multiline-outputs must allow both cc1 and cc1.exe

Prior to 14-2027-g985d6480fe5, the input text had the file extensions
pruned. In 14-2027-g985d6480fe5, due to the move of the call, the
pruning is never done. This change restores the pruning of the file
extension to allow multiline test to pass on both Windows and other
platforms like Linux.

gcc/testsuite/ChangeLog:

* lib/multiline.exp: Added pruning of .exe.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
3 days agoDaily bump.
GCC Administrator [Sun, 10 Aug 2025 00:18:41 +0000 (00:18 +0000)] 
Daily bump.

3 days agoasm-hard-reg-2.c: Use long long on z to trigger RA error
H.J. Lu [Sat, 9 Aug 2025 21:00:47 +0000 (14:00 -0700)] 
asm-hard-reg-2.c: Use long long on z to trigger RA error

Use long long on z to trigger

error: 'asm' operand has impossible constraints or there are not enough registers

for -m32 on asm statements like:

  __asm__ __volatile__ ("" : "=A" (z), "={rax}" (y));

PR testsuite/121205
* gcc.target/i386/asm-hard-reg-2.c (z): Use long long for -m32
to trigger RA error.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
4 days agoFortran: Correct wrong PR numbers
Paul Thomas [Sat, 9 Aug 2025 15:00:10 +0000 (16:00 +0100)] 
Fortran: Correct wrong PR numbers

4 days agoDarwin: Anchor block internal symbols must not be linker-visible.
Iain Sandoe [Thu, 7 Aug 2025 16:51:14 +0000 (17:51 +0100)] 
Darwin: Anchor block internal symbols must not be linker-visible.

When we are using section anchors, there's a requirement that the
sequence of the content is an unbroken block.  If we allow linker-
visible symbols in that block, ld(64) would be able to break it
into sub-sections on those symbol boundaries.

Do not allow symbols that should be visible to be anchored.
Do not make anchor block internal symbols linker-visible.

gcc/ChangeLog:

* config/darwin.cc (darwin_encode_section_info): Do not
make anchored symbols linker-visible.
(darwin_use_anchors_for_symbol_p): Disallow anchoring on
symbols that must be linker-visible (or external), even
if the definitions are in this TU.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
4 days agoDarwin: Section anchors must be linker-visible.
Iain Sandoe [Wed, 6 Aug 2025 05:07:43 +0000 (06:07 +0100)] 
Darwin: Section anchors must be linker-visible.

In principle, these begin (or at least delineate) a region that
could be split by the static linker.  If the symbols are hidden
to newer linkers they produce diagnostics about the temporary
symbol generated.

gcc/ChangeLog:

* config/darwin.h (ASM_GENERATE_INTERNAL_LABEL): New
entry for LANCHOR.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
4 days agodiagnostics: fix build on hosts where unsigned == size_t
David Malcolm [Sat, 9 Aug 2025 13:15:04 +0000 (09:15 -0400)] 
diagnostics: fix build on hosts where unsigned == size_t

Looks like I broke the build with r16-3091-gac4e7455a33237 on hosts
where unsigned == size_t.

../../gcc/gcc/diagnostics/dumping.cc:98:1: error: redefinition of ‘void diagnostics::dumping::emit_field(FILE*, int, const char*, T) [with T = unsigned int; FILE = FILE]’
   98 | emit_field<unsigned> (FILE *outfile, int indent,
      | ^~~~~~~~~~~~~~~~~~~~
../../gcc/gcc/diagnostics/dumping.cc:80:1: note: ‘void diagnostics::dumping::emit_field(FILE*, int, const char*, T) [with T = unsigned int; FILE = FILE]’ previously declared here
   80 | emit_field<size_t> (FILE *outfile, int indent,
      | ^~~~~~~~~~~~~~~~~~

Sorry about this.

Should be fixed by the following patch, which avoids templates here
in favor of being explicit about types, avoids the use of "%zi" with
fprintf in various places, and fixes some other minor issues in the
dumping logic that I noticed whilst testing the patch.

gcc/ChangeLog:
* diagnostics/context.cc (context::dump): Bulletproof against
m_reference_printer being null.
* diagnostics/dumping.cc (emit_field<const char *>): Replace
with...
(emit_string_field): ...this.
(emit_field<char *>): Eliminate.
(emit_field<bool>): Replace with...
(emit_bool_field): ...this.
(emit_field<size_t>): Replace with...
(emit_size_t_field): ...this, and use HOST_SIZE_T_PRINT_DEC rather
than %zi in fprintf call.
(emit_field<int>): Replace with...
(emit_int_field): ...this.
(emit_field<unsigned>): Replace with...
(emit_unsigned_field): ...this.
* diagnostics/dumping.h (emit_field): Replace this template decl
with...
(emit_string_field): ...this,
(emit_bool_field): ...this,
(emit_size_t_field): ...this,
(emit_int_field): ...this,
(emit_unsigned_field): ... and this.
(DIAGNOSTICS_DUMPING_EMIT_FIELD): Rename to...
(DIAGNOSTICS_DUMPING_EMIT_BOOL_FIELD): ...this and update for
above change.
* diagnostics/file-cache.cc (file_cache_slot::dump): Replace
emit_field calls with calls that explicitly state the type.  Fix
type of dump of m_missing_trailing_newline to use bool.
(file_cache_slot::dump): Use HOST_SIZE_T_PRINT_DEC rather than
%zi in fprintf call.
* diagnostics/html-sink.cc (html_generation_options::dump): Update
for macro renaming.
* diagnostics/sarif-sink.cc
(sarif_serialization_format_json::dump): Likewise.
(sarif_generation_options::dump): Likewise, and for function
renaming.
* diagnostics/text-sink.cc (text_sink::dump): Update for macro
renaming.
* libgdiagnostics.cc (diagnostic_manager_debug_dump_file): Use
HOST_SIZE_T_PRINT_DEC rather than %zi in fprintf call.
* pretty-print.cc: Include "diagnostics/dumping.h".
(pp_formatted_chunks::dump): Use it.
(get_url_format_as_string): New.
(pretty_printer::dump): Use diagnostics::dumping.  Bulletproof
against m_buffer being null.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 days agotestsuite: Skip class-11_a.H for default_packed targets
Dimitar Dimitrov [Sat, 9 Aug 2025 11:01:48 +0000 (14:01 +0300)] 
testsuite: Skip class-11_a.H for default_packed targets

The g++.dg/modules/class-11_a.H test expects structs to have a padding.
Skip this test for targets which have packed structs by default.

This patch fixes the test for pru-unknown-elf from FAIL to UNSUPPORTED.
The test still passes on x86_64-linux-gnu.

gcc/testsuite/ChangeLog:

* g++.dg/modules/class-11_a.H: Skip test for effective
default_packed targets.
* g++.dg/modules/class-11_b.C: Ditto.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
4 days agoFortran: F2018 GENERIC statement is missing [PR121182]
Paul Thomas [Sat, 9 Aug 2025 10:40:09 +0000 (11:40 +0100)] 
Fortran: F2018 GENERIC statement is missing [PR121182]

2025-08-09  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/121182
* decl.cc (match_generic_stmt): New function based on original
gfc_match_generic but feeding namespace rather than typebound
generics.
(match_typebound_generic): Renamed original gfc_match_generic.
(gfc_match_generic): New function that selects between type
bound generic and other generic statements and calls one of the
above two functions as appropriate.
* parse.cc (decode_specification_statement): Allow generic
statements.
(parse_spec): Accept a generic statement in a specification
block.

gcc/testsuite/
PR fortran/121182
* gfortran.dg/generic_stmt_1.f90: New test.
* gfortran.dg/generic_stmt_2.f90: New test.
* gfortran.dg/generic_stmt_3.f90: New test.
* gfortran.dg/generic_stmt_4.f90: New test.

4 days agotestsuite: Require atomic operations for hardbool-ai.c
Dimitar Dimitrov [Sat, 9 Aug 2025 05:26:13 +0000 (08:26 +0300)] 
testsuite: Require atomic operations for hardbool-ai.c

The test uses _Atomic int type, so add a filter to ensure the target
supports it.

This fixes a spurious test failure on pru-unknown-elf, which lacks
atomic ops.  The test still passes on x86_64-linux-gnu.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/hardbool-ai.c: Require target that supports
atomic operations on int types.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
4 days agoxtensa: Refine constraint "T" to define_special_memory_constraint
Takayuki 'January June' Suwa [Thu, 7 Aug 2025 21:49:13 +0000 (06:49 +0900)] 
xtensa: Refine constraint "T" to define_special_memory_constraint

References to literal pool entries do not need to be reloaded or converted
to "(mem (reg X))" to load via base register.

gcc/ChangeLog:

* config/xtensa/constraints.md (T):
Change define_memory_constraint to define_special_memory_constraint.

4 days agoDaily bump.
GCC Administrator [Sat, 9 Aug 2025 00:19:57 +0000 (00:19 +0000)] 
Daily bump.

4 days agoforwprop: Don't do copy-prop-aggregates from statements that could throw [PR120599]
Andrew Pinski [Mon, 28 Jul 2025 03:37:55 +0000 (20:37 -0700)] 
forwprop: Don't do copy-prop-aggregates from statements that could throw [PR120599]

In the testcase provided, currently we lose the landing pad for the exception that could
throw from the aggregate load as we remove one copy and the second statement where load
happens was not marked as throwable before so the landing pad for that internal throw is
now gone.

The fix is to ignore statements that could throw (internally or externally).

PR tree-optimization/120599

gcc/ChangeLog:

* tree-ssa-forwprop.cc (optimize_agr_copyprop): Don't try to copy
from statements that throw.

gcc/testsuite/ChangeLog:

* g++.dg/torture/noncall-eh-1.C: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
4 days agoforwprop: Change proping memset into memcpy into a forwprop rather than a backwalk
Andrew Pinski [Mon, 9 Jun 2025 06:13:23 +0000 (23:13 -0700)] 
forwprop: Change proping memset into memcpy into a forwprop rather than a backwalk

One thing I noticed while working on copy prop for aggregates is that we start with
a memcpy like statement and then walk backwards. This means we could have a few walks
backwards to see there was no statement for zeroing. Instead this changes the walk
backwards into a true forwprop. In the future we can expand to forwprop the zeroing
into say an function argument or something more than memcpy like statement.

This should speed up slightly the compile time performance since there will be less
memsets like statements than memcpy and there is only one walk forwards for memset like
staments instead of multiple walk backwards to find the memset.

Note this does add one extra improvement, the memcpy now does not need to have an address
as its dest argument; this could have been done before too but it was even more noticable
now because of the variable became only set so it was removed and the check was removed
as well.

There is also a fix on how ao_ref for the memset/memcpy is done, before it was just using
ao_ref_init which is wrong since it should instead of used ao_ref_init_from_ptr_and_size.
This part fixes PR 121422.

Changes since v1:
* v2: Add back limit on the walk which was missed in v1.
      Move the call to get_addr_base_and_unit_offset outside
of the vuse loop.
* v3: Remove extra check before the call to optimize_aggr_zeroprop_1.
      Fix setting up of ao_ref for memset (PR121422).

PR tree-optimization/118946
PR tree-optimization/121422

gcc/ChangeLog:

* tree-ssa-forwprop.cc (optimize_memcpy_to_memset): Remove.
(optimize_aggr_zeroprop_1): New function.
(optimize_aggr_zeroprop): New function.
(simplify_builtin_call): Don't call optimize_memcpy_to_memset
for memcpy but call optimize_aggr_zeroprop for memset.
(pass_forwprop::execute): Don't call optimize_memcpy_to_memset
for aggregate copies but rather call optimize_aggr_zeroprop
for aggregate stores.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
4 days agoforwprop: Change optimize_agr_copyprop into forward walk instead of backwards
Andrew Pinski [Sun, 8 Jun 2025 17:51:02 +0000 (10:51 -0700)] 
forwprop: Change optimize_agr_copyprop into forward walk instead of backwards

While thinking about how to implement the rest of the copy prop and makes sure not
to introduce some compile time problems, optimize_agr_copyprop should be changed
into a forwproping rather than looking backwards.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* tree-ssa-forwprop.cc (optimize_agr_copyprop): Change into a
forward looking (looking at vdef's uses) instead of a back
looking (vuse's def).

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
4 days agodiagnostics: enable nested diagnostics by default [PR116253]
David Malcolm [Fri, 8 Aug 2025 20:55:46 +0000 (16:55 -0400)] 
diagnostics: enable nested diagnostics by default [PR116253]

In GCC 15 I added an experimental nesting view in text sinks
for hierarchical diagnostics, such as C++ template problems.

This patch enables it for text sinks by default.  The old
behavior can be restored via -fno-diagnostics-show-nesting,
which the patch also adds to -fdiagnostics-plain-output.

The patch does not yet enable it for text sinks in sarif-replay.

gcc/ChangeLog:
PR diagnostics/116253
* common.opt (fdiagnostics-show-nesting): New option.
(fdiagnostics-show-nesting-locations): New option.
(fdiagnostics-show-nesting-levels): New option.
* common.opt.urls: Regenerate.
* diagnostics/context.cc (context::set_show_nesting): New.
(context::set_show_nesting_locations): New.
(context::set_show_nesting_levels): New.
* diagnostics/context.h (context::set_show_nesting): New decl.
(context::set_show_nesting_locations): New decl.
(context::set_show_nesting_levels): New decl.
* diagnostics/html-sink.cc: Tweak comment.
* diagnostics/output-spec.cc (text_scheme_handler::make_sink):
Rename "experimental-nesting" to "show-nesting" and enable by
default.  Rename "experimental-nesting-show-locations" to
"show-nesting-locations".  Rename
"experimental-nesting-show-levels" to "show-nesting-levels".
* diagnostics/sink.h (sink::dyn_cast_text_sink): New.
* diagnostics/text-sink.h (text_sink::dyn_cast_text_sink): New.
* doc/invoke.texi: Add -fdiagnostics-show-nesting,
-fdiagnostics-show-nesting-locations, and
-fdiagnostics-show-nesting-levels.  Update for changes to
output-spec.cc above.
* lto-wrapper.cc (merge_and_complain): Ignore
OPT_fdiagnostics_show_nesting,
OPT_fdiagnostics_show_nesting_locations, and
OPT_fdiagnostics_show_nesting_levels.
(append_compiler_options): Likewise.
(append_diag_options): Likewise.
* opts-common.cc (decode_cmdline_options_to_array): Add
"-fno-diagnostics-show-nesting" to -fdiagnostics-plain-output.
* opts.cc (common_handle_option): Handle the new options.
(gen_command_line_string): Ignore the new options.
* toplev.cc (general_init): Call set_show_nesting,
set_show_nesting_locations, and set_show_nesting_levels on
global_dc.

gcc/testsuite/ChangeLog:
PR diagnostics/116253
* g++.dg/concepts/nested-diagnostics-1-truncated.C: Update for
renamed keys to -fdiagnostics-set-output=text
* g++.dg/concepts/nested-diagnostics-1.C: Likewise.
* g++.dg/concepts/nested-diagnostics-2.C: Likewise.
* gcc.dg/plugin/diagnostic-test-nesting-no-show-nesting.c: New
test.
* gcc.dg/plugin/diagnostic-test-nesting-show-nesting.c: New test.
* gcc.dg/plugin/diagnostic-test-nesting-text-indented-show-levels.c:
Update for renamed keys to -fdiagnostics-set-output=text.
* gcc.dg/plugin/diagnostic-test-nesting-text-indented-unicode.c:
Likewise.
* gcc.dg/plugin/diagnostic-test-nesting-text-indented.c: Likewise.
* gcc.dg/plugin/plugin.exp: Add the new tests.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 days agodiagnostics: revamp of dumping of "diagnostics" internal state
David Malcolm [Fri, 8 Aug 2025 20:55:45 +0000 (16:55 -0400)] 
diagnostics: revamp of dumping of "diagnostics" internal state

The diagnostics subsystem has a handy dump feature, usable
during debugging via

  (gdb) call global_dc->dump ()

which prints copious amounts of information about the state
of the diagnostics subsystem to stderr.

This patch consolidates the implementation and extends it, adding
various per-sink data (generation options specific to each of text,
SARIF, and HTML).

No functional difference intended outside of the debugger.

gcc/ChangeLog:
* Makefile.in (OBJS-libcommon): Add diagnostics/dumping.o.
* diagnostics/buffering.cc: Include "diagnostics/dumping.h".
(buffer::dump): Reimplement using diagnostics::dumping.
* diagnostics/context.cc: Include "diagnostics/dumping.h".
(context::dump): Reimplement using diagnostics::dumping.
Use sink::dump_kind when listing the sinks.
(sink::dump): Reimplement using diagnostics::dumping.
(counters::dump): Likewise.
* diagnostics/dumping.cc: New file.
* diagnostics/dumping.h: New file.
* diagnostics/file-cache.cc: Include "diagnostics/dumping.h".
(file_cache::dump): Reimplement using diagnostics::dumping.
(file_cache_slot::dump): Likewise.
* diagnostics/html-sink.cc: Include "diagnostics/dumping.h".
(html_generation_options::dump): New.
(html_sink_buffer::dump): Reimplement using diagnostics::dumping.
(html_builder::dump): New.
(html_sink::dump): Reimplement using diagnostics::dumping.
Add dump of the html_builder.
(html_file_sink::dump): Replace with...
(html_file_sink::dump_kind): ...this.
(html_buffered_sink::dump_kind): New.
* diagnostics/html-sink.h (html_generation_options::dump): New
decl.
* diagnostics/sarif-sink.cc: Include "diagnostics/dumping.h".
(sarif_serialization_format_json::dump): New.
(sarif_builder::dump): New.
(sarif_sink_buffer::dump): Reimplement using diagnostics::dumping.
(sarif_sink::dump): Likewise.  Add dump of the sarif_builder.
(sarif_stream_sink::dump_kind): New.
(sarif_file_sink::dump): Replace with...
(sarif_file_sink::dump_kind): ...this.
(get_dump_string_for_sarif_version): New.
(sarif_generation_options::dump): New.
(class buffered_sink): Rename to...
(class sarif_buffered_sink): ...this.
(sarif_buffered_sink::dump_kind): New.
* diagnostics/sarif-sink.h (sarif_serialization_format::dump):
New.
(sarif_serialization_format_json::dump): New decl.
(sarif_generation_options::dump): New decl.
* diagnostics/sink.h (sink::dump_kind): New.
* diagnostics/text-sink.cc: Include "diagnostics/dumping.h".
(text_sink_buffer::dump): Reimplement using diagnostics::dumping.
(text_sink::dump): Likewise.  Emit fields m_show_nesting,
m_show_locations_in_nesting, and m_show_nesting_levels.
* diagnostics/text-sink.h (text_sink::dump_kind): New.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 days agodiagnostics: minor cleanups
David Malcolm [Fri, 8 Aug 2025 20:55:45 +0000 (16:55 -0400)] 
diagnostics: minor cleanups

No functional change intended.

gcc/ChangeLog:
* diagnostic.h (diagnostics::get_cwe_url): Move decl to
diagnostics/metadata.h.
(diagnostics::maybe_line_and_column): Move into
diagnostics::text_sink.
* diagnostics/context.cc: Update for maybe_line_and_column
becoming a static member of text_sink.
* diagnostics/metadata.h (diagnostics::get_cwe_url): Move decl
here from diagnostic.h.
* diagnostics/text-sink.cc (maybe_line_and_column): Convert to...
(text_sink::maybe_line_and_column): ...this.
* diagnostics/text-sink.h (text_sink::maybe_line_and_column): Move
here from diagnostic.h.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 days agodiagnostics: update signature of some callbacks
David Malcolm [Fri, 8 Aug 2025 20:55:44 +0000 (16:55 -0400)] 
diagnostics: update signature of some callbacks

No functional change intended.

gcc/cp/ChangeLog:
* error.cc (cp_adjust_diagnostic_info): Convert "context" arg from
ptr to const &.

gcc/ChangeLog:
* diagnostics/context.cc (context::get_any_inlining_info): Convert
"context" arg of m_set_locations_cb from ptr to const &.
(context::report_diagnostic): Convert "context" arg of
m_adjust_diagnostic_info from ptr to const &.
* diagnostics/context.h (context::set_locations_callback_t):
Likewise.
(context::set_adjust_diagnostic_info_callback): Likewise.
(context::m_adjust_diagnostic_info): Likewise.
* tree-diagnostic.cc (set_inlining_locations): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>