Fix g++.dg/torture/pr59226.C

Message ID
State New
Headers show
  • Fix g++.dg/torture/pr59226.C
Related show

Commit Message

Jan Hubicka Dec. 5, 2019, 10:08 a.m.
this patch fixes ICE in g++.dg/torture/pr59226.C which was triggered by
new comdat_local sanity check.  What happens here is that function gets
inlined into its own thunk which makes it !comdat_local_p but the updating
code does not notice since thunk calls comdat local alias of the function
itself and we look at alias target rather than original callee.

This also shows that we miss optimization here.  Currently we will not inline
thunk out of its comdat local group w/o inlining function it is associated with
into it.

We should teach inline_call to reoslve edges to aliases while inlining and 
relax calls_comdat_local flag.  But this needs bit more work, so I fix the
ICE first.

Bootstrap running on x86_64-linux, will commit it after testing finishes.

	* ipa-inline-transform.c (inline_call): Fix maintenatnce of comdat_local


Index: ipa-inline-transform.c
--- ipa-inline-transform.c	(revision 278959)
+++ ipa-inline-transform.c	(working copy)
@@ -331,6 +331,7 @@  inline_call (struct cgraph_edge *e, bool
   int old_size = 0, new_size = 0;
   struct cgraph_node *to = NULL;
   struct cgraph_edge *curr = e;
+  bool comdat_local = e->callee->comdat_local_p ();
   struct cgraph_node *callee = e->callee->ultimate_alias_target ();
   bool new_edges_found = false;
@@ -502,7 +503,7 @@  inline_call (struct cgraph_edge *e, bool
   if (callee->calls_comdat_local)
     to->calls_comdat_local = true;
-  else if (to->calls_comdat_local && callee->comdat_local_p ())
+  else if (to->calls_comdat_local && comdat_local)
       struct cgraph_edge *se = to->callees;
       for (; se; se = se->next_callee)