Skip to content
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

Add a MIR pass manager (Taylor's Version) #91475

Merged
merged 9 commits into from
Dec 5, 2021

Conversation

ecstatic-morse
Copy link
Contributor

@ecstatic-morse ecstatic-morse commented Dec 2, 2021

The final draft of #91386 and #77665.

While the compile-time constraints in #91386 are cool, I decided on a more minimal approach for now. I want to explore phase constraints and maybe relative-ordering constraints in the future, though. This should preserve existing behavior exactly (please let me know if it doesn't) while making the following changes to the way we organize things today:

  • Each MirPhase now corresponds to a single MIR pass. run_passes is not responsible for listing the correct MIR phase.
  • run_passes no longer silently skips passes if the declared MIR phase is greater than or equal to the body's. This has bitten me multiple times. If you want this behavior, you can always branch on body.phase yourself.
  • If your pass is solely to emit errors, you can use the MirLint interface instead, which gets a shared reference to Body instead of a mutable one. By differentiating the two, I hope to make it clearer in the short term where lints belong in the pipeline. In the long term perhaps we could enforce this at compile-time?
  • MIR is no longer dumped for passes that aren't enabled, or for lints.

I tried to check that -Zvalidate still works correctly, since the MIR phase is now updated as soon as the associated pass is done, instead of at the end of all the passes in run_passes. However, it looks like -Zvalidate is broken with current nightlies anyways 😢 (it spits out a bunch of errors).

cc @oli-obk @wesleywiser

r? rust-lang/wg-mir-opt

@rust-highfive
Copy link
Collaborator

r? @jackh726

(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 Dec 2, 2021
@rust-log-analyzer

This comment has been minimized.

@ecstatic-morse ecstatic-morse changed the title Add a MIR pass manager (Taylor's version) Add a MIR pass manager (Taylor's Version) Dec 3, 2021
@ecstatic-morse ecstatic-morse force-pushed the mir-pass-manager3 branch 2 times, most recently from cefefc4 to 37ac4ad Compare December 3, 2021 01:29
Looks like Generator drop shims already have `post_borrowck_cleanup` run
on them. That's a bit surprising, since it means they're getting const-
and maybe borrow-checked? This merits further investigation, but for now
just preserve the status quo.
The noopt test never actually ran the pass
@oli-obk
Copy link
Contributor

oli-obk commented Dec 3, 2021

r? @oli-obk

@rust-highfive rust-highfive assigned oli-obk and unassigned jackh726 Dec 3, 2021
Copy link
Contributor

@oli-obk oli-obk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really nice. It will make further changes so much easier to impl and reason about.

Also thx for the clean commits, reviewing was real easy.

r=me with ci passing, perf clean and the comment removed

// FIXME(#70073): This pass is responsible for both optimization as well as some lints.
&const_prop::ConstProp,
//
// FIXME: The old pass manager ran this only at mir-opt-level >= 1, but
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While const prop runs unconditionally, it doesn't change the MIR unless the opt level is 1 or above. So we indeed don't need to simplify unconditionally

@oli-obk
Copy link
Contributor

oli-obk commented Dec 3, 2021

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Dec 3, 2021
@bors
Copy link
Contributor

bors commented Dec 3, 2021

⌛ Trying commit 7bc5eca with merge 0d6119ad550f626d8dac7253fa6d5897ec3d3667...

@bors
Copy link
Contributor

bors commented Dec 3, 2021

☀️ Try build successful - checks-actions
Build commit: 0d6119ad550f626d8dac7253fa6d5897ec3d3667 (0d6119ad550f626d8dac7253fa6d5897ec3d3667)

@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 Dec 4, 2021
@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

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

@bors
Copy link
Contributor

bors commented Dec 4, 2021

⌛ Testing commit 7bc5eca with merge 23fd1e950a1e0b895d1f1e5e0cc3f444c7ca21ce...

@bors
Copy link
Contributor

bors commented Dec 4, 2021

💔 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 Dec 4, 2021
@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

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

@matthiaskrgr
Copy link
Member

0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (6) Could not resolve host: ci-mirrors.rust-lang.org
@bors retry

@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 Dec 4, 2021
@bors
Copy link
Contributor

bors commented Dec 5, 2021

⌛ Testing commit 7bc5eca with merge bdaa901...

@bors
Copy link
Contributor

bors commented Dec 5, 2021

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing bdaa901 to master...

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (bdaa901): comparison url.

Summary: This change led to moderate relevant improvements 🎉 in compiler performance.

  • Moderate improvement in instruction counts (up to -0.8% on full builds of stm32f4)

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

@rustbot label: -perf-regression

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Dec 8, 2021
…anup, r=oli-obk

Address some FIXMEs left over from rust-lang#91475

This shouldn't change behavior, only clarify what we're currently doing. I filed rust-lang#91576 to see if the treatment of generator drop shims is intentional.

cc rust-lang#91475
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Dec 8, 2021
…anup, r=oli-obk

Address some FIXMEs left over from rust-lang#91475

This shouldn't change behavior, only clarify what we're currently doing. I filed rust-lang#91576 to see if the treatment of generator drop shims is intentional.

cc rust-lang#91475
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 8, 2021
…askrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#83744 (Deprecate crate_type and crate_name nested inside #![cfg_attr])
 - rust-lang#90550 (Update certificates in some Ubuntu 16 images.)
 - rust-lang#91272 (Print a suggestion when comparing references to primitive types in `const fn`)
 - rust-lang#91467 (Emphasise that an OsStr[ing] is not necessarily a platform string)
 - rust-lang#91531 (Do not add `;` to expected tokens list when it's wrong)
 - rust-lang#91577 (Address some FIXMEs left over from rust-lang#91475)
 - rust-lang#91638 (Remove `in_band_lifetimes` from `rustc_mir_transform`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-mir-opt Area: MIR optimizations merged-by-bors This PR was explicitly merged by bors. 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.

10 participants