aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-cfg.c
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2014-05-16 19:49:06 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2014-05-16 17:49:06 +0000
commit6de88c6a1c7fb017720cf79a6f93e52221afdfb8 (patch)
tree95128482337699b940df1c3ea7402e38fb4ecb88 /gcc/tree-cfg.c
parent54674a35bd0a8d231ad314064d5f7bb8a60ef5df (diff)
downloadgcc-6de88c6a1c7fb017720cf79a6f93e52221afdfb8.zip
gcc-6de88c6a1c7fb017720cf79a6f93e52221afdfb8.tar.gz
gcc-6de88c6a1c7fb017720cf79a6f93e52221afdfb8.tar.bz2
varpool.c (dump_varpool_node): Dump write-only flag.
* varpool.c (dump_varpool_node): Dump write-only flag. * lto-cgraph.c (lto_output_varpool_node, input_varpool_node): Stream write-only flag. * tree-cfg.c (execute_fixup_cfg): Remove statements setting write-only variables. * gcc.c-torture/execute/20101011-1.c: Update testcase. * gcc.dg/ira-shrinkwrap-prep-1.c: Update testcase. * gcc.dg/tree-ssa/writeonly.c: New testcase. * gcc.dg/tree-ssa/ssa-dse-6.c: Update testcase. * gcc.dg/tree-ssa/pr21559.c: Update testcase. * gcc.dg/debug/pr35154.c: Update testcase. * gcc.target/i386/vectorize1.c: Update testcase. * ipa.c (process_references): New function. (set_readonly_bit): New function. (set_writeonly_bit): New function. (clear_addressable_bit): New function. (ipa_discover_readonly_nonaddressable_var): Mark write only variables; fix handling of aliases. * cgraph.h (struct varpool_node): Add writeonly flag. From-SVN: r210522
Diffstat (limited to 'gcc/tree-cfg.c')
-rw-r--r--gcc/tree-cfg.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index fee1ede8..9228d41 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -8431,7 +8431,7 @@ execute_fixup_cfg (void)
FOR_EACH_BB_FN (bb, cfun)
{
bb->count = apply_scale (bb->count, count_scale);
- for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+ for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi);)
{
gimple stmt = gsi_stmt (gsi);
tree decl = is_gimple_call (stmt)
@@ -8457,9 +8457,46 @@ execute_fixup_cfg (void)
todo |= TODO_cleanup_cfg;
}
+ /* Remove stores to variables we marked write-only.
+ Keep access when store has side effect, i.e. in case when source
+ is volatile. */
+ if (gimple_store_p (stmt)
+ && !gimple_has_side_effects (stmt))
+ {
+ tree lhs = get_base_address (gimple_get_lhs (stmt));
+
+ if (TREE_CODE (lhs) == VAR_DECL
+ && (TREE_STATIC (lhs) || DECL_EXTERNAL (lhs))
+ && varpool_get_node (lhs)->writeonly)
+ {
+ unlink_stmt_vdef (stmt);
+ gsi_remove (&gsi, true);
+ release_defs (stmt);
+ todo |= TODO_update_ssa | TODO_cleanup_cfg;
+ continue;
+ }
+ }
+ /* For calls we can simply remove LHS when it is known
+ to be write-only. */
+ if (is_gimple_call (stmt)
+ && gimple_get_lhs (stmt))
+ {
+ tree lhs = get_base_address (gimple_get_lhs (stmt));
+
+ if (TREE_CODE (lhs) == VAR_DECL
+ && (TREE_STATIC (lhs) || DECL_EXTERNAL (lhs))
+ && varpool_get_node (lhs)->writeonly)
+ {
+ gimple_call_set_lhs (stmt, NULL);
+ update_stmt (stmt);
+ todo |= TODO_update_ssa | TODO_cleanup_cfg;
+ }
+ }
+
if (maybe_clean_eh_stmt (stmt)
&& gimple_purge_dead_eh_edges (bb))
todo |= TODO_cleanup_cfg;
+ gsi_next (&gsi);
}
FOR_EACH_EDGE (e, ei, bb->succs)