This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Do not inline variadic thunks (PR ipa/83549).
- From: Martin Liška <mliska at suse dot cz>
- To: Jan Hubicka <hubicka at ucw dot cz>
- Cc: gcc-patches at gcc dot gnu dot org, Jakub Jelinek <jakub at redhat dot com>
- Date: Wed, 3 Jan 2018 15:02:51 +0100
- Subject: Re: [PATCH] Do not inline variadic thunks (PR ipa/83549).
- Authentication-results: sourceware.org; auth=none
- References: <0bc71a0b-ea65-650f-def4-f986f7f2e95e@suse.cz> <20180103134149.GE39213@kam.mff.cuni.cz>
On 01/03/2018 02:41 PM, Jan Hubicka wrote:
>> Hi.
>>
>> As mentioned in the PR, we should bail out inlining of thunks with variadic
>> arguments. It's problematic for cgraph_node::expand_thunk function that
>> does not support variadic functions.
>>
>> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
>>
>> Ready to be installed?
>> Martin
>>
>> gcc/ChangeLog:
>>
>> 2018-01-03 Martin Liska <mliska@suse.cz>
>>
>> PR ipa/83549
>> * ipa-fnsummary.c (compute_fn_summary): Do not inline variadic
>> thunks.
>>
>> gcc/testsuite/ChangeLog:
>>
>> 2018-01-03 Martin Liska <mliska@suse.cz>
>>
>> PR ipa/83549
>> * g++.dg/ipa/pr83549.C: New test.
>
> OK, but please introduce new CIF_CODE for this case. MISMATCHED arguments
> is a kitchen sink for various issues and it is very hard to analyze what
> happened when it triggers.
Fully agree, I'm attaching patch that I'll commit soon.
Martin
>
> Thanks,
> Honza
>> ---
>> gcc/ipa-fnsummary.c | 5 +++++
>> gcc/testsuite/g++.dg/ipa/pr83549.C | 8 ++++++++
>> 2 files changed, 13 insertions(+)
>> create mode 100644 gcc/testsuite/g++.dg/ipa/pr83549.C
>>
>>
>
>> diff --git a/gcc/ipa-fnsummary.c b/gcc/ipa-fnsummary.c
>> index 94150312105..274bd8c6758 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_MISMATCHED_ARGUMENTS;
>> + }
>> else
>> info->inlinable = true;
>> }
>> 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;
>>
>
>From d890dbc95bdc57d13f26759888ef48f4b492f53e Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Wed, 3 Jan 2018 13:23:46 +0100
Subject: [PATCH] Do not inline variadic thunks (PR ipa/83549).
gcc/ChangeLog:
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.
gcc/testsuite/ChangeLog:
2018-01-03 Martin Liska <mliska@suse.cz>
PR ipa/83549
* g++.dg/ipa/pr83549.C: New test.
---
gcc/cif-code.def | 4 ++++
gcc/ipa-fnsummary.c | 5 +++++
gcc/testsuite/g++.dg/ipa/pr83549.C | 8 ++++++++
3 files changed, 17 insertions(+)
create mode 100644 gcc/testsuite/g++.dg/ipa/pr83549.C
diff --git a/gcc/cif-code.def b/gcc/cif-code.def
index 92d81d30a49..a587e712fdf 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 94150312105..9b1b7daca2e 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/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.14.3