-
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
Fix line numbers for MIR inlined code #103071
Conversation
`should_collapse_debuginfo` detects if the specified span is part of a macro expansion however it does this by checking if the span is anything other than a normal (non-expanded) kind, then the span sequence is walked backwards to the root span. This doesn't work when the MIR inliner inlines code as it creates spans with expansion information set to `ExprKind::Inlined` and results in the line number being attributed to the inline callsite rather than the normal line number of the inlined code.
r? @jackh726 (rust-highfive has picked a reviewer for you, use r? to override) |
Comparison of panics from the test case before & after this change: Before> .\mir-inlined-line-numbers.exe
thread 'main' panicked at 'explicit panic', .\src\test\codegen\mir-inlined-line-numbers.rs:8:5
stack backtrace:
0: std::panicking::begin_panic<str>
at /rustc/6b3ede3f7bc502eba7bbd202b4b9312d812adcd7\library\std\src\panicking.rs:607
1: mir_inlined_line_numbers::bar
at .\src\test\codegen\mir-inlined-line-numbers.rs:8
2: mir_inlined_line_numbers::foo
at .\src\test\codegen\mir-inlined-line-numbers.rs:12
3: mir_inlined_line_numbers::main
at .\src\test\codegen\mir-inlined-line-numbers.rs:12
4: core::ops::function::FnOnce::call_once
at /rustc/6b3ede3f7bc502eba7bbd202b4b9312d812adcd7\library\core\src\ops\function.rs:251
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. After> .\mir-inlined-line-numbers.exe
thread 'main' panicked at 'explicit panic', .\src\test\codegen\mir-inlined-line-numbers.rs:8:5
stack backtrace:
0: std::panicking::begin_panic<str>
at .\library\std\src\panicking.rs:607
1: mir_inlined_line_numbers::bar
at .\src\test\codegen\mir-inlined-line-numbers.rs:8
2: mir_inlined_line_numbers::foo
at .\src\test\codegen\mir-inlined-line-numbers.rs:3
3: mir_inlined_line_numbers::main
at .\src\test\codegen\mir-inlined-line-numbers.rs:12
4: core::ops::function::FnOnce::call_once
at .\library\core\src\ops\function.rs:251
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. |
r? @davidtwco As I think you might be familiar with this code 🙂 |
@bors r+ |
discussed with Wesley. Unilaterally backport approving to go into 1.65 beta branch (which will be stable next week). |
@bors p=1 We're backporting this to ride the train alongside the MIR inliner being enabled by default. |
⌛ Testing commit 34d90a4 with merge 9db8c2939a620326d47daadbc8d36abd1cdebb1a... |
💔 Test failed - checks-actions |
Seems spurious? @bors retry |
☀️ Test successful - checks-actions |
Finished benchmarking commit (77e7b74): 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.
|
…mulacrum [beta] backport rollup * poll_fn and Unpin: fix pinning rust-lang#102737 * Support raw-dylib functions being used inside inlined functions rust-lang#102988 * Fix line numbers for MIR inlined code rust-lang#103071 * Add architectures to fn create_object_file rust-lang#103240 * Add eval hack in super_relate_consts back rust-lang#103279 * Mark std::os::wasi::io::AsFd etc. as stable. rust-lang#103308 * Truncate thread names on Linux and Apple targets rust-lang#103379 * Do not consider repeated lifetime params for elision. rust-lang#103450 * rustdoc: add missing URL redirect rust-lang#103588 * Remove commit_if_ok probe from NLL type relation rust-lang#103601 Also includes a copy of the release notes. r? `@ghost`
These perf regressions look real. |
I'll spend some time investigating this week. |
The regressions are real but expected. Both regex and webrender enable debuginfo generation in release mode. Prior to this change, any inlined code was being incorrectly placed at the line number of the calling function which caused a reduction in the amount of debuginfo generated by LLVM (and given to LLVM by rustc). Fixing that bug causes the debuginfo to be generated with the appropriate line numbers and results in more debuginfo. cachegrind results back this up and show the biggest increases in debuginfo related LLVM functions. Both of these benchmarks improved considerably when MIR inlining was enabled and even with the regression caused by this fix, we're still showing net wins on these benchmarks. I couldn't find any other actionable items that might improve these results at this time. |
…, r=davidtwco Fix line numbers for MIR inlined code `should_collapse_debuginfo` detects if the specified span is part of a macro expansion however it does this by checking if the span is anything other than a normal (non-expanded) kind, then the span sequence is walked backwards to the root span. This doesn't work when the MIR inliner inlines code as it creates spans with expansion information set to `ExprKind::Inlined` and results in the line number being attributed to the inline callsite rather than the normal line number of the inlined code. Fixes rust-lang#103068
should_collapse_debuginfo
detects if the specified span is part of amacro expansion however it does this by checking if the span is anything
other than a normal (non-expanded) kind, then the span sequence is
walked backwards to the root span.
This doesn't work when the MIR inliner inlines code as it creates spans
with expansion information set to
ExprKind::Inlined
and results in theline number being attributed to the inline callsite rather than the
normal line number of the inlined code.
Fixes #103068