public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR ipa/65465
@ 2015-03-19 17:08 Martin Liška
  2015-03-19 17:14 ` Jakub Jelinek
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Liška @ 2015-03-19 17:08 UTC (permalink / raw)
  To: GCC Patches; +Cc: jakub Jelinek

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

Hello.

Following patch is fix for the PR. Problem is caused if we fill up cgraph_thunk_info with some values (e.g. virtual_value != 0)
and further analysis set thunk_p = false. In all situations IPA ICF needs to reset all fields of the struct as it sets
thunk_p = true.

Tested on x86_64-linux-pc, no new regression. Fixed ICE for the arm cross compiler.

Ready for trunk?
Thanks,
Martin

[-- Attachment #2: 0001-Fix-for-PR-ipa-65465.patch --]
[-- Type: text/x-patch, Size: 1725 bytes --]

From 1b0416658cf59348664d44b14518c994075fd9bd Mon Sep 17 00:00:00 2001
From: mliska <mliska@suse.cz>
Date: Thu, 19 Mar 2015 15:36:34 +0100
Subject: [PATCH] Fix for PR ipa/65465.

gcc/ChangeLog:

2015-03-19  Martin Liska  <mliska@suse.cz>

	PR ipa/65465
	* cgraphunit.c (cgraph_node::create_wrapper): Correctly reset
	all fields of cgraph_thunk_info.

gcc/testsuite/ChangeLog:

2015-03-19  Jakub Jelinek  <jakub@redhat.com>

	* g++.dg/ipa/pr65465.C: New test.
---
 gcc/cgraphunit.c                   |  3 ++-
 gcc/testsuite/g++.dg/ipa/pr65465.C | 16 ++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/ipa/pr65465.C

diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index e640907..8b7d056 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -2484,8 +2484,9 @@ cgraph_node::create_wrapper (cgraph_node *target)
 
   /* Turn alias into thunk and expand it into GIMPLE representation.  */
   definition = true;
+
+  memset (&thunk, 0, sizeof(cgraph_thunk_info));
   thunk.thunk_p = true;
-  thunk.this_adjusting = false;
   create_edge (target, NULL, count, CGRAPH_FREQ_BASE);
 
   tree arguments = DECL_ARGUMENTS (decl);
diff --git a/gcc/testsuite/g++.dg/ipa/pr65465.C b/gcc/testsuite/g++.dg/ipa/pr65465.C
new file mode 100644
index 0000000..004b76e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/pr65465.C
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+struct A {};
+struct B { virtual A foo () const; };
+struct C { A foo () const; };
+struct D : virtual B { A foo () const {} };
+struct F : D { virtual int bar () const; };
+int F::bar () const { return 0; }
+A C::foo () const { return A (); }
+
+int
+main ()
+{
+  return 0;
+}
-- 
2.1.2


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

* Re: [PATCH] Fix PR ipa/65465
  2015-03-19 17:08 [PATCH] Fix PR ipa/65465 Martin Liška
@ 2015-03-19 17:14 ` Jakub Jelinek
  2015-03-19 17:26   ` Martin Liška
  0 siblings, 1 reply; 3+ messages in thread
From: Jakub Jelinek @ 2015-03-19 17:14 UTC (permalink / raw)
  To: Martin Liška; +Cc: GCC Patches

On Thu, Mar 19, 2015 at 06:08:03PM +0100, Martin Liška wrote:
> >From 1b0416658cf59348664d44b14518c994075fd9bd Mon Sep 17 00:00:00 2001
> From: mliska <mliska@suse.cz>
> Date: Thu, 19 Mar 2015 15:36:34 +0100
> Subject: [PATCH] Fix for PR ipa/65465.
> 
> gcc/ChangeLog:
> 
> 2015-03-19  Martin Liska  <mliska@suse.cz>
> 
> 	PR ipa/65465
> 	* cgraphunit.c (cgraph_node::create_wrapper): Correctly reset
> 	all fields of cgraph_thunk_info.
> 
> gcc/testsuite/ChangeLog:
> 
> 2015-03-19  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* g++.dg/ipa/pr65465.C: New test.
> ---
>  gcc/cgraphunit.c                   |  3 ++-
>  gcc/testsuite/g++.dg/ipa/pr65465.C | 16 ++++++++++++++++
>  2 files changed, 18 insertions(+), 1 deletion(-)
>  create mode 100644 gcc/testsuite/g++.dg/ipa/pr65465.C
> 
> diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
> index e640907..8b7d056 100644
> --- a/gcc/cgraphunit.c
> +++ b/gcc/cgraphunit.c
> @@ -2484,8 +2484,9 @@ cgraph_node::create_wrapper (cgraph_node *target)
>  
>    /* Turn alias into thunk and expand it into GIMPLE representation.  */
>    definition = true;
> +
> +  memset (&thunk, 0, sizeof(cgraph_thunk_info));

Please put space after sizeof.

>    thunk.thunk_p = true;
> -  thunk.this_adjusting = false;
>    create_edge (target, NULL, count, CGRAPH_FREQ_BASE);
>  
>    tree arguments = DECL_ARGUMENTS (decl);

Ok for trunk with that change.

> diff --git a/gcc/testsuite/g++.dg/ipa/pr65465.C b/gcc/testsuite/g++.dg/ipa/pr65465.C
> new file mode 100644
> index 0000000..004b76e
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/ipa/pr65465.C
> @@ -0,0 +1,16 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2" } */
> +
> +struct A {};
> +struct B { virtual A foo () const; };
> +struct C { A foo () const; };
> +struct D : virtual B { A foo () const {} };
> +struct F : D { virtual int bar () const; };
> +int F::bar () const { return 0; }
> +A C::foo () const { return A (); }
> +
> +int
> +main ()
> +{
> +  return 0;
> +}

Why do you need main for a dg-do compile testcase?
And even if you do for some reason, the return 0; in there
is implicit in C++.

	Jakub

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

* Re: [PATCH] Fix PR ipa/65465
  2015-03-19 17:14 ` Jakub Jelinek
