Commit 3a2e4b46 by Andrew Pinski

re PR tree-optimization/18507 (block_defs_stack varrray should not be GC'ed)

2004-11-19  Andrew Pinski  <pinskia@physics.uc.edu>

        PR tree-opt/18507
        * tree-flow.h (tree2): Typedef because there is already a VEC(tree).
        Define a VEC(tree2) for head.
        (register_new_def): Change second argument to be a VEC(tree2).
        * tree-ssa-dom.c (block_defs_stack): Change to be a VEC(tree2).
        (tree_ssa_dominator_optimize): Initialize block_defs_stack with
        the VEC(tree2) function.  Also free it before returning.
        (dom_opt_initialize_block): Use VEC_safe_push instead of VARRAY_PUSH_TREE
        for block_defs_stack.
        (restore_currdefs_to_original_value): Use VEC_length instead of
        VARRAY_ACTIVE_SIZE. VEC_pop instead of VARRAY_TOP_TREE/VARRAY_POP.
        (dom_opt_finalize_block): Use VEC_safe_push instead of VARRAY_PUSH_TREE
        for block_defs_stack.
        * tree-into-ssa.c (block_defs_stack): Change to be a VEC(tree2).
        (rewrite_initialize_block): Use VEC_safe_push instead of VARRAY_PUSH_TREE
        for block_defs_stack.
        (ssa_register_new_def): Likewise.
        (ssa_rewrite_initialize_block): Likewise.
        (rewrite_finalize_block): Use VEC_length instead of
        VARRAY_ACTIVE_SIZE. VEC_pop instead of VARRAY_TOP_TREE/VARRAY_POP.
        (ssa_rewrite_finalize_block): Likewise.
        (register_new_def): Change second argument to be a VEC(tree2).
        Use VEC_safe_push instead of VARRAY_PUSH_TREE.
        (rewrite_blocks): Initialize block_defs_stack with
        the VEC(tree2) function.  Also free it before returning.
        (rewrite_ssa_into_ssa): Likewise.

From-SVN: r90926
parent 0e1ad529
2004-11-18 Fariborz Jahanian <fjahanian@apple.com> 2004-11-19 Andrew Pinski <pinskia@physics.uc.edu>
PR tree-opt/18507
* tree-flow.h (tree2): Typedef because there is already a VEC(tree).
Define a VEC(tree2) for head.
(register_new_def): Change second argument to be a VEC(tree2).
* tree-ssa-dom.c (block_defs_stack): Change to be a VEC(tree2).
(tree_ssa_dominator_optimize): Initialize block_defs_stack with
the VEC(tree2) function. Also free it before returning.
(dom_opt_initialize_block): Use VEC_safe_push instead of VARRAY_PUSH_TREE
for block_defs_stack.
(restore_currdefs_to_original_value): Use VEC_length instead of
VARRAY_ACTIVE_SIZE. VEC_pop instead of VARRAY_TOP_TREE/VARRAY_POP.
(dom_opt_finalize_block): Use VEC_safe_push instead of VARRAY_PUSH_TREE
for block_defs_stack.
* tree-into-ssa.c (block_defs_stack): Change to be a VEC(tree2).
(rewrite_initialize_block): Use VEC_safe_push instead of VARRAY_PUSH_TREE
for block_defs_stack.
(ssa_register_new_def): Likewise.
(ssa_rewrite_initialize_block): Likewise.
(rewrite_finalize_block): Use VEC_length instead of
VARRAY_ACTIVE_SIZE. VEC_pop instead of VARRAY_TOP_TREE/VARRAY_POP.
(ssa_rewrite_finalize_block): Likewise.
(register_new_def): Change second argument to be a VEC(tree2).
Use VEC_safe_push instead of VARRAY_PUSH_TREE.
(rewrite_blocks): Initialize block_defs_stack with
the VEC(tree2) function. Also free it before returning.
(rewrite_ssa_into_ssa): Likewise.
2004-11-19 Fariborz Jahanian <fjahanian@apple.com>
* config/darwin.c (machopic_data_defined_p): return 1 for * config/darwin.c (machopic_data_defined_p): return 1 for
MACHOPIC_DEFINED_FUNCTION. MACHOPIC_DEFINED_FUNCTION.
......
...@@ -562,6 +562,9 @@ extern struct ptr_info_def *get_ptr_info (tree); ...@@ -562,6 +562,9 @@ extern struct ptr_info_def *get_ptr_info (tree);
definition, a function with this prototype is called. */ definition, a function with this prototype is called. */
typedef bool (*walk_use_def_chains_fn) (tree, tree, void *); typedef bool (*walk_use_def_chains_fn) (tree, tree, void *);
typedef tree tree_on_heap;
DEF_VEC_MALLOC_P (tree_on_heap);
/* In tree-ssa.c */ /* In tree-ssa.c */
extern void init_tree_ssa (void); extern void init_tree_ssa (void);
extern void debug_reaching_defs (void); extern void debug_reaching_defs (void);
...@@ -577,7 +580,7 @@ extern bool tree_ssa_useless_type_conversion (tree); ...@@ -577,7 +580,7 @@ extern bool tree_ssa_useless_type_conversion (tree);
extern bool tree_ssa_useless_type_conversion_1 (tree, tree); extern bool tree_ssa_useless_type_conversion_1 (tree, tree);
extern void verify_ssa (void); extern void verify_ssa (void);
extern void delete_tree_ssa (void); extern void delete_tree_ssa (void);
extern void register_new_def (tree, varray_type *); extern void register_new_def (tree, VEC (tree_on_heap) **);
extern void walk_use_def_chains (tree, walk_use_def_chains_fn, void *, bool); extern void walk_use_def_chains (tree, walk_use_def_chains_fn, void *, bool);
extern void kill_redundant_phi_nodes (void); extern void kill_redundant_phi_nodes (void);
extern bool stmt_references_memory_p (tree); extern bool stmt_references_memory_p (tree);
......
...@@ -109,7 +109,9 @@ static htab_t def_blocks; ...@@ -109,7 +109,9 @@ static htab_t def_blocks;
A NULL node at the top entry is used to mark the last node associated A NULL node at the top entry is used to mark the last node associated
with the current block. */ with the current block. */
static varray_type block_defs_stack; static VEC(tree_on_heap) *block_defs_stack;
/* FIXME: The other stacks should also be VEC(tree_on_heap). */
/* Global data to attach to the main dominator walk structure. */ /* Global data to attach to the main dominator walk structure. */
struct mark_def_sites_global_data struct mark_def_sites_global_data
...@@ -678,7 +680,7 @@ rewrite_initialize_block (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED, ...@@ -678,7 +680,7 @@ rewrite_initialize_block (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED,
fprintf (dump_file, "\n\nRenaming block #%d\n\n", bb->index); fprintf (dump_file, "\n\nRenaming block #%d\n\n", bb->index);
/* Mark the unwind point for this block. */ /* Mark the unwind point for this block. */
VARRAY_PUSH_TREE (block_defs_stack, NULL_TREE); VEC_safe_push (tree_on_heap, block_defs_stack, NULL_TREE);
/* Step 1. Register new definitions for every PHI node in the block. /* Step 1. Register new definitions for every PHI node in the block.
Conceptually, all the PHI nodes are executed in parallel and each PHI Conceptually, all the PHI nodes are executed in parallel and each PHI
...@@ -716,8 +718,8 @@ ssa_register_new_def (tree var, tree def) ...@@ -716,8 +718,8 @@ ssa_register_new_def (tree var, tree def)
later used by the dominator tree callbacks to restore the reaching later used by the dominator tree callbacks to restore the reaching
definitions for all the variables defined in the block after a recursive definitions for all the variables defined in the block after a recursive
visit to all its immediately dominated blocks. */ visit to all its immediately dominated blocks. */
VARRAY_PUSH_TREE (block_defs_stack, currdef); VEC_safe_push (tree_on_heap, block_defs_stack, currdef);
VARRAY_PUSH_TREE (block_defs_stack, var); VEC_safe_push (tree_on_heap, block_defs_stack, var);
/* Set the current reaching definition for VAR to be DEF. */ /* Set the current reaching definition for VAR to be DEF. */
set_current_def (var, def); set_current_def (var, def);
...@@ -738,7 +740,7 @@ ssa_rewrite_initialize_block (struct dom_walk_data *walk_data, basic_block bb) ...@@ -738,7 +740,7 @@ ssa_rewrite_initialize_block (struct dom_walk_data *walk_data, basic_block bb)
fprintf (dump_file, "\n\nRenaming block #%d\n\n", bb->index); fprintf (dump_file, "\n\nRenaming block #%d\n\n", bb->index);
/* Mark the unwind point for this block. */ /* Mark the unwind point for this block. */
VARRAY_PUSH_TREE (block_defs_stack, NULL_TREE); VEC_safe_push (tree_on_heap, block_defs_stack, NULL_TREE);
FOR_EACH_EDGE (e, ei, bb->preds) FOR_EACH_EDGE (e, ei, bb->preds)
if (e->flags & EDGE_ABNORMAL) if (e->flags & EDGE_ABNORMAL)
...@@ -876,13 +878,11 @@ rewrite_finalize_block (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED, ...@@ -876,13 +878,11 @@ rewrite_finalize_block (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED,
basic_block bb ATTRIBUTE_UNUSED) basic_block bb ATTRIBUTE_UNUSED)
{ {
/* Restore CURRDEFS to its original state. */ /* Restore CURRDEFS to its original state. */
while (VARRAY_ACTIVE_SIZE (block_defs_stack) > 0) while (VEC_length (tree_on_heap, block_defs_stack) > 0)
{ {
tree tmp = VARRAY_TOP_TREE (block_defs_stack); tree tmp = VEC_pop (tree_on_heap, block_defs_stack);
tree saved_def, var; tree saved_def, var;
VARRAY_POP (block_defs_stack);
if (tmp == NULL_TREE) if (tmp == NULL_TREE)
break; break;
...@@ -914,18 +914,15 @@ ssa_rewrite_finalize_block (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED, ...@@ -914,18 +914,15 @@ ssa_rewrite_finalize_block (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED,
/* Step 5. Restore the current reaching definition for each variable /* Step 5. Restore the current reaching definition for each variable
referenced in the block (in reverse order). */ referenced in the block (in reverse order). */
while (VARRAY_ACTIVE_SIZE (block_defs_stack) > 0) while (VEC_length (tree_on_heap, block_defs_stack) > 0)
{ {
tree var = VARRAY_TOP_TREE (block_defs_stack); tree var = VEC_pop (tree_on_heap, block_defs_stack);
tree saved_def; tree saved_def;
VARRAY_POP (block_defs_stack);
if (var == NULL) if (var == NULL)
break; break;
saved_def = VARRAY_TOP_TREE (block_defs_stack); saved_def = VEC_pop (tree_on_heap, block_defs_stack);
VARRAY_POP (block_defs_stack);
set_current_def (var, saved_def); set_current_def (var, saved_def);
} }
...@@ -1190,7 +1187,7 @@ rewrite_operand (use_operand_p op_p) ...@@ -1190,7 +1187,7 @@ rewrite_operand (use_operand_p op_p)
into the stack pointed by BLOCK_DEFS_P. */ into the stack pointed by BLOCK_DEFS_P. */
void void
register_new_def (tree def, varray_type *block_defs_p) register_new_def (tree def, VEC (tree_on_heap) **block_defs_p)
{ {
tree var = SSA_NAME_VAR (def); tree var = SSA_NAME_VAR (def);
tree currdef; tree currdef;
...@@ -1216,7 +1213,7 @@ register_new_def (tree def, varray_type *block_defs_p) ...@@ -1216,7 +1213,7 @@ register_new_def (tree def, varray_type *block_defs_p)
definitions for all the variables defined in the block after a recursive definitions for all the variables defined in the block after a recursive
visit to all its immediately dominated blocks. If there is no current visit to all its immediately dominated blocks. If there is no current
reaching definition, then just record the underlying _DECL node. */ reaching definition, then just record the underlying _DECL node. */
VARRAY_PUSH_TREE (*block_defs_p, currdef ? currdef : var); VEC_safe_push (tree_on_heap, *block_defs_p, currdef ? currdef : var);
/* Set the current reaching definition for VAR to be DEF. */ /* Set the current reaching definition for VAR to be DEF. */
set_current_def (var, def); set_current_def (var, def);
...@@ -1437,7 +1434,7 @@ rewrite_blocks (bool fix_virtual_phis) ...@@ -1437,7 +1434,7 @@ rewrite_blocks (bool fix_virtual_phis)
walk_data.global_data = NULL; walk_data.global_data = NULL;
walk_data.block_local_data_size = 0; walk_data.block_local_data_size = 0;
VARRAY_TREE_INIT (block_defs_stack, 10, "Block DEFS Stack"); block_defs_stack = VEC_alloc (tree_on_heap, 10);
/* Initialize the dominator walker. */ /* Initialize the dominator walker. */
init_walk_dominator_tree (&walk_data); init_walk_dominator_tree (&walk_data);
...@@ -1451,6 +1448,9 @@ rewrite_blocks (bool fix_virtual_phis) ...@@ -1451,6 +1448,9 @@ rewrite_blocks (bool fix_virtual_phis)
htab_delete (def_blocks); htab_delete (def_blocks);
VEC_free (tree_on_heap, block_defs_stack);
block_defs_stack = NULL;
timevar_pop (TV_TREE_SSA_REWRITE_BLOCKS); timevar_pop (TV_TREE_SSA_REWRITE_BLOCKS);
} }
...@@ -1670,7 +1670,7 @@ rewrite_ssa_into_ssa (void) ...@@ -1670,7 +1670,7 @@ rewrite_ssa_into_ssa (void)
mark_def_sites_global_data.names_to_rename = snames_to_rename; mark_def_sites_global_data.names_to_rename = snames_to_rename;
walk_data.global_data = &mark_def_sites_global_data; walk_data.global_data = &mark_def_sites_global_data;
VARRAY_TREE_INIT (block_defs_stack, 10, "Block DEFS Stack"); block_defs_stack = VEC_alloc (tree_on_heap, 10);
/* We do not have any local data. */ /* We do not have any local data. */
walk_data.block_local_data_size = 0; walk_data.block_local_data_size = 0;
...@@ -1756,6 +1756,9 @@ rewrite_ssa_into_ssa (void) ...@@ -1756,6 +1756,9 @@ rewrite_ssa_into_ssa (void)
} }
BITMAP_XFREE (to_rename); BITMAP_XFREE (to_rename);
VEC_free (tree_on_heap, block_defs_stack);
block_defs_stack = NULL;
timevar_pop (TV_TREE_SSA_OTHER); timevar_pop (TV_TREE_SSA_OTHER);
} }
......
...@@ -106,7 +106,9 @@ static varray_type avail_exprs_stack; ...@@ -106,7 +106,9 @@ static varray_type avail_exprs_stack;
A NULL node is used to mark the last node associated with the A NULL node is used to mark the last node associated with the
current block. */ current block. */
varray_type block_defs_stack; VEC(tree_on_heap) *block_defs_stack;
/* FIXME: The other stacks should also be VEC(tree_on_heap). */
/* Stack of statements we need to rescan during finalization for newly /* Stack of statements we need to rescan during finalization for newly
exposed variables. exposed variables.
...@@ -384,7 +386,7 @@ tree_ssa_dominator_optimize (void) ...@@ -384,7 +386,7 @@ tree_ssa_dominator_optimize (void)
avail_exprs = htab_create (1024, real_avail_expr_hash, avail_expr_eq, free); avail_exprs = htab_create (1024, real_avail_expr_hash, avail_expr_eq, free);
vrp_data = htab_create (ceil_log2 (num_ssa_names), vrp_hash, vrp_eq, free); vrp_data = htab_create (ceil_log2 (num_ssa_names), vrp_hash, vrp_eq, free);
VARRAY_TREE_INIT (avail_exprs_stack, 20, "Available expression stack"); VARRAY_TREE_INIT (avail_exprs_stack, 20, "Available expression stack");
VARRAY_TREE_INIT (block_defs_stack, 20, "Block DEFS stack"); block_defs_stack = VEC_alloc (tree_on_heap, 20);
VARRAY_TREE_INIT (const_and_copies_stack, 20, "Block const_and_copies stack"); VARRAY_TREE_INIT (const_and_copies_stack, 20, "Block const_and_copies stack");
VARRAY_TREE_INIT (nonzero_vars_stack, 20, "Block nonzero_vars stack"); VARRAY_TREE_INIT (nonzero_vars_stack, 20, "Block nonzero_vars stack");
VARRAY_TREE_INIT (vrp_variables_stack, 20, "Block vrp_variables stack"); VARRAY_TREE_INIT (vrp_variables_stack, 20, "Block vrp_variables stack");
...@@ -502,6 +504,9 @@ tree_ssa_dominator_optimize (void) ...@@ -502,6 +504,9 @@ tree_ssa_dominator_optimize (void)
if (value && !is_gimple_min_invariant (value)) if (value && !is_gimple_min_invariant (value))
SSA_NAME_VALUE (name) = NULL; SSA_NAME_VALUE (name) = NULL;
} }
VEC_free (tree_on_heap, block_defs_stack);
block_defs_stack = NULL;
} }
static bool static bool
...@@ -804,7 +809,7 @@ dom_opt_initialize_block (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED, ...@@ -804,7 +809,7 @@ dom_opt_initialize_block (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED,
/* Push a marker on the stacks of local information so that we know how /* Push a marker on the stacks of local information so that we know how
far to unwind when we finalize this block. */ far to unwind when we finalize this block. */
VARRAY_PUSH_TREE (avail_exprs_stack, NULL_TREE); VARRAY_PUSH_TREE (avail_exprs_stack, NULL_TREE);
VARRAY_PUSH_TREE (block_defs_stack, NULL_TREE); VEC_safe_push (tree_on_heap, block_defs_stack, NULL_TREE);
VARRAY_PUSH_TREE (const_and_copies_stack, NULL_TREE); VARRAY_PUSH_TREE (const_and_copies_stack, NULL_TREE);
VARRAY_PUSH_TREE (nonzero_vars_stack, NULL_TREE); VARRAY_PUSH_TREE (nonzero_vars_stack, NULL_TREE);
VARRAY_PUSH_TREE (vrp_variables_stack, NULL_TREE); VARRAY_PUSH_TREE (vrp_variables_stack, NULL_TREE);
...@@ -925,13 +930,11 @@ static void ...@@ -925,13 +930,11 @@ static void
restore_currdefs_to_original_value (void) restore_currdefs_to_original_value (void)
{ {
/* Restore CURRDEFS to its original state. */ /* Restore CURRDEFS to its original state. */
while (VARRAY_ACTIVE_SIZE (block_defs_stack) > 0) while (VEC_length (tree_on_heap, block_defs_stack) > 0)
{ {
tree tmp = VARRAY_TOP_TREE (block_defs_stack); tree tmp = VEC_pop (tree_on_heap, block_defs_stack);
tree saved_def, var; tree saved_def, var;
VARRAY_POP (block_defs_stack);
if (tmp == NULL_TREE) if (tmp == NULL_TREE)
break; break;
...@@ -999,7 +1002,7 @@ dom_opt_finalize_block (struct dom_walk_data *walk_data, basic_block bb) ...@@ -999,7 +1002,7 @@ dom_opt_finalize_block (struct dom_walk_data *walk_data, basic_block bb)
unwind any expressions related to the TRUE arm before processing unwind any expressions related to the TRUE arm before processing
the false arm below. */ the false arm below. */
VARRAY_PUSH_TREE (avail_exprs_stack, NULL_TREE); VARRAY_PUSH_TREE (avail_exprs_stack, NULL_TREE);
VARRAY_PUSH_TREE (block_defs_stack, NULL_TREE); VEC_safe_push (tree_on_heap, block_defs_stack, NULL_TREE);
VARRAY_PUSH_TREE (const_and_copies_stack, NULL_TREE); VARRAY_PUSH_TREE (const_and_copies_stack, NULL_TREE);
edge_info = true_edge->aux; edge_info = true_edge->aux;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment