From patchwork Sat Jul 10 04:43:03 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: RFA: Fix debug/44832 Date: Fri, 09 Jul 2010 18:43:03 -0000 From: Joern Rennecke X-Patchwork-Id: 58460 Message-Id: <20100710004303.ez0r2n9bcgsk4w40-nzlynne@webmail.spamcop.net> To: gcc-patches@gcc.gnu.org Bootstrapped & regression tested on i686-pc-linux-gnu on top of the patch for PR other/44874 in trunk revision 161952; as expected, the pr44832 test is fixed for gcc and g++; there are no new regressions. It also fixes the -fcompare-debug failures on i686-pc-linux-gnu for the various hand-run test cases we have for this PR. 2010-07-10 Richard Guenther Joern Rennecke PR debug/44832 * tree-ssa-live.c (mark_all_vars_used_1): Set TREE_USED for LABEL_DECL. (remove_unused_scope_block_p): Don't drop TREE_USED LABEL_DECLs unless they have DECL_IGNORED_P set. diff -pu ../../../pr44874/gcc/gcc/tree-ssa-live.c ./tree-ssa-live.c --- ../../../pr44874/gcc/gcc/tree-ssa-live.c 2010-07-09 19:46:22.862606781 +0100 +++ ./tree-ssa-live.c 2010-07-09 19:49:13.544981717 +0100 @@ -384,6 +384,19 @@ mark_all_vars_used_1 (tree *tp, int *wal } set_is_used (t); } + /* remove_unused_scope_block_p requires information about labels + which are not DECL_IGNORED_P to tell if they might be used in the IL. */ + if (TREE_CODE (t) == LABEL_DECL) +#if 0 + /* A label that has not been artifically created by the compiler should + only be used in the IL if it has been explicitly used by the + programmer. */ + gcc_assert (TREE_USED (t) || DECL_IGNORED_P (t)); +#else + /* Actually, init_vars_expansion clears TREE_USED for LABEL_DECLs too, + so we must compute it here. */ + TREE_USED (t) = 1; +#endif if (IS_TYPE_OR_DECL_P (t)) *walk_subtrees = 0; @@ -463,6 +476,19 @@ remove_unused_scope_block_p (tree scope) else if ((ann = var_ann (*t)) != NULL && ann->used) unused = false; + else if (TREE_CODE (*t) == LABEL_DECL && TREE_USED (*t)) + /* For labels that are still used in the IL, the decision to + preserve them must not depend DEBUG_INFO_LEVEL, otherwise we + risk having different ordering in debug vs. non-debug builds + during inlining or versioning. + A label appearing here (we have already checked DECL_IGNORED_P) + should not be used in the IL unless it has been explicitly used + before, so we use TREE_USED as an approximation. */ + /* In principle, we should do the same here as for the debug case + below, however, when debugging, there might be additional nested + levels that keep an upper level with a label live, so we have to + force this block to be considered used, too. */ + unused = false; /* When we are not doing full debug info, we however can keep around only the used variables for cfgexpand's memory packing saving quite