diff mbox

Fix ICE with redirecting to unreachable in thunks (PR ipa/71146)

Message ID 20160517195723.GD1611@redhat.com
State New
Headers show

Commit Message

Marek Polacek May 17, 2016, 7:57 p.m. UTC
Since Honza's change in r236012 we're able to expand thunks inline, and as
a side-effect we can redirect call within thunk to __buitin_unreachable (at
least that's my understanding ;).

But that means we need to employ the maybe_remove_unused_call_args function
so that we don't left __buitin_unreachable with arguments in the IL.

Bootstrapped/regtested on x86_64-linux, applying to trunk (approved by Honza
in the PR).

2016-05-17  Marek Polacek  <polacek@redhat.com>

	PR ipa/71146
	* tree-inline.c (expand_call_inline): Call
	maybe_remove_unused_call_args.

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


	Marek
diff mbox

Patch

diff --git gcc/testsuite/g++.dg/ipa/pr71146.C gcc/testsuite/g++.dg/ipa/pr71146.C
index e69de29..54d34a7 100644
--- gcc/testsuite/g++.dg/ipa/pr71146.C
+++ gcc/testsuite/g++.dg/ipa/pr71146.C
@@ -0,0 +1,29 @@ 
+// PR ipa/71146
+// { dg-do compile }
+// { dg-options "-O3" }
+
+typedef enum { X } E;
+struct A {
+  virtual void bar ();
+};
+struct B {
+  virtual E fn (const char *, int, int *) = 0;
+};
+struct C : A, B {
+  E fn (const char *, int, int *);
+  void fn2 ();
+  B *foo;
+};
+void C::fn2 () {
+  if (!foo)
+    return;
+  foo->fn (0, 0, 0);
+}
+E
+C::fn (const char *, int, int *)
+{
+  fn2 ();
+  foo = 0;
+  fn (0, 0, 0);
+  return X;
+}
diff --git gcc/tree-inline.c gcc/tree-inline.c
index 85ed2c2..954dac3 100644
--- gcc/tree-inline.c
+++ gcc/tree-inline.c
@@ -4486,6 +4486,7 @@  expand_call_inline (basic_block bb, gimple *stmt, copy_body_data *id)
       update_stmt (stmt);
       id->src_node->remove ();
       expand_call_inline (bb, stmt, id);
+      maybe_remove_unused_call_args (cfun, stmt);
       return true;
     }
   fn = cg_edge->callee->decl;