]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
11 months agoaarch64/testsuite: Fix gcc.target/aarch64/simd/vmmla.c [PR116207]
Andrew Pinski [Tue, 6 Aug 2024 22:43:21 +0000 (15:43 -0700)] 
aarch64/testsuite: Fix gcc.target/aarch64/simd/vmmla.c [PR116207]

After r15-2414-g2d105efd6f60 which fixed the dg-do directive, the testcase
stopped working because there was a missing -save-temps. This adds that and
now the testcase passes again.

Pushed as obvious.

gcc/testsuite/ChangeLog:

PR testsuite/116207
* gcc.target/aarch64/simd/vmmla.c: Add -save-temps to the
options.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
11 months agolibstdc++: Fix some undeclared uses of uintptr_t [PR116247]
Jonathan Wakely [Tue, 6 Aug 2024 20:26:24 +0000 (21:26 +0100)] 
libstdc++: Fix some undeclared uses of uintptr_t [PR116247]

libstdc++-v3/ChangeLog:

PR libstdc++/116247
* include/bits/fs_path.h: Use __UINTPTR_TYPE__ instead of
uintptr_t.
* include/bits/shared_ptr_atomic.h: Likewise.
* include/ext/pointer.h: Include <stdint.h>.

11 months agodiagnostics: SARIF output: fix "executionSuccessful" §3.20.14 [PR116177]
David Malcolm [Tue, 6 Aug 2024 22:24:45 +0000 (18:24 -0400)] 
diagnostics: SARIF output: fix "executionSuccessful" §3.20.14 [PR116177]

Previously the invocation's "executionSuccessful" property (§3.20.14)
was only false if there was an ICE.

Update it so that it will also be false if we will exit with a non-zero
exit code (due to errors, Werror, and "sorry").

gcc/ChangeLog:
PR other/116177
* diagnostic-format-sarif.cc (sarif_invocation::prepare_to_flush):
If the diagnostics would lead to us exiting with a failure code,
then emit "executionSuccessful": False (SARIF v2.1.0 section
§3.20.14).
* diagnostic.cc (diagnostic_context::execution_failed_p): New.
* diagnostic.h (diagnostic_context::execution_failed_p): New decl.
* toplev.cc (toplev::main): Use it for determining returned value.

gcc/testsuite/ChangeLog:
PR other/116177
* gcc.dg/sarif-output/include-chain-2.c: Remove pruning of
"exit status is 1", as we expect this to exit with 0.
* gcc.dg/sarif-output/no-diagnostics.c: New test.
* gcc.dg/sarif-output/test-include-chain-1.py
(test_execution_unsuccessful): Add.
* gcc.dg/sarif-output/test-include-chain-2.py
(test_execution_successful): Add.
* gcc.dg/sarif-output/test-missing-semicolon.py
(test_execution_unsuccessful): Add.
* gcc.dg/sarif-output/test-no-diagnostics.py: New test.
* gcc.dg/sarif-output/test-werror.py: New test.
* gcc.dg/sarif-output/werror.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
11 months agoAArch64: take gather/scatter decode overhead into account
Tamar Christina [Tue, 6 Aug 2024 21:41:10 +0000 (22:41 +0100)] 
AArch64: take gather/scatter decode overhead into account

Gather and scatters are not usually beneficial when the loop count is small.
This is because there's not only a cost to their execution within the loop but
there is also some cost to enter loops with them.

As such this patch models this overhead.  For generic tuning we however still
prefer gathers/scatters when the loop costs work out.

gcc/ChangeLog:

* config/aarch64/aarch64-protos.h (struct sve_vec_cost): Add
gather_load_x32_init_cost and gather_load_x64_init_cost.
* config/aarch64/aarch64.cc (aarch64_vector_costs): Add
m_sve_gather_scatter_init_cost.
(aarch64_vector_costs::add_stmt_cost): Use them.
(aarch64_vector_costs::finish_cost): Likewise.
* config/aarch64/tuning_models/a64fx.h: Update.
* config/aarch64/tuning_models/cortexx925.h: Update.
* config/aarch64/tuning_models/generic.h: Update.
* config/aarch64/tuning_models/generic_armv8_a.h: Update.
* config/aarch64/tuning_models/generic_armv9_a.h: Update.
* config/aarch64/tuning_models/neoverse512tvb.h: Update.
* config/aarch64/tuning_models/neoversen2.h: Update.
* config/aarch64/tuning_models/neoversen3.h: Update.
* config/aarch64/tuning_models/neoversev1.h: Update.
* config/aarch64/tuning_models/neoversev2.h: Update.
* config/aarch64/tuning_models/neoversev3.h: Update.
* config/aarch64/tuning_models/neoversev3ae.h: Update.

11 months agodoc: Rephrase GM2 Limitations section
Gerald Pfeifer [Tue, 6 Aug 2024 20:38:41 +0000 (22:38 +0200)] 
doc: Rephrase GM2 Limitations section

gcc:
* doc/gm2.texi (Limitations): Rephrase. Remove invalid link.

12 months agoRemove MMX code path in lexer
Andi Kleen [Tue, 30 Jul 2024 01:48:08 +0000 (18:48 -0700)] 
Remove MMX code path in lexer

Host systems with only MMX and no SSE2 should be really rare now.
Let's remove the MMX code path to keep the number of custom
implementations the same.

The SSE2 code path is also somewhat dubious now (nearly everything
should have SSE4 4.2 which is >15 years old now), but the SSE2
code path is used as fallback for others and also apparently
Solaris uses it due to tool chain deficiencies.

libcpp/ChangeLog:

* lex.cc (search_line_mmx): Remove function.
(init_vectorized_lexer): Remove search_line_mmx.

12 months agohppa: Fix (plus (plus (mult (a) (mem_shadd_constant)) (b)) (c)) optimization
John David Anglin [Tue, 6 Aug 2024 17:40:26 +0000 (13:40 -0400)] 
hppa: Fix (plus (plus (mult (a) (mem_shadd_constant)) (b)) (c)) optimization

The constant C must be an integral multiple of the shift value in
the above optimization.  Non integral values can occur evaluating
IMAGPART_EXPR when the shadd constant is 8 and we have SFmode.

2024-08-06  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

PR target/113384
* config/pa/pa.cc (hppa_legitimize_address): Add check to
ensure constant is an integral multiple of shift the value.

12 months agoRISC-V: Fix typos in code
Patrick O'Neill [Mon, 5 Aug 2024 21:19:58 +0000 (14:19 -0700)] 
RISC-V: Fix typos in code

This fixes typos in function names and executed code.

gcc/ChangeLog:

* config/riscv/riscv-target-attr.cc (num_occurences_in_str): Rename...
(num_occurrences_in_str): here.
(riscv_process_target_attr): Update num_occurences_in_str callsite.
* config/riscv/riscv-v.cc (emit_vec_widden_cvt_x_f): widden -> widen.
(emit_vec_widen_cvt_x_f): Ditto.
(emit_vec_widden_cvt_f_f): Ditto.
(emit_vec_widen_cvt_f_f): Ditto.
(emit_vec_rounding_to_integer): Update *widden* callsites.
* config/riscv/riscv-vector-builtins.cc (expand_builtin): Update
required_ext_to_isa_name callsite and fix xtheadvector typo.
* config/riscv/riscv-vector-builtins.h (reqired_ext_to_isa_name): Rename...
(required_ext_to_isa_name): here.
* config/riscv/riscv_th_vector.h: Fix endif label.
* config/riscv/vector-crypto.md: boardcast_scalar -> broadcast_scalar.
* config/riscv/vector.md: Ditto.

Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
12 months agoRISC-V: Fix comment typos
Patrick O'Neill [Mon, 5 Aug 2024 21:13:12 +0000 (14:13 -0700)] 
RISC-V: Fix comment typos

This fixes most of the typos I found when reading various parts of the RISC-V
backend.

gcc/ChangeLog:

* config/riscv/arch-canonicalize: Fix typos in comments.
* config/riscv/autovec.md: Ditto.
* config/riscv/riscv-avlprop.cc (avl_can_be_propagated_p): Ditto.
(pass_avlprop::get_vlmax_ta_preferred_avl): Ditto.
* config/riscv/riscv-modes.def (ADJUST_FLOAT_FORMAT): Ditto.
(VLS_MODES): Ditto.
* config/riscv/riscv-opts.h (TARGET_ZICOND_LIKE): Ditto.
(enum rvv_vector_bits_enum): Ditto.
* config/riscv/riscv-protos.h (enum insn_flags): Ditto.
(enum insn_type): Ditto.
* config/riscv/riscv-sr.cc (riscv_sr_match_epilogue): Ditto.
* config/riscv/riscv-string.cc (expand_block_move): Ditto.
* config/riscv/riscv-v.cc (rvv_builder::is_repeating_sequence): Ditto.
(rvv_builder::single_step_npatterns_p): Ditto.
(calculate_ratio): Ditto.
(expand_const_vector): Ditto.
(shuffle_merge_patterns): Ditto.
(shuffle_compress_patterns): Ditto.
(expand_select_vl): Ditto.
* config/riscv/riscv-vector-builtins-functions.def (REQUIRED_EXTENSIONS): Ditto.
* config/riscv/riscv-vector-builtins-shapes.h: Ditto.
* config/riscv/riscv-vector-builtins.cc (function_builder::add_function): Ditto.
(resolve_overloaded_builtin): Ditto.
* config/riscv/riscv-vector-builtins.def (vbool1_t): Ditto.
(vuint8m8_t): Ditto.
(vuint16m8_t): Ditto.
(vfloat16m8_t): Ditto.
(unsigned_vector): Ditto.
* config/riscv/riscv-vector-builtins.h (enum required_ext): Ditto.
* config/riscv/riscv-vector-costs.cc (get_store_value): Ditto.
(costs::analyze_loop_vinfo): Ditto.
(costs::add_stmt_cost): Ditto.
* config/riscv/riscv.cc (riscv_build_integer): Ditto.
(riscv_vector_type_p): Ditto.
* config/riscv/thead.cc (th_mempair_output_move): Ditto.
* config/riscv/thead.md: Ditto.
* config/riscv/vector-iterators.md: Ditto.
* config/riscv/vector.md: Ditto.
* config/riscv/zc.md: Ditto.

Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
12 months agoc++: further concept_check_p clean-up
Marek Polacek [Tue, 6 Aug 2024 13:34:02 +0000 (09:34 -0400)] 
c++: further concept_check_p clean-up

Patrick noticed a few more concept_check_p checks that can be removed
now.

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_call_expression): Remove concept_check_p check.
(cxx_eval_outermost_constant_expr): Likewise.
* cp-gimplify.cc (cp_genericize_r) <case CALL_EXPR>: Likewise.
* except.cc (check_noexcept_r): Likewise.

12 months agoc++: more non-type template parms [PR116223]
Jason Merrill [Mon, 5 Aug 2024 17:20:17 +0000 (13:20 -0400)] 
c++: more non-type template parms [PR116223]

Building on the last patch, deduction should probably look through all
IMPLICIT_CONV_EXPR like we do other conversions.

One resulting regression turned out to be due to PR94568, fixed separately.

The one other regression was for a seeming mismatch between a function and
its address, handled here.  Before this change we treated the
IMPLICIT_CONV_EXPR as dependent because the template parameter has dependent
type.

PR c++/116223

gcc/cp/ChangeLog:

* pt.cc (deducible_expression): Strip all IMPLICIT_CONV_EXPR.
(unify): Likewise.  Handle resulting function/addr mismatch.

