Fortran: Fix missing substring ref for allocatable saved vars [PR120483]
Compute a substring ref on an allocatable static character array
using pointer arithmetic. Using an array type corrupts type
layouting and crashes omp generation.
PR fortran/120483
gcc/fortran/ChangeLog:
* trans-expr.cc (gfc_conv_substring): Use pointer arithmetic on
static allocatable char arrays.
Hu, Lin1 [Mon, 10 Mar 2025 08:52:22 +0000 (16:52 +0800)]
i386: Add more peephole2 for APX NDD
The patch aims to optimize
movb (%rdi), %al
movq %rdi, %rbx
xorl %esi, %eax, %edx
movb %dl, (%rdi)
cmpb %sil, %al
jne
to
xorb %sil, (%rdi)
movq %rdi, %rbx
jne
Reduce 2 mov and 1 cmp instructions.
Due to APX NDD allowing the dest register and source register to be different,
some original peephole2 are invalid. Add new peephole2 patterns for APX NDD.
gcc/ChangeLog:
* config/i386/i386.md (define_peephole2): Define some new peephole2 for
APX NDD.
Hu, Lin1 [Wed, 19 Feb 2025 07:51:40 +0000 (15:51 +0800)]
i386: Add more forms peephole2 for adc/sbb
Enable -mapxf will change some patterns about adc/sbb.
Hence gcc will raise an extra mov like
movq 8(%rdi), %rax
adcq %rax, 8(%rsi), %rax
movq %rax, 8(%rdi)
rather than
movq 8(%rsi), %rax
adcq %rax, 8(%rdi)
The patch add more kinds of peephole2 to eliminate the extra mov.
gcc/ChangeLog:
* config/i386/i386.md: Add 4 new peephole2 by swap the original
peephole2's operands' order to support new pattern.
Martin Uecker [Sun, 1 Jun 2025 18:34:52 +0000 (20:34 +0200)]
c: Move checking assertions from recursion when forming composite types to avoid ICE.
The checking assertion in composite_type_internal for structures and unions may
fail if there are self-referential types. To avoid this, we move them out of
the recursion. This should also be more efficient and covers other types.
We have to ignore some cases where we form composite types with qualifiers
not matching (PR120510).
Pan Li [Mon, 2 Jun 2025 08:56:59 +0000 (16:56 +0800)]
RISC-V: Combine vec_duplicate + vidv.vv to vdiv.vx on GR2VR cost
This patch would like to combine the vec_duplicate + vdiv.vv to the
vdiv.vx. From example as below code. The related pattern will depend
on the cost of vec_duplicate from GR2VR. Then the late-combine will
take action if the cost of GR2VR is zero, and reject the combination
if the GR2VR cost is greater than zero.
Assume we have example code like below, GR2VR cost is 0.
#define DEF_VX_BINARY(T, OP) \
void \
test_vx_binary (T * restrict out, T * restrict in, T x, unsigned n) \
{ \
for (unsigned i = 0; i < n; i++) \
out[i] = in[i] OP x; \
}
The below test suites are passed for this patch.
* The rv64gcv fully regression test.
gcc/ChangeLog:
* config/riscv/riscv-v.cc (expand_vx_binary_vec_vec_dup): Add new
case for DIV op.
* config/riscv/riscv.cc (get_vector_binary_rtx_cost): Add new func
to get the cost of vector binary.
(riscv_rtx_costs): Add div rtx match and leverage above wrap to
get cost.
* config/riscv/vector-iterators.md: Add new op div to no_shift_vx_op.
Richard Biener [Tue, 3 Jun 2025 12:09:22 +0000 (14:09 +0200)]
tree-optimization/120517 - fix dataref group split math
DR_INIT is already measured in bytes, so there's no need to multiply
the DR_INIT difference of two DRs by the size of one of the DRs when
comparing that difference against MAX_BITSIZE_MODE_ANY_MODE.
PR tree-optimization/120517
* tree-vect-data-refs.cc (vect_analyze_data_ref_accesses):
Fix math in dataref group split.
Jonathan Wakely [Mon, 2 Jun 2025 10:24:32 +0000 (11:24 +0100)]
libstdc++: Fix errors and incorrect returns in atomic timed waits
The __detail::__wait_until function has a comment that should have been
removed when r16-1000-g225622398a9631 changed the return type from a
std::pair to a struct with three members.
The __atomic_wait_address_until_v and __atomic_wait_address_for_v
function templates are apparently never used or instantiated, because
they don't compile. This fixes them, but they're still unused. I plan
to make use of them in a later commit.
In __atomic_wait_address_until_v, __res.first in the return statement
should have also been changed when r16-1000-g225622398a9631 changed
__wait_result_type, and &__args should have been changed to just __args
by r16-988-g219bb905a60d95.
In __atomic_wait_address_for_v, the parameter is a copy & paste error
and should use chrono::duration not chrono::time_point
Fix _M_spin_until_impl so that the _M_has_val member of the result is
accurate. If the deadline has passed then it never enters the loop and
so never loads a fresh value, so _M_has_val should be false. There's
also a redundant clock::now() call in __spin_until_impl which can be
removed, we can reuse the call immediately before it.
libstdc++-v3/ChangeLog:
* include/bits/atomic_timed_wait.h (__detail::__wait_until):
Remove incorrect comment.
(__atomic_wait_address_until_v): Do not take address of __args in
call to __detail::__wait_until. Fix return statement to refer to
member of __wait_result_type.
(__atomic_wait_address_for_v): Change parameter type from
time_point to duration.
* src/c++20/atomic.cc (__spin_until_impl): Fix incorrect
return value. Reuse result of first call to clock.
Jonathan Wakely [Thu, 29 May 2025 10:40:59 +0000 (11:40 +0100)]
libstdc++: Replace some implicit conversions in std::vector
This replaces two implicit conversions from ptrdiff_t to size_t with
explicit conversions that include unreachable hints for the ptrdiff_t
value not being negative.
libstdc++-v3/ChangeLog:
* include/bits/stl_vector.h (~_Vector_base): Add unreachable
hint for negative capacity and cast to size_t explicitly.
* include/bits/vector.tcc (vector::_M_realloc_append): Use
size() instead of end() - begin().
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Jonathan Wakely [Tue, 27 May 2025 15:54:52 +0000 (16:54 +0100)]
libstdc++: Remove redundant macro checks in std.cc.in
__cpp_lib_any and __cpp_lib_chrono are defined unconditionally in C++20
and __cpp_lib_three_way_comparison and __cpp_lib_concepts depend on
front-end features which are definitely supported by GCC trunk and all
non-GCC compilers we care about.
libstdc++-v3/ChangeLog:
* src/c++23/std.cc.in: Remove redundant checks for feature test
macros that are always true.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
RISC-V: Use helper function to get FPR to VR move cost
Since last patch introduced get_fr2vr_cost () to get the correct cost to move
data from a floating-point to a vector register, this patch replaces existing
uses of the constant FR2VR.
RISC-V: Add pattern for vector-scalar multiply-add/sub [PR119100]
This pattern enables the combine pass (or late-combine, depending on the case)
to merge a vec_duplicate into a plus-mult or minus-mult RTL instruction.
Before this patch, we have two instructions, e.g.:
vfmv.v.f v6,fa0
vfmadd.vv v9,v6,v7
After, we get only one:
vfmadd.vf v9,fa0,v7
On SPEC2017's 503.bwaves_r, depending on the workload, the reduction in dynamic
instruction count varies from -4.66% to -4.75%.
PR target/119100
gcc/ChangeLog:
* config/riscv/autovec-opt.md (*<optab>_vf_<mode>): Add new pattern to
combine vec_duplicate + vfm{add,sub}.vv into vfm{add,sub}.vf.
* config/riscv/riscv-opts.h (FPR2VR_COST_UNPROVIDED): Define.
* config/riscv/riscv-protos.h (get_fr2vr_cost): Declare function.
* config/riscv/riscv.cc (riscv_rtx_costs): Add cost model for MULT with
VEC_DUPLICATE.
(get_fr2vr_cost): New function.
* config/riscv/riscv.opt: Add new option --param=fpr2vr-cost.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/vx_vf/vf-1-f16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-1-f32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-1-f64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-2-f16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-2-f32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-2-f64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-3-f16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-3-f32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-3-f64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-4-f16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-4-f32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf-4-f64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_mulop.h: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_mulop_data.h: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_mulop_run.h: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfmadd-run-1-f16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfmadd-run-1-f32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfmadd-run-1-f64.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfmsub-run-1-f16.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfmsub-run-1-f32.c: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/vf_vfmsub-run-1-f64.c: New test.
Jakub Jelinek [Tue, 3 Jun 2025 05:54:37 +0000 (07:54 +0200)]
libgomp: Fix up omp_target_memset-3.c test for C++ [PR120444]
The test PASSes for C, but FAILs for C++:
.../libgomp.c-c++-common/omp_target_memset-3.c: In function 'void test_it(void*, int, size_t)':
.../libgomp.c-c++-common/omp_target_memset-3.c:31:7: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
.../libgomp.c-c++-common/omp_target_memset-3.c:33:13: error: invalid conversion from 'void*' to 'int8_t*' {aka 'signed char*'} [-fpermissive]
.../libgomp.c-c++-common/omp_target_memset-3.c:10:19: note: initializing argument 1 of 'void init_val(int8_t*, int, size_t)'
.../libgomp.c-c++-common/omp_target_memset-3.c:37:14: error: invalid conversion from 'void*' to 'int8_t*' {aka 'signed char*'} [-fpermissive]
.../libgomp.c-c++-common/omp_target_memset-3.c:17:20: note: initializing argument 1 of 'void check_val(int8_t*, int, size_t)'
.../libgomp.c-c++-common/omp_target_memset-3.c:38:18: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
.../libgomp.c-c++-common/omp_target_memset-3.c:38:18: error: invalid conversion from 'void*' to 'int8_t*' {aka 'signed char*'} [-fpermissive]
.../libgomp.c-c++-common/omp_target_memset-3.c:17:20: note: initializing argument 1 of 'void check_val(int8_t*, int, size_t)'
.../libgomp.c-c++-common/omp_target_memset-3.c: In function 'int main()':
.../libgomp.c-c++-common/omp_target_memset-3.c:46:7: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
The following two-liner fixes that, tested on x86_64-linux and i686-linux.
2025-06-03 Jakub Jelinek <jakub@redhat.com>
PR libgomp/120444
* testsuite/libgomp.c-c++-common/omp_target_memset-3.c (test_it):
Change ptr argument type from void * to int8_t *.
(main): Change ptr variable type from void * to int8_t * and cast
omp_target_alloc result to the latter type.
Andrew Pinski [Mon, 2 Jun 2025 22:56:20 +0000 (15:56 -0700)]
switch-conversion: Mark CSWTCH as mergeable [PR120451]
When we have a smallish CSWTCH, it could be placed in the rodata.cst16
section so it can be merged with other constants across TUs.
The fix is simple; just mark the decl as mergable (DECL_MERGEABLE).
DECL_MERGEABLE was added with r14-1500-g4d935f52b0d5c0 specifically
to improve these kind of decls.
PR tree-optimization/120451
gcc/ChangeLog:
* tree-switch-conversion.cc (switch_conversion::build_one_array): Mark
the newly created decl as mergable.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/cswtch-6.c: New test.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
Alexandre Oliva [Mon, 2 Jun 2025 23:21:45 +0000 (20:21 -0300)]
[lra] force reg update after spilling to memory [PR120424]
In the added C++ testcase, a stack slot at a negative sp offset is
used to hold a value across a call.
There are a couple of causes that directly lead to this outcome:
- the -fstack-clash-protection and -fnon-call-exception options, that
cause arm_frame_pointer_required to flip from false to true when the
first pseudo gets spilled to memory;
- when the affected pseudo is spilled to memory, we fail to update lra
regno info, because the insns that reference it are already on the
lra_constraint_insn_stack;
There is another potentially-related issue:
- when we notice that the frame pointer can no longer be eliminated to
the stack pointer, we immediately clear can_eliminate, and also
prev_can_eliminate, but update_reg_eliminate relied on the latter to
tell that it needs to propagate a previous_offset to the
newly-selected elimination, or restore the original offsets.
This patch ensures that we update insn register info after spilling a
pseudo to memory, and enables update_reg_eliminate to recognize the
case in which a previously-preferred elimination is disabled
regardless of prev_can_eliminate.
for gcc/ChangeLog
PR rtl-optimization/120424
PR middle-end/118939
* lra-spills.cc (spill_pseudos): Update insn regno info.
* lra-eliminations.cc (update_reg_eliminate): Recognize
disabling of active elimination regardless of
prev_can_eliminate.
Robert Dubner [Mon, 2 Jun 2025 19:55:20 +0000 (15:55 -0400)]
cobol: Honor HAVE_CLOCK_GETTIME and HAVE_GETTIMEOFDAY. [PR119975]
These changes cause genapi.cc to use whichever of clock_gettime() or
gettimeofday() are available. This prevents compilation errors on
systems where clock_gettime() is not available.
Iain Sandoe [Sat, 31 May 2025 15:13:40 +0000 (16:13 +0100)]
c++, coroutines: Some cleanups in build_actor.
We were incorrectly guarding all the frame cleanups on the
basis of frame_needs_free (which is always set for the present
code-gen since we have no allocation elision). The net result
being that the (incorrect) code was behaving as expected.
We built, but never used, a label for the frame destruction;
in practice it is never triggered independently of the promise
and argument copy destruction.
Finally there are a few instances where we had been building
expressions manually rather than using higher-level APIs.
gcc/cp/ChangeLog:
* coroutines.cc (build_actor_fn): Remove an unused
label, guard the frame deallocation correctly, use
simpler APIs to build if and return statements.
Jonathan Wakely [Wed, 21 May 2025 19:12:50 +0000 (20:12 +0100)]
libstdc++: Implement LWG 2439 for std::unique_copy [PR120386]
The current overload set for __unique_copy handles three cases:
- The input range uses forward iterators, the output range does not.
This is the simplest case, and can just compare adjacent elements of
the input range.
- Neither the input range nor output range use forward iterators.
This requires a local variable copied from the input range and updated
by assigning each element to the local variable.
- The output range uses forward iterators.
For this case we compare the current element from the input range with
the element just written to the output range.
There are two problems with this implementation. Firstly, the third case
assumes that the value type of the output range can be compared to the
value type of the input range, which might not be possible at all, or
might be possible but give different results to comparing elements of
the input range. This is the problem identified in LWG 2439.
Secondly, the third case is used when both ranges use forward iterators,
even though the first case could (and should) be used. This means that
we compare elements from the output range instead of the input range,
with the problems described above (either not well-formed, or might give
the wrong results).
The cause of the second problem is that the overload for the first case
looks like:
When the output range uses forward iterators this overload cannot be
used, because forward_iterator_tag does not inherit from
output_iterator_tag, so is not convertible to it.
To fix these problems we need to implement the resolution of LWG 2439 so
that the third case is only used when the value types of the two ranges
are the same. This ensures that the comparisons are well behaved. We
also need to ensure that the first case is used when both ranges use
forward iterators.
This change replaces a single step of tag dispatching to choose between
three overloads with two step of tag dispatching, choosing between two
overloads at each step. The first step dispatches based on the iterator
category of the input range, ignoring the category of the output range.
The second step only happens when the input range uses non-forward
iterators, and dispatches based on the category of the output range and
whether the value type of the two ranges is the same. So now the cases
that are handled are:
- The input range uses forward iterators.
- The output range uses non-forward iterators or a different value type.
- The output range uses forward iterators and has the same value type.
For the second case, the old code used __gnu_cxx::__ops::__iter_comp_val
to wrap the predicate in another level of indirection. That seems
unnecessary, as we can just use a pointer to the local variable instead
of an iterator referring to it.
During review of this patch, it was discovered that all known
implementations of std::unique_copy and ranges::unique_copy (except
cmcstl2) disagree with the specification. The standard (and the SGI STL
documentation) say that it uses pred(*i, *(i-1)) but everybody uses
pred(*(i-1), *i) instead, and apparently always has done. This patch
adjusts ranges::unique_copy to be consistent.
In the first __unique_copy overload, the local copy of the iterator is
changed to be the previous position not the next one, so that we use
++first as the "next" iterator, consistent with the logic used in the
other overloads. This makes it easier to compare them, because we aren't
using pred(*first, *next) in one and pred(something, *first) in the
others. Instead it's always pred(something, *first).
libstdc++-v3/ChangeLog:
PR libstdc++/120386
* include/bits/ranges_algo.h (__unique_copy_fn): Reorder
arguments for third case to match the first two cases.
* include/bits/stl_algo.h (__unique_copy): Replace three
overloads with two, depending only on the iterator category of
the input range. Dispatch to __unique_copy_1 for the
non-forward case.
(__unique_copy_1): New overloads for the case where the input
range uses non-forward iterators.
(unique_copy): Only pass the input range category to
__unique_copy.
* testsuite/25_algorithms/unique_copy/lwg2439.cc: New test.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Jason Merrill [Mon, 2 Jun 2025 14:09:07 +0000 (10:09 -0400)]
c++: __is_destructible fixes [PR107600]
destructible_expr was wrongly assuming that TO is a class type.
When is_xible_helper was added in r8-742 it returned early for abstract
class types, which is correct for __is_constructible, but not
__is_assignable or (now) __is_destructible.
PR c++/107600
gcc/cp/ChangeLog:
* method.cc (destructible_expr): Handle non-classes.
(constructible_expr): Check for abstract class here...
(is_xible_helper): ...not here.
Tomasz Kamiński [Wed, 28 May 2025 09:16:22 +0000 (11:16 +0200)]
libstdc++: Pass small trivial types by value in polymorphic wrappers
This patch adjust the passing of parameters for the move_only_function,
copyable_function and function_ref. For types that are declared as being passed
by value in signature template argument, they are passed by value to the invoker,
when they are small (at most two pointers), trivially move constructible and
trivially destructible. The latter guarantees that passing them by value has not
user visible side effects.
In particular, this extends the set of types forwarded by value, that was
previously limited to scalars, to also include specializations of std::span and
std::string_view, and similar standard and program defined-types.
Checking the suitability of the parameter types requires the types to be complete.
As a consequence, the implementation imposes requirements on instantiation of
move_only_function and copyable_function. To avoid producing the errors from
the implementation details, a static assertion was added to partial
specializations of copyable_function, move_only_function and function_ref.
The static assertion uses existing __is_complete_or_unbounded, as arrays type
parameters are automatically decayed in function type.
Standard already specifies in [res.on.functions] p2.5 that instantiating these
partial specialization with incomplete types leads to undefined behavior.
libstdc++-v3/ChangeLog:
* include/bits/funcwrap.h (__polyfunc::__pass_by_rref): Define.
(__polyfunc::__param_t): Update to use __pass_by_rref.
* include/bits/cpyfunc_impl.h:: Assert that are parameters type
are complete.
* include/bits/funcref_impl.h: Likewise.
* include/bits/mofunc_impl.h: Likewise.
* testsuite/20_util/copyable_function/call.cc: New test.
* testsuite/20_util/function_ref/call.cc: New test.
* testsuite/20_util/move_only_function/call.cc: New test.
* testsuite/20_util/copyable_function/conv.cc: New test.
* testsuite/20_util/function_ref/conv.cc: New test.
* testsuite/20_util/move_only_function/conv.cc: New test.
* testsuite/20_util/copyable_function/incomplete_neg.cc: New test.
* testsuite/20_util/function_ref/incomplete_neg.cc: New test.
* testsuite/20_util/move_only_function/incomplete_neg.cc: New test.
Reviewed-by: Patrick Palka <ppalka@redhat.com> Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
This patch implements C++26 std::polymorphic as specified in P3019 with
amendment to move assignment from LWG 4251.
The implementation always allocate stored object on the heap. The manager
function (_M_manager) is similary keep with the object (polymorphic::_Obj),
which reduces the size of the polymorphic to size of the single pointer plus
allocator (that is declared with [[no_unique_address]]).
The implementation does not not use small-object optimization (SSO). We may
consider adding this in the future, as SSO is allowed by the standard. However,
storing any polimorphic object will require providing space for two pointers
(manager function and vtable pointer) and user-declared data members.
PR libstdc++/119152
libstdc++-v3/ChangeLog:
* include/bits/indirect.h (std::polymorphic, pmr::polymorphic)
[__glibcxx_polymorphic]: Define.
* include/bits/version.def (polymorphic): Define.
* include/bits/version.h: Regenerate.
* include/std/memory: Define __cpp_lib_polymorphic.
* testsuite/std/memory/polymorphic/copy.cc: New test.
* testsuite/std/memory/polymorphic/copy_alloc.cc: New test.
* testsuite/std/memory/polymorphic/ctor.cc: New test.
* testsuite/std/memory/polymorphic/ctor_poly.cc: New test.
* testsuite/std/memory/polymorphic/incomplete.cc: New test.
* testsuite/std/memory/polymorphic/invalid_neg.cc: New test.
* testsuite/std/memory/polymorphic/move.cc: New test.
* testsuite/std/memory/polymorphic/move_alloc.cc: New test.
Co-authored-by: Tomasz Kamiński <tkaminsk@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
Stafford Horne [Sat, 31 May 2025 05:54:58 +0000 (06:54 +0100)]
or1k: Fix struct return test
In or1k structs are returned from functions using the memory address
passed in r3. In the current version of GCC the struct stores changed
from r11 (the return value) to r3 the incoming memory address. Both of
are valid.
Adjust the test to match what GCC is producing now.
Stafford Horne [Mon, 12 May 2025 20:47:21 +0000 (21:47 +0100)]
or1k: Support long jump offsets with -mcmodel=large
The -mcmodel=large option was originally added to handle generation of
large binaries with large PLTs. However, when compiling the Linux
kernel with allyesconfig the output binary is so large that the jump
instruction 26-bit immediate is not large enough to store the jump
offset to some symbols when linking. Example error:
relocation truncated to fit: R_OR1K_INSN_REL_26 against symbol `do_fpe_trap' defined in .text section in arch/openrisc/kernel/traps.o
We fix this by forcing jump offsets to registers when -mcmodel=large.
Note, to get the Linux kernel allyesconfig config to work with OpenRISC,
this patch is needed along with some other patches to the Linux hand
coded assembly bits.
gcc/ChangeLog:
* config/or1k/predicates.md (call_insn_operand): Add condition
to not allow symbol_ref operands with TARGET_CMODEL_LARGE.
* config/or1k/or1k.opt: Document new -mcmodel=large
implications.
* doc/invoke.texi: Likewise.
gcc/testsuite/ChangeLog:
* gcc.target/or1k/call-1.c: New test.
* gcc.target/or1k/got-1.c: New test.
Some tests have 'dg-do link' but currently require 'tls' which is a
compile-only check.
In some configurations of arm-none-eabi, the 'tls' effective-target
can be successful although these tests fail to link with
undefined reference to `__aeabi_read_tp'
This patch as a new tls_link effective target which makes sure we can
build an executable.
Kito Cheng [Wed, 28 May 2025 09:59:11 +0000 (17:59 +0800)]
RISC-V: Adjust build rule for gen-riscv-ext-opt and gen-riscv-ext-texi
Separate the build rules to compile and link stage to make sure
BUILD_LINKERFLAGS and BUILD_LDFLAGS are applied correctly.
We hit this issue when we try to build GCC with non-system-default g++,
and it use newer libstdc++, and then got error from using older libstdc++ from
system, that should not happened if we link with -static-libgcc and
-static-libstdc++.
gcc/ChangeLog:
* config/riscv/t-riscv: Adjust build rule for gen-riscv-ext-opt
and gen-riscv-ext-texi.
Kito Cheng [Tue, 27 May 2025 02:10:15 +0000 (10:10 +0800)]
c++tools: Don't check --enable-default-pie.
`--enable-default-pie` is an option to specify whether to enable
position-independent executables by default for `target`.
However c++tools is build for `host`, so it should just follow
`--enable-host-pie` option to determine whether to build with
position-independent executables or not.
NOTE:
I checked PR 98324 and build with same configure option
(`--enable-default-pie` and lto bootstrap) on x86-64 linux to make sure
it won't cause same problem.
OpenMP: Handle more cases in user/condition selector
Tobias had noted that the C front end was not treating C23 constexprs
as constant in the user/condition selector property, which led to
missed opportunities to resolve metadirectives at parse time.
Additionally neither C nor C++ was permitting the expression to have
pointer or floating-point type -- the former being a common idiom in
other C/C++ conditional expressions. By using the existing front-end
hooks for the implicit conversion to bool in conditional expressions,
we also get free support for using a C++ class object that has a bool
conversion operator in the user/condition selector.
gcc/c/ChangeLog
* c-parser.cc (c_parser_omp_context_selector): Call
convert_lvalue_to_rvalue and c_objc_common_truthvalue_conversion
on the expression for OMP_TRAIT_PROPERTY_BOOL_EXPR.
gcc/cp/ChangeLog
* cp-tree.h (maybe_convert_cond): Declare.
* parser.cc (cp_parser_omp_context_selector): Call
maybe_convert_cond and fold_build_cleanup_point_expr on the
expression for OMP_TRAIT_PROPERTY_BOOL_EXPR.
* pt.cc (tsubst_omp_context_selector): Likewise.
* semantics.cc (maybe_convert_cond): Remove static declaration.
Jerry DeLisle [Sat, 31 May 2025 15:57:22 +0000 (08:57 -0700)]
Fortran: Fix handling of parsed format strings.
Previously parsed strings with errors were being cached such
that subsequent use of the format string were not being
checked for errors.
PR libfortran/119856
libgfortran/ChangeLog:
* io/format.c (parse_format_list): Set the fmt->error
message for missing comma.
(parse_format): Do not cache the parsed format string
if a previous error ocurred.
Andrew Pinski [Sat, 31 May 2025 22:10:14 +0000 (15:10 -0700)]
forwprop: Manually rename the virtual mem op for complex and vector loads prop
There are two places which forwprop replaces an original load to a few different loads.
Both can set the vuse manually instead of relying on update_ssa.
One is doing a complex load followed by REAL/IMAG_PART only
And the other is very similar but for vector loads followed by BIT_FIELD_REF.
Since this was the last place that needed to handle updating the ssa form,
Remove the TODO_update_ssa also from the pass.
gcc/ChangeLog:
* tree-ssa-forwprop.cc (optimize_vector_load): Set the vuse manually
on the new load statements. Also remove forward declaration since
the definition is before the first use.
(pass_forwprop::execute): Likewise for complex loads.
(pass_data_forwprop): Remove TODO_update_ssa.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
Martin Uecker [Thu, 29 May 2025 15:17:12 +0000 (17:17 +0200)]
c: fix ICE related to tagged types with attributes in diagnostics [PR120380]
get_aka_type will create a new type for diagnostics, but for tagged types
attributes will then be ignored with a warning. This can lead to reentering
warning code which leads to an ICE. Fix this by ignoring the attributes
for tagged types.
PR c/120380
gcc/c/ChangeLog:
* c-objc-common.cc (get_aka_type): Ignore attributes for tagged types.
gcc/testsuite/ChangeLog:
* gcc.dg/pr120380.c: New test.
xtensa: Remove an unnecessary constraint modifier from movsf_internal insn pattern
In this case, there is no need to consider reloading when memory is the
destination. On the other hand, when memory is the source, reloading
read from constant pool becomes double indirection and should obviously
be avoided.
gcc/ChangeLog:
* config/xtensa/xtensa.md (movsf_internal):
Remove destination side constraint modifier '^' in the third
alternative.
Implement TARGET_IRA_CHANGE_PSEUDO_ALLOCNO_CLASS in order to avoid using
ALL_REGS rclass as is done on other targets, instead of overestimating
between integer and FP register move costs.
gcc/ChangeLog:
* config/xtensa/xtensa.cc
(xtensa_ira_change_pseudo_allocno_class):
New prototype and function.
(TARGET_IRA_CHANGE_PSEUDO_ALLOCNO_CLASS): Define macro.
(xtensa_register_move_cost):
Change between integer and FP register move cost to a value
based on actual behavior, i.e. 2, the default and the same as
the move cost between integer registers.
Gaius Mulley [Sun, 1 Jun 2025 00:05:55 +0000 (01:05 +0100)]
PR modula2/120497: error is generated for good code when returning a pointer var variable
The return type checking needs to skip over the Lvalue part of the VAR
parameter or variable.
gcc/m2/ChangeLog:
PR modula2/120497
* gm2-compiler/M2Range.mod (IsAssignmentCompatible): Remove from
import list.
(FoldTypeReturnFunc): Rewrite to skip the Lvalue of a var
variable.
(CodeTypeReturnFunc): Ditto.
(CodeTypeIndrX): Call AssignmentTypeCompatible rather than
IsAssignmentCompatible.
(FoldTypeIndrX): Ditto.
gcc/testsuite/ChangeLog:
PR modula2/120497
* gm2/pim/pass/ReturnType.mod: New test.
* gm2/pim/pass/ReturnType2.mod: New test.
Andrew Pinski [Fri, 30 May 2025 06:50:08 +0000 (23:50 -0700)]
Have TODO_verify_* not set by any pass
This is a follow up to the patch set starting at https://gcc.gnu.org/pipermail/gcc-patches/2014-April/386650.html.
Currently TODO_verify_{il,all} is set by a few passes as TODOs afterwards but
we don't need to do that any more. Those were mostly removed back in
https://gcc.gnu.org/pipermail/gcc-patches/2014-May/387647.html
And now since TODO_verify_all is no longer used, remove it too.
Removes last_verified from the function structure since it is always 0 before the
call to execute_todo that has TODO_verify_all set on it.
Also this removes the ability for good to use TODO_verify_il from the passes and reserves
bit 31 of the TODO for the verfification and internally only the passes.cc code.
gcc/ChangeLog:
* function.h (struct function): Remove last_verified.
* gimple-harden-conditionals.cc (pass_data_harden_compares): Remove
TODO_verify_il.
(pass_data_harden_conditional_branches): Likewise.
* gimple-harden-control-flow.cc (pass_harden_control_flow_redundancy::execute):
Don't return TODO_verify_il.
* ipa-strub.cc (pass_data_ipa_strub): Remove TODO_verify_il.
* passes.cc (TODO_verify_il): Define.
(execute_function_todo): Don't use or set last_verified.
(clear_last_verified): Remove.
(execute_one_ipa_transform_pass): Update comment before execute_todo.
Assert that none of the todos have TODO_verify_il set on it.
(execute_one_pass): Don't call clear_last_verified on all functions.
Assert that none of the todos have TODO_verify_il set on it.
* tree-inline.cc (initialize_cfun): Don't copy last_verified.
* tree-pass.h (TODO_verify_all): Remove.
* tree-vrp.cc (pass_data_early_vrp): Remove TODO_verify_all.
(pass_data_fast_vrp): Likewise.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
Richard Biener [Fri, 30 May 2025 12:11:47 +0000 (14:11 +0200)]
tree-optimization/120357 - ICE with early break vectorization
When doing early break vectorization of a loop with a conditional
reduction the epilog creation code is confused as to before which exit
to insert the conditional reduction induction IV update. The
following make sure this is done before the main IV exit.
PR tree-optimization/120357
* tree-vect-loop.cc (vect_create_epilog_for_reduction): Create
the conditional reduction induction IV increment before the
main IV exit.
* gcc.dg/vect/vect-early-break_136-pr120357.c: New testcase.
Gaius Mulley [Sat, 31 May 2025 00:53:48 +0000 (01:53 +0100)]
PR modula2/120389 Assigning wrong type to an array causes an ICE
This patch provides follow on fixes for undetected type violations
which can occur then Lvalues are generated during assignment.
For example array accesses and with statements. The type checker
M2Check.mod has been overhauled and cleaned up.
gcc/ChangeLog:
PR modula2/120389
* doc/gm2.texi (-fm2-strict-type-reason): Document new flag.
gcc/m2/ChangeLog:
PR modula2/120389
* gm2-compiler/M2Check.def (AssignmentTypeCompatible): Add new
parameter enableReason.
* gm2-compiler/M2Check.mod (EquivalenceProcedure): New type.
(falseReason2): New procedure function.
(falseReason1): Ditto.
(falseReason0): Ditto.
(checkTypeEquivalence): Rewrite.
(checkUnboundedArray): Ditto.
(checkUnbounded): Ditto.
(checkArrayTypeEquivalence): Ditto.
(checkCharStringTypeEquivalence): Ditto.
(buildError4): Add false reason.
(buildError2): Ditto.
(IsTyped): Use GetDType.
(IsTypeEquivalence): New procedure function.
(checkVarTypeEquivalence): Ditto.
(checkVarEquivalence ): Rewrite.
(checkConstMeta): Ditto.
(checkEnumField): New procedure function.
(checkEnumFieldEquivalence): Ditto.
(checkSubrangeTypeEquivalence): Rewrite.
(checkSystemEquivalence): Ditto.
(checkTypeKindViolation): Ditto.
(doCheckPair): Ditto.
(InitEquivalenceArray): New procedure.
(addEquivalence): Ditto.
(checkProcType): Rewrite.
(deconstruct): Deallocate reason string.
(AssignmentTypeCompatible): Initialize reason and reasonEnable
fields.
(ParameterTypeCompatible): Ditto.
(doExpressionTypeCompatible): Ditto.
* gm2-compiler/M2GenGCC.mod (CodeIndrX) Rewrite.
(CheckBinaryExpressionTypes): Rewrite and simplify now that the
type checker is more robust.
(CheckElementSetTypes): Ditto.
(CodeXIndr): Add new range assignment type check.
* gm2-compiler/M2MetaError.def: Correct comments.
* gm2-compiler/M2Options.def (SetStrictTypeAssignment): New procedure.
(SetStrictTypeReason): Ditto.
* gm2-compiler/M2Options.mod: (SetStrictTypeAssignment): New procedure.
(SetStrictTypeReason): Ditto.
(StrictTypeReason): Initialize.
(StrictTypeAssignment): Ditto.
* gm2-compiler/M2Quads.mod (CheckBreak): Delete.
(BreakQuad): New global variable.
(BreakAtQuad): Delete.
(gdbhook): New procedure.
(BreakWhenQuadCreated): Ditto.
(CheckBreak): Ditto.
(Init): Call BreakWhenQuadCreated and gdbhook.
(doBuildAssignment): Add type assignment range check.
(CheckProcTypeAndProcedure): Only check if the procedure
types differ.
(doIndrX): Add type IndrX range check.
(CheckReturnType): Add range return type check.
* gm2-compiler/M2Range.def (InitTypesIndrXCheck): New procedure
function.
(InitTypesReturnTypeCheck): Ditto.
* gm2-compiler/M2Range.mod (InitTypesIndrXCheck): New procedure
function.
(InitTypesReturnTypeCheck): Ditto.
(HandlerExists): Add new clauses.
(FoldAssignment): Pass extra FALSE parameter to
AssignmentTypeCompatible.
(FoldTypeReturnFunc): New procedure.
(FoldTypeAssign): Ditto.
(FoldTypeIndrX): Ditto.
(CodeTypeAssign): Rewrite.
(CodeTypeIndrX): New procedure.
(CodeTypeReturnFunc): Ditto.
(FoldTypeCheck): Add new case clauses.
(CodeTypeCheck): Ditto.
(FoldRangeCheckLower): Ditto.
(IssueWarning): Ditto.
* gm2-gcc/m2options.h (M2Options_SetStrictTypeAssignment): New
function prototype.
(M2Options_SetStrictTypeReason): Ditto.
* gm2-lang.cc (gm2_langhook_handle_option): New case clause
OPT_fm2_strict_type_reason.
* lang.opt (-fm2-strict-type-reason): New option.
gcc/testsuite/ChangeLog:
PR modula2/120389
* gm2/pim/fail/testcharint.mod: New test.
* gm2/pim/fail/testindrx.mod: New test.
* gm2/pim/pass/testxindr.mod: New test.
* gm2/pim/pass/testxindr2.mod: New test.
* gm2/pim/pass/testxindr3.mod: New test.
David Malcolm [Fri, 30 May 2025 23:57:46 +0000 (19:57 -0400)]
diagnostics: implement highlight-a vs -b in HTML output [PR116792]
Update HTML output so that it renders highlight-a vs highlight-b
via <span> tags in the message itself, in the quoted source line,
in the underlines, and in the labels and their vertical bars.
Example output can be seen at:
https://dmalcolm.fedorapeople.org/gcc/2025-05-28/diagnostic-ranges.c.html
gcc/ChangeLog:
PR other/116792
* diagnostic-format-html.cc (HTML_STYLE): Add ".highlight-a" and
".highlight-b".
(html_builder::make_element_for_diagnostic): Handle begin_color
and end_color.
* diagnostic-show-locus.cc (to_html::to_html): Add "richloc"
param and use it to initialize m_richloc.
(to_html::colorize_text_for_range_idx): Drop.
(to_html::get_location_range_by_idx): New.
(to_html::get_highlight_color_for_range_idx): New.
(to_html::m_richloc): New field.
(print_html_span_start): Update for new param of to_html ctor.
(line_printer::m_was_in_range_p): New field.
(line_printer::m_last_range_idx): New field.
(layout_printer<Sink>::print_source_line): Use set_in_range
and set_outside_range rather than colorization calls.
(layout_printer<Sink>::set_in_range): New.
(layout_printer<Sink>::set_outside_range): New.
(layout_printer<Sink>::print_annotation_line): Use set_in_range
and set_outside_range rather than colorization calls.
(layout_printer<to_text>::begin_label): Convert param from label
to state_idx. Add "is_label_text" param and use it to guard logic
for turning off colorization within paths.
(layout_printer<to_html>::begin_label): Likewise. Push <span>
for any highlight color.
(layout_printer<to_text>::end_label): Likewise.
(layout_printer<to_text>::end_label): Likewise, popping the
<span>.
(layout_printer<Sink>::print_any_labels): Convert begin/end_label
calls to pass in state_idx rather than label. Use begin/end_label
rather than colorization calls.
(layout_printer<Sink>::layout_printer): Likewise.
(layout_printer<Sink>::layout_printer): Initialize new fields.
(diagnostic_source_print_policy::print_as_html): Update for new
param of to_html ctor.
gcc/testsuite/ChangeLog:
PR other/116792
* gcc.dg/format/diagnostic-ranges-html.py: New test script.
* gcc.dg/format/diagnostic-ranges.c: Add HTML generation to
options, and invoke the new script to check the HTML output.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Joseph Myers [Fri, 30 May 2025 20:15:53 +0000 (20:15 +0000)]
c: Update description of C library facilities provided by GCC for C23
The documentation of which standard C library facilities (headers) are
provided by GCC, as being those required of freestanding
implementations, is reasonably accurate for C99 and before (if you
ignore the provision of <tgmath.h> for non-GNU targets). It's less
accurate for C11, since we provide <stdatomic.h> although that's not
required for freestanding implementations. And it's very inaccurate
for C23, which specifies that freestanding implementations also
provide most of <string.h>, memalignment from <stdlib.h>, and, when
supporting Annex F, also <fenv.h>, <math.h> and the strto*
floating-point numeric conversion functions from <stdlib.h>.
I don't think expanding the scope of the C library facilities GCC
provides to include all those extra facilities specified by C23 for
freestanding implementations is a good idea. (Indeed, GCC once used
to install assert.h on some platforms, but stopped doing so a long
time ago.) Rather, it seems better to document that in both the
freestanding and the hosted cases, GCC is intended to provide the
compiler part of a conforming implementation, to be combined with a
corresponding library implementation, rather than providing all the
required library facilities in either case.
The rule about which headers GCC provides is then described in terms
of headers not declaring functions with external linkage, which is
much closer to existing practice, although still not perfect in all
cases (<stdatomic.h>, although mainly providing type-generic
operations, does declare a few non-type-generic functions that we
provide in libatomic).
A paragraph in trouble.texi that talks about freestanding
implementations with -ansi -pedantic is not changed (given that the
description in terms of freestanding implementations is sufficiently
accurate for C90); if the -ansi there were changed to an option for a
more recent standard, a corresponding change to that paragraph might
be needed as well.
Tested with "make info html pdf".
* doc/standards.texi (C Language): Document library facilities
provided in terms of headers not declaring functions with external
linkage, not in terms of headers required of freestanding
implementations.
* doc/sourcebuild.texi (Subdirectories, Headers): Likewise.
* doc/trouble.texi (Standard Libraries): Likewise.
Harald Anlauf [Fri, 30 May 2025 17:25:15 +0000 (19:25 +0200)]
Fortran: parameter inquiries of constant complex arrays [PR102599,PR114022]
PR fortran/102599
PR fortran/114022
gcc/fortran/ChangeLog:
* expr.cc (simplify_complex_array_inquiry_ref): Helper function for
simplification of inquiry references (%re/%im) of constant complex
arrays.
(find_inquiry_ref): Use it for handling %re/%im inquiry references
of complex arrays.
(scalarize_intrinsic_call): Fix frontend memleak.
* primary.cc (gfc_match_varspec): When the reference is NULL, the
previous simplification has succeeded in evaluating inquiry
references also of arrays.
Qing Zhao [Thu, 29 May 2025 15:59:41 +0000 (15:59 +0000)]
C: Flex array in union followed by a structure field is not reported [PR120354]
There is only one last_field for a structure type, but there might
be multiple last_fields for a union type, therefore we should ORed
the result of TYPE_INCLUDES_FLEXARRAY for multiple last_fields of
a union type.
PR c/120354
gcc/c/ChangeLog:
* c-decl.cc (finish_struct): Or the results for TYPE_INCLUDES_FLEXARRAY.
Qing Zhao [Wed, 28 May 2025 21:13:38 +0000 (21:13 +0000)]
C: Flex array in the middle via type alias is not reported [PR120353]
The root cause of the bug is: the TYPE_INCLUDES_FLEXARRAY marking of the
structure type is not copied to its aliased type.
The fix is to copy this marking to all the variant types of the current
structure type.
PR c/120353
gcc/c/ChangeLog:
* c-decl.cc (finish_struct): Copy TYPE_INCLUDES_FLEXARRAY marking
to all the variant types of the current structure type.
Pan Li [Thu, 29 May 2025 13:33:44 +0000 (21:33 +0800)]
RISC-V: Add test cases for avg_ceil vaadd implementation
Add asm and run testcase for avg_ceil vaadd implementation.
The below test suites are passed for this patch series.
* The rv64gcv fully regression test.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/avg.h: Add test helper macros.
* gcc.target/riscv/rvv/autovec/avg_data.h: Add test data for
avg_ceil.
* gcc.target/riscv/rvv/autovec/avg_ceil-1-i16-from-i32.c: New test.
* gcc.target/riscv/rvv/autovec/avg_ceil-1-i16-from-i64.c: New test.
* gcc.target/riscv/rvv/autovec/avg_ceil-1-i32-from-i64.c: New test.
* gcc.target/riscv/rvv/autovec/avg_ceil-1-i8-from-i16.c: New test.
* gcc.target/riscv/rvv/autovec/avg_ceil-1-i8-from-i32.c: New test.
* gcc.target/riscv/rvv/autovec/avg_ceil-1-i8-from-i64.c: New test.
* gcc.target/riscv/rvv/autovec/avg_ceil-run-1-i16-from-i32.c: New test.
* gcc.target/riscv/rvv/autovec/avg_ceil-run-1-i16-from-i64.c: New test.
* gcc.target/riscv/rvv/autovec/avg_ceil-run-1-i32-from-i64.c: New test.
* gcc.target/riscv/rvv/autovec/avg_ceil-run-1-i8-from-i16.c: New test.
* gcc.target/riscv/rvv/autovec/avg_ceil-run-1-i8-from-i32.c: New test.
* gcc.target/riscv/rvv/autovec/avg_ceil-run-1-i8-from-i64.c: New test.
Pan Li [Thu, 29 May 2025 13:19:36 +0000 (21:19 +0800)]
RISC-V: Leverage vaadd.vv for signed standard name avg_ceil
The avg_ceil has the rounding mode towards +inf, while the
vaadd.vv has the rnu which totally match the sematics. From
RVV spec, the fixed vaadd.vv with rnu,
roundoff_signed(v, d) = (signed(v) >> d) + r
r = v[d - 1]
For vaadd, d = 1, then we have
roundoff_signed(v, 1) = (signed(v) >> 1) + v[0]
If v[0] is bit 0, nothing need to do as there is no rounding.
If v[0] is bit 1, there will be rounding with 2 cases.
Case 1: v is positive.
roundoff_signed(v, 1) = (signed(v) >> 1) + 1, aka round towards +inf
roundoff_signed(2 + 3, 1) = (5 >> 1) + 1 = 3
Case 2: v is negative.
roundoff_signed(v, 1) = (signed(v) >> 1) + 1, aka round towards +inf
roundoff_signed(-9 + 2, 1) = (-7 >> 1) + 1 = -4 + 1 = -3
Thus, we can leverage the vaadd with rnu directly for avg_ceil.
The below test suites are passed for this patch series.
* The rv64gcv fully regression test.
gcc/ChangeLog:
* config/riscv/autovec.md (avg<v_double_trunc>3_ceil): Add insn
expand to leverage vaadd with rnu directly.
Waffl3x [Mon, 26 May 2025 08:38:27 +0000 (02:38 -0600)]
Add 'libgomp.c++/target-flex-[...].C' test cases
libgomp/ChangeLog:
* testsuite/libgomp.c++/target-flex-10.C: New test.
* testsuite/libgomp.c++/target-flex-100.C: New test.
* testsuite/libgomp.c++/target-flex-101.C: New test.
* testsuite/libgomp.c++/target-flex-11.C: New test.
* testsuite/libgomp.c++/target-flex-12.C: New test.
* testsuite/libgomp.c++/target-flex-2000.C: New test.
* testsuite/libgomp.c++/target-flex-2001.C: New test.
* testsuite/libgomp.c++/target-flex-2002.C: New test.
* testsuite/libgomp.c++/target-flex-2003.C: New test.
* testsuite/libgomp.c++/target-flex-30.C: New test.
* testsuite/libgomp.c++/target-flex-300.C: New test.
* testsuite/libgomp.c++/target-flex-31.C: New test.
* testsuite/libgomp.c++/target-flex-32.C: New test.
* testsuite/libgomp.c++/target-flex-33.C: New test.
* testsuite/libgomp.c++/target-flex-41.C: New test.
* testsuite/libgomp.c++/target-flex-60.C: New test.
* testsuite/libgomp.c++/target-flex-61.C: New test.
* testsuite/libgomp.c++/target-flex-62.C: New test.
* testsuite/libgomp.c++/target-flex-70.C: New test.
* testsuite/libgomp.c++/target-flex-80.C: New test.
* testsuite/libgomp.c++/target-flex-81.C: New test.
* testsuite/libgomp.c++/target-flex-90.C: New test.
* testsuite/libgomp.c++/target-flex-common.h: New test.
Co-authored-by: Thomas Schwinge <tschwinge@baylibre.com>
Thomas Koenig [Fri, 30 May 2025 11:31:58 +0000 (13:31 +0200)]
Type mismatch for passed external function
This obvious and simple patch fixes a 15/16 regression where the
typespec of a global function was in the RESULT clause and not
in the symbol itself.
gcc/fortran/ChangeLog:
PR fortran/120355
* interface.cc (compare_parameter): If the global function has a
result clause, take typespec from there for the comparison against
the dummy argument.
gcc/testsuite/ChangeLog:
PR fortran/120355
* gfortran.dg/interface_62.f90: New test.
David Malcolm [Fri, 30 May 2025 11:18:44 +0000 (07:18 -0400)]
diagnostics: consolidate calls to colorizer::set_named_color
I noticed whilst working on another issue that in diagnostic-show-locus
within the quoted source lines and the annotation underlines that when
we're showing highlight-{a,b} that we emit
start-colorization-code, character, end-colorization-code
per *character*, rather than just when the colorization changes.
This was due to me failing to implement consolidation of such changes in
colorizer::set_named_color in r15-2015-g7d73c01ce6d1ab.
Fixed thusly, simplifying the output.
I manually inspected all of the changed testcases in a terminal with
color enabled and verified that the output is visually identical to
before.
gcc/ChangeLog:
* diagnostic-show-locus.cc (colorizer::m_current_named_color): New
field.
(colorizer::set_named_color): Use it to consolidate repeated calls
to the same color.
gcc/testsuite/ChangeLog:
* g++.dg/diagnostic/bad-binary-ops-highlight-colors.C: Update
expected multiline output for quoted source and underlines to
reflect emitting color codes when changes happen, rather than
per character.
* g++.dg/diagnostic/long-short-colorization.C: Likewise.
* g++.dg/plugin/show-template-tree-color-labels.C: Likewise.
* gcc.dg/bad-binary-ops-highlight-colors.c: Likewise.
* gcc.dg/format/colors.c: Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Richard Biener [Fri, 30 May 2025 06:54:10 +0000 (08:54 +0200)]
tree-optimization/120457 - avoid lowering of some single-element interleave
The following makes sure we are not lowering single-element interleaving
schemes in a way that defeats load vectorizing later but allows the
VMAT_ELEMENTWISE fallback to be used.
PR tree-optimization/120457
* tree-vect-slp.cc (vect_lower_load_permutations): Implement
the same heuristics as load vectorization for single-element
interleaving that spans multiple vectors.
Jonathan Wakely [Wed, 15 Jan 2025 09:05:28 +0000 (09:05 +0000)]
libstdc++: Rewrite std::counting_semaphore base class [PR118494]
Remove __platform_semaphore. Replace __atomic_semaphore with
__semaphore_base<bool> and change its counter to be ptrdiff_t when the
count doesn't fit in __platform_wait_t (PR 118494).
Make the std::counting_semaphore constructor constexpr to support
constant initialization (PR 110854).
Add precondition checks to the constructor and release member functions
(PR 98749).
libstdc++-v3/ChangeLog:
PR libstdc++/118494
PR libstdc++/110854
PR libstdc++/98749
* acinclude.m4 (GLIBCXX_CHECK_GTHREADS): Remove checks for
sem_timedwait. Do not define _GLIBCXX_HAVE_POSIX_SEMAPHORE.
* config.h.in: Regenerate.
* configure: Regenerate.
* include/bits/semaphore_base.h (__platform_semaphore): Remove.
(__atomic_semaphore): Replace with __semaphore_base<bool> and
make type of _M_count depend on template parameter. Fix _S_max
constant to use correct type.
(__semaphore_base::_M_try_acquire): Qualify to avoid ADL.
(__semaphore_base::_M_release): Return old value. Remove FIXME
comment.
(__semaphore_impl): Replace typedef with alias template.
* include/bits/version.def (semaphore): Do not depend on
_GLIBCXX_HAVE_POSIX_SEMAPHORE.
* include/bits/version.h: Regenerate.
* include/std/semaphore (semaphore): Adjust type of _M_sem
member. Add constexpr to constructor. Add assertions to
(semaphore::semaphore(ptrdiff_t)): Add constexpr. Add assertion
for precondition.
(semaphore::release): Add assertion using value returned from
_M_release.
* testsuite/30_threads/semaphore/100806.cc: Increase template
argument for std::counting_semaphore, so constructor
precondition is met.
* testsuite/30_threads/semaphore/cons.cc: New test.
* testsuite/30_threads/semaphore/try_acquire_posix.cc: Remove.
* testsuite/30_threads/semaphore/platform_try_acquire_for.cc:
Removed.
Jonathan Wakely [Fri, 10 Jan 2025 12:22:21 +0000 (12:22 +0000)]
libstdc++: Fix std::barrier for constant initialization [PR118395]
The std::barrier constructor should be constexpr, which means we need to
defer the dynamic allocation if the constructor is called during
constant-initialization. We can defer it to the first call to
barrier::arrive, using compare-and-swap on an atomic<T*> (instead of the
unique_ptr<T[]> currently used).
Also add precondition checks to the constructor and arrive member
function. Also implement the proposed resolution of LWG 3898.
libstdc++-v3/ChangeLog:
PR libstdc++/118395
PR libstdc++/108974
PR libstdc++/98749
* include/std/barrier (__tree_barrier): Use default
member-initializers. Change _M_state member from
unique_ptr<__state_t[]> to atomic<__state_t*>. Add
no_unique_address attribute to _M_completion.
(__tree_barrier::_M_arrive): Load value from _M_state.
(__tree_barrier::_M_invoke_completion): New member function to
ensure a throwing completion function will terminate, as
proposed in LWG 3898.
(__tree_barrier::max): Reduce by one to avoid overflow.
(__tree_barrier::__tree_barrier): Add constexpr. Qualify call to
std::move. Remove mem-initializers made unnecessary by default
member-initializers. Add precondition check. Only allocate state
array if not constant evaluated.
(__tree_barrier::arrive): Add precondition check. Do deferred
initialization of _M_state if needed.
(barrier): Add static_assert, as proposed in LWG 3898.
(barrier::barrier): Add constexpr.
* testsuite/30_threads/barrier/cons.cc: New test.
* testsuite/30_threads/barrier/lwg3898.cc: New test.