summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2015-01-18 17:31:35 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2015-01-18 17:31:35 +0000
commit2c9d5cb8354d561bbfa418895cb6158c1c855e75 (patch)
tree5e9c965ac3ae352399fa5d34e07ea24667cf9498 /gcc
parentdd920757d437ffa60a0f9b008e57507d4c8ee831 (diff)
downloadgcc-2c9d5cb8354d561bbfa418895cb6158c1c855e75.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@219822 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/ipa-cp.c9
-rw-r--r--gcc/ipa-prop.c3
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/torture/pr64378.C24
5 files changed, 45 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index bbf60d69f2e..00a9622928d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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]):
diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index 44f16bf86f2..90fd3c29191 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -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;
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index 6807c22d7ed..9c8a785ceeb 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -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
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a902dc30f03..e6972b8f4f4 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 00000000000..6770601eaf2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr64378.C
@@ -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);
+}