Skip to content

Conversation

luqmana
Copy link
Contributor

@luqmana luqmana commented Apr 10, 2022

As part of the switch to the new LLVM Pass Manager the behaviour of flags such as -Z verify-llvm-ir (e.g. sanitizer, instrumentation) was modified when combined with -C no-prepopulate-passes. With the old PM, rustc was the one manually constructing the pipeline and respected those flags but in the new pass manager, those flags are used to build a list of callbacks that get invoked at certain extension points in the pipeline. Unfortunately, -C no-prepopulate-passes would skip building the pipeline altogether meaning we'd never add the corresponding passes. The fix here is to just manually invoke those callbacks as needed.

Fixes #95874

Demonstrating the current vs fixed behaviour using the bug in #95864

$ rustc +nightly asm-miscompile.rs --edition 2021 --emit=llvm-ir -C no-prepopulate-passes -Z verify-llvm-ir                         
$ echo $?
0
$ rustc +stage1 asm-miscompile.rs --edition 2021 --emit=llvm-ir -C no-prepopulate-passes -Z verify-llvm-ir
Basic Block in function '_ZN14asm_miscompile3foo28_$u7b$$u7b$closure$u7d$$u7d$17h360e2f7eee1275c5E' does not have terminator!
label %bb1
LLVM ERROR: Broken module found, compilation aborted!

…combined with -C no-prepopulate-passes in the new LLVM Pass Manager.
@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 10, 2022
@rust-highfive
Copy link
Contributor

r? @petrochenkov

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 10, 2022
@petrochenkov
Copy link
Contributor

r? @nikic

@rust-highfive rust-highfive assigned nikic and unassigned petrochenkov Apr 10, 2022
@nikic
Copy link
Contributor

nikic commented Apr 11, 2022

@bors r+

@bors
Copy link
Collaborator

bors commented Apr 11, 2022

📌 Commit 84fb481 has been approved by nikic

@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 Apr 11, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Apr 12, 2022
…s, r=nikic

Respect -Z verify-llvm-ir and other flags that add extra passes when combined with -C no-prepopulate-passes in the new LLVM Pass Manager.

As part of the switch to the new LLVM Pass Manager the behaviour of flags such as `-Z verify-llvm-ir` (e.g. sanitizer, instrumentation) was modified when combined with `-C no-prepopulate-passes`. With the old PM, rustc was the one manually constructing the pipeline and respected those flags but in the new pass manager, those flags are used to build a list of callbacks that get invoked at certain extension points in the pipeline. Unfortunately, `-C no-prepopulate-passes` would skip building the pipeline altogether meaning we'd never add the corresponding passes. The fix here is to just manually invoke those callbacks as needed.

Fixes rust-lang#95874

Demonstrating the current vs fixed behaviour using the bug in rust-lang#95864
```console
$ rustc +nightly asm-miscompile.rs --edition 2021 --emit=llvm-ir -C no-prepopulate-passes -Z verify-llvm-ir
$ echo $?
0
$ rustc +stage1 asm-miscompile.rs --edition 2021 --emit=llvm-ir -C no-prepopulate-passes -Z verify-llvm-ir
Basic Block in function '_ZN14asm_miscompile3foo28_$u7b$$u7b$closure$u7d$$u7d$17h360e2f7eee1275c5E' does not have terminator!
label %bb1
LLVM ERROR: Broken module found, compilation aborted!
```
@bors
Copy link
Collaborator

bors commented Apr 12, 2022

⌛ Testing commit 84fb481 with merge b8f4cb6...

@bors
Copy link
Collaborator

bors commented Apr 12, 2022

☀️ Test successful - checks-actions
Approved by: nikic
Pushing b8f4cb6 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 12, 2022
@bors bors merged commit b8f4cb6 into rust-lang:master Apr 12, 2022
@rustbot rustbot added this to the 1.62.0 milestone Apr 12, 2022
@luqmana luqmana deleted the no-prepopulate-passes-tweaks branch April 12, 2022 06:41
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (b8f4cb6): comparison url.

Summary:

  • Primary benchmarks: no relevant changes found
  • Secondary benchmarks: mixed results
Regressions 😿
(primary)
Regressions 😿
(secondary)
Improvements 🎉
(primary)
Improvements 🎉
(secondary)
All 😿 🎉
(primary)
count1 0 3 0 6 0
mean2 N/A 0.5% N/A -0.4% N/A
max N/A 0.6% N/A -0.5% N/A

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

@rustbot label: +perf-regression

Footnotes

  1. number of relevant changes

  2. the arithmetic mean of the percent change

@rustbot rustbot added the perf-regression Performance regression. label Apr 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

When the new LLVM Pass Manager is enabled, -Z verify-llvm-ir=yes is ignored if -C no-prepopulate-passes is also given
7 participants