From 8010ed3d640a15ac18138d8a96ea61f318aae2cb Mon Sep 17 00:00:00 2001 From: Andreas Zwinkau Date: Fri, 15 Apr 2011 15:58:44 +0200 Subject: [PATCH] Use block walk for ssa_cons_start The node walk used before was inefficient, since everything but blocks was ignored. Additionally, this fixes a bug, because ssa_cons_finish already used a block walk already, such that unreachable blocks were immatured, but not matured in the scalar-replace optimization. This bug could also be avoided by ensuring cfopt before scalar-replace, but keeping ssacons start and finish symmetric seems to be more robust. --- ir/ir/irssacons.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/ir/ir/irssacons.c b/ir/ir/irssacons.c index e6b382c94..d3982c860 100644 --- a/ir/ir/irssacons.c +++ b/ir/ir/irssacons.c @@ -34,19 +34,16 @@ * Post-walker: prepare the graph nodes for new SSA construction cycle by * allocation new arrays. */ -static void prepare_nodes(ir_node *irn, void *env) +static void prepare_blocks(ir_node *irn, void *env) { (void)env; - - if (is_Block(irn)) { - unsigned n_loc = current_ir_graph->n_loc; - struct obstack *obst = current_ir_graph->obst; - /* reset mature flag */ - set_Block_matured(irn, 0); - irn->attr.block.graph_arr = NEW_ARR_D(ir_node *, obst, n_loc); - memset(irn->attr.block.graph_arr, 0, sizeof(ir_node*) * n_loc); - irn->attr.block.phis = NULL; - } + unsigned n_loc = current_ir_graph->n_loc; + struct obstack *obst = current_ir_graph->obst; + /* reset mature flag */ + set_Block_matured(irn, 0); + irn->attr.block.graph_arr = NEW_ARR_D(ir_node *, obst, n_loc); + memset(irn->attr.block.graph_arr, 0, sizeof(ir_node*) * n_loc); + irn->attr.block.phis = NULL; } /* @@ -75,7 +72,7 @@ void ssa_cons_start(ir_graph *irg, int n_loc) * seems worth to do this. First, we have to check if they really exists and * then clear them. We do not expect SSA construction is used often. */ - irg_walk_graph(irg, NULL, prepare_nodes, NULL); + irg_block_walk_graph(irg, NULL, prepare_blocks, NULL); } /** -- 2.20.1