12 months agoc++: alias and non-type template parm [PR116223]
Jason Merrill [Mon, 5 Aug 2024 15:21:05 +0000 (11:21 -0400)] 
c++: alias and non-type template parm [PR116223]

My r14-8291 for PR112632 introduced IMPLICIT_CONV_EXPR_FORCED to express
conversions to the type of an alias template parameter.  In this example,
that broke deduction of X in the call to foo, so let's teach deduction to
look through it.

PR c++/116223
PR c++/112632

gcc/cp/ChangeLog:

* pt.cc (deducible_expression): Also look through
IMPLICIT_CONV_EXPR_FORCED.
(unify): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1z/nontype-auto25.C: New test.

12 months agoc++: zero-init and class nttp [PR94568]
Jason Merrill [Mon, 5 Aug 2024 19:04:05 +0000 (15:04 -0400)] 
c++: zero-init and class nttp [PR94568]

A zero-initializer should not reflect the constness of what it's
initializing, as it does not for initializers with different syntax.

This does have mangling implications for rare C++20 code, but it seems
infeasable to make the mangling depend on -fabi-version while fixing the
semantic bug, and C++20 is still experimental anyway.

PR c++/94568

gcc/cp/ChangeLog:

* init.cc (build_zero_init_1): Call cv_unqualified.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/nontype-class36.C: Remove xfail.
* g++.dg/cpp2a/nontype-class37.C: Remove xfail.
* g++.dg/cpp1z/nontype-auto26.C: New test.

12 months agoi386: Refactor V2DI arithmetic right shift expansion for STV.
Roger Sayle [Tue, 6 Aug 2024 16:19:29 +0000 (17:19 +0100)] 
i386: Refactor V2DI arithmetic right shift expansion for STV.

This patch refactors ashrv2di RTL expansion into a function so that it may
be reused by a pre-reload splitter, such that DImode right shifts may be
considered candidates during the Scalar-To-Vector (STV) pass.  Currently
DImode arithmetic right shifts are not considered potential candidates
during STV, so for the following testcase:

long long m;
typedef long long v2di __attribute__((vector_size (16)));
void foo(v2di x) { m = x[0]>>63; }

We currently see the following warning/error during STV2
>  r101 use in insn 7 isn't convertible

And end up generating scalar code with an interunit move:

foo: movq    %xmm0, %rax
        sarq    $63, %rax
        movq    %rax, m(%rip)
        ret

With this patch, we can reuse the RTL expansion logic and produce:

foo: psrad   $31, %xmm0
        pshufd  $245, %xmm0, %xmm0
        movq    %xmm0, m(%rip)
        ret

Or with the addition of -mavx2, the equivalent:

foo:    vpxor   %xmm1, %xmm1, %xmm1
        vpcmpgtq        %xmm0, %xmm1, %xmm0
        vmovq   %xmm0, m(%rip)
        ret

The only design decision of note is the choice to continue lowering V2DI
into vector sequences during RTL expansion, to enable combine to optimize
things if possible.  Using just define_insn_and_split potentially misses
optimizations, such as reusing the zero vector produced by vpxor above.
It may be necessary to tweak STV's compute gain at some point, but this
patch controls what's possible (rather than what's beneficial).

2024-08-06  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
* config/i386/i386-expand.cc (ix86_expand_v2di_ashiftrt): New
function refactored from define_expand ashrv2di3.
* config/i386/i386-features.cc (general_scalar_to_vector_candidate_p)
<case ASHIFTRT>: Handle like other shifts and rotates.
* config/i386/i386-protos.h (ix86_expand_v2di_ashiftrt): Prototype.
* config/i386/sse.md (ashrv2di3): Call ix86_expand_v2di_ashiftrt.
(*ashrv2di3): New define_insn_and_split to enable creation by stv2
pass, and splitting during split1 reusing ix86_expand_v2di_ashiftrt.

gcc/testsuite/ChangeLog
* gcc.target/i386/sse2-stv-2.c: New test case.

12 months agoRISC-V: Fix format-diag warning from improperly formatted url
Patrick O'Neill [Tue, 6 Aug 2024 15:16:26 +0000 (08:16 -0700)] 
RISC-V: Fix format-diag warning from improperly formatted url

gcc/ChangeLog:

PR target/116152
* config/riscv/riscv.cc (riscv_option_override): Fix url
formatting.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/predef-9.c: Update testcase.

Co-authored-by: Jakub Jelinek <jakub@redhat.com>
Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
12 months agoc++: fold calls to std::forward_like [PR96780]
Patrick Palka [Tue, 6 Aug 2024 15:51:45 +0000 (11:51 -0400)] 
c++: fold calls to std::forward_like [PR96780]

This extends our folding of cast-like standard library functions
to also include C++23's std::forward_like.

PR c++/96780

gcc/cp/ChangeLog:

* cp-gimplify.cc (cp_fold) <case CALL_EXPR>: Fold calls
to std::forward_like as well.

gcc/testsuite/ChangeLog:

* g++.dg/opt/pr96780.C: Also test std::forward_like folding.

Reviewed-by: Marek Polacek <mpolacek@redhat.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
12 months agogimple ssa: Put SCCOPY logic into a class
Filip Kastl [Tue, 6 Aug 2024 13:19:11 +0000 (15:19 +0200)] 
gimple ssa: Put SCCOPY logic into a class

Currently the main logic of the sccopy pass is implemented as static
functions.  This patch instead puts the code into a class.  This also
gets rid of a global variable (dead_stmts).

gcc/ChangeLog:

* gimple-ssa-sccopy.cc (class scc_copy_prop): New class.
(replace_scc_by_value): Put into...
(scc_copy_prop::replace_scc_by_value): ...scc_copy_prop.
(sccopy_visit_op): Put into...
(scc_copy_prop::visit_op): ...scc_copy_prop.
(sccopy_propagate): Put into...
(scc_copy_prop::propagate): ...scc_copy_prop.
(init_sccopy): Replace by...
(scc_copy_prop::scc_copy_prop): ...the construtor.
(finalize_sccopy): Replace by...
(scc_copy_prop::~scc_copy_prop): ...the destructor.
(pass_sccopy::execute): Use scc_copy_prop.

Signed-off-by: Filip Kastl <fkastl@suse.cz>
12 months agotree-optimization/116241 - ICE with SLP condition reduction
Richard Biener [Tue, 6 Aug 2024 07:50:00 +0000 (09:50 +0200)] 
tree-optimization/116241 - ICE with SLP condition reduction

When there's a conversion in front of a SLP condition reduction the
code following the reduc-idx SLP chain fails because it assumes
there's only COND_EXPRs.

PR tree-optimization/116241
* tree-vect-loop.cc (vect_create_epilog_for_reduction): Handle
non-COND_EXPR nodes in SLP reduction chain following.

* g++.dg/vect/pr116241.cc: New testcase.

12 months agotestsuite: Fix up pr116037.c test [PR116245]
Jakub Jelinek [Tue, 6 Aug 2024 09:52:35 +0000 (11:52 +0200)] 
testsuite: Fix up pr116037.c test [PR116245]

The test FAILs on big endian targets, because VV is a vector of unsigned __int128
and VC vector of unsigned char and so ((VC) vv)[0] is 0x01 on little endian
but 0xff on big endian and PDP endian.
As I believe it is intentional to test it as it is written on little endian,
the following patch just adds another case for big endian and for other
endians instead of figuring out what exactly to fetch it fetches the whole
unsigned __int128 and casts it to unsigned char.  Not that pdp11 has
__int128 support...

2024-08-06  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/116037
PR testsuite/116245
* gcc.dg/torture/pr116037.c (foo): Fix up for big end middle endian.

12 months agowide-int: Fix up mul_internal overflow checking [PR116224]
Jakub Jelinek [Tue, 6 Aug 2024 09:09:33 +0000 (11:09 +0200)] 
wide-int: Fix up mul_internal overflow checking [PR116224]

The following testcase is miscompiled, because wi::mul for (_BitInt(65))-15
times (_BitInt(65))-15 computes the right value (_BitInt(65))225, but
sets *overflow to wi::OVF_UNKNOWN as that it overflowed when it didn't.

Even signed operands are unpacked as unsigned but because they are
implicitly sign-extended from the represented value (the operands
obviously have len==1), we get
0xfffffff1, 0xffffffff, 0x1, 0x0
in both u and v (0x1 because that is exactly 65 bits).
We then multiply these.  Next step is because both the high and
overflow handling expects the high half to start at a limb boundary
the bits of the result starting with bit 65 are shifted up by 63 such
that the bits relevant for high/need_overflow start at the half of the
4th half wide int limb.
Because both operands are negative that part is then adjusted.

The reason mul_internal says there is overflow is because of the unspecified
garbage in the most significant bits of the result which the adjusting
doesn't clean up.  65 bit multiplication needs 65 bits of result and 65 bits
of the high part, can't produce more, so the following patch fixes it by
checking for the overflow only in those first 65 bits of the high part, not
anything beyond that.  If it was a highpart multiply, we'd have ignored that
as well (canonicalized).

2024-08-06  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/116224
* wide-int.cc (wi::mul_internal): If prec isn't multiple of
HOST_BITS_PER_WIDE_INT, for need_overflow checking only look at
the least significant prec bits starting with r[half_blocks_needed].

* gcc.dg/torture/bitint-72.c: New test.

12 months agoada: Fix error in GNATprove inlining with array concatenation
Yannick Moy [Wed, 24 Jul 2024 15:36:20 +0000 (17:36 +0200)] 
ada: Fix error in GNATprove inlining with array concatenation

Wrong interpretation of the type of the concatenation can lead to a
spurious error in GNATprove when inlining code. Now fixed.

gcc/ada/

* sem_ch4.adb (Analyze_Concatenation_Rest): Do not add a wrong
interpretation of the concatenation, using the type of the operand
already recognized as of the element type.

12 months agoada: Implement type inference for generic parameters
Bob Duff [Wed, 24 Jul 2024 17:29:01 +0000 (13:29 -0400)] 
ada: Implement type inference for generic parameters

...based on previous work that added Gen_Assocs_Rec.
Minor cleanup of that previous work.

gcc/ada/

* sem_ch12.adb: Implement type inference for generic parameters.
(Maybe_Infer_One): Forbid inference of anonymous subtypes and
types.
(Inference_Reason): Fix comment.
* debug.adb: Document -gnatd_I switch.
* errout.ads: Document that Empty is not allowed for "&".
* errout.adb (Set_Msg_Insertion_Node): Minor: Do not allow
Error_Msg_Node_1 = Empty for "&". Use "in" instead of multiple
"=". Improve comment.

12 months agoada: GNAT-LLVM compiler crash on container aggregates with iterators
Gary Dismukes [Tue, 23 Jul 2024 21:05:29 +0000 (21:05 +0000)] 
ada: GNAT-LLVM compiler crash on container aggregates with iterators

Recent fixes for container aggregates with iterated element associations
exposed a latent bug with loops that are wrapped in blocks, where the loop
entity's scope was not adjusted to reflect the new enclosing block scope.

gcc/ada/

* sem_ch5.adb (Analyze_Loop_Statement.Wrap_Loop_Statement): Remove
the loop Entity_Id from its old scope and insert it in the new
block scope that wraps it.

12 months agoada: Spurious error on the default value of a derived scalar type
Javier Miranda [Tue, 23 Jul 2024 11:46:19 +0000 (11:46 +0000)] 
ada: Spurious error on the default value of a derived scalar type

