diff --git a/lib/cretonne/src/dominator_tree.rs b/lib/cretonne/src/dominator_tree.rs index 8022ee1096..14f08e4263 100644 --- a/lib/cretonne/src/dominator_tree.rs +++ b/lib/cretonne/src/dominator_tree.rs @@ -141,28 +141,6 @@ impl DominatorTree { if a == ebb_b { inst_b } else { None } } - /// Returns `true` if `ebb_a` dominates `b`. - /// - /// This means that every control-flow path from the function entry to `b` must go through - /// `ebb_a`. - /// - /// Dominance is ill defined for unreachable blocks. This function can always determine - /// dominance for instructions in the same EBB, but otherwise returns `false` if either block - /// is unreachable. - pub fn ebb_dominates(&self, ebb_a: Ebb, mut b: Inst, layout: &Layout) -> bool { - let mut ebb_b = layout.inst_ebb(b).expect("Instruction not in layout."); - let rpo_a = self.nodes[ebb_a].rpo_number; - - // Run a finger up the dominator tree from b until we see a. - // Do nothing if b is unreachable. - while rpo_a < self.nodes[ebb_b].rpo_number { - b = self.idom(ebb_b).expect("Shouldn't meet unreachable here."); - ebb_b = layout.inst_ebb(b).expect("Dominator got removed."); - } - - ebb_a == ebb_b - } - /// Compute the common dominator of two basic blocks. /// /// Both basic blocks are assumed to be reachable. diff --git a/lib/cretonne/src/licm.rs b/lib/cretonne/src/licm.rs index 1c9e1930fd..0fc8212460 100644 --- a/lib/cretonne/src/licm.rs +++ b/lib/cretonne/src/licm.rs @@ -77,7 +77,7 @@ fn create_pre_header(header: Ebb, } for &(_, last_inst) in cfg.get_predecessors(header) { // We only follow normal edges (not the back edges) - if !domtree.ebb_dominates(header.clone(), last_inst, &func.layout) { + if !domtree.dominates(header, last_inst, &func.layout) { change_branch_jump_destination(last_inst, pre_header, func); } } @@ -108,7 +108,7 @@ fn has_pre_header(layout: &Layout, let mut found = false; for &(pred_ebb, last_inst) in cfg.get_predecessors(header) { // We only count normal edges (not the back edges) - if !domtree.ebb_dominates(header.clone(), last_inst, layout) { + if !domtree.dominates(header, last_inst, layout) { if found { // We have already found one, there are more than one return None; diff --git a/lib/cretonne/src/loop_analysis.rs b/lib/cretonne/src/loop_analysis.rs index f5ea45424e..5ed5f8a4d8 100644 --- a/lib/cretonne/src/loop_analysis.rs +++ b/lib/cretonne/src/loop_analysis.rs @@ -132,7 +132,7 @@ impl LoopAnalysis { for &ebb in domtree.cfg_postorder().iter().rev() { for &(_, pred_inst) in cfg.get_predecessors(ebb) { // If the ebb dominates one of its predecessors it is a back edge - if domtree.ebb_dominates(ebb, pred_inst, layout) { + if domtree.dominates(ebb, pred_inst, layout) { // This ebb is a loop header, so we create its associated loop let lp = self.loops.push(LoopData::new(ebb, None)); self.ebb_loop_map[ebb] = lp.into(); @@ -156,7 +156,7 @@ impl LoopAnalysis { for lp in self.loops().rev() { for &(pred, pred_inst) in cfg.get_predecessors(self.loops[lp].header) { // We follow the back edges - if domtree.ebb_dominates(self.loops[lp].header, pred_inst, layout) { + if domtree.dominates(self.loops[lp].header, pred_inst, layout) { stack.push(pred); } } diff --git a/lib/cretonne/src/verifier/mod.rs b/lib/cretonne/src/verifier/mod.rs index 5c283dd6d3..a2f806a447 100644 --- a/lib/cretonne/src/verifier/mod.rs +++ b/lib/cretonne/src/verifier/mod.rs @@ -381,7 +381,7 @@ impl<'a> Verifier<'a> { ebb); } // The defining EBB dominates the instruction using this value. - if !self.domtree.ebb_dominates(ebb, loc_inst, &self.func.layout) { + if !self.domtree.dominates(ebb, loc_inst, &self.func.layout) { return err!(loc_inst, "uses value arg from non-dominating {}", ebb); } }