Patchwork [alpha] : Fix PR target/41089, stdarg pass produces wrong code

login
register
mail settings
Submitter Uros Bizjak
Date Aug. 2, 2010, 5:24 p.m.
Message ID <AANLkTin-0-1G5n6ocy5LLawtAQJsCHpD3u1PMFWmvA+E@mail.gmail.com>
Download mbox | patch
Permalink /patch/60559/
State New
Headers show

Comments

Uros Bizjak - Aug. 2, 2010, 5:24 p.m.
On Mon, Aug 2, 2010 at 6:59 PM, Richard Henderson <rth@redhat.com> wrote:

>> As discussed in the PR, stdarg pass depends on number of assignments
>> to ap.__offset location for correct operation. However, recent FRE/DCE
>> enhancements remove one assignment as a dead code, causing the test
>> failure:
>>
>> FAIL: gcc.c-torture/execute/stdarg-1.c execution,  -O3 -fomit-frame-pointer
>> FAIL: gcc.c-torture/execute/stdarg-1.c execution,  -O3 -g
>>
>> Attached patch marks __offset as volatile (suggested by Richi in
>> comment #39), preventing optimizations that could otherwise confuse
>> stdarg pass.
>>
>> 2010-08-01  Uros Bizjak  <ubizjak@gmail.com>
>>
>>       PR target/41089
>>       * config/alpha/alpha.c (alpha_build_builtin_va_list): Mark __offset
>>       as volatile.
>>
>> Patch was bootstrapped and regression tested on
>> alphaev68-pc-linux-gnu, where it fixes the failure.
>
> Ug.  That's awful.  It means that when you really do have dead code
> it won't get deleted, and thus the stdarg pass won't be able to
> eliminate the stores that could have been prevented.
>
> I'm tempted to say just remove the entire optimization, but what's
> left after the volatile may be slightly better than no optimization
> at all -- i.e. we can determine that there were never any va_arg
> requests for double at all.
>
> So... patch ok.

Thanks. I have committed the patch with a comment:


Uros.
Richard Guenther - Aug. 3, 2010, 8:43 a.m.
On Mon, 2 Aug 2010, Uros Bizjak wrote:

> On Mon, Aug 2, 2010 at 6:59 PM, Richard Henderson <rth@redhat.com> wrote:
> 
> >> As discussed in the PR, stdarg pass depends on number of assignments
> >> to ap.__offset location for correct operation. However, recent FRE/DCE
> >> enhancements remove one assignment as a dead code, causing the test
> >> failure:
> >>
> >> FAIL: gcc.c-torture/execute/stdarg-1.c execution,  -O3 -fomit-frame-pointer
> >> FAIL: gcc.c-torture/execute/stdarg-1.c execution,  -O3 -g
> >>
> >> Attached patch marks __offset as volatile (suggested by Richi in
> >> comment #39), preventing optimizations that could otherwise confuse
> >> stdarg pass.
> >>
> >> 2010-08-01  Uros Bizjak  <ubizjak@gmail.com>
> >>
> >>       PR target/41089
> >>       * config/alpha/alpha.c (alpha_build_builtin_va_list): Mark __offset
> >>       as volatile.
> >>
> >> Patch was bootstrapped and regression tested on
> >> alphaev68-pc-linux-gnu, where it fixes the failure.
> >
> > Ug.  That's awful.  It means that when you really do have dead code
> > it won't get deleted, and thus the stdarg pass won't be able to
> > eliminate the stores that could have been prevented.
> >
> > I'm tempted to say just remove the entire optimization, but what's
> > left after the volatile may be slightly better than no optimization
> > at all -- i.e. we can determine that there were never any va_arg
> > requests for double at all.
> >
> > So... patch ok.
> 
> Thanks. I have committed the patch with a comment:
> 
> Index: alpha.c
> ===================================================================
> --- alpha.c	(revision 162825)
> +++ alpha.c	(working copy)
> @@ -5950,6 +5950,10 @@
>  		    integer_type_node);
>    DECL_FIELD_CONTEXT (ofs) = record;
>    DECL_CHAIN (ofs) = space;
> +  /* ??? This is a hack, __offset is marked volatile to prevent
> +     DCE that confuses stdarg optimization and results in
> +     gcc.c-torture/execute/stdarg-1.c failure.  See PR 41089.  */
> +  TREE_THIS_VOLATILE (ofs) = 1;
> 
>    base = build_decl (BUILTINS_LOCATION,
>  		     FIELD_DECL, get_identifier ("__base"),

I wonder if we can't use points-to information instead of trying
to match the lowered accesses.

Richard.

Patch

Index: alpha.c
===================================================================
--- alpha.c	(revision 162825)
+++ alpha.c	(working copy)
@@ -5950,6 +5950,10 @@ 
 		    integer_type_node);
   DECL_FIELD_CONTEXT (ofs) = record;
   DECL_CHAIN (ofs) = space;
+  /* ??? This is a hack, __offset is marked volatile to prevent
+     DCE that confuses stdarg optimization and results in
+     gcc.c-torture/execute/stdarg-1.c failure.  See PR 41089.  */
+  TREE_THIS_VOLATILE (ofs) = 1;

   base = build_decl (BUILTINS_LOCATION,
 		     FIELD_DECL, get_identifier ("__base"),