Use PackedOption<Inst> in the dominator tree.

Also rework the algorithm to be more robust against unreachable blocks.

- Add an is_reachable(ebb) method.
- Change idom(ebb) to just return an instruction.
- Make idom() return None for the entry block as well as unreachable
  blocks.
This commit is contained in:
Jakob Stoklund Olesen
2017-01-19 18:44:33 -08:00
parent 0d77b19708
commit 02bf84431b
3 changed files with 184 additions and 97 deletions

View File

@@ -48,6 +48,11 @@ impl<T: ReservedValue> PackedOption<T> {
self.expand().unwrap()
}
/// Unwrap a packed `Some` value or panic.
pub fn expect(self, msg: &str) -> T {
self.expand().expect(msg)
}
/// Takes the value out of the packed option, leaving a `None` in its place.
pub fn take(&mut self) -> Option<T> {
mem::replace(self, None.into()).expand()