-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
rustc: move debug info from LocalDecl and UpvarDecl into a dedicated VarDebugInfo. #56231
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
☔ The latest upstream changes (presumably #56198) made this pull request unmergeable. Please resolve the merge conflicts. |
ping from triage @eddyb @matthewjasper what's the update on this? is this blocked on anything? |
Blocked on #56278. Also, r? @nikomatsakis |
See #56642. |
Closing in favor of #56278 for now |
…tsakis Future-proof MIR for dedicated debuginfo. This is rust-lang#56231 without the last commit (the one that actually moves to `VarDebuginfo`). Nothing should be broken, but it should no longer depend on debuginfo for anything else. r? @nikomatsakis
…tsakis Future-proof MIR for dedicated debuginfo. This is rust-lang#56231 without the last commit (the one that actually moves to `VarDebuginfo`). Nothing should be broken, but it should no longer depend on debuginfo for anything else. r? @nikomatsakis
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
r? @oli-obk |
if let Place::Base(PlaceBase::Local(local)) = var_debug_info.place { | ||
if let Some(prev_name) = local_names[local] { | ||
if var_debug_info.name != prev_name { | ||
span_bug!(var_debug_info.source_info.span, |
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.
why doesn't this trigger on the reuse of locals? Or can that only happen after optimizations?
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, and borrowck runs before optimizations.
OTOH, this is a complete hack, cc @matthewjasper.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
53a32bb
to
6f45e12
Compare
@bors rollup=never |
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.
r=me with generator stuff pulled in a function
@bors r=oli-obk |
📌 Commit 563ed27 has been approved by |
rustc: move debug info from LocalDecl and UpvarDecl into a dedicated VarDebugInfo. This PR introduces a MIR "user variable" debuginfo system, which amounts to mapping a variable name, in some `SourceScope`, to a `Place`, so that: * each name can appear multiple times (e.g. due to macro hygiene), even in the same scope * each `Place` can appear multiple times (e.g. in the future from optimizations like NRVO, which collapse multiple MIR locals into one) * the `Place`s aren't limited to just locals, so they can describe the (right now quite ad-hoc) closure upvars and generator saved state fields, and can be properly transformed by optimizations (e.g. inlining - see `src/test/mir-opt/inline-closure-captures.rs`) The main motivation for this was that #48300 and further optimizations were blocked on being able to describe complex debuginfo transformations (see #48300 (comment)). <hr/> In the textual representation, the "user variable" debuginfo can be found in each scope, and consists of `debug NAME => PLACE;` "declarations", e.g. the MIR for `let x = ...; let y = ...; ...` is now: ```rust let _1: T; // in scope 0 at ... scope 1 { debug x => _1; // in scope 1 at ... let _2: T; // in scope 1 at ... scope 2 { debug y => _2; // in scope 2 at ... } } ``` For reference, this is how the information was represented before this PR: (notably, the scopes in which the variables are visible for debuginfo weren't even shown anywhere, making `scope 2` look pointless, and user variable names were part of MIR locals) ```rust let _1: T; // "x" in scope 0 at ... scope 1 { let _2: T; // "y" in scope 1 at ... scope 2 { } } ``` cc @nikomatsakis @michaelwoerister
Oh, one more thing I shouldn't forget about, especially once this PR lands: I should also search for |
☀️ Test successful - checks-azure |
Tested on commit rust-lang/rust@e87a205. Direct link to PR: <rust-lang/rust#56231> 💔 rls on linux: test-pass → test-fail (cc @Xanewok, @rust-lang/infra).
This PR introduces a MIR "user variable" debuginfo system, which amounts to mapping a variable name, in some
SourceScope
, to aPlace
, so that:Place
can appear multiple times (e.g. in the future from optimizations like NRVO, which collapse multiple MIR locals into one)Place
s aren't limited to just locals, so they can describe the (right now quite ad-hoc) closure upvars and generator saved state fields, and can be properly transformed by optimizations (e.g. inlining - seesrc/test/mir-opt/inline-closure-captures.rs
)The main motivation for this was that #48300 and further optimizations were blocked on being able to describe complex debuginfo transformations (see #48300 (comment)).
In the textual representation, the "user variable" debuginfo can be found in each scope, and consists of
debug NAME => PLACE;
"declarations", e.g. the MIR forlet x = ...; let y = ...; ...
is now:For reference, this is how the information was represented before this PR:
(notably, the scopes in which the variables are visible for debuginfo weren't even shown anywhere, making
scope 2
look pointless, and user variable names were part of MIR locals)cc @nikomatsakis @michaelwoerister