This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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"),

Uros.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]