Remove the ebb_dominates function.

This is now subsumed by the generic 'dominates' function.
This commit is contained in:
Jakob Stoklund Olesen
2017-06-12 14:59:34 -07:00
parent a1dfd0f06f
commit ea8a8a95a8
4 changed files with 5 additions and 27 deletions

View File

@@ -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.

View File

@@ -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;

View File

@@ -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);
}
}

View File

@@ -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);
}
}