Preprocess dominator tree to answer queries in O(1)
This commit is contained in:
parent
6c64870fa6
commit
aa1267f630
7 changed files with 137 additions and 55 deletions
|
@ -3,6 +3,7 @@ use crate::mir::{BasicBlock, BasicBlockData, Successors, Terminator, TerminatorK
|
|||
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::graph;
|
||||
use rustc_data_structures::graph::dominators::{dominator_tree, DominatorTree};
|
||||
use rustc_data_structures::graph::dominators::{dominators, Dominators};
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_data_structures::sync::OnceCell;
|
||||
|
@ -41,8 +42,12 @@ impl<'tcx> BasicBlocks<'tcx> {
|
|||
*self.cache.is_cyclic.get_or_init(|| graph::is_cyclic(self))
|
||||
}
|
||||
|
||||
pub fn dominator_tree(&self) -> DominatorTree<BasicBlock> {
|
||||
dominator_tree(&self)
|
||||
}
|
||||
|
||||
pub fn dominators(&self) -> Dominators<BasicBlock> {
|
||||
dominators(&self)
|
||||
dominators(&self.dominator_tree())
|
||||
}
|
||||
|
||||
/// Returns predecessors for each basic block.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue