public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Handle PHI nodes w/o a argument (PR ipa/80205).
@ 2017-03-27 12:51 Martin Liška
  2017-03-27 14:25 ` Richard Biener
  0 siblings, 1 reply; 7+ messages in thread
From: Martin Liška @ 2017-03-27 12:51 UTC (permalink / raw)
  To: GCC Patches; +Cc: Jan Hubicka

[-- Attachment #1: Type: text/plain, Size: 264 bytes --]

Hello.

As described in the PR, we can create a PHI node in einline that has no argument.
That can cause ICE in devirtualization and should be thus handled.

Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.

Ready to be installed?
Martin

[-- Attachment #2: 0001-Handle-PHI-nodes-w-o-a-argument-PR-ipa-80205.patch --]
[-- Type: text/x-patch, Size: 1848 bytes --]

From d0dc319a8df5d9f00434f54fef13b3dc427061e1 Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Mon, 27 Mar 2017 13:32:52 +0200
Subject: [PATCH] Handle PHI nodes w/o a argument (PR ipa/80205).

gcc/testsuite/ChangeLog:

2017-03-27  Martin Liska  <mliska@suse.cz>

	* g++.dg/ipa/pr80205.C: New test.

gcc/ChangeLog:

2017-03-27  Martin Liska  <mliska@suse.cz>

	PR ipa/80205
	* ipa-polymorphic-call.c (walk_ssa_copies): Handle phi nodes
	w/o a argument.
---
 gcc/ipa-polymorphic-call.c         |  2 +-
 gcc/testsuite/g++.dg/ipa/pr80205.C | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/ipa/pr80205.C

diff --git a/gcc/ipa-polymorphic-call.c b/gcc/ipa-polymorphic-call.c
index e690d05158d..89c008ee5c0 100644
--- a/gcc/ipa-polymorphic-call.c
+++ b/gcc/ipa-polymorphic-call.c
@@ -828,7 +828,7 @@ walk_ssa_copies (tree op, hash_set<tree> **global_visited = NULL)
 	{
 	  gimple *phi = SSA_NAME_DEF_STMT (op);
 
-	  if (gimple_phi_num_args (phi) > 2)
+	  if (gimple_phi_num_args (phi) == 0 || gimple_phi_num_args (phi) > 2)
 	    goto done;
 	  if (gimple_phi_num_args (phi) == 1)
 	    op = gimple_phi_arg_def (phi, 0);
diff --git a/gcc/testsuite/g++.dg/ipa/pr80205.C b/gcc/testsuite/g++.dg/ipa/pr80205.C
new file mode 100644
index 00000000000..460bdcb02ca
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/pr80205.C
@@ -0,0 +1,34 @@
+// PR ipa/80205
+// { dg-options "-fnon-call-exceptions --param early-inlining-insns=100 -O2" }
+
+class a
+{
+public:
+  virtual ~a ();
+};
+class b
+{
+public:
+  template <typename c> b (c);
+  ~b () { delete d; }
+  void
+  operator= (b e)
+  {
+    b (e).f (*this);
+  }
+  void
+  f (b &e)
+  {
+    a g;
+    d = e.d;
+    e.d = &g;
+  }
+  a *d;
+};
+void
+h ()
+{
+  b i = int();
+  void j ();
+  i = j;
+}
-- 
2.12.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-03-28  8:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-27 12:51 [PATCH] Handle PHI nodes w/o a argument (PR ipa/80205) Martin Liška
2017-03-27 14:25 ` Richard Biener
2017-03-27 14:27   ` Jeff Law
2017-03-27 14:28   ` Richard Biener
2017-03-27 15:30     ` Jeff Law
2017-03-28  7:52     ` Martin Liška
2017-03-28  8:23       ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).