@@ -49,17 +49,17 @@ impl<'tcx> crate::MirPass<'tcx> for CopyProp {
4949
5050 let any_replacement = ssa. copy_classes ( ) . iter_enumerated ( ) . any ( |( l, & h) | l != h) ;
5151
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 ( ) ) ;
5453
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) ;
6261
62+ if any_replacement {
6363 let move_data = MoveData :: gather_moves ( body, tcx, |_| true ) ;
6464
6565 let maybe_uninit = MaybeUninitializedPlaces :: new ( tcx, body, & move_data)
@@ -77,9 +77,7 @@ impl<'tcx> crate::MirPass<'tcx> for CopyProp {
7777 storage_checker. storage_to_remove
7878 } ;
7979 StorageRemover { tcx, storage_to_remove } . visit_body_preserves_cfg ( body) ;
80- }
8180
82- if any_replacement {
8381 crate :: simplify:: remove_unused_definitions ( body) ;
8482 }
8583 }
@@ -187,7 +185,6 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> {
187185 * rhs
188186 && lhs == rhs
189187 {
190- debug ! ( ?stmt, ?loc, ?lhs, ?rhs, "removing tautological assignment" ) ;
191188 stmt. make_nop ( ) ;
192189 }
193190 }
@@ -201,9 +198,14 @@ struct StorageChecker<'a, 'tcx> {
201198
202199impl < ' a , ' tcx > Visitor < ' tcx > for StorageChecker < ' a , ' tcx > {
203200 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.
205202 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 ( _) => {
207209 return ;
208210 }
209211 _ => { }
@@ -234,7 +236,6 @@ impl<'a, 'tcx> Visitor<'tcx> for StorageChecker<'a, 'tcx> {
234236 }
235237}
236238
237- /// Utility to help performing substitution of `*pattern` by `target`.
238239struct StorageRemover < ' tcx > {
239240 tcx : TyCtxt < ' tcx > ,
240241 storage_to_remove : DenseBitSet < Local > ,
0 commit comments