Do not inline variadic thunks (PR ipa/83549).
authorMartin Liska <mliska@suse.cz>
Wed, 3 Jan 2018 14:15:58 +0000 (15:15 +0100)
committerMartin Liska <marxin@gcc.gnu.org>
Wed, 3 Jan 2018 14:15:58 +0000 (14:15 +0000)
2018-01-03  Martin Liska  <mliska@suse.cz>

PR ipa/83549
* cif-code.def (VARIADIC_THUNK): New enum value.
* ipa-fnsummary.c (compute_fn_summary): Do not inline variadic
thunks.
2018-01-03  Martin Liska  <mliska@suse.cz>

PR ipa/83549
* g++.dg/ipa/pr83549.C: New test.

From-SVN: r256177

gcc/ChangeLog
gcc/cif-code.def
gcc/ipa-fnsummary.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ipa/pr83549.C [new file with mode: 0644]

index d9c4c6adf9789c31a1896e6527fe21d1af8568d5..ad327b955d376e960f8e2ceb9bf2df57fbcc45af 100644 (file)
@@ -1,3 +1,10 @@
+2018-01-03  Martin Liska  <mliska@suse.cz>
+
+       PR ipa/83549
+       * cif-code.def (VARIADIC_THUNK): New enum value.
+       * ipa-fnsummary.c (compute_fn_summary): Do not inline variadic
+       thunks.
+
 2018-01-03  Jan Beulich  <jbeulich@suse.com>
 
        * sse.md (mov<mode>_internal): Tighten condition for when to use
index 6d7e2b4070ba5be8b97ec1b6961ef841af5884c2..19a76213943dd11fd1d35e79394b8eeacc8d3580 100644 (file)
@@ -95,6 +95,10 @@ DEFCIFCODE(MISMATCHED_ARGUMENTS, CIF_FINAL_ERROR,
 DEFCIFCODE(LTO_MISMATCHED_DECLARATIONS, CIF_FINAL_ERROR,
           N_("mismatched declarations during linktime optimization"))
 
+/* Caller is variadic thunk.  */
+DEFCIFCODE(VARIADIC_THUNK, CIF_FINAL_ERROR,
+          N_("variadic thunk call"))
+
 /* Call was originally indirect.  */
 DEFCIFCODE(ORIGINALLY_INDIRECT_CALL, CIF_FINAL_NORMAL,
           N_("originally indirect function call not considered for inlining"))
index fc18518d48f4a33218a9fe4b93f4f94264af5556..e9f76d5cdac3a49a6dcab141e0924ae4e13aa4bb 100644 (file)
@@ -2422,6 +2422,11 @@ compute_fn_summary (struct cgraph_node *node, bool early)
           info->inlinable = false;
           node->callees->inline_failed = CIF_CHKP;
        }
+      else if (stdarg_p (TREE_TYPE (node->decl)))
+       {
+         info->inlinable = false;
+         node->callees->inline_failed = CIF_VARIADIC_THUNK;
+       }
       else
         info->inlinable = true;
     }
index d4d380447ec7988957bc00cc1d9d312fb94e8ea8..969ce39efef36240ee1222322302469342a3dcb9 100644 (file)
@@ -1,3 +1,8 @@
+2018-01-03  Martin Liska  <mliska@suse.cz>
+
+       PR ipa/83549
+       * g++.dg/ipa/pr83549.C: New test.
+
 2018-01-03  Marek Polacek  <polacek@redhat.com>
 
        PR c++/83592
diff --git a/gcc/testsuite/g++.dg/ipa/pr83549.C b/gcc/testsuite/g++.dg/ipa/pr83549.C
new file mode 100644 (file)
index 0000000..90cf8fe
--- /dev/null
@@ -0,0 +1,8 @@
+// PR ipa/83549
+// { dg-do compile }
+// { dg-options "-O2" }
+
+struct A { virtual ~A (); };
+struct B { virtual void foo (...); };
+struct C : A, B { void foo (...) {} };
+C c;