1 //! This pass removes storage markers if they won't be emitted during codegen.
4 use rustc_middle::mir::*;
5 use rustc_middle::ty::TyCtxt;
7 pub struct RemoveStorageMarkers;
9 impl<'tcx> MirPass<'tcx> for RemoveStorageMarkers {
10 fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
11 sess.mir_opt_level() > 0
14 fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
15 if tcx.sess.emit_lifetime_markers() {
19 trace!("Running RemoveStorageMarkers on {:?}", body.source);
20 for data in body.basic_blocks.as_mut_preserves_cfg() {
21 data.statements.retain(|statement| match statement.kind {
22 StatementKind::StorageLive(..)
23 | StatementKind::StorageDead(..)
24 | StatementKind::Nop => false,