-
Notifications
You must be signed in to change notification settings - Fork 13.3k
We don't need NonNull::as_ptr
debuginfo
#133899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this one also be gone? Pin::new (after inlining the function call in its body and stripping debug info) is just the same as Pin::new_unchecked, but its debug info seems to stay around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pointer
is the parameter toPin::new
, so it's not removedrust/library/core/src/pin.rs
Line 1191 in cdeddae
(Rather than if it were a local in the function)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But isn't the same true for the
pointer
arg ofnew_unchecked
?Ah, if the currently-being-optimized function were in libcore, the arg of
new
would also be gone...Makes sense, but subtle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, definitely subtle. We could be less subtle by just removing all the debuginfo from trivial functions, but I thought it would be worth allowing at least that outer bit so that if you're unsure what you're calling into core with, that first step in having those arguments visible seemed potentially useful.
Basically I'm trying to make as small a change as I can while still avoiding the bad incentive of local variables in core making the compiler slower.