https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128602
Bug ID: 128602
Summary: ICE in callback_redirect_edge with a callback_only
clone that has no parameters
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: ice-on-valid-code
Severity: normal
Priority: P3
Component: ipa
Assignee: unassigned at gcc dot gnu.org
Reporter: konstantinos.eleftheriou at vrull dot eu
CC: ptomsich at gcc dot gnu.org
Target Milestone: ---
Target: aarch64-linux-gnu
Created attachment 66129
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=66129&action=edit
testcase
The attached testcase.c ICEs at -O3 on
trunk (r17-5988-g06c476d192702a07dc6a8431b7f1a54d7526d3a5), configured with
--enable-checking=yes,extra:
$ gcc -O3 testcase.c
during IPA pass: inline
testcase.c: In function 'run':
testcase.c:17:1: internal compiler error: in gimple_call_arg, at gimple.h:3369
17 | run (void)
| ^~~
0x26d0a53 internal_error(char const*, ...)
../../gcc/gcc/diagnostic-global-context.cc:787
0x845c8f fancy_abort(char const*, int, char const*)
../../gcc/gcc/diagnostics/context.cc:1813
0x1566f7b gimple_call_arg(gcall const*, unsigned int)
../../gcc/gcc/gimple.h:3369
0x1566f7b gimple_call_arg(gcall const*, unsigned int)
../../gcc/gcc/gimple.h:3367
0x1566f7b callback_redirect_edge(cgraph_edge*)
../../gcc/gcc/attr-callback.cc:195
0xaa7f23 cgraph_edge::redirect_call_stmt_to_callee(cgraph_edge*,
hash_set<tree_node*, false, default_hash_traits<tree_node*> >*)
../../gcc/gcc/cgraph.cc:1903
0xdc3633 inline_transform(cgraph_node*)
../../gcc/gcc/ipa-inline-transform.cc:860
0xf6fe9b execute_one_ipa_transform_pass
../../gcc/gcc/passes.cc:2332
0xf6fe9b execute_all_ipa_transforms(bool)
../../gcc/gcc/passes.cc:2395
0xab15eb cgraph_node::expand()
../../gcc/gcc/cgraphunit.cc:1868
0xab15eb cgraph_node::expand()
../../gcc/gcc/cgraphunit.cc:1828
0xab2f8b expand_all_functions
../../gcc/gcc/cgraphunit.cc:2058
0xab2f8b symbol_table::compile()
../../gcc/gcc/cgraphunit.cc:2436
0xab632b symbol_table::compile()
../../gcc/gcc/cgraphunit.cc:2349
0xab632b symbol_table::finalize_compilation_unit()
../../gcc/gcc/cgraphunit.cc:2627
It also ICEs with -O2 -fipa-cp-clone and at -O3 without "static" on dispatch.
-O2, -O3 -fno-ipa-cp and -O3 -fno-ipa-cp-clone compile it.
IPA-CP replaces both parameters of dispatch (fn by kernel, k by 3), so
dispatch.constprop has none left. build_new_function_type only checks for
modified arguments inside "if (m_adj_params)", and m_adj_params is NULL here,
so adjust_decl keeps callback_only on the clone and the callback edge to
kernel.constprop is not purged. Redirecting that edge in inline_transform
then calls gimple_call_arg (stmt, 0) on dispatch.constprop ().
If the clone keeps a parameter, the attribute is dropped. With a second
caller that passes a variable k, -fdump-ipa-cp-details shows for the edge to
that caller's clone:
Purging callbacks, because the callback-dispatchingfunction no longer has
any callback attributes.