Commit 74cacb71 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

all: Do not change current_ir_graph during walking/analyses/...

parent 8cdc5248
......@@ -30,8 +30,7 @@
* Walks over the ir graph, starting at the node given as first argument.
* Executes pre before visiting the predecessor of a node, post after.
* irg_walk uses the visited flag in irg and the nodes to determine visited
* nodes. It executes inc_irg_visited(current_ir_graph) to generate a new
* flag. Therefore current_ir_graph must be set before calling the walker.
* nodes. It executes inc_irg_visited() to generate a new flag.
* It marks the node as visited before executing pre.
* The void* env can be used to pass status information between the
* pre and post functions. Does not use the link fields.
......@@ -46,8 +45,7 @@ FIRM_API void irg_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post,
void *env);
/**
* core walker function. Does NOT touch current_ir_graph and does not call
* inc_irg_visited before walking
* core walker function. Does NOT call inc_irg_visited before walking.
*/
FIRM_API void irg_walk_core(ir_node *node, irg_walk_func *pre,
irg_walk_func *post, void *env);
......@@ -61,8 +59,7 @@ FIRM_API void irg_walk_core(ir_node *node, irg_walk_func *pre,
* @param env environment, passed to pre and post
*
* Like irg_walk(), but walks over all reachable nodes in the ir
* graph, starting at the end operation. During the walk current_ir_graph
* is set to irg. Does not use the link field.
* graph, starting at the end operation. Does not use the link field.
*/
FIRM_API void irg_walk_graph(ir_graph *irg, irg_walk_func *pre,
irg_walk_func *post, void *env);
......@@ -73,8 +70,7 @@ FIRM_API void irg_walk_graph(ir_graph *irg, irg_walk_func *pre,
* Walks over the ir graph, starting at the node given as first argument.
* Executes pre before visiting the predecessor of a node, post after.
* irg_walk uses the visited flag in irg and the nodes to determine visited
* nodes. It executes inc_irg_visited(current_ir_graph) to generate a new
* flag. Therefore current_ir_graph must be set before calling the walker.
* nodes. It executes inc_irg_visited() to generate a new flag.
* It marks the node as visited before executing pre.
* The void* env can be used to pass status information between the
* pre and post functions. Does not use the link fields.
......@@ -98,8 +94,7 @@ FIRM_API void irg_walk_in_or_dep(ir_node *node, irg_walk_func *pre,
* @param env environment, passed to pre and post
*
* Like irg_walk(), but walks over all reachable nodes in the ir
* graph, starting at the end operation. During the walk current_ir_graph
* is set to irg. Does not use the link field.
* graph, starting at the end operation. Does not use the link field.
* This walker also follows additional dependency egdes.
*/
FIRM_API void irg_walk_in_or_dep_graph(ir_graph *irg, irg_walk_func *pre,
......@@ -113,8 +108,7 @@ FIRM_API void irg_walk_in_or_dep_graph(ir_graph *irg, irg_walk_func *pre,
* @param env environment, passed to pre and post
*
* This function executes irg_walk(end, pre, post, env) for all irgraphs in irprog.
* Sets current_ir_graph properly for each walk. Conserves current
* current_ir_graph. Does not use the link field.
* Does not use the link field.
*/
FIRM_API void all_irg_walk(irg_walk_func *pre, irg_walk_func *post, void *env);
......@@ -166,8 +160,8 @@ FIRM_API void walk_const_code(irg_walk_func *pre, irg_walk_func *post,
* Executes pre before visiting the predecessor of a node, post after.
* irg_walk_blkwise_graph() uses the visited flag in irg and the nodes to
* determine visited nodes.
* It executes inc_irg_visited(current_ir_graph) to generate a new
* flag. It marks the node as visited before executing pre.
* It executes inc_irg_visited() to generate a new flag. It marks the node as
* visited before executing pre.
* The void *env can be used to pass status information between the
* pre and post functions. Does not use the link fields.
*
......@@ -185,8 +179,8 @@ FIRM_API void irg_walk_blkwise_graph(ir_graph *irg, irg_walk_func *pre,
* Executes pre before visiting the predecessor of a node, post after.
* irg_walk_blkwise_graph() uses the visited flag in irg and the nodes to
* determine visited nodes.
* It executes inc_irg_visited(current_ir_graph) to generate a new
* flag. It marks the node as visited before executing pre.
* It executes inc_irg_visited() to generate a new flag. It marks the node as
* visited before executing pre.
* The void *env can be used to pass status information between the
* pre and post functions. Does not use the link fields.
* This walker also follows dependency edges.
......@@ -207,8 +201,8 @@ FIRM_API void irg_walk_in_or_dep_blkwise_graph(ir_graph *irg,
* Executes pre before visiting the predecessor of a node, post after.
* irg_walk_blkwise_graph() uses the visited flag in irg and the nodes to
* determine visited nodes.
* It executes inc_irg_visited(current_ir_graph) to generate a new
* flag. It marks the node as visited before executing pre.
* It executes inc_irg_visited() to generate a new flag. It marks the node as
* visited before executing pre.
* The void *env can be used to pass status information between the
* pre and post functions. Does not use the link fields.
*
......
......@@ -192,9 +192,6 @@ void irg_out_block_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post,
ir_graph *irg = get_irn_irg(node);
assert(is_Block(node) || (get_irn_mode(node) == mode_X));
ir_graph *rem = current_ir_graph;
current_ir_graph = irg;
inc_irg_block_visited(irg);
if (get_irn_mode(node) == mode_X) {
......@@ -205,8 +202,6 @@ void irg_out_block_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post,
} else {
irg_out_block_walk2(node, pre, post, env);
}
current_ir_graph = rem;
}
/*--------------------------------------------------------------------*/
......
......@@ -650,10 +650,8 @@ static void scc(ir_node *n)
void construct_backedges(ir_graph *irg)
{
ir_graph *rem = current_ir_graph;
struct obstack temp;
current_ir_graph = irg;
outermost_ir_graph = irg;
obstack_init(&temp);
......@@ -678,7 +676,6 @@ void construct_backedges(ir_graph *irg)
set_irg_loop(irg, current_loop);
add_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO);
assert(get_irg_loop(irg)->kind == k_ir_loop);
current_ir_graph = rem;
}
static void reset_backedges(ir_node *n)
......
......@@ -367,9 +367,6 @@ static void transform_nodes(ir_graph *irg, arch_pretrans_nodes *pre_transform)
void be_transform_graph(ir_graph *irg, arch_pretrans_nodes *func)
{
ir_graph *old_current_ir_graph = current_ir_graph;
current_ir_graph = irg;
/* create a new obstack */
struct obstack old_obst = irg->obst;
obstack_init(&irg->obst);
......@@ -386,9 +383,6 @@ void be_transform_graph(ir_graph *irg, arch_pretrans_nodes *func)
/* free the old obstack */
obstack_free(&old_obst, 0);
/* restore state */
current_ir_graph = old_current_ir_graph;
/* most analysis info is wrong after transformation */
be_invalidate_live_chk(irg);
confirm_irg_properties(irg, IR_GRAPH_PROPERTIES_NONE);
......
......@@ -41,15 +41,7 @@ static void optimize_in_place_wrapper(ir_node *n, void *env)
}
}
/**
* Do local optimizations for a node.
*
* @param n the IR-node where to start. Typically the End node
* of a graph
*
* @note current_ir_graph must be set
*/
static inline void do_local_optimize(ir_node *n)
void local_optimize_node(ir_node *n)
{
ir_graph *irg = get_irn_irg(n);
......@@ -64,16 +56,6 @@ static inline void do_local_optimize(ir_node *n)
irg_walk(n, firm_clear_link, optimize_in_place_wrapper, NULL);
}
void local_optimize_node(ir_node *n)
{
ir_graph *rem = current_ir_graph;
current_ir_graph = get_irn_irg(n);
do_local_optimize(n);
current_ir_graph = rem;
}
static void enqueue_node(ir_node *node, pdeq *waitq)
{
if (get_irn_link(node) == waitq)
......@@ -136,12 +118,7 @@ static void find_unreachable_blocks(ir_node *block, void *env)
void local_optimize_graph(ir_graph *irg)
{
ir_graph *rem = current_ir_graph;
current_ir_graph = irg;
do_local_optimize(get_irg_end(irg));
current_ir_graph = rem;
local_optimize_node(get_irg_end(irg));
}
/**
......@@ -165,10 +142,7 @@ static void opt_walker(ir_node *n, void *env)
void optimize_graph_df(ir_graph *irg)
{
pdeq *waitq = new_pdeq();
ir_graph *rem = current_ir_graph;
current_ir_graph = irg;
pdeq *waitq = new_pdeq();
if (get_opt_global_cse())
set_irg_pinned(irg, op_pin_state_floats);
......@@ -226,8 +200,6 @@ void optimize_graph_df(ir_graph *irg)
* Doing this AFTER edges where deactivated saves cycles */
ir_node *end = get_irg_end(irg);
remove_End_Bads_and_doublets(end);
current_ir_graph = rem;
}
void local_opts_const_code(void)
......
......@@ -117,24 +117,17 @@ void irg_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post,
void *env)
{
ir_graph *irg = get_irn_irg(node);
ir_graph *rem = current_ir_graph;
current_ir_graph = irg;
ir_reserve_resources(irg, IR_RESOURCE_IRN_VISITED);
inc_irg_visited(irg);
irg_walk_core(node, pre, post, env);
ir_free_resources(irg, IR_RESOURCE_IRN_VISITED);
current_ir_graph = rem;
}
void irg_walk_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env)
{
ir_graph * rem = current_ir_graph;
hook_irg_walk(irg, (generic_func *)pre, (generic_func *)post);
current_ir_graph = irg;
irg_walk(get_irg_end(irg), pre, post, env);
current_ir_graph = rem;
}
void all_irg_walk(irg_walk_func *pre, irg_walk_func *post, void *env)
......@@ -248,12 +241,8 @@ void irg_walk_in_or_dep(ir_node *node, irg_walk_func *pre, irg_walk_func *post,
void irg_walk_in_or_dep_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env)
{
ir_graph * rem = current_ir_graph;
hook_irg_walk(irg, (generic_func *)pre, (generic_func *)post);
current_ir_graph = irg;
irg_walk_in_or_dep(get_irg_end(irg), pre, post, env);
current_ir_graph = rem;
}
/* Walks back from n until it finds a real cf op. */
......@@ -321,10 +310,7 @@ void irg_block_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post,
void irg_block_walk_graph(ir_graph *irg, irg_walk_func *pre,
irg_walk_func *post, void *env)
{
ir_graph * rem = current_ir_graph;
current_ir_graph = irg;
irg_block_walk(get_irg_end(irg), pre, post, env);
current_ir_graph = rem;
}
void irg_walk_anchors(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env)
......@@ -380,9 +366,8 @@ void walk_const_code(irg_walk_func *pre, irg_walk_func *post, void *env)
size_t i;
size_t n_types;
ir_graph *rem = current_ir_graph;
current_ir_graph = get_const_code_irg();
inc_irg_visited(current_ir_graph);
ir_graph *const irg = get_const_code_irg();
inc_irg_visited(irg);
my_env.pre = pre;
my_env.post = post;
......@@ -406,6 +391,4 @@ void walk_const_code(irg_walk_func *pre, irg_walk_func *post, void *env)
irg_walk(size, pre, post, env);
}
}
current_ir_graph = rem;
}
......@@ -437,30 +437,18 @@ static void do_irg_walk_blk(ir_graph *irg, irg_walk_func *pre,
void irg_walk_blkwise_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env)
{
ir_graph * rem = current_ir_graph;
hook_irg_walk_blkwise(irg, (generic_func *)pre, (generic_func *)post);
current_ir_graph = irg;
do_irg_walk_blk(irg, pre, post, env, 0, traverse_blocks);
current_ir_graph = rem;
}
void irg_walk_in_or_dep_blkwise_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env)
{
ir_graph * rem = current_ir_graph;
hook_irg_walk_blkwise(irg, (generic_func *)pre, (generic_func *)post);
current_ir_graph = irg;
do_irg_walk_blk(irg, pre, post, env, 1, traverse_blocks);
current_ir_graph = rem;
}
void irg_walk_blkwise_dom_top_down(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *env)
{
ir_graph * rem = current_ir_graph;
hook_irg_walk_blkwise(irg, (generic_func *)pre, (generic_func *)post);
current_ir_graph = irg;
do_irg_walk_blk(irg, pre, post, env, 0, traverse_dom_blocks_top_down);
current_ir_graph = rem;
}
......@@ -6922,13 +6922,9 @@ void add_identities(ir_node *node)
void visit_all_identities(ir_graph *irg, irg_walk_func visit, void *env)
{
ir_graph *rem = current_ir_graph;
current_ir_graph = irg;
foreach_pset(irg->value_table, ir_node, node) {
visit(node, env);
}
current_ir_graph = rem;
}
ir_node *optimize_node(ir_node *n)
......
......@@ -2717,7 +2717,6 @@ static void lower_irg(ir_graph *irg)
/* just here for debugging */
obstack_init(&env->obst);
current_ir_graph = irg;
unsigned n_idx = get_irg_last_idx(irg);
n_idx = n_idx + (n_idx >> 2); /* add 25% */
......
......@@ -520,9 +520,6 @@ void opt_tail_rec_irg(ir_graph *irg)
return;
}
ir_graph *rem = current_ir_graph;
current_ir_graph = irg;
ir_entity *ent = get_irg_entity(irg);
ir_type *mtd_type = get_entity_type(ent);
int n_ress = get_method_n_ress(mtd_type);
......@@ -628,7 +625,6 @@ void opt_tail_rec_irg(ir_graph *irg)
confirm_irg_properties(irg, IR_GRAPH_PROPERTIES_ALL);
}
ir_free_resources(irg, IR_RESOURCE_IRN_LINK);
current_ir_graph = rem;
}
/*
......
......@@ -1108,14 +1108,10 @@ static void update_graph_stat(graph_entry_t *global, graph_entry_t *graph)
/* count the number of address calculation */
if (graph->irg != get_const_code_irg()) {
ir_graph *rem = current_ir_graph;
assure_irg_outs(graph->irg);
/* Must be done an the outs graph */
current_ir_graph = graph->irg;
irg_out_walk(get_irg_start(graph->irg), NULL, mark_address_calc, graph);
current_ir_graph = rem;
#ifdef DUMP_ADR_MODE
/* register the vcg hook and dump the graph for test */
......
......@@ -227,9 +227,6 @@ void type_walk_irg(ir_graph *irg,
type_env.post = post;
type_env.env = env;
ir_graph *rem = current_ir_graph;
current_ir_graph = irg;
/* We walk over the irg to find all IR-nodes that contain an attribute
with type information. If we find one we call a type walker to
touch the reachable type information.
......@@ -247,8 +244,6 @@ void type_walk_irg(ir_graph *irg,
do_type_walk(get_irg_frame_type(irg), NULL, pre, post, env);
irp_free_resources(irp, IRP_RESOURCE_TYPE_VISITED);
current_ir_graph = rem;
}
static void type_walk_s2s_2(ir_type *const tp,
......
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