Remove the ebb_dominates function.
This is now subsumed by the generic 'dominates' function.
This commit is contained in:
@@ -141,28 +141,6 @@ impl DominatorTree {
|
|||||||
if a == ebb_b { inst_b } else { None }
|
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.
|
/// Compute the common dominator of two basic blocks.
|
||||||
///
|
///
|
||||||
/// Both basic blocks are assumed to be reachable.
|
/// Both basic blocks are assumed to be reachable.
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ fn create_pre_header(header: Ebb,
|
|||||||
}
|
}
|
||||||
for &(_, last_inst) in cfg.get_predecessors(header) {
|
for &(_, last_inst) in cfg.get_predecessors(header) {
|
||||||
// We only follow normal edges (not the back edges)
|
// 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);
|
change_branch_jump_destination(last_inst, pre_header, func);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,7 +108,7 @@ fn has_pre_header(layout: &Layout,
|
|||||||
let mut found = false;
|
let mut found = false;
|
||||||
for &(pred_ebb, last_inst) in cfg.get_predecessors(header) {
|
for &(pred_ebb, last_inst) in cfg.get_predecessors(header) {
|
||||||
// We only count normal edges (not the back edges)
|
// 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 {
|
if found {
|
||||||
// We have already found one, there are more than one
|
// We have already found one, there are more than one
|
||||||
return None;
|
return None;
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ impl LoopAnalysis {
|
|||||||
for &ebb in domtree.cfg_postorder().iter().rev() {
|
for &ebb in domtree.cfg_postorder().iter().rev() {
|
||||||
for &(_, pred_inst) in cfg.get_predecessors(ebb) {
|
for &(_, pred_inst) in cfg.get_predecessors(ebb) {
|
||||||
// If the ebb dominates one of its predecessors it is a back edge
|
// 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
|
// This ebb is a loop header, so we create its associated loop
|
||||||
let lp = self.loops.push(LoopData::new(ebb, None));
|
let lp = self.loops.push(LoopData::new(ebb, None));
|
||||||
self.ebb_loop_map[ebb] = lp.into();
|
self.ebb_loop_map[ebb] = lp.into();
|
||||||
@@ -156,7 +156,7 @@ impl LoopAnalysis {
|
|||||||
for lp in self.loops().rev() {
|
for lp in self.loops().rev() {
|
||||||
for &(pred, pred_inst) in cfg.get_predecessors(self.loops[lp].header) {
|
for &(pred, pred_inst) in cfg.get_predecessors(self.loops[lp].header) {
|
||||||
// We follow the back edges
|
// 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);
|
stack.push(pred);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -381,7 +381,7 @@ impl<'a> Verifier<'a> {
|
|||||||
ebb);
|
ebb);
|
||||||
}
|
}
|
||||||
// The defining EBB dominates the instruction using this value.
|
// 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);
|
return err!(loc_inst, "uses value arg from non-dominating {}", ebb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user