From df314687531986d3a06b309e226a1e5fc7cdfc01 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 24 Apr 2017 13:16:34 +0000
Subject: [PATCH 12/12] Backport r247097
gcc/ChangeLog:
2017-04-24 Jan Hubicka <hubicka@ucw.cz>
PR middle-end/79931
* ipa-devirt.c (dump_possible_polymorphic_call_targets): Fix ICE.
gcc/testsuite/ChangeLog:
2017-04-24 Martin Liska <mliska@suse.cz>
PR middle-end/79931
* g++.dg/ipa/pr79931.C: New test.
---
gcc/ipa-devirt.c | 8 +++++++-
gcc/testsuite/g++.dg/ipa/pr79931.C | 24 ++++++++++++++++++++++++
2 files changed, 31 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/g++.dg/ipa/pr79931.C
@@ -3211,7 +3211,13 @@ dump_possible_polymorphic_call_targets (FILE *f,
fprintf (f, " Speculative targets:");
dump_targets (f, targets);
}
- gcc_assert (targets.length () <= len);
+ /* Ugly: during callgraph construction the target cache may get populated
+ before all targets are found. While this is harmless (because all local
+ types are discovered and only in those case we devirtualize fully and we
+ don't do speculative devirtualization before IPA stage) it triggers
+ assert here when dumping at that stage also populates the case with
+ speculative targets. Quietly ignore this. */
+ gcc_assert (symtab->state < IPA_SSA || targets.length () <= len);
fprintf (f, "\n");
}
new file mode 100644
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-all" } */
+
+class DocumentImpl;
+struct NodeImpl
+{
+ virtual DocumentImpl * getOwnerDocument();
+ virtual NodeImpl * getParentNode();
+ virtual NodeImpl * removeChild(NodeImpl *oldChild);
+};
+struct AttrImpl : NodeImpl
+{
+ NodeImpl *insertBefore(NodeImpl *newChild, NodeImpl *refChild);
+};
+struct DocumentImpl : NodeImpl
+{
+ virtual NodeImpl *removeChild(NodeImpl *oldChild);
+ virtual int* getRanges();
+};
+NodeImpl *AttrImpl::insertBefore(NodeImpl *newChild, NodeImpl *refChild) {
+ NodeImpl *oldparent = newChild->getParentNode();
+ oldparent->removeChild(newChild);
+ this->getOwnerDocument()->getRanges();
+}
--
2.12.2