Skip to content

Conversation

dianqk
Copy link
Member

@dianqk dianqk commented Jun 20, 2025

The PR introduces support for debug information within dead statements. Currently, only the reference statement is supported, which is sufficient to fix #128081.

I don't modify Stable MIR, as I don't think we need debug information when using it.

This PR represents the debug information for the dead reference statement via #dbg_value. For example, let _foo_b = &foo.b becomes #dbg_value(ptr %foo, !22, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value), !26). You can see this here: https://rust.godbolt.org/z/d43js6adv.

The general principle for handling debug information is to never provide less debug information than the optimized LLVM IR.

The current rules for dropping debug information in this PR are:

I doesn't drop debuginfos in MatchBranchSimplification, because LLVM also pick one branch for it.

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 20, 2025
@rust-log-analyzer

This comment has been minimized.

@dianqk dianqk force-pushed the mir-stmt-debuginfo branch from 15c968a to 6b013d4 Compare June 20, 2025 08:01
@rust-log-analyzer

This comment has been minimized.

@dianqk dianqk force-pushed the mir-stmt-debuginfo branch from 6b013d4 to 51576e7 Compare June 20, 2025 09:23
@rust-log-analyzer

This comment has been minimized.

@dianqk
Copy link
Member Author

dianqk commented Jun 20, 2025

@bors2 try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Jun 20, 2025

⌛ Trying commit 51576e7 with merge eb83156

To cancel the try build, run the command @bors2 try cancel.

rust-bors bot added a commit that referenced this pull request Jun 20, 2025
Introduce debuginfo to statements in MIR

Not ready for reviewing. Something known:

