add RPO to BB CFG cache
This commit is contained in:
parent
e596579066
commit
066d38190b
1 changed files with 12 additions and 0 deletions
|
@ -27,6 +27,7 @@ struct Cache {
|
||||||
switch_sources: OnceCell<SwitchSources>,
|
switch_sources: OnceCell<SwitchSources>,
|
||||||
is_cyclic: OnceCell<bool>,
|
is_cyclic: OnceCell<bool>,
|
||||||
postorder: OnceCell<Vec<BasicBlock>>,
|
postorder: OnceCell<Vec<BasicBlock>>,
|
||||||
|
reverse_postorder: OnceCell<Vec<BasicBlock>>,
|
||||||
dominators: OnceCell<Dominators<BasicBlock>>,
|
dominators: OnceCell<Dominators<BasicBlock>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +71,17 @@ impl<'tcx> BasicBlocks<'tcx> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns basic blocks in a reverse postorder.
|
||||||
|
#[inline]
|
||||||
|
pub fn reverse_postorder(&self) -> &[BasicBlock] {
|
||||||
|
self.cache.reverse_postorder.get_or_init(|| {
|
||||||
|
let mut rpo: Vec<_> =
|
||||||
|
Postorder::new(&self.basic_blocks, START_BLOCK).map(|(bb, _)| bb).collect();
|
||||||
|
rpo.reverse();
|
||||||
|
rpo
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/// `switch_sources()[&(target, switch)]` returns a list of switch
|
/// `switch_sources()[&(target, switch)]` returns a list of switch
|
||||||
/// values that lead to a `target` block from a `switch` block.
|
/// values that lead to a `target` block from a `switch` block.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue