Patrick Palka [Mon, 15 Dec 2025 20:03:39 +0000 (15:03 -0500)]
c++: losslessly encode TYPENAME_TYPE tag
We currently have 7 distinct tag_types, but our TYPENAME_TYPE
representation effectively only differentiates between 4 of them at the
expense of struct_type (which gets conflated with class_type),
none_type and scope_type (which get conflated with typename_type).
struct_type / class_type conflation is mostly harmless, but it
probably affects -Wmismatched-tags. none_type / typename_type too
should be harmless. But scope_type / typename_type conflation is
problematic because scope_type indicates a type-only lookup unlike
typename_type.
This patch makes our representation of TYPENAME_TYPE encode the numeric
tag type value losslessly using the first three adjacent tree flag bits.
We already use three flag bits for the tag encoding (but inefficiently)
so no additional space is needed.
gcc/cp/ChangeLog:
* cp-tree.h (TYPENAME_TYPE_TAG_BIT_0): New.
(TYPENAME_TYPE_TAG_BIT_1): New.
(TYPENAME_TYPE_TAG_BIT_2): New.
(TYPENAME_IS_ENUM_P): Use get_typename_tag.
(TYPENAME_IS_CLASS_P): Rename to ...
(TYPENAME_IS_CLASS_OR_STRUCT_P): ... this, and use
get_typename_tag.
(TYPENAME_IS_UNION_P): Use get_typename_tag.
(TYPENAME_IS_RESOLVING_P): Use TREE_LANG_FLAG_3
instead of _2.
(get_typename_tag): New.
(set_typename_tag): New.
(tag_name): Declare.
* decl.cc (typename_info): Replace bool fields with a single
tag_types field.
(typename_hasher::equal): Adjust.
(build_typename_type): Adjust.
(tag_name): Handle none_type and scope_type.
* error.cc (dump_type) <case TYPENAME_TYPE>: Use tag_name.
* module.cc (trees_out::type_node) <case TYPENAME_TYPE>: Use
get_typename_tag.
* pt.cc (tsubst) <case TYPENAME_TYPE>: Likewise.
Patrick Palka [Mon, 15 Dec 2025 20:03:36 +0000 (15:03 -0500)]
c++: restrict TYPE_POLYMORPHIC_P to class types
Since TYPE_POLYMORPHIC_P shares the same storage as other flags for
TYPENAME_TYPE and DECLTYPE_TYPE, we should avoid accidentally using
this accessor on those tree codes. This patch restricts the accessor
to RECORD/UNION_TYPE which allows callers to conveniently guard any
uses with CLASS_TYPE_P. Otherwise with the next patch applied that
rearranges TYPENAME_TYPE flags, noexcept_override_late_checks would
not skip over a TYPENAME_TYPE base for which TYPE_POLYMORPHIC_P
nonsensically returns true, leading to an eventual ICE.
gcc/cp/ChangeLog:
* cp-tree.h (CLASSTYPE_LAMBDA_EXPR): Check CLASS_TYPE_P before
inspecting TYPE_POLYMORPHIC_P.
(TYPE_POLYMORPHIC_P): Restrict to RECORD_TYPE or UNION_TYPE.
Document its use of TREE_LANG_FLAG_2.
* parser.cc (noexcept_override_late_checks): Only
check TYPE_POLYMORPHIC_P on CLASS_TYPE_P types.
* rtti.cc (build_headof): Likewise.
(get_tinfo_ptr_dynamic): Likewise.
(build_typeid): Likewise.
Jerry DeLisle [Sun, 14 Dec 2025 21:23:36 +0000 (13:23 -0800)]
Fortran: Fix bad read involving extra input text.
The problem here involved DTIO mixed with non-DTIO
variables in list formatted reads. The previous fix to
PR105361 broke the test case here by mis-handling the
end of file conditions. It was found that the code could
be significantly reduced as well.
PR libfortran/122936
libgfortran/ChangeLog:
* io/list_read.c (finish_list_read): Remove the use of hit_eof
and free_line. Simplify the logic. Add comments to clarify.
Patrick Palka [Mon, 15 Dec 2025 19:30:53 +0000 (14:30 -0500)]
c++: nested typename type resolving to wildcard type [PR122752]
Here typename A<S>::VertexSet::size_type within the out-of-line
declaration is initially parsed at namespace scope, so the LHS
A<S>::VertexSet is treated as a dependent name and represented as a
TYPENAME_TYPE with tag_type as class_type.[1]
Once we realize we're parsing a member declarator we call
maybe_update_decl_type to reprocess the TYPENAME_TYPE relative to the
class template scope, during which make_typename_type succeeds in
resolving the lookup and returns the member typedef VertexSet (to the
TEMPLATE_TYPE_PARM S). But then the caller tsubst complains that this
result isn't a class type as per the tag_type.
This patch just relaxes tsubst to allow TYPENAME_TYPE getting resolved
to a wildcard type regardless of the tag_type. This does mean we lose
information about the tag_type during a subsequent tsubst, but that's
probably harmless (famous last words).
[1]: The tag_type should probably be scope_type. Changing this seems
to be a matter of changing cp_parser_qualifying_entity to pass
scope_type instead of class_type, but I don't feel confident about that
and it seems risky. I then got confused as to why that function passes
none_type in the !type_p case; to me it should use scope_type
unconditionally, but doing so breaks things. This approach seems safer
to backport.
PR c++/122752
gcc/cp/ChangeLog:
* pt.cc (tsubst) <case TYPENAME_TYPE>: Allow TYPENAME_TYPE
resolving to another wildcard type.
Patrick Palka [Mon, 15 Dec 2025 19:23:52 +0000 (14:23 -0500)]
c++: delay noexcept parsing for templated friends [PR122668]
The r16-5425 workaround to delay current-instantiation name lookup
within a friend's noexcept-spec is unsound because it considers the
flag cp_noexcept_operand but that indicates a noexcept-expr, not a
noexcept-spec. We don't currently have a flag for indicating a
noexcept-spec context (and I don't think we really want one).
This patch reverts that workaround and instead makes us properly
delay noexcept-spec parsing of templated friends, which should fully
address the regression since it's applicable only to ahead of time
name lookup at class template scope. Delaying noexcept-spec parsing
of non-templated friends is trickier since it means we need to defer
declaration matching of such friends until after delayed parsing rather
than immediately matching. In contrast, for templated friends we
naturally defer declaration matching until instantiation time, i.e.
well after delayed parsing.
PR c++/122668
PR c++/114764
gcc/cp/ChangeLog:
* parser.cc (cp_parser_class_specifier): Adjust after
changing the element type of unparsed_noexcepts. Pass
the class type to noexcept_override_late_checks.
(cp_parser_member_declaration): Set
CP_PARSER_FLAGS_DELAY_NOEXCEPT also for templated friends.
(noexcept_override_late_checks): Add class_type parameter.
(cp_parser_single_declaration): Set
CP_PARSER_FLAGS_DELAY_NOEXCEPT also for template friends
at class template scope.
(cp_parser_save_default_args): Push current_class_type
to unparsed_noexcepts.
* parser.h (cp_unparsed_functions_entry::noexcepts):
Change element type to cp_default_arg_entry.
* pt.cc (dependentish_scope_p): Revert r16-5425 change.
Jakub Jelinek [Mon, 15 Dec 2025 18:08:06 +0000 (19:08 +0100)]
libgomp: Avoid -Waddress warning
The function has assert (htab_find) with a comment that that is to
avoid -Wunused-function warning. The problem is that it triggers
a different warning,
../../../libgomp/plugin/build-target-indirect-htab.h:68:3: warning: the address of ‘htab_find’ will always evaluate as ‘true’
(or error depending on exact flags).
This uses (void) htab_find instead to avoid any diagnostics.
2025-12-15 Jakub Jelinek <jakub@redhat.com>
* plugin/build-target-indirect-htab.h (create_target_indirect_map):
Use (void) htab_find instead of assert (htab_find) to silence
-Werror=unused-function because the latter triggers -Werror=address.
Joseph Myers [Mon, 15 Dec 2025 17:58:20 +0000 (17:58 +0000)]
testsuite: Support plugin testing for installed compiler
Plugin tests are currently only enabled for build-tree testing.
Enable them for installed testing as well, using
-print-file-name=plugin/include to locate the installed headers in
that case.
Support is also added to contrib/test_installed for the associated
site.exp settings. Installed testing also shows up that some plugin
tests are using text-art/*.h headers that aren't currently installed,
so add those to PLUGIN_HEADERS.
Bootstrapped with no regressions for x86_64-pc-linux-gnu, and also ran
plugin tests for an installed compiler with contrib/test_installed.
contrib/
* test_installed (--enable-plugin, --with-plugincc=)
(--with-plugincflags=, --with-gmpinc=): New options.
gcc/testsuite/
* lib/plugin-support.exp (plugin-test-execute): Support installed
testing.
* g++.dg/plugin/plugin.exp, gcc.dg/plugin/plugin.exp,
obj-c++.dg/plugin/plugin.exp, objc.dg/plugin/plugin.exp: Do not
disable for installed testing.
At present we reject uncounted loops outright when doing initial loop
analysis in `vect_analyze_loop_form'.
We have the following gating condition that causes rejection of a
given loop:
if (integer_zerop (info->assumptions)
|| !info->number_of_iterations
|| chrec_contains_undetermined (info->number_of_iterations))
We can do away with this check altogether, but not without problems,
allowing many malformed loops through which ought to be rejected as
early as possible.
We observe that a common thread running through these malformed loops
is the absence of any scalar evolution between iterations.
We have therefore adjusted the analysis replacing the checks on
`niters' for a test for the presence of scalar evolution in the loop,
which can be detected via the presence of phi nodes in the loop.
The categorization of uncounted loops as
LOOP_VINFO_EARLY_BREAKS_VECT_PEELED disables prolog peeling by
default. This is due to the assumption that you have early break
exits following the IV counting main exit. For such loops, prolog
peeling is indeed problematic.
For enabling prolog peeling in uncounted loops it is sufficient, when
duplicating the loop for the prolog, to convert the prolog loop into a
counted loop, inserting a counting IV exit at the end, thus resulting
in the kind of early-break loop already supported by the compiler.
The pre-existing exits will continue to point to the exit node, while
the new exit will point to the vectorized loop, directing control flow
there once the number of iterations required for alignment are
completed.
In order to achieve this, we note that `vect_set_loop_condition'
replaces the condition in the main exit of a counted loop, all the
while inserting the prolog IV and its update statement. The design
strategy is thus:
- Have `slpeel_tree_duplicate_loop_to_edge_cfg' add a dummy main
exit to the loop in the non-exiting branch of the original "main"
exit in the loop, between the condition-containing BB and the latch
BB. For the original exit, if the exit condition is true, the
edge->dest will remain unchanged. The dummy exit will replicate
this control-flow, with the exiting branch of the if statement
initially leading to the same exit BB as the preceding exit.
- As this new basic block will contain the IV-counting exit
condition, its exit edge will be used for the control flow when
alignment is achieved and thus we mark it as the new `new_exit'.
This exit is then used in `redirect_edge_and_branch_force (new_exit,
preheader)' and its basic block passed to `vect_set_loop_condition',
wherein its condition will be replaced accordingly, correctly
completing the setting up of our prolog loop.
- In order to control this new functionality in
slpeel_tree_duplicate_loop_to_edge_cfg we are, however, required to
add a new parameter to the function. This is to be set to true when
we have an uncounted loop AND we're generating its prolog. This is
done via the `bool duplicate_main_e' parameter, defaulting to false,
allowing existing calls to the function to remain unchanged.
vect: Reject uncounted loop vectorization where alias analysis may fail
Issues with alias list pruning for uncounted loops was found to cause
as-of-yet unresolved issues in the execution of SpecV6. Disable this
while a reduced testcase is developed and a solution implemented.
Test derived from "omp_get_partition_place_nums" from libgomp "icv.c":
unsigned len = 8;
void
alias_fail (int n[8])
{
unsigned int i;
for (i = 0; i < len; i++)
*n++ = i;
}
gcc/ChangeLog:
* tree-vect-data-refs.cc (vect_prune_runtime_alias_test_list):
Reject when !operand_equal_p for any data ref pair.
vect: Disable use of partial vectors for uncounted loops
Given the current reliance of masking on niters and the fact this is
undetermined for uncounted loops, we circumvent this limitation by
disabling the use of partial vectors when vectorizing loops with an
unkown upper bound.
gcc/ChangeLog:
* tree-vect-loop.cc (vect_analyze_loop_2): Disable partial
vector use for uncounted loops.
vect: Fix uncounted PHI handling of `slpeel_tree_duplicate_loop_to_edge_cfg'
Given how present requirements for loops, early-break or otherwise, to
have a known iteration count, there is currently no need for
single-exit loops to reset induction variables and accumulators prior
to entering the exit loop.
For multiple-exit uncounted loops, there are provisions in the code
for resetting IVs and accumulators on exiting the loop via early
exits. This is extended to the main exit (though only in
multiple-exit loops) if `peeled_iters' is set to `true', wherein the
definition of `peeled_iters' is equivalent to that of
LOOP_VINFO_EARLY_BREAKS_VECT_PEELED, but is evaluated independently as
the function does not have access to loop_vinfo.
Therefore, the first fix is to ensure that, just as for
LOOP_VINFO_EARLY_BREAKS_VECT_PEELED, `peeled_iters' also evaluates to
true for uncounted loops.
The second fix implemented here is: given the relevant logic is
currently hidden behind the `multiple_exits_p', we enable relevant
logic via use of the new function argument `uncounted_p'.
gcc/ChangeLog:
* tree-vect-loop-manip.cc (slpeel_tree_duplicate_loop_to_edge_cfg):
reset IVs and accumulators for all exits for uncounted loops.
* tree-vectorizer.h (slpeel_tree_duplicate_loop_to_edge_cfg):
add boolean `uncounted_p' argument.
vect: Disable niters-based skipping of uncounted vectorized loops
The iteration count profitability check is irrelevant for uncounted
loops given that, even at runtime, the number of iterations is unknown
at the start of loop execution.
Likewise, the test for skipping the vectorized version of the loop is
based on whether the number of iterations that will be run for the
loop and whether it is smaller than the vectorization factor. As this
is undetermined, the check can never be run for uncounted loops.
vect: guard niters manipulation with `LOOP_VINFO_NITERS_UNCOUNTED_P'
In `vect_do_peeling' and `vect_transform_loop', there are several bits
of logic reliant on niters that need to be handled differently in the
case of uncounted loops.
Firstly When we peel the loop, adding a prolog, we subtract the
prolog peeling factor from the original number of iterations for the
main loop.
Then, upon vectorization of the main loop, we need to update the
iteration upper-bound to reflect the fact that each iteration now acts
on VF elements, such that less iterations will be needed.
Both of these updates become unnecessary when we don't have an IV
counting exit. Therefore, it is sufficient to guard these
manipulations behind a check for whether the loop we're dealing with
is uncounted.
vect: Extend `vec_init_loop_exit_info' to handle uncounted loops
In its current implementation, the loop vectorizer requires the main
exit be the counting IV exit. With uncounted loops we no longer need
to have any counting IV exits. Furthermore, it is possible to have
reached this stage with malformed loops with no exits at all.
Consequently, we need an approach to handle malformed loops and some
logic to follow when choosing the main exit, when counting IV is no
longer a valid criterion.
For malformed loops, it is sufficient to return NULL, so that we can
reject such loops upon the function return.
In the case of multiple exits and no counting IV exit, we choose the
last one in the loop. This is done so that we continue to have an
empty effective latch.
As a consequence of allowing the main exit to no longer be associated
with IV counting, the old nomenclature of `LOOP_VINFO_IV_EXIT' and
`vec_loop_iv_exit' no longer fully cover the usage of such fields and
accessors. With that in mind, these are modified to replace "IV" for
"MAIN" for these.
vect: Make all exit conditions early breaks for uncounted loops
For uncounted loops, given how no information can be derived from the
max number of iterations, we wish to make no distinction between the
"main" exit and any additional exits.
That is, an epilogue is required across all exits to establish when
the exit condition was met within the final vectorized loop iteration.
This can be accomplished via a two-fold approach:
1. The need for all exits to go to the epilogue is shared with
counted loops with early-break exits after the IV-counting exit.
Such counted loops have the `LOOP_VINFO_EARLY_BREAKS_VECT_PEELED'
flag set. By modifying the flag's definition to encompass
uncounted loops, we can make considerable use of the code written
for this category of counted loops.
2. Currently, when populating the `loop_vinfo' struct for a given
loop, there is an assumption that the first exit condition in the
`vect_loop_form_info' struct is the IV condition and any
subsequent conditions are early break conditions. This
assumption breaks down for uncounted loops where _all_ exits
should be treated as being "early break" exits.
This is fixed by populating `LOOP_VINFO_LOOP_IV_COND (loop_vinfo)'
conditionally on the false evaluation of the
`LOOP_VINFO_NITERS_UNCOUNTED_P (loop_vinfo)' predicate, such that
if we do have an uncounted loop we leave this field unpopulated,
storing all conditions in `LOOP_VINFO_LOOP_CONDS (loop_vinfo)'.
This approach has a further benefit in that, give how
`LOOP_VINFO_EARLY_BREAKS' is defined by a non-empty list of early
break exit conditions (`LOOP_VINFO_LOOP_CONDS (loop_vinfo)'),
having LOOP_VINFO_LOOP_CONDS populated even for single-exit
uncounted loops means that `LOOP_VINFO_EARLY_BREAKS' evaluates to
true for all uncounted loops, irrespective of the number of exits
it has.
gcc/ChangeLog:
* tree-vectorizer.h (LOOP_VINFO_EARLY_BREAKS_VECT_PEELED): OR
its current definition with `LOOP_VINFO_NITERS_UNCOUNTED_P(L)'
* tree-vect-loop.cc (vect_create_loop_vinfo): Don't populate
`LOOP_VINFO_LOOP_IV_COND' for uncounted loops.
Given that scalar evolution analysis of uncounted loops sets
`loop_vec_info->num_iters' to `chrec_dont_know', we use this as the
criterion for probing whether a loop is uncounted or not.
Consequently, we introduce a new access function on `loop_vec_info' to
conveniently test whether a loop in question is uncounted or not, in
the form of `LOOP_VINFO_NITERS_UNCOUNTED_P(L)'.
Default types:
--------------
While the primary exit condition for loops is no longer tied to some
upper limit in the number of executed iterations, similar limits are
still required for vectorization. One example of this is with prolog
peeling. The prolog will always have an IV exit associated with the
misalignment of data accesses within the loop.
Historically, the assumption held that the data-type that this counter
should have could be derived from the type of the niters limit for the
original loop, so we could get the type from `TREE_TYPE (niters)'.
Moving forward, we provide a backup type to be used for iteration
counters when the maximum number of iterations to be run is unknown.
We take this to be `sizetype', given its role in storing the maximum
size of a theoretically possible object of any type (including array).
Default return values:
----------------------
To avoid having to gate all calls to functions that query a loop's
niters value it is better to "teach" such functions how to handle
uncounted loops and have them return a sensible value that can be
handled upon a function's return.
We therefore prevent functions operating on niters from segfaulting by
adding a default `SCEV_NOT_KNOWN' return value when niters information
absent.
Peter Damianov [Thu, 11 Dec 2025 01:52:43 +0000 (01:52 +0000)]
Driver: Implement --with-windres= argument to configure script [PR108866]
To align with the rest of the options (--with-ld, --with-as, --with-dsymutil),
implement --with-windres for overriding the windres binary the driver invokes
with an absolute path to a windres binary.
Peter Damianov [Thu, 11 Dec 2025 01:52:42 +0000 (01:52 +0000)]
Driver: Add support for Windows resource files (.rc, .res) [PR108866]
This patch adds support for compiling Windows resource files
(.rc) and pre-compiled resource files (.res) directly through the
GCC driver on PECOFF targets.
Previously, users had to manually invoke windres to compile resource
files before linking:
If any of -E -M or -MM were passed, do nothing. No object files are output.
"%{!E:%{!M:%{!MM:windres
Add -J so that windres does not perform autodetection of input type
Add -O so that the output type is always COFF
-J rc -O coff \
For multilib configurations, tell windres to write out the correct COFF format.
- If -m32 is specified, use pe-i386 format
- If -m64 is specified, use pe-x86_64 format
- If neither are specified, use the correct default for the target
This is defined in WINDRES_FORMAT_SPEC which expands to:
For 64-bit: "%{m32:-F pe-i386;m64|!m32:-F pe-x86-64}"
For 32-bit: "%{m64:-F pe-x86-64;m32|!m64:-F pe-i386}"
Pass through -I -D -U on to windres, because it supports them.
%{I*:-I%*} %{D*:-D%*} %{U*:-U%*} \
If -c is passed, pass through -o to windres, if it was specified. Otherwise,
output to the input basename with .o suffix. Else, output to a
temp file that will be deleted after linking.
%{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O} %i}}}",
gcc/ChangeLog:
PR driver/108866
* gcc.cc (default_compilers): Add EXTRA_DEFAULT_COMPILERS so the config
of a target can add an extra compiler spec to default_compilers.
* config/i386/cygming.h (WINDRES_FORMAT_SPEC): New macro to handle
PE format selection based on TARGET_64BIT_DEFAULT and -m32/-m64 flags.
(EXTRA_DEFAULT_COMPILERS): Add spec for windres.
* config/aarch64/cygming.h (EXTRA_DEFAULT_COMPILERS): Likewise.
Signed-off-by: Peter Damianov <peter0x44@disroot.org> Signed-off-by: Jonathan Yong <10walls@gmail.com>
Jakub Jelinek [Mon, 15 Dec 2025 12:44:20 +0000 (13:44 +0100)]
openmp: Fix next variable initialization in cp_parser_omp_clause_linear [PR123128]
Apparently clang++ emits error on int *p = ((unsigned long) 0); while g++
accepts it without any diagnostics even with -pedantic-errors -W -Wall.
Dunno which is right, anyway, I meant to initialize with NULL, not
UNKNOWN_LOCATION.
2025-12-15 Jakub Jelinek <jakub@redhat.com>
PR c++/123128
* parser.cc (cp_parser_omp_clause_linear): Initialize next to NULL
rather than UNKNOWN_LOCATION.
Eric Botcazou [Mon, 15 Dec 2025 08:09:13 +0000 (09:09 +0100)]
Ada: Fix ICE in fld_incomplete_type_of when building GtkAda with LTO
This is a regression from GCC 9 present on mainline and all active branches:
the compilation of GtkAda in LTO mode trips on the assertion present in the
fld_incomplete_type_of function about the TYPE_CANONICAL of types pointed to
by pointer (or reference) types. The problem comes from an oversight in the
update_pointer_to function on gcc-interface, which correctly propagates the
TYPE_CANONICAL of the new pointer type to the old one when there is a new
pointer type, but fails to synthesize it when there is no new pointer type.
gcc/ada/
PR ada/123060
* gcc-interface/utils.cc (update_pointer_to): Synthesize a new
TYPE_CANONICAL for the old pointer type in the case where there
is no new pointer type. Likewise for references.
gcc/testsuite/
* gnat.dg/lto30.ads, gnat.dg/lto30.adb: New test.
* ga68-exports.pk (ga68_text_reloc_64): Renamed and
adapted from ga68_text_reloc.
(ga68_data_reloc_64): Renamed and adapted from ga68_data_reloc.
(ga68_mode_64): Renamed and adapted from ga68_mode.
(ga68_extract_64): Renamed and adapted from ga68_extract.
(ga68_module_64): Renamed and adapted from ga68_module.
(ga68_text_reloc_32): New type.
(ga68_data_reloc_32): Likewise.
(ga68_mode_32): Likewise.
(ga68_extract_32): Likewise.
(ga68_module_32): Likewise.
Lewis Hyatt [Sun, 14 Dec 2025 14:51:12 +0000 (09:51 -0500)]
middle-end: Fix spurious -Walloc-size-larger-than warning during LTO [PR106409]
The implementation of -Walloc-size-larger-than has logic to avoid issuing
the warning for ::operator new[] calls emitted by the C++ front end, which
otherwise produce known false positives. The logic for suppressing the
warning only activates in the C++ front end, and so it does not prevent the
LTO front end from issuing the warning. Fix by applying the logic in all
cases.
gcc/ChangeLog:
PR tree-optimization/106409
* gimple-ssa-warn-access.cc (maybe_warn_alloc_args_overflow): Adjust
comment for clarity, and augment check to work in LTO as well.
gcc/testsuite/ChangeLog:
PR tree-optimization/106409
* g++.dg/lto/pr106409_0.C: New test.
cprop_hardreg: Prevent copy propagation from a non-frame related insn to a frame related insn
The pass 'cprop_hardreg' should not propagate a value from a
non-frame-related insn to a frame-related one. This can lead to
incorrect dwarf information as noted in PR122274.
cprop_hardreg uses 'struct value_data' to hold lists of registers that
contain the same value. However, the value data does not have any
information about the instruction that sets the values in the register.
In this patch, a new field is added to 'struct value_data_entry'
which indicates if the instruction that created this
value is frame related or not. Then during copy propagation, we do not
replace registers if the copy is happening from a non-frame related insn
to a frame related insn.
Andrew Pinski [Sat, 13 Dec 2025 09:23:13 +0000 (01:23 -0800)]
final_cleanupcfg: Make sure TODO_cleanup_cfg is unset
While I was looking into the code generation of PR 122727,
I noticed that TODO_cleanup_cfg could be set from the call to
execute_fixup_cfg even though cleanupcfg did nothing afterwards.
This means the forwarder blocks that were just created with
make_forwarders_with_degenerate_phis are being removed.
Instead of conditionally unsetting TODO_cleanup_cfg,
unconditionally unset TODO_cleanup_cfg after the call
to make_forwarders_with_degenerate_phis. Since we already
did the cleanup (maybe twice).
Bootstrapped and tested on x86_64-linux-gnu.
PR tree-optimization/46555
gcc/ChangeLog:
* tree-cfgcleanup.cc (execute_cleanup_cfg_post_optimizing):
Unconditionally set TODO_cleanup_cfg.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Jose E. Marchesi [Sat, 13 Dec 2025 12:01:41 +0000 (13:01 +0100)]
a68: handling of PUB in contracted declarations
This commit adds support for using 'pub' in contracted declarations.
Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
gcc/algol68/ChangeLog
* a68-parser-bottom-up.cc (a68_bottom_up_coalesce_pub): Do not
mark defining entities as publicized.
* a68-parser-extract.cc (a68_extract_indicants): Mark public
defining entities.
(a68_extract_priorities): Likewise.
(a68_extract_operators): Likewise.
(a68_extract_identities): Likewise.
(a68_extract_variables): Likewise.
(a68_extract_proc_identities): Likewise.
(a68_extract_proc_variables): Likewise.
gcc/testsuite/ChangeLog
* algol68/execute/modules/module1.a68: Also test contracted
forms.
* algol68/execute/modules/module3.a68: Likewise.
* algol68/execute/modules/module5.a68: Likewise.
* algol68/execute/modules/program-1.a68: Likewise.
Andrew Pinski [Sat, 13 Dec 2025 04:17:00 +0000 (20:17 -0800)]
match: disable some match patterns for non GIMPLE
This disables some match (not the simplify one) patterns
for non-GIMPLE. All of the saturation related match patterns,
the clz/popcount related match patterns that are used from forwardprop.
Also cond_expr_convert_p and bitwise_induction_p match patterns.
These are only used from outside of match and simplify and only the
gimple form so there is no reason to generate the GENERIC form of
this.
THis should speed up bootstrap slightly by not generating or compiling
them. This should (when compiled without LTO) also improve the overall
size of the built binaries too.
For GCC 17, I am thinking about moving the gimple only simplify and match
patterns to their own file as match.pd is getting too big to search for
patterns.
Bootstrapped and tested on x86_64-linux-gnu.
gcc/ChangeLog:
* match.pd: Disable a few match patterns for !GIMPLE.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Andrew Pinski [Wed, 19 Nov 2025 07:02:36 +0000 (23:02 -0800)]
ch: Improve copy header when the bbs are predicated as non-executed [PR122734]
This is version based on https://gcc.gnu.org/pipermail/gcc-patches/2025-November/701533.html
review. Though the only thing is we still need an extra check for the edge probability
like it is done in single_likely_exit because probabilities are still not being tracked
correctly it seems.
I also added copy-headers-12.c which we fail by duplicating too much. But I think that is ok,
as this pattern of being the "correct" part of the loop header leading to a
noreturn function does not happen that often and when it does the header would have had a
statically figured out conditional which is already being checked.
Bootstrapped and tested on x86_64-linux-gnu.
PR tree-optimization/122734
gcc/ChangeLog:
* tree-ssa-loop-ch.cc (should_duplicate_loop_header_p): Add new argument,
canbe_neverexecuted. When canbe_neverexecuted is true, return if a loop
exit is "never executed" like we are doing an invariant conditional.
(ch_base::copy_headers): Update call to should_duplicate_loop_header_p.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/20030711-1.c: Update.
* gcc.dg/tree-ssa/copy-headers-10.c: New test.
* gcc.dg/tree-ssa/copy-headers-11.c: New test.
* gcc.dg/tree-ssa/copy-headers-12.c: New test.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Jakub Jelinek [Sat, 13 Dec 2025 09:02:55 +0000 (10:02 +0100)]
openmp: Provide fixit hints for -Wdeprecated-openmp diagnostics from C++ FE
I think especially the linear clause -Wdeprecated-openmp diagnostics
will be complete nightmare for users, when they have
linear (ref (x, y, z))
or
linear (uval (a, b, c) : 2)
they will have no clue what the new syntax is.
Here is an attempt to provide fixit hints from the C++ FE for most
of these warnings, and even -fdiagnostics-generate-patch can then be
useful for porting.
2025-12-13 Jakub Jelinek <jakub@redhat.com>
* parser.cc (cp_parser_omp_clause_reduction): Provide fixit hints
for -Wdeprecated-openmp diagnostics.
(cp_parser_omp_clause_linear): Likewise.
(cp_parser_omp_clause_depend): Likewise.
(cp_parser_omp_clause_map): Likewise. Reset num_commas after the
diagnostics.
(cp_parser_omp_clause_proc_bind): Provide fixit hints for
-Wdeprecated-openmp diagnostics.
(cp_parser_omp_all_clauses): Move -Wdeprecated-openmp diagnostics
for to vs. enter here, add fixit hints for it.
(cp_parser_omp_master):Add MASTER_LOC argument. Provide fixit hints
for -Wdeprecated-openmp diagnostics.
(cp_parser_omp_parallel): Adjust cp_parser_omp_master caller.
(cp_parser_omp_declare_target): Don't emit -Wdeprecated-openmp
warning for to vs. enter here.
(cp_parser_omp_metadirective): Provide fixit hints for
-Wdeprecated-openmp diagnostics.
(cp_parser_omp_construct): Adjust cp_parser_omp_master caller.
Jakub Jelinek [Sat, 13 Dec 2025 09:01:30 +0000 (10:01 +0100)]
openmp: Provide fixit hints for -Wdeprecated-openmp diagnostics from C FE
I think especially the linear clause -Wdeprecated-openmp diagnostics
will be complete nightmare for users, when they have
linear (ref (x, y, z))
or
linear (uval (a, b, c) : 2)
they will have no clue what the new syntax is.
Here is a so far lightly tested attempt to provide fixit hints for most
of these warnings, and even -fdiagnostics-generate-patch can then be
useful for porting.
And so far I've done just the C FE.
Some issues:
1) I have no idea what to do about
or their attribute variants, for pragmas the location_t one gets is
the omp keyword, not master or declare, and there is no other location_t
easily available to add a fixit hint that master -> masked or
begin inserted before declare. And for attributes I have no idea what
location_t we get there. Note, for omp parallel master or omp parallel
master taskloop I do emit fixit hints.
2) I think there is a missing warning for
(similar case to reduction clause with - identifier)
3) I think the map clause diagnostics for missing comma separation
will not diagnose
just missing commas in between multiple modifiers (and I've fixed it
not to emit diagnostics multiple times if only one comma is missing,
e.g.
would I think diagnose missing comma twice.
2025-12-13 Jakub Jelinek <jakub@redhat.com>
* c-parser.cc (c_parser_omp_clause_reduction): Provide fixit hints
for -Wdeprecated-openmp diagnostics.
(c_parser_omp_clause_linear): Likewise.
(c_parser_omp_clause_depend): Likewise. Add HERE argument.
(c_parser_omp_clause_map): Provide fixit hints for -Wdeprecated-openmp
diagnostics. Reset num_commas after the diagnostics.
(c_parser_omp_clause_proc_bind): Provide fixit hints for
-Wdeprecated-openmp diagnostics.
(c_parser_omp_all_clauses): Move -Wdeprecated-openmp diagnostics
for to vs. enter here, add fixit hints for it. Adjust
c_parser_omp_clause_depend caller.
(c_parser_omp_depobj): Adjust c_parser_omp_clause_depend caller.
(c_parser_omp_master): Add MASTER_LOC argument. Provide fixit hints
for -Wdeprecated-openmp diagnostics.
(c_parser_omp_parallel): Adjust c_parser_omp_master caller.
(c_parser_omp_declare_target): Don't emit -Wdeprecated-openmp
warning for to vs. enter here.
(c_parser_omp_metadirective): Provide fixit hints for
-Wdeprecated-openmp diagnostics.
(c_parser_omp_construct): Adjust c_parser_omp_master caller.
* c-c++-common/gomp/52-deps.c: Change locations of 2 warnings for C.
* gcc.dg/gomp/deprecate-1.c: New test.
Alexandre Oliva [Sat, 13 Dec 2025 07:11:29 +0000 (04:11 -0300)]
[testsuite] allow relative line numbers in gnat.dg/
The wrappers for dg-warning and dg-error that handle relative line
numbers with process-message are only activated if the global
variables gcc_warning_prefix and gcc_error_prefix, respectively, are
defined.
gnat.exp didn't set these variables, so we couldn't use relative line
numbers.
Set them to empty strings, for minimal disruption.
for gcc/testsuite/ChangeLog
* lib/gnat.exp (gnat_init): Set gcc_warning_prefix and
gcc_error_prefix.
Alexandre Oliva [Sat, 13 Dec 2025 07:12:02 +0000 (04:12 -0300)]
[testsuite] xfail vect-121.c on ia32 [PR119293]
Once fre5 resolves conditional of the guard block for the vectorized
loop, cfgcleanup removes the edge that bypasses it, adjusting the
other edge probability, but not the edge's dest's count. The blocks
get combined, and their counts are merged, but nothing adjusts the
counts of the block that lost an incoming edge.
The incoming counts remain inconsistent from that point on, and get
reported as "Invalid sum of incoming counts" in the tree dump where
vect-121.c checks for the absence of this error.
That was added in response to a fix for a vectorizer profile count
management problem. This is a different profile count management
problem, so it makes sense to silence this failure marking it as
expected.
for gcc/testsuite/ChangeLog
PR tree-optimization/119293
* gcc.dg/vect/vect-121.c: XFAIL on ia32.
doc, pdp11: Clean up PDP-11 documentation [PR122243]
While working on this patch I saw that this target has an -mlra option
that still defaults to off. Although the LRA support was added in
2018 apparently it wasn't robust enough to enable by default. We are
supposed to be deleting reload support and all targets that don't use
LRA by default in GCC 16, so this target may be declared obsolete very
soon, but I've made the documentation of other options consistent with
the .opt files and conventions used for other targets anyway in case
either somebody who can build/test for this target switches the
default (see PR target/113947) or the reload removal is postponed.
gcc/ChangeLog
PR other/122243
* config/pdp11/pdp11.opt (m40, m45): Add RejectNegative.
* doc/invoke.texi (Option Summary) <PDP-11 Options>: Remove
redundant -mno- forms from the list.
(PDP-11 Options): Fix some markup issues. Merge documentation
of positive and negative forms of -mac0. Index negative forms
of -msplit, -mlra.
doc, or1k: Clean up OpenRISC option documentation [PR122243]
I'm not sure what the rationale is for having "RejectNegative" on all
of the options that control instruction usage except for -mdouble-float,
but with this patch the documentation matches what is in the .opt files.
gcc/ChangeLog
PR other/122243
* config/or1k/elf.opt (mnewlib): Mark obsolete option as
"Undocumented".
* config/or1k/or1k.opt (mcmov): Don't use future tense in doc string.
(msfimm): Likewise.
(mshftimm): Likewise.
* doc/invoke.texi (Option Summary) <OpenRISC Options>: Don't
document -mnewlib.
(OpenRISC Options): Likewise. Add @opindex entry for
-mno-double-float. Fix more instances of incorrect use of future
tense.
doc, nvptx: Clean up documentation of Nvidia PTX Options [PR122243]
gcc/ChangeLog
PR other/122243
* doc/invoke.texi (Option Summary) <Nvidia PTX Options>: Add
several missing options.
(Nvidia PTX Options): Correct index entry for -march-map. List
negative forms of -moptimize, muniform-simt, and -mgomp. Fix some
Texinfo markup issues.
doc, nds32: Clean up NDS32 option documentation [PR122243]
gcc/ChangeLog
PR other/122243
* doc/invoke.texi (Option Summary) <NDS32 Options>: Don't list
both positive and negative option forms.
(NDS32 Options): Consolidate separate entries for positive and
negative forms of the same option. Document missing negative
forms in the same style.
doc, msp430: Clean up MSP430 option documentation [PR122243]
gcc/ChangeLog
PR other/122243
* config/msp430/msp430.opt (mcpu): Mark deprecated option as
"Undocumented".
(mdevices-csv-loc=): Mark option not intended to be used by users
as "Undocumented".
* doc/invoke.texi (Option Summary) <MSP430 Options>: Fill in
argument syntax for options of the form -mfoo=@var{arg}. Don't
list deprecated option -mcpu=. Add missing entries for
-mwarn-devices-csv and -muse-lower-region-prefix.
(MSP430 Options): Similarly document argument syntax in the table
@item entries. Add @opindex entries for negative forms.
Delete documentation of deprecated -mcpu= option. Add
documentation for -muse-lower-region-prefix. Markup and
copy-editing fixes throughout the section.
doc, mn10300: Clean up MN10300 option documentation [PR122243]
gcc/ChangeLog
PR other/122243
* doc/invoke.texi (Option Summary) <MN10300 Options>: Remove
redundant -mno- forms from the list.
(MN10300 Options): Combine the documentation for -mmult-bug,
-mam33, -mliw, and -msetlb with the entries for the respective
negative forms. List and index the negative forms -mno-am33-2,
-mno-am34, -mno-return-pointer-on-d0, -mno-mul.x.
doc, mips: Clean up MIPS option documentation [PR122243]
gcc/ChangeLog
PR other/122243
* config/mips/mips.opt (mnoasmopt): Mark as "Undocumented".
* doc/invoke.texi (Option Summary) <MIPS Options>: Add missing
entries for -mel/-meb. Only list one of -mfoo/-mno-foo.
(MIPS Options): Document -meb/-mel as synonyms for -EB/-EL.
Add missing @opindex entries. Document -mmsa and -mfix4300.
Minor copy-editing for grammar and jargon issues.
doc, microblaze: Clean up MicroBlaze option documentation [PR122243]
gcc/ChangeLog
PR other/122243
* config/microblaze/microblaze.opt (Zxl-mode-bootstrap):
Mark as "Undocumented".
(Zxl-mode-executable): Likewise.
(Zxl-mode-novectors): Likewise.
(Zxl-mode-xilkernel): Likewise.
(Zxl-mode-xmdstub): Likewise.
(mxl-stack-check): Likewise.
(mno-clearbss): Likewise.
(mxl-mode-executable): Make help string more useful.
(mxl-mode-xmdstub): Likewise.
(mxl-mode-bootstrap): Likewise.
(mxl-mode-novectors): Likewise.
(mxl-mode-xilkernel): Mark as "Undocumented".
* doc/invoke.texi (Option Summary) <MicroBlaze Options>: Delete
entries for obsolete options now explicitly undocumented, and add
missing -mxl-prefetch option.
(MicroBlaze Options): Add missing @opindex entries for negative
option forms and list negative forms explicitly when appropriate.
Delete documentation for obsolete/deprecated options. Add
missing @opindex entries for the m[no-]xml-mode- options.
Add missing documentation for -mxl-prefetch.
doc, m68k: Clean up M680x0 option documentation [PR122243] [PR119404]
gcc/ChangeLog
PR other/122243
PR target/119404
* config/m68k/m68k.opt (mlra): Fix typo in help string.
* doc/invoke.texi (Option Summary) <M680x0 Options>: Remove
redundant -mno- forms from the list.
(M680x0 Options): Combine documentation for -mshort, mbitfield,
-msep-data, -mid-shared-library with that for their respective
negatives that were formerly separately listed. Add missing
@opindex entries.
doc, m32r: Clean up documentation of M32R/D options [PR122243]
gcc/ChangeLog
PR other/122243
* doc/invoke.texi (Option Summary) <M32R/D Options>: Remove
redundant -mno entry.
(M32R/D Options): Regularize form of @opindex entries for
various options of the form -mfoo=@var{value}. Combine
the documentation for -malign-loops and -mno-align-loops.
doc, loongarch: Clean up LoongArch option documentation [PR122243]
gcc/ChangeLog
PR other/122243
* doc/invoke.texi (Option Summary) <LoongArch Options>:
Remove redundant -mno forms from list. Fix formatting so that
there is uniformly two spaces between options on the same line.
(LoongArch Options): Copy-editing for grammar, etc. Add
@opindex for negative forms.
doc, ia64: Clean up documentation of IA-64 options [PR122243]
This backend is no longer maintained and was supposed to have been
deleted as of GCC 15, but since it is still part of GCC and documented
in the manual, I have gone ahead and fixed up its options
documentation for consistency with other active targets.
gcc/ChangeLog
PR other/122243
* config/ia64/ia64.opt (msched-prefer-data-spec-insns): Mark as
explicitly "Undocumented".
(msched-prefer-non-control-spec-insns): Likewise.
* doc/invoke.texi (Option Summary) <IA-64 Options>: Remove
explicitly undocumented and redundant mno- forms from the list.
(IA-64 Options): Remove documentation for already-deleted option
-mfused-add and the two explicitly undocumented options. Add
@opindex for negative forms and explicitly list the -mno-forms
of options that are enabled by default.
Note that the default for the -mlra option on HPPA was recently
changed from 0 to 1. This option has never been documented for this
target and reload is supposed to be going away entirely soon, so I
see no reason to document it now.
gcc/ChangeLog
PR other/122243
* config/pa/pa.opt (mbig-switch): Mark obsolete option as
"Undocumented".
(mjump-in-delay): Likewise.
(mlra): Likewise.
(mnosnake, msnake): Likewise.
* doc/invoke.texi (Option Summary) <HPPA Options>: Remove
deliberately undocumented options from list. Remove redundant
negative/positive forms from list. Fix formatting so there is
uniformly two spaces between options on the same line.
(HPPA Options): Remove documentation for obsolete options.
Add @opindex for negative forms. Properly list -mwsio instead
of just referring to it in the -msio docs. Light copy-editing to
fix markup, jargon, etc.
doc, h8300: Clean up H8/300 option and attribute documentation [PR122243]
Comparing the documentation in invoke.texi with hs8300.opt, I spotted
a few options in the latter that were missing documentation, and added
it.
I wanted to add a link to the "monitor" attribute
referenced in the existing docs for this option, but found that was
also missing, along with docs for the "OS_Task" attribute; so I fixed
those problems while I was at it.
gcc/ChangeLog
PR other/122243
* config/h8300/h8300.opt (mexr, mno-exr): Add FIXME re ambiguity
for -mno-exr semantics.
* doc/extend.texi (H8/300 Function Attributes): Document
monitor and OS_Task attributes.
* doc/invoke.texi (Option Summary) <H8/300 Options}: Add -msx,
-ms2600, -mquickcall, -mslowbyte. Combine -mexr and -mno-exr.
(H8/300 Options): Likewise. Add @opindex entries for options
that have negative forms.
doc, arc: Clean up ARC option documentation [PR122243]
The ARC front end presently has a large number of options that are
explicitly deprecated, either by the "Warn" option or by being
documented as such in the GCC manual. The manual text has documented
a long list of obsolete options with a warning that they will be removed
completely in a future release since at least GCC 5, 10+ years ago.
Some of documented options have, in fact, already been deleted.
This patch does *not* delete the remaining obsolete options, but only
marks them as "Undocumented" in the .opt file and removes the
documentation to reduce clutter in the manual. I've also added missing
index entries for the remaining options to the manual.
gcc/ChangeLog
PR other/122243
* config/arc/arc.opt: Mark -mbig-endian, -mlittle-endian,
-mmixed-code, -mno-mpy, -margonaut, -munalign-prob-threshold=,
-mannotate-align, -malign-call, -mRcq, -mRcw, -mbbit-peephole,
-mcompact-casesi, -mq-class, -mexpand-adddi, -mcrc, -mdsp-packa,
-mdvbf, -mtelephony, -mrtsc, -EB, -EL, -mrla, -mEA, and
-multcost= as "Undocumented".
* doc/invoke.texi: Remove documentation for the above options.
plus -mmac-d16 and -mmac-24 (which were already marked as
"Undocumented"). Likewise remove documentation for
-mbarrel_shifter, -mdpfp_compact, -mdpfp_fast, -mdsp_packa,
-mmac_24, -mmac_d16, -mspfp_compact, and -mspfp_fast, which
had already been deleted from arc.opt at some point.
Add index entries for the -mno- forms of remaining options that
have them. Document positive forms of -mno-brcc and -mno-dpfp-lrsr.
arc: Fix positive form of -mno-brcc and -mno-dpfp-lrsr options [PR122243]
These two options are defined in the negative form and don't have the
RejectNegative property so they end up having positive forms beginning
with "-mno-no-", which is confusing. I've inverted the sense of the
option instead (so that the positive forms are -mbrcc and
-mdpfp-lrsr).
I'm not set up to build or test gcc for ARC but this is a straightforward
change similar to fixes I've made for other target-inspecific options.
Either this fix or adding RejectNegative would break any makefiles
that use the (undocumented) -mno-no forms, though.
gcc/ChangeLog
PR other/122243
* config/arc/arc.opt (-mno-brcc, -mno-dpfp-lrsr): Redefine in
the positive sense.
Andrew Pinski [Wed, 3 Dec 2025 21:46:43 +0000 (13:46 -0800)]
cgraph: Move next/previous from symtab to toplevel_node [PR122955]
Currently the GC marker functions don't support chain_next on non-toplevel
tag structures (and does not error out either). So since r16-4747-g529c25ed6e0a06
if there are a lot of chained symtab_nodes (happens most likely with LTO), the GC
marker function could cause a stack overflow because of the recusive nature of the marker.
This fixes the problem by moving next/previous to toplevel_node. I had originally
thought about doing chain_next/chain_prev and using is_a<symtab_node *> to get if
it was symtab_node and then used the next/previous from there. But it was noticed that
asm_node had a next too (though not using chain_next) so adding a previous is not going
to much more space anyways; there will not be many toplevel inline-asm anyways.
Bootstraped and tested on x86_64-linux-gnu.
PR ipa/122955
gcc/ChangeLog:
* cgraph.h (toplevel_node): Add next and previous fields.
Add chain_next and chain_prev to GTY.
(symtab_node): Remove next and previous field. Remove chain_next and chain_prev
from the GTY.
(asm_node): Remove next field.
(symtab_node::next_defined_symbol): Use save_as_a<symtab_node*> around next.
(symbol_table::unregister): Likewise
(FOR_EACH_SYMBOL): Likewise
(symbol_table::first_defined_symbol): Likewise
(symbol_table::first_variable): Likewise
(symbol_table::next_variable): Likewise
(symbol_table::first_static_initializer): Likewise
(symbol_table::next_static_initializer): Likewise
(symbol_table::first_defined_variable): Likewise
(symbol_table::next_defined_variable): Likewise
(symbol_table::first_defined_function): Likewise
(symbol_table::next_defined_function): Likewise
(symbol_table::first_function): Likewise
(symbol_table::next_function): Likewise
(symbol_table::first_function_with_gimple_body): Likewise
(symbol_table::next_function_with_gimple_body): Likewise
* cgraphunit.cc (analyze_functions): Likewise
(output_in_order): Likewise
* lto-streamer-out.cc (lto_output): Use save_as_a<asm_node*> around next.
* symtab.cc (symtab_node::verify_symtab_nodes): Likewise.
gcc/lto/ChangeLog:
* lto-partition.cc (lto_1_to_1_map): Use save_as_a<asm_node*> around next.
(create_asm_partition): Likewise.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Nathaniel Shead [Thu, 11 Dec 2025 21:57:20 +0000 (08:57 +1100)]
c++: Add missing explanations for is_constructible<Abstract>
Checking whether an abstract class type is constructible currently is
missing an explanation. With this patch, we now get the following
output for an abstract type:
test.cpp:7:20: error: static assertion failed
7 | static_assert(std::is_default_constructible_v<A>);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
• ‘A’ is not default constructible, because
• error: cannot construct an object of abstract type ‘A’
• because the following virtual functions are pure within ‘A’:
test.cpp:3:8:
3 | struct A {
| ^
• ‘virtual void A::foo()’
test.cpp:4:18:
4 | virtual void foo() = 0;
| ^~~
Before this patch, the diagnostic stopped after the "A is not default
constructible, because" message.
gcc/cp/ChangeLog:
* method.cc (constructible_expr): Emit diagnostics for abstract
types.
* typeck2.cc (abstract_virtuals_error): Use more accurate
wording for default case, and remove extranneous whitespace
in favour of a nesting level.
gcc/testsuite/ChangeLog:
* g++.dg/ext/is_constructible9.C: Add to testcase.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
Tobias Burnus [Fri, 12 Dec 2025 21:06:42 +0000 (22:06 +0100)]
OpenMP: Small fortran/intrinsic.texi + libgomp.texi update
Some followup to the OpenMP 5.2 version bump - and marking some features
as partially implemented: uses_allocators (only predefined allocators),
'declare mapper' (only C/C++, some but few loose ends), map iterator
(C/C++ only - and several loose ends, most fixed by approved patches
that still have to land after minor modifications).
gcc/fortran/ChangeLog:
* intrinsic.texi (OpenMP Modules OMP_LIB and OMP_LIB_KINDS): Link
also to OpenMP 6.0, move 'partially supported' to the end of the
list of OpenMP versions. Mark 'omp_lock_hint_...' and
'omp_atv_sequential' constants as deprecated.
libgomp/ChangeLog:
* libgomp.texi (OpenMP Implementation Status): Add missing '@tab';
claim initial partial support for 'declare mapper',
'uses_allocators', and map iterators.
Chung-Lin Tang [Fri, 12 Dec 2025 20:20:33 +0000 (21:20 +0100)]
OpenMP: Add uses_allocators parser support to C/C++
This is the parser part for C/C++, including early middle end bits,
but then stops with a 'sorry, unimplemented'. It also adds support
for omp_null_alloctor (6.0 clarificiation, is to be ignored). As
predefined allocators do not require any special handling in GCC,
those are ignored. Therefore, this patch fully supports
uses_allocators that only use predefined allocators - only printing
a sorry for those that use the (implicit) traits/memspace modifer.
(The parsing support for Fortran was added before; this patch just
adds omp_null_allocator support to Fortran. The sorry message for
Fortran is also still in the FE and not in gimplify.cc, but that
only make a difference for the original dump.)
Except for some minor fixes, this is the same patch as
https://gcc.gnu.org/pipermail/gcc-patches/2025-November/700345.html
with the middle-end + libgomp handling excluded. That patch in turn
is based on previous patches, the latest previous one was
https://gcc.gnu.org/pipermail/gcc-patches/2023-November/637415.html
and, in particular, the C/C++ parser style was updated following the
review comments. Also, more C++ template-handling fixes have been
applied.
* openmp.cc (resolve_omp_clauses): Handle omp_null_allocator.
* trans-openmp.cc (gfc_trans_omp_clauses): Mention it in a comment.
gcc/ChangeLog:
* gimplify.cc (gimplify_scan_omp_clauses): Handle uses_allocators
by printing a 'sorry, unimplemented' and removing it.
* tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_USES_ALLOCATORS.
* tree.cc (omp_clause_num_ops, omp_clause_code_name): Likewise.
* tree-pretty-print.cc (dump_omp_clause): Handle it.
* tree.h (OMP_CLAUSE_USES_ALLOCATORS_ALLOCATOR,
OMP_CLAUSE_USES_ALLOCATORS_MEMSPACE,
OMP_CLAUSE_USES_ALLOCATORS_TRAITS): New.
libgomp/ChangeLog:
* testsuite/libgomp.fortran/uses_allocators_1.f90: Add check for
omp_null_allocator.
* testsuite/libgomp.fortran/uses_allocators-7.f90: New test.
gcc/testsuite/ChangeLog:
* c-c++-common/gomp/uses_allocators-1.c: New test.
* c-c++-common/gomp/uses_allocators-2.c: New test.
* c-c++-common/gomp/uses_allocators-4.c: New test.
* c-c++-common/gomp/uses_allocators-7.c: New test.
* g++.dg/gomp/deprecate-2.C: New test.
* g++.dg/gomp/uses_allocators-1.C: New test.
* gcc.dg/gomp/deprecate-2.c: New test.
Co-authored-by: Tobias Burnus <tburnus@baylibre.com> Co-authored-by: Andrew Stubbs <ams@baylibre.com>
Andrew Pinski [Tue, 9 Dec 2025 09:09:53 +0000 (01:09 -0800)]
ldist: Fix probability on loop exit
While moving the phi part of removal of forwarder blocks,
I noticed that I was getting some failures due to "mismatch counts".
I worked around the issue by disabling the case where the forwarder
block would just get merged. I have now gone back and found
the problem is in ldist where it is removing the loop
by changing the exit to always exit but forgot to update
the edge to always probability. This fixes that and
also removes a few of the "mismatch counts".
Bootstrapped and tested on x86_64-linux-gnu.
gcc/ChangeLog:
PR tree-optimization/103680
* tree-loop-distribution.cc (destroy_loop): Set probability
of the exit edge to be always.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Andrew Pinski [Tue, 9 Dec 2025 06:53:06 +0000 (22:53 -0800)]
cfg: Fix count when creating new forwarder block
This was a bug previously but maybe did't matter as most of
the time the block was going to be removed after cddce.
Anyways the problem here is the count of the new bb was missing
of the first edge that was moved to it. So the fix is reuse the count
after the splitting of the edge as the initial value instead of 0.
This does not fix gcc.target/i386/pr90178.c with -m32, but at least
we don't get any more warning saying the incorrect count happening.
Bootstrapped and tested on x86_64-linux-gnu.
gcc/ChangeLog:
PR tree-optimization/103680
* tree-cfg.cc (make_forwarders_with_degenerate_phis): Fix
initial value of the count to new bb.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
The second argument for builtin s390_vec_load_bndry must be an integer
constant. The C++ front end wraps a constant inside a NON_LVALUE_EXPR
which we need to unpack first. Otherwise we bail out in
s390_adjust_builtin_arglist():
t.C: In function ‘__vector(4) unsigned int test(const unsigned int*)’:
t.C:7:42: error: constant value required for builtin ‘__vector(16) signed char __builtin_s390_vlbb(const void*, int)’ argument 2
7 | return __builtin_s390_vec_load_bndry (x, 4096);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
gcc/ChangeLog:
* config/s390/s390-c.cc (s390_adjust_builtin_arglist): Fix
builtin s390_vec_load_bndry for C++.
A difference in front ends is that in contrast to C the C++ FE does no
array-to-pointer conversion prior calling resolve_overloaded_builtin().
However, we depend on this for finding the proper overloaded builtin or
in case of direct expansion. Therefore, do the conversion manually.
gcc/ChangeLog:
* config/s390/s390-c.cc (s390_resolve_overloaded_builtin):
Perform array-to-pointer conversion for C++.
gcc/testsuite/ChangeLog:
* g++.target/s390/builtin-array-arg-1.C: New test.
* gcc.target/s390/builtin-array-arg-1.c: New test.
David Malcolm [Fri, 12 Dec 2025 17:23:34 +0000 (12:23 -0500)]
analyzer: reimplement supergraph to eliminate function_point and stmt_finder
GCC's static analyzer code has become hard to debug and extend.
I've realized that the core data structures within it for tracking
positions in the user's code are clunky and make things more difficult
than they need to be.
The analyzer has a data structure called the "supergraph" which unifies
all CFGs and the callgraph into a single directed graph expressing
control flow and function calls in the user's code. The core job of the
analyzer is to walk paths in the supergraph to build a directed graph
called the exploded graph, which combines control flow and data flow,
and uncovers problems as it does so (e.g. double-free bugs).
Previously, the nodes in the supergraph closely matched basic blocks in
the gimple CFG representation in the hope that this would help the
analyzer scale better, using a class function_point to refer to places
in the code, such as *within* a basic block/supernode. This approach
needed lots of awkward special cases and workarounds to deal with state
changes that happen mid-node, which complicated the implementation and
make debugging it hard.
This patch reimplements the analyzer's supergraph:
* eliminate class function_point in favor of a very fine-grained
supergraph, where each node in the graph represents a location in the
user's program, and each edge in the graph represents an operation (with
no-op edges for showing changing locations). The debug option
"-fanalyzer-fine-grained" becomes redundant.
* eliminate the class hierarchy inheriting from class superedge in
favor of having each superedge optionally own an "operation", to better
express the state transitions along edges (composition rather than
inheritance), and splitting up the more complicated cases into
multiple operations/edges (making debugging easier and reasoning about
state transitions clearer).
* perform various post-processing "passes" to the supergraph after it's
initially constructed but before performing the analysis, such as
simplifying the graph, improving source location information, etc
* eliminate class stmt_finder (which was always something of a hack) in
favor of improving user source locations in the supergraph, using
class event_loc_info more consistently, and a new class
pending_location::fixup_for_epath for the most awkward cases (leaks)
* precompute and cache various properties in operations, such as for
switch edges and for phi edges, rather than performing work each time we
visit an edge.
Advantages:
* The implementation is much simpler, easier to understand and debug,
and has much clearer separation of responsibilities.
* Locations for diagnostics are somewhat improved (due to being more
consistent about using the goto_locus field of CFG edges when
constructing the supergraph, and fixing up missing location data from
gimple stmts).
* The analyzer now detects a missing "return" from a non-void-returning
function (albeit as a read of uninitialized "<return-value>"), which
found many lurking true +ves in the test suite. I can fix the wording
of this case as a follow-up.
Disadvantages:
* The supergraph is much larger than before (one node per gimple stmt,
rather than per basic block) - but the optimizer that runs after the
supergraph is built simplifies it somewhat (and I have various ideas for
future simplifications which I hope will help the analyzer scale).
* all edges in the supergraph are intraprocedural, making "supergraph"
a misnomer.
Other notes:
* I tried to maintain the behavior of -fanalyzer as closely as possible,
but there are changes to the testsuite output. These mostly are places
where the exploration of the exploded graph leads to nodes not being
merged as well as the previous implementation on a particular test case,
leading to the analysis hitting a termination limit and bailing out.
So I expect the analyzer's behavior to change somewhat. I had to add
xfails in various places - but was able to remove xfails in others.
* the testsuite was running with -fanalyzer-call-summaries enabled,
which is not the default for users. The new implementation uncovered
numerous pre-existing bugs in -fanalyzer-call-summaries, so the patch
disables this within the testsuite, matching the default for users.
Fixing those bugs can be done separately from the patch.
* the only performance data I have so far is with a debug rather than
release build. "wall" time spent in the analyzer shows a slight
improvement overall, but with one new outlier in the integration
testsuite that now takes over an hour (specifically,
qemu-7.2.0/build/target_hexagon_decode.c) but I'd like to go ahead with
pushing this, and treat that specific slowdown as a bug.
I posted an incomplete version of this before the close of stage 1 here:
https://gcc.gnu.org/pipermail/gcc-patches/2025-November/700883.html
Although the patch is a very large change to -fanalyzer, the changes are
confined to that component (apart from a trivial addition of
INCLUDE_DEQUE/#include <deque> to system.h), so I want to apply this
patch now in stage 3: it's a big quality-of-life improvement when
debugging -fanalyzer.
gcc/ChangeLog:
PR analyzer/122003
* Makefile.in (ANALYZER_OBJS): Add analyzer/ops.o,
analyzer/supergraph-fixup-locations.o,
analyzer/supergraph-simplify.o, and analyzer/supergraph-sorting.o.
* digraph.h (dnode::add_in_edge): New.
(dnode::remove_in_edge): New.
(dnode::add_out_edge): New.
(dnode::remove_out_edge): New.
(dnode::m_preds): Make public.
(dnode::m_succs): Likewise.
(dnode::find_edge_idx): New.
(dedge::edge_t): New typedef.
(dedge::m_src): Make non-const.
(dedge::m_dest): Likewise.
(dedge::set_dest): New.
(digraph::add_any_extra_stmts): New.
(digraph<GraphTraits>::dump_dot_to_pp): Call it.
* doc/analyzer.texi: Update for rewrite of supergraph.
* doc/invoke.texi (fanalyzer-fine-grained): Make this as a no-op
preserved for backwards compatibility.
(fanalyzer-simplify-supergraph): Document new option.
(fdump-analyzer-supergraph): Update for changes to output.
* gdbhooks.py (AnaSupernodePrinter.to_string): Update for renaming
of supernode::m_index to supernode::m_id.
* system.h: Include <deque> if INCLUDE_DEQUE was defined.
gcc/analyzer/ChangeLog:
PR analyzer/122003
* analyzer-logging.h (class log_nesting_level): New.
(log_nesting_level::log_nesting_level): New.
(log_nesting_level::~log_nesting_level): New.
* analyzer.cc (is_cxa_end_catch_p): New.
* analyzer.opt (fdump-analyzer-callgraph): Make this as a no-op
preserved for backwards compatibility.
(fanalyzer-fine-grained): Likewise.
(fanalyzer-simplify-supergraph): New.
* bounds-checking.cc (strip_types): Update for changes to
widening_svalue.
* call-details.h: Include "pending-diagnostic.h".
* call-info.cc (custom_edge_info::get_dot_attrs): New.
(call_info::add_events_to_path): Add pending_diagnostic & param.
Fix indentation.
* call-info.h (call_info::add_events_to_path): Add
pending_diagnostic & param.
* call-string.cc (call_string::element_t::operator==): Reimplement.
(call_string::element_t::cmp): New.
(call_string::element_t::get_caller_function): Likewise.
(call_string::element_t::get_callee_function): Likewise.
(call_string::element_t::get_call_snode_in_caller): New.
(call_string::element_t::get_return_snode_in_caller): New.
(call_string::element_t::get_call_stmt): New.
(call_string::print): Update for new implementation.
(call_string::to_json): Likewise.
(call_string::push_call): Likewise.
(call_string::count_occurrences_of_function): Likewise.
(call_string::cmp): Likewise.
(call_string::get_callee_node): Delete.
(call_string::get_caller_node): Convert into...
(call_string::get_return_node_in_caller): ...this new function.
(call_string::validate): Update for new implementation.
(call_string::recursive_log): Likewise.
* call-string.h (class call_superedge): Delete forward decl.
(class return_superedge): Likewise.
(class call_and_return_op): New forward decl.
(struct call_string::element_t): Reimplement using
call_and_return_op, rather than relying on interprocedural edges
in the supergraph.
(class call_string): Likewise.
* call-summary.cc (call_summary::get_fndecl): Reimplement.
(call_summary_replay::convert_svalue_from_summary_1): Update for
changes to widening_svalue.
* checker-event.cc (event_kind_to_string): Update for renamings
of event_kind::{call_edge -> call_} and
event_kind::{return_edge -> return_}.
(region_creation_event_debug::print_desc): Update for change to
event_loc_info.
(state_change_event::state_change_event): Pass in event_loc_info
rather than stack_depth, and pass it to checker_event ctor.
(superedge_event::get_callgraph_superedge): Delete.
(superedge_event::should_filter_p): Reimplement in terms of
get_any_cfg_edge.
(superedge_event::get_call_and_return_op): New.
(superedge_event::superedge_event): Drop m_eedge and
m_critical_state. Add assertion that the superedge is non-null.
(cfg_edge_event::get_cfg_superedge): Delete.
(cfg_edge_event::cfg_edge_event): Add "op" param, and remove
assertion refering to kinds of superedge.
(cfg_edge_event::get_meaning): Reimplement without
cfg_superedge.
(cfg_edge_event::get_cfg_edge): New.
(start_cfg_edge_event::print_desc): Use m_op. Update for renaming
of superedge::m_index to superedge::m_id.
(start_cfg_edge_event::maybe_describe_condition): Reimplement in
ops.cc as gcond_edge_op::maybe_describe_condition.
(start_cfg_edge_event::should_print_expr_p): Reimplement in ops.cc
as gcond_edge_op::should_print_expr_p.
(call_event::call_event): Update for renaming of event_kind. Drop
assertion about superedge kind.
(call_event::print_desc): Update for consolidation of m_var and
m_critical_state into a struct.
(return_event::return_event): Inherit directly from checker_event.
Drop assertion referring to kinds of superedge. Initialize m_edge
and m_call_and_return_op.
(return_event::print_desc): Update for change to m_critical_state.
* checker-event.h (enum class event_kind): Rename call_edge to
call_, and return_edge to return_.
(state_change_event::state_change_event): Update for changes to
location-handling in base class ctor.
(state_change_event::record_critical_state): Drop this, moving
it to special-cases in the subclasses that need it.
(state_change_event::get_callgraph_superedge): Delete.
(superedge_event::get_call_and_return_op): New vfunc decl.
(superedge_event::m_var, superedge_event::m_critical_state): Drop
these fields from this class, combining them into a new struct
and moving the fields to the interprocedural event subclasses
where they make sense.
(cfg_edge_event::get_cfg_superedge): Delete.
(cfg_edge_event::get_cfg_edge): Add.
(cfg_edge_event::cfg_edge_event): Update for changes to location
handling in base class ctor. Add "op".
(cfg_edge_event::m_op): New field.
(start_cfg_edge_event::start_cfg_edge_event): Update for changes
to base class ctor.
(start_cfg_edge_event::maybe_describe_condition): Drop.
(end_cfg_edge_event::end_cfg_edge_event): Update for changes to
base class ctor.
(catch_cfg_edge_event::catch_cfg_edge_event): Likewise.
(struct critical_state): New struct.
(call_event::record_critical_state): New decl.
(call_event::m_critical_state): New field.
(class return_event): Inherit from checker_event, rather than
superedge_event.
(return_event::get_call_and_return_op): New.
(return_event::record_critical_state): New.
(return_event::m_call_and_return_op): New field.
(return_event::m_critical_state): New field.
* common.h: Define INCLUDE_SET.
(class cfg_superedge): Drop forward decl.
(class switch_cfg_superedge): Likewise.
(class eh_dispatch_cfg_superedge): Likewise.
(class eh_dispatch_try_cfg_superedge): Likewise.
(class eh_dispatch_allowed_cfg_superedge): Likewise.
(class callgraph_superedge): Likewise.
(class call_superedge): Likewise.
(class return_superedge): Likewise.
(class stmt_finder): Likewise.
(class function_point): Likewise.
(class feasibility_state): New forward decl.
(class uncertainty_t): Likewise.
(useful_location_p): New.
(known_function::check_any_preconditions): New.
(custom_edge_info::get_dot_attrs): New decl.
(custom_edge_info::add_events_to_path): Add param
"pending_diagnostic &pd".
(is_cxa_end_catch_p): New decl.
* constraint-manager.cc
(bounded_ranges_manager::get_or_create_ranges_for_switch): Delete.
(bounded_ranges_manager::create_ranges_for_switch): Delete.
* constraint-manager.h
(bounded_ranges_manager::get_or_create_ranges_for_switch): Delete
decl.
(bounded_ranges_manager::create_ranges_for_switch): Likewise.
(bounded_ranges_manager::make_case_label_ranges): Make public for
use by ops code.
(bounded_ranges_manager::edge_cache_t): Delete.
(bounded_ranges_manager::m_edge_cache): Delete.
* diagnostic-manager.cc (pending_location::pending_location): New
ctor implementations.
(pending_location::to_json): New.
(epath_finder::get_best_epath): Rename param to "target_enode".
Drop param "target_stmt". Update for renaming of
supernode::m_index to m_id.
(epath_finder::explore_feasible_paths): Drop param "target_stmt".
(process_worklist_item): Likewise.
(saved_diagnostic::saved_diagnostic): Pass in param "ploc" by
rvalue reference and store it in m_ploc. Drop m_stmt_finder and
other fields made redundant by m_ploc.
(saved_diagnostic::get_supernode): New.
(saved_diagnostic::operator==): Update for changes to
location-tracking.
(saved_diagnostic::to_json): Update.
(saved_diagnostic::dump_as_dot_node): Drop m_stmt.
(saved_diagnostic::calc_best_epath): Update for change to
location-tracking.
(saved_diagnostic::supercedes_p): Likewise.
(saved_diagnostic::maybe_add_sarif_properties): Likewise.
(get_emission_location): Delete.
(diagnostic_manager::add_diagnostic): Pass "ploc" by rvalue
reference, moving it to the saved_diagnostic. Update early
rejection check, and call fixup_location before-hand.
(class dedupe_key): Drop m_stmt field, and update for changes
to saved_diagnostic.
(dedupe_winners::add): Call get_best_epath here, and call
fixer_for_epath on it.
(diagnostic_manager::emit_saved_diagnostics): Update for
changes to saved_diagnostic and supernode.
(diagnostic_manager::emit_saved_diagnostic): Likewise.
Use the pending_location from the saved_diagnostic for the
location of the final event, and for the primary location of the
diagnostic itself.
(diagnostic_manager::build_emission_path): Use useful_location_p.
(state_change_event_creator::on_global_state_change): Update for
changes to location-tracking.
(state_change_event_creator::on_state_change): Likewise.
(struct null_assignment_sm_context): Reimplement within ops.cc.
(diagnostic_manager::add_events_for_eedge): Reimplement.
(diagnostic_manager::add_events_for_superedge): Delete in favor of
control_flow_op::add_any_events_for_eedge.
(diagnostic_manager::prune_for_sm_diagnostic): Update call/return
for event_kind renamings, and to use call_and_return_op rathern
than callgraph_superedge.
(diagnostic_manager::consolidate_conditions): Port from
cfg_superedge to get_cfg_edge.
* diagnostic-manager.h: Include "analyzer/supergraph.h" and
"analyzer/event-loc-info.h".
(struct pending_location): Move decl earlier in file. Replace
the existing specified ctors with 3 new ones. Add comments.
(class pending_location::fixer_for_epath): New.
(pending_location::get_location): New.
(pending_location::to_json): New decl.
(pending_location::m_snode): Drop redundant field.
(pending_location::m_event_loc_info): New field, replacing m_stmt
and m_loc.
(pending_location::m_finder): Replace with...
(pending_location::m_fixer_for_epath): ...this new field.
(make_ploc_fixer_for_epath_for_leak_diagnostic): New decl.
(saved_diagnostic::saved_diagnostic): Pass in param "ploc" by
rvalue reference and store it in m_ploc.
(saved_diagnostic::get_supernode): New.
(saved_diagnostic::m_ploc): New field, replacing m_enode,
m_snode, m_stmt, m_stmt_finder, and m_loc.
(diagnostic_manager::add_diagnostic): Pass ploc as rvalue
reference.
(diagnostic_manager::add_events_for_superedge): Delete decl.
* engine.cc: Include "gimple-predict.h" and
"analyzer/impl-sm-context.h".
(impl_region_model_context::impl_region_model_context): Drop
stmt_finder.
(impl_region_model_context::warn): Convert to...
(impl_region_model_context::warn_at): ...this.
(class impl_sm_context): Move to impl-sm-context.h.
(impl_region_model_context::get_state_map_by_name): Drop
m_stmt_finder.
(class leak_stmt_finder): Reimplement as...
(class leak_ploc_fixer_for_epath): ...this.
(make_ploc_fixer_for_epath_for_leak_diagnostic): New.
(returning_from_function_p): Update for supergraph changes.
(impl_region_model_context::on_state_leak): Port from
leak_stmt_finder to leak_ploc_fixer_for_epath.
(impl_region_model_context::on_condition): Update for
location-handling changes.
(impl_region_model_context::on_bounded_ranges): Likewise.
(impl_region_model_context::on_phi): Likewise.
(impl_region_model_context::get_pending_location_for_diag): New.
(exploded_node::status_to_str): Add status::special.
(exploded_node::get_processed_stmt): Delete.
(exploded_node::dump_dot): Elide state if we have a single
predecessor and the state hasn't changed.
(exploded_node::dump_processed_stmts): Delete.
(exploded_node::on_stmt): Delete, reimplementing in ops.cc as
gimple_stmt_op::execute_on_state, call_and_return_op::execute, and
operation::handle_on_stmt_for_state_machines.
(exploded_node::on_stmt_pre): Delete, reimplementing in ops.cc as
call_and_return_op::make.
(exploded_node::on_stmt_post): Delete.
(class call_summary_edge_info): Move to ops.cc.
(exploded_node::replay_call_summaries): Delete.
(exploded_node::replay_call_summary): Delete.
(exploded_node::on_edge): Delete.
(exploded_node::on_longjmp): Eliminate ambiguous "setjmp_point"
and "next_point" in favor of "point_before_setjmp" and
"point_after_setjmp".
(exploded_graph::unwind_from_exception): Update for changes to
program_point.
(exploded_node::on_throw): Convert "after_throw_point" to a param.
(exploded_node::on_resx): Delete.
(exploded_node::detect_leaks): Update for renaming of
supernode::return_p to supernode::exit_p, and drop stmt param of
impl_region_model_context ctor.
(dynamic_call_info_t::update_model): Delete.
(dynamic_call_info_t::add_events_to_path): Delete.
(interprocedural_call::print): New.
(interprocedural_call::get_dot_attrs): New.
(interprocedural_call::update_state): New.
(interprocedural_call::update_model): New.
(interprocedural_call::add_events_to_path): New.
(interprocedural_return::print): New.
(interprocedural_return::get_dot_attrs): New.
(interprocedural_return::update_state): New.
(interprocedural_return::update_model): New.
(interprocedural_return::add_events_to_path): New.
(rewind_info_t::add_events_to_path): Add pending_diagnostic &
param.
(exploded_edge::dump_dot_label): Drop superedge kinds. Show
op vs no-op. Flush before printing any superedge label, and
escape that label.
(exploded_edge::maybe_get_stmt): New.
(exploded_edge::maybe_get_op): New.
(stats::stats): Update for change to m_num_nodes;
(stats::log): Likewise.
(stats::dump): Likewise.
(stats::get_total_enodes): Likewise.
(strongly_connected_components::strongly_connected_components):
Update for changes to supergraph.
(strongly_connected_components::dump): Show the stack. Update for
changes to supernode.
(strongly_connected_components::to_json): Update for changes to
supergraph.
(strongly_connected_components::strong_connect): Rename "index" to
"id". Drop superedge kinds.
(worklist::key_t::cmp): Compare BB indexes before snode ids.
Drop function_point.
(exploded_graph::exploded_graph): Update stats initialization.
(tainted_args_function_info::update_model): Reimplement.
(tainted_args_function_info::add_events_to_path): Add param.
(exploded_graph::get_or_create_node): Check for recursion limit
here, rather than in program_point::on_edge and
exploded_graph::maybe_create_dynamic_call. Only merge state
for points with state_merge_at_p. Update stats tracking for
changes to supergraph. Fix wording of log of state.
(exploded_graph::get_or_create_per_call_string_data): Update for
supergraph changes.
(tainted_args_call_info::update_model): Reimplement.
(tainted_args_call_info::add_events_to_path): Add param.
(exploded_graph::process_worklist): Drop assertions that nodes
have no successors, due to some cases during unwinding exceptions.
Update call to maybe_process_run_of_before_supernode_enodes to
call to maybe_process_run_of_enodes, and only at points for
which state_merge_at_p. Reimplement "too complex" check.
(exploded_graph::maybe_process_run_of_before_supernode_enodes):
Convert to...
(exploded_graph::maybe_process_run_of_enodes): ...this. Only
consider nodes with a single successor in the supergraph and for
which that superedge supports_bulk_merge_p. Port state updates to
using operation::update_state_for_bulk_merger.
(stmt_requires_new_enode_p): Delete.
(state_change_requires_new_enode_p): Delete.
(exploded_graph::maybe_create_dynamic_call): Delete.
(class impl_path_context): Reimplement in ops.cc.
(class jump_through_null): Move to region-model.cc.
(exploded_graph::process_node): Use location_t from supernode,
rather than trying to have a stmt associated with a supernode.
Drop switch on program_point kind, instead using the operation, if any,
from the superedge.
(exploded_graph::get_or_create_function_stats): Update computation
of num_supernodes for the function.
(exploded_graph::print_bar_charts): Update for supergraph changes.
(exploded_graph::dump_stats): Likewise.
(exploded_graph::dump_states_for_supernode): Delete.
(exploded_graph::to_json): Update comment.
(exploded_path::find_stmt_backwards): Update for supergraph
reimplementation.
(exploded_path::feasible_p): Drop "last_stmt".
(feasibility_state::maybe_update_for_edge): Move most of
implementation to ops and custom_edge_infos.
(feasibility_state::update_for_stmt): Delete.
(supernode_cluster::dump_dot): Update for supernode changes.
(supernode_cluster::cmp_ptr_ptr): Likewise.
(exploded_graph::dump_exploded_nodes): Update for
location-handling changes, and for changes to supergraph
representation.
(class viz_callgraph_node): Delete
(class viz_callgraph_edge): Delete.
(class viz_callgraph): Delete.
(class viz_callgraph_cluster): Delete.
(struct viz_callgraph_traits): Delete.
(dump_callgraph): Delete.
(exploded_graph_annotator::exploded_graph_annotator): Update for
supernode::m_index becoming supernode:m_id.
(exploded_graph_annotator::add_node_annotations): Reimplement to
show enodes within the node for the supernode.
(exploded_graph_annotator::print_enode_port): New.
(exploded_graph_annotator::print_enode): Add port.
(exploded_graph_annotator::print_saved_diagnostic): Drop stmt.
(exploded_graph_annotator::m_enodes_per_snodes): Convert to...
(exploded_graph_annotator::m_enodes_per_snode_id): ...this, using
std::vector.
(maybe_dump_supergraph): New.
(impl_run_checkers): Create region_model_manager before supergraph
and pass it to supergraph ctor. Dump the original form of the
supergraph, then call fixup_locations, simplify, and sort_nodes on
the supergraph, dumping it at each stage. Drop dump_callgraph.
Replace dump to "NAME.supergraph-eg.dot" with dump to
"NAME.supergraph.N.eg.dot".
* event-loc-info.h (event_loc_info::event_loc_info): Add ctors taking
const exploded_node * and const program_point &.
* exploded-graph.h: Add include of "analyzer/region-model.h".
(impl_region_model_context::impl_region_model_context): Add default
for "stmt" param. Drop "stmt_finder" param.
(impl_region_model_context::warn): Convert to...
(impl_region_model_context::warn_at): ...this.
(impl_region_model_context::get_pending_location_for_diag): New.
(impl_region_model_context::m_stmt_finder): Drop.
(struct exploded_node::on_stmt_flags): Drop.
(exploded_node::on_stmt): Drop.
(exploded_node::on_stmt_pre): Drop.
(exploded_node::on_stmt_post): Drop.
(exploded_node::replay_call_summaries): Drop.
(exploded_node::replay_call_summary): Drop.
(exploded_node::on_edge): Drop.
(exploded_node::on_throw): Add "after_throw_point" param.
(exploded_node::on_resx): Drop.
(exploded_node::get_location): New.
(exploded_node::get_stmt): Drop.
(exploded_node::get_processed_stmt): Drop.
(exploded_node::maybe_get_stmt): New decl.
(exploded_node::maybe_get_op): New decl.
(class dynamic_call_info_t): Delete.
(class interprocedural_call): New.
(class interprocedural_return): New.
(rewind_info_t::add_events_to_path): Add pending_diagnostic &
param.
(rewind_info_t::get_setjmp_point): Replace with...
(rewind_info_t::get_point_before_setjmp): ...this...
(rewind_info_t::get_point_after_setjmp): ...and this.
(stats::m_num_nodes): Convert from an array to a plain int.
(class strongly_connected_components): Convert from index to id
throughout.
(exploded_graph::maybe_process_run_of_before_supernode_enodes):
Replace with...
(exploded_graph::maybe_process_run_of_enodes): ...this.
(exploded_graph::maybe_create_dynamic_call): Delete.
(exploded_graph::save_diagnostic): Drop stmt_finder param.
(exploded_graph::dump_states_for_supernode): Drop.
(exploded_graph::m_PK_AFTER_SUPERNODE_per_snode): Drop.
(class feasibility_problem): Drop "m_last_stmt".
(feasibility_state::update_for_stmt): Drop.
(feasibility_state::get_model): Add non-const accessor.
(feasibility_state::get_snodes_visited): New accessor.
(class stmt_finder): Drop.
* feasible-graph.cc (feasible_node::dump_dot): Drop call to
dump_processed_stmts.
(feasible_node::get_state_at_stmt): Drop.
* impl-sm-context.h: New file, adapted from material in engine.cc.
* infinite-loop.cc
(perpetual_start_cfg_edge_event::perpetual_start_cfg_edge_event):
Add "op" param.
(perpetual_start_cfg_edge_event::print_desc): Use m_op to describe
condition.
(looping_back_event::looping_back_event): Add "op" param.
(infinite_loop_diagnostic::maybe_add_custom_events_for_superedge):
Convert to...
(infinite_loop_diagnostic::maybe_add_custom_events_for_eedge):
...this.
(infinite_loop_diagnostic::add_final_event): Port from
cfg_superedge to get_any_cfg_edge and operations. Update for
location-handling changes.
(get_in_edge_back_edge): Port from cfg_superedge to
get_any_cfg_edge.
(starts_infinite_loop_p): Update for location-handling changes.
(exploded_graph::detect_infinite_loops): Remove redundant params.
* infinite-recursion.cc
(infinite_recursion_diagnostic::add_final_event): Update for
location-handling changes.
(infinite_recursion_diagnostic::check_valid_fpath_p): Drop gimple
param.
(infinite_recursion_diagnostic::fedge_uses_conjured_svalue_p):
Port from cfg_superedge to operations.
(is_entrypoint_p): Update for supergraph changes.
(exploded_graph::detect_infinite_recursion): Update for
location-handling changes.
* kf-lang-cp.cc (kf_operator_new::impl_call_pre): Split out
code to handle placement-new into...
(kf_operator_new::check_any_preconditions): ...this...
(kf_operator_new::get_sized_region_for_placement_new): ...and
this.
* ops.cc: New file, albeit with material adatpted from old
implementation.
* ops.h: Likewise.
* pending-diagnostic.cc (pending_diagnostic::add_call_event): Add
gcall param. Update for changes to location-handling.
* pending-diagnostic.h
(pending_diagnostic::maybe_add_custom_events_for_superedge):
Convert to...
(pending_diagnostic::maybe_add_custom_events_for_eedge): ...this.
(pending_diagnostic::add_call_event): Add "call_stmt" param.
(pending_diagnostic::check_valid_fpath_p): Drop stmt param.
* program-point.cc (point_kind_to_string): Delete.
(function_point::function_point): Delete.
(function_point::print): Delete.
(function_point::hash): Delete.
(function_point::get_function): Delete.
(function_point::get_stmt): Delete.
(function_point::get_location): Delete.
(function_point::final_stmt_p): Delete.
(function_point::from_function_entry): Delete.
(function_point::before_supernode): Delete.
(function_point::print_source_line): Convert to...
(program_point::print_source_line): ...this.
(program_point::print): Reimplement.
(program_point::to_json): Likewise.
(program_point::push_to_call_stack): Delete.
(program_point::hash): Reimplement.
(program_point::get_function_at_depth): Likewise.
(program_point::on_edge): Delete.
(function_point::cmp_within_supernode_1): Delete.
(function_point::cmp_within_supernode): Delete.
(function_point::cmp): Delete.
(function_point::cmp_ptr): Delete.
(function_point::next_stmt): Delete.
(function_point::get_next): Delete.
(program_point::origin): Update.
(program_point::from_function_entry): Update.
(program_point::get_next): Delete.
(selftest::test_function_point_equality): Delete.
(selftest::test_function_point_ordering): Delete.
(selftest::test_program_point_equality): Update for changes to
program_point.
(selftest::analyzer_program_point_cc_tests): Don't call deleted
function_point tests.
* program-point.h: Include "analyzer/supergraph.h".
(class exploded_graph): Drop forward decl.
(enum point_kind): Drop.
(point_kind_to_string): Drop decl.
(class function_point): Delete.
(program_point::program_point): Take a const supernode *
rather than a const function_point &.
(program_point::print_source_line): New decl.
(program_point::operator==): Update.
(program_point::get_function_point): Drop.
(program_point::get_supernode): Reimplement.
(program_point::get_function): Reimplement.
(program_point::get_fndecl): Reimplement.
(program_point::get_stmt): Drop.
(program_point::get_location): Reimplement.
(program_point::get_kind): Drop.
(program_point::get_from_edge): Drop.
(program_point::get_stmt_idx): Drop.
(program_point::get_stack_depth): Update.
(program_point::state_merge_at_p): New.
(program_point::before_supernode): Drop.
(program_point::before_stmt): Drop.
(program_point::after_supernode): Drop.
(program_point::empty): Drop.
(program_point::deleted): Drop.
(program_point::on_edge): Drop.
(program_point::push_to_call_stack): Drop.
(program_point::next_stmt): Drop.
(program_point::get_next): Drop.
(program_point::m_function_point): Replace with...
(program_point::m_snode): ...this.
* program-state.cc (program_state::on_edge): Delete.
(program_state::push_call): Delete.
(program_state::returning_call): Delete.
(program_state::prune_for_point): Port from function_point to
supernode. Drop stmt param to impl_region_model_context ctor.
(selftest::test_sm_state_map): Update for engine borrowing rather
owning the region_model_manager.
(selftest::test_program_state_1): Likewise.
(selftest::test_program_state_2): Likewise.
(selftest::test_program_state_merging): Likewise.
(selftest::test_program_state_merging_2): Likewise.
* program-state.h (program_state::push_call): Delete decl.
(program_state::returning_call): Delete decl.
(program_state::on_edge): Delete decl.
* region-model-manager.cc (region_model_manager::maybe_fold_unaryop):
Only fold constants if we have a type.
(region_model_manager::get_or_create_widening_svalue): Port from
function_point to supernode.
* region-model-manager.h
(region_model_manager::get_or_create_widening_svalue): Likewise.
* region-model.cc
(poisoned_value_diagnostic::check_valid_fpath_p): Drop code for
handling function_points within an snode.
(exception_thrown_from_unrecognized_call::add_events_to_path): Add
pending_diagnostic param.
(class jump_through_null): Move here from engine.cc.
(region_model::on_call_pre): Check for jump through null here,
rather than in exploded_graph::process_node.
(region_model::on_setjmp): Add superedge param and pass it to
setjmp_record ctor.
(region_model::handle_phi): Delete, in favor of
phis_for_edge_op::update_state in ops.cc.
(region_model::update_for_phis): Likewise.
(region_model::maybe_update_for_edge): Delete.
(region_model::update_for_call_superedge): Delete.
(region_model::update_for_return_superedge): Delete.
(region_model::apply_constraints_for_gcond): Reimplement in ops.cc as
gcond_edge_op::apply_constraints.
(has_nondefault_case_for_value_p): Move to ops.cc.
(has_nondefault_cases_for_all_enum_values_p): Move to ops.cc
(region_model::apply_constraints_for_gswitch): Reimplement in
ops.cc as switch_case_op::apply_constraints.
(class rejected_eh_dispatch): Move to ops.cc.
(exception_matches_type_p): Move to ops.cc.
(matches_any_exception_type_p): Move to ops.cc.
(region_model::apply_constraints_for_eh_dispatch): Reimplement in
ops.cc as eh_dispatch_edge_op::apply_constraints.
(region_model::apply_constraints_for_eh_dispatch_try): Reimplement
in ops.cc as eh_dispatch_try_edge_op::apply_eh_constraints.
(region_model::apply_constraints_for_eh_dispatch_allowed):
Reimplement in ops.cc as
eh_dispatch_allowed_edge_op::apply_eh_constraints.
(region_model::apply_constraints_for_ggoto): Reimplement in ops.cc
as ggoto_edge_op::apply_constraints.
(caller_context::warn): Replace with...
(caller_context::get_pending_location_for_diag): ...this.
(region_model::get_or_create_region_for_heap_alloc): Fix
indentation.
(region_model_context::warn): New, replacing vfunc with
shared code that calls get_pending_location_for_diag and warn_at
vfuncs.
(engine::engine): Borrow m_mgr rather than own it.
(seldtest::test_state_merging): Update test for ptrs to different
base regions becoming unmergeable.
(selftest::test_widening_constraints): Port from function_point to
supernode.
* region-model.h: Include "analyzer/diagnostic-manager.h".
(region_model::on_setjmp): Add superedge param.
(region_model::void update_for_phis): Drop decl.
(region_model::handle_phi): Drop decl.
(region_model::maybe_update_for_edge): Drop decl.
(region_model::apply_constraints_for_eh_dispatch_try): Drop decl.
(region_model::apply_constraints_for_eh_dispatch_allowed): Drop
decl.
(region_model::update_for_call_superedge): Drop decl.
(region_model::update_for_return_superedge): Drop decl.
(region_model::apply_constraints_for_gcond): Drop decl.
(region_model::apply_constraints_for_gswitch): Drop decl.
(region_model::apply_constraints_for_ggoto): Drop decl.
(region_model::apply_constraints_for_eh_dispatch): Drop decl.
(region_model_context::warn): Convert from vfunc to func.
(region_model_context::get_pending_location_for_diag): New vfunc.
(region_model_context::warn_at): New vfunc.
(class noop_region_model_context): Update for changes to
region_model_context.
(class region_model_context_decorator): Likewise.
(class annotating_context): Likewise.
(struct model_merger): Port from function_point to supernode.
(class engine): Borrow m_mgr rather than own it.
(class test_region_model_context): Update for changes to
region_model_context.
* region.cc (frame_region::get_region_for_local): Update for
change to supergraph.
* sm-fd.cc: Drop redundant params throughout. Pass stmt
rather than node to the various on_ calls.
* sm-file.cc: Drop redundant params throughout.
(register_known_file_functions): Register "*_unlocked" versions of
functions that I'd missed.
* sm-malloc.cc: Drop redundant params throughout.
(deref_before_check::loop_header_p): Reimplement cfg_superedge
check.
(malloc_state_machine::on_stmt): Move attribute-handling to...
(malloc_state_machine::check_call_preconditions): ...this new
function.
(maybe_complain_about_deref_before_check): Use
sm_ctxt.get_emission_location when checking for inlining.
* sm-pattern-test.cc: Drop redundant params throughout.
* sm-sensitive.cc: Likewise.
* sm-signal.cc: Likewise.
* sm-taint.cc: Likewise.
* sm.cc: Fix unused param warnings.
* sm.h: Include "analyzer/analyzer-logging.h". Drop redundant
params throughout.
(state_machine::check_call_preconditions): New vfunc.
(sm_context::get_state): Drop "stmt" args.
(sm_context::set_next_state): Likewise.
(sm_context::on_transition): Drop "stmt" and "node" args.
(sm_context::warn): Likewise.
(sm_context::get_emission_location): New vfunc.
* state-purge.cc: Define INCLUDE_SET.
(class gimple_op_visitor): Replace function_point and function
with superedge.
(state_purge_map::state_purge_map): Iterate through ops on edges,
rather than on stmts in supernodes.
(state_purge_map::on_duplicated_node): New.
(state_purge_map::get_or_create_data_for_decl): Use supernode
rather than function_point.
(state_purge_per_ssa_name::state_purge_per_ssa_name): Likewise.
(state_purge_per_ssa_name::needed_at_point_p): Replace with...
(state_purge_per_ssa_name::needed_at_supernode_p): ...this.
(state_purge_per_ssa_name::before_use_stmt): Delete.
(state_purge_per_ssa_name::add_to_worklist): Use supernode rather
than function_point.
(name_used_by_phis_p): Delete.
(state_purge_per_ssa_name::process_point): Replace with...
(state_purge_per_ssa_name::process_supernode): ...this.
(state_purge_per_ssa_name::on_duplicated_node): New.
(state_purge_per_decl::state_purge_per_decl): Use supernode rather
than function_point.
(state_purge_per_decl::add_needed_at): Likewise.
(state_purge_per_decl::add_pointed_to_at): Likewise.
(state_purge_per_decl::process_worklists): Likewise.
(state_purge_per_decl::add_to_worklist): Likewise.
(state_purge_per_decl::process_point_backwards): Replace with...
(state_purge_per_decl::process_supernode_backwards): ...this.
(state_purge_per_decl::process_point_forwards): Replace with...
(state_purge_per_decl::process_supernode_forwards): ...this.
(state_purge_per_decl::needed_at_point_p): Replace with...
(state_purge_per_decl::needed_at_supernode_p): ...this.
(state_purge_per_decl::on_duplicated_node): New.
(print_vec_of_names): Drop "within_table" param.
(state_purge_annotator::add_stmt_annotations): Drop.
(state_purge_annotator::add_node_annotations): Reimplement.
* state-purge.h: Convert throughout from function_point to
supernode.
(state_purge_map::on_duplicated_node): New decl.
(state_purge_per_ssa_name::on_duplicated_node): Likewise.
(state_purge_per_decl::on_duplicated_node): Likewise.
* store.cc (needs_loop_replay_fixup_p): New.
(store::loop_replay_fixup): Use it rather than checking for
SK_WIDENING.
* supergraph-fixup-locations.cc: New file.
* supergraph-manipulation.h: New file.
* supergraph-simplify.cc: New file.
* supergraph-sorting.cc: New file.
* supergraph.cc: Define INCLUDE_DEQUE. Drop include of
"tree-dfa.h". Include "diagnostics/file-cache.h"
and "analyzer/exploded-graph.h".
(supergraph_call_edge): Delete.
(control_flow_stmt_p): New.
(supergraph::supergraph): Add "mgr" param. Initialize
m_next_snode_id. Reimplement.
(supergraph::populate_for_basic_block): New.
(supergraph::dump_dot_to_pp): Add auto_cfun sentinel.
Split up nodes using loop information from the original CFG,
then by basic block. Call the node_annotator's
add_extra_objects vfunc.
(supergraph::dump_dot_to_gv_for_loop): New.
(supergraph::dump_dot_to_gv_for_bb): New, based on code in
dump_dot_to_pp.
(supergraph::add_node): Drop "returning_call" and "phi_nodes"
params. Add logger param and logging. Use m_next_snode_id to
allow for node deletion.
(supergraph::add_cfg_edge): Delete.
(supergraph::add_call_superedge): Delete.
(supergraph::add_return_superedge): Delete.
(supergraph::delete_nodes): New.
(supergraph::add_sedges_for_cfg_edge): New.
(supernode::dump_dot): Drop output cluster, moving
add_node_annotations to within the dot node. Show any SCC id.
Show m_preserve_p and m_state_merger_node. Update for renaming of
supernode::return_p to supernode::exit_p. Highlight nodes without
source location information. Show m_loc and m_stmt_loc. Show
source lines, with color for highlight.
(supernode::dump_dot_id): Update.
(supernode::to_json): Update.
(supernode::get_start_location): Delete.
(supernode::get_end_location): Delete.
(supernode::get_stmt_index): Delete.
(supernode::get_label): Delete.
(edge_kind_to_string): Delete.
(superedge::dump): Update for supernode::m_index becoming m_id.
(superedge::dump_dot): Drop ltail/lhead attrs. Flush after
dumping the label.
(superedge::to_json): Reimplement.
(superedge::get_any_cfg_edge): Delete.
(superedge::get_any_callgraph_edge): Delete.
(superedge::preserve_p): New.
(superedge::supports_bulk_merge_p): New.
(cfg_superedge::dump_label_to_pp): Delete.
(superedge::dump_label_to_pp): New.
(cfg_superedge::get_phi_arg_idx): Delete.
(cfg_superedge::get_phi_arg): Delete.
(switch_cfg_superedge::switch_cfg_superedge): Delete.
(switch_cfg_superedge::dump_label_to_pp): Delete.
(switch_cfg_superedge::implicitly_created_default_p): Delete.
(get_catch): Move to ops.cc.
(eh_dispatch_cfg_superedge::make): Delete in favor of
eh_dispatch_edge_op::make.
(eh_dispatch_cfg_superedge::eh_dispatch_cfg_superedge): Delete.
(eh_dispatch_cfg_superedge::get_eh_status): Delete.
(eh_dispatch_try_cfg_superedge::dump_label_to_pp): Delete.
(eh_dispatch_try_cfg_superedge::apply_constraints): Delete.
(eh_dispatch_allowed_cfg_superedge::eh_dispatch_allowed_cfg_superedge):
Delete.
(eh_dispatch_allowed_cfg_superedge::dump_label_to_pp): Delete.
(eh_dispatch_allowed_cfg_superedge::apply_constraints): Delete.
(callgraph_superedge::dump_label_to_pp): Delete.
(callgraph_superedge::get_callee_function): Delete.
(callgraph_superedge::get_caller_function): Delete
(callgraph_superedge::get_callee_decl): Delete
(callgraph_superedge::get_call_stmt): Delete
(callgraph_superedge::get_caller_decl): Delete
(callgraph_superedge::get_arg_for_parm): Delete in favor of
call_and_return_op::get_arg_for_parm in ops.cc.
(callgraph_superedge::get_parm_for_arg): Delete in favor of
call_and_return_op::get_parm_for_arg in ops.cc.
(callgraph_superedge::map_expr_from_caller_to_callee): Delete in
favor of call_and_return_op::map_expr_from_caller_to_callee in
ops.cc.
(callgraph_superedge::map_expr_from_callee_to_caller): Delete in
favor of call_and_return_op::map_expr_from_callee_to_caller in
ops.cc.
* supergraph.h: Include "cfgloop.h" and "analyzer/ops.h".
(enum edge_kind): Delete.
(struct supergraph_traits::dump_args_t): Add m_eg.
(class supergraph): Rewrite leading comment.
(supergraph::supergraph): Add "mgr" param.
(supergraph::get_node_for_function_entry): Reimplement.
(supergraph::get_node_for_function_exit): Reimplement.
(supergraph::get_node_for_block): Convert to...
(supergraph::get_initial_node_for_block): ...this.
(supergraph::get_caller_next_node): Delete.
(supergraph::get_edge_for_call): Delete.
(supergraph::get_edge_for_return): Delete.
(supergraph::get_intraprocedural_edge_for_call): Delete.
(supergraph::get_edge_for_cfg_edge): Delete.
(supergraph::get_supernode_for_stmt): Delete.
(supergraph::get_final_node_for_block): New.
(supergraph::get_supernode_for_stmt): New.
(supergraph::get_superedge_for_phis): New.
(supergraph::get_node_by_index): Delete.
(supergraph::add_node): Drop "returning_call" and "phi_nodes"
params. Add logger param.
(supergraph::add_cfg_edge): Delete.
(supergraph::add_call_superedge): Delete.
(supergraph::add_return_superedge): Delete.
(supergraph::log_stats): New decl.
(supergraph::delete_nodes): New decl.
(supergraph::fixup_locations): New decl.
(supergraph::simplify): New decl.
(supergraph::sort_nodes): New decl.
(supergraph::populate_for_basic_block): New decl.
(supergraph::add_sedges_for_cfg_edge): New decl.
(supergraph::dump_dot_to_gv_for_loop): New decl.
(supergraph::dump_dot_to_gv_for_bb): New decl.
(supergraph::reorder_nodes_and_ids): New decl.
(supergraph::bb_to_node_t): Make private.
(supergraph::m_bb_to_initial_node): Make private.
(supergraph::m_bb_to_final_node): Make private.
(supergraph::cgraph_edge_to_node_t): Delete typedef.
(supergraph::m_cgraph_edge_to_caller_prev_node): Delete.
(supergraph::m_cgraph_edge_to_caller_next_node): Delete.
(supergraph::cfg_edge_to_cfg_superedge_t): Delete typedef.
(supergraph::m_cfg_edge_to_cfg_superedge): Delete.
(supergraph::cgraph_edge_to_call_superedge_t): Delete typedef.
(supergraph::m_cgraph_edge_to_call_superedge): Delete
(supergraph::cgraph_edge_to_return_superedge_t): Delete typedef.
(supergraph::m_cgraph_edge_to_return_superedge): Delete.
(supergraph::cgraph_edge_to_intraproc_superedge_t): Delete
typedef.
(supergraph::m_cgraph_edge_to_intraproc_superedge): Delete.
(supergraph::stmt_to_node_t): Delete typedef.
(supergraph::m_stmt_to_node_t): Replace with...
(supergraph::m_node_for_stmt): ...this.
(supergraph::m_edges_for_phis): New field.
(supergraph::m_next_snode_id): New field.
(supergraph::m_snode_by_id): New field.
(supernode::supernode): Drop "returning_call" and "phi_nodes"
params. Convert "index" to "id". Update for changes to fields.
(supernode::return_p): Rename for clarity to...
(supernode::exit_p): ...this.
(supernode::get_start_location): Delete.
(supernode::get_end_location): Delete.
(supernode::start_phis): Delete.
(supernode::get_returning_call): Delete.
(supernode::print): New.
(supernode::get_last_stmt): Delete.
(supernode::get_final_call): Delete.
(supernode::get_stmt_index): Delete.
(supernode::get_location): New.
(supernode::get_label): Convert to trivial accessor.
(supernode::preserve_p): New.
(supernode::m_returning_call): Drop field.
(supernode::m_phi_nodes): Drop field.
(supernode::m_stmts): Drop field.
(supernode::m_index): Replace with...
(supernode::m_id): ...this.
(supernode::m_loc): New field.
(supernode::m_stmt_loc): New field.
(supernode::m_original_id): New field.
(supernode::m_label): New field.
(supernode::m_preserve_p): New field.
(supernode::m_state_merger_node): New field.
(class superedge): Update leading comment.
(superedge::superedge): Make public rather than protected. Drop
"kind" param. Add "op" and "cfg_edge" params. Assert that edge
is intraprocedural.
(superedge::m_kind): Drop field.
(superedge::m_op): New field.
(superedge::m_cfg_edge): New field.
(superedge::dump_label_to_pp): Make non-virtual.
(superedge::get_op): New.
(superedge::set_op): New.
(superedge::get_kind): Drop.
(superedge::get_dest_snode): New accessor.
(superedge::dyn_cast_cfg_superedge): Delete.
(superedge::dyn_cast_switch_cfg_superedge): Delete
(superedge::dyn_cast_eh_dispatch_cfg_superedge): Delete
(superedge::dyn_cast_eh_dispatch_try_cfg_superedge): Delete
(superedge::dyn_cast_eh_dispatch_allowed_cfg_superedge): Delete
(superedge::dyn_cast_callgraph_superedge): Delete
(superedge::dyn_cast_callgraph_superedge): Delete
(superedge::dyn_cast_call_superedge): Delete
(superedge::dyn_cast_call_superedge): Delete
(superedge::dyn_cast_return_superedge): Delete
(superedge::dyn_cast_return_superedge): Delete
(superedge::get_any_cfg_edge): Convert to trivial accessor.
(superedge::get_any_callgraph_edge): Drop.
(superedge::preserve_p): New.
(superedge::supports_bulk_merge_p): New.
(class callgraph_superedge): Drop.
(is_a_helper <const callgraph_superedge *>::test): Drop.
(class call_superedge): Drop.
(is_a_helper <const call_superedge *>::test): Drop.
(class return_superedge): Drop.
(is_a_helper <const return_superedge *>::test): Drop.
(class cfg_superedge): Drop.
(class switch_cfg_superedge): Drop.
(is_a_helper <const switch_cfg_superedge *>::test): Drop.
(class eh_dispatch_cfg_superedge): Drop.
(is_a_helper <const eh_dispatch_cfg_superedge *>::test): Drop.
(class eh_dispatch_try_cfg_superedge): Drop.
(is_a_helper <const eh_dispatch_try_cfg_superedge *>::test): Drop.
(class eh_dispatch_allowed_cfg_superedge): Drop.
(is_a_helper <const eh_dispatch_allowed_cfg_superedge *>::test):
Drop.
(dot_annotator::~dot_annotator): Use "= default;".
(dot_annotator::add_node_annotations): Drop return value and
"within_table" param.
(dot_annotator::add_stmt_annotations): Drop.
(dot_annotator::add_after_node_annotations): Drop.
(dot_annotator::add_extra_objects): New.
(supergraph_call_edge): Delete decl.
(get_ultimate_function_for_cgraph_edge): Delete decl.
* svalue.cc (svalue::can_merge_p): Reject attempts to merge
pointers that point to different base regions, except for the case
where both are string literals. Update for point change in
widening_svalue.
(svalue::cmp_ptr): Update for point change to widening_svalue.
(widening_svalue::dump_to_pp): Likewise.
(widening_svalue::print_dump_widget_label): Likewise.
* svalue.h (struct setjmp_record): Add m_sedge.
(class widening_svalue): Replace function_point m_point with
const supernode *m_snode throughout.
* varargs.cc (va_list_state_machine::on_stmt): Drop redundant
param.
(va_list_state_machine::on_va_start): Likewise. Update for change
to get_state.
(va_list_state_machine::check_for_ended_va_list): Likewise.
(va_list_state_machine::on_va_copy): Likewise.
(va_list_state_machine::on_va_arg): Likewise.
(va_list_state_machine::on_va_end): Likewise.
(va_arg_diagnostic::add_call_event): Update for changes to
location-tracking.
gcc/testsuite/ChangeLog:
PR analyzer/122003
* c-c++-common/analyzer/allocation-size-multiline-1.c: Update for split
of region creation events.
* c-c++-common/analyzer/bzip2-arg-parse-1.c: Drop test for enode
merging. Add -Wno-analyzer-too-complex.
* c-c++-common/analyzer/coreutils-cksum-pr108664.c: Add
-Wno-analyzer-symbol-too-complex. Add dg-bogus for false +ve seen
during patch development.
* c-c++-common/analyzer/coreutils-group_number.c: New test.
* c-c++-common/analyzer/data-model-20.c: Mark warnings as xfail.
* c-c++-common/analyzer/deref-before-check-qemu-qtest_rsp_args.c:
Add xfails.
* c-c++-common/analyzer/dot-output.c: Update for changes to dumps.
* c-c++-common/analyzer/fd-symbolic-socket.c: Update for
improvements to locations of leaks.
* c-c++-common/analyzer/fibonacci.c: Update regex.
* c-c++-common/analyzer/flex-with-call-summaries.c: Add xfail.
* c-c++-common/analyzer/flex-without-call-summaries.c: Add
-Wno-analyzer-symbol-too-complex. Add xfail.
* c-c++-common/analyzer/infinite-recursion-5.c: Disable cases that
now explode the analysis.
* c-c++-common/analyzer/infinite-recursion-pr108524-2.c: Remove
xfail.
* c-c++-common/analyzer/invalid-shift-1.c: Remove xfails with c++26.
* c-c++-common/analyzer/ipa-callbacks-1.c: New test.
* c-c++-common/analyzer/loop-4.c: Expect incorrect UNKNOWN within
loop. Update expected number of enodes.
* c-c++-common/analyzer/loop-n-down-to-1-by-1.c: Expect incorrect
UNKNOWN within loop.
* c-c++-common/analyzer/loop.c: Drop xfail.
* c-c++-common/analyzer/out-of-bounds-coreutils.c: Expect infinite
loop warning.
* c-c++-common/analyzer/paths-4.c: Update expected number of
enodes.
* c-c++-common/analyzer/pr94362-1.c: Drop -Wno-analyzer-too-complex.
* c-c++-common/analyzer/pr94851-2.c: Add xfail.
* c-c++-common/analyzer/pr96650-1-notrans.c: Add
-Wno-analyzer-too-complex.
* c-c++-common/analyzer/pr98628.c: Likewise.
* c-c++-common/analyzer/pr99774-1.c: Likewise.
* c-c++-common/analyzer/pragma-2.c: Expect double-free warning.
* c-c++-common/analyzer/realloc-1.c: Move expected location of
leak from trailing "}" to realloc call.
* c-c++-common/analyzer/sock-1.c: Add -fno-exceptions.
* c-c++-common/analyzer/sprintf-2.c: Add __attribute__ nonnull to
decl.
* c-c++-common/analyzer/sprintf-concat.c: Move expected location
of leak of p from sprintf to trailing "}".
* c-c++-common/analyzer/stdarg-sentinel-1.c: Drop
-Wno-analyzer-too-complex.
* c-c++-common/analyzer/strncpy-1.c: Add __attribute__ nonnull to
decl.
* c-c++-common/analyzer/strstr-1.c: Likewise.
* g++.dg/analyzer/analyzer.exp: Drop -fanalyzer-call-summaries.
* g++.dg/analyzer/fanalyzer-show-events-in-system-headers-default.C:
Update expected messages.
* g++.dg/analyzer/fanalyzer-show-events-in-system-headers-no.C:
Likewise.
* g++.dg/analyzer/fanalyzer-show-events-in-system-headers.C: Likewise.
* g++.dg/analyzer/pr94028.C: Move expected location of leak
warning to where return value of f is discarded within m.
* g++.dg/analyzer/pr96641.C: Expect infinite recursion warning.
* gcc.dg/analyzer/CWE-131-examples.c: Add
-Wno-analyzer-too-complex.
* gcc.dg/analyzer/abs-1.c (test_2): Fix return type.
* gcc.dg/analyzer/analyzer-decls.h: Reformat. Add
__attribute__ ((nothrow)) to all functions.
* gcc.dg/analyzer/analyzer.exp: Drop -fanalyzer-call-summaries.
* gcc.dg/analyzer/boxed-malloc-1.c: Fix return types.
* gcc.dg/analyzer/call-summaries-2.c: Likewise.
* gcc.dg/analyzer/combined-conditionals-1.c: Likewise.
* gcc.dg/analyzer/compound-assignment-2.c: Expect warning about
missing return.
* gcc.dg/analyzer/compound-assignment-3.c: Likewise.
* gcc.dg/analyzer/conditionals-3.c: Fix return type.
* gcc.dg/analyzer/data-model-1.c: Likewise.
* gcc.dg/analyzer/data-model-15.c: Likewise.
* gcc.dg/analyzer/data-model-17.c: Likewise.
* gcc.dg/analyzer/data-model-20a.c: Remove xfail from bogus leak.
* gcc.dg/analyzer/data-model-7.c: Fix return type.
* gcc.dg/analyzer/doom-d_main-IdentifyVersion.c: Add xfail to some
of the leak msgs.
* gcc.dg/analyzer/doom-s_sound-pr108867.c: Add xfail.
* gcc.dg/analyzer/edges-1.c: Update for improvements to location
of leak.
* gcc.dg/analyzer/error-1.c: Fix return type.
* gcc.dg/analyzer/explode-1.c: Drop xfail. Expect uninit and
double-free warnings.
* gcc.dg/analyzer/explode-2.c: Add xfail.
* gcc.dg/analyzer/explode-3.c: Drop xfail. Expect uninit and
double-free warnings.
* gcc.dg/analyzer/fd-datagram-socket.c: Move expected location of
leaks to closing "}"s.
* gcc.dg/analyzer/fd-glibc-byte-stream-connection-server.c: Add
false +ve leak message, due to not considering that program is
about to exit.
* gcc.dg/analyzer/fd-stream-socket.c: Move expected location of
leaks to closing "}"s.
* gcc.dg/analyzer/malloc-1.c: Fix return types.
* gcc.dg/analyzer/malloc-many-paths-2.c: Likewise.
* gcc.dg/analyzer/malloc-paths-10.c: Likewise.
* gcc.dg/analyzer/malloc-vs-local-4.c: Likewise.
* gcc.dg/analyzer/memset-CVE-2017-18549-1.c: Likewise.
* gcc.dg/analyzer/null-deref-pr102671-1.c: Enable
-fanalyzer-call-summaries.
* gcc.dg/analyzer/null-deref-pr102671-2.c: Remove xfail.
* gcc.dg/analyzer/pr101143.c: Fix return type.
* gcc.dg/analyzer/pr101837.c: Fix return type. Add warning about
missing return.
* gcc.dg/analyzer/pr101983-not-main.c: Fix return type.
* gcc.dg/analyzer/pr103892.c: Enable -fanalyzer-call-summaries.
* gcc.dg/analyzer/pr104224.c: Add xfails.
* gcc.dg/analyzer/pr104434-nonconst.c: Likewise.
* gcc.dg/analyzer/pr93032-mztools-signed-char.c: Increase
exploration limits by a factor of 5.
* gcc.dg/analyzer/pr93032-mztools-unsigned-char.c: Likewise.
* gcc.dg/analyzer/pr93355-localealias-feasibility-2.c: Fix return type.
* gcc.dg/analyzer/pr93355-localealias.c: Add xfail. Add expected
leak true +ve and uninit false +ve.
* gcc.dg/analyzer/pr94579.c: Add warning about missing return.
* gcc.dg/analyzer/pr98599-a.c: Add missing return stmts.
* gcc.dg/analyzer/pr99771-1.c: Fix expected locations of leaks.
* gcc.dg/analyzer/pr99774-2.c: Likewise.
* gcc.dg/analyzer/sensitive-1.c: Fix return types.
* gcc.dg/analyzer/state-diagram-1-sarif.py: Update.
* gcc.dg/analyzer/stdarg-1.c
(__analyzer_test_not_enough_args_2_middle): Add test coverage for
wording of call event with variadic args.
* gcc.dg/analyzer/strcmp-1.c: Fix return types.
* gcc.dg/analyzer/strcpy-1.c: Likewise.
* gcc.dg/analyzer/switch-enum-taint-1.c: Add warning about missing
return.
* gcc.dg/analyzer/switch.c: Fix return types.
* gcc.dg/analyzer/taint-assert.c: Likewise.
* gcc.dg/analyzer/taint-write-offset-1.c: Likewise.
* gcc.dg/analyzer/torture/analyzer-torture.exp: Drop
-fanalyzer-call-summaries.
* gcc.dg/analyzer/torture/boxed-ptr-1.c: Fix return type.
* gcc.dg/analyzer/torture/fold-ptr-arith-pr105784.c: Add
-Wno-analyzer-too-complex.
* gcc.dg/analyzer/torture/loop-inc-ptr-1.c: Skip at -O3 to avoid
changes to enode count.
* gcc.dg/analyzer/torture/pr102225.c: Consolidate on one line to
avoid caring about precise location of leak warning.
* gcc.dg/analyzer/torture/pr93379.c: Skip on -fno-fat-lto-objects.
Add warning about uninit.
* gcc.dg/analyzer/torture/stdarg-4.c: Replace UNKNOWN with
symbolic sum of params.
* gcc.dg/analyzer/untracked-1.c: Fix return type.
* gcc.dg/analyzer/use-after-free.c: Likewise.
* gcc.dg/analyzer/zlib-3.c: Add xfails.
* gcc.dg/plugin/analyzer_cpython_plugin.cc
(class refcnt_stmt_finder): Eliminate.
(check_refcnt): ...in favor of a call to
make_ploc_fixer_for_epath_for_leak_diagnostic.
* gcc.dg/plugin/analyzer_gil_plugin.cc: Update for
location-handling changes.
* gcc.dg/plugin/infoleak-CVE-2011-1078-1.c: Add missing
"return 0;".
* gcc.dg/plugin/infoleak-CVE-2011-1078-2.c: Fix return types.
* gcc.dg/plugin/infoleak-CVE-2017-18549-1.c: Likewise.
* gdc.dg/analyzer/analyzer.exp: Drop -fanalyzer-call-summaries.
* gfortran.dg/analyzer/analyzer.exp: Likewise.
* gfortran.dg/analyzer/uninit-pr63311.f90: Add
-Wno-analyzer-too-complex.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Jakub Jelinek [Fri, 12 Dec 2025 14:18:08 +0000 (15:18 +0100)]
rtlanal: Use REG_UNUSED notes in single_set only in passes where df_analyze has computed them [PR121852]
REG_UNUSED and REG_DEAD notes are only valid when computed by df
with df_note_add_problem () before df_analyze ().
Generally, especially CSE/GCSE optimizations can invalidate those
notes by reusing the REG_UNUSED results later on, unfortunately dropping
REG_UNUSED notes in such cases is not very easy.
See e.g. PR113059 and PR40209 for additional details.
Most users of REG_UNUSED/REG_DEAD notes add the note problems, but
single_set function is called from many of the passes and requiring
that df_note_add_problem () is done in each such a case would be very
slow and would need some checking.
The following patch instead limits the use of REG_UNUSED notes to
passes which have the note problem computed (i.e. df && df_note), and
for pseudos as a fallback uses DF_REG_USE_COUNT == 0 check if at least
df is computed.
2025-12-12 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/121852
* rtlanal.cc (single_set_2): Only look for REG_UNUSED notes if
df && df_note, otherwise if df and SET_DEST is a pseudo with
DF_REG_USE_COUNT 0, assume it is unused as well. Otherwise
assume it may be used.
mengqinggang [Thu, 11 Dec 2025 06:38:52 +0000 (14:38 +0800)]
LoongArch: Add deleted testcases
Add gcc.target/loongarch/la64 path for LA64 testcases.
Move vector testcases in gcc.target/loongarch to
gcc.target/loongarch/vector/lsx or gcc.target/loongarch/vector/lasx.
gcc/testsuite/ChangeLog:
* gcc.target/loongarch/la64/add-const.c: New test.
* gcc.target/loongarch/la64/alsl-cost.c: New test.
* gcc.target/loongarch/la64/alsl_wu.c: New test.
* gcc.target/loongarch/la64/and-large-immediate-opt.c: New test.
* gcc.target/loongarch/la64/arch-func-attr-1.c: New test.
* gcc.target/loongarch/la64/arch-pragma-attr-1.c: New test.
* gcc.target/loongarch/la64/attr-model-1.c: New test.
* gcc.target/loongarch/la64/attr-model-2.c: New test.
* gcc.target/loongarch/la64/attr-model-3.c: New test.
* gcc.target/loongarch/la64/attr-model-4.c: New test.
* gcc.target/loongarch/la64/attr-model-5.c: New test.
* gcc.target/loongarch/la64/attr-model-diag.c: New test.
* gcc.target/loongarch/la64/attr-model-test.c: New test.
* gcc.target/loongarch/la64/bitint-alignments.c: New test.
* gcc.target/loongarch/la64/bitint-args.c: New test.
* gcc.target/loongarch/la64/bitint-sizes.c: New test.
* gcc.target/loongarch/la64/bitwise-shift-reassoc.c: New test.
* gcc.target/loongarch/la64/bitwise_extend.c: New test.
* gcc.target/loongarch/la64/bstrins-1.c: New test.
* gcc.target/loongarch/la64/bstrins-2.c: New test.
* gcc.target/loongarch/la64/bstrins-3.c: New test.
* gcc.target/loongarch/la64/bstrins-4.c: New test.
* gcc.target/loongarch/la64/bstrpick_alsl_paired.c: New test.
* gcc.target/loongarch/la64/bytepick_combine.c: New test.
* gcc.target/loongarch/la64/bytepick_shift_128.c: New test.
* gcc.target/loongarch/la64/can_inline_1.c: New test.
* gcc.target/loongarch/la64/can_inline_2.c: New test.
* gcc.target/loongarch/la64/can_inline_3.c: New test.
* gcc.target/loongarch/la64/can_inline_4.c: New test.
* gcc.target/loongarch/la64/can_inline_5.c: New test.
* gcc.target/loongarch/la64/can_inline_6.c: New test.
* gcc.target/loongarch/la64/cmodel-extreme-1.c: New test.
* gcc.target/loongarch/la64/cmodel-extreme-2.c: New test.
* gcc.target/loongarch/la64/cmodel-func-attr-1.c: New test.
* gcc.target/loongarch/la64/cmodel-pragma-attr-1.c: New test.
* gcc.target/loongarch/la64/cmov_ii.c: New test.
* gcc.target/loongarch/la64/compare-both-non-zero.c: New test.
* gcc.target/loongarch/la64/conditional-move-opt-1.c: New test.
* gcc.target/loongarch/la64/conditional-move-opt-2.c: New test.
* gcc.target/loongarch/la64/conditional-move-opt-3.c: New test.
* gcc.target/loongarch/la64/const-double-zero-stx.c: New test.
* gcc.target/loongarch/la64/crc-sext.c: New test.
* gcc.target/loongarch/la64/direct-extern-1.c: New test.
* gcc.target/loongarch/la64/div-div32.c: New test.
* gcc.target/loongarch/la64/div-no-div32.c: New test.
* gcc.target/loongarch/la64/divf.c: New test.
* gcc.target/loongarch/la64/explicit-relocs-auto-extreme-tls-desc.c: New test.
* gcc.target/loongarch/la64/explicit-relocs-auto-lto.c: New test.
* gcc.target/loongarch/la64/explicit-relocs-auto-single-load-store-2.c: New test.
* gcc.target/loongarch/la64/explicit-relocs-auto-single-load-store-3.c: New test.
* gcc.target/loongarch/la64/explicit-relocs-auto-single-load-store-no-anchor.c: New test.
* gcc.target/loongarch/la64/explicit-relocs-auto-single-load-store.c: New test.
* gcc.target/loongarch/la64/explicit-relocs-auto-tls-desc.c: New test.
* gcc.target/loongarch/la64/explicit-relocs-auto-tls-ld-gd.c: New test.
* gcc.target/loongarch/la64/explicit-relocs-auto-tls-le-ie.c: New test.
* gcc.target/loongarch/la64/explicit-relocs-extreme-auto-tls-ld-gd.c: New test.
* gcc.target/loongarch/la64/explicit-relocs-extreme-tls-desc.c: New test.
* gcc.target/loongarch/la64/explicit-relocs-medium-auto-tls-ld-gd.c: New test.
* gcc.target/loongarch/la64/explicit-relocs-medium-call36-auto-tls-ld-gd.c: New test.
* gcc.target/loongarch/la64/explicit-relocs-tls-desc.c: New test.
* gcc.target/loongarch/la64/extendsidi2-combine.c: New test.
* gcc.target/loongarch/la64/fclass-compile.c: New test.
* gcc.target/loongarch/la64/fclass-run.c: New test.
* gcc.target/loongarch/la64/flogb.c: New test.
* gcc.target/loongarch/la64/flt-abi-isa-1.c: New test.
* gcc.target/loongarch/la64/flt-abi-isa-2.c: New test.
* gcc.target/loongarch/la64/flt-abi-isa-3.c: New test.
* gcc.target/loongarch/la64/flt-abi-isa-4.c: New test.
* gcc.target/loongarch/la64/frint.c: New test.
* gcc.target/loongarch/la64/fscaleb.c: New test.
* gcc.target/loongarch/la64/ftint-no-inexact.c: New test.
* gcc.target/loongarch/la64/ftint.c: New test.
* gcc.target/loongarch/la64/func-call-1.c: New test.
* gcc.target/loongarch/la64/func-call-2.c: New test.
* gcc.target/loongarch/la64/func-call-3.c: New test.
* gcc.target/loongarch/la64/func-call-4.c: New test.
* gcc.target/loongarch/la64/func-call-5.c: New test.
* gcc.target/loongarch/la64/func-call-6.c: New test.
* gcc.target/loongarch/la64/func-call-7.c: New test.
* gcc.target/loongarch/la64/func-call-8.c: New test.
* gcc.target/loongarch/la64/func-call-extreme-1.c: New test.
* gcc.target/loongarch/la64/func-call-extreme-2.c: New test.
* gcc.target/loongarch/la64/func-call-extreme-3.c: New test.
* gcc.target/loongarch/la64/func-call-extreme-4.c: New test.
* gcc.target/loongarch/la64/func-call-extreme-5.c: New test.
* gcc.target/loongarch/la64/func-call-extreme-6.c: New test.
* gcc.target/loongarch/la64/func-call-medium-1.c: New test.
* gcc.target/loongarch/la64/func-call-medium-2.c: New test.
* gcc.target/loongarch/la64/func-call-medium-3.c: New test.
* gcc.target/loongarch/la64/func-call-medium-5.c: New test.
* gcc.target/loongarch/la64/func-call-medium-6.c: New test.
* gcc.target/loongarch/la64/func-call-medium-7.c: New test.
* gcc.target/loongarch/la64/func-call-medium-8.c: New test.
* gcc.target/loongarch/la64/func-call-medium-call36-1.c: New test.
* gcc.target/loongarch/la64/func-call-medium-call36.c: New test.
* gcc.target/loongarch/la64/imm-load.c: New test.
* gcc.target/loongarch/la64/imm-load1.c: New test.
* gcc.target/loongarch/la64/invariant-recip.c: New test.
* gcc.target/loongarch/la64/la64.exp: New test.
* gcc.target/loongarch/la64/larch-frecipe-builtin.c: New test.
* gcc.target/loongarch/la64/larch-frecipe-intrinsic.c: New test.
* gcc.target/loongarch/la64/lasx-func-attr-1.c: New test.
* gcc.target/loongarch/la64/lasx-pragma-attr-1.c: New test.
* gcc.target/loongarch/la64/lsx-func-attr-1.c: New test.
* gcc.target/loongarch/la64/lsx-pragma-attr-1.c: New test.
* gcc.target/loongarch/la64/math-float-128.c: New test.
* gcc.target/loongarch/la64/mem-and-mask-opt.c: New test.
* gcc.target/loongarch/la64/memcpy-vec-1.c: New test.
* gcc.target/loongarch/la64/memcpy-vec-2.c: New test.
* gcc.target/loongarch/la64/memcpy-vec-3.c: New test.
* gcc.target/loongarch/la64/mode-tieable-opt.c: New test.
* gcc.target/loongarch/la64/mov-zero-2.c: New test.
* gcc.target/loongarch/la64/movcf2gr-via-fr.c: New test.
* gcc.target/loongarch/la64/movcf2gr.c: New test.
* gcc.target/loongarch/la64/mul-const-reduction.c: New test.
* gcc.target/loongarch/la64/mulh_wu.c: New test.
* gcc.target/loongarch/la64/mulw_d_w.c: New test.
* gcc.target/loongarch/la64/mulw_d_wu.c: New test.
* gcc.target/loongarch/la64/pr109465-1.c: New test.
* gcc.target/loongarch/la64/pr109465-2.c: New test.
* gcc.target/loongarch/la64/pr109465-3.c: New test.
* gcc.target/loongarch/la64/pr113148.c: New test.
* gcc.target/loongarch/la64/pr114861.c: New test.
* gcc.target/loongarch/la64/pr118561.c: New test.
* gcc.target/loongarch/la64/pr118828-2.c: New test.
* gcc.target/loongarch/la64/pr118828-3.c: New test.
* gcc.target/loongarch/la64/pr118828-4.c: New test.
* gcc.target/loongarch/la64/pr118828.c: New test.
* gcc.target/loongarch/la64/pr118843.c: New test.
* gcc.target/loongarch/la64/pr119127.c: New test.
* gcc.target/loongarch/la64/pr121542.c: New test.
* gcc.target/loongarch/la64/pr121634.c: New test.
* gcc.target/loongarch/la64/pr121875.c: New test.
* gcc.target/loongarch/la64/prolog-opt.c: New test.
* gcc.target/loongarch/la64/recip-divf.c: New test.
* gcc.target/loongarch/la64/recip-sqrtf.c: New test.
* gcc.target/loongarch/la64/relocs-symbol-noaddend.c: New test.
* gcc.target/loongarch/la64/revb.c: New test.
* gcc.target/loongarch/la64/rotl-with-rotr.c: New test.
* gcc.target/loongarch/la64/rotrw.c: New test.
* gcc.target/loongarch/la64/sign-extend-1.c: New test.
* gcc.target/loongarch/la64/sign-extend-2.c: New test.
* gcc.target/loongarch/la64/sign-extend-3.c: New test.
* gcc.target/loongarch/la64/sign-extend-4.c: New test.
* gcc.target/loongarch/la64/sign-extend-5.c: New test.
* gcc.target/loongarch/la64/sign-extend-6.c: New test.
* gcc.target/loongarch/la64/sign-extend-bitwise.c: New test.
* gcc.target/loongarch/la64/sign_extend_ashift.c: New test.
* gcc.target/loongarch/la64/slt-sign-extend.c: New test.
* gcc.target/loongarch/la64/smuldi3_highpart.c: New test.
* gcc.target/loongarch/la64/spill-less.c: New test.
* gcc.target/loongarch/la64/sqrtf.c: New test.
* gcc.target/loongarch/la64/switch-qi.c: New test.
* gcc.target/loongarch/la64/tls-extreme-macro.c: New test.
* gcc.target/loongarch/la64/tls-gd-noplt.c: New test.
* gcc.target/loongarch/la64/tls-ie-extreme.c: New test.
* gcc.target/loongarch/la64/tls-ie-norelax.c: New test.
* gcc.target/loongarch/la64/tls-ie-relax.c: New test.
* gcc.target/loongarch/la64/tls-le-relax.c: New test.
* gcc.target/loongarch/la64/widen-mul-rtx-cost-signed.c: New test.
* gcc.target/loongarch/la64/widen-mul-rtx-cost-unsigned.c: New test.
* gcc.target/loongarch/la64/zero-size-field-pass.c: New test.
* gcc.target/loongarch/la64/zero-size-field-ret.c: New test.
* gcc.target/loongarch/vector/lasx/abd-lasx.c: New test.
* gcc.target/loongarch/vector/lasx/avg-ceil-lasx.c: New test.
* gcc.target/loongarch/vector/lasx/avg-floor-lasx.c: New test.
* gcc.target/loongarch/vector/lasx/fnmam4-vec.c: New test.
* gcc.target/loongarch/vector/lasx/lasx-andn-iorn.c: New test.
* gcc.target/loongarch/vector/lasx/lasx-extract-even_odd-opt.c: New test.
* gcc.target/loongarch/vector/lasx/lasx-func-attr-2.c: New test.
* gcc.target/loongarch/vector/lasx/lasx-pragma-attr-2.c: New test.
* gcc.target/loongarch/vector/lasx/lasx-reduc-1.c: New test.
* gcc.target/loongarch/vector/lasx/lasx-xvpermi_q-opt.c: New test.
* gcc.target/loongarch/vector/lasx/pr112476-2.c: New test.
* gcc.target/loongarch/vector/lasx/pr112476-4.c: New test.
* gcc.target/loongarch/vector/lasx/pr113033.c: New test.
* gcc.target/loongarch/vector/lasx/pragma-push-pop.c: New test.
* gcc.target/loongarch/vector/lasx/rotl-with-xvrotr-b.c: New test.
* gcc.target/loongarch/vector/lasx/rotl-with-xvrotr-d.c: New test.
* gcc.target/loongarch/vector/lasx/rotl-with-xvrotr-h.c: New test.
* gcc.target/loongarch/vector/lasx/rotl-with-xvrotr-w.c: New test.
* gcc.target/loongarch/vector/lasx/sad-lasx.c: New test.
* gcc.target/loongarch/vector/lasx/strict-align.c: New test.
* gcc.target/loongarch/vector/lasx/vec_pack_unpack_256.c: New test.
* gcc.target/loongarch/vector/lasx/vec_reduc_half.c: New test.
* gcc.target/loongarch/vector/lasx/vect-extract.c: New test.
* gcc.target/loongarch/vector/lasx/vect-frint-no-inexact.c: New test.
* gcc.target/loongarch/vector/lasx/vect-frint.c: New test.
* gcc.target/loongarch/vector/lasx/vect-ftint-no-inexact.c: New test.
* gcc.target/loongarch/vector/lasx/vect-ftint.c: New test.
* gcc.target/loongarch/vector/lasx/vect-ld-st-imm12.c: New test.
* gcc.target/loongarch/vector/lasx/vect-muh.c: New test.
* gcc.target/loongarch/vector/lasx/vect-rotr.c: New test.
* gcc.target/loongarch/vector/lasx/vect-shuf-fp.c: New test.
* gcc.target/loongarch/vector/lasx/vect-slp-two-operator.c: New test.
* gcc.target/loongarch/vector/lasx/vect-widen-add.c: New test.
* gcc.target/loongarch/vector/lasx/vect-widen-mul.c: New test.
* gcc.target/loongarch/vector/lasx/vect-widen-sub.c: New test.
* gcc.target/loongarch/vector/lasx/vfmax-vfmin.c: New test.
* gcc.target/loongarch/vector/lasx/vrepli.c: New test.
* gcc.target/loongarch/vector/lasx/wide-mul-reduc-1.c: New test.
* gcc.target/loongarch/vector/lasx/wide-mul-reduc-2.c: New test.
* gcc.target/loongarch/vector/lasx/xvfcmp-d.c: New test.
* gcc.target/loongarch/vector/lasx/xvfcmp-f.c: New test.
* gcc.target/loongarch/vector/lsx/abd-lsx.c: New test.
* gcc.target/loongarch/vector/lsx/avg-ceil-lsx.c: New test.
* gcc.target/loongarch/vector/lsx/avg-floor-lsx.c: New test.
* gcc.target/loongarch/vector/lsx/lsx-andn-iorn.c: New test.
* gcc.target/loongarch/vector/lsx/lsx-func-attr-2.c: New test.
* gcc.target/loongarch/vector/lsx/lsx-pragma-attr-2.c: New test.
* gcc.target/loongarch/vector/lsx/mov-zero-1.c: New test.
* gcc.target/loongarch/vector/lsx/popcnt.c: New test.
* gcc.target/loongarch/vector/lsx/popcount.c: New test.
* gcc.target/loongarch/vector/lsx/pr112476-1.c: New test.
* gcc.target/loongarch/vector/lsx/pr112476-3.c: New test.
* gcc.target/loongarch/vector/lsx/pr119084.c: New test.
* gcc.target/loongarch/vector/lsx/pr121064.c: New test.
* gcc.target/loongarch/vector/lsx/pr122097.c: New test.
* gcc.target/loongarch/vector/lsx/rotl-with-vrotr-b.c: New test.
* gcc.target/loongarch/vector/lsx/rotl-with-vrotr-d.c: New test.
* gcc.target/loongarch/vector/lsx/rotl-with-vrotr-h.c: New test.
* gcc.target/loongarch/vector/lsx/rotl-with-vrotr-w.c: New test.
* gcc.target/loongarch/vector/lsx/sad-lsx.c: New test.
* gcc.target/loongarch/vector/lsx/vec_pack_unpack_128.c: New test.
* gcc.target/loongarch/vector/lsx/vect-frint-scalar-no-inexact.c: New test.
* gcc.target/loongarch/vector/lsx/vect-frint-scalar.c: New test.
* gcc.target/loongarch/vector/lsx/vect-shift-imm-round.c: New test.
* gcc.target/loongarch/vector/lsx/vector-func-attr-1.c: New test.
* gcc.target/loongarch/vector/lsx/vector-pragma-attr-1.c: New test.
* gcc.target/loongarch/vector/lsx/vfcmp-d.c: New test.
* gcc.target/loongarch/vector/lsx/vfcmp-f.c: New test.
* gcc.target/loongarch/vector/lsx/xorsign-run.c: New test.
* gcc.target/loongarch/vector/lsx/xorsign.c: New test.
mengqinggang [Thu, 11 Dec 2025 06:37:39 +0000 (14:37 +0800)]
LoongArch: Testcases for LA32
Delete LA64 testcases in gcc.target/loongarch.
Add a new path gcc.target/loongarch/la64 for LA64 testcases in next patch.
Delete vector testcases in gcc.target/loongarch.
Move these vector testcases to gcc.target/loongarch/vector/lsx
or gcc.target/loongarch/vector/lasx in next patch.
mengqinggang [Thu, 11 Dec 2025 06:23:57 +0000 (14:23 +0800)]
LoongArch: XALLOCAVEC allocate too large space on stack
Compare (length > la_max_inline_memcpy_size) and
(length <= align * LARCH_MAX_MOVE_OPS_STRAIGHT) is signed.
But loongarch_block_move_straight() -> XALLOCAVEC() -> alloca() allocate
space as unsigned value. It may result in segment fault if length > 0x7fffffff.
gcc/ChangeLog:
* config/loongarch/loongarch.cc (loongarch_block_move_loop): Change
length, align to unsigned.
(loongarch_expand_block_move): Ditto.
gcc/testsuite/ChangeLog:
* gcc.target/loongarch/la32/memcpy.c: New test.
Reviewed-by: Xi Ruoyao <xry111@xry111.site> Reviewed-by: Lulu Cheng <chenglulu@loongson.cn>
"insn 8" -1 operand can't match Yx constraint low_bitmask_len condition.
low_bitmask_len can selects a field of low-order bits within an item but not
the entire word. Add (match_test "INTVAL (op) == -1") to low_bitmask_operand
predicate.
Note: "uint64_t a & 0xffffffffffffffff" and "uint32_t a & 0xffffffff" are
optimized away before expand with -O0, can't cause this error.
gcc/ChangeLog:
* config/loongarch/predicates.md: Add CONSTM1_RTX for low_bitmask_operand.
gcc/testsuite/ChangeLog:
* gcc.target/loongarch/la32/and.c: New test.
* gcc.target/loongarch/la32/la32.exp: New test.
Reviewed-by: Xi Ruoyao <xry111@xry111.site> Reviewed-by: Lulu Cheng <chenglulu@loongson.cn>
mengqinggang [Tue, 25 Nov 2025 11:07:42 +0000 (19:07 +0800)]
LoongArch: C and .h files for LA32
gcc/ChangeLog:
* config/loongarch/loongarch-opts.cc (loongarch_target_option_override):
Delete opts->x_flag_pcc_struct_return and enable mstrict-align by
default on LA32.
* config/loongarch/loongarch.cc (loongarch_for_each_saved_reg): Save reg
depend on float abi.
(loongarch_explicit_relocs_p): Disable explicit relocs on LA32.
(loongarch_valid_offset_p): Disable const_imm16_operand with 4 byte aligned.
(loongarch_valid_lo_sum_p): Allow lo_sum to be used with DF in ilp32d.
(loongarch_valid_index_p): Disable ADDRESS_REG_REG on LA32.
(loongarch_legitimize_address): Disable mem_shadd_or_shadd_rtx_p on LA32.
(loongarch_output_move_index): Assert TARGET_64BIT for ldx/stx.
(loongarch_output_move): Disable ldptr/stptr if offset is 0.
(loongarch_output_equal_conditional_branch): Disable beqz/bnez on LA32R.
(loongarch_trampoline_init): Change pcaddi to pcaddu12i.
(loongarch_get_separate_components): Disable ldptr/stptr on LA32.
(loongarch_c_mode_for_floating_type): Use TFmode for long double
regardless of target bitness.
(loongarch_bitint_type_info): Disable BitInt on LA32.
(loongarch_call_tls_get_addr): Use call30 on LA32.
(loongarch_split_move): Add split for DI, DF, TF.
* config/loongarch/loongarch.h (LA_LONG_DOUBLE_TYPE_SIZE): Set
LONG_DOUBLE_TYPE_SIZE to 128 regardless of target bitness.
(MAX_FIXED_MODE_SIZE): Set to 64 on LA32.
(DEFAULT_PCC_STRUCT_RETURN): New.
(STACK_BOUNDARY): Set to 128 on LA64 and LA32.
(LARCH_STACK_ALIGN): Set to 16 on LA64 and LA32.
(TRAMPOLINE_SIZE): Set to same value on LA64 and LA32.
include/ChangeLog:
* longlong.h (count_leading_zeros): Delete because LA32R no clz.
(count_trailing_zeros): Delete because LA32R no ctz.
(COUNT_LEADING_ZEROS_0): Delete.
mengqinggang [Wed, 5 Nov 2025 02:55:13 +0000 (10:55 +0800)]
LoongArch: Introduce LoongArch32 target
Introduce LoongArch32 (LA32) ilp32d abi and LoongArch32 Reduced (LA32R) ilp32s abi.
Add march la32v1.0 and la32rv1.0.
Add mtune loongarch32 as a general tune.
Add la32 march and mtune to gcc/doc/invoke.texi.
contrib/ChangeLog:
* config-list.mk: Add loongarch32-linux-gnu*.
gcc/ChangeLog:
* config.gcc: Add target triple loongarch32-*-*-* and
corresponding abi ilp32f, ilp32d and ilp32s.
* config/loongarch/genopts/loongarch-strings: Add strings for
loongarch32 and ilp32 abi variants.
* config/loongarch/genopts/loongarch.opt.in: Add
-march=la32v1.0/la32rv1.0 and -mabi=ilp32d/ilp32f/ilp32s.
* config/loongarch/gnu-user.h: Add ilp32 abi variants to spec.
* config/loongarch/linux.h: Add ABI_LIBDIR for ilp32 abi
variants.
* config/loongarch/loongarch-c.cc (loongarch_define_unconditional_macros):
Add builtin definitions for loongarch32 target.
* config/loongarch/loongarch-def.cc: Add loongarch32 and ilp32
definitions.
* config/loongarch/loongarch-def.h: Add loongarch32 and ilp32
definitions.
* config/loongarch/loongarch-driver.h: Add ilp32 abi variants to
spec.
* config/loongarch/loongarch-opts.cc: Handle ilp32 abi variants.
* config/loongarch/loongarch-opts.h: Add loongarch32 case to
macros.
* config/loongarch/loongarch-str.h: Add loongarch32 and ilp32
strings.
* config/loongarch/loongarch.opt: Add -march=la32v1.0/la32rv1.0
and -mabi=ilp32d/ilp32f/ilp32s.
* config/loongarch/t-linux: Add ilp32 abi variants to multilib.
* doc/invoke.texi: Add LA32 arch and tune.
Jose E. Marchesi [Fri, 12 Dec 2025 02:43:38 +0000 (03:43 +0100)]
a68: emit proper error for empty source file
Ok this is an embarrassing one. A source file that is either empty or
that contains just blanks, characters and/or pragmats, is not a proper
particular program nor a prelude packet. This patch makes ga68 to
emit an error mesage rather than ICEing.
Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
gcc/algol68/ChangeLog
* a68-parser-scanner.cc (a68_lexical_analyser): New argument
empty_program.
* a68.h: Update prototype of a68_lexical_analyser.
* a68-parser.cc (a68_parser): Emit error for empty input files.