When the aspect Default_Value is inherited by a derived scalar
type, and both the parent type T and the derived type DT are
declared in the same scope, a spurious error may be reported.
This occurs if a subprogram declared in the same scope has a
parameter of type DT with a default value, leading the compiler
to incorrectly flag the default value specified in the aspect
of type T as having the wrong type.

gcc/ada/

* freeze.adb (Freeze_Entity): For scalar derived types that
inherit the aspect Default_Value, do not analyze and resolve the
inherited aspect, as the type of the aspect remains the parent
type.

12 months agoada: Use fully qualified in more library files
Viljar Indus [Tue, 23 Jul 2024 07:47:20 +0000 (10:47 +0300)] 
ada: Use fully qualified in more library files

gcc/ada/

* libgnarl/s-interr__hwint.adb: Use fully qualified names to avoid
ambiguity.
* libgnarl/s-taprop__qnx.adb: Likewise.

12 months agoada: Assert failure in repinfo
Javier Miranda [Mon, 22 Jul 2024 10:26:41 +0000 (10:26 +0000)] 
ada: Assert failure in repinfo

Using switch gnatR4, the frontend crashes when generating information
for a private record type.

gcc/ada/

* repinfo.adb (List_Record_Info): Handle private record types.

12 months agoada: Use fully qualified in the runtime library
Viljar Indus [Mon, 22 Jul 2024 09:10:51 +0000 (12:10 +0300)] 
ada: Use fully qualified in the runtime library

gcc/ada/

* libgnarl/s-taprop__mingw.adb: Use fully qualified names
to avoid ambiguity.
* libgnarl/s-taprop__posix.adb: Likewise.
* libgnarl/s-taprop__qnx.adb: Likewise.
* libgnarl/s-taprop__rtems.adb: Likewise.

12 months agoada: Fix propagation of SPARK_Mode for renaming-as-body
Yannick Moy [Mon, 22 Jul 2024 09:31:03 +0000 (11:31 +0200)] 
ada: Fix propagation of SPARK_Mode for renaming-as-body

The value of SPARK_Mode associated with a renaming-as-body might
not be the correct one, when the private part of the package containing
the declaration has SPARK_Mode Off while the public part has SPARK_Mode
On. This may lead to analysis of code by GNATprove that should not be
analyzed.

gcc/ada/

* freeze.adb (Build_Renamed_Body): Propagate SPARK_Pragma to body
build from renaming, so that locally relevant value is taken into
account.
* sem_ch6.adb (Analyze_Expression_Function): Propagate
SPARK_Pragma to body built from expression function, so that
locally relevant value is taken into account.

12 months agoada: Reject use-clause conflicts in the run-time library
Bob Duff [Wed, 17 Jul 2024 23:42:57 +0000 (19:42 -0400)] 
ada: Reject use-clause conflicts in the run-time library

This patch fixes a bug where GNAT would fail to detect certain
errors when compiling the run-time library.  In particular, if
two overloaded homographs are both directly visible, it would
pick one, rather than complaining about the ambiguity.

The problem was that some special-purpose code in Sem_Ch8 was trying
to make a user name take precedence over some run-time library
declaration that (incorrectly) appears to be visible because of
rtsfind. The solution is to disable that code while compiling
the run-time library itself.

In addition, we fix the newly-found errors in the run-time library.

gcc/ada/

* sem_ch8.adb (Find_Direct_Name): Disable the special-purpose code
when we are actually compiling the run-time library itself.
* libgnarl/a-exetim__posix.adb: Fix newly-found use-clause
conflicts.
* libgnat/a-direct.adb: Likewise.
* libgnat/a-nbnbin.adb: Likewise.
* libgnat/a-timoio__128.adb: Likewise.
* libgnat/a-timoio.adb: Likewise.
* libgnat/a-wtmoio__128.adb: Likewise.
* libgnat/a-wtmoio.adb: Likewise.
* libgnat/a-ztmoio__128.adb: Likewise.
* libgnat/a-ztmoio.adb: Likewise.

12 months agolibgomp: Device load_image - improve minor num-funcs/vars check
Tobias Burnus [Tue, 6 Aug 2024 08:34:28 +0000 (10:34 +0200)] 
libgomp: Device load_image - improve minor num-funcs/vars check

The run time library loads the offload functions and variable and optionally
the ICV variable and returns the number of loaded items, which has to match
the host side. The plugin returns "+1" (since GCC 12) for the ICV variable
entry, independently whether it was loaded or not, but the var's value
(start == end == 0) can be used to detect when this failed.

Thus, we can tighten the assert check - which this commit does together with
making the output less surprising - and simplify the condition further below.

libgomp/ChangeLog:

* target.c (gomp_load_image_to_device): Extend fatal-error message;
simplify a condition.

12 months agomiddle-end/111821 - compile-time/memory-hog with large copy
Richard Biener [Fri, 2 Aug 2024 11:49:34 +0000 (13:49 +0200)] 
middle-end/111821 - compile-time/memory-hog with large copy

The following fixes a compile-time/memory-hog when performing a
large aggregate copy to a small object allocated to a register.
While store_bit_field_1 called by store_integral_bit_field will
do nothign for accesses outside of the target the loop over the
source in store_integral_bit_field will still code-generate
the read parts for all words in the source.  The following copies
the noop condition from store_bit_field_1 and terminates the
loop when it runs forward or avoid code-generating the read parts
when not.

PR middle-end/111821
* expmed.cc (store_integral_bit_field): Terminate the
word-wise copy loop when we get out of the destination
and do a forward copy.  Skip the word if it would be
outside of the destination in case of a backward copy.

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

12 months agors6000: Add const_vector into any_operand predicate
Haochen Gui [Tue, 6 Aug 2024 06:15:05 +0000 (14:15 +0800)] 
rs6000: Add const_vector into any_operand predicate

gcc/
* config/rs6000/predicates.md (any_operand): Add const_vector.

12 months agoFortran: Fix class transformational intrinsic calls [PR102689]
Paul Thomas [Tue, 6 Aug 2024 05:42:27 +0000 (06:42 +0100)] 
Fortran: Fix class transformational intrinsic calls [PR102689]

2024-08-06  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/102689
* trans-array.cc (get_array_ref_dim_for_loop_dim): Use the arg1
class container carried in ss->info as the seed for a lhs in
class valued transformational intrinsic calls that are not the
rhs of an assignment. Otherwise, the lhs variable expression is
taken from the loop chain. For this latter case, the _vptr and
_len fields are set.
(gfc_trans_create_temp_array): Use either the lhs expression
seeds to build a class variable that will take the returned
descriptor as its _data field. In the case that the arg1 expr.
is used, a class typespec must be built with the correct rank
and the _vptr and _len fields set. The element size is provided
for the temporary allocation and to set the descriptor span.
(gfc_array_init_size): When an intrinsic type scalar expr3 is
used in allocation of a class array, use its element size in
the descriptor dtype.
* trans-expr.cc (gfc_conv_class_to_class): Class valued
transformational intrinsics return the pointer to the array
descriptor as the _data field of a class temporary. Extract
directly and return the address of the class temporary.
(gfc_conv_procedure_call): store the expression for the first
argument of a class valued transformational intrinsic function
in the ss info class_container field. Later, use its type  as
the element type in the call to gfc_trans_create_temp_array.
(fcncall_realloc_result): Add a dtype argument and use it in
the descriptor, when available.
(gfc_trans_arrayfunc_assign): For class lhs, build a dtype with
the lhs rank and the rhs element size and use it in the call to
fcncall_realloc_result.

gcc/testsuite/
PR fortran/102689
* gfortran.dg/class_transformational_1.f90: New test for class-
valued reshape.
* gfortran.dg/class_transformational_2.f90: New test for other
class_valued transformational intrinsics.

12 months agovect: Add missed opcodes in vect_get_smallest_scalar_type [PR115228]
Feng Xue [Mon, 5 Aug 2024 07:53:19 +0000 (15:53 +0800)] 
vect: Add missed opcodes in vect_get_smallest_scalar_type [PR115228]

Some opcodes are missed when determining the smallest scalar type for a
vectorizable statement. Currently, this bug does not cause any problem,
because vect_get_smallest_scalar_type is only used to compute max nunits
vectype, and even statement with missed opcode is incorrectly bypassed,
the max nunits vectype could also be rightly deduced from def statements
for operands of the statement.

In the future, if this function will be called to do other thing, we may
get something wrong. So fix it in this patch.

2024-08-05 Feng Xue <fxue@os.amperecomputing.com>

gcc/
PR tree-optimization/115228
* tree-vect-data-refs.cc (vect_get_smallest_scalar_type): Add
missed opcodes that involve widening operation.

12 months agovect: Allow unsigned-to-signed promotion in vect_look_through_possible_promotion...
Feng Xue [Mon, 5 Aug 2024 07:23:56 +0000 (15:23 +0800)] 
vect: Allow unsigned-to-signed promotion in vect_look_through_possible_promotion [PR115707]

The function fails to figure out root definition if casts involves more than
two promotions with sign change as:

long a = (long)b;       // promotion cast
 -> int b = (int)c;     // promotion cast, sign change
   -> unsigned short c = ...;

For this case, the function thinks the 2nd cast has different sign as the 1st,
so stop looking through, while "unsigned short -> integer" is a nature sign
extension.

2024-08-05 Feng Xue <fxue@os.amperecomputing.com>

gcc/
PR tree-optimization/115707
* tree-vect-patterns.cc (vect_look_through_possible_promotion): Allow
unsigned-to-signed promotion.

12 months agosh: Don't call make_insn_raw in sh_recog_treg_set_expr [PR116189]
Andrew Pinski [Sat, 3 Aug 2024 16:30:57 +0000 (09:30 -0700)] 
sh: Don't call make_insn_raw in sh_recog_treg_set_expr [PR116189]

This was an interesting compare debug failure to debug. The first symptom
was in gcse which would produce different order of creating psedu-registers. This
was caused by a different order of a hashtable walk, due to the hash table having different
number of entries. Which in turn was due to the number of max insn being different between
the 2 runs. The place max insn uid comes from was in sh_recog_treg_set_expr which is called
via rtx_costs and fwprop would cause rtx_costs in some cases for debug insn related stuff.

Build and tested for sh4-linux-gnu.

PR target/116189

gcc/ChangeLog:

* config/sh/sh.cc (sh_recog_treg_set_expr): Don't call make_insn_raw,
make the insn with a fake uid.

gcc/testsuite/ChangeLog:

* c-c++-common/torture/pr116189-1.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
12 months agoc++: remove function/var concepts code
Marek Polacek [Thu, 1 Aug 2024 19:39:10 +0000 (15:39 -0400)] 
c++: remove function/var concepts code

This patch removes vestigial Concepts TS code as discussed in
<https://gcc.gnu.org/pipermail/gcc-patches/2024-July/657937.html>.

In particular, it removes code related to function/variable concepts.
That includes variable_concept_p and function_concept_p, which then
cascades into removing DECL_DECLARED_CONCEPT_P etc.  So I think we
no longer need to say "standard concept" since there are no non-standard
ones anymore.

