forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#133899 - scottmcm:strip-mir-debuginfo, r=oli-obk
We don't need `NonNull::as_ptr` debuginfo In order to stop pessimizing the use of local variables in core, skip debug info for MIR temporaries in tiny (single-BB) functions. For functions as simple as this -- `Pin::new`, etc -- nobody every actually wants debuginfo for them in the first place. They're more like intrinsics than real functions, and stepping over them is good.
- Loading branch information
Showing
11 changed files
with
170 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use rustc_middle::mir::*; | ||
use rustc_middle::ty::TyCtxt; | ||
use rustc_session::config::MirStripDebugInfo; | ||
|
||
/// Conditionally remove some of the VarDebugInfo in MIR. | ||
/// | ||
/// In particular, stripping non-parameter debug info for tiny, primitive-like | ||
/// methods in core saves work later, and nobody ever wanted to use it anyway. | ||
pub(super) struct StripDebugInfo; | ||
|
||
impl<'tcx> crate::MirPass<'tcx> for StripDebugInfo { | ||
fn is_enabled(&self, sess: &rustc_session::Session) -> bool { | ||
sess.opts.unstable_opts.mir_strip_debuginfo != MirStripDebugInfo::None | ||
} | ||
|
||
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { | ||
match tcx.sess.opts.unstable_opts.mir_strip_debuginfo { | ||
MirStripDebugInfo::None => return, | ||
MirStripDebugInfo::AllLocals => {} | ||
MirStripDebugInfo::LocalsInTinyFunctions | ||
if let TerminatorKind::Return { .. } = | ||
body.basic_blocks[START_BLOCK].terminator().kind => {} | ||
MirStripDebugInfo::LocalsInTinyFunctions => return, | ||
} | ||
|
||
body.var_debug_info.retain(|vdi| { | ||
matches!( | ||
vdi.value, | ||
VarDebugInfoContents::Place(place) | ||
if place.local.as_usize() <= body.arg_count && place.local != RETURN_PLACE, | ||
) | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.