From 64a05bd2846f1dbe27318977303d411fc4149484 Mon Sep 17 00:00:00 2001 From: Andreas Zwinkau Date: Tue, 17 May 2011 13:25:41 +0200 Subject: [PATCH] code placement fixes gcse GCSEing nodes into unreachable blocks is ok now. The verifier does not check the cfg, when irg is floating. Code placement fixes and pins the irg after gcse. Nodes in unreachable blocks are moved into the first block after the start block. Reachability checks in place_late are converted into asserts, because after place_early, there are no unreachable blocks anymore. reverts c64fe29 and 318579c but also fixes opt/unreachable_block --- ir/ir/iropt.c | 10 ---------- ir/ir/irverify.c | 2 +- ir/opt/code_placement.c | 20 +++++++------------- 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/ir/ir/iropt.c b/ir/ir/iropt.c index a17533be8..679410da3 100644 --- a/ir/ir/iropt.c +++ b/ir/ir/iropt.c @@ -6129,16 +6129,6 @@ ir_node *identify_remember(ir_node *n) if (value_table == NULL) return n; - if (get_opt_global_cse()) { - /* do not remember unreachable nodes */ - if (!is_Block(n)) { - ir_node *block = get_nodes_block(n); - if (is_block_unreachable(block)) { - return n; - } - } - } - ir_normalize_node(n); /* lookup or insert in hash table with given hash key. */ nn = (ir_node*)pset_insert(value_table, n, ir_node_hash(n)); diff --git a/ir/ir/irverify.c b/ir/ir/irverify.c index 530470039..3173a5c2b 100644 --- a/ir/ir/irverify.c +++ b/ir/ir/irverify.c @@ -1999,7 +1999,7 @@ int irg_verify(ir_graph *irg, unsigned flags) last_irg_error = NULL; #endif /* NDEBUG */ - if (!check_cfg(irg)) + if (pinned && !check_cfg(irg)) res = 0; if (res == 1 && (flags & VERIFY_ENFORCE_SSA) && pinned) diff --git a/ir/opt/code_placement.c b/ir/opt/code_placement.c index 6ec90e427..2e3e5a60c 100644 --- a/ir/opt/code_placement.c +++ b/ir/opt/code_placement.c @@ -95,10 +95,6 @@ static void place_floats_early(ir_node *n, waitq *worklist) } block = get_nodes_block(n); - /* do not move unreachable code (or its predecessors around) since dominance - * is inalid there */ - if (!is_block_reachable(block)) - return; /* first move predecessors up */ arity = get_irn_arity(n); @@ -215,8 +211,8 @@ static ir_node *consumer_dom_dca(ir_node *dca, ir_node *consumer, if (is_Bad(new_block)) continue; - if (is_block_reachable(new_block)) - dca = calc_dom_dca(dca, new_block); + assert(is_block_reachable(new_block)); + dca = calc_dom_dca(dca, new_block); } } } else { @@ -285,10 +281,7 @@ static ir_node *get_deepest_common_dom_ancestor(ir_node *node, ir_node *dca) * the users of Proj are our users. */ dca = get_deepest_common_dom_ancestor(succ, dca); } else { - /* ignore successors in unreachable code */ - ir_node *succ_blk = get_nodes_block(succ); - if (!is_block_reachable(succ_blk)) - continue; + assert(is_block_reachable(get_nodes_block(succ))); dca = consumer_dom_dca(dca, succ, node); } } @@ -364,10 +357,8 @@ static void place_floats_late(ir_node *n, pdeq *worklist) return; } - /* don't move unreachable code around */ block = get_nodes_block(n); - if (!is_block_reachable(block)) - return; + assert(is_block_reachable(block)); /* deepest common ancestor in the dominator tree of all nodes' blocks depending on us; our final placement has to dominate @@ -422,6 +413,9 @@ void place_code(ir_graph *irg) worklist = new_waitq(); place_early(irg, worklist); + /* While GCSE might place nodes in unreachable blocks, + * these are now placed in reachable blocks. */ + /* Note: place_early changes only blocks, no data edges. So, the * data out edges are still valid, no need to recalculate them here. */ -- 2.20.1