Improve domtree as per @Amanieu's feedback.

This commit is contained in:
Chris Fallin
2021-08-12 12:13:56 -07:00
parent 3e1e0f39b6
commit 1f30958b5a
2 changed files with 6 additions and 9 deletions

View File

@@ -98,6 +98,10 @@ pub fn calculate<'a, PredFn: Fn(Block) -> &'a [Block]>(
}
}
// Now set the start node's dominator-tree parent to "invalid";
// this allows the loop in `dominates` to terminate.
idom[start.index()] = Block::invalid();
idom
}
@@ -109,10 +113,6 @@ pub fn dominates(idom: &[Block], a: Block, mut b: Block) -> bool {
if b.is_invalid() {
return false;
}
let parent = idom[b.index()];
if b == parent {
return false;
}
b = idom[b.index()];
}
}