Skip to content

Commit b57d309

Browse files
committed
Also address in debuginfo.
1 parent 29306a5 commit b57d309

File tree

1 file changed

+39
-16
lines changed
  • compiler/rustc_mir_transform/src

1 file changed

+39
-16
lines changed

Diff for: compiler/rustc_mir_transform/src/gvn.rs

+39-16
Original file line numberDiff line numberDiff line change
@@ -1327,25 +1327,48 @@ impl<'tcx> VnState<'_, 'tcx> {
13271327
return None;
13281328
}
13291329

1330-
let Value::Projection(base, elem) = *self.get(value) else {
1331-
break;
1332-
};
1333-
1334-
let elem = match elem {
1335-
ProjectionElem::Deref => ProjectionElem::Deref,
1336-
ProjectionElem::Downcast(name, read_variant) => {
1337-
ProjectionElem::Downcast(name, read_variant)
1330+
match *self.get(value) {
1331+
Value::Projection(base, elem) => {
1332+
let elem = match elem {
1333+
ProjectionElem::Deref => ProjectionElem::Deref,
1334+
ProjectionElem::Downcast(name, read_variant) => {
1335+
ProjectionElem::Downcast(name, read_variant)
1336+
}
1337+
ProjectionElem::Field(f, ty) => ProjectionElem::Field(f, ty),
1338+
ProjectionElem::ConstantIndex {
1339+
offset,
1340+
min_length,
1341+
from_end: false,
1342+
} => ProjectionElem::ConstantIndex {
1343+
offset,
1344+
min_length,
1345+
from_end: false,
1346+
},
1347+
// Not allowed in debuginfo.
1348+
_ => return None,
1349+
};
1350+
projections.push(elem);
1351+
value = base;
13381352
}
1339-
ProjectionElem::Field(f, ty) => ProjectionElem::Field(f, ty),
1340-
ProjectionElem::ConstantIndex { offset, min_length, from_end: false } => {
1341-
ProjectionElem::ConstantIndex { offset, min_length, from_end: false }
1353+
Value::Address { place: target, kind: _, provenance: _ }
1354+
if projections.is_empty()
1355+
&& target.projection.iter().all(|e| e.can_use_in_debuginfo()) =>
1356+
{
1357+
var_debug_info
1358+
.composite
1359+
.get_or_insert_with(|| {
1360+
Box::new(VarDebugInfoFragment {
1361+
ty: self.local_decls[place.local].ty,
1362+
projection: Vec::new(),
1363+
})
1364+
})
1365+
.projection
1366+
.push(PlaceElem::Deref);
1367+
*place = target;
1368+
break;
13421369
}
1343-
// Not allowed in debuginfo.
13441370
_ => return None,
1345-
};
1346-
1347-
projections.push(elem);
1348-
value = base;
1371+
}
13491372
}
13501373

13511374
return None;

0 commit comments

Comments
 (0)