I've added two new errors saying that "variable/function concepts are
no longer supported".

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_constant_expression): Don't call
unpack_concept_check.  Add a concept_check_p assert.  Remove
function_concept_p code.
* constraint.cc (check_constraint_atom): Remove function concepts code.
(unpack_concept_check): Remove.
(get_concept_check_template): Remove Concepts TS code.
(resolve_function_concept_overload): Remove.
(resolve_function_concept_check): Remove.
(resolve_concept_check): Remove Concepts TS code.
(get_returned_expression): Remove.
(get_variable_initializer): Remove.
(get_concept_definition): Remove Concepts TS code.
(normalize_concept_check): Likewise.
(build_function_check): Remove.
(build_variable_check): Remove.
(build_standard_check): Use concept_definition_p instead of
standard_concept_p.
(build_concept_check): Remove variable_concept_p/function_concept_p
code.
(build_concept_id): Simplify.
(build_type_constraint): Likewise.
(placeholder_extract_concept_and_args): Likewise.
(satisfy_nondeclaration_constraints): Likewise.
(check_function_concept): Remove.
(get_constraint_error_location): Remove Concepts TS code.
* cp-tree.h (DECL_DECLARED_CONCEPT_P): Remove.
(check_function_concept): Remove.
(unpack_concept_check): Remove.
(standard_concept_p): Remove.
(variable_concept_p): Remove.
(function_concept_p): Remove.
(concept_definition_p): Simplify.
(concept_check_p): Don't check for CALL_EXPR.
* decl.cc (check_concept_refinement): Remove.
(duplicate_decls): Remove check_concept_refinement code.
(is_concept_var): Remove.
(cp_finish_decl): Remove is_concept_var.
(check_concept_fn): Remove.
(grokfndecl): Give an error about function concepts not being supported
anymore.  Remove unused code.
(grokvardecl): Give an error about variable concepts not being
supported anymore.
(finish_function): Remove DECL_DECLARED_CONCEPT_P code.
* decl2.cc (min_vis_expr_r): Use concept_definition_p instead of
standard_concept_p.
(maybe_instantiate_decl): Remove DECL_DECLARED_CONCEPT_P check.
(mark_used): Likewise.
* error.cc (dump_simple_decl): Use concept_definition_p instead of
standard_concept_p.
(dump_function_decl): Remove DECL_DECLARED_CONCEPT_P code.
(print_concept_check_info): Don't call unpack_concept_check.  Simplify.
* mangle.cc (write_type_constraint): Likewise.
* parser.cc (cp_parser_nested_name_specifier_opt): Remove
function_concept_p code.  Only check concept_definition_p, not
variable_concept_p/standard_concept_p.
(add_debug_begin_stmt): Remove DECL_DECLARED_CONCEPT_P code.
(cp_parser_template_declaration_after_parameters): Remove a stale
comment.
* pt.cc (check_explicit_specialization): Remove
DECL_DECLARED_CONCEPT_P code.
(process_partial_specialization): Remove variable_concept_p code.
(lookup_template_variable): Likewise.
(tsubst_expr) <case CALL_EXPR>: Remove Concepts TS code and simplify.
(do_decl_instantiation): Remove DECL_DECLARED_CONCEPT_P code.
(instantiate_decl): Likewise.
(placeholder_type_constraint_dependent_p): Don't call
unpack_concept_check.  Add a concept_check_p assert.
(convert_generic_types_to_packs): Likewise.
* semantics.cc (finish_call_expr): Remove Concepts TS code and simplify.

gcc/testsuite/ChangeLog:

* g++.dg/concepts/decl-diagnose.C: Adjust dg-error.
* g++.dg/concepts/fn-concept2.C: Likewise.
* g++.dg/concepts/pr71128.C: Likewise.
* g++.dg/concepts/var-concept6.C: Likewise.
* g++.dg/cpp2a/concepts.C: Likewise.

12 months agoDaily bump.
GCC Administrator [Tue, 6 Aug 2024 00:17:19 +0000 (00:17 +0000)] 
Daily bump.

12 months agolibbacktrace: avoid -Wpointer-arith errors
Ian Lance Taylor [Mon, 5 Aug 2024 23:46:03 +0000 (16:46 -0700)] 
libbacktrace: avoid -Wpointer-arith errors

Based on patch from Kirill Müller.

* configure.ac (ACX_PROG_CC_WARNING_OPTS): Add -Wpointer-arith.
* pecoff.c (coff_add): Cast void pointers.
* xcoff.c (xcoff_add): Likewise.
* configure: Regenerate.

12 months agocompiler: panic arguments are empty interface type
Ian Lance Taylor [Mon, 5 Aug 2024 20:01:32 +0000 (13:01 -0700)] 
compiler: panic arguments are empty interface type

After CL 536643 passing NULL as the expected type permitted an untyped
constant expression to remain untyped. Change to passing the empty
interface type.

The panic and print/println functions are the only builtin functions
that turn an untyped constant expression into a regular function call,
and we already handled print/println specially.

The test case is https://go.dev/cl/603096.

Fixes golang/go#68734

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/603215

12 months agoRISC-V: Add deprecation warning to LP64E abi
Patrick O'Neill [Wed, 31 Jul 2024 00:32:09 +0000 (17:32 -0700)] 
RISC-V: Add deprecation warning to LP64E abi

gcc/ChangeLog:

PR target/116152
* config/riscv/riscv.cc (riscv_option_override): Add deprecation
warning.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/predef-9.c: Add check for warning.

Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
12 months agoc++, coroutines: Simplify separation of the user function body and ramp.
Iain Sandoe [Wed, 31 Jul 2024 22:05:49 +0000 (23:05 +0100)] 
c++, coroutines: Simplify separation of the user function body and ramp.

We need to separate the original user-authored function body from the
definition of the ramp function (which is what is called instead).
The function body tree is either in DECL_SAVED_TREE or the first operand
of current_eh_spec_block (for functions with an EH spec).
This version simplifies the process by extracting the second case directly
instead of inspecting the DECL_SAVED_TREE trees to discover it.

gcc/cp/ChangeLog:

* coroutines.cc (split_coroutine_body_from_ramp): New.
(morph_fn_to_coro): Use split_coroutine_body_from_ramp().
* cp-tree.h (use_eh_spec_block): New.
* decl.cc (use_eh_spec_block): Make non-static.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
12 months agoFix handling of const or volatile void pointers in CodeView
Mark Harmstone [Sun, 4 Aug 2024 22:26:53 +0000 (23:26 +0100)] 
Fix handling of const or volatile void pointers in CodeView

DWARF represents voids in DW_TAG_const_type and DW_TAG_volatile_type
DIEs by the absence of a DW_AT_type attribute, which we weren't handling
correctly.

gcc/
* dwarf2codeview.cc (get_type_num_const_type): Handle missing
DW_AT_type attribute.
(get_type_num_volatile_type): Likewise.

12 months agoUpdate gcc fr.po
Joseph Myers [Mon, 5 Aug 2024 16:32:59 +0000 (16:32 +0000)] 
Update gcc fr.po

* fr.po: Update.

12 months agoc++: fix -Wdangling-reference false positive [PR115987]
Marek Polacek [Wed, 31 Jul 2024 21:33:55 +0000 (17:33 -0400)] 
c++: fix -Wdangling-reference false positive [PR115987]

This fixes another false positive.  When a function is taking a
temporary of scalar type that couldn't be bound to the return type
of the function, don't warn, such a program would be ill-formed.

Thanks to Jonathan for reporting the problem.

PR c++/115987

gcc/cp/ChangeLog:

* call.cc (do_warn_dangling_reference): Don't consider a
temporary with a scalar type that cannot bind to the return type.

gcc/testsuite/ChangeLog:

* g++.dg/ext/attr-no-dangling6.C: Adjust.
* g++.dg/ext/attr-no-dangling7.C: Likewise.
* g++.dg/warn/Wdangling-reference22.C: New test.

12 months agobpf: do not emit BPF non-fetching atomic instructions
Jose E. Marchesi [Mon, 5 Aug 2024 14:23:47 +0000 (16:23 +0200)] 
bpf: do not emit BPF non-fetching atomic instructions

When GCC finds a call to one of the __atomic_OP_fetch built-ins in
which the return value is not used it optimizes it into the
corresponding non-fetching atomic operation.  Up to now we had
definitions in gcc/config/bpf/atomic.md to implement both atomic_OP
and atomic_fetch_OP sets of insns:

  atomic_add -> aadd (aka xadd)
  atomic_and -> aand
  atomic_or  -> aor
  atomic_xor -> axor

  atomic_fetch_add -> afadd
  atomic_fetch_and -> afand
  atomic_fetch_or  -> afor
  atomic_fetch_xor -> afxor

This was not correct, because as it happens the non-fetching BPF
atomic instructions imply different memory ordering semantics than the
fetching BPF atomic instructions, and they cannot be used
interchangeably, as it would be expected.

This patch modifies config/bpf/atomic.md in order to not define the
atomic_{add,and,or,xor} insns.  This makes GCC to implement them in
terms of the corresponding fetching operations; this is less
efficient, but correct.  It also updates the expected results in the
corresponding tests, which are also updated to cover cases where the
value resulting from the __atomic_fetch_* operations is actually used.

Tested in bpf-unknown-none target in x86_64-linux-gnu host.

gcc/ChangeLog

* config/bpf/atomic.md ("atomic_add<AMO:mode>"): Remove insn.
("atomic_and<AMO:mode>"): Likewise
("atomic_or<AMO:mode>"): Likewise.
("atomic_xor<AMO:mode>"): Likewise.

gcc/testsuite/ChangeLog

* gcc.target/bpf/atomic-op-1.c (test_used_atomic_add): New
function.
(test_used_atomic_sub): Likewise.
(test_used_atomic_and): Likewise.
(test_used_atomic_nand): Likewise.
(test_used_atomic_or): Likewise.
(test_used_atomic_xor): Likewise.
* gcc.target/bpf/atomic-op-2.c (test_used_atomic_add): Likewise.
(test_used_atomic_sub): Likewise.
(test_used_atomic_and): Likewise.
(test_used_atomic_nand): Likewise.
(test_used_atomic_or): Likewise.
(test_used_atomic_xor): Likewise.
* gcc.target/bpf/sync-fetch-and-add.c: Expected results updated.

12 months agotestsuite: Add RISC-V to targets not xfailing gcc.dg/attr-alloc_size-11.c:50,51.
Jiawei [Mon, 5 Aug 2024 12:15:59 +0000 (20:15 +0800)] 
testsuite: Add RISC-V to targets not xfailing gcc.dg/attr-alloc_size-11.c:50,51.

The test has been observed to pass on most architectures including RISC-V:
https://godbolt.org/z/8nYEvW6n1

Origin issue see:
https://gcc.gnu.org/PR79356#c11

Update RISC-V target to the pass list.

gcc/testsuite/ChangeLog:

* gcc.dg/attr-alloc_size-11.c: Add RISC-V to the list
of targets excluding xfail on lines 50 and 51.

12 months agoAArch64: Set instruction attribute of TST to logics_imm
Jennifer Schmitz [Mon, 29 Jul 2024 14:59:33 +0000 (07:59 -0700)] 
AArch64: Set instruction attribute of TST to logics_imm

As suggested in
https://gcc.gnu.org/pipermail/gcc-patches/2024-July/658249.html,
this patch changes the instruction attribute of "*and<mode>_compare0" (TST) from
alus_imm to logics_imm.

The patch was bootstrapped and regtested on aarch64-linux-gnu, no regression.
OK for mainline?

Signed-off-by: Jennifer Schmitz <jschmitz@nvidia.com>
gcc/

* config/aarch64/aarch64.md (*and<mode>_compare0): Change attribute.

12 months agogimple ssa: Fix a typo in gimple-ssa-sccopy.cc
Filip Kastl [Mon, 5 Aug 2024 12:39:06 +0000 (14:39 +0200)] 
gimple ssa: Fix a typo in gimple-ssa-sccopy.cc

