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
Use the same DISubprogram for each instance of the same inlined function within a caller #115417
Conversation
r? @TaKO8Ki (rustbot has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…pe to child subsequent scopes and variables from colliding
Some changes occurred in compiler/rustc_codegen_gcc cc @antoyo |
r? @wesleywiser |
Thanks @dpaoliello! @bors r+ rollup=never (Setting rollup=never in case we need to bisect) |
☀️ Test successful - checks-actions |
Finished benchmarking commit (62ebe3a): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Bootstrap: 630.375s -> 628.62s (-0.28%) |
@rustbot label: +perf-regression-triaged These regressions are expected: we are either producing the same or more debug information, as well as adding a map lookup. Once #115455 is fixed we should be able to get a perf boost, but in the meantime this is the only way that we can get accurate debugging info for trailing inlined functions. |
Issue Details:
The call to
panic
within a function likeOption::unwrap
is translated to LLVM as atail call
(as it will never return), when multiple calls to the same function like this are inlined LLVM will notice the commontail call
block (i.e., loading the same panic string + location info and then callingpanic
) and merge them together.When merging these instructions together, LLVM will also attempt to merge the debug locations as well, but this fails (i.e., debug info is dropped) as Rust emits a new
DISubprogram
at each inline site thus LLVM doesn't recognize that these are actually the same function and so thinks that there isn't a common debug location.As an example of this, consider the following program:
When building for x86_64 Windows using 1.72 it generates (note the lack of
.cv_loc
before the call topanic
, thus it will be attributed to the same line at theaddq
instruction):Fix Details:
Cache the
DISubprogram
emitted for each inlined function instance within a caller so that this can be reused if that instance is encountered again.Ideally, we would also deduplicate child scopes and variables, however my attempt to do that with #114643 resulted in asserts when building for Linux (#115156) which would require some deep changes to Rust to fix (#115455).
Instead, when using an inlined function as a debug scope, we will also create a new child scope such that subsequent child scopes and variables do not collide (from LLVM's perspective).
After this change the above assembly now (with https://reviews.llvm.org/D159226 as well) shows the
panic!
was inlined fromunwrap
inoption.rs
at line 935 into the current function inlib.rs
at line 0 (line 0 is emitted since it is ambiguous which line to use as there were two inline sites that lead to this same code):