From ca04a532f3fcf91939ec03da628aa94207eaa067 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Wed, 3 Jan 2018 15:15:58 +0100 Subject: [PATCH] Do not inline variadic thunks (PR ipa/83549). 2018-01-03 Martin Liska 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 PR ipa/83549 * g++.dg/ipa/pr83549.C: New test. From-SVN: r256177 --- gcc/ChangeLog | 7 +++++++ gcc/cif-code.def | 4 ++++ gcc/ipa-fnsummary.c | 5 +++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/ipa/pr83549.C | 8 ++++++++ 5 files changed, 29 insertions(+) create mode 100644 gcc/testsuite/g++.dg/ipa/pr83549.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d9c4c6adf97..ad327b955d3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2018-01-03 Martin Liska + + 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 * sse.md (mov_internal): Tighten condition for when to use diff --git a/gcc/cif-code.def b/gcc/cif-code.def index 6d7e2b4070b..19a76213943 100644 --- a/gcc/cif-code.def +++ b/gcc/cif-code.def @@ -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")) diff --git a/gcc/ipa-fnsummary.c b/gcc/ipa-fnsummary.c index fc18518d48f..e9f76d5cdac 100644 --- a/gcc/ipa-fnsummary.c +++ b/gcc/ipa-fnsummary.c @@ -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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d4d380447ec..969ce39efef 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-01-03 Martin Liska + + PR ipa/83549 + * g++.dg/ipa/pr83549.C: New test. + 2018-01-03 Marek Polacek 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 index 00000000000..90cf8fe7e0d --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr83549.C @@ -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; -- 2.30.2