-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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_mir: track inlined callees in SourceScopeData. #68965
Conversation
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.
This comment has been minimized.
This comment has been minimized.
The However, you're right there is a problem, it's just not in inlining: #47809 (comment) |
0f373ea
to
5c3ec91
Compare
I want to see if the |
Awaiting bors try build completion |
rustc_mir: track inlined callees in SourceScopeData. This would be a prerequisite for generating the correct debuginfo in codegen, which would look similar to what LLVM inlining generates (we should be able to "fake it" as well). Also, `#[track_caller]` is now correct in the face of MIR inlining (cc @anp). However, the debuginfo side isn't implemented yet. I might take a stab at it soon, not sure. r? @rust-lang/wg-mir-opt
if let Some(source_info) = frame.current_source_info() { | ||
// Walk up the `SourceScope`s, in case some of them are from MIR inlining. | ||
let mut scope = source_info.scope; | ||
loop { |
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.
Would be great if we could deduplicate this logic.
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.
Probably a method on mir::Body
?
☀️ Try build successful - checks-azure |
Queued 5f38376 with parent a19edd6, future comparison URL. |
Finished benchmarking try commit 5f38376, comparison URL. |
What this tells me is that walking up the scope tree for every |
c43d529
to
c8c1f61
Compare
Added a second |
Awaiting bors try build completion |
⌛ Trying commit c8c1f61e4bdb0bea14c6df1ff69dd3a93f0fd149 with merge 43b730a168b06d9629d3e3a4a42a885eb565c2be... |
☀️ Try build successful - checks-azure |
Queued 43b730a168b06d9629d3e3a4a42a885eb565c2be with parent 6dff769, future comparison URL. |
Finished benchmarking try commit 43b730a168b06d9629d3e3a4a42a885eb565c2be, comparison URL. |
syn-opt clean build has a 9% regression in mir->llvm translation (~3% overall regression) The rest of the regressions don't seem to have a noticable change in the self-profiling data. |
This looks very similar to the last run except that there should be be no |
The regressions are smaller this time. |
Only for |
r? @nagisa for LLVM (I wish we had GH teams specifically for review roles so I don't have to guess) |
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.
There are a number of tests for MIR / at MIR level that have changed, which is fine; I'd love to see a test against LLVM-IR too.
From what I've seen in MIR tests, we might also want to have a way to run only a specific MIR optimisation at least for test purposes… sometime down the line.
See comments, but otherwise the changes LGTM (though I didn't pay super close attention to MIR ones, trusting Oli's review).
span: Span, | ||
) -> S { | ||
// FIXME(eddyb) this should never be `None`. | ||
let dbg_scope = self.dbg_scope.unwrap(); |
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.
expect
and/or unwrap_or_else(|| bug!(...))
?
|
||
let arg_ty = self.monomorphize(&decl.ty); | ||
|
||
let span = self.adjust_span_for_debugging(decl.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.
This pattern appears to be repeated multiple times throughout the codebase. It might make sense to just have a method that does these three steps in a single location? Not sure what'd it be named tho… adjusted_span_and_dbg_scope
maybe?
The way mir opts are being run is being reworked, and I think something like overwriting the optimization pipeline on a per-opt basis was also on the menu |
@bors r=nagisa,oli-obk |
📌 Commit 2b3f009 has been approved by |
☀️ Test successful - checks-actions |
This went unused in commit 88d874d, part of rust-lang#68965.
llvm: Remove the unused context from CreateDebugLocation This went unused in commit 88d874d, part of rust-lang#68965.
llvm: Remove the unused context from CreateDebugLocation This went unused in commit 88d874d, part of rust-lang#68965.
llvm: Remove the unused context from CreateDebugLocation This went unused in commit 88d874d, part of rust-lang#68965.
llvm: Remove the unused context from CreateDebugLocation This went unused in commit 88d874d, part of rust-lang#68965.
llvm: Remove the unused context from CreateDebugLocation This went unused in commit 88d874d, part of rust-lang#68965.
We now record which MIR scopes are the roots of other (inlined) functions's scope trees, which allows us to generate the correct debuginfo in codegen, similar to what LLVM inlining generates.
This PR makes the
ui
testbacktrace-debuginfo
pass, if the MIR inliner is turned on by default.Also,
#[track_caller]
is now correct in the face of MIR inlining (cc @anp).Fixes #76997.
r? @rust-lang/wg-mir-opt