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

Intern SimplifyCfg into enum variants #108026

Closed
wants to merge 0 commits into from

Conversation

miguelraz
Copy link
Contributor

@miguelraz miguelraz commented Feb 14, 2023

EDIT:
WHELP, forgot to rebase to beta. brb in a few.

Was poking around and found that there are only 8 variants that need SimplifyCfg in compiler/rustc_mir_transforms/ - I think they can be shoved into an enum and earn some perf due to reduced (arena) allocations/fetching and compacting.

The variants are

[I] miguelraz@pop-os ~/o/r/c/r/src> rg "new\(\""
lib.rs
302:            &simplify::SimplifyCfg::new("initial"),
342:            &simplify::SimplifyCfg::new("promote-consts"),
474:                &simplify::SimplifyCfg::new("remove-false-edges"),
496:        &simplify_branches::SimplifyConstCondition::new("initial"),
499:        &simplify::SimplifyCfg::new("early-opt"),
537:        &simplify::SimplifyCfg::new("elaborate-drops"),
558:            &o1(simplify::SimplifyCfg::new("after-uninhabited-enum-branching")),
575:            &o1(simplify_branches::SimplifyConstCondition::new("after-const-prop")),
582:            &o1(simplify_branches::SimplifyConstCondition::new("final")),
584:            &o1(simplify::SimplifyCfg::new("final")),

shim.rs
97:            &simplify::SimplifyCfg::new("make_shim"),

Note that a comment in simplify.rs says

  10   │ //! On the other side of the spectrum, the `SimplifyCfg` pass is considerably cheap to run, thus
  11   │ //! one should run it after every pass which may modify CFG in significant ways. This pass must
  12   │ //! also be run before any analysis passes because it removes dead blocks, and some of these can be
  13   │ //! ill-typed.

so I'm hoping for some low-hanging perf fruits here, but the benchmarks will tell.

I plan to also intern the SimplifyConstCondition, but this had tests passing locally so I wanted to push it now.

This is my first rust-lang PR, any feedback is appreciated. Thanks!

@rustbot
Copy link
Collaborator

rustbot commented Feb 14, 2023

r? @albertlarsan68

(rustbot has picked a reviewer for you, use r? to override)

@rustbot
Copy link
Collaborator

rustbot commented Feb 14, 2023

⚠️ Warning ⚠️

  • These commits modify submodules.

@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-release Relevant to the release subteam, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Feb 14, 2023
@rustbot
Copy link
Collaborator

rustbot commented Feb 14, 2023

Some changes occurred in src/tools/cargo

cc @ehuss

These commits modify the Cargo.lock file. Random changes to Cargo.lock can be introduced when switching branches and rebasing PRs.
This was probably unintentional and should be reverted before this PR is merged.

If this was intentional then you can ignore this comment.

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

The Miri subtree was changed

cc @rust-lang/miri

@albertlarsan68
Copy link
Member

albertlarsan68 commented Feb 14, 2023

I think you messed up while rebasing, see the documentation.
Also, I'm not the right person to review.
r? compiler

@rustbot rustbot assigned eholk and unassigned albertlarsan68 Feb 14, 2023
@albertlarsan68
Copy link
Member

cc @eholk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-release Relevant to the release subteam, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants