Do not clone dominator tree for SSA analysis.
This commit is contained in:
parent
fa8598cb50
commit
ada7f1c2c4
1 changed files with 8 additions and 11 deletions
|
@ -31,11 +31,11 @@ pub struct SsaLocals {
|
||||||
/// We often encounter MIR bodies with 1 or 2 basic blocks. In those cases, it's unnecessary to
|
/// We often encounter MIR bodies with 1 or 2 basic blocks. In those cases, it's unnecessary to
|
||||||
/// actually compute dominators, we can just compare block indices because bb0 is always the first
|
/// actually compute dominators, we can just compare block indices because bb0 is always the first
|
||||||
/// block, and in any body all other blocks are always dominated by bb0.
|
/// block, and in any body all other blocks are always dominated by bb0.
|
||||||
struct SmallDominators {
|
struct SmallDominators<'a> {
|
||||||
inner: Option<Dominators<BasicBlock>>,
|
inner: Option<&'a Dominators<BasicBlock>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SmallDominators {
|
impl SmallDominators<'_> {
|
||||||
fn dominates(&self, first: Location, second: Location) -> bool {
|
fn dominates(&self, first: Location, second: Location) -> bool {
|
||||||
if first.block == second.block {
|
if first.block == second.block {
|
||||||
first.statement_index <= second.statement_index
|
first.statement_index <= second.statement_index
|
||||||
|
@ -68,11 +68,8 @@ impl SsaLocals {
|
||||||
let assignment_order = Vec::with_capacity(body.local_decls.len());
|
let assignment_order = Vec::with_capacity(body.local_decls.len());
|
||||||
|
|
||||||
let assignments = IndexVec::from_elem(Set1::Empty, &body.local_decls);
|
let assignments = IndexVec::from_elem(Set1::Empty, &body.local_decls);
|
||||||
let dominators = if body.basic_blocks.len() > 2 {
|
let dominators =
|
||||||
Some(body.basic_blocks.dominators().clone())
|
if body.basic_blocks.len() > 2 { Some(body.basic_blocks.dominators()) } else { None };
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
let dominators = SmallDominators { inner: dominators };
|
let dominators = SmallDominators { inner: dominators };
|
||||||
|
|
||||||
let direct_uses = IndexVec::from_elem(0, &body.local_decls);
|
let direct_uses = IndexVec::from_elem(0, &body.local_decls);
|
||||||
|
@ -201,14 +198,14 @@ enum LocationExtended {
|
||||||
Arg,
|
Arg,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SsaVisitor {
|
struct SsaVisitor<'a> {
|
||||||
dominators: SmallDominators,
|
dominators: SmallDominators<'a>,
|
||||||
assignments: IndexVec<Local, Set1<LocationExtended>>,
|
assignments: IndexVec<Local, Set1<LocationExtended>>,
|
||||||
assignment_order: Vec<Local>,
|
assignment_order: Vec<Local>,
|
||||||
direct_uses: IndexVec<Local, u32>,
|
direct_uses: IndexVec<Local, u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Visitor<'tcx> for SsaVisitor {
|
impl<'tcx> Visitor<'tcx> for SsaVisitor<'_> {
|
||||||
fn visit_local(&mut self, local: Local, ctxt: PlaceContext, loc: Location) {
|
fn visit_local(&mut self, local: Local, ctxt: PlaceContext, loc: Location) {
|
||||||
match ctxt {
|
match ctxt {
|
||||||
PlaceContext::MutatingUse(MutatingUseContext::Projection)
|
PlaceContext::MutatingUse(MutatingUseContext::Projection)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue