From patchwork Wed Sep 22 21:35:18 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Tidy up execute_update_addresses_taken Date: Wed, 22 Sep 2010 11:35:18 -0000 From: Eric Botcazou X-Patchwork-Id: 65458 Message-Id: <201009222335.18725.ebotcazou@adacore.com> To: gcc-patches@gcc.gnu.org Hi, I happened to notice that execute_update_addresses_taken is only called with DO_OPTIMIZE set to true and when optimization is enabled, so the apparently weird behaviour of the function (doing a complicated analysis and dropping the result half of the time) is only apparent. The attached patch cleans this up a little. Tested on i586-suse-linux, OK for mainline? 2010-09-22 Eric Botcazou * tree-flow.h (execute_update_addresses_taken): Adjust. * tree-ssa.c (execute_update_addresses_taken): Remove parameter and test of OPTIMIZE. * passes.c (execute_function_todo): Adjust calls to above function. Index: tree-ssa.c =================================================================== --- tree-ssa.c (revision 164507) +++ tree-ssa.c (working copy) @@ -1944,10 +1944,11 @@ maybe_optimize_var (tree var, bitmap add return update_vops; } -/* Compute TREE_ADDRESSABLE and DECL_GIMPLE_REG_P for local variables. */ +/* When possible, clear TREE_ADDRESSABLE bit or set DECL_GIMPLE_REG_P bit for + local variables. */ void -execute_update_addresses_taken (bool do_optimize) +execute_update_addresses_taken (void) { tree var; gimple_stmt_iterator gsi; @@ -2047,18 +2048,13 @@ execute_update_addresses_taken (bool do_ } } - /* When possible, clear ADDRESSABLE bit or set the REGISTER bit - and mark variable for conversion into SSA. */ - if (optimize && do_optimize) - { - /* We cannot iterate over all referenced vars as that can contain - unused vars from BLOCK trees which cause code generation - differences for -g vs. -g0. */ - for (var = DECL_ARGUMENTS (cfun->decl); var; var = DECL_CHAIN (var)) - update_vops |= maybe_optimize_var (var, addresses_taken, not_reg_needs); - FOR_EACH_VEC_ELT (tree, cfun->local_decls, i, var) - update_vops |= maybe_optimize_var (var, addresses_taken, not_reg_needs); - } + /* We cannot iterate over all referenced vars because that can contain + unused vars from BLOCK trees, which causes code generation differences + for -g vs. -g0. */ + for (var = DECL_ARGUMENTS (cfun->decl); var; var = DECL_CHAIN (var)) + update_vops |= maybe_optimize_var (var, addresses_taken, not_reg_needs); + FOR_EACH_VEC_ELT (tree, cfun->local_decls, i, var) + update_vops |= maybe_optimize_var (var, addresses_taken, not_reg_needs); /* Operand caches needs to be recomputed for operands referencing the updated variables. */ Index: tree-flow.h =================================================================== --- tree-flow.h (revision 164507) +++ tree-flow.h (working copy) @@ -559,7 +559,7 @@ extern void delete_tree_ssa (void); extern bool ssa_undefined_value_p (tree); extern void warn_uninit (tree, const char *, void *); extern unsigned int warn_uninitialized_vars (bool); -extern void execute_update_addresses_taken (bool); +extern void execute_update_addresses_taken (void); /* Call-back function for walk_use_def_chains(). At each reaching definition, a function with this prototype is called. */ Index: passes.c =================================================================== --- passes.c (revision 164507) +++ passes.c (working copy) @@ -1209,12 +1209,12 @@ execute_function_todo (void *data) } if (flags & TODO_update_address_taken) - execute_update_addresses_taken (true); + execute_update_addresses_taken (); if (flags & TODO_rebuild_alias) { if (!(flags & TODO_update_address_taken)) - execute_update_addresses_taken (true); + execute_update_addresses_taken (); compute_may_aliases (); }