Patchwork Fix corruption of call site hash with speculative edges

login
register
mail settings
Submitter Jan Hubicka
Date Aug. 20, 2013, 9:42 p.m.
Message ID <20130820214203.GC24782@kam.mff.cuni.cz>
Download mbox | patch
Permalink /patch/268653/
State New
Headers show

Comments

Jan Hubicka - Aug. 20, 2013, 9:42 p.m.
Hi,
this patch should fix cgrpah verifier ICE that occurs for speculative calls
with call site hash in caller.   Here we manage to wrong non-speculative
edge into the hash from time to time, when the edges are copied by inliner.

This patch fixes the problema and also fixes problem in
cgraph_turn_edge_to_speculative I noticed independently where
can_throw_external is not cleared when callee is nothrow.

Bootstrapped/regtested x86_64-linux and also profiledbootstrapped.
Will commit it shortly.
I get occasional ICE in verifier for dead refs after saving inline
body.  I will look into that next.

Honza

	PR bootstrap/58186
	* cgraph.c (cgraph_add_edge_to_call_site_hash): Overwrite hash
	entry for direct edges.
	(cgraph_turn_edge_to_speculative): Fix setting of can_throw_external.

Patch

Index: cgraph.c
===================================================================
--- cgraph.c	(revision 201838)
+++ cgraph.c	(working copy)
@@ -701,6 +701,8 @@  cgraph_add_edge_to_call_site_hash (struc
   if (*slot)
     {
       gcc_assert (((struct cgraph_edge *)*slot)->speculative);
+      if (e->callee)
+	*slot = e;
       return;
     }
   gcc_assert (!*slot || e->speculative);
@@ -1083,8 +1085,10 @@  cgraph_turn_edge_to_speculative (struct
   e2 = cgraph_create_edge (n, n2, e->call_stmt, direct_count, direct_frequency);
   initialize_inline_failed (e2);
   e2->speculative = true;
-  e2->call_stmt = e->call_stmt;
-  e2->can_throw_external = e->can_throw_external;
+  if (TREE_NOTHROW (n2->symbol.decl))
+    e2->can_throw_external = false;
+  else
+    e2->can_throw_external = e->can_throw_external;
   e2->lto_stmt_uid = e->lto_stmt_uid;
   e->count -= e2->count;
   e->frequency -= e2->frequency;