Fixes a misplaced comment in gimple-ssa-sccopy.cc.  The comment belongs
to a bitmap definition but was instead placed before the beginning of a
namespace block.

gcc/ChangeLog:

* gimple-ssa-sccopy.cc: Move a misplaced comment.

Signed-off-by: Filip Kastl <fkastl@suse.cz>
12 months ago[MAINTAINERS] Add my email address to write after approval and DCO.
Jennifer Schmitz [Mon, 5 Aug 2024 12:08:19 +0000 (14:08 +0200)] 
[MAINTAINERS] Add my email address to write after approval and DCO.

ChangeLog:
* MAINTAINERS: Add myself.

12 months agolibiberty/argv.c: remove only_whitespace
Andrew Burgess [Mon, 29 Jul 2024 12:47:32 +0000 (13:47 +0100)] 
libiberty/argv.c: remove only_whitespace

After the commit:

  commit 5e1d530da87a6d2aa7e719744cb278e7e54a6623 (gcc-buildargv)
  Date:   Sat Feb 10 11:22:13 2024 +0000

      libiberty/buildargv: handle input consisting of only white space

The function only_whitespace (in argv.c) was no longer being called.
Lets delete it.

There should be no user visible changes after this commit.

2024-07-29  Andrew Burgess  <aburgess@redhat.com>

libiberty/

* argv.c (only_whitespace): Delete.

12 months agotree-reassoc.cc: PR tree-optimization/116139 Don't assert when forming fully-pipeline...
Kyrylo Tkachov [Fri, 2 Aug 2024 13:21:16 +0000 (06:21 -0700)] 
tree-reassoc.cc: PR tree-optimization/116139 Don't assert when forming fully-pipelined FMAs on wide MULT targets

The code in get_reassociation_width that forms FMAs aggressively when
they are fully pipelined expects the FMUL reassociation width in the
target to be less than for FMAs. This doesn't hold for all target
tunings.

This code shouldn't ICE, just avoid forming these FMAs here.
This patch does that.

Signed-off-by: Kyrylo Tkachov <ktkachov@nvidia.com>
PR tree-optimization/116139

gcc/ChangeLog:

* tree-ssa-reassoc.cc (get_reassociation_width): Move width_mult
<= width comparison to if condition rather than assert.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/pr116139.c: New test.

12 months agovect: Fix dot-product slp testcases [PR116000]
Feng Xue [Mon, 5 Aug 2024 10:13:55 +0000 (18:13 +0800)] 
vect: Fix dot-product slp testcases [PR116000]

These testcases were added by the patch of supporting multiple lane-reducing
operations. For target that has no dot-product instrution, we should add
matching condition to skip it.

2024-08-05 Feng Xue <fxue@os.amperecomputing.com>

gcc/testsuite/
PR tree-optimization/116000
* gcc.dg/vect/vect-reduc-chain-dot-slp-1.c: Skip target with no dot-
product instruction.
* gcc.dg/vect/vect-reduc-chain-dot-slp-2.c: Likewise.
* gcc.dg/vect/vect-reduc-chain-dot-slp-3.c: Likewise.
* gcc.dg/vect/vect-reduc-chain-dot-slp-4.c: Likewise.

12 months agoRevert "Make may_trap_p_1 return false for constant pool references [PR116145]" ...
Richard Sandiford [Mon, 5 Aug 2024 09:02:45 +0000 (10:02 +0100)] 
Revert "Make may_trap_p_1 return false for constant pool references [PR116145]" [PR116200]

This reverts commit ba730fd10934e4ca004251aa3748bf9da4d35e62.

12 months agoInline 'gcc/rust/Make-lang.in:RUST_LIBDEPS'
Thomas Schwinge [Wed, 28 Feb 2024 22:06:25 +0000 (23:06 +0100)] 
Inline 'gcc/rust/Make-lang.in:RUST_LIBDEPS'

..., also fixing up an apparently mis-merged
commit 2340894554334a310b891a1d9e9d5e3f502357ac
"gccrs: Add 'gcc/rust/Make-lang.in:LIBFORMAT_PARSER'", which was adding a bogus
second definition of 'RUST_LIBDEPS'.

gcc/rust/
* Make-lang.in (RUST_LIBDEPS): Inline into all users.

12 months agoDon't override 'LIBS' if '--enable-languages=rust'; use 'CRAB1_LIBS'
Thomas Schwinge [Mon, 5 Aug 2024 08:06:05 +0000 (10:06 +0200)] 
Don't override 'LIBS' if '--enable-languages=rust'; use 'CRAB1_LIBS'

Recent commit 6fef4d6ffcab0fec8518adcb05458cba5dbeac25
"gccrs: libgrust: Add format_parser library", added a general override of
'LIBS += -ldl -lpthread' if '--enable-languages=rust'.  This is wrong
conceptually, and will make the build fail on systems not providing such
libraries.  Instead, 'CRAB1_LIBS', added a while ago in
commit 75299e4fe50aa8d9b3ff529e48db4ed246083e64
"rust: Do not link with libdl and libpthread unconditionally", should be used,
and not generally, but for 'crab1' only.

gcc/rust/
* Make-lang.in (LIBS): Don't override.
(crab1$(exeext):): Use 'CRAB1_LIBS'.

12 months agogdbhooks: Add attempt to invoke on-gcc-hooks-load
Alex Coplan [Mon, 5 Aug 2024 07:45:58 +0000 (08:45 +0100)] 
gdbhooks: Add attempt to invoke on-gcc-hooks-load

This extends GCC's GDB hooks to attempt invoking the user-defined
command "on-gcc-hooks-load".  The idea is that users can define the
command in their .gdbinit to override the default values of parameters
defined by GCC's GDB extensions.

For example, together with the previous patch, I can add the following
fragment to my .gdbinit:

define on-gcc-hooks-load
  set gcc-dot-cmd xdot
end

which means, once the GCC extensions get loaded, whenever I invoke
dot-fn then the graph will be rendered using xdot.

The try/except should make this patch a no-op for users that don't
currently define this command.  I looked for a way to test explicitly
for whether a GDB command exists but didn't find one.

This is needed because the user's .gdbinit is sourced before GCC's GDB
extensions are loaded, and GCC-specific parameters can't be configured
before they are defined.

gcc/ChangeLog:

* gdbhooks.py: Add attempted call to "on-gcc-hooks-load" once
we've finished loading the hooks.

12 months agogdbhooks: Make dot viewer configurable
Alex Coplan [Mon, 5 Aug 2024 07:45:29 +0000 (08:45 +0100)] 
gdbhooks: Make dot viewer configurable

This adds a new GDB parameter 'gcc-dot-cmd' which allows the user to
configure the command used to render the CFG within dot-fn.

E.g. with this patch the user can change their dot viewer like so:

(gdb) show gcc-dot-cmd
The current value of 'gcc-dot-cmd' is "dot -Tx11".
(gdb) set gcc-dot-cmd xdot
(gdb) dot-fn # opens in xdot

The second patch in this series adds a hook which users can define in
their .gdbinit in order to be called when the GCC extensions have
finished loading, thus allowing users to automatically configure
gcc-dot-cmd as desired in their .gdbinit.

gcc/ChangeLog:

* gdbhooks.py (GCCDotCmd): New.
(gcc_dot_cmd): New. Use it ...
(DotFn.invoke): ... here.

12 months agolibgomp.texi: Add OpenMP TR13 routines to @menu (commented out)
Tobias Burnus [Mon, 5 Aug 2024 07:18:29 +0000 (09:18 +0200)] 
libgomp.texi: Add OpenMP TR13 routines to @menu (commented out)

To keep track of missing routine documentation (both implemented and not),
the libgomp.texi file contains all non-OMPT routines as commented items
in @menu. This commit adds the routines added in TR13 as commented fixme
items.

libgomp/ChangeLog:

* libgomp.texi (OpenMP Runtime Library Routines): Add TR13 routines
to @menu (commented out).

12 months agoIRA: Ignore debug insns for uses in split_live_ranges_for_shrink_wrap. [PR116179]
Andrew Pinski [Fri, 2 Aug 2024 17:04:40 +0000 (10:04 -0700)] 
IRA: Ignore debug insns for uses in split_live_ranges_for_shrink_wrap. [PR116179]

Late_combine exposed this latent bug in split_live_ranges_for_shrink_wrap.
What it did was copy-prop regno 151 from regno 119 from:
```
(insn 2 264 3 2 (set (reg/f:DI 119 [ thisD.3697 ])
        (reg:DI 151)) "/app/example.cpp":19:13 70 {*movdi_aarch64}
     (expr_list:REG_DEAD (reg:DI 151)
        (nil)))
```

into these insns:
```
(debug_insn 147 146 148 5 (var_location:DI thisD.3727 (reg/f:DI 119 [ thisD.3697 ])) "/app/example.cpp":21:5 -1
     (nil))
....
(insn 167 166 168 7 (set (reg:DI 1 x1)
        (reg/f:DI 119 [ thisD.3697 ])) "/app/example.cpp":14:21 70 {*movdi_aarch64}
     (nil))
```

Both are valid things to do. The problem is split_live_ranges_for_shrink_wrap looks at the
uses of reg 151 and with and without debugging reg 151 have a different usage in different BBs.
The function is trying to find a splitting point for reg 151 and they are different. In the end
this causes register allocation difference.
The fix is for split_live_ranges_for_shrink_wrap to ignore uses that were in debug insns.

Bootstrappped and tested on x86_64-linux-gnu with no regressions.

PR rtl-optimization/116179

gcc/ChangeLog:

* ira.cc (split_live_ranges_for_shrink_wrap): For the uses loop,
only look at non-debug insns.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
12 months agoDaily bump.
GCC Administrator [Mon, 5 Aug 2024 00:16:29 +0000 (00:16 +0000)] 
Daily bump.

12 months ago[committed][PR rtl-optimization/116199] Fix latent bug in reload's SUBREG handling
Jeff Law [Sun, 4 Aug 2024 19:09:02 +0000 (13:09 -0600)] 
[committed][PR rtl-optimization/116199] Fix latent bug in reload's SUBREG handling

Building glibc on the m68k has exposed a long standing latent bug in reload.

Basically ext-dce replaced an extension with a subreg expression (good)
resulting in this pair of insns:

> (insn 7 4 8 2 (set (reg:DI 31 [ _1 ])
>         (subreg:DI (reg/v:SI 37 [ __major ]) 0)) "j.c":7:32 75 {*m68k.md:1568}
>      (nil))
> (insn 8 7 10 2 (set (reg:DI 39 [ _2 ])
>         (ashift:DI (reg:DI 31 [ _1 ])
>             (const_int 8 [0x8]))) "j.c":7:48 322 {*ashldi3}
>      (expr_list:REG_DEAD (reg:DI 31 [ _1 ])
>         (nil)))

insn 7 was optimized to the simple copy by ext-dce.  That looks fine.  Combine
comes along and squashes them together resulting in:

> (insn 8 7 10 2 (set (reg:DI 39 [ _2 ])
>         (ashift:DI (subreg:DI (reg/v:SI 37 [ __major ]) 0)
>             (const_int 8 [0x8]))) "j.c":7:48 322 {*ashldi3}
>      (nil))

Which also looks good.

After IRA's allocation, in the middle of reload we have:

> (insn 8 7 10 2 (set (reg:DI 8 %a0 [orig:39 _2 ] [39])
>         (ashift:DI (subreg:DI (reg/v:SI 0 %d0 [orig:37 __major ] [37]) 0)
>             (const_int 8 [0x8]))) "j.c":7:48 322 {*ashldi3}
>      (nil))

