]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Backport r247097
authorMartin Liska <mliska@suse.cz>
Mon, 29 May 2017 09:13:50 +0000 (11:13 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Mon, 29 May 2017 09:13:50 +0000 (09:13 +0000)
2017-05-29  Martin Liska  <mliska@suse.cz>

Backport from mainline
2017-04-24  Jan Hubicka  <hubicka@ucw.cz>

PR middle-end/79931
* ipa-devirt.c (dump_possible_polymorphic_call_targets): Fix ICE.
2017-05-29  Martin Liska  <mliska@suse.cz>

Backport from mainline
2017-04-24  Martin Liska  <mliska@suse.cz>

PR middle-end/79931
* g++.dg/ipa/pr79931.C: New test.

From-SVN: r248569

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

index ee556b7e7e31d15ab64563438f07dd2788d64854..514581d350b3c5d7a9baf545e750116787f1de1a 100644 (file)
@@ -1,3 +1,11 @@
+2017-05-29  Martin Liska  <mliska@suse.cz>
+
+       Backport from mainline
+       2017-04-24  Jan Hubicka  <hubicka@ucw.cz>
+
+       PR middle-end/79931
+       * ipa-devirt.c (dump_possible_polymorphic_call_targets): Fix ICE.
+
 2017-05-29  Martin Liska  <mliska@suse.cz>
 
        Backport from mainline
index c165bceb16b73eeb8ac8c4939a2b79a75fc68fd2..08cfa8033f01d83ff9de872e555327f9edec8eba 100644 (file)
@@ -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");
 }
 
index d64e5e8f90fbd679344387455afc99d8834086c2..f9c9aaa751bb69150c3a07ee4f74b1cfe4a34c9e 100644 (file)
@@ -1,3 +1,11 @@
+2017-05-29  Martin Liska  <mliska@suse.cz>
+
+       Backport from mainline
+       2017-04-24  Martin Liska  <mliska@suse.cz>
+
+       PR middle-end/79931
+       * g++.dg/ipa/pr79931.C: New test.
+
 2017-05-29  Martin Liska  <mliska@suse.cz>
 
        Backport from mainline
diff --git a/gcc/testsuite/g++.dg/ipa/pr79931.C b/gcc/testsuite/g++.dg/ipa/pr79931.C
new file mode 100644 (file)
index 0000000..78f6e03
--- /dev/null
@@ -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();
+}