1
Fork 0

Preserve unused pointer to address casts

This commit is contained in:
Tomasz Miąsko 2022-06-01 00:00:00 +00:00
parent 7fe2c4b00d
commit 6277c3a944
6 changed files with 65 additions and 11 deletions

View file

@ -34,7 +34,7 @@ pub fn eliminate<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>, borrowed: &BitS
for (statement_index, statement) in bb_data.statements.iter().enumerate().rev() {
let loc = Location { block: bb, statement_index };
if let StatementKind::Assign(assign) = &statement.kind {
if assign.1.is_pointer_int_cast() {
if !assign.1.is_safe_to_remove() {
continue;
}
}

View file

@ -494,8 +494,12 @@ impl<'tcx> Visitor<'tcx> for UsedLocals {
StatementKind::StorageLive(_local) | StatementKind::StorageDead(_local) => {}
StatementKind::Assign(box (ref place, ref rvalue)) => {
self.visit_lhs(place, location);
self.visit_rvalue(rvalue, location);
if rvalue.is_safe_to_remove() {
self.visit_lhs(place, location);
self.visit_rvalue(rvalue, location);
} else {
self.super_statement(statement, location);
}
}
StatementKind::SetDiscriminant { ref place, variant_index: _ }