aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Jambor <mjambor@suse.cz>2016-08-09 18:05:30 +0200
committerMartin Jambor <jamborm@gcc.gnu.org>2016-08-09 18:05:30 +0200
commit04d6d3b6d77d247616543dedad7ee239368591a5 (patch)
treefb415bd7783c05576d00d25478e6a73a42af2380
parent045f240b97c75ad7e8f27a6464ae5b6857128fbe (diff)
downloadgcc-04d6d3b6d77d247616543dedad7ee239368591a5.zip
gcc-04d6d3b6d77d247616543dedad7ee239368591a5.tar.gz
gcc-04d6d3b6d77d247616543dedad7ee239368591a5.tar.bz2
[PR ipa/71981] Make get_dynamic_type grok MEM_REF
2016-08-09 Martin Jambor <mjambor@suse.cz> PR ipa/71981 * ipa-polymorphic-call.c (get_dynamic_type): Bail out gracefully if instance is a MEM_REF. testsuite/ PR ipa/71981 * gcc.dg/ipa/pr71981.c: New test. From-SVN: r239294
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/ipa-polymorphic-call.c6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/ipa/pr71981.c10
4 files changed, 26 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 7ae8055..854dea5 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2016-08-09 Martin Jambor <mjambor@suse.cz>
+
+ PR ipa/71981
+ * ipa-polymorphic-call.c (get_dynamic_type): Bail out gracefully
+ if instance is a MEM_REF.
+
2016-08-09 Uros Bizjak <ubizjak@gmail.com>
PR target/72843
diff --git a/gcc/ipa-polymorphic-call.c b/gcc/ipa-polymorphic-call.c
index 56f3344..f7ef6aa 100644
--- a/gcc/ipa-polymorphic-call.c
+++ b/gcc/ipa-polymorphic-call.c
@@ -1544,6 +1544,11 @@ ipa_polymorphic_call_context::get_dynamic_type (tree instance,
if (!maybe_in_construction && !maybe_derived_type)
return false;
+ /* If we are in fact not looking at any object object or the instance is
+ some placement new into a random load, give up straight away. */
+ if (TREE_CODE (instance) == MEM_REF)
+ return false;
+
/* We need to obtain refernce to virtual table pointer. It is better
to look it up in the code rather than build our own. This require bit
of pattern matching, but we end up verifying that what we found is
@@ -1664,7 +1669,6 @@ ipa_polymorphic_call_context::get_dynamic_type (tree instance,
tci.offset = instance_offset;
tci.instance = instance;
tci.vtbl_ptr_ref = instance_ref;
- gcc_assert (TREE_CODE (instance) != MEM_REF);
tci.known_current_type = NULL_TREE;
tci.known_current_offset = 0;
tci.otr_type = otr_type;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5674f97b..3483469 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-08-09 Martin Jambor <mjambor@suse.cz>
+
+ PR ipa/71981
+ * gcc.dg/ipa/pr71981.c: New test.
+
2016-08-09 Bin Cheng <bin.cheng@arm.com>
PR tree-optimization/33707
diff --git a/gcc/testsuite/gcc.dg/ipa/pr71981.c b/gcc/testsuite/gcc.dg/ipa/pr71981.c
new file mode 100644
index 0000000..1b21602
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/pr71981.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -w" } */
+
+int **a;
+static void fn1(char **p1) {
+ char s = *p1, b = &s;
+ while (*fn2()[a])
+ ;
+}
+int main() { fn1(""); return 0; }