Again, sensible.  The pattern requires op0 and op1 to match, so we try to
figure out if d0 & a0 are the same underlying register.  So we get into this
code in operands_match_p:

>       if (code == SUBREG)
>         {
>           i = REGNO (SUBREG_REG (x));
>           if (i >= FIRST_PSEUDO_REGISTER)
>             goto slow;
>           i += subreg_regno_offset (REGNO (SUBREG_REG (x)),
>                                     GET_MODE (SUBREG_REG (x)),
>                                     SUBREG_BYTE (x),
>                                     GET_MODE (x));
>         }
>       else
>         i = REGNO (x);
There's a similar fragment for the other operand.  The key is that
subreg_regno_offset call.  That call assumes the subreg is representable.  But
in the case of (subreg:DI (reg:SI d0)) we're going to get -1 (remember, m68k is
a big endian target).  That -1 gets passed to hard_regno_regs via this code
(again, just showing one of the two copies of this fragment):

>      if (REG_WORDS_BIG_ENDIAN
>           && is_a <scalar_int_mode> (GET_MODE (x), &xmode)
>           && GET_MODE_SIZE (xmode) > UNITS_PER_WORD
>           && i < FIRST_PSEUDO_REGISTER)
>         i += hard_regno_nregs (i, xmode) - 1;

That triggers the reported ICE.  It appears this has been broken since the
conversion to SUBREG_BYTE way back in 2001, though possibly it could have been
some minor changes around this code circa 2005 as well, it didn't seem worth
putting under the debugger to be sure.  Certainly the code from 2001 looks
suspicious to me.

Anyway, the fix here is pretty simple.  The routine "simplify_subreg_regno" is
meant to be used to determine if we can simplify the subreg expression and will
explicitly return -1 if it can't be represented for one reason or another.  It
checks a variety of conditions that aren't worth listing here.

