#include "coretypes.h"
#include "tm.h"
#include "hashtab.h"
+#include "pointer-set.h"
#include "tree.h"
#include "rtl.h"
#include "tm_p.h"
block_stmt_iterator si;
struct walk_state walk_state;
- cgraph_reset_static_var_maps ();
vars_found = htab_create (50, htab_hash_pointer, htab_eq_pointer, NULL);
memset (&walk_state, 0, sizeof (walk_state));
walk_state.vars_found = vars_found;
NULL, /* sub */
NULL, /* next */
0, /* static_pass_number */
- 0, /* tv_id */
+ TV_FIND_REFERENCED_VARS, /* tv_id */
PROP_gimple_leh | PROP_cfg, /* properties_required */
PROP_referenced_vars, /* properties_provided */
0, /* properties_destroyed */
}
-/* Invalidates dataflow information for a statement STMT. */
+/* Invalidates dataflow information for a statement STMT. */
void
free_df_for_stmt (tree stmt)
if (!IS_EMPTY_STMT (imm_rdef_stmt) && (!calc_for || calc_for (use)))
add_immediate_use (imm_rdef_stmt, stmt);
}
- }
+
+ FOR_EACH_SSA_TREE_OPERAND (use, stmt, iter, SSA_OP_ALL_KILLS)
+ {
+ tree imm_rdef_stmt = SSA_NAME_DEF_STMT (use);
+ if (!IS_EMPTY_STMT (imm_rdef_stmt) && (!calc_for || calc_for (use)))
+ add_immediate_use (imm_rdef_stmt, stmt);
+ }
+ }
}
if (is_global_var (var))
fprintf (file, ", is global");
+ if (TREE_THIS_VOLATILE (var))
+ fprintf (file, ", is volatile");
+
if (is_call_clobbered (var))
fprintf (file, ", call clobbered");
size = num_referenced_vars * sizeof (tree);
total += size;
- fprintf (file, fmt_str_1, "Referenced variables", num_referenced_vars,
+ fprintf (file, fmt_str_1, "Referenced variables", (unsigned long)num_referenced_vars,
SCALE (size), LABEL (size));
size = dfa_stats.num_stmt_anns * sizeof (struct stmt_ann_d);
static void
collect_dfa_stats (struct dfa_stats_d *dfa_stats_p)
{
- htab_t htab;
+ struct pointer_set_t *pset;
basic_block bb;
block_stmt_iterator i;
/* Walk all the trees in the function counting references. Start at
basic block 0, but don't stop at block boundaries. */
- htab = htab_create (30, htab_hash_pointer, htab_eq_pointer, NULL);
+ pset = pointer_set_create ();
for (i = bsi_start (BASIC_BLOCK (0)); !bsi_end_p (i); bsi_next (&i))
walk_tree (bsi_stmt_ptr (i), collect_dfa_stats_r, (void *) dfa_stats_p,
- (void *) htab);
+ pset);
- htab_delete (htab);
+ pointer_set_destroy (pset);
FOR_EACH_BB (bb)
{
/* Type, _DECL and constant nodes have no interesting children.
Ignore them. */
- else if (DECL_P (*tp)
- || TYPE_P (*tp)
- || TREE_CODE_CLASS (TREE_CODE (*tp)) == 'c')
+ else if (IS_TYPE_OR_DECL_P (*tp) || CONSTANT_CLASS_P (*tp))
*walk_subtrees = 0;
return NULL_TREE;
if (is_global_var (var))
mark_call_clobbered (var);
- /* If an initialized global variable then register the initializer
- as well. */
- if (POINTER_TYPE_P (TREE_TYPE (var))
- && TREE_READONLY (var)
- && DECL_INITIAL (var)
- && TREE_CODE (DECL_INITIAL (var)) == ADDR_EXPR)
+ /* Scan DECL_INITIAL for pointer variables as they may contain
+ address arithmetic referencing the address of other
+ variables. */
+ if (DECL_INITIAL (var)
+ && POINTER_TYPE_P (TREE_TYPE (var)))
walk_tree (&DECL_INITIAL (var), find_vars_r, walk_state, 0);
}
}
v_may_defs_after = NUM_V_MAY_DEFS (STMT_V_MAY_DEF_OPS (stmt));
v_must_defs_after = NUM_V_MUST_DEFS (STMT_V_MUST_DEF_OPS (stmt));
- FOR_EACH_SSA_TREE_OPERAND (val, stmt, iter,
- SSA_OP_VMAYDEF | SSA_OP_VUSE | SSA_OP_VMUSTDEF)
-
+ FOR_EACH_SSA_TREE_OPERAND (val, stmt, iter, SSA_OP_ALL_OPERANDS)
{
if (DECL_P (val))
{
if (found_exposed_symbol
|| v_may_defs_before > v_may_defs_after
|| v_must_defs_before > v_must_defs_after)
- bitmap_a_or_b (vars_to_rename, vars_to_rename, vars_in_vops_to_rename);
+ bitmap_ior_into (vars_to_rename, vars_in_vops_to_rename);
BITMAP_XFREE (vars_in_vops_to_rename);
}
+
+/* Find all variables within the gimplified statement that were not previously
+ visible to the function and add them to the referenced variables list. */
+
+static tree
+find_new_referenced_vars_1 (tree *tp, int *walk_subtrees,
+ void *data ATTRIBUTE_UNUSED)
+{
+ tree t = *tp;
+
+ if (TREE_CODE (t) == VAR_DECL && !var_ann (t))
+ add_referenced_tmp_var (t);
+
+ if (IS_TYPE_OR_DECL_P (t))
+ *walk_subtrees = 0;
+
+ return NULL;
+}
+
+void
+find_new_referenced_vars (tree *stmt_p)
+{
+ walk_tree (stmt_p, find_new_referenced_vars_1, NULL, NULL);
+}