aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-dfa.c
diff options
context:
space:
mode:
authorEric Christopher <echristo@redhat.com>2004-07-27 00:20:03 +0000
committerEric Christopher <echristo@redhat.com>2004-07-27 00:20:03 +0000
commit3fe70ba3d052bab8b019848aa9f8dad4dec3e775 (patch)
tree9a02867216571663e8a78b4717752c799bbfd856 /gcc/tree-dfa.c
parent9b782f399988b04f49db9fa0d5715859d1a7f524 (diff)
2004-07-26 Eric Christopher <echristo@redhat.com>
* tree-dfa.c (add_referenced_var): Register initializers of global variables. 2004-07-26 Eric Christopher <echristo@redhat.com> * gcc.c-torture/compile/20040726-2.c: New test. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@85214 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-dfa.c')
-rw-r--r--gcc/tree-dfa.c56
1 files changed, 32 insertions, 24 deletions
diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c
index c8986e80372..9e9ee324826 100644
--- a/gcc/tree-dfa.c
+++ b/gcc/tree-dfa.c
@@ -139,8 +139,8 @@ struct tree_opt_pass pass_referenced_vars =
};
-/* Compute immediate uses.
-
+/* Compute immediate uses.
+
CALC_FOR is an optional function pointer which indicates whether
immediate uses information should be calculated for a given SSA
variable. If NULL, then information is computed for all
@@ -253,7 +253,7 @@ compute_immediate_uses_for_phi (tree phi, bool (*calc_for)(tree))
tree arg = PHI_ARG_DEF (phi, i);
if (TREE_CODE (arg) == SSA_NAME && (!calc_for || calc_for (arg)))
- {
+ {
tree imm_rdef_stmt = SSA_NAME_DEF_STMT (PHI_ARG_DEF (phi, i));
if (!IS_EMPTY_STMT (imm_rdef_stmt))
add_immediate_use (imm_rdef_stmt, phi);
@@ -351,7 +351,7 @@ add_immediate_use (tree stmt, tree use_stmt)
/* If the immediate use of USE points to OLD, then redirect it to NEW. */
-
+
static void
redirect_immediate_use (tree use, tree old, tree new)
{
@@ -388,7 +388,7 @@ redirect_immediate_uses (tree old, tree new)
/* Look at USE_OPS or VUSE_OPS according to FLAGS. */
for (i = 0; i < NUM_USES (uses); i++)
- redirect_immediate_use (USE_OP (uses, i), old, new);
+ redirect_immediate_use (USE_OP (uses, i), old, new);
for (i = 0; i < NUM_VUSES (vuses); i++)
redirect_immediate_use (VUSE_OP (vuses, i), old, new);
@@ -505,7 +505,7 @@ dump_referenced_vars (FILE *file)
{
size_t i;
- fprintf (file, "\nReferenced variables in %s: %u\n\n",
+ fprintf (file, "\nReferenced variables in %s: %u\n\n",
get_name (current_function_decl), (unsigned) num_referenced_vars);
for (i = 0; i < num_referenced_vars; i++)
@@ -533,7 +533,7 @@ void
dump_variable (FILE *file, tree var)
{
var_ann_t ann;
-
+
if (TREE_CODE (var) == SSA_NAME)
{
if (POINTER_TYPE_P (TREE_TYPE (var)))
@@ -691,7 +691,7 @@ dump_dfa_stats (FILE *file)
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", num_referenced_vars,
SCALE (size), LABEL (size));
size = dfa_stats.num_stmt_anns * sizeof (struct stmt_ann_d);
@@ -723,7 +723,7 @@ dump_dfa_stats (FILE *file)
total += size;
fprintf (file, fmt_str_1, "V_MAY_DEF operands", dfa_stats.num_v_may_defs,
SCALE (size), LABEL (size));
-
+
size = dfa_stats.num_v_must_defs * sizeof (tree *);
total += size;
fprintf (file, fmt_str_1, "V_MUST_DEF operands", dfa_stats.num_v_must_defs,
@@ -822,10 +822,10 @@ collect_dfa_stats_r (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED,
dfa_stats_p->num_stmt_anns++;
dfa_stats_p->num_defs += NUM_DEFS (DEF_OPS (ann));
dfa_stats_p->num_uses += NUM_USES (USE_OPS (ann));
- dfa_stats_p->num_v_may_defs +=
+ dfa_stats_p->num_v_may_defs +=
NUM_V_MAY_DEFS (V_MAY_DEF_OPS (ann));
dfa_stats_p->num_vuses += NUM_VUSES (VUSE_OPS (ann));
- dfa_stats_p->num_v_must_defs +=
+ dfa_stats_p->num_v_must_defs +=
NUM_V_MUST_DEFS (V_MUST_DEF_OPS (ann));
break;
}
@@ -903,6 +903,14 @@ add_referenced_var (tree var, struct walk_state *walk_state)
/* Global and static variables are call-clobbered, always. */
if (needs_to_live_in_memory (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)
+ walk_tree (&DECL_INITIAL (var), find_vars_r, walk_state, 0);
}
}
@@ -920,7 +928,7 @@ get_virtual_var (tree var)
while (TREE_CODE (var) == REALPART_EXPR || TREE_CODE (var) == IMAGPART_EXPR
|| handled_component_p (var))
var = TREE_OPERAND (var, 0);
-
+
#ifdef ENABLE_CHECKING
/* Treating GIMPLE registers as virtual variables makes no sense.
Also complain if we couldn't extract a _DECL out of the original
@@ -945,42 +953,42 @@ add_referenced_tmp_var (tree var)
add_referenced_var (var, NULL);
}
-/* Return true if V_MAY_DEFS_AFTER contains fewer entries than
- V_MAY_DEFS_BEFORE. Note that this assumes that both varrays
+/* Return true if V_MAY_DEFS_AFTER contains fewer entries than
+ V_MAY_DEFS_BEFORE. Note that this assumes that both varrays
are V_MAY_DEF operands for the same statement. */
static inline bool
-v_may_defs_disappeared_p (v_may_def_optype v_may_defs_before,
+v_may_defs_disappeared_p (v_may_def_optype v_may_defs_before,
v_may_def_optype v_may_defs_after)
{
/* If there was nothing before, nothing could've disappeared. */
if (v_may_defs_before == NULL)
return false;
-
+
/* All/some of them gone. */
if (v_may_defs_after == NULL
- || NUM_V_MAY_DEFS (v_may_defs_before) >
+ || NUM_V_MAY_DEFS (v_may_defs_before) >
NUM_V_MAY_DEFS (v_may_defs_after))
return true;
return false;
}
-/* Return true if V_MUST_DEFS_AFTER contains fewer entries than
- V_MUST_DEFS_BEFORE. Note that this assumes that both varrays
+/* Return true if V_MUST_DEFS_AFTER contains fewer entries than
+ V_MUST_DEFS_BEFORE. Note that this assumes that both varrays
are V_MUST_DEF operands for the same statement. */
static inline bool
-v_must_defs_disappeared_p (v_must_def_optype v_must_defs_before,
+v_must_defs_disappeared_p (v_must_def_optype v_must_defs_before,
v_must_def_optype v_must_defs_after)
{
/* If there was nothing before, nothing could've disappeared. */
if (v_must_defs_before == NULL)
return false;
-
+
/* All/some of them gone. */
if (v_must_defs_after == NULL
- || NUM_V_MUST_DEFS (v_must_defs_before) >
+ || NUM_V_MUST_DEFS (v_must_defs_before) >
NUM_V_MUST_DEFS (v_must_defs_after))
return true;
@@ -1093,7 +1101,7 @@ mark_new_vars_to_rename (tree stmt, bitmap vars_to_rename)
bitmap_set_bit (vars_to_rename, var_ann (var)->uid);
}
}
-
+
v_must_defs_after = v_must_defs = V_MUST_DEF_OPS (ann);
for (i = 0; i < NUM_V_MUST_DEFS (v_must_defs); i++)
{
@@ -1103,7 +1111,7 @@ mark_new_vars_to_rename (tree stmt, bitmap vars_to_rename)
found_exposed_symbol = true;
bitmap_set_bit (vars_to_rename, var_ann (var)->uid);
}
- }
+ }
/* If we found any newly exposed symbols, or if there are fewer VDEF
operands in the statement, add the variables we had set in