From 8a2256dda3eb92563d08180b8dff95c5a4ec45b7 Mon Sep 17 00:00:00 2001 From: Martin Jambor Date: Thu, 15 May 2014 17:04:18 +0200 Subject: [PATCH] re PR ipa/61085 (wrong code with -O2 -fno-early-inlining (maybe wrong devirtualization)) 2014-05-15 Martin Jambor 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 | 6 ++++++ gcc/ipa-prop.c | 12 +++++++---- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/ipa/pr61085.C | 33 ++++++++++++++++++++++++++++++ 4 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ipa/pr61085.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 960927c7228..2ddb6dd00cf 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2014-05-15 Martin Jambor + + 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 PR tree-optimization/61090 diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index f4b9b3bdd7f..e372171114e 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -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 { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0a43475ee70..96b63036f3a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-05-15 Martin Jambor + + PR ipa/61085 + * g++.dg/ipa/pr61085.C: New test. + 2014-05-15 Martin Jambor 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 index 00000000000..531f59d5302 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr61085.C @@ -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; +}