Skip to content

Commit dafcfed

Browse files
committed
GVN: Use VnIndex for the local base in Address
1 parent cf8346d commit dafcfed

File tree

1 file changed

+4
-5
lines changed
  • compiler/rustc_mir_transform/src

1 file changed

+4
-5
lines changed

compiler/rustc_mir_transform/src/gvn.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ enum AddressKind {
194194

195195
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
196196
enum AddressBase {
197-
/// This address is based on this local.
198-
Local(Local),
197+
/// This address is based on the local.
198+
Local(VnIndex),
199199
/// This address is based on the deref of this pointer.
200200
Deref(VnIndex),
201201
}
@@ -457,13 +457,13 @@ impl<'body, 'a, 'tcx> VnState<'body, 'a, 'tcx> {
457457
};
458458

459459
let mut projection = place.projection.iter();
460+
let base = self.locals[place.local]?;
460461
let base = if place.is_indirect_first_projection() {
461-
let base = self.locals[place.local]?;
462462
// Skip the initial `Deref`.
463463
projection.next();
464464
AddressBase::Deref(base)
465465
} else {
466-
AddressBase::Local(place.local)
466+
AddressBase::Local(base)
467467
};
468468
// Do not try evaluating inside `Index`, this has been done by `simplify_place_projection`.
469469
let projection =
@@ -788,7 +788,6 @@ impl<'body, 'a, 'tcx> VnState<'body, 'a, 'tcx> {
788788
let (mut place_ty, mut value) = match base {
789789
// The base is a local, so we take the local's value and project from it.
790790
AddressBase::Local(local) => {
791-
let local = self.locals[local]?;
792791
let place_ty = PlaceTy::from_ty(self.ty(local));
793792
(place_ty, local)
794793
}

0 commit comments

Comments
 (0)