]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR ipa/61085 (wrong code with -O2 -fno-early-inlining (maybe wrong devirtualization))
authorMartin Jambor <mjambor@suse.cz>
Thu, 15 May 2014 15:04:18 +0000 (17:04 +0200)
committerMartin Jambor <jamborm@gcc.gnu.org>
Thu, 15 May 2014 15:04:18 +0000 (17:04 +0200)
2014-05-15  Martin Jambor  <mjambor@suse.cz>

PR ipa/61085
* ipa-prop.c (update_indirect_edges_after_inlining): Check
type_preserved flag when the indirect edge is polymorphic.

testsuite/
* g++.dg/ipa/pr61085.C: New test.

From-SVN: r210477

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

index 960927c7228064cca55ffb445874f64af89fb53d..2ddb6dd00cf602b685d42dad5c864f8647fec0ac 100644 (file)
@@ -1,3 +1,9 @@
+2014-05-15  Martin Jambor  <mjambor@suse.cz>
+
+       PR ipa/61085
+       * ipa-prop.c (update_indirect_edges_after_inlining): Check
+       type_preserved flag when the indirect edge is polymorphic.
+
 2014-05-15  Martin Jambor  <mjambor@suse.cz>
 
        PR tree-optimization/61090
index f4b9b3bdd7f4dffbfa46c061b2735f0cf228f327..e372171114e8750d2960648d5e5c8bd6f0d3ba98 100644 (file)
@@ -2877,16 +2877,20 @@ update_indirect_edges_after_inlining (struct cgraph_edge *cs,
       else if (jfunc->type == IPA_JF_PASS_THROUGH
               && ipa_get_jf_pass_through_operation (jfunc) == NOP_EXPR)
        {
-         if (ici->agg_contents
-             && !ipa_get_jf_pass_through_agg_preserved (jfunc))
+         if ((ici->agg_contents
+              && !ipa_get_jf_pass_through_agg_preserved (jfunc))
+             || (ici->polymorphic
+                 && !ipa_get_jf_pass_through_type_preserved (jfunc)))
            ici->param_index = -1;
          else
            ici->param_index = ipa_get_jf_pass_through_formal_id (jfunc);
        }
       else if (jfunc->type == IPA_JF_ANCESTOR)
        {
-         if (ici->agg_contents
-             && !ipa_get_jf_ancestor_agg_preserved (jfunc))
+         if ((ici->agg_contents
+              && !ipa_get_jf_ancestor_agg_preserved (jfunc))
+             || (ici->polymorphic
+                 && !ipa_get_jf_ancestor_type_preserved (jfunc)))
            ici->param_index = -1;
          else
            {
index 0a43475ee70fad61a88b0ee4d735da92701336bf..96b63036f3a5c878a10d0da6864003b89a7b5fa7 100644 (file)
@@ -1,3 +1,8 @@
+2014-05-15  Martin Jambor  <mjambor@suse.cz>
+
+       PR ipa/61085
+       * g++.dg/ipa/pr61085.C: New test.
+
 2014-05-15  Martin Jambor  <mjambor@suse.cz>
 
        PR tree-optimization/61090
diff --git a/gcc/testsuite/g++.dg/ipa/pr61085.C b/gcc/testsuite/g++.dg/ipa/pr61085.C
new file mode 100644 (file)
index 0000000..531f59d
--- /dev/null
@@ -0,0 +1,33 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-early-inlining" } */
+
+struct A {};
+struct B : virtual A {
+  unsigned m_i;
+  B() : m_i () {}
+  virtual A *m_virt ()
+  {
+    return 0;
+  }
+  ~B ()
+  {
+    m_foo ();
+    while (m_i)
+      ;
+  }
+  void m_foo ()
+  {
+    m_virt ();
+  }
+};
+
+class C : B {
+  A *m_virt () {
+    __builtin_abort ();
+  }
+};
+
+int main ()
+{
+  C c;
+}