- [ ] Retain debuginfo when concatenating bbs
- [ ] Document about when to drop debuginfos (don't be worse than the optimized LLVM IR)
- [ ] Missing tests

r? ghost
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 20, 2025
@rust-bors
Copy link

rust-bors bot commented Jun 20, 2025

☀️ Try build successful (CI)
Build commit: eb83156 (eb83156169ae3bbdd1385d498455dbc44283f5ff, parent: 18491d5be00eb3ed2f1ccee2ac5b792694f2a7a0)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (eb83156): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.9% [0.2%, 14.5%] 51
Regressions ❌
(secondary)
0.8% [0.1%, 1.6%] 52
Improvements ✅
(primary)
-0.4% [-2.1%, -0.2%] 35
Improvements ✅
(secondary)
-0.3% [-0.5%, -0.2%] 39
All ❌✅ (primary) 0.4% [-2.1%, 14.5%] 86

Max RSS (memory usage)

Results (primary 2.3%, secondary 3.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.3% [0.8%, 4.7%] 54
Regressions ❌
(secondary)
3.6% [0.7%, 7.4%] 38
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.3% [-3.3%, -3.3%] 1
All ❌✅ (primary) 2.3% [0.8%, 4.7%] 54

Cycles

Results (primary 3.2%, secondary 2.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
3.9% [1.1%, 14.4%] 7
Regressions ❌
(secondary)
2.5% [2.0%, 3.3%] 3
Improvements ✅
(primary)
-2.0% [-2.0%, -2.0%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 3.2% [-2.0%, 14.4%] 8

Binary size

Results (primary 0.5%, secondary 0.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.7% [0.0%, 2.2%] 123
Regressions ❌
(secondary)
1.1% [0.0%, 3.5%] 59
Improvements ✅
(primary)
-0.9% [-6.5%, -0.1%] 11
Improvements ✅
(secondary)
-0.5% [-13.0%, -0.1%] 55
All ❌✅ (primary) 0.5% [-6.5%, 2.2%] 134

Bootstrap: 691.482s -> 692.445s (0.14%)
Artifact size: 371.94 MiB -> 372.12 MiB (0.05%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jun 20, 2025
@dianqk dianqk force-pushed the mir-stmt-debuginfo branch from 51576e7 to e72c3ae Compare June 21, 2025 02:31
@dianqk
Copy link
Member Author

dianqk commented Jun 21, 2025

@bors2 try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Jun 21, 2025

⌛ Trying commit e72c3ae with merge 77d5c6a

To cancel the try build, run the command @bors2 try cancel.

rust-bors bot added a commit that referenced this pull request Jun 21, 2025
Introduce debuginfo to statements in MIR

Not ready for reviewing. Something known:

- [ ] Retain debuginfo when concatenating bbs
- [ ] Document about when to drop debuginfos (don't be worse than the optimized LLVM IR)
- [ ] Missing tests

r? ghost
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 21, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Jun 21, 2025

☀️ Try build successful (CI)
Build commit: 77d5c6a (77d5c6a20a77fabdee3790a412618b82178e9ab4, parent: 15c701fbc995eb6c5b3a86021c18185f8eee020d)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (77d5c6a): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.9% [0.1%, 14.5%] 53
Regressions ❌
(secondary)
0.8% [0.1%, 1.6%] 50
Improvements ✅
(primary)
-0.4% [-3.0%, -0.2%] 46
Improvements ✅
(secondary)
-0.3% [-0.5%, -0.2%] 41
All ❌✅ (primary) 0.3% [-3.0%, 14.5%] 99

Max RSS (memory usage)

Results (primary 2.4%, secondary 3.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.4% [0.5%, 5.7%] 38
Regressions ❌
(secondary)
4.2% [1.3%, 6.2%] 25
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.7% [-3.0%, -1.1%] 4
All ❌✅ (primary) 2.4% [0.5%, 5.7%] 38

Cycles

Results (primary 2.1%, secondary 0.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
3.0% [0.8%, 14.1%] 10
Regressions ❌
(secondary)
3.3% [2.3%, 4.3%] 2
Improvements ✅
(primary)
-2.3% [-2.9%, -1.7%] 2
Improvements ✅
(secondary)
-2.2% [-2.6%, -1.9%] 2
All ❌✅ (primary) 2.1% [-2.9%, 14.1%] 12

Binary size

Results (primary 0.5%, secondary 0.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.7% [0.0%, 3.0%] 122
Regressions ❌
(secondary)
1.1% [0.0%, 3.5%] 59
Improvements ✅
(primary)
-0.7% [-4.9%, -0.0%] 15
Improvements ✅
(secondary)
-0.5% [-12.7%, -0.0%] 55
All ❌✅ (primary) 0.5% [-4.9%, 3.0%] 137

Bootstrap: 690.617s -> 691.47s (0.12%)
Artifact size: 371.83 MiB -> 372.01 MiB (0.05%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 21, 2025
@bors
Copy link
Collaborator

bors commented Jun 25, 2025

☔ The latest upstream changes (presumably #142870) made this pull request unmergeable. Please resolve the merge conflicts.

@rust-bors
Copy link

rust-bors bot commented Oct 3, 2025

☀️ Try build successful (CI)
Build commit: 7485df3 (7485df387f376e7d3124e920cbb0c28648e50b43, parent: 8d603ef2879fd263f8e9aea340b4c035ed7973db)

@dianqk
Copy link
Member Author

dianqk commented Oct 3, 2025

@bors r=cjgillot

@bors
Copy link
Collaborator

bors commented Oct 3, 2025

📌 Commit c2a03ce has been approved by cjgillot

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 3, 2025
bors added a commit that referenced this pull request Oct 3, 2025
Introduce debuginfo to statements in MIR

The PR introduces support for debug information within dead statements. Currently, only the reference statement is supported, which is sufficient to fix #128081.

I don't modify Stable MIR, as I don't think we need debug information when using it.

This PR represents the debug information for the dead reference statement via `#dbg_value`. For example, `let _foo_b = &foo.b` becomes `#dbg_value(ptr %foo, !22, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value), !26)`. You can see this here: https://rust.godbolt.org/z/d43js6adv.

The general principle for handling debug information is to never provide less debug information than the optimized LLVM IR.

The current rules for dropping debug information in this PR are:

- If the LLVM IR cannot represent a reference address, it's replaced with poison or simply dropped. For example, see: https://rust.godbolt.org/z/shGqPec8W. I'm using poison in all such cases now.
- All debuginfos is dropped when merging multiple successor BBs. An example is available here: https://rust.godbolt.org/z/TE1q3Wq6M.

I doesn't drop debuginfos in `MatchBranchSimplification`, because LLVM also pick one branch for it.
@bors
Copy link
Collaborator

bors commented Oct 3, 2025

⌛ Testing commit c2a03ce with merge 463a7f6...

@rust-log-analyzer
Copy link
Collaborator

The job dist-ohos-aarch64 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@bors
Copy link
Collaborator

bors commented Oct 3, 2025

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 3, 2025
@dianqk
Copy link
Member Author

dianqk commented Oct 3, 2025

@bors retry (spurious network error)

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 3, 2025
@bors
Copy link
Collaborator

bors commented Oct 3, 2025

⌛ Testing commit c2a03ce with merge 8b6b15b...

@bors
Copy link
Collaborator

bors commented Oct 3, 2025

☀️ Test successful - checks-actions
Approved by: cjgillot
Pushing 8b6b15b to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Oct 3, 2025
@bors bors merged commit 8b6b15b into rust-lang:master Oct 3, 2025
12 checks passed
@rustbot rustbot added this to the 1.92.0 milestone Oct 3, 2025
Copy link
Contributor

github-actions bot commented Oct 3, 2025

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing dd09100 (parent) -> 8b6b15b (this PR)

Test differences

Show 36 test diffs

Stage 1

  • [codegen] tests/codegen-llvm/debuginfo-dse.rs#CODEGEN: [missing] -> pass (J1)
  • [codegen] tests/codegen-llvm/debuginfo-dse.rs#OPTIMIZED: [missing] -> pass (J1)
  • [debuginfo-gdb] tests/debuginfo/opt/dead_refs.rs: [missing] -> pass (J1)
  • [mir-opt] tests/mir-opt/dead-store-elimination/ref.rs: [missing] -> pass (J1)
  • [mir-opt] tests/mir-opt/debuginfo/simplifycfg.rs: [missing] -> pass (J1)
  • [mir-opt] tests/mir-opt/pre-codegen/dead_on_invalid_place.rs: [missing] -> pass (J1)
  • [mir-opt] tests/mir-opt/pre-codegen/loops.rs: pass -> ignore (ignored when std is built with debug assertions ((debug assertions result in different inlines))) (J1)

Stage 2

  • [codegen] tests/codegen-llvm/debuginfo-dse.rs#CODEGEN: [missing] -> ignore (only executed when the pointer width is 64bit) (J0)
  • [codegen] tests/codegen-llvm/debuginfo-dse.rs#OPTIMIZED: [missing] -> ignore (only executed when the pointer width is 64bit) (J0)
  • [codegen] tests/codegen-llvm/debuginfo-dse.rs#CODEGEN: [missing] -> pass (J2)
  • [codegen] tests/codegen-llvm/debuginfo-dse.rs#OPTIMIZED: [missing] -> pass (J2)
  • [debuginfo-gdb] tests/debuginfo/opt/dead_refs.rs: [missing] -> pass (J3)
  • [mir-opt] tests/mir-opt/dead-store-elimination/ref.rs: [missing] -> pass (J4)
  • [mir-opt] tests/mir-opt/debuginfo/simplifycfg.rs: [missing] -> pass (J4)
  • [mir-opt] tests/mir-opt/pre-codegen/dead_on_invalid_place.rs: [missing] -> pass (J4)
  • [mir-opt] tests/mir-opt/pre-codegen/loops.rs: pass -> ignore (ignored when std is built with debug assertions ((debug assertions result in different inlines))) (J5)
  • [debuginfo-cdb] tests/debuginfo/opt/dead_refs.rs: [missing] -> pass (J6)
  • [debuginfo-lldb] tests/debuginfo/opt/dead_refs.rs: [missing] -> ignore (ignored when the LLDB version is 1800) (J7)
  • [debuginfo-gdb (split-dwarf)] tests/debuginfo/opt/dead_refs.rs: [missing] -> ignore (ignored when the GDB version is lower than 13.0) (J8)
  • [debuginfo-gdb] tests/debuginfo/opt/dead_refs.rs: [missing] -> ignore (ignored when the GDB version is lower than 13.0) (J9)

Additionally, 16 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 8b6b15b877fbceb1ee5d9a5a4746e7515901574a --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-android: 1110.3s -> 1596.7s (43.8%)
  2. dist-aarch64-linux: 6240.9s -> 8927.0s (43.0%)
  3. dist-aarch64-apple: 6316.4s -> 7530.9s (19.2%)
  4. dist-x86_64-apple: 6740.6s -> 7979.0s (18.4%)
  5. dist-aarch64-msvc: 6194.2s -> 5593.3s (-9.7%)
  6. aarch64-apple: 7543.2s -> 8221.3s (9.0%)
  7. aarch64-gnu-llvm-20-1: 3725.7s -> 3404.2s (-8.6%)
  8. aarch64-msvc-2: 4942.4s -> 5298.1s (7.2%)
  9. dist-x86_64-windows-gnullvm: 5382.5s -> 5006.7s (-7.0%)
  10. x86_64-msvc-1: 8497.2s -> 9070.4s (6.7%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (8b6b15b): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.5% [0.1%, 2.0%] 9
Regressions ❌
(secondary)
0.5% [0.1%, 0.9%] 43
Improvements ✅
(primary)
-0.3% [-1.2%, -0.1%] 101
Improvements ✅
(secondary)
-0.3% [-1.0%, -0.1%] 102
All ❌✅ (primary) -0.3% [-1.2%, 2.0%] 110

Max RSS (memory usage)

Results (primary 2.1%, secondary 3.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.1% [0.5%, 6.7%] 85
Regressions ❌
(secondary)
3.6% [0.9%, 7.4%] 57
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.5% [-3.4%, -1.5%] 3
All ❌✅ (primary) 2.1% [0.5%, 6.7%] 85

Cycles

Results (primary 1.9%, secondary 1.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
1.9% [1.5%, 2.1%] 4
Regressions ❌
(secondary)
3.1% [1.2%, 6.7%] 14
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.6% [-6.1%, -2.2%] 6
All ❌✅ (primary) 1.9% [1.5%, 2.1%] 4

Binary size

Results (primary 0.5%, secondary 0.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.7% [0.0%, 2.2%] 122
Regressions ❌
(secondary)
1.1% [0.1%, 3.5%] 59
Improvements ✅
(primary)
-0.7% [-6.4%, -0.2%] 13
Improvements ✅
(secondary)
-0.6% [-13.0%, -0.1%] 58
All ❌✅ (primary) 0.5% [-6.4%, 2.2%] 135

Bootstrap: 470.825s -> 471.778s (0.20%)
Artifact size: 387.79 MiB -> 388.26 MiB (0.12%)

@dianqk
Copy link
Member Author

dianqk commented Oct 4, 2025

Pre-merged perf results: #142771 (comment).

diesel-2.2.10-opt-full's regression is mainly due to more MIR inlining.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bad codegen for non-copy-derived struct with all Copy derived fields
9 participants