diff mbox

Fix ordering issue with speculation reoslution

Message ID 20150205001728.GD31160@kam.mff.cuni.cz
State New
Headers show

Commit Message

Jan Hubicka Feb. 5, 2015, 12:17 a.m. UTC
Hi,
this patch fixes issue with speculation - update is needed between every resolution
and key insertion.

Bootstrapped/regtested x86_64-linux, comitted.

Honza

	PR ipa/64686
	* ipa-inline.c (inline_small_functions): Fix ordering issue between
	speculation resolution and key updates.
	* g++.dg/torture/pr64686.C: New testcase.
diff mbox

Patch

Index: ipa-inline.c
===================================================================
--- ipa-inline.c	(revision 220417)
+++ ipa-inline.c	(working copy)
@@ -1702,6 +1702,7 @@  inline_small_functions (void)
     {
       bool update = false;
       struct cgraph_edge *next;
+      bool has_speculative = false;
 
       if (dump_file)
 	fprintf (dump_file, "Enqueueing calls in %s/%i.\n",
@@ -1719,12 +1720,17 @@  inline_small_functions (void)
 	      gcc_assert (!edge->aux);
 	      update_edge_key (&edge_heap, edge);
 	    }
-	  if (edge->speculative && !speculation_useful_p (edge, edge->aux != NULL))
+	  if (edge->speculative)
+	    has_speculative = true;
+	}
+      if (has_speculative)
+	for (edge = node->callees; edge; edge = next)
+	  if (edge->speculative && !speculation_useful_p (edge,
+							  edge->aux != NULL))
 	    {
 	      edge->resolve_speculation ();
 	      update = true;
 	    }
-	}
       if (update)
 	{
 	  struct cgraph_node *where = node->global.inlined_to
Index: testsuite/g++.dg/torture/pr64686.C
===================================================================
--- testsuite/g++.dg/torture/pr64686.C	(revision 0)
+++ testsuite/g++.dg/torture/pr64686.C	(revision 0)
@@ -0,0 +1,19 @@ 
+// { dg-do compile }
+class A
+{
+protected:
+  A *m_fn2 (int) const;
+public:
+  virtual A *m_fn1 (int *) const = 0;
+};
+class B : A
+{
+  B (A *, int, A *);
+  A *m_fn1 (int *) const;
+};
+A *
+B::m_fn1 (int *) const
+{
+  new B (m_fn2 (0)->m_fn1 (0), 0, m_fn2 (0)->m_fn1 (0));
+}
+