Skip to content

Improve MIR modification - #137203

Merged
bors merged 5 commits into
rust-lang:masterfrom
nnethercote:improve-MIR-modification
Feb 19, 2025
Merged

Improve MIR modification#137203
bors merged 5 commits into
rust-lang:masterfrom
nnethercote:improve-MIR-modification

Conversation

@nnethercote

Copy link
Copy Markdown
Contributor

A few commits that simplify code that manipulates MIR bodies.

r? @tmiasko

Instead of `expand_statements`. This makes the code shorter and
consistent with other MIR transform passes.
The tests require updating because there is a slight change in
MIR output:
- the old code replaced the original statement with twelve new
statements.
- the new code inserts converts the original statement to a `nop` and
then insert twelve new statements in front of it.
I.e. we now end up with an extra `nop`, which doesn't matter at all.
It's currently lacking comments. This commit adds some, which is useful
because there are some methods with non-obvious behaviour.
The commit also renames two things:
- `patch_map` becomes `term_patch_map`, because it's only about
terminators.
- `is_patched` becomes `is_term_patched`, for the same reason.
(I would guess that originally `MirPatch` only handled terminators, and
then over time it expanded to allow other modifications, but these names
weren't updated.)
The previous commit removed its single use. `MirPatch` is a more
flexible alternative.
It has a single call site, and the code is clearer this way.
It has a single call site, and doesn't seem worth having as an API
function.
@rustbotrustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 18, 2025
@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@compiler-errors

Copy link
Copy Markdown
Contributor

r? compiler-errors @bors r+ rollup

@bors

bors commented Feb 18, 2025

Copy link
Copy Markdown
Collaborator

📌 Commit 04eeda4 has been approved by compiler-errors

It is now in the queue for this repository.

@borsbors 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 Feb 18, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 18, 2025
…iaskrgr
Rollup of 10 pull requests
Successful merges:
- rust-lang#135711 (Do not ICE on default_field_value const with lifetimes)
- rust-lang#136599 (librustdoc: more usages of `Joined::joined`)
- rust-lang#136876 (Locking documentation updates)
- rust-lang#137000 (Deeply normalize item bounds in new solver)
- rust-lang#137126 (fix docs for inherent str constructors)
- rust-lang#137161 (Pattern Migration 2024: fix incorrect messages/suggestions when errors arise in macro expansions)
- rust-lang#137191 (Update mdbook and move error_index_generator)
- rust-lang#137203 (Improve MIR modification)
- rust-lang#137206 (Make E0599 a structured error)
- rust-lang#137218 (misc `layout_of` cleanup)
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit 10dd016 into rust-lang:masterFeb 19, 2025
@rustbotrustbot added this to the 1.87.0 milestone Feb 19, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 19, 2025
Rollup merge of rust-lang#137203 - nnethercote:improve-MIR-modification, r=compiler-errors
Improve MIR modification
A few commits that simplify code that manipulates MIR bodies.
r? `@tmiasko`
@nnethercote
nnethercote deleted the improve-MIR-modification branch February 19, 2025 01:04
github-actionsBot pushed a commit to tautschnig/verify-rust-std that referenced this pull request Mar 11, 2025
…iaskrgr
Rollup of 10 pull requests
Successful merges:
- rust-lang#135711 (Do not ICE on default_field_value const with lifetimes)
- rust-lang#136599 (librustdoc: more usages of `Joined::joined`)
- rust-lang#136876 (Locking documentation updates)
- rust-lang#137000 (Deeply normalize item bounds in new solver)
- rust-lang#137126 (fix docs for inherent str constructors)
- rust-lang#137161 (Pattern Migration 2024: fix incorrect messages/suggestions when errors arise in macro expansions)
- rust-lang#137191 (Update mdbook and move error_index_generator)
- rust-lang#137203 (Improve MIR modification)
- rust-lang#137206 (Make E0599 a structured error)
- rust-lang#137218 (misc `layout_of` cleanup)
r? `@ghost`
`@rustbot` modify labels: rollup
github-actionsBot pushed a commit to tautschnig/verify-rust-std that referenced this pull request Mar 11, 2025
…iaskrgr
Rollup of 10 pull requests
Successful merges:
- rust-lang#135711 (Do not ICE on default_field_value const with lifetimes)
- rust-lang#136599 (librustdoc: more usages of `Joined::joined`)
- rust-lang#136876 (Locking documentation updates)
- rust-lang#137000 (Deeply normalize item bounds in new solver)
- rust-lang#137126 (fix docs for inherent str constructors)
- rust-lang#137161 (Pattern Migration 2024: fix incorrect messages/suggestions when errors arise in macro expansions)
- rust-lang#137191 (Update mdbook and move error_index_generator)
- rust-lang#137203 (Improve MIR modification)
- rust-lang#137206 (Make E0599 a structured error)
- rust-lang#137218 (misc `layout_of` cleanup)
r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant 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.

5 participants

@nnethercote@rustbot@compiler-errors@bors@tmiasko