From patchwork Mon Aug 2 17:24:43 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [alpha] : Fix PR target/41089, stdarg pass produces wrong code From: Uros Bizjak X-Patchwork-Id: 60559 Message-Id: To: Richard Henderson Cc: gcc-patches@gcc.gnu.org, Richard Guenther , Jakub Jelinek Date: Mon, 2 Aug 2010 19:24:43 +0200 On Mon, Aug 2, 2010 at 6:59 PM, Richard Henderson 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   >> >>       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. 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"),