@@ -59,22 +59,26 @@ impl<'tcx> crate::MirPass<'tcx> for CopyProp {
5959 }
6060 . visit_body_preserves_cfg ( body) ;
6161
62- if any_replacement {
63- let move_data = MoveData :: gather_moves ( body, tcx, |_| true ) ;
62+ debug ! ( ?head_storage_to_check) ;
6463
65- let maybe_uninit = MaybeUninitializedPlaces :: new ( tcx, body, & move_data)
66- . iterate_to_fixpoint ( tcx, body, Some ( "mir_opt::copy_prop" ) )
67- . into_results_cursor ( body) ;
64+ if any_replacement {
65+ // Debug builds have no use for the storage statements, so avoid extra work.
66+ let storage_to_remove = if tcx. sess . emit_lifetime_markers ( ) {
67+ let move_data = MoveData :: gather_moves ( body, tcx, |_| true ) ;
6868
69- debug ! ( ?head_storage_to_check) ;
69+ let maybe_uninit = MaybeUninitializedPlaces :: new ( tcx, body, & move_data)
70+ . iterate_to_fixpoint ( tcx, body, Some ( "mir_opt::copy_prop" ) )
71+ . into_results_cursor ( body) ;
7072
71- let storage_to_remove = {
7273 let mut storage_checker =
7374 StorageChecker { maybe_uninit, head_storage_to_check, storage_to_remove } ;
7475
7576 storage_checker. visit_body ( body) ;
7677
7778 storage_checker. storage_to_remove
79+ } else {
80+ // Conservatively remove all storage statements for the head locals.
81+ head_storage_to_check
7882 } ;
7983 StorageRemover { tcx, storage_to_remove } . visit_body_preserves_cfg ( body) ;
8084
0 commit comments