@ 2015-03-19 17:26   ` Martin Liška
  0 siblings, 0 replies; 3+ messages in thread
From: Martin Liška @ 2015-03-19 17:26 UTC (permalink / raw)
  To: gcc-patches; +Cc: jakub Jelinek

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

On 03/19/2015 06:13 PM, Jakub Jelinek wrote:
> On Thu, Mar 19, 2015 at 06:08:03PM +0100, Martin Liška wrote:
>> >From 1b0416658cf59348664d44b14518c994075fd9bd Mon Sep 17 00:00:00 2001
>> From: mliska <mliska@suse.cz>
>> Date: Thu, 19 Mar 2015 15:36:34 +0100
>> Subject: [PATCH] Fix for PR ipa/65465.
>>
>> gcc/ChangeLog:
>>
>> 2015-03-19  Martin Liska  <mliska@suse.cz>
>>
>> 	PR ipa/65465
>> 	* cgraphunit.c (cgraph_node::create_wrapper): Correctly reset
>> 	all fields of cgraph_thunk_info.
>>
>> gcc/testsuite/ChangeLog:
>>
>> 2015-03-19  Jakub Jelinek  <jakub@redhat.com>
>>
>> 	* g++.dg/ipa/pr65465.C: New test.
>> ---
>>   gcc/cgraphunit.c                   |  3 ++-
>>   gcc/testsuite/g++.dg/ipa/pr65465.C | 16 ++++++++++++++++
>>   2 files changed, 18 insertions(+), 1 deletion(-)
>>   create mode 100644 gcc/testsuite/g++.dg/ipa/pr65465.C
>>
>> diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
>> index e640907..8b7d056 100644
>> --- a/gcc/cgraphunit.c
>> +++ b/gcc/cgraphunit.c
>> @@ -2484,8 +2484,9 @@ cgraph_node::create_wrapper (cgraph_node *target)
>>
>>     /* Turn alias into thunk and expand it into GIMPLE representation.  */
>>     definition = true;
>> +
>> +  memset (&thunk, 0, sizeof(cgraph_thunk_info));
>
> Please put space after sizeof.
>
>>     thunk.thunk_p = true;
>> -  thunk.this_adjusting = false;
>>     create_edge (target, NULL, count, CGRAPH_FREQ_BASE);
>>
>>     tree arguments = DECL_ARGUMENTS (decl);
>
> Ok for trunk with that change.
>
>> diff --git a/gcc/testsuite/g++.dg/ipa/pr65465.C b/gcc/testsuite/g++.dg/ipa/pr65465.C
>> new file mode 100644
>> index 0000000..004b76e
>> --- /dev/null
>> +++ b/gcc/testsuite/g++.dg/ipa/pr65465.C
>> @@ -0,0 +1,16 @@
>> +/* { dg-do compile } */
>> +/* { dg-options "-O2" } */
>> +
>> +struct A {};
>> +struct B { virtual A foo () const; };
>> +struct C { A foo () const; };
>> +struct D : virtual B { A foo () const {} };
>> +struct F : D { virtual int bar () const; };
>> +int F::bar () const { return 0; }
>> +A C::foo () const { return A (); }
>> +
>> +int
>> +main ()
>> +{
>> +  return 0;
>> +}
>
> Why do you need main for a dg-do compile testcase?
> And even if you do for some reason, the return 0; in there
> is implicit in C++.
>
> 	Jakub
>

Thanks for both notes, there's fixed version I'm going to install.

Martin

[-- Attachment #2: 0001-Fix-for-PR-ipa-65465.patch --]
[-- Type: text/x-patch, Size: 1685 bytes --]

From 065789b7b2e8bf94f1caf2a610c5acc1831c20bc Mon Sep 17 00:00:00 2001
From: mliska <mliska@suse.cz>
Date: Thu, 19 Mar 2015 15:36:34 +0100
Subject: [PATCH] Fix for PR ipa/65465.

gcc/ChangeLog:

2015-03-19  Martin Liska  <mliska@suse.cz>

	PR ipa/65465
	* cgraphunit.c (cgraph_node::create_wrapper): Correctly reset
	all fields of cgraph_thunk_info.

gcc/testsuite/ChangeLog:

2015-03-19  Jakub Jelinek  <jakub@redhat.com>

	* g++.dg/ipa/pr65465.C: New test.
---
 gcc/cgraphunit.c                   |  3 ++-
 gcc/testsuite/g++.dg/ipa/pr65465.C | 10 ++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/ipa/pr65465.C

diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index e640907..8ac92e1 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -2484,8 +2484,9 @@ cgraph_node::create_wrapper (cgraph_node *target)
 
   /* Turn alias into thunk and expand it into GIMPLE representation.  */
   definition = true;
+
+  memset (&thunk, 0, sizeof (cgraph_thunk_info));
   thunk.thunk_p = true;
-  thunk.this_adjusting = false;
   create_edge (target, NULL, count, CGRAPH_FREQ_BASE);
 
   tree arguments = DECL_ARGUMENTS (decl);
diff --git a/gcc/testsuite/g++.dg/ipa/pr65465.C b/gcc/testsuite/g++.dg/ipa/pr65465.C
new file mode 100644
index 0000000..436d88f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/pr65465.C
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+struct A {};
+struct B { virtual A foo () const; };
+struct C { A foo () const; };
+struct D : virtual B { A foo () const {} };
+struct F : D { virtual int bar () const; };
+int F::bar () const { return 0; }
+A C::foo () const { return A (); }
-- 
2.1.2


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

end of thread, other threads:[~2015-03-19 17:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-19 17:08 [PATCH] Fix PR ipa/65465 Martin Liška
2015-03-19 17:14 ` Jakub Jelinek
2015-03-19 17:26   ` 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).