re PR ipa/64378 (ICE: in inline_call, at ipa-inline-transform.c:347 with -O3 -fno...
authorJan Hubicka <hubicka@ucw.cz>
Sun, 18 Jan 2015 17:31:35 +0000 (18:31 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Sun, 18 Jan 2015 17:31:35 +0000 (17:31 +0000)
PR ipa/64378
* ipa-prop.c (try_make_edge_direct_virtual_call): Clear speculative
flag correctly.
* ipa-cp.c (ipa_get_indirect_edge_target_1): Handle speculation.
* g++.dg/torture/pr64378.C: New testcase.

From-SVN: r219822

gcc/ChangeLog
gcc/ipa-cp.c
gcc/ipa-prop.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr64378.C [new file with mode: 0644]

index bbf60d69f2ef2821a3d502786f5758d77d0675c1..00a9622928db35a09735a58abb719e4149d8c5ef 100644 (file)
@@ -1,3 +1,10 @@
+2015-01-18  Jan Hubicka  <hubicka@ucw.cz>
+
+       PR ipa/64378
+       * ipa-prop.c (try_make_edge_direct_virtual_call): Clear speculative
+       flag correctly.
+       * ipa-cp.c (ipa_get_indirect_edge_target_1): Handle speculation.
+
 2015-01-18  Sandra Loosemore  <sandra@codesourcery.com>
 
        * doc/invoke.texi ([-funroll-loops], [-funroll-all-loops]):
index 44f16bf86f29d691f2ee9c27ae52cc07be01d2ae..90fd3c29191ef2aa0a147eef04fb17de245e5e53 100644 (file)
@@ -1975,8 +1975,13 @@ ipa_get_indirect_edge_target_1 (struct cgraph_edge *ie,
        }
     }
   else if (t)
-    context = ipa_polymorphic_call_context (t, ie->indirect_info->otr_type,
-                                           anc_offset);
+    {
+      context = ipa_polymorphic_call_context (t, ie->indirect_info->otr_type,
+                                             anc_offset);
+      if (ie->indirect_info->vptr_changed)
+       context.possible_dynamic_type_change (ie->in_polymorphic_cdtor,
+                                             ie->indirect_info->otr_type);
+    }
   else
     return NULL_TREE;
 
index 6807c22d7ed9105d1edfa2c5f36a968cf2424e00..9c8a785ceebd573a60252fc86a8f6d21f01af51f 100644 (file)
@@ -2985,7 +2985,7 @@ try_make_edge_direct_virtual_call (struct cgraph_edge *ie,
                  || !possible_polymorphic_call_target_p
                       (ie, cgraph_node::get (t)))
                {
-                 /* Do not speculate builtin_unreachable, it is stpid!  */
+                 /* Do not speculate builtin_unreachable, it is stupid!  */
                  if (!ie->indirect_info->vptr_changed)
                    target = ipa_impossible_devirt_target (ie, target);
                }
@@ -3013,6 +3013,7 @@ try_make_edge_direct_virtual_call (struct cgraph_edge *ie,
      ctx, &final);
   if (final && targets.length () <= 1)
     {
+      speculative = false;
       if (targets.length () == 1)
        target = targets[0]->decl;
       else
index a902dc30f03cbcd8c7bf3ad2fa785caa2958a3f0..e6972b8f4f4d88c23ede9dd0a70d2637f52f31fa 100644 (file)
@@ -1,3 +1,8 @@
+2015-01-18  Jan Hubicka  <hubicka@ucw.cz>
+
+       PR ipa/64378
+       * g++.dg/torture/pr64378.C: New testcase.
+
 2015-01-18  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/57959
diff --git a/gcc/testsuite/g++.dg/torture/pr64378.C b/gcc/testsuite/g++.dg/torture/pr64378.C
new file mode 100644 (file)
index 0000000..6770601
--- /dev/null
@@ -0,0 +1,24 @@
+// { dg-do compile }
+// { dg-options "-fno-ipa-cp" }
+struct data {
+  data(int) {}
+};
+
+struct top {
+  virtual int topf() {}
+};
+
+struct child1: top {
+    void childf()
+    {
+        data d(topf());
+    }
+};
+
+void test(top *t)
+{
+    child1 *c = static_cast<child1 *>(t);
+    c->childf();
+    child1 d;
+    test(&d);
+}