Skip to content

Commit ada7f1c

Browse files
committed
Do not clone dominator tree for SSA analysis.
1 parent fa8598c commit ada7f1c

File tree

1 file changed

+8
-11
lines changed
  • compiler/rustc_mir_transform/src

1 file changed

+8
-11
lines changed

compiler/rustc_mir_transform/src/ssa.rs

+8-11
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ pub struct SsaLocals {
3131
/// We often encounter MIR bodies with 1 or 2 basic blocks. In those cases, it's unnecessary to
3232
/// actually compute dominators, we can just compare block indices because bb0 is always the first
3333
/// block, and in any body all other blocks are always dominated by bb0.
34-
struct SmallDominators {
35-
inner: Option<Dominators<BasicBlock>>,
34+
struct SmallDominators<'a> {
35+
inner: Option<&'a Dominators<BasicBlock>>,
3636
}
3737

38-
impl SmallDominators {
38+
impl SmallDominators<'_> {
3939
fn dominates(&self, first: Location, second: Location) -> bool {
4040
if first.block == second.block {
4141
first.statement_index <= second.statement_index
@@ -68,11 +68,8 @@ impl SsaLocals {
6868
let assignment_order = Vec::with_capacity(body.local_decls.len());
6969

7070
let assignments = IndexVec::from_elem(Set1::Empty, &body.local_decls);
71-
let dominators = if body.basic_blocks.len() > 2 {
72-
Some(body.basic_blocks.dominators().clone())
73-
} else {
74-
None
75-
};
71+
let dominators =
72+
if body.basic_blocks.len() > 2 { Some(body.basic_blocks.dominators()) } else { None };
7673
let dominators = SmallDominators { inner: dominators };
7774

7875
let direct_uses = IndexVec::from_elem(0, &body.local_decls);
@@ -201,14 +198,14 @@ enum LocationExtended {
201198
Arg,
202199
}
203200

204-
struct SsaVisitor {
205-
dominators: SmallDominators,
201+
struct SsaVisitor<'a> {
202+
dominators: SmallDominators<'a>,
206203
assignments: IndexVec<Local, Set1<LocationExtended>>,
207204
assignment_order: Vec<Local>,
208205
direct_uses: IndexVec<Local, u32>,
209206
}
210207

211-
impl<'tcx> Visitor<'tcx> for SsaVisitor {
208+
impl<'tcx> Visitor<'tcx> for SsaVisitor<'_> {
212209
fn visit_local(&mut self, local: Local, ctxt: PlaceContext, loc: Location) {
213210
match ctxt {
214211
PlaceContext::MutatingUse(MutatingUseContext::Projection)

0 commit comments

Comments
 (0)