Pan Li [Fri, 19 Sep 2025 06:54:47 +0000 (14:54 +0800)]
Match: Add form 5 of unsigned SAT_MUL for mul
This patch would like to try to match the the unsigned
SAT_MUL form 5, aka below:
#define DEF_SAT_U_MUL_FMT_5(NT, WT) \
NT __attribute__((noinline)) \
sat_u_mul_##NT##_from_##WT##_fmt_5 (NT a, NT b) \
{ \
WT x = (WT)a * (WT)b; \
NT hi = x >> (sizeof(NT) * 8); \
NT lo = (NT)x; \
return lo | -!!hi; \
}
while WT is uint16_t, uint32_t and uint64_t.
and T is uint8_t, uint16_t, uint32_t.
gcc/ChangeLog:
* match.pd: Add pattern of mult and reuse the widen-mul
by for keyword.
David Malcolm [Tue, 23 Sep 2025 20:38:37 +0000 (16:38 -0400)]
sarif output: add descriptions to fix-it hints (§3.55.2) [PR121986]
SARIF "fix" objects SHOULD have a "description" property (§3.55.2) that
describes the proposed fix, but currently GCC's SARIF output doesn't
support this, and we don't capture this anywhere internally as we build
fix-it hints in the compiler.
Currently we can have zero or more instances of fixit_hint associated
with a diagnostic, each representing an edit of a range of the source
code. Ideally we would have an internal API that allowed for associating
multiple fixes with a diagnostic, each with a description worded in terms
of the source language (e.g. "Fix 'colour' mispelling of field 'color'"),
and each consisting of multiple edited ranges.
For now, this patch extends the sarif output sink so that it
autogenerates descriptions of fix-it hints for simple cases of
insertion, deletion, and replacement of a single range
(e.g. "Replace 'colour' with 'color'").
gcc/ChangeLog:
PR diagnostics/121986
* diagnostics/sarif-sink.cc: Include "intl.h".
(sarif_builder::make_message_describing_fix_it_hint): New.
(sarif_builder::make_fix_object): Attempt to auto-generate a
description for fix-it hints.
gcc/testsuite/ChangeLog:
PR diagnostics/121986
* gcc.dg/sarif-output/extra-semicolon.c: New test.
* gcc.dg/sarif-output/extra-semicolon.py: New test.
* gcc.dg/sarif-output/missing-semicolon.py: Verify the description
of the insertion fix-it hint.
* libgdiagnostics.dg/test-fix-it-hint-c.py: Verify the description
of the replacement fix-it hint.
libcpp/ChangeLog:
PR diagnostics/121986
* include/rich-location.h (fixit_hint::deletion_p): New accessor.
(fixit_hint::replacement_p): New accessor.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Jonathan Wakely [Mon, 8 Sep 2025 20:53:33 +0000 (21:53 +0100)]
libstdc++: Refactor std::philox_engine member functions
libstdc++-v3/ChangeLog:
* include/bits/random.h: Include <bits/ios_base.h> instead of
<iomanip>. Change preprocessor checks to use internal feature
test macro.
(philox_engine): Reword doxygen comments. Use typename instead
of class in template parameter lists. Reformat and adjust
whitespace.
(philox_engine::_If_seed_seq): Replace alias template with
__is_seed_seq variable template.
(philox_engine::philox_engine(result_type)): Define inline.
(philox_engine::seed(result_type), philox_engine::set_counter)
(philox_engine::operator(), philox_engine::discard): Likewise.
(operator==): Define as defaulted.
(operator<<): Reuse widened char.
* include/bits/random.tcc: Reformat and adjust whitespace.
(philox_engine::_M_philox): Use std::array copy constructor and
std::array::fill instead of looping.
* testsuite/26_numerics/random/philox4x32.cc: Gate test on
feature test macro. Add static_assert to check typedef.
* testsuite/26_numerics/random/philox4x64.cc: Likewise.
* testsuite/26_numerics/random/philox_engine/cons/copy.cc: Add
VERIFY assertions to check copies are equal. Test different
seeds.
* testsuite/26_numerics/random/philox_engine/cons/default.cc:
Add VERIFY assertions to check construction results.
* testsuite/26_numerics/random/philox_engine/cons/seed.cc:
Likewise.
* testsuite/26_numerics/random/philox_engine/operators/equal.cc:
Also test inequality.
* testsuite/26_numerics/random/philox_engine/operators/serialize.cc:
Remove redundant include and return.
* testsuite/26_numerics/random/philox_engine/requirements/constants.cc:
Check values of all constants.
* testsuite/26_numerics/random/philox_engine/requirements/typedefs.cc:
Check typedefs are correct.
* testsuite/26_numerics/random/philox_engine/cons/119794.cc:
Removed.
* testsuite/26_numerics/random/philox_engine/cons/seed_seq.cc:
Removed.
* testsuite/26_numerics/random/philox_engine/operators/inequal.cc:
Removed.
* testsuite/26_numerics/random/philox_engine/requirements/constexpr_data.cc:
Removed.
* testsuite/26_numerics/random/philox_engine/requirements/constexpr_functions.cc:
Removed.
* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error
line number.
1nfocalypse [Tue, 5 Aug 2025 01:37:18 +0000 (01:37 +0000)]
libstdc++: Implement Philox Engine (PR119794)
Conforms with errata LWG4143, LWG4153 for Philox Engine.
PR libstdc++/119794
libstdc++-v3/ChangeLog:
* include/bits/random.h (philox_engine): Define.
* include/bits/random.tcc (philox_engine): Define member
functions.
* include/bits/version.def (philox_engine): New macro.
* include/bits/version.h: Regenerated.
* include/std/random: Define __glibcxx_want_philox_engine and
include <bits/version.h>.
* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error
line number.
* testsuite/26_numerics/random/philox4x32.cc: New test.
* testsuite/26_numerics/random/philox4x64.cc: New test.
* testsuite/26_numerics/random/philox_engine/cons/119794.cc: New test.
* testsuite/26_numerics/random/philox_engine/cons/copy.cc: New test.
* testsuite/26_numerics/random/philox_engine/cons/default.cc: New test.
* testsuite/26_numerics/random/philox_engine/cons/seed.cc: New test.
* testsuite/26_numerics/random/philox_engine/cons/seed_seq.cc: New test.
* testsuite/26_numerics/random/philox_engine/operators/equal.cc: New test.
* testsuite/26_numerics/random/philox_engine/operators/inequal.cc: New test.
* testsuite/26_numerics/random/philox_engine/operators/serialize.cc: New test.
* testsuite/26_numerics/random/philox_engine/requirements/constants.cc: New test.
* testsuite/26_numerics/random/philox_engine/requirements/constexpr_data.cc: New test.
* testsuite/26_numerics/random/philox_engine/requirements/constexpr_functions.cc: New test.
* testsuite/26_numerics/random/philox_engine/requirements/typedefs.cc: New test.
Ben Wu [Fri, 19 Sep 2025 00:25:41 +0000 (17:25 -0700)]
libstdc++: fix element construction in std::deque::emplace [PR118087]
In order to emplace a value in the middle of a deque, a temporary was
previously constructed directly with __args... in _M_emplace_aux.
This would not work since std::deque is allocator-aware and should
construct elements with _Alloc_traits::construct instead before the
element is moved.
Using the suggestion in PR118087, we can define _Temporary_value
similar to the one used in std::vector, so the temporary can be
constructed with uses-allocator construction.
PR libstdc++/118087
libstdc++-v3/ChangeLog:
* include/bits/deque.tcc: Use _Temporary_value in
_M_emplace_aux.
* include/bits/stl_deque.h: Introduce _Temporary_value.
* testsuite/23_containers/deque/modifiers/emplace/118087.cc:
New test.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Ben Wu <soggysocks206@gmail.com>
arm: mve: fix out-of range literal pool for a const_vector [PR121810]
For the pattern mve_mov<mode>, the alternative that describes literal
pool support is incorrect. This leads to compiler getting the
calculations wrong for the available distance to the next pool
fragment because the selected alternative is a shorter sequence than
the correct one. In particular the sequence generated for a 128-bit
constant is
vldr.64 d0, Pool // Insn length 4, alternative 7 (part 1)
vldr.64 d1, Pool+8 // Insn length 4, alternative 7 (part 2)
Note that the second instruction needs 4 bytes more range than the
first because the PC has advanced by 4 bytes, but the next slot in the
pool has advanced by 8.
The fix is to move the 'Ui' constraint to the correct alternative
and to move the pool-range attributes to that alternative as well.
I've fixed a couple of other nits in this code at the same time:
- the thumb2_neg_pool_range attribute was misnamed (as neg_pool_range),
meaning it was ignored in Thumb state, which is the only time this
pattern is available.
- the load range was not a multiple of 4, which makes no sense for
an insn sequence that is a multiple of 4 bytes long. I've rounded the
value down out of caution, but it may well have been OK with 1020 as
the forward range.
I'm not adding a testcase for this patch; the code to reproduce is
simply too complex to reliably test for a regression.
gcc/ChangeLog:
PR target/121810
* config/arm/mve.md (mve_mov<mode>): Move the Ui constraint
and pool_range attributes to the final alternative. Fix
the forward range value and correctly name the negative
range.
Tomasz Kamiński [Tue, 23 Sep 2025 06:54:28 +0000 (08:54 +0200)]
libstdc++: Make function_ref(nontype<f>, r) CTAD SFINAE friendly [PR121940]
Instantiating the __deduce_funcref function body for function pointers
without arguments or member pointers with non-matching object types
previously led to hard errors due to the formation of invalid types.
The __deduce_funcref function is now adjusted to return void in such
cases. The corresponding function_ref deduction guide is constrained to
only match if the return type is not void, making it SFINAE friendly.
PR libstdc++/121940
libstdc++-v3/ChangeLog:
* include/bits/funcwrap.h (__polyfunc::__deduce_funcref): Return void
for ill-formed constructs.
(function_ref(nontype_t<__f>, _Tp&&)): Constrain on __deduce_funcref
producing non-void results.
* testsuite/20_util/function_ref/deduction.cc: Negative tests.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
Bob Duff [Mon, 15 Sep 2025 12:26:03 +0000 (08:26 -0400)]
ada: Fix unnesting problem related to constructors
This patch fixes a bug in unnesting, which is used by the llvm back end.
Exp_Unst relies on the Scope field of nodes to detect up-level
references. Temps created by Prepend_Constructor_Procedure_Prologue
could have an incorrect Scope, causing Exp_Unst to use an up-level
reference to an activation record to implement up-level references. That
won't work; Exp_Unst is supposed to REMOVE up-level references.
This patch corrects the Scope of such temps.
gcc/ada/ChangeLog:
* exp_ch6.adb (Prepend_Constructor_Procedure_Prologue):
Push/Pop the procedure scope, so that temps created herein
get the right Scope.
Jose Ruiz [Tue, 22 Jul 2025 09:22:36 +0000 (11:22 +0200)]
ada: Improve robustness of stack usage tracking in concurrent contexts
Enabled computation of stack usage for tasks that have already
initialized their stacks with the expected fill pattern.
Ensured that stack usage snapshots for tasks are taken while
the runtime is locked, to maintain consistency.
For the environment task, approximated the stack origin using
the topmost stack known address during initialization, and take
into account that the Stack_Analyzer object is not part of its
ATCB.
gcc/ada/ChangeLog:
* libgnarl/s-stusta.adb (Report_Impl): Export a copy of
the current stack usage while holding the runtime lock.
(Report_For_Task): Do not compute stack usage for a task
that has not yet initialized its stack with the expected
pattern.
(Report_For_Task): The Stack_Analyzer object for the
environment task is not part of its ATCB. For the rest of
the tasks wait until we have initialized the stack pattern
before computing stack usage.
(Report_All_Tasks, Get_All_Tasks_Usage,
Get_Current_Task_Usage): Adapt to the new interface from
Report_Impl. Take into account that Result_Array can be
null. When we don't store stack results for a task we
need to compute it when requested.
(Print): Handle the case when we don't know the stack
usage to be reported.
* libgnat/s-stausa.adb (Initialize): For the environment
task, approximate the stack origin with the topmost
stack address that is known.
* libgnat/s-stausa.ads: Clarify comments.
Douglas B Rupp [Thu, 11 Sep 2025 17:13:35 +0000 (10:13 -0700)]
ada: Remove rtp base spec linker option pragma
Remove the linker option pragmas from vxworks7 rtp system specs,
since this is needed only with gnatmake. The same info is contained
in gprbuild, which is the only tool that can be used for building
vxworks apps.
Gary Dismukes [Wed, 10 Sep 2025 19:33:56 +0000 (19:33 +0000)]
ada: New preprocessing option for emitting empty comments for deleted lines
When integrated preprocessing is done on a source file with lines that are
filtered out, by default this can result in multiple blank lines being emitted,
but this can clash with the style switch -gnatyu, which will flag cases of
multiple blank lines. A new preprocessing option "-e" is added to allow
outputting "empty" comment lines rather than blank lines (the comments consist
of "--!" and no other text). This option is also available for the gnatprep
tool. This behavior is the default when integrated preprocessing is done
without generating a ".prep" output file with -gnateG, but when -gnateG is
used, blank lines are still substituted by default for directives and removed
source lines (for compatibility with long-existing behavior). The -gnateG
switch is also extended to allow appending 'b', 'c', or 'e' at the end of
the switch to force any of the replacement options ('b' => blank lines,
'c' => comments including the original source lintes, and 'e' => empty
comment lines).
gcc/ada/ChangeLog:
* doc/gnat_ugn/building_executable_programs_with_gnat.rst: Add doc
for addition of -gnateG options b, c, and e.
* doc/gnat_ugn/the_gnat_compilation_model.rst: Add doc for "-e" optionn
on gnatprep and integrated preprocessing. Add doc for addition of
-gnateG options b, c, and e.
* gprep.adb (Scan_Command_Line): Add 'e' to the list of allowed switch
letters in the string passed to GNAT.Command_Line.Getopt. Set the flag
Opt.Empty_Comment_Deleted_Lines to True when the "-e" switch is found.
(Usage): Output a switch description for the "-e" switch.
* opt.ads: Add new flag variable Empty_Comment_Deleted_Lines. Add
"GNAT" to the "GNATPREP" comment line for Comment_Deleted_Lines.
* prep.adb (Output_Line): Add handling for Empty_Comment_Deleted_Lines,
outputting comment lines consisting of "--!" for lines that are removed
in the preprocessed source file when Empty_Comment_Deleted_Lines is True.
* prepcomp.adb (Preproc_Data): Add Empty_Comments component (defaulting
to False).
(No_Preproc_Data): Add association for Empty_Comments component.
(Parse_Preprocessing_Data_File): Add handling for new switch -e.
(Prepare_To_Preprocess): Add logic for setting the new option
Empty_Comment_Deleted_Lines (and making it the default for
integrated preprocessing in the absence of other switches).
* switch-c.adb (Scan_Front_End_Switches): Add support adding a single
character 'b', 'c', 'e' to the "-gnateG" switch, to select any of the
three options for replacing deleted lines in preprocessing output file.
* usage.adb: Update usage info for -gnateG, to reflect the option of
appending b, c, or e to the switch.
* gnat_ugn.texi: Regenerate.
Javier Miranda [Tue, 2 Sep 2025 12:15:45 +0000 (12:15 +0000)]
ada: Spurious predicate check at default initialization
For an object created by an object_declaration with no explicit
initialization expression, if the type of the object is a record
type (or a private record type) with no components and a dynamic
predicate, then no predicate check must be performed at runtime
(RM 3.2.4(31/5)).
gcc/ada/ChangeLog:
* sem_util.adb (Is_Partially_Initialized_Type): Return False
for record types with no components.
Pan Li [Tue, 23 Sep 2025 01:51:14 +0000 (09:51 +0800)]
Widen-Mul: Fix typo assignment in build_and_insert_cast [PR122031]
The previous fix for PR122021 introduces a typo that the assignment
to the var itself. This PR would like to fix the typo, and sorry for
my silly mistake.
The below test suites are passed for this patch:
1. The rv64gcv fully regression tests.
2. The x86 bootstrap tests.
3. The x86 fully regression tests.
PR middle-end/122031
gcc/ChangeLog:
* tree-ssa-math-opts.cc (build_and_insert_cast): Fix the typo
of self assignment.
Richard Earnshaw [Mon, 22 Sep 2025 16:29:21 +0000 (17:29 +0100)]
arm: fix target-specific test duplicates for gcc
This patch fixes all the duplicates that I see when testing GCC (C
code). Some of these were real problems with the testsuite where we
were testing the wrong thing because of typos; others are due to
laxity in the tests so that we had a degree of ambiguity in the
results. I've mostly fixed the latter category by converting the
relevant test into a check-function-bodies test.
gcc/testsuite/ChangeLog:
* gcc.target/arm/acle/simd32.c (test_sadd16): Scan for sadd16.
* gcc.target/arm/armv8_2-fp16-neon-1.c (vcgtz, 128-bit): Scan for vcgt.
* gcc.target/arm/armv8_2-fp16-neon-2.c (vcgtz, 128-bit): Scan for vcgt.
(vmul, vmul N): Use check function bodies to avoid ambiguity.
* gcc.target/arm/armv8_2-fp16-scalar-1.c (vrndm): Scan for vrintm.
(vrndn): Scan for vrintn.
(vrndp): Scan for vrintp.
(vrndx): Scan for vrintx.
* gcc.target/arm/asm-flag-1.c: Scan for movlt.
* gcc.target/arm/csneg.c: Convert to check-function-bodies.
* gcc.target/arm/mve/dlstp-compile-asm-2.c (test10): Fix comment that caused test9 scan
to be run twice.
* gcc.target/arm/mve/intrinsics/vgetq_lane_f16.c: Convert to check-function-bodies.
* gcc.target/arm/mve/intrinsics/vgetq_lane_f32.c: Likewise.
* gcc.target/arm/mve/intrinsics/vgetq_lane_s16.c: Likewise.
* gcc.target/arm/mve/intrinsics/vgetq_lane_s32.c: Likewise.
* gcc.target/arm/mve/intrinsics/vgetq_lane_s8.c: Likewise.
* gcc.target/arm/mve/intrinsics/vgetq_lane_u16.c: Likewise.
* gcc.target/arm/mve/intrinsics/vgetq_lane_u32.c: Likewise.
* gcc.target/arm/mve/intrinsics/vgetq_lane_u8.c: Likewise.
Alfie Richards [Thu, 13 Feb 2025 15:59:43 +0000 (15:59 +0000)]
aarch64: testsuite: Add diagnostic tests for Aarch64 FMV.
Add tests covering many FMV errors for Aarch64, including
redeclaration, and mixing target_clones and target_versions.
gcc/testsuite/ChangeLog:
* g++.target/aarch64/mv-and-mvc-error1.C: New test.
* g++.target/aarch64/mv-and-mvc-error2.C: New test.
* g++.target/aarch64/mv-and-mvc-error3.C: New test.
* g++.target/aarch64/mv-error1.C: New test.
* g++.target/aarch64/mv-error2.C: New test.
* g++.target/aarch64/mv-error3.C: New test.
* g++.target/aarch64/mv-error4.C: New test.
* g++.target/aarch64/mv-error5.C: New test.
* g++.target/aarch64/mv-error6.C: New test.
* g++.target/aarch64/mv-error7.C: New test.
* g++.target/aarch64/mv-error8.C: New test.
* g++.target/aarch64/mvc-error1.C: New test.
* g++.target/aarch64/mvc-error2.C: New test.
* g++.target/aarch64/mvc-warning1.C: Modified test.
Alfie Richards [Wed, 6 Aug 2025 11:22:14 +0000 (11:22 +0000)]
fmv: Support mixing of target_clones and target_version.
Add support for a FMV set defined by a combination of target_clones and
target_version definitions.
Additionally, change is_function_default_version to consider a function
declaration annotated with target_clones containing default to be a
default version.
Lastly, add support for the case that a target_clone has all versions filtered
out and therefore the declaration should be removed. This is relevant as now
the default could be defined in a target_version, so a target_clones no longer
necessarily contains the default.
This takes advantage of refactoring done in previous patches changing how
target_clones are expanded and how conflicting decls are handled.
gcc/ChangeLog:
* attribs.cc (is_function_default_version): Update to handle
target_clones.
* cgraph.h (FOR_EACH_FUNCTION_REMOVABLE): New macro.
* multiple_target.cc (expand_target_clones): Update logic to delete
empty target_clones and modify diagnostic.
(ipa_target_clone): Update to use FOR_EACH_FUNCTION_REMOVABLE.
gcc/c-family/ChangeLog:
* c-attribs.cc: Add support for target_version and target_clone mixing.
gcc/testsuite/ChangeLog:
* g++.target/aarch64/mv-and-mvc1.C: New test.
* g++.target/aarch64/mv-and-mvc2.C: New test.
* g++.target/aarch64/mv-and-mvc3.C: New test.
* g++.target/aarch64/mv-and-mvc4.C: New test.
Alfie Richards [Mon, 24 Mar 2025 13:20:01 +0000 (13:20 +0000)]
c++: Refactor FMV frontend conflict and merging logic and hooks.
This change refactors FMV handling in the frontend to allows greater
reasoning about versions in shared code.
This is needed for allowing target_clones and target_versions to be used
together in a function set, as there is then two distinct concerns when
encountering two declarations that previously were conflated:
1. Are these two declarations completely disjoint FMV declarations
(ie. the sets of versions they define have no overlap). If so, they don't
conflict so there is no need to merge and both can be pushed.
2. For two declarations that aren't completely disjoint, are they matching
and therefore mergeable. (ie. two target_clone decls that define the same set
of versions, or an un-annotated declaration, and a target_clones definition
containing the default version). If so, continue to the existing merging logic
to try to merge these and diagnose if it's not possible.
If not, then diagnose the conflicting declarations.
To do this the common_function_versions function has been renamed
disjoint_function_versions (meaning, are the version sets defined by these
two decl's completely distinct from each other).
A new hook called same_function_version is introduces taking two
string_slice's (each representing a single version) and determining if they
define the same version.
A new function, called diagnose_versioned_decls is added, which checks
if two decls (with overlapping version sets) can be merged and diagnose when
they cannot be (only in terms of the attributes, the existing logic is used to
detect other mergeability conflicts like redefinition).
This only effects targets with TARGET_HAS_FMV_TARGET_ATTRIBUTE set to false.
(ie. aarch64 and riscv), the existing logic for i86 and ppc is unchanged.
This also means the same function version hook is only used for aarch64 and
riscv.
gcc/ChangeLog:
* attribs.h (common_function_versions): Removed.
* attribs.cc (common_function_versions): Removed.
* config/aarch64/aarch64.cc (aarch64_common_function_versions): Removed.
(aarch64_same_function_versions): New function to check if two version
strings imply the same version.
(TARGET_OPTION_FUNCTION_VERSIONS): Removed.
(TARGET_OPTION_SAME_FUNCTION_VERSIONS): New macro.
* config/i386/i386.cc (TARGET_OPTION_FUNCTION_VERSIONS): Removed.
* config/rs6000/rs6000.cc (TARGET_OPTION_FUNCTION_VERSIONS): Removed.
* config/riscv/riscv.cc (riscv_same_function_versions): New function
to check if two version strings imply the same version.
(riscv_common_function_versions): Removed.
(TARGET_OPTION_FUNCTION_VERSIONS): Removed.
(TARGET_OPTION_SAME_FUNCTION_VERSIONS): New macro.
* doc/tm.texi: Regenerated.
* target.def: Remove common_version hook and add same_function_version
hook.
* doc/tm.texi.in: Ditto.
* tree.cc (distinct_version_decls): New function.
(mergeable_version_decls): Ditto.
* tree.h (distinct_version_decls): New function.
(mergeable_version_decls): Ditto.
* hooks.h (hook_stringslice_stringslice_unreachable): New function.
* hooks.cc (hook_stringslice_stringslice_unreachable): New function.
gcc/cp/ChangeLog:
* class.cc (resolve_address_of_overloaded_function): Updated to use
dijoint_versions_decls instead of common_function_version hook.
* decl.cc (decls_match): Refacture to use disjoint_version_decls and
to pass through conflicting_version argument.
(maybe_version_functions): Updated to use
disjoint_version_decls instead of common_function_version hook.
(duplicate_decls): Add logic to handle conflicting unmergable decls
and improve diagnostics for conflicting versions.
* decl2.cc (check_classfn): Updated to use
disjoint_version_decls instead of common_function_version hook.
Alfie Richards [Wed, 28 May 2025 15:42:07 +0000 (15:42 +0000)]
c: c++: Add target_[version/clones] to decl diagnostics formatting.
Adds the target_version and target_clones attributes to diagnostic messages
for target_version semantics.
This is because the target_version/target_clones attributes affect the identity
of the decls, so need to be represented in diagnostics for them.
This also requires making maybe_print_whitespace available to c++ code so
we can control if whitespace is needed cosistantly between c and c++
diagnostics.
After this change diagnostics look like:
c:
```
test.c:6:8: error: redefinition of ‘foo [[target_version("sve")]]’
6 | float foo () {return 1;}
| ^~~
test.c:3:8: note: previous definition of ‘foo [[target_version("sve")]]’ with type ‘float(void)’
3 | float foo () {return 2;}
| ^~~
test.c:12:8: error: redefinition of ‘bar [[target_clones("sve")]]’
12 | float bar () {return 1;}
| ^~~
test.c:9:8: note: previous definition of ‘bar [[target_clones("sve")]]’ with type ‘float(void)’
9 | float bar () {return 2;}
| ^~~
```
c++:
```
test.cpp:6:8: error: redefinition of ‘float foo [[target_version("sve")]] ()’
6 | float foo () {return 1;}
| ^~~
test.cpp:3:8: note: ‘float foo [[target_version("sve")]] ()’ previously defined here
3 | float foo () {return 2;}
| ^~~
test.cpp:12:8: error: redefinition of ‘float bar [[target_clones("sve")]] ()’
12 | float bar () {return 1;}
| ^~~
test.cpp:9:8: note: ‘float bar [[target_clones("sve")]] ()’ previously defined here
9 | float bar () {return 2;}
| ^~~
```
This only affects targets which use target_version (aarch64 and riscv).
gcc/c-family/ChangeLog:
* c-pretty-print.cc (pp_c_function_target_version): New function.
(pp_c_function_target_clones): New function.
(pp_c_maybe_whitespace): Move to c-pretty-print.h.
* c-pretty-print.h (pp_c_function_target_version): New function.
(pp_c_function_target_clones): New function.
(pp_c_maybe_whitespace): Moved here from c-pretty-print.cc.
gcc/c/ChangeLog:
* c-objc-common.cc (c_tree_printer): Add printing of target_clone and
target_version in decl diagnostics.
gcc/cp/ChangeLog:
* cxx-pretty-print.h (pp_cxx_function_target_version): New macro.
(pp_cxx_function_target_clones): Ditto.
(pp_cxx_maybe_whitespace): Ditto.
* error.cc (dump_function_decl): Add printing of target_clone and
target_version in decl diagnostics.
Alfie Richards [Thu, 13 Feb 2025 15:30:45 +0000 (15:30 +0000)]
fmv: c++: Change target_version semantics to follow ACLE specification.
This patch changes the semantics of target_version and target_clones attributes
to match the behavior described in the Arm C Language extension.
The changes to behavior are:
- The scope and signature of an FMV function set is now that of the default
version.
- The FMV resolver is now created at the locations of the default version
implementation. Previously this was at the first call to an FMV function.
- When a TU has a single annotated function version, it gets mangled.
- This includes a lone annotated default version.
This only affects targets with TARRGET_HAS_FMV_TARGET_ATTRIBUTE set to false.
Currently that is aarch64 and riscv.
This is achieved by:
- Skipping the existing FMV dispatching code at C++ gimplification and instead
making use of the target_clones dispatching code in multiple_targets.cc.
(This fixes PR target/118313 for aarch64 and riscv).
- Splitting target_clones pass in two, an early and late pass, where the early
pass handles cases where multiple declarations are used to define a version,
and the late pass handling target semantics targets, and cases where a FMV
set is defined by a single target_clones decl.
- Changing the logic in add_candidates and resolve_address of overloaded
function to prevent resolution of any version except a default version.
(thus making the default version determine scope and signature of the
versioned function set).
- Adding logic for dispatching a lone annotated default version in
multiple_targets.cc
- As as annotated default version gets mangled an alias is created from the
dispatched symbol to the default version as no ifunc resolution is required
in this case. (ie. an alias from `_Z3foov` to `_Z3foov.default`)
- Adding logic to `symbol_table::remove_unreachable_nodes` and analyze_functions
that a reference to the default function version also implies a possible
reference to the other versions (so they shouldnt be deleted and do need to
be analyzed).
gcc/ChangeLog:
PR target/118313
* cgraph.cc (delete_function_version): Made public static member of
cgraph_node.
* cgraph.h (delete_function_version): Ditto.
* cgraphunit.cc (analyze_functions): Add logic for target version
dependencies.
* ipa.cc (symbol_table::remove_unreachable_nodes): Ditto.
* multiple_target.cc (create_dispatcher_calls): Change to support
target version semantics.
(ipa_target_clone): Change to dispatch all function sets in
target_version semantics, and to have early and late pass.
(expand_target_clones): Add logic for cases of target_clones with no
defaults.
(is_simple_target_clones_case): New function.
(class pass_target_clone): New parameter for early or late pass.
* config/aarch64/aarch64.cc: (aarch64_get_function_versions_dispatcher):
Refactor with the assumption that the DECL node will be default.
* config/riscv/riscv.cc: (riscv_get_function_versions_dispatcher):
Refactor with the assumption that the DECL node will be default.
* passes.def: Split target_clones pass into early and late version.
gcc/cp/ChangeLog:
PR target/118313
* call.cc (add_candidates): Change to not resolve non-default versions
in target_version semantics.
* class.cc (resolve_address_of_overloaded_function): Ditto.
* cp-gimplify.cc (cp_genericize_r): Change logic to not apply for
target_version semantics.
* decl.cc (maybe_mark_function_versioned): Remove static.
* cp-tree.h (maybe_mark_function_versioned): New function.
* decl2.cc (cplus_decl_attributes ): Change to mark and therefore
mangle all target_version decls in target_version semantics.
* typeck.cc (cp_build_function_call_vec): Add error for calling
unresolvable non-default node in target_version semantics.
gcc/testsuite/ChangeLog:
* g++.target/aarch64/mv-1.C: Change for target_version semantics.
* g++.target/aarch64/mv-symbols2.C: Ditto.
* g++.target/aarch64/mv-symbols3.C: Ditto.
* g++.target/aarch64/mv-symbols4.C: Ditto.
* g++.target/aarch64/mv-symbols5.C: Ditto.
* g++.target/aarch64/mvc-symbols3.C: Ditto.
* g++.target/riscv/mv-symbols2.C: Ditto.
* g++.target/riscv/mv-symbols3.C: Ditto.
* g++.target/riscv/mv-symbols4.C: Ditto.
* g++.target/riscv/mv-symbols5.C: Ditto.
* g++.target/riscv/mvc-symbols3.C: Ditto.
* g++.target/aarch64/mv-symbols10.C: New test.
* g++.target/aarch64/mv-symbols11.C: New test.
* g++.target/aarch64/mv-symbols12.C: New test.
* g++.target/aarch64/mv-symbols13.C: New test.
* g++.target/aarch64/mv-symbols6.C: New test.
* g++.target/aarch64/mv-symbols7.C: New test.
* g++.target/aarch64/mv-symbols8.C: New test.
* g++.target/aarch64/mv-symbols9.C: New test.
Alfie Richards [Mon, 24 Mar 2025 15:04:38 +0000 (15:04 +0000)]
fmv: c++: Add check_target_clone hook for filtering target_clone versions.
This patch introduces the TARGET_CHECK_TARGET_CLONE_VERSION hook
which is used to determine if a target_clones version string parses.
The hook has a flag to enable emitting diagnostics.
This is as specified in the Arm C Language Extension. The purpose of this
is to be able to ignore invalid versions to allow some portability of code
using target_clones attributes.
Currently this is only properly implemented for the Aarch64 backend.
For riscv which is the only other backend which uses target_version
semantics a partial implementation is present, where this hook is used
to check parsing, in which errors will be emitted on a failed parse
rather than warnings. A refactor of the riscv parsing logic would be
required to enable this functionality fully.
This fixes PR 118339 where parse failures could cause ICE in Aarch64.
gcc/ChangeLog:
PR target/118339
* target.def: Add check_target_clone_version hook.
* tree.cc (get_clone_attr_versions): Add filter argument.
(get_clone_versions): Add filter argument.
* tree.h (get_clone_attr_versions): Add filter.
(get_clone_versions): Add filter argument.
* config/aarch64/aarch64.cc (aarch64_check_target_clone_version):
New function
(TARGET_CHECK_TARGET_CLONE_VERSION): New define.
* config/riscv/riscv.cc (riscv_check_target_clone_version):
New function.
(TARGET_CHECK_TARGET_CLONE_VERSION): New define.
* doc/tm.texi: Regenerated.
* doc/tm.texi.in: Add documentation for new hook.
* hooks.h (hook_stringslice_locationtptr_true): New function.
* hooks.cc (hook_stringslice_locationtptr_true): New function.
gcc/c-family/ChangeLog:
* c-attribs.cc (handle_target_clones_attribute): Update to use new hook.
Alfie Richards [Mon, 24 Mar 2025 11:45:32 +0000 (11:45 +0000)]
riscv: Refactor riscv target parsing to take string_slice.
This is a quick refactor of the riscv target processing code
to take a string_slice rather than a decl.
The reason for this is to enable it to work with target_clones
where merging logic requires reasoning about each version string
individually in the front end.
This refactor primarily serves just to get this working. Ideally the
logic here would be further refactored as currently there is no way to
check if a parse fails or not without emitting an error.
This makes things difficult for later patches which intends to emit a
warning and ignoring unrecognised/not parsed target_clone values rather
than erroring which can't currently be achieved with the current riscv
code.
gcc/ChangeLog:
* config/riscv/riscv-protos.h (riscv_process_target_version_str): New function..
* config/riscv/riscv-target-attr.cc (riscv_process_target_attr): Refactor to take
string_slice.
(riscv_process_target_version_str): New function.
* config/riscv/riscv.cc (parse_features_for_version): Refactor to take
string_slice.
(riscv_compare_version_priority): Ditto.
(dispatch_function_versions): Change to pass location.
Alfie Richards [Wed, 12 Feb 2025 14:13:02 +0000 (14:13 +0000)]
x86: fmv: Refactor FMV name mangling.
This patch is an overhaul of how FMV name mangling works. Previously
mangling logic was duplicated in several places across both target
specific and independent code. This patch changes this such that all
mangling is done in targetm.mangle_decl_assembler_name (including for the
dispatched symbol and dispatcher resolver).
Adds the assembler_name member to cgraph_function_version_info to store
the base assembler name of the function set, before FMV mangling.
This allows for the removing of previous hacks, such as where the default
mangled decl's assembler name was unmangled to then remangle all versions
and the resolver and dispatched symbol.
This introduces a change (shown in test changes) for the assembler name of the
dispatched symbol for a x86 versioned function set. Previously it used the
function name mangled twice. This was hard to reproduce without hacks I
wasn't comfortable with. Therefore, the mangling is changed to instead append
".ifunc" which matches clang's behavior.
This change also refactors expand_target_clone using
targetm.mangle_decl_assembler_name for mangling and get_clone_versions.
It is modified such that if the target_clone is in a FMV structure
the ordering is preserved once expanded. This is used later for ACLE semantics
and target_clone/target_version mixing.
gcc/ChangeLog:
* attribs.cc (make_dispatcher_decl): Move duplicated cgraph logic into
this function and change to use targetm.mangle_decl_assembler_name for
mangling.
* cgraph.cc (cgraph_node::insert_new_function_version): Record
assembler_name.
* cgraph.h (struct cgraph_function_version_info): Add assembler_name.
(struct cgraph_node): Add dispatcher_resolver_function and
is_target_clone.
* config/aarch64/aarch64.cc (aarch64_parse_fmv_features): Change to
support string_slice.
(aarch64_process_target_version_attr): Ditto.
(get_feature_mask_for_version): Ditto.
(aarch64_mangle_decl_assembler_name): Add logic for mangling dispatched
symbol and resolver.
(get_suffixed_assembler_name): Removed.
(make_resolver_func): Refactor to use
aarch64_mangle_decl_assembler_name for mangling.
(aarch64_generate_version_dispatcher_body): Remove remangling.
(aarch64_get_function_versions_dispatcher): Refactor to remove
duplicated cgraph logic.
* config/i386/i386-features.cc
(ix86_mangle_function_version_assembler_name): Refactor to use
clone_identifier and to mangle default.
(ix86_mangle_decl_assembler_name): Add logic for mangling dispatched
symbol and resolver.
(ix86_get_function_versions_dispatcher): Remove duplicated cgraph
logic.
(make_resolver_func): Refactor to use ix86_mangle_decl_assembler_name
for mangling.
* config/riscv/riscv.cc (riscv_mangle_decl_assembler_name): Add logic
for FMV mangling.
(get_suffixed_assembler_name): Removed.
(make_resolver_func): Refactor to use riscv_mangle_decl_assembler_name
for mangling.
(riscv_generate_version_dispatcher_body): Remove unnecessary remangling.
(riscv_get_function_versions_dispatcher): Remove duplicated cgraph
logic.
* config/rs6000/rs6000.cc (rs6000_mangle_decl_assembler_name): New
function.
(rs6000_get_function_versions_dispatcher): Remove duplicated cgraph
logic.
(make_resolver_func): Refactor to use rs6000_mangle_decl_assembler_name
for mangling.
(rs6000_mangle_function_version_assembler_name): New function.
* multiple_target.cc (create_dispatcher_calls): Remove mangling code.
(get_attr_str): Removed.
(separate_attrs): Ditto.
(is_valid_asm_symbol): Removed.
(create_new_asm_name): Ditto.
(expand_target_clones): Refactor to use
targetm.mangle_decl_assembler_name for mangling and be more general.
* tree.cc (get_target_clone_attr_len): Removed.
* tree.h (get_target_clone_attr_len): Removed.
gcc/cp/ChangeLog:
* decl.cc (maybe_mark_function_versioned): Change to insert function version
and therefore record assembler name.
Alfie Richards [Fri, 31 Jan 2025 11:47:57 +0000 (11:47 +0000)]
cgraph: Add clone_identifier function.
This is similar to clone_function_name and its siblings but takes an
identifier tree node rather than a function declaration.
This is to be used in conjunction with the identifier node stored in
cgraph_function_version_info::assembler_name to mangle FMV functions in
later patches.
gcc/ChangeLog:
* cgraph.h (clone_identifier): New function.
* cgraphclones.cc (clone_identifier): New function.
(clone_function_name): Refactored to use clone_identifier.
(is_valid_asm_symbol): New helper function.
Jonathan Wakely [Fri, 19 Sep 2025 11:11:26 +0000 (12:11 +0100)]
libstdc++: Remove unwanted PACKAGE macros from c++config.h [PR79147]
Autoconf insists on adding macros like PACKAGE_NAME and
PACKAGE_BUG_TARNAME to config.h but those are useless for libstdc++
because it's not a complete package, just a sub-directory of gcc, and we
never use any of those strings in our sources.
Since we include the generated config.h in our installed c++config.h
header, those useless macros are exposed to users. We do transform them
to use the reserved _GLIBCXX_ prefix, but they're still just useless
noise in the installed header.
I don't know any way to get autoconf to not add them to config.h but
this change comments them out so they're not defined when users include
our headers.
Although not really important now that the macro isn't being defined,
this change also avoids the double substitution for PACKAGE_VERSION
which was resulting in _GLIBCXX_PACKAGE__GLIBCXX_VERSION.
libstdc++-v3/ChangeLog:
PR libstdc++/79147
* include/Makefile.am (c++config.h): Adjust sed command to
comment out all PACKAGE_XXX macros and to avoid adjusting
PACKAGE_VERSION twice.
* include/Makefile.in: Regenerate.
Tomasz Kamiński [Tue, 23 Sep 2025 05:51:18 +0000 (07:51 +0200)]
libstdc++: Remove leftover __formatter_chrono base classes.
This patch removes the __formatter_chrono<_CharT> base class from the
formatters for utc_time, gps_time, and tai_time. These formatters
are using the __formatter_duration<_CharT> member only.
Since it regressed SPEC performance(Refer to PR121994), I guess
it's related to register pressure and can be tuned by adjusting
reduc_lat_mult_thr. I don't have Zen2 machine, so for simplity, I'll
just disable unroll in vectorizer for Zen2.
Also adjust count number for {AVX256,AVX512}_SPLIT_REGS.
gcc/ChangeLog:
PR target/121994
* config/i386/x86-tune-costs.h (znver2_cost): Set
vect_unroll_limit to 1.
(znver1_cost): Ditto.
* config/i386/i386.cc (ix86_vector_costs::add_stmt_cost):
Adjust count number for {AVX256,AVX512}_SPLIT_REGS.
Peter Bergner [Mon, 22 Sep 2025 17:17:26 +0000 (12:17 -0500)]
RISC-V: Add missing define_insn_reservation to tt-ascalon-d8.md [PR121982]
The tt-ascalon-d8's pipeline description has reservations for 16-bit, 32-bit
and 64-bit vector integer divides, but was missing a reservation for 8-bit
vector integer divides, leading to an ICE. Add the missing reservation.
2025-09-22 Peter Bergner <bergner@tenstorrent.com>
gcc/
PR target/121982
* config/riscv/tt-ascalon-d8.md (tt_ascalon_d8_vec_idiv_byte): New
define_insn_reservation.
gcc/testsuite/
PR target/121982
* gcc.target/riscv/pr121982.c: New test.
Signed-off-by: Peter Bergner <bergner@tenstorrent.com>
c++: Fix canonical type for lambda pack captures [PR122015]
comp_template_parms_position uses whether a TEMPLATE_TYPE_PARM is a pack
to determine equivalency. This in turn affects whether
canonical_type_parameter finds a pre-existing auto type as equivalent.
When generating the 'auto...' type for a lambda pack capture, we only
mark it as a pack after generating the node (and calculating its
canonical); this means that later when comparing a version streamed in
from a module we think that two equivalent types have different
TYPE_CANONICAL, because the latter already had
TEMPLATE_PARM_PARAMETER_PACK set before calculating its canonical.
This patch fixes this by using a new 'make_auto_pack' function to ensure
that packness is set before the canonical is looked up.
PR c++/122015
gcc/cp/ChangeLog:
* cp-tree.h (make_auto_pack): Declare.
* lambda.cc (lambda_capture_field_type): Use make_auto_pack to
ensure TYPE_CANONICAL is set correctly.
* pt.cc (make_auto_pack): New function.
gcc/testsuite/ChangeLog:
* g++.dg/modules/lambda-11.h: New test.
* g++.dg/modules/lambda-11_a.H: New test.
* g++.dg/modules/lambda-11_b.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Patrick Palka <ppalka@redhat.com>
Jonathan Wakely [Fri, 19 Sep 2025 16:28:51 +0000 (17:28 +0100)]
top-level: Add .editorconfig file
This config file sets default formatting behaviour for a large number
of common editors, see https://editorconfig.org
It also ensures that https://forge.sourceware.org formats GCC code
correctly, because it defaults to tab_width=4 but will respect a
.editorconfig file if present in the repo.
Andrew Pinski [Fri, 19 Sep 2025 21:37:04 +0000 (14:37 -0700)]
fab/gimple-fold: Move __builtin_constant_p folding to gimple-fold [PR121762]
This is the first patch in removing fold_all_builtins pass.
We want to fold __builtin_constant_p into 0 if we know the argument can't be
a constant. So currently that is done in fab pass (though ranger handles it now too).
Instead of having fab do it we can check PROP_last_full_fold if set and set it
to 0 instead.
Note for -Og, fab was the only place which did this conversion, so we need to
set PROP_last_full_fold for it; later on fab will be removed and isel will do
it instead but that is for another day.
Also instead of going through fold_call_stmt to call fold_builtin_constant_p,
fold_builtin_constant_p is called directly from gimple_fold_builtin_constant_p.
This should speed up the compiling slight :).
Note fab was originally added to do this transformation during the development
of the ssa branch.
Bootstrapped and tested on x86_64-linux-gnu.
PR tree-optimization/121762
gcc/ChangeLog:
* builtins.cc (fold_builtin_constant_p): Make non-static.
* builtins.h (fold_builtin_constant_p): New declaration.
* gimple-fold.cc (gimple_fold_builtin_constant_p): New function.
(gimple_fold_builtin): Call gimple_fold_builtin_constant_p
for BUILT_IN_CONSTANT_P.
* tree-ssa-ccp.cc (pass_fold_builtins::execute): Set PROP_last_full_fold
on curr_properties. Remove handling of BUILT_IN_CONSTANT_P.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Tomasz Kamiński [Thu, 11 Sep 2025 09:11:06 +0000 (11:11 +0200)]
libstdc++: Rework handling of ISO week calendar and week index formatting.
The handling of ISO week-calendar year specifiers (%G, %g) and ISO week
number (%V) was merged into a single _M_g_G_V function, as the latter
requires ISO year value, computed by the former.
The values for %U and %W, which are based on the number of days since the
first Sunday and Monday of the year respectively, are now expressed as an
offset from the existing _M_day_of_year field. This reduces redundant
computation. The required flags were also updated to only need _DayOfYear
and _Weekday.
The _M_g_G_V function uses _M_day_of_year to compute __idoy, the day of the
year for the nearest Thursday. This value is used to determine if the ISO
year is the previous year (__idoy <= 0), the current year (__idoy <= 365/366),
next year (__idoy <= 730), or later year. This avoids an expensive conversion
from local_days to year_month_day in most cases. If the ISO calendar year
is current year, the __idoy value is reused for weekday index computation.
libstdc++-v3/ChangeLog:
* include/bits/chrono_io.h(__formatter_chrono::_M_parse): Update
needed flags for %g, %G, %V, %U, %W.
(__formatter_chrono::_M_format_to): Change how %V is handled.
(__formatter_chrono::_M_g_G): Merged into _M_g_G_V.
(__formatter_chrono::_M_g_G_V): Reworked from _M_g_G.
(__formatter_chrono::_M_U_V_W): Changed into _M_U_V.
(__formatter_chrono::_M_U_W): Reworked implementation.
* testsuite/std/time/year_month_day/io.cc: New tests.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
Tomasz Kamiński [Mon, 22 Sep 2025 11:31:17 +0000 (13:31 +0200)]
libstdc++: Move start_lifetime_as functions to bits/stl_construct.h [PR106658]
This allows inplace_vector to use these functions without including the entire
<memory> header.
Preprocessor checks are changed to use __glibcxx macros, so new functions are
available outside memory header, that exports __cpp_lib macros.
PR libstdc++/106658
libstdc++-v3/ChangeLog:
* include/bits/stl_construct.h (std::start_lifetime_as_array)
(std::start_lifetime_as): Moved from std/memory, with update
to guard macros.
* include/std/memory (std::start_lifetime_as_array)
(std::start_lifetime_as): Moved to bits/stl_construct.h.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
To:
int32_t _5 = (int32_t)_3; // zero-extend 16 => 32
That will have a problem for sign-extend, the highest bits may be all 1s
but will be loss after convert to zero-extend. Thus, there will be more
cases if the convert has different types. Case 1 as above and Case 2,
3, and 4 as following.
Then, we can see, there will be mis-compile if and only if there is
a cast from small to big size with sign extend. Thus, restrict the
check and stop prop if there is sign extend cast.
The below test suites are passed for this patch:
1. The rv64gcv fully regression tests.
2. The x86 bootstrap tests.
3. The x86 fully regression tests.
PR middle-end/122021
gcc/ChangeLog:
* tree-ssa-math-opts.cc (build_and_insert_cast): Add sign-extend
check before prop.
Richard Biener [Mon, 22 Sep 2025 08:14:31 +0000 (10:14 +0200)]
tree-optimization/122016 - PRE insertion breaks abnormal coalescing
When PRE asks VN to simplify a NARY but not insert, that bypasses
the abnormal guard in maybe_push_res_to_seq and we blindly accept
new uses of abnormals. The following fixes this.
PR tree-optimization/122016
* tree-ssa-sccvn.cc (vn_nary_simplify): Do not use the
simplified expression when it references abnormals.
Eric Botcazou [Mon, 22 Sep 2025 09:08:34 +0000 (11:08 +0200)]
Ada: Fix internal error on use clause present in generic formal part
This is a regression present on the mainline and 15 branch: the compiler
aborts on a use clause present in the formal part of a generic unit because
of an oversight in the new inference code for generic actual parameters.
The fix also adds a missing test to Analyze_Dimension_Array_Aggregate.
gcc/ada/
PR ada/121968
* sem_ch12.adb (Associations.Find_Assoc): Add guard for clauses.
* sem_dim.adb (Analyze_Dimension_Array_Aggregate): Add test for
N_Iterated_Component_Association nodes.
Dimitar Dimitrov [Sat, 19 Oct 2024 20:40:35 +0000 (23:40 +0300)]
pru: Reject bit-fields for TI ABI
TI ABI has non-conventional requirements for bit-fields, which cannot
be implemented with the current target hooks in GCC.
Target hooks are focused on packing and alignment. But PRU uses packed
structs by default, and has 1 byte alignment for all types. As an
example, this makes it difficult to implement the TI ABI requirement
for the following struct to be sized to 4 bytes, per the bit-field type:
struct S { int i : 1; }
Instead of introducing new target hooks and making risky changes to
common GCC code, simply declare bit-fields as not supported in TI ABI
mode.
PRU is a baremetal target. It has neither support for interrupts nor an
RTOS. Hence ABI compatibility is not that critical. I have not seen
any projects which rely on ABI compatibility in order to mix object
files from GCC and the TI proprietary compiler.
The target-specific pass to scan for TI ABI compatibility was rewritten
as an IPA pass. This allowed scanning not only of function bodies, but
also global variable declarations. Diagnostic locations should now be
more accurate. Thus some test cases had to be adjusted.
PR target/116205
gcc/ChangeLog:
* config/pru/pru-passes.cc (class pass_pru_tiabi_check): Make
this an IPA pass.
(chkp_type_has_function_pointer): Remove.
(check_type_tiabi_compatibility): New function.
(chk_function_decl): Rename.
(check_function_decl): Simplify.
(check_op_callback): Rework to use
check_type_tiabi_compatibility.
(pass_pru_tiabi_check::execute): Rework to scan all symbols and
gimple contents of all defined functions.
* config/pru/pru-passes.def (INSERT_PASS_AFTER): Move after
pass_ipa_auto_profile_offline.
* config/pru/pru-protos.h (make_pru_tiabi_check): New
declaration to mark as IPA pass.
(make_pru_minrt_check): Specify it is making a gimple pass.
* doc/invoke.texi: Document that bit-fields are now rejected for
TI ABI.
gcc/testsuite/ChangeLog:
* gcc.target/pru/mabi-ti-1.c: Adjust diagnostic location.
* gcc.target/pru/mabi-ti-2.c: Ditto.
* gcc.target/pru/mabi-ti-3.c: Ditto.
* gcc.target/pru/mabi-ti-5.c: Ditto.
* gcc.target/pru/mabi-ti-6.c: Ditto.
* gcc.target/pru/mabi-ti-7.c: Adjust diagnostic locations and
add global variables for checking.
* gcc.target/pru/mabi-ti-11.c: New test.
* gcc.target/pru/mabi-ti-12.c: New test.
* gcc.target/pru/mabi-ti-8.c: New test.
* gcc.target/pru/mabi-ti-9.c: New test.
Andrew Pinski [Fri, 19 Sep 2025 19:23:57 +0000 (12:23 -0700)]
fab: Remove forced label check from optimize_unreachable
Since optimize_unreachable does not directly remove the bb, we can still remove
the condition that goes to a block containing a forced label. This is a small cleanup
from the original patch which added optimize_unreachable.
The review of the original patch missed that the bb was not being removed by the pass
but later on by cleanupcfg; https://gcc.gnu.org/pipermail/gcc-patches/2012-July/343239.html.
Which is why this is allowed to be done.
I added another testcase to check that the `if` is removed too.
Bootstrapped and tested on x86_64-linux-gnu.
gcc/ChangeLog:
* tree-ssa-ccp.cc (optimize_unreachable): Don't check for forced labels.
gcc/testsuite/ChangeLog:
* gcc.dg/builtin-unreachable-7.c: New test.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Jan Hubicka [Sun, 21 Sep 2025 17:54:51 +0000 (19:54 +0200)]
Update calls_comdat_local in cgraph_node::create_version_clone
This patches fixes ICE when ipa-split is run from ipa-profile. In normal
computation we recompute the flag elsewhere, but it is supposed to be kept
up-to-date by passes possibly modifying it.
Jan Hubicka [Sun, 21 Sep 2025 17:51:57 +0000 (19:51 +0200)]
One extra special case for AFDO0
This patch makes inliner and ipa-cp to consider optimization interesting even
in scenarios where aufdo countis 0, but scaleis high enough to make optimization
worthwhile.
gcc/ChangeLog:
* cgraph.cc (cgraph_edge::maybe_hot_p): For AFDO profiles force
count to be non-zero.
Jan Hubicka [Sun, 21 Sep 2025 14:52:18 +0000 (16:52 +0200)]
Increase auto-fdo profile scaling
Increase scaling factor for auto-fdo profiles. I origianlly used
n_bits/2 which is also used by local guessing algorithm. For local guessing
algorithm the main factor is to prevent inliner scaling up the profile till
overflow.
With sane IPA profile large scaling up should essentially never happen. Inliner and
ipa-cp only duplicates code and should only scale down. ipa-icf and tail merging merges
code but not very large number of code paths.
In practice scaling up still happens when profile is inconsisent, so this use
n_bits-10, which is 50 currently. The main advantage of this is to reduce chances
things drop to 0 and we hit the various special cases for 0 auto-FDO profile.
gcc/ChangeLog:
* auto-profile.cc (autofdo_source_profile::read): Scale profile up to
profile_count::n_bits - 10.
Thomas Koenig [Sun, 21 Sep 2025 12:46:35 +0000 (14:46 +0200)]
Fix test case and add errors for when -fexternal-blas64 makse no sense.
-fexternal-blas64 requires front-end optimization to be turned on.
This patch issues a hard error if this is not the case, and also issues
an error on not-64 bit systems, where specifying it would make no sense,
and lead to errors. Finally, this makes sure that the test is only performed
on 64-bit systems.
I tried creating test cases for the hard errors for the wrong option
combinations, but didn't succeed; see the thread on the gcc mailing
list on that topic. These can always be added afterwards.
gcc/fortran/ChangeLog:
PR fortran/121161
* invoke.texi: Mention that -ffrontend-optimize is required
for -fexternal-blas64.
* options.cc (gfc_post_options): Fatal error if -fexternal-blas64
is specified without -ffrontend-optimize.
* trans-types.cc (gfc_init_kinds): Fatal error if -fexternal-blas64
is specified on a system which does not have 64-bit ptrdiff_t.
Jan Hubicka [Sun, 21 Sep 2025 10:28:17 +0000 (12:28 +0200)]
Make inliner more careful about profile inconsistencies
This patch makes inliner to not subtract inlined function profile from the
offline copy in cases where profile is clearly not consistent. As a result we
do not drop the offline version to likely never executed profile. This helps
in cases the profile got lost, i.e. by comdat function merging and also for
auto-fdo.
gcc/ChangeLog:
* ipa-inline-transform.cc (clone_inlined_nodes): Add KEEP_OFFLINE_COPY
parameter.
(inline_call): Sanity check profile and if it is clearly broken do
not subtract profile from original function.
* ipa-inline.cc (recursive_inlining): Update.
* ipa-inline.h (clone_inlined_nodes): Update.
Harald Anlauf [Sat, 20 Sep 2025 20:20:25 +0000 (22:20 +0200)]
Fortran: fix issues with rank-2 deferred-length character arrays [PR108581]
PR fortran/108581
gcc/fortran/ChangeLog:
* trans-array.cc (gfc_conv_expr_descriptor): Take the dynamic
string length into account when deriving the dataptr offset for
a deferred-length character array.
gcc/testsuite/ChangeLog:
* gfortran.dg/deferred_character_39.f90: New test.
Patrick Palka [Sat, 20 Sep 2025 14:45:22 +0000 (10:45 -0400)]
c++: find_template_parameters and NTTPs [PR121981]
Here the normal form of the two immediately-declared D<<placeholder>, V>
constraints is the same, so we rightfully share the normal form between
them. We first compute the normal form from the context of auto deduction
for W in which case the placeholder has level 2 where the set of
in-scope template parameters has depth 2 (a dummy level is added from
normalize_placeholder_type_constraints).
Naturally the atomic constraint only depends on the template parameter
V of depth 1 index 0. The depth 2 of current_template_parms however
means that find_template_parameters when it sees V within the atomic
constraint will recurse into its TREE_TYPE, an auto of level 2, and mark
the atomic constraint as also depending on the template parameter of
depth 2 index 0, which is clearly wrong. Later during constraint
checking for B we ICE within the satisfaction cache since we lack two
levels of template arguments supposedly needed by the cached atomic
constraint.
I think when find_template_parameters sees an NTTP, it doesn't need to
walk its TREE_TYPE because NTTP substitution is done obliviously with
respect to its type -- only the corresponding NTTP argument matters,
not other template arguments possibly used within its type. This is
most clearly true for (unconstrained) auto NTTPs as in the testcase, but
also true for other NTTPs. Doing so fixes the testcase because we no
longer record any depth 2 when walking V within the atomic constraint.
PR c++/121981
gcc/cp/ChangeLog:
* pt.cc (any_template_parm_r) <case TEMPLATE_TYPE_PARM>:
Don't walk TREE_TYPE.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/concepts-placeholder15.C: New test.
Paul Thomas [Sat, 20 Sep 2025 13:25:47 +0000 (14:25 +0100)]
Fortran: Fix regtest failure in pdt_48.f03. [PR83746]
2025-09-20 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/83746
* trans-decl.cc (gfc_trans_deferred_vars): If a procedure with
an non-allocatable, non-pointer explicit PDT result has no
default initializer, the parameterized components should be
allocated.
Jan Hubicka [Sat, 20 Sep 2025 13:11:50 +0000 (15:11 +0200)]
Add --param max-devirt-targets
Currently we speculatively devirtualize using static analysis (with no profile
feedback) only when there is one possible target found. With profile feedback
we support multiple targets which seems useful in some scenarios.
This patch adds --param max-devirt-targets which enables devirtualization up to
given number of targets and defaults it to 3. This happens i.e. in spec2017
omnetpp, though the devirtualizaton is later undone by inliner since it is not
considered useful. The patch still seems to improve omnetpp by 2% in some
setups.
Other advantage of the patch is that the multi-target devirtualizatoin gets
tested without profile feedback so we more likely notice problems with it.
Joseph Myers [Sat, 20 Sep 2025 00:24:26 +0000 (00:24 +0000)]
c: Implement C2y N3481 constraint against lvalue conversion with incomplete type
C2y replaces undefined behavior for lvalue conversion of an lvalue
with incomplete, non-array type with a constraint violation.
Implement this in GCC, which means disallowing lvalue conversion of
qualified or atomic void for C2y. (Unqualified, non-atomic void is
excluded from the definition of "lvalue".)
I'm not convinced that the resolution of C90 DR#106 (which said that
certain cases with qualified void were valid) was really justified
even based on the wording of C90; nevertheless, this patch takes the
conservative approach of only disallowing qualified void here for C2y.
The test for this change showed that attempting to access an _Atomic
void object produced an ICE-after-error attempting the atomic load
logic for such a type. require_complete_type returning
error_mark_node prevents this ICE from occurring any more in C2y mode;
to avoid it in older modes, a check of COMPLETE_TYPE_P is added to
really_atomic_lvalue. I didn't find any existing bug report in
Bugzilla for this issue.
Bootstrapped with no regressions for x86_64-pc-linux-gnu.
gcc/c/
* c-typeck.cc (really_atomic_lvalue): Return false for incomplete
types.
(convert_lvalue_to_rvalue): Call require_complete_type for
qualified void for C2y.
gcc/testsuite/
* gcc.dg/c11-atomic-6.c, gcc.dg/c23-incomplete-1.c,
gcc.dg/c2y-incomplete-3.c: New tests.
Add non-type template parameter function-object/-pointer argument
versions of bind_front, bind_back, and not_fn.
This introduces a new internal type _Bind_fn_t to carry the
template-argument function object when no arguments are bound,
used in both bind_front and bind_back. Otherwise they return
a lambda object that has captured the arguments.
There is no need to change libstdc++-v3/src/c++23/std.cc.in
because existing exports: "using std::bind_front;" etc. export
the new overloads.
libstdc++-v3/ChangeLog:
PR libstdc++/119744
* include/bits/version.def: Redefine __cpp_lib_bind_front etc.
* include/bits/version.h: Ditto.
* include/std/functional: Add new bind_front etc. overloads
* testsuite/20_util/function_objects/bind_back/1.cc:
Check plumbing better
* testsuite/20_util/function_objects/bind_back/nttp.cc: New test.
* testsuite/20_util/function_objects/bind_back/nttp_neg.cc: New test.
* testsuite/20_util/function_objects/bind_front/1.cc:
Check plumbing better
* testsuite/20_util/function_objects/bind_front/nttp.cc: New test.
* testsuite/20_util/function_objects/bind_front/nttp_neg.cc: New test.
* testsuite/20_util/function_objects/not_fn/nttp.cc: New test.
* testsuite/20_util/function_objects/not_fn/nttp_neg.cc: New test.
* testsuite/20_util/headers/functional/synopsis.cc: New decls.
[ira] avoid resetting ira_reg_equiv for function invariants
An aarch64 toolchain built with --enable-default-pie fails
gcc.target/aarch64/sme/nonlocal_goto_[123].c because the register
allocator ends up resetting equivalences, so it concludes it needs to
preserve a rematerializable function invariant across a call instead
of rematerializing it.
Restore the find_reg_equiv_invariant_const logic that was in place
before commit 55a2c3226a3e90a6d65f19710bab1ac377054234 rewrote it and
added a (spurious?) requirement for non-function-invariants to retain
an equivalence when other PIC-related conditions didn't apply. That
requirement seems either reversed or unnecessary.
for gcc/ChangeLog
* ira.cc (setup_reg_equiv): Retain function invariant
equivalences.
Andrew Pinski [Fri, 19 Sep 2025 06:06:19 +0000 (23:06 -0700)]
forwprop: change optimize_aggr_zeroprop and optimize_agr_copyprop to take stmt instead of gsi
As mentioned, optimize_aggr_zeroprop and optimize_agr_copyprop don't change the stmt
so they should take stmt instead of the iterator.
Pushed as obvious after bootstrap/test on x86_64-linux-gnu.
gcc/ChangeLog:
* tree-ssa-forwprop.cc (optimize_aggr_zeroprop): Take gimple*
instead of iterator.
(optimize_agr_copyprop): Likewise.
(simplify_builtin_call): Update call to optimize_aggr_zeroprop.
(pass_forwprop::execute): Update calls to optimize_aggr_zeroprop
and optimize_agr_copyprop.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Andrew Pinski [Tue, 16 Sep 2025 22:42:54 +0000 (15:42 -0700)]
forwprop: Don't loop on the stmt when optimize_aggr_zeroprop or optimize_agr_copyprop return true
Since now optimize_aggr_zeroprop and optimize_agr_copyprop work by forward walk to prop
the zero/aggregate and does not change the statement at hand, there is no reason to
repeat the loop if they do anything. This will prevent problems like PR 121962 from
happening again as we will never loop.
Bootstrapped and tested on x86_64-linux-gnu.
gcc/ChangeLog:
* tree-ssa-forwprop.cc (optimize_aggr_zeroprop_1): Change return type
to void.
(optimize_aggr_zeroprop): Likewise.
(optimize_agr_copyprop_1): Likewise.
(optimize_agr_copyprop_arg): Likewise.
(optimize_agr_copyprop): Likewise.
(simplify_builtin_call): Handle update of the return type
of optimize_aggr_zeroprop.
(pass_forwprop::execute): Likewise and optimize_agr_copyprop.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Atomic support enhanced to fix existing atomic_compare_and_swapsi pattern
to handle side effects; new patterns atomic_fetch_op and atomic_test_and_set
added. As MicroBlaze has no QImode test/set instruction, use shift magic
to implement atomic_test_and_set.
Jan Hubicka [Fri, 19 Sep 2025 17:09:00 +0000 (19:09 +0200)]
Improve costing of speculative calls in ipa-fnsummary
This patch implements logic to estimate_edge_devirt_benefit to not account call
statement sizes of speculative calls in case we know the call we be turned to
direct call by inlining. I also noticed that estimate_edge_size_and_time fails
to accont code size savings by devirtualization when not asked to compute hints
(this is quite rare; only early inliner and inlining functions called once is
affected) and compensated for that in estimate_calls_size_and_time
gcc/ChangeLog:
* ipa-fnsummary.cc (estimate_edge_devirt_benefit): Handle speculative
edges correctly.
(estimate_edge_size_and_time): Even when not collecting hints,
devirtualization affects function size.
(estimate_calls_size_and_time): Do not use tables when devirtualization
is possible.
Jan Hubicka [Fri, 19 Sep 2025 17:05:34 +0000 (19:05 +0200)]
Improve ipa-cp devirtualization costing
This patch fixed devirtualization time benefit of ipa-cp which should be scaled
by edge frequency but it is not. The cost model is still not correct for speculative
calls, since it does not take into account the fact that code size will shrink if
speculation is removed.
I also made cgraph_edge::make_direct to not ICE when there are multiple speculations
to same target. This can happen in combination of devirtualization and ICF in some
rare cases.
gcc/ChangeLog:
* cgraph.cc (cgraph_edge::make_direct): Do not ICE when there are
multiple speculations to comptaible targets
(cgraph_edge::combined_sreal_frequency): New member function.
* cgraph.h (cgraph_edge::combined_sreal_frequency): Declare.
* ipa-cp.cc (devirtualization_time_bonus): Return sreal; consider
profile.
(estimate_local_effects): Likewise.
Paul Thomas [Fri, 19 Sep 2025 16:48:45 +0000 (17:48 +0100)]
Fortran: Intrinsic functions in PDT specification exprs. [PR83746]
2025-09-19 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/83746
* trans-array.cc (structure_alloc_comps): Add the pre and post
blocks to 'fnblock' for all the evaluations of parameterized
expressions in PDT component allocatation.
gcc/testsuite/
PR fortran/83746
* gfortran.dg/pdt_48.f03: New test.
Gaius Mulley [Fri, 19 Sep 2025 16:26:18 +0000 (17:26 +0100)]
PR modula2/121856: New wideset implementation
The new wideset implementation uses an ARRAY OF BYTE (internally) to
represent large sets. This replaces the huge struct of anonymous
fields created by the old implementation and results in quicker
declaration times for large set types.
gcc/ChangeLog:
PR modula2/121856
* doc/gm2.texi (Compiler options): New item -fwideset.
gcc/m2/ChangeLog:
PR modula2/121856
* Make-lang.in (GM2-LIBS-BOOT-DEFS): Add M2Diagnostic.def.
Add Selective.def.
(GM2-LIBS-BOOT-MODS): Add M2Diagnostic.mod.
(GM2-LIBS-BOOT-C): Add Selective.c.
(GM2-LIBS-DEFS): Add Selective.def.
(GM2-LIBS-MODS): Add M2Diagnostic.mod.
(MC-LIB-MODS): Add M2Diagnostic.mod.
(m2/gm2-libs-boot/Selective.o): New rule.
(BUILD-PGE-O): Add m2/pge-boot/GM2Diagnostic.o.
Add m2/pge-boot/GM2Diagnostic.o.
Add m2/pge-boot/GStringConvert.o.
Add m2/pge-boot/Gdtoa.o.
Add m2/pge-boot/Gldtoa.o.
* Make-maintainer.in (PPG-LIB-DEFS): Add M2Diagnostic.def.
Add StringConvert.def.
(PPG-LIB-MODS): Add M2Diagnostic.mod.
Add StringConvert.mod.
(PGE-DEF): Add M2Diagnostic.def.
(PGE-DEPS): Add GM2Diagnostic.cc.
Add GM2Diagnostic.h.
* gm2-compiler/FifoQueue.def (PutSetIntoFifoQueue): New
procedure.
(GetSetFromFifoQueue): New procedure function.
* gm2-compiler/FifoQueue.mod (PutSetIntoFifoQueue): New
procedure.
(GetSetFromFifoQueue): New procedure function.
* gm2-compiler/M2ALU.def (KillValue): New procedure.
(PushSetTree): Rename parameter t to value.
(ConstructSetConstant): Rewrite comment.
* gm2-compiler/M2ALU.mod: Rewrite to use the new set type
and introduce memory diagnostics.
* gm2-compiler/M2Base.mod (InitBaseProcedures): Lookup M2WIDESET.
* gm2-compiler/M2CaseList.mod (CheckCaseBoundsResolved): Change
format specifier to allow the preceeding indefinite article to
have a n concatenated providing the following string substitute
begins with a vowel.
(checkTypes): Ditto.
* gm2-compiler/M2Check.mod (checkGenericUnboundedTyped): New
procedure function.
* gm2-compiler/M2Code.mod (OptimizationAnalysis): Replace with ...
(ResourceAnalysis): ... this.
* gm2-compiler/M2Comp.mod (PopulateResource): New procedure.
(compile): Call PopulateResource.
Call M2Diagnostic.Generate.
* gm2-compiler/M2GCCDeclare.mod: Rewrite for new set type.
* gm2-compiler/M2GenGCC.mod: Rewrite implementation for
becomes, incl, excl, and, or, not, xor for the new set type.
* gm2-compiler/M2MetaError.def: Extend comment documenting
the v format specifier.
* gm2-compiler/M2MetaError.mod (errorBlock): New field vowel.
(initErrorBlock): Initialize field vowel.
Reformat comments.
(pop): Call checkVowel.
(checkVowel): New procedure.
(isVowel): New procedure function.
(symDesc): Remove indefinite article.
(op): Set vowel field in case clause.
* gm2-compiler/M2Options.def (OptimizeSets): New global.
(TimeReport): Ditto.
(MemReport): Ditto.
(SetMemReport): New procedure.
(SetTimeReport): Ditto.
(SetWideset): Ditto.
(GetWideset): New procedure function.
* gm2-compiler/M2Options.mod (SetOptimizing): Assign
OptimizeSets depending upon the optimization level.
(SetMemReport): New procedure.
(SetTimeReport): Ditto.
(SetWideset): Ditto.
(GetWideset): New procedure function.
(OptimizeSets): Initialize to FALSE.
(TimeReport): Ditto.
(MemReport): Ditto.
* gm2-compiler/M2Quads.mod (M2Diagnostic): Import.
(QuadsMemDiag): New global variable.
(NewQuad): Bump QuadsMemDiag whenever a quad is allocated.
(BuildAssignmentBoolean): New procedure.
(doBuildAssignment): Ditto.
Add v to the format specifier.
(CheckCompatibleWithBecomes): Add v to the format specifier.
(CheckProcTypeAndProcedure): Ditto.
(BuildAddAdrFunction): Ditto.
(BuildSubAdrFunction): Ditto.
(BuildDifAdrFunction): Ditto.
(BuildDesignatorArrayStaticDynamic): Ditto.
(BuildDesignatorPointer): Ditto.
(CheckVariableOrConstantOrProcedure): Ditto.
(Init): Initialize QuadsMemDiag.
* gm2-compiler/M2Range.mod (CodeTypeAssign): Add v to the
format specifier.
* gm2-compiler/M2Scaffold.mod (DeclareScaffoldFunctions):
Generate more precise warning note.
* gm2-compiler/M2SymInit.mod (PrintSymInit): Add record
field warning.
* gm2-compiler/M2System.mod
(IsPseudoSystemFunctionConstExpression): Add TBitSize.
* gm2-compiler/NameKey.mod: Add MemDiagnostic code
commented out.
* gm2-compiler/P1SymBuild.mod (StartBuildProcedure):
Add v format specifier.
* gm2-compiler/P2SymBuild.mod (BuildFieldRecord): Ditto.
* gm2-compiler/P3Build.bnf (SetType): Reformat.
* gm2-compiler/PathName.def (Copyright): Added.
* gm2-compiler/PathName.mod: Remove blank line.
* gm2-compiler/SymbolConversion.mod (gdbhook): New procedure.
(BreakWhenSymBooked): Ditto.
(CheckBook): Ditto.
(Init): Rewrite.
* gm2-compiler/SymbolTable.def (GetSetArray): New procedure.
(PutSetArray): Ditto.
(MakeSetArray): New procedure function.
(PutSetInWord): New procedure.
(GetSetInWord): New procedure function.
(IsConstVar): Ditto.
* gm2-compiler/SymbolTable.mod (SymSet): SetInWord new field.
SetArray new field.
Align new field.
(SymMemDiag): New global variable.
(Init): Initialize SymMemDiag.
(IsConstVar): New procedure function.
(IsVariableSSA): Replace InternalError with Return FALSE.
(GetNthParamOrdered): Reimplement.
(GetNthParamAnyClosest): Ditto.
(GetOuterModuleScope): Ditto.
(MakeSet): Ditto.
(PutSetArray): New procedure.
(GetSetArray): New procedure function.
(MakeSetArray): Ditto.
(PutSetInWord): New procedure.
(GetSetInWord): New procedure function.
* gm2-gcc/init.cc (_M2_M2Diagnostic_init): Define
prototype.
(init_FrontEndInit):Call _M2_M2Diagnostic_init.
* gm2-gcc/m2block.cc (m2block_GetTotalConstants): New function.
(m2block_GetGlobalTypes): Ditto.
* gm2-gcc/m2block.def (GetTotalConstants): New procedure function.
(GetGlobalTypes): New procedure function.
* gm2-gcc/m2block.h (m2block_GetTotalConstants): New function
prototype.
(m2block_GetGlobalTypes): Ditto.
* gm2-gcc/m2convert.cc (converting_ISO_generic): Reimplement.
(m2convert_ToPIMByte): New function.
* gm2-gcc/m2convert.def (ToLoc): New procedure function.
(ToPIMByte): Ditto.
* gm2-gcc/m2convert.h (m2convert_ToPIMByte): Ditto.
* gm2-gcc/m2decl.h (m2decl_RememberVariables): Ditto.
* gm2-gcc/m2expr.cc (m2expr_BuildLogicalShift): Reimplement.
(m2expr_BuildLRotate): Ditto.
(m2expr_BuildLRLn): Ditto.
(m2expr_BuildLRRn): Ditto.
(m2expr_BuildLogicalRotate): Ditto.
(buildUnboundedArrayOf): Ditto.
(BuildIfBitInSetLower): New function.
(m2expr_BuildBinarySetDo): Reimplement.
(m2expr_BuildIfInSet): Ditto.
(m2expr_BuildIfNotInSet): New function.
(m2expr_Build4LogicalOr): Reimplement.
(m2expr_BuildSetNegate): Ditto.
(m2expr_BuildLogicalOrAddress): Ditto.
(m2expr_BuildLogicalOr): Ditto.
(m2expr_BuildLogicalAnd): Ditto.
(m2expr_BuildSymmetricDifference): Ditto.
(m2expr_BuildLogicalDifference): Ditto.
(boolean_enum_to_unsigned): Ditto.
(m2expr_BuildIsSuperset): Ditto.
(m2expr_BuildIsNotSuperset): Ditto.
(m2expr_BuildIsSubset): Ditto.
(m2expr_BuildIfBitInSetJump): Ditto.
(m2expr_BuildIfNotConstInVar): Ditto.
(m2expr_BuildIfVarInVar): Ditto.
(m2expr_BuildIfNotVarInVar): Remove.
(m2expr_BuildIfConstInVar): Remove.
(m2expr_BuildForeachWordInSetDoIfExpr): Ditto.
(m2expr_BuildBinaryForeachWordDo): Ditto.
(m2expr_BuildIfInRangeGoto): Reimplement.
(m2expr_BuildIfNotInRangeGoto): Ditto.
(m2expr_SetAndNarrow): Ditto.
(m2expr_GetBitsetZero): New function.
(m2expr_GetRValue): Ditto.
* gm2-gcc/m2expr.def (GetBitsetZero): New function.
(BuildSetNegate): Ditto.
(BuildLogicalOr): Reimplement.
(BuildLogicalAnd): Ditto.
(BuildSymmetricDifference): Ditto.
(BuildLogicalDifference): Ditto.
(BuildIfInSet): New procedure function.
(BuildIfNotInSet): Ditto.
(BuildEqualTo): Reimplement.
(BuildNotEqualTo): Ditto.
(BuildBinaryForeachWordDo): Remove.
(BuildBinarySetDo): Ditto.
(GetRValue): New procedure function.
* gm2-gcc/m2expr.h (m2expr_BuildBinaryForeachWordDo): Remove.
(m2expr_BuildForeachWordInSetDoIfExpr): Ditto.
(m2expr_BuildIfNotVarInVar): Ditto.
(m2expr_BuildIfVarInVar): Ditto.
(m2expr_BuildIfNotConstInVar): Ditto.
(m2expr_BuildIfConstInVar): Ditto.
(m2expr_BuildLogicalDifference): Reimplement.
(m2expr_BuildSymmetricDifference): Ditto.
(m2expr_BuildLogicalAnd): Ditto.
(m2expr_BuildLogicalOr): Ditto.
(m2expr_BuildLogicalOrAddress): Ditto.
(m2expr_BuildSetNegate): Ditto.
(m2expr_GetBitsetZero): New function.
(m2expr_GetRValue): Ditto.
(m2expr_BuildIfInSet): Ditto.
(m2expr_BuildIfNotInSet): Ditto.
* gm2-gcc/m2options.h (M2Options_SetTimeReport): New function.
(M2Options_SetMemReport): Ditto.
(M2Options_SetWideset): Ditto.
(M2Options_GetWideset): Ditto.
* gm2-gcc/m2pp.cc (m2pp_shiftrotate_expr): New function.
(m2pp_simple_expression): Ditto.
* gm2-gcc/m2statement.cc (m2statement_BuildStartFunctionCode):
Tidyup comments.
(m2statement_BuildEndFunctionCode): Ditto.
(m2statement_BuildPushFunctionContext): Ditto.
(copy_array): Ditto.
(CopyByField_Lower): Ditto.
(m2statement_BuildGoto): Ditto.
(m2statement_DeclareLabel): Ditto.
(m2statement_BuildParam): Ditto.
(nCount): Ditto.
(m2statement_BuildProcedureCallTree): Ditto.
(m2statement_BuildBuiltinCallTree): Ditto.
(m2statement_BuildFunctValue): Ditto.
(m2statement_BuildCall2): Ditto.
(m2statement_BuildCall3): Ditto.
(m2statement_BuildFunctionCallTree): Ditto.
(m2statement_SetLastFunction): Ditto.
(m2statement_SetParamList): Ditto.
(m2statement_GetLastFunction): Ditto.
(m2statement_GetParamList): Ditto.
(m2statement_GetCurrentFunction): Ditto.
(m2statement_GetParamTree): Ditto.
(m2statement_BuildTryFinally): Ditto.
(m2statement_BuildCleanUp): Ditto.
(m2statement_BuildUnaryForeachWordDo): Remove.
(m2statement_BuildExcludeVarConst): Ditto.
(m2statement_BuildExcludeVarVar): Ditto.
(m2statement_BuildIncludeVarConst): Ditto.
(m2statement_BuildIncludeVarVar): Ditto.
(m2statement_DoJump): Remove.
(m2statement_IfExprJump): New function.
(m2statement_IfBitInSetJump): Ditto.
* gm2-gcc/m2statement.def (DoJump): Remove.
(IfExprJump): New procedure function.
(BuildUnaryForeachWordDo): Remove.
(IfBitInSetJump): New procedure function.
* gm2-gcc/m2statement.h (m2statement_BuildForeachWordDo): Remove.
(m2statement_DoJump): Ditto.
(m2statement_IfExprJump): New function.
(m2statement_IfBitInSetJump): Ditto.
* gm2-gcc/m2treelib.cc (m2treelib_do_jump_if_bit): Reimplement.
(nCount): Replace with ...
(m2treelib_nCount): ... this.
(m2treelib_DoCall): Reimplement.
(m2treelib_get_rvalue): Remove.
* gm2-gcc/m2treelib.def (get_rvalue): Remove.
(nCount): New procedure function.
* gm2-gcc/m2treelib.h (m2treelib_get_rvalue): Remove.
(m2treelib_nCount): New function.
* gm2-gcc/m2type.cc (constructor_elements): Change type to vec.
(m2type_BuildEndArrayType): Reformat.
(build_m2_type_node_by_array): Ditto.
(m2type_GetBooleanEnumList): New procedure function.
(m2type_BuildEnumerator): Add const to char *.
(m2type_BuildSetConstructorElement): Reimplement.
(m2type_BuildEndSetConstructor): Ditto.
(build_record_constructor): New function.
(m2type_BuildEndRecordConstructor): Reimplement.
(m2type_BuildRecordConstructorElement): Ditto.
(m2type_BuildStartArrayConstructor): Reimplement.
(m2type_BuildEndArrayConstructor): Remove blank lines.
* gm2-gcc/m2type.def (BuildSetConstructorElement): Reimplement.
(BuildEndArrayType): Reformat.
(GetBooleanEnumList): New function.
* gm2-gcc/m2type.h (m2type_BuildEnumerator): Add const to char *.
(m2type_BuildSetConstructorElement): Reimplement.
(m2type_GetBooleanEnumList): New procedure function.
* gm2-lang.cc (OPT_fmem_report): New option.
(OPT_ftime_report): Ditto.
(OPT_fwideset): Ditto.
* gm2-libs-coroutines/SYSTEM.def (ShiftVal): Remove.
(ShiftLeft): Ditto.
(ShiftRight): Ditto.
(RotateVal): Ditto.
(RotateLeft): Ditto.
(RotateRight): Ditto.
* gm2-libs-coroutines/SYSTEM.mod: Reimplement.
* gm2-libs-iso/SYSTEM.def (ShiftVal): Remove.
(ShiftLeft): Ditto.
(ShiftRight): Ditto.
(RotateVal): Ditto.
(RotateLeft): Ditto.
(RotateRight): Ditto.
* gm2-libs-iso/SYSTEM.mod: Reimplement.
* gm2-libs/SYSTEM.def (ShiftVal): Remove.
(ShiftLeft): Ditto.
(ShiftRight): Ditto.
(RotateVal): Ditto.
(RotateLeft): Ditto.
(RotateRight): Ditto.
* gm2-libs/SYSTEM.mod: Reimplement.
* gm2-libs/SysStorage.def (DEALLOCATE): Improve comment.
* gm2-libs/SysStorage.mod: Improve comment.
* init/ppginit (M2Diagnostic): Add.
(StringConvert): Add.
* lang.opt (fmem-report): Add access to c.opt.
(ftime-report): Ditto.
(fwideset): New option.
* pge-boot/main.cc (_M2_M2Diagnostic_init): New function.
(_M2_M2Diagnostic_fini): Ditto.
(_M2_StringConvert_init): Ditto.
(_M2_StringConvert_fini): Ditto.
(main): Call _M2_M2Diagnostic_init.
Call _M2_StringConvert_init.
Call _M2_M2Diagnostic_fini.
Call _M2_StringConvert_fini.
* tools-src/makeSystem: Add -gdb option.
* gm2-libs/M2Diagnostic.def: New file.
* gm2-libs/M2Diagnostic.mod: New file.
* gm2-libs/M2WIDESET.def: New file.
* gm2-libs/M2WIDESET.mod: New file.
* mc-boot/GM2Diagnostic.cc: New file.
* mc-boot/GM2Diagnostic.h: New file.
* pge-boot/GM2Diagnostic.cc: New file.
* pge-boot/GM2Diagnostic.h: New file.
* pge-boot/GSelective.h: New file.
* pge-boot/GStringConvert.cc: New file.
Jeff Law [Fri, 19 Sep 2025 15:17:01 +0000 (09:17 -0600)]
[RISC-V][PR target/121983] Fix unprotected REGNO invocation
So this was a naked REGNO usage, which of course blows up if RTL checking is
enabled and something else sneaks in (SUBREG). Thankfully it never results in
incorrect code, though I could theorize it could cause a bootstrap comparison
failure in the "right" circumstances.
Bootstrapped & regression tested on the Pioneer. Also regression tested on
riscv64-elf and riscv32-elf. I'll push to the trunk once pre-commit CI is
done.
jeff
PR target/121983
gcc/
* config/riscv/riscv.cc (riscv_macro_fusion_pair_p): Make sure
object is a REG before asking for its REGNO. Fix a trivial
whitespace nit.
gcc/testsuite/
* gcc.target/riscv/pr121983.c: New test.
Improve shuffle_slide_patterns to better recognize permutations that
can be constructed by a slideup or slidedown, covering more cases:
Slideup one vector into the middle the other like
{0, 4, 5, 3}.
Slidedown one vector not ending in the last element like
{5, 6, 2, 3}.
Slidedown one vector from the beginning like
{4, 5, 2, 3}.
gcc/ChangeLog:
* config/riscv/riscv-v.cc
(shuffle_slide_patterns): Cover more permutations.
Jim Lin [Fri, 19 Sep 2025 13:08:09 +0000 (07:08 -0600)]
RISC-V: Only Save/Restore required registers for ILP32E/LP64E
Previously the spec
https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/70
has changed the save/restore routines to save/restore the registers which
are really used for ILP32E/LP64 rather than always save/restore all
of ra/s0/s1.
I also found here that lacks the implementation for lp64e. If it's
necessary I will file anothor patch for that.
gcc/ChangeLog:
* config/riscv/riscv.cc (riscv_compute_frame_info): Remove the
dedicated calculation for RVE.
libgcc/ChangeLog:
* config/riscv/save-restore.S: Only save/restore the registers
which are really used for ILP32E/LP64.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/save-restore-cfi-3.c: New test.
Jeff Law [Fri, 19 Sep 2025 12:54:01 +0000 (06:54 -0600)]
[RISC-V] Optimize clear-lowest-set-bit sequence when ctz is nearby
Daniel Barboza and I were looking at deepsjeng recently and spotted an oddity.
In particular we had a sequence like this:
addi a1,a0,-1
and a1,a0,a1
That idiom clears the lowest set bit in a0. In the initial code we looked at
there was a subsequent ctz dest,a0. In other cases I could see an earlier ctz.
And when I went digging further I even found the ctz between the addi/and.
The key is the ctz uses the same input as the addi, but a different output. So
the ctz doesn't participate in combine with the addi/and.
Tackling this in gimple isn't really feasible as the resultant code is going to
have a higher expression count. The bclr idiom looks like (and (rotate (-2)
(count) (input)) where the count comes from a ctz. SO to make it work from a
costing standpoint, we'd have to go find the ctz and use it.
Tackling in gimple->rtl expansion looked potentially feasible, but sign and
general type changes make that painful. So while I could see the add+and and
could speculatively hope there was a nearby ctz it looked less than ideal from
an implementation standpoint. It also tickled some undesirable behavior in the
combiner.
Tackling in combine isn't possible because the ctz doesn't feed the addi/and or
vice-versa.
Tackling with a peephole works sometimes, but is easily thwarted by the
scheduler putting random code in the middle of the sequences we want to adjust.
So in the end I just made a new RISC-V pass that runs after combine.
It walks each block looking for the addi+and construct. When found it then
looks a few instructions in either direction for a related ctz. When found
it'll move things around as necessary and use ctz+bclr. It depends on DCE to
eliminate the almost certainly dead addi+and insns.
I haven't benchmarked this one on design, but it's definitely picking up the
opportunities in deepsjeng and saves a few billion instructions. It has
survived a riscv64-elf and riscv32-elf build. Bootstrap on the BPI is in
flight, bootstrap on the Pioneer passes, but this code won't trigger this
because the Pioneer doesn't have ctz or bclr instructions.
Note while I would expect some of this pass to be usable on other targets, it
does make some assumptions about RTL structure that hold on RISC-V. For
example subword arithmetic has an explicit sign extension to word mode, bit
position is QImode, etc.
Comments? Other thoughts on how to resolve?
gcc/
* config.gcc (riscv*); Add riscv-bclr-lowest-set-bit.o to extra_objs.
* config/riscv/riscv-bclr-lowest-set-bit.cc: New file.
* config/riscv/riscv-passes.def: Add new pass after combine.
* config/riscv/riscv-protos.h (make_pass_bclr_lowest_set_bit): Add
prototype.
* config/riscv/t-riscv: Add rules to build riscv-bclr-lowest-set-bit.o.
gcc/testsuite
* gcc.target/riscv/bclr-lowest-set-bit-1.c: New test.
Marc Poulhiès [Tue, 15 Jul 2025 09:44:56 +0000 (11:44 +0200)]
ada: Initial support for Extended Access types
This change introduces the support for the new GNAT specific
Extended_Access aspect for access to unconstrained array type :
type Ext_Access is access all Some_Array_Type with Extended_Access;
This new kind of access type does not use the existing "fat" layout with
a record of two pointers: one to the actual data, one to a record with the
bounds of the array. Instead, it removes the second indirection and extends
the record to contain the pointer to the actual data followed by the bounds.
This mainly allows the following features:
- have access to slice of array
- easier interface when allocation is done in a foreign language
Eric Botcazou [Fri, 4 Apr 2025 23:00:34 +0000 (01:00 +0200)]
ada: Preliminary implementation of structural generic instantiation
It contains the changes to the parser required for the new syntax, as well
as the mechanism to instantiate generics implicitly. The implementation is
strictly structural, in the sense that if the implicit instantiation cannot
be made structural for semantic dependence reasons, then it is rejected.
gcc/ada/ChangeLog:
* doc/gnat_rm/gnat_language_extensions.rst (Structural Generic
Instantiation): New entry
* einfo.ads (Is_Link_Once): New flag defined in entities.
* sinfo.ads (Is_Structural): New flag defined in instantiations.
* gen_il-fields.ads (Opt_Field_Enum): Add Is_Link_Once and
Is_Structural.
* gen_il-gen-gen_entities.adb (Entity_Kind): Add Is_Link_Once
semantic flag.
* gen_il-gen-gen_nodes.adb (N_Generic_Instantiation): Move up
Parent_Spec field and add Is_Structural semantic flag.
* frontend.adb: Add with clause for Sem_Ch12.
(Frontend): After analysis is complete and bodies are instantiated,
call Sem_Ch12.Mark_Link_Once on the declarations of the main unit.
* par.adb (P_Qualified_Simple_Name): Delete.
(P_Qualified_Simple_Name_Resync): Likewise
(P_Exception_Name): New function declaration.
(P_Label_Name): Likewise.
(P_Loop_Name): Likewise.
(P_Generic_Unit_Name): Likewise.
(P_Library_Unit_Name): Likewise.
(P_Package_Name): Likewise.
(P_Parent_Unit_Name): Likewise.
(P_Subtype_Name): Likewise.
(P_Subtype_Name_Resync): Likewise.
* par-ch3.adb (P_Subtype_Mark_Resync): Replace call to
P_Qualified_Simple_Name_Resync by P_Subtype_Name_Resync.
(P_Identifier_Declarations): Replace call to
P_Qualified_Simple_Name_Resync by P_Exception_Name.
(P_Derived_Type_Def_Or_Private_Ext_Decl): Replace call to
P_Qualified_Simple_Name by P_Subtype_Name.
(P_Interface_Type_Definition): Replace calls to
P_Qualified_Simple_Name by P_Subtype_Name.
* par-ch4.adb (P_Reduction_Attribute_Reference): Move around and
change name of parameter.
(P_Name): Document new grammar rule and make a couple of tweaks.
(P_Exception_Name): New function.
(P_Label_Name): Likewise.
(P_Loop_Name): Likewise.
(P_Generic_Unit_Name): Likewise.
(P_Library_Unit_Name): Likewise.
(P_Package_Name): Likewise.
(P_Parent_Unit_Name): Likewise.
(P_Subtype_Name): Likewise.
(P_Subtype_Name_Resync): Likewise.
(P_Qualified_Simple_Name): Rename into...
(P_Simple_Name): ...this.
(P_Qualified_Simple_Name_Resync): Rename into...
(P_Simple_Name_Resync): ...this. Accept left parenthesis and
dot as name extensions.
(P_Allocator): Replace call to P_Qualified_Simple_Name_Resync
by P_Subtype_Name_Resync.
* par-ch5.adb (P_Goto_Statement): Replace call to
P_Qualified_Simple_Name by P_Label_Name.
(Parse_Loop_Flow_Statement): Replace call to
P_Qualified_Simple_Name by P_Loop_Name.
* par-ch6.adb (P_Subprogram): Replace call to
P_Qualified_Simple_Name by P_Generic_Unit_Name.
* par-ch7.adb (P_Package): Replace calls to
P_Qualified_Simple_Name by P_Package_Name and P_Generic_Unit_Name.
* par-ch8.adb (P_Use_Package_Clause): Replace calls to
P_Qualified_Simple_Name by P_Package_Name.
* par-ch9.adb (P_Task): Replace call to
P_Qualified_Simple_Name by P_Subtype_Name.
(P_Protected): Likewise.
* par-ch10.adb (P_Context_Clause): Replace call to
P_Qualified_Simple_Name by P_Library_Unit_Name.
(P_Subunit): Replace call to P_Qualified_Simple_Name by
P_Parent_Unit_Name.
* par-ch12.adb (P_Generic): Replace call to
P_Qualified_Simple_Name by P_Generic_Unit_Name.
(P_Formal_Derived_Type_Definition): Replace call to
P_Qualified_Simple_Name by P_Subtype_Name.
(P_Formal_Package_Declaration): Replace call to
P_Qualified_Simple_Name by P_Generic_Unit_Name.
* sem_ch4.adb: Add with and use clauses for Sem_Ch12.
(Analyze_Call): Accept implicit instantiations with -gnatX0.
(Analyze_Indexed_Component_Form): Likewise.
* sem_ch8.adb (Analyze_Use_Package): Add guard before inserting
a with clause automatically when there is a use clause.
(Check_In_Previous_With_Clause): Retrieve original names.
(Check_Library_Unit_Renaming): Deal with structural instances.
(End_Use_Type): Minor tweak.
* sem_ch10.adb (Analyze_With_Clause): Remove useless test and
call Defining_Entity_Of_Instance.
* sem_ch12.ads (Build_Structural_Instantiation): New function.
(Mark_Link_Once): New procedure.
* sem_ch12.adb: Add with and use clauses for Exp_Dbug.
(Analyze_Associations): Add support for structural instantiations.
(Analyze_Package_Instantiation): Likewise.
(Analyze_Subprogram_Instantiation): Likewise.
(Analyze_Structural_Associations): New procedure.
(Need_Subprogram_Instance_Body): Return True for instantiation is
in the auxiliary declarations of the main unit.
(Build_Structural_Instantiation): New function.
(Mark_Link_Once): New procedure.
* sem_util.ads (Add_Local_Declaration): New procedure.
(Defining_Entity_Of_Instance): New function.
* sem_util.adb (Add_Local_Declaration): New procedure.
(Defining_Entity_Of_Instance): New function.
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.
The comment this patch changes claimed that operational aspects are
"view-specific". The following excerpt from ARM 13.1 (11/5) indicates
that the set of view-specific aspects is in fact much more restricted:
If a type-related aspect is defined for the partial view of a type,
then it has the same definition for the full view of the type, except
for certain Boolean-valued operational aspects where the language
specifies that the partial view can have the value False even when
the full view has the value True.
On the other hand, a feature of operational aspects is that they can be
specified on partial views, unlike representation aspects. That's stated
by AARM 13.1 (9.c/1):
Unlike representation items, operational items can be specified on
partial views.
So this patch changes the comment to be about that instead.
The comment this patch removes was about representation aspects but it
was placed above Operational_Aspect. The comment in itself was not very
helpful either since operational aspects, for example, are also needed
during expansion and code generation.
Marc Poulhiès [Fri, 5 Sep 2025 13:36:05 +0000 (15:36 +0200)]
ada: Add C binding for Is_Extended_Access_Type
gcc/ada/ChangeLog:
* fe.h (Is_Extended_Access_Type): Add C bindings.
* sem_util.ads (Is_Extended_Access_Type): Add comment that any
change to the function must take care of the C binding.
Steve Baird [Wed, 3 Sep 2025 19:21:10 +0000 (12:21 -0700)]
ada: Compiler crashes on subunits with Streaming/Put_Image attribute references
When necessary, the compiler builds subprograms to implement the streaming
attributes (or the Put_Image attribute) for a type. In some cases involving
separate subunits, these compiler-generated subprograms were inserted at the
wrong point in the tree, resulting in internal compiler errors.
gcc/ada/ChangeLog:
* exp_attr.adb (Interunit_Ref_OK): Treat a subunit like a body.
(Build_And_Insert_Type_Attr_Subp): When climbing up the
tree, go from an N_Subunit node to its stub (instead of to the
subunit's N_Compilation_Unit node).
Gary Dismukes [Fri, 5 Sep 2025 20:58:54 +0000 (20:58 +0000)]
ada: Incorrect expansion of VADS Size attribute applied to an array type
The compiler fails, either with an Assert_Failure (for a compiler with
assertions enabled) or by producing a bad value, when processing a VADS_Size
attribute (or a Size attribute when pragma Use_VADS_Size is in force),
in the case where the prefix denotes a composite type or subtype whose
object size (Esise) is not known by the front end. The bug is due to
Eval_Attribute attempting to fold a VADS-related size attribute even
when Esize is not yet known for the type.
gcc/ada/ChangeLog:
* sem_attr.adb (Eval_Attribute): In the case of a VADS-specific
size attribute, only fold to the object size when the Esize field
is known.
Richard Biener [Thu, 18 Sep 2025 12:19:40 +0000 (14:19 +0200)]
Cleanup vect_get_num_copies API
The following removes the dual non-SLP/SLP API in favor of only
handling SLP. This also removes the possibility to override
vectype of a SLP node with an inconsistent one while still using
the SLP nodes number of lanes. This requires adjustment of
a few places where such inconsistencies happened.
* tree-vectorizer.h (vect_get_num_copies): Remove unused
overload. Remove defaulted vectype argument and always
use the vector type of the SLP node.
* tree-vect-loop.cc (vect_reduction_update_partial_vector_usage):
Adjust.
(vectorizable_lane_reducing): Likewise.
(vect_transform_reduction): Likewise.
(vectorizable_nonlinear_induction): Likewise.
* tree-vect-stmts.cc (check_load_store_for_partial_vectors):
Likewise.