Bootstrapped and regression tested on x86 (after reverting an unrelated patch
from Richard S that's causing multiple unrelated failures), which of course
doesn't really test the code as x86 is an LRA target.  Also built & tested the
crosses, none of which show issues (and some of which are reload targets).
m68k will bootstrap & regression test tomorrow, but I don't think there's any
point in waiting for that.

Pushing to the trunk.

PR rtl-optimization/116199
gcc/
* reload.cc (operands_match_p): Verify subreg is expressable before
trying to simplify and match it to another operand.

gcc/testsuite/
* gcc.dg/torture/pr116199.c: New test.

12 months agoDaily bump.
GCC Administrator [Sun, 4 Aug 2024 00:17:30 +0000 (00:17 +0000)] 
Daily bump.

12 months agolibquadmath: Fix up libquadmath/math/sqrtq.c compilation in some powerpc* configurati...
Jakub Jelinek [Sat, 3 Aug 2024 18:37:54 +0000 (20:37 +0200)] 
libquadmath: Fix up libquadmath/math/sqrtq.c compilation in some powerpc* configurations [PR116007]

My PR114623 change started using soft-fp.h and quad.h for the sqrtq implementation.
Unfortunately, that seems to fail building in some powerpc* configurations, where
TFmode isn't available.
quad.h has:
 #ifndef TFtype
 typedef float TFtype __attribute__ ((mode (TF)));
 #endif
and uses TFtype.  quad.h has:
 /* Define the complex type corresponding to __float128
    ("_Complex __float128" is not allowed) */
 #if (!defined(_ARCH_PPC)) || defined(__LONG_DOUBLE_IEEE128__)
 typedef _Complex float __attribute__((mode(TC))) __complex128;
 #else
 typedef _Complex float __attribute__((mode(KC))) __complex128;
 #endif
with the conditional and KCmode use added during porting of libquadmath
to powerpc*, so I've just defined TFtype for powerpc when __LONG_DOUBLE_IEEE128__
isn't defined; I could define it to float __attribute__ ((mode (KF))) but it
seemed easier to just define it to __float128 which should do the same thing.

2024-08-03  Jakub Jelinek  <jakub@redhat.com>

PR target/116007
* math/sqrtq.c (TFtype): For PowerPC without __LONG_DOUBLE_IEEE128__
define to __float128 before including soft-fp.h and quad.h.

12 months agolibstdc++: use concrete return type for std::forward_like
Patrick Palka [Sat, 3 Aug 2024 13:05:05 +0000 (09:05 -0400)] 
libstdc++: use concrete return type for std::forward_like

Inspired by https://github.com/llvm/llvm-project/issues/101614 this
inverts the relationship between forward_like and __like_t so that
forward_like is defined in terms of __like_t and with a concrete return
type.  __like_t in turn is defined via partial specializations that
pattern match on the const- and reference-ness of T.

This turns out to be more SFINAE friendly and significantly cheaper
to compile than the previous implementation.

libstdc++-v3/ChangeLog:

* include/bits/move.h (__like_impl): New metafunction.
(__like_t): Redefine in terms of __like_impl.
(forward_like): Redefine in terms of __like_t.
* testsuite/20_util/forward_like/2_neg.cc: Don't expect
error outside the immediate context anymore.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
12 months agoDaily bump.
GCC Administrator [Sat, 3 Aug 2024 00:18:55 +0000 (00:18 +0000)] 
Daily bump.

12 months agoFortran: Fix ICE on invalid in gfc_format_decoder.
Steve Kargl [Fri, 2 Aug 2024 04:50:49 +0000 (21:50 -0700)] 
Fortran: Fix ICE on invalid in gfc_format_decoder.

PR fortran/104626

gcc/fortran/ChangeLog:

* symbol.cc (gfc_add_save): Add checks for SAVE attribute
conflicts and duplicate SAVE attribute.

gcc/testsuite/ChangeLog:

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

12 months agoUpdate gcc .po files
Joseph Myers [Fri, 2 Aug 2024 21:12:13 +0000 (21:12 +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, nl.po, ru.po, sr.po, sv.po, tr.po, uk.po, vi.po, zh_CN.po,
zh_TW.po: Update.

12 months agoc++: Move -Wdangling-reference to -Wextra
Marek Polacek [Thu, 1 Aug 2024 14:35:38 +0000 (10:35 -0400)] 
c++: Move -Wdangling-reference to -Wextra

Despite a number of mitigations (don't warn for std::span-like classes,
lambdas, adding [[gnu::no_dangling]], etc.), the warning still seems to
cause some grief.  Let's move the warning to -Wextra, then.

gcc/c-family/ChangeLog:

* c.opt (Wdangling-reference): Move from -Wall to -Wextra.

gcc/ChangeLog:

* doc/invoke.texi: Document that -Wdangling-reference is
enabled by -Wextra.

12 months agoc++/coroutines: check for members we use in handle_types [PR105475]
Arsen Arsenović [Thu, 25 Jul 2024 20:41:34 +0000 (22:41 +0200)] 
c++/coroutines: check for members we use in handle_types [PR105475]

Currently, it is possible to ICE GCC by giving it sufficiently broken
code, where sufficiently broken means a std::coroutine_handle missing a
default on the promise_type template argument, and missing members.
As the code generator relies on lookups in the coroutine_handle never
failing (and has no way to signal that error), lets do it ahead of time,
save the result, and use that.  This saves us some lookups and allows us
to propagate an error.

PR c++/105475 - coroutines: ICE in coerce_template_parms, at cp/pt.cc:9183

gcc/cp/ChangeLog:

PR c++/105475
* coroutines.cc (struct coroutine_info): Add from_address.
Carries the from_address member we looked up earlier.
(coro_resume_identifier): Remove.  Unused.
(coro_init_identifiers): Do not initialize the above.
(void_coro_handle_address): New variable.  Contains the baselink
for the std::coroutine_handle<void>::address() instance method.
(get_handle_type_address): New function.  Looks up and validates
handle_type::address in a given handle_type.
(get_handle_type_from_address): New function.  Looks up and
validates handle_type::from_address in a given handle_type.
(coro_promise_type_found_p): Remove reliance on
coroutine_handle<> defaulting the promise type to void.  Store
get_handle_type_* results where appropriate.
(get_coroutine_from_address): New helper.  Gets the
handle_type::from_address BASELINK from a coroutine_info.
(build_actor_fn): Use the get_coroutine_from_address helper and
void_coro_handle_address.

gcc/testsuite/ChangeLog:

PR c++/105475
* g++.dg/coroutines/pr103868.C: Add std::coroutine_handle
members we check for now.
* g++.dg/coroutines/pr105287.C: Ditto.
* g++.dg/coroutines/pr105301.C: Ditto.
* g++.dg/coroutines/pr94528.C: Ditto.
* g++.dg/coroutines/pr94879-folly-1.C: Ditto.
* g++.dg/coroutines/pr94883-folly-2.C: Ditto.
* g++.dg/coroutines/pr98118.C: Ditto.
* g++.dg/coroutines/pr105475.C: New test.
* g++.dg/coroutines/pr105475-1.C: New test.
* g++.dg/coroutines/pr105475-2.C: New test.
* g++.dg/coroutines/pr105475-3.C: New test.
* g++.dg/coroutines/pr105475-4.C: New test.
* g++.dg/coroutines/pr105475-5.C: New test.
* g++.dg/coroutines/pr105475-6.C: New test.
* g++.dg/coroutines/pr105475-broken-spec.C: New test.
* g++.dg/coroutines/pr105475-broken-spec-2.C: New test.

12 months agofortran: Support optional dummy as BACK argument of MINLOC/MAXLOC.
Mikael Morin [Fri, 2 Aug 2024 12:24:34 +0000 (14:24 +0200)] 
fortran: Support optional dummy as BACK argument of MINLOC/MAXLOC.

Protect the evaluation of BACK with a check that the reference is non-null
in case the expression is an optional dummy, in the inline code generated
for MINLOC and MAXLOC.

This change contains a revert of the non-testsuite part of commit
r15-1994-ga55d24b3cf7f4d07492bb8e6fcee557175b47ea3, which factored the
evaluation of BACK out of the loop using the scalarizer.  It was a bad idea,
because delegating the argument evaluation to the scalarizer makes it
cumbersome to add a null pointer check next to the evaluation.

Instead, evaluate BACK at the beginning, before scalarization, add a check
that the argument is present if necessary, and evaluate the resulting
expression to a variable, before using the variable in the inline code.

gcc/fortran/ChangeLog:

* trans-intrinsic.cc (maybe_absent_optional_variable): New function.
(gfc_conv_intrinsic_minmaxloc): Remove BACK from scalarization and
evaluate it before.  Add a check that BACK is not null if the
expression is an optional dummy.  Save the resulting expression to a
variable.  Use the variable in the generated inline code.

gcc/testsuite/ChangeLog:

* gfortran.dg/maxloc_6.f90: New test.
* gfortran.dg/minloc_7.f90: New test.

12 months agogenemit: Fix handling of explicit parallels for clobbers [PR116058]
Andrew Pinski [Thu, 1 Aug 2024 21:22:36 +0000 (14:22 -0700)] 
genemit: Fix handling of explicit parallels for clobbers [PR116058]

In a define_insn, you could use either an explicit parallel for
the insns or genrecog/genemit will add one for you.
The problem when genemit is processing the pattern for clobbers
(to create the function add_clobbers), genemit hadn't add the implicit
parallel yet but at the same time forgot to ignore that there
could be an explicit parallel there.
This means in some cases (like in the sh backend), add_clobbers
and recog had a different idea if there was clobbers on the insn.
This fixes the problem by looking through the explicit parallel
for the instruction in genemit.

Bootstrapped and tested on x86_64-linux-gnu.

PR middle-end/116058

gcc/ChangeLog:

* genemit.cc (struct clobber_pat): Change pattern to be rtvec.
Add code field.
(gen_insn): Look through an explicit parallel if there was one.
Update store to new clobber_pat.
(output_add_clobbers): Update call to gen_exp for the changed
clobber_pat.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
12 months agoRISC-V: Improve length attributes for atomic insn sequences
Patrick O'Neill [Fri, 2 Aug 2024 03:27:52 +0000 (20:27 -0700)] 
RISC-V: Improve length attributes for atomic insn sequences

gcc/ChangeLog:

* config/riscv/sync-rvwmo.md: Add conditional length attributes.
* config/riscv/sync-ztso.md: Ditto.
* config/riscv/sync.md: Fix incorrect insn length attributes and
reformat existing conditional checks.

Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
12 months agoarm: Fix testism with mve/ivopts-3.c testcase
Andre Vieira [Fri, 2 Aug 2024 15:39:34 +0000 (16:39 +0100)] 
arm: Fix testism with mve/ivopts-3.c testcase

This patch ensures this testcase is ran for armv8.1-m.main+mve as this is
testing that doloops with function calls that aren't intrinsics get rejected
as potential doloop targets during ivopts.  For other targets this loop gets
rejected for different reasons.

gcc/testsuite/ChangeLog:

* gcc.target/arm/mve/ivopts-3.c: Add require target and options.

12 months agoAArch64: Fuse CMP+CSEL and CMP+CSET for -mcpu=neoverse-v2
Jennifer Schmitz [Fri, 2 Aug 2024 14:58:32 +0000 (15:58 +0100)] 
AArch64: Fuse CMP+CSEL and CMP+CSET for -mcpu=neoverse-v2

According to the Neoverse V2 Software Optimization Guide (section 4.14), the
instruction pairs CMP+CSEL and CMP+CSET can be fused, which had not been
implemented so far. This patch implements and tests the two fusion pairs.

The patch was bootstrapped and regtested on aarch64-linux-gnu, no regression.
There was also no non-noise impact on SPEC CPU2017 benchmark.
OK for mainline?

Signed-off-by: Jennifer Schmitz <jschmitz@nvidia.com>
gcc/

* config/aarch64/aarch64.cc (aarch_macro_fusion_pair_p): Implement
fusion logic.
* config/aarch64/aarch64-fusion-pairs.def (cmp+csel): New entry.
(cmp+cset): Likewise.
* config/aarch64/tuning_models/neoversev2.h: Enable logic in
field fusible_ops.

gcc/testsuite/

* gcc.target/aarch64/fuse_cmp_csel.c: New test.
* gcc.target/aarch64/fuse_cmp_cset.c: Likewise.

12 months agoMake may_trap_p_1 return false for constant pool references [PR116145]
Richard Sandiford [Fri, 2 Aug 2024 14:58:31 +0000 (15:58 +0100)] 
Make may_trap_p_1 return false for constant pool references [PR116145]

The testcase contains the constant:

  arr2 = svreinterpret_u8(svdup_u32(0x0a0d5c3f));

which was initially hoisted by hand, but which gimple optimisers later
propagated to each use (as expected).  The constant was then expanded
as a load-and-duplicate from the constant pool.  Normally that load
should then be hoisted back out of the loop, but may_trap_or_fault_p
stopped that from happening in this case.

The code responsible was:

      if (/* MEM_NOTRAP_P only relates to the actual position of the memory
     reference; moving it out of context such as when moving code
     when optimizing, might cause its address to become invalid.  */
  code_changed
  || !MEM_NOTRAP_P (x))
{
  poly_int64 size = MEM_SIZE_KNOWN_P (x) ? MEM_SIZE (x) : -1;
  return rtx_addr_can_trap_p_1 (XEXP (x, 0), 0, size,
GET_MODE (x), code_changed);
}

where code_changed is true.  (Arguably it doesn't need to be true in
this case, if we inserted invariants on the preheader edge, but it
would still need to be true for conditionally executed loads.)

Normally this wouldn't be a problem, since rtx_addr_can_trap_p_1
would recognise that the address refers to the constant pool.
However, the SVE load-and-replicate instructions have a limited
offset range, so it isn't possible for them to have a LO_SUM address.
All we have is a plain pseudo base register.

MEM_READONLY_P is defined as:

  /* 1 if RTX is a mem that is statically allocated in read-only memory.  */
  #define MEM_READONLY_P(RTX) \
    (RTL_FLAG_CHECK1 ("MEM_READONLY_P", (RTX), MEM)->unchanging)

and so I think it should be safe to move memory references if both
MEM_READONLY_P and MEM_NOTRAP_P are true.

The testcase isn't a minimal reproducer, but I think it's good
to have a realistic full routine in the testsuite.

gcc/
PR rtl-optimization/116145
* rtlanal.cc (may_trap_p_1): Trust MEM_NOTRAP_P even for code
movement if MEM_READONLY_P is also true.

gcc/testsuite/
PR rtl-optimization/116145
* gcc.target/aarch64/sve/acle/general/pr116145.c: New test.

12 months agoc++: DR882, main cannot be deleted [PR116169]
Marek Polacek [Thu, 1 Aug 2024 15:32:26 +0000 (11:32 -0400)] 
c++: DR882, main cannot be deleted [PR116169]

This DR clarifies that "int main() = delete;" is ill-formed.

PR c++/116169

gcc/cp/ChangeLog:

* decl.cc (cp_finish_decl): Disallow deleting ::main.

gcc/testsuite/ChangeLog:

* g++.dg/DRs/dr882.C: New test.

12 months agoc++, coroutines: Provide a CTOR for a callback object [NFC].
Iain Sandoe [Wed, 31 Jul 2024 13:51:31 +0000 (14:51 +0100)] 
c++, coroutines: Provide a CTOR for a callback object [NFC].

This provides and uses a CTOR to initialize the object used in
tree walks to track local variable uses.  This makes the idiom
used consistent.

gcc/cp/ChangeLog:

* coroutines.cc (struct local_vars_frame_data): Add a
CTOR.
(morph_fn_to_coro): Use CTOR for local_vars_frame_data
instead of brace init.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
12 months agoc++, coroutines: Remove unused suspend point state [NFC].
Iain Sandoe [Tue, 30 Jul 2024 07:58:42 +0000 (08:58 +0100)] 
c++, coroutines: Remove unused suspend point state [NFC].

We maintain state on the progress of await analysis in an object that
is passed to the various tree walks used.  Some of the state had become
stale (i.e. unused members).  Remove those and provide a CTOR so that
updates are localised.

Remove the file scope hash_map used to collect the final state for the
actor function and make that part of the suspend point state.

gcc/cp/ChangeLog:

* coroutines.cc (struct susp_frame_data): Remove unused members,
provide a CTOR.
(morph_fn_to_coro): Use susp_frame_data CTOR, and make the suspend
state hash map local to the morph function.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
12 months agoc++, coroutines: Fix a typo in checking for void expression types.
Iain Sandoe [Wed, 24 Jul 2024 19:59:10 +0000 (20:59 +0100)] 
c++, coroutines: Fix a typo in checking for void expression types.

The current code fails to check for void expression types because it does
not looup the type.  Fixed thus.

gcc/cp/ChangeLog:

* coroutines.cc (replace_continue): Look up expression type.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
12 months agoforwprop: Don't add uses to dce list if debug statement [PR116156]
Andrew Pinski [Thu, 1 Aug 2024 17:33:34 +0000 (10:33 -0700)] 
forwprop: Don't add uses to dce list if debug statement [PR116156]

The problem here is that when forwprop does a copy prop, into a statement,
we mark the uses of that statement as possibly need to be removed. But it just
happened that statement was a debug statement, there will be a difference when
compiling with debuging info turned on vs off; this is not expected.
So the fix is not to add the old use to dce list to process if it was a debug
statement.

Bootstrapped and tested on x86_64-linux-gnu with no regressions.

PR tree-optimization/116156

gcc/ChangeLog:

* tree-ssa-forwprop.cc (pass_forwprop::execute): Don't add
uses if the statement was a debug statement.

gcc/testsuite/ChangeLog:

* c-c++-common/torture/pr116156-1.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
12 months agoc: Add support for byte arrays in C2Y
Martin Uecker [Sun, 23 Jun 2024 21:14:33 +0000 (23:14 +0200)] 
c: Add support for byte arrays in C2Y

To get correct aliasing behavior requires that structures and unions
that contain a byte array, i.e. an array of non-atomic character
type (N3254), are marked with TYPE_TYPELESS_STORAGE.  This change
affects also earlier language modes.

gcc/c/
* c-decl.cc (grokdeclarator, finish_struct): Set and
propagate TYPE_TYPELESS_STORAGE.

gcc/testsuite/
* gcc.dg/c2y-byte-alias-1.c: New test.
* gcc.dg/c2y-byte-alias-2.c: New test.
* gcc.dg/c2y-byte-alias-3.c: New test.

12 months agoi386: Fix comment/naming for APX NDD constraints
Lingling Kong [Fri, 2 Aug 2024 08:52:33 +0000 (16:52 +0800)] 
i386: Fix comment/naming for APX NDD constraints

gcc/ChangeLog:

* config/i386/constraints.md: Fixed the comment/naming for je/jM/jO.
* config/i386/predicates.md (apx_ndd_memory_operand): Renamed and
fixed the comment.
(apx_evex_memory_operand): New name.
(apx_ndd_add_memory_operand): Ditto.
(apx_evex_add_memory_operand): Ditto.

12 months agolibstdc++: Add missing <cstdint> to test
Jonathan Wakely [Fri, 2 Aug 2024 07:27:09 +0000 (08:27 +0100)] 
libstdc++: Add missing <cstdint> to test

libstdc++-v3/ChangeLog:

* testsuite/libstdc++-prettyprinters/shared_ptr.cc: Include
<cstdint>.

12 months agoada: Fix handling of SPARK_Mode on standalone child subprogram
Yannick Moy [Wed, 17 Jul 2024 08:43:06 +0000 (10:43 +0200)] 
ada: Fix handling of SPARK_Mode on standalone child subprogram

SPARK_Mode aspect was not properly propagated to the body of
a standalone child subprogram from the generated spec for that subprogram,
leading GNATprove to not analyze this body. Now fixed.

gcc/ada/

* aspects.adb (Find_Aspect): Take into account the case of a node
of kind N_Defining_Program_Unit_Name.
* sem_ch10.adb (Analyze_Compilation_Unit): Copy the SPARK aspect
from the spec to the body. Delay semantic analysis after that
point to ensure that SPARK_Mode is properly analyzed.

12 months agoada: Fix handling of iterated component associations with sub-aggregates
Piotr Trojanek [Tue, 16 Jul 2024 14:07:59 +0000 (16:07 +0200)] 
ada: Fix handling of iterated component associations with sub-aggregates

Fix a number of problems in handling of actions generated for a
2-dimensional array aggregate where the outer aggregate has iterated
component association and the inner aggregate involves run-time checks.

gcc/ada/

* exp_aggr.adb (Add_Loop_Actions): Actions are now attached to
iterated component association just like they are attached to
ordinary component association.
(Build_Array_Aggr_Code): If resolution of the array aggregate
generated some actions, e.g. for run-time checks, then we must
keep them; same for the Other_Clause.
* sem_aggr.adb (Resolve_Iterated_Component_Association): Unset
references to iterator variable in loop actions (which might come
from run-time check), just these references are unset in the
expression itself.

12 months agoada: Remove unused null branch
Piotr Trojanek [Fri, 5 Jul 2024 15:42:00 +0000 (17:42 +0200)] 
ada: Remove unused null branch

Code cleanup; semantics is unaffected.

gcc/ada/

* exp_util.adb (Insert_Actions): Remove null ELSE branch.

12 months agoada: Simplify manipulation of the list with loop actions
Piotr Trojanek [Fri, 5 Jul 2024 15:16:36 +0000 (17:16 +0200)] 
ada: Simplify manipulation of the list with loop actions

Code cleanup; behavior is unaffected.

gcc/ada/

* exp_aggr.adb (Add_Loop_Actions): Change manipulation of list
to avoid unnecessary calls to Parent and Loop_Actions.

12 months agoada: Refactor negated conjuncts
Piotr Trojanek [Fri, 5 Jul 2024 15:15:49 +0000 (17:15 +0200)] 
ada: Refactor negated conjuncts

Code cleanup; semantics is unaffected.

gcc/ada/

* exp_util.adb (Insert_Actions): Move negation in front of
complex conjunctions.

12 months agoada: Simplify code by reusing Choice_List
Piotr Trojanek [Fri, 5 Jul 2024 11:01:08 +0000 (13:01 +0200)] 
ada: Simplify code by reusing Choice_List

Code cleanup; semantics is unaffected.

gcc/ada/

* exp_aggr.adb (Gen_Assign): Fix layout.
* sem_aggr.adb (Empty_Range): Reuse Choice_List.

12 months agoada: Errors on legal container aggregates with iterated_element_associations
Gary Dismukes [Mon, 15 Jul 2024 23:57:43 +0000 (23:57 +0000)] 
ada: Errors on legal container aggregates with iterated_element_associations

The compiler rejects various cases of container aggregates with
iterated_element_associations that include a loop_parameter_subtype_indication
or that include the "reverse" keyword. The fixes are in the parser, for
naccepting the syntax for these cases, as well as for properly accounting
for reverse iterators in the analyzer and expander.

gcc/ada/

* exp_aggr.adb
(Expand_Container_Aggregate.Expand_Iterated_Component): Set the
Reverse_Present flag when creating the loop's iteration_scheme.
* gen_il-gen-gen_nodes.adb: Add flag Reverse_Present to
N_Iterated_Component_Association nodes.
* par-ch3.adb (P_Constraint_Op): Remove testing for and ignoring
of Tok_In following a constraint. It's allowed for "in" to follow
a constraint of loop_parameter_subtype_indication of an
iterator_specification, so it shouldn't be ignored.
* par-ch4.adb (P_Iterated_Component_Association): Account for
"reverse" following the "in" in an iterated_component_association,
and set the Reverse_Present flag on the
N_Iterated_Component_Association node. Add handling for a ":"
following the identifier in an iterator_specification of an
iterated_element_association, sharing the code with the "of" case
(which backs up to the identifier at the beginning of the
iterator_specification). Fix incorrect trailing comment following
the call to Scan.
(Build_Iterated_Element_Association): Set the Reverse_Present flag
on an N_Loop_Parameter_Specification node of an
N_Iterated_Element_Association.
* par-ch5.adb (P_Iterator_Specification): Remove error-recovery
and error code that reports "subtype indication is only legal on
an element iterator", as that error can no longer be emitted (and
was formerly only reported on one fixedbugs test).
* sem_aggr.adb
(Resolve_Container_Aggregate.Resolve_Iterated_Association): When
creating an N_Iterator_Specification for an
N_Iterated_Component_Association, set the Reverse_Present flag of
the N_Iterated_Specification from the flag on the latter.
* sinfo.ads: Add comments for the Reverse_Present flag, which is
now allowed on nodes of kind N_Iterated_Component_Association.

12 months agoada: Plug loophole in handling of No_Raise pragma
Eric Botcazou [Mon, 15 Jul 2024 20:29:06 +0000 (22:29 +0200)] 
ada: Plug loophole in handling of No_Raise pragma

Unlike the aspect, the pragma needs to be propagated explicitly from a
generic subprogram to its instances.

gcc/ada/

* sem_ch12.adb (Analyze_Subprogram_Instantiation): Propagate the
No_Raise flag like the No_Return flag.

12 months agoada: Tweak container aggregate expansion code
Ronan Desplanques [Mon, 15 Jul 2024 08:22:29 +0000 (10:22 +0200)] 
ada: Tweak container aggregate expansion code

This patch makes a minor modification to Expand_Container_Aggregate
in order to silence a GNAT SAS false positive.

gcc/ada/

* exp_aggr.adb (Expand_Container_Aggregate): Remove variables.
(To_Int): New function.
(Add_Range_Size): Use newly introduced function.

12 months agoada: Add contracts to Ada.Strings.Unbounded and adapt implementation
Yannick Moy [Tue, 2 Jul 2024 14:07:05 +0000 (16:07 +0200)] 
ada: Add contracts to Ada.Strings.Unbounded and adapt implementation

Add complete functional contracts to all subprograms in
Ada.Strings.Unbounded, except Count, following the specification from
Ada RM A.4.5. These contracts are similar to the contracts found in
Ada.Strings.Fixed and Ada.Strings.Bounded.

A difference is that type Unbounded_String is controlled, thus we avoid
performing copies of a parameter Source with Source'Old, and instead
apply 'Old attribute on the enclosing call, such as Length(Source)'Old.

As Unbounded_String is controlled, the implementation is not in SPARK.
Instead, we have separately proved a slightly different implementation
for which Unbounded_String is not controlled, against the same
specification. This ensures that the specification is consistent.

To minimize differences between this test from the SPARK testsuite and
the actual implementation (the one in a-strunb.adb), and to avoid
overflows in the actual implementation, some code is slightly rewritten.
Delete and Insert are modified to return the correct result in all
cases allowed by the standard.

The same contracts are added to the version in a-strunb__shared.ads and
similar implementation patches are applied to the body
a-strunb__shared.adb. In particular, tests are added to avoid overflows
on strings for which the last index is Natural'Last, and the computations
that involve Sum to guarantee that an exception is raised in case of
overflow are rewritten to guarantee correct detection and no intermediate
overflows (and such tests are applied consistently between the procedure
and the function when both exist).

gcc/ada/

* libgnat/a-strunb.adb (Sum, Saturated_Sum, Saturated_Mul): Adapt
function signatures to more precise types that allow proof.
(function "&"): Conditionally assign a slice to avoid possible
overflow which only occurs when the assignment is a noop (because
the slice is empty in that case).
(Append): Same.
(function "*"): Retype K to avoid a possible overflow. Add early
return on null length for proof.
(Delete): Fix implementation to return the correct result in all
cases allowed by the Ada standard.
(Insert): Same. Also avoid possible overflows.
(Length): Rewrite as expression function for proof.
(Overwrite): Avoid possible overflows.
(Slice): Same.
(To_String): Rewrite as expression function for proof.
* libgnat/a-strunb.ads: Extend Assertion_Policy to new contracts
used. Add complete functional contracts to all subprograms of the
public API except Count.
* libgnat/a-strunb__shared.adb (Sum): Adapt function signature to
more precise types that allow proof.
(function "&"): Conditionally assign a slice to avoid possible
overflow.
(function "*"): Retype K to avoid a possible overflow.
(Delete): Fix implementation to return the correct result in all
cases allowed by the Ada standard.
(Insert): Avoid possible overflows.
(Overwrite): Avoid possible overflows.
(Replace_Slice): Same.
(Slice): Same.
(To_String): Rewrite as expression function for proof.
* libgnat/a-strunb__shared.ads: Extend Assertion_Policy to new
contracts used. Add complete functional contracts to all
subprograms of the public API except Count. Mark public part of
spec as in SPARK.

12 months agoada: Ensure variable is initialized before use
Ronan Desplanques [Fri, 12 Jul 2024 08:56:58 +0000 (10:56 +0200)] 
ada: Ensure variable is initialized before use

This patch is motivated by a GNAT SAS report.

gcc/ada/

* scng.adb (Slit): Initialize object in uncommon path.

12 months agoada: Remove unreferenced procedure
Richard Kenner [Fri, 12 Jul 2024 13:38:21 +0000 (09:38 -0400)] 
ada: Remove unreferenced procedure

gcc/ada/

* exp_ch4.adb (Generate_Temporary): Remove unused procedure.

12 months agoada: Clean up handling of inlining of finalizer procedures
Richard Kenner [Fri, 12 Jul 2024 13:45:26 +0000 (09:45 -0400)] 
ada: Clean up handling of inlining of finalizer procedures

Change Is_Finalizer from synthesized attribute into flag. Remove duplicate
Is_Finalizer_Proc. Add new Try_Inline_Always for backend usage.

gcc/ada/

* einfo-utils.ads (Is_Finalizer): Delete.
* einfo-utils.adb (Is_Finalizer): Delete.
* einfo.ads: Adjust comment.
* gen_il-fields.ads, gen_il-gen-gen_entities.adb: Add Is_Finalizer
flag.
* exp_ch3.adb (Build_Init_Procedure): Set it.
* exp_ch7.adb (Create_Finalizer): Likewise.
* exp_util.adb (Try_Inline_Always): New function.
* exp_util.ads (Try_Inline_Always): New function.
* sem_elab.adb (Is_Finalizer_Proc): Replace with Is_Finalizer.

12 months agoada: Add leap second support to conversion of Unix_Time
Tonu Naks [Mon, 8 Jul 2024 08:50:00 +0000 (08:50 +0000)] 
ada: Add leap second support to conversion of Unix_Time

Unix timestamp jumps one second back when a leap second
is applied and doesn't count cumulative leap seconds.
This was not taken into account in conversions between
Unix time and Ada time. Now fixed.

gcc/ada/

* libgnat/a-calend.adb: Modify unix time handling.

12 months agoada: Update doc of Style_Checks pragma
Tonu Naks [Tue, 9 Jul 2024 12:02:57 +0000 (12:02 +0000)] 
ada: Update doc of Style_Checks pragma

gcc/ada/

* doc/gnat_rm/implementation_defined_pragmas.rst: Add examples.
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.

12 months agoada: Reject ambiguous function calls in interpolated string expressions
Javier Miranda [Sat, 6 Jul 2024 19:07:16 +0000 (19:07 +0000)] 
ada: Reject ambiguous function calls in interpolated string expressions

This patch enhances support for this language feature by rejecting
more ambiguous function calls. In terms of name resolution, the
analysis of interpolated expressions is now treated as an expression
of any type, as required by the documentation. Additionally, support
for nested interpolated strings has been removed.

gcc/ada/

* gen_il-fields.ads (Is_Interpolated_String_Literal): New field.
* gen_il-gen-gen_nodes.adb (Is_Interpolated_String_Literal): The
new field is a flag handled by the parser (syntax flag).
* par-ch2.adb (P_Interpolated_String_Literal): Decorate the new
flag.
* sem_ch2.adb (Analyze_Interpolated_String_Literal): Improve code
detecting and reporting ambiguous function calls.
* sem_res.adb (Resolve_Interpolated_String_Literal): Restrict
resolution imposed by the context type to string literals that
have the new flag.
* sinfo.ads (Is_Interpolated_String_Literal): New field defined in
string literals. Fix documentation of the syntax rule of
interpolated string literal.