diff mbox

PATCH: PR middle-end/48440: [4.7 Regression] FAIL: gcc.c-torture/compile/labels-3.c

Message ID BANLkTikGt_eSbSiB+-dJRBrs5ExrBiYfOg@mail.gmail.com
State New
Headers show

Commit Message

H.J. Lu April 5, 2011, 12:51 a.m. UTC
On Mon, Apr 4, 2011 at 3:00 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Sun, Apr 3, 2011 at 3:14 AM, Michael Matz <matz@suse.de> wrote:
>> Hi,
>>
>> On Thu, 31 Mar 2011, Richard Guenther wrote:
>>
>>> > In the meanwhile, is the below version okay?
>>>
>>> If it bootstraps & tests ok then yes.  The java parts look obvious.
>>
>> So, we indeed can't remove the other calls to
>> canonicalize_constructor_val, because of local ctors.  And fortran has a
>> similar problem with java.  Instead of fixing up all these places of
>> resetting cfun (where otherwise the frontends don't deal at all with it,
>> it's mostly just set from the various cgraph routines), I decided to
>> simply clear this at the appropriate place in
>> cgraph_finalize_compilation_unit.
>>
>> Regstrapping in progress again.  Still okay if that works?
>>
>>
>> Ciao,
>> Michael.
>> --
>>        * cgraphbuild.c (record_reference): Canonicalize constructor
>>        values.
>
>>
>> Index: cgraphbuild.c
>> ===================================================================
>> --- cgraphbuild.c.orig  2011-04-03 11:28:45.000000000 +0200
>> +++ cgraphbuild.c       2011-04-03 11:31:21.000000000 +0200
>> @@ -53,6 +53,12 @@ record_reference (tree *tp, int *walk_su
>>   tree decl;
>>   struct record_reference_ctx *ctx = (struct record_reference_ctx *)data;
>>
>> +  t = canonicalize_constructor_val (t);
>> +  if (!t)
>> +    t = *tp;
>> +  else if (t != *tp)
>> +    *tp = t;
>> +
>>   switch (TREE_CODE (t))
>>     {
>>     case VAR_DECL:
>
> This change caused:
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48440
>

This avoids  canonicalizing constructor values for address conversion
if Pmode != ptr_mode.  OK for trunk?

Thanks.

Comments

Paolo Bonzini April 5, 2011, 6:44 a.m. UTC | #1
>>> Index: cgraphbuild.c
>>> ===================================================================
>>> --- cgraphbuild.c.orig  2011-04-03 11:28:45.000000000 +0200
>>> +++ cgraphbuild.c       2011-04-03 11:31:21.000000000 +0200
>>> @@ -53,6 +53,12 @@ record_reference (tree *tp, int *walk_su
>>>   tree decl;
>>>   struct record_reference_ctx *ctx = (struct record_reference_ctx *)data;
>>>
>>> +  t = canonicalize_constructor_val (t);
>>> +  if (!t)
>>> +    t = *tp;
>>> +  else if (t != *tp)
>>> +    *tp = t;
>>> +
>>>   switch (TREE_CODE (t))
>>>     {
>>>     case VAR_DECL:
>>
>> This change caused:
>>
>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48440
>>
>
> This avoids  canonicalizing constructor values for address conversion
> if Pmode != ptr_mode.  OK for trunk?

Certainly the right place to fix it is in canonicalize_constructor_val itself.

Paolo
Richard Biener April 5, 2011, 10:29 a.m. UTC | #2
On Tue, Apr 5, 2011 at 8:44 AM, Paolo Bonzini <bonzini@gnu.org> wrote:
>>>> Index: cgraphbuild.c
>>>> ===================================================================
>>>> --- cgraphbuild.c.orig  2011-04-03 11:28:45.000000000 +0200
>>>> +++ cgraphbuild.c       2011-04-03 11:31:21.000000000 +0200
>>>> @@ -53,6 +53,12 @@ record_reference (tree *tp, int *walk_su
>>>>   tree decl;
>>>>   struct record_reference_ctx *ctx = (struct record_reference_ctx *)data;
>>>>
>>>> +  t = canonicalize_constructor_val (t);
>>>> +  if (!t)
>>>> +    t = *tp;
>>>> +  else if (t != *tp)
>>>> +    *tp = t;
>>>> +
>>>>   switch (TREE_CODE (t))
>>>>     {
>>>>     case VAR_DECL:
>>>
>>> This change caused:
>>>
>>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48440
>>>
>>
>> This avoids  canonicalizing constructor values for address conversion
>> if Pmode != ptr_mode.  OK for trunk?
>
> Certainly the right place to fix it is in canonicalize_constructor_val itself.

There should never be any Pmode pointer types in the gimple IL.  The
proper place to fix it if any is in useless_type_conversion_p.

Richard.

> Paolo
>
diff mbox

Patch

diff --git a/gcc/cgraphbuild.c b/gcc/cgraphbuild.c
index 3948cf6..8ba7864 100644
--- a/gcc/cgraphbuild.c
+++ b/gcc/cgraphbuild.c
@@ -49,15 +49,20 @@  struct record_reference_ctx
 static tree
 record_reference (tree *tp, int *walk_subtrees, void *data)
 {
-  tree t = *tp;
+  tree t = *tp, tc;
   tree decl;
   struct record_reference_ctx *ctx = (struct record_reference_ctx *)data;
 
-  t = canonicalize_constructor_val (t);
-  if (!t)
-    t = *tp;
-  else if (t != *tp)
-    *tp = t;
+  tc = canonicalize_constructor_val (t);
+  if (tc
+      && tc != t
+      && !(Pmode != ptr_mode
+	   && TREE_CODE (tc) == ADDR_EXPR
+	   && TREE_CODE (t) == CONVERT_EXPR))
+    {
+      *tp = tc;
+      t = tc;
+    }
 
   switch (TREE_CODE (t))
     {