public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Do not inline variadic thunks (PR ipa/83549).
@ 2018-01-03 13:39 Martin Liška
  2018-01-03 13:41 ` Jan Hubicka
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Liška @ 2018-01-03 13:39 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jakub Jelinek, Jan Hubicka

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

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.
---
 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



[-- Attachment #2: 0001-Do-not-inline-variadic-thunks-PR-ipa-83549.patch --]
[-- Type: text/x-patch, Size: 909 bytes --]

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;


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

* Re: [PATCH] Do not inline variadic thunks (PR ipa/83549).
  2018-01-03 13:39 [PATCH] Do not inline variadic thunks (PR ipa/83549) Martin Liška
@ 2018-01-03 13:41 ` Jan Hubicka
  2018-01-03 14:02   ` Martin Liška
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Hubicka @ 2018-01-03 13:41 UTC (permalink / raw)
  To: Martin Liška; +Cc: gcc-patches, Jakub Jelinek

> 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.

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;
> 

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

* Re: [PATCH] Do not inline variadic thunks (PR ipa/83549).
  2018-01-03 13:41 ` Jan Hubicka
@ 2018-01-03 14:02   ` Martin Liška
  0 siblings, 0 replies; 3+ messages in thread
From: Martin Liška @ 2018-01-03 14:02 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: gcc-patches, Jakub Jelinek

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

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;
>>
> 


[-- Attachment #2: 0001-Do-not-inline-variadic-thunks-PR-ipa-83549.patch --]
[-- Type: text/x-patch, Size: 2276 bytes --]

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


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

end of thread, other threads:[~2018-01-03 14:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-03 13:39 [PATCH] Do not inline variadic thunks (PR ipa/83549) Martin Liška
2018-01-03 13:41 ` Jan Hubicka
2018-01-03 14:02   ` Martin Liška

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).