Skip to content

Commit a67bf08

Browse files
committed
Only check storage liveness for direct projections.
1 parent 3b4e1fe commit a67bf08

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

compiler/rustc_mir_transform/src/ref_prop.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,18 +163,15 @@ fn compute_replacement<'tcx>(
163163
};
164164

165165
let mut can_perform_opt = |target: Place<'tcx>, loc: Location| {
166-
maybe_dead.seek_after_primary_effect(loc);
167-
let maybe_dead = maybe_dead.contains(target.local);
168-
169166
if target.projection.first() == Some(&PlaceElem::Deref) {
170167
// We are creating a reborrow. As `place.local` is a reference, removing the storage
171168
// statements should not make it much harder for LLVM to optimize.
172-
if maybe_dead {
173-
storage_to_remove.insert(target.local);
174-
}
169+
storage_to_remove.insert(target.local);
175170
true
176171
} else {
177172
// This is a proper dereference. We can only allow it if `target` is live.
173+
maybe_dead.seek_after_primary_effect(loc);
174+
let maybe_dead = maybe_dead.contains(target.local);
178175
!maybe_dead
179176
}
180177
};

0 commit comments

Comments
 (0)