@@ -49,17 +49,17 @@ impl<'tcx> crate::MirPass<'tcx> for CopyProp {
49
49
50
50
let any_replacement = ssa. copy_classes ( ) . iter_enumerated ( ) . any ( |( l, & h) | l != h) ;
51
51
52
- if any_replacement {
53
- let storage_to_remove = DenseBitSet :: new_empty ( fully_moved. domain_size ( ) ) ;
52
+ let storage_to_remove = DenseBitSet :: new_empty ( fully_moved. domain_size ( ) ) ;
54
53
55
- Replacer {
56
- tcx,
57
- copy_classes : ssa. copy_classes ( ) ,
58
- fully_moved,
59
- borrowed_locals : ssa. borrowed_locals ( ) ,
60
- }
61
- . visit_body_preserves_cfg ( body) ;
54
+ Replacer {
55
+ tcx,
56
+ copy_classes : ssa. copy_classes ( ) ,
57
+ fully_moved,
58
+ borrowed_locals : ssa. borrowed_locals ( ) ,
59
+ }
60
+ . visit_body_preserves_cfg ( body) ;
62
61
62
+ if any_replacement {
63
63
let move_data = MoveData :: gather_moves ( body, tcx, |_| true ) ;
64
64
65
65
let maybe_uninit = MaybeUninitializedPlaces :: new ( tcx, body, & move_data)
@@ -77,9 +77,7 @@ impl<'tcx> crate::MirPass<'tcx> for CopyProp {
77
77
storage_checker. storage_to_remove
78
78
} ;
79
79
StorageRemover { tcx, storage_to_remove } . visit_body_preserves_cfg ( body) ;
80
- }
81
80
82
- if any_replacement {
83
81
crate :: simplify:: remove_unused_definitions ( body) ;
84
82
}
85
83
}
@@ -187,7 +185,6 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> {
187
185
* rhs
188
186
&& lhs == rhs
189
187
{
190
- debug ! ( ?stmt, ?loc, ?lhs, ?rhs, "removing tautological assignment" ) ;
191
188
stmt. make_nop ( ) ;
192
189
}
193
190
}
@@ -201,9 +198,14 @@ struct StorageChecker<'a, 'tcx> {
201
198
202
199
impl < ' a , ' tcx > Visitor < ' tcx > for StorageChecker < ' a , ' tcx > {
203
200
fn visit_local ( & mut self , local : Local , context : PlaceContext , loc : Location ) {
204
- // We don't need to check storage statements and stores ( for which the local doesn't need to be initialized) .
201
+ // We don't need to check storage statements and statements for which the local doesn't need to be initialized.
205
202
match context {
206
- PlaceContext :: MutatingUse ( MutatingUseContext :: Store ) | PlaceContext :: NonUse ( _) => {
203
+ PlaceContext :: MutatingUse (
204
+ MutatingUseContext :: Store
205
+ | MutatingUseContext :: Call
206
+ | MutatingUseContext :: AsmOutput ,
207
+ )
208
+ | PlaceContext :: NonUse ( _) => {
207
209
return ;
208
210
}
209
211
_ => { }
@@ -234,7 +236,6 @@ impl<'a, 'tcx> Visitor<'tcx> for StorageChecker<'a, 'tcx> {
234
236
}
235
237
}
236
238
237
- /// Utility to help performing substitution of `*pattern` by `target`.
238
239
struct StorageRemover < ' tcx > {
239
240
tcx : TyCtxt < ' tcx > ,
240
241
storage_to_remove : DenseBitSet < Local > ,
0 commit comments