Rollup merge of #97597 - tmiasko:simplify-locals-side-effects, r=RalfJung,JakobDegen
Preserve unused pointer to address casts Fixes #97421. cc `@RalfJung`
This commit is contained in:
commit
d380b457d8
6 changed files with 65 additions and 11 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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: _ }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue