aboutsummaryrefslogtreecommitdiff
path: root/gcc/ipa-reference.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2009-04-16 13:22:03 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2009-04-16 13:22:03 +0000
commit346ef3faa0225ae51f85931a0a259b144347b5e3 (patch)
tree23dd4190a75ec3d4a003945074976a4b867c0cdf /gcc/ipa-reference.c
parent9fbb3ae64a8d1c6103f4d4a91e60f1ee8312b3f3 (diff)
downloadgcc-346ef3faa0225ae51f85931a0a259b144347b5e3.zip
gcc-346ef3faa0225ae51f85931a0a259b144347b5e3.tar.gz
gcc-346ef3faa0225ae51f85931a0a259b144347b5e3.tar.bz2
gimple.h (walk_stmt_load_store_addr_ops): Declare.
2009-04-16 Richard Guenther <rguenther@suse.de> * gimple.h (walk_stmt_load_store_addr_ops): Declare. (walk_stmt_load_store_ops): Likewise. * gimple.c (get_base_loadstore): New function. (walk_stmt_load_store_addr_ops): Likewise. (walk_stmt_load_store_ops): Likewise. * ipa-pure-const.c (check_op): Simplify. (check_load, check_store): New functions. (check_stmt): Use walk_stmt_load_store_ops. * ipa-reference.c (mark_load): Adjust signature. (mark_store): Likewise. (scan_stmt_for_static_refs): Use walk_stmt_load_store_addr_ops. From-SVN: r146190
Diffstat (limited to 'gcc/ipa-reference.c')
-rw-r--r--gcc/ipa-reference.c58
1 files changed, 13 insertions, 45 deletions
diff --git a/gcc/ipa-reference.c b/gcc/ipa-reference.c
index 4bc49cf..d2c20c0 100644
--- a/gcc/ipa-reference.c
+++ b/gcc/ipa-reference.c
@@ -336,21 +336,22 @@ mark_address_taken (tree x)
/* Mark load of T. */
-static void
-mark_load (ipa_reference_local_vars_info_t local,
- tree t)
+static bool
+mark_load (gimple stmt ATTRIBUTE_UNUSED, tree t, void *data)
{
+ ipa_reference_local_vars_info_t local = (ipa_reference_local_vars_info_t)data;
if (TREE_CODE (t) == VAR_DECL
&& has_proper_scope_for_analysis (t))
bitmap_set_bit (local->statics_read, DECL_UID (t));
+ return false;
}
/* Mark store of T. */
-static void
-mark_store (ipa_reference_local_vars_info_t local,
- tree t)
+static bool
+mark_store (gimple stmt ATTRIBUTE_UNUSED, tree t, void *data)
{
+ ipa_reference_local_vars_info_t local = (ipa_reference_local_vars_info_t)data;
if (TREE_CODE (t) == VAR_DECL
&& has_proper_scope_for_analysis (t))
{
@@ -361,6 +362,7 @@ mark_store (ipa_reference_local_vars_info_t local,
if (module_statics_written)
bitmap_set_bit (module_statics_written, DECL_UID (t));
}
+ return false;
}
/* Look for memory clobber and set read_all/write_all if present. */
@@ -434,46 +436,12 @@ scan_stmt_for_static_refs (gimple_stmt_iterator *gsip,
local = get_reference_vars_info (fn)->local;
/* Look for direct loads and stores. */
- if (gimple_has_lhs (stmt))
- {
- tree lhs = get_base_address (gimple_get_lhs (stmt));
- if (lhs && DECL_P (lhs))
- mark_store (local, lhs);
- }
- if (gimple_assign_single_p (stmt))
- {
- tree rhs = get_base_address (gimple_assign_rhs1 (stmt));
- if (rhs && DECL_P (rhs))
- mark_load (local, rhs);
- }
- else if (is_gimple_call (stmt))
- {
- for (i = 0; i < gimple_call_num_args (stmt); ++i)
- {
- tree rhs = get_base_address (gimple_call_arg (stmt, i));
- if (rhs && DECL_P (rhs))
- mark_load (local, rhs);
- }
- check_call (local, stmt);
- }
+ walk_stmt_load_store_addr_ops (stmt, local, mark_load, mark_store, NULL);
+
+ if (is_gimple_call (stmt))
+ check_call (local, stmt);
else if (gimple_code (stmt) == GIMPLE_ASM)
- {
- for (i = 0; i < gimple_asm_ninputs (stmt); ++i)
- {
- tree op = TREE_VALUE (gimple_asm_input_op (stmt, i));
- op = get_base_address (op);
- if (op && DECL_P (op))
- mark_load (local, op);
- }
- for (i = 0; i < gimple_asm_noutputs (stmt); ++i)
- {
- tree op = TREE_VALUE (gimple_asm_output_op (stmt, i));
- op = get_base_address (op);
- if (op && DECL_P (op))
- mark_store (local, op);
- }
- check_asm_memory_clobber (local, stmt);
- }
+ check_asm_memory_clobber (local, stmt);
if (gimple_addresses_taken (stmt))
EXECUTE_IF_SET_IN_BITMAP (gimple_addresses_taken (stmt), 0, i, bi)