https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91299
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot
gnu.org
--- Comment #19 from Richard Biener <rguenth at gcc dot gnu.org> ---
OK, so this goes wrong in
#0 cgraph_node::get_availability (
this=<cgraph_node * const 0x7ffff6818220 "get_t"/0>,
ref=<symtab_node * 0x0>) at ../../src/gcc/gcc/cgraph.cc:2393
#1 0x0000000000e9791c in symtab_node::get_availability (
this=<symtab_node * const 0x7ffff6818220 "get_t"/0>,
ref=<symtab_node * 0x7ffff6818330 "main"/2>)
at ../../src/gcc/gcc/cgraph.h:3395
#2 0x0000000000e9780b in symtab_node::ultimate_alias_target (
this=<symtab_node * const 0x7ffff6818220 "get_t"/0>,
availability=0x7fffffffd664, ref=<symtab_node * 0x7ffff6818330 "main"/2>)
at ../../src/gcc/gcc/cgraph.h:3236
#3 0x0000000000faf73b in cgraph_node::ultimate_alias_target (
this=<cgraph_node * const 0x7ffff6818220 "get_t"/0>,
availability=0x7fffffffd664, ref=<symtab_node * 0x7ffff6818330 "main"/2>)
at ../../src/gcc/gcc/cgraph.h:3254
#4 0x00000000033053bd in can_inline_edge_p (
e=<cgraph_edge* 0x7ffff680b1a0 (<cgraph_node * 0x7ffff6818330 "main"/2> ->
<cgraph_node * 0x7ffff6818220 "get_t"/0>)>, report=true, early=false)
at ../../src/gcc/gcc/ipa-inline.cc:385
as get_availability computes AVAIL_AVAILABLE because the node is
!externally_visible (IPA visibility promoted it local since it was interposed).
The later
else if (decl_replaceable_p (decl, semantic_interposition)
&& !DECL_EXTERNAL (decl))
avail = AVAIL_INTERPOSABLE;
wouldn't trigger since DECL_EXTERNAL (decl) is set.
get_t/1 (get_t)
Type: function definition analyzed
Visibility: semantic_interposition preempted_reg external public weak
References:
Referring:
Read from file: t.o
Availability: available
Unit id: 1
Function flags: count:1073741824 (estimated locally)
Called by: main/2 (1073741824 (estimated locally),1.00 per call)
Calls:
DECL_EXTERNAL is set by lto_symtab_merge_symbols but it's set too early
so the
else if (!node->alias
&& node->definition
&& node->get_availability () <= AVAIL_INTERPOSABLE)
check suffers from the above issue, failing to return AVAIL_INTERPOSABLE.
The following should fix it.
diff --git a/gcc/lto/lto-symtab.cc b/gcc/lto/lto-symtab.cc
index bc3c144e444..66674a4415f 100644
--- a/gcc/lto/lto-symtab.cc
+++ b/gcc/lto/lto-symtab.cc
@@ -1016,7 +1016,6 @@ lto_symtab_merge_symbols (void)
|| node->resolution == LDPR_RESOLVED_EXEC
|| node->resolution == LDPR_RESOLVED_DYN))
{
- DECL_EXTERNAL (node->decl) = 1;
/* If alias to local symbol was preempted by external definition,
we know it is not pointing to the local symbol. Remove it.
*/
if (node->alias
@@ -1042,6 +1041,7 @@ lto_symtab_merge_symbols (void)
node->remove_all_references ();
}
}
+ DECL_EXTERNAL (node->decl) = 1;
}
if (!(cnode = dyn_cast <cgraph_node *> (node))