Skip to content

Make MIR basic blocks field public - #98930

Merged
bors merged 5 commits into
rust-lang:masterfrom
tmiasko:pub-basic-blocks
Jul 7, 2022
Merged

Make MIR basic blocks field public#98930
bors merged 5 commits into
rust-lang:masterfrom
tmiasko:pub-basic-blocks

Conversation

@tmiasko

Copy link
Copy Markdown
Contributor

This makes it possible to mutably borrow different fields of the MIR
body without resorting to methods like basic_blocks_local_decls_mut_and_var_debug_info.

To preserve validity of control flow graph caches in the presence of
modifications, a new struct BasicBlocks wraps together basic blocks
and control flow graph caches.

The BasicBlocks dereferences to IndexVec<BasicBlock, BasicBlockData>.
On the other hand a mutable access requires explicit as_mut() call.

@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rustbotrustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jul 5, 2022
@rust-highfive

Copy link
Copy Markdown
Contributor

r? @petrochenkov

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

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 5, 2022
Comment threadcompiler/rustc_middle/src/mir/mod.rs Outdated
@oli-obk

Copy link
Copy Markdown
Contributor

r? @oli-obk

this is neat, definitely a massive improvement over the explosion of iteration methods ^^

@JakobDegen

Copy link
Copy Markdown
Contributor

Yeah, agreed, this is a much better solution than what I did

@oli-obk

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Jul 6, 2022

Copy link
Copy Markdown
Collaborator

📌 Commit 802cb1c has been approved by oli-obk

@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 Jul 6, 2022
@Dylan-DPCDylan-DPC mentioned this pull request Jul 7, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Jul 7, 2022
Make MIR basic blocks field public
This makes it possible to mutably borrow different fields of the MIR
body without resorting to methods like `basic_blocks_local_decls_mut_and_var_debug_info`.
To preserve validity of control flow graph caches in the presence of
modifications, a new struct `BasicBlocks` wraps together basic blocks
and control flow graph caches.
The `BasicBlocks` dereferences to `IndexVec<BasicBlock, BasicBlockData>`.
On the other hand a mutable access requires explicit `as_mut()` call.
@Dylan-DPC

Copy link
Copy Markdown
Member

failed in rollup ci

@bors r-

@borsbors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 7, 2022
tmiasko added 5 commits July 7, 2022 08:11
This makes it possible to mutably borrow different fields of the MIR
body without resorting to methods like `basic_blocks_local_decls_mut_and_var_debug_info`.
To preserve validity of control flow graph caches in the presence of
modifications, a new struct `BasicBlocks` wraps together basic blocks
and control flow graph caches.
The `BasicBlocks` dereferences to `IndexVec<BasicBlock, BasicBlockData>`.
On the other hand a mutable access requires explicit `as_mut()` call.
@oli-obk

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Jul 7, 2022

Copy link
Copy Markdown
Collaborator

📌 Commit 17adfeb has been approved by oli-obk

@borsbors removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jul 7, 2022
@borsbors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jul 7, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Jul 7, 2022
Make MIR basic blocks field public
This makes it possible to mutably borrow different fields of the MIR
body without resorting to methods like `basic_blocks_local_decls_mut_and_var_debug_info`.
To preserve validity of control flow graph caches in the presence of
modifications, a new struct `BasicBlocks` wraps together basic blocks
and control flow graph caches.
The `BasicBlocks` dereferences to `IndexVec<BasicBlock, BasicBlockData>`.
On the other hand a mutable access requires explicit `as_mut()` call.
@Dylan-DPCDylan-DPC mentioned this pull request Jul 7, 2022
@eddyb

eddyb commented Jul 7, 2022

Copy link
Copy Markdown
Contributor

Neat! I guess the focus on basic_blocks: IndexVec<...> had obscured the deeper connection, before.


As a random aside, I believe some IRs would describe this subset of information as "the CFG" (though they might vary in whether that includes the BB contents, or just the terminators).

The only reason I bring this up is because body.cfg[bb] is quite compact and reads nicely IMO, but of course these are just subjective aesthetics - feel free to ignore this drive-by bikeshed comment.

@Dylan-DPCDylan-DPC mentioned this pull request Jul 7, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 7, 2022
Rollup of 8 pull requests
Successful merges:
- rust-lang#96856 (Fix ProjectionElem validation)
- rust-lang#97711 (Improve soundness of rustc_arena)
- rust-lang#98507 (Finishing touches for `#[expect]` (RFC 2383))
- rust-lang#98692 (rustdoc: Cleanup more FIXMEs)
- rust-lang#98901 (incr: cache dwarf objects in work products)
- rust-lang#98930 (Make MIR basic blocks field public)
- rust-lang#98973 (Remove (unused) inherent impl anchors)
- rust-lang#98981 ( Edit `rustc_mir_dataflow::framework` documentation )
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit 71b3fbd into rust-lang:masterJul 7, 2022
@rustbotrustbot added this to the 1.64.0 milestone Jul 7, 2022
@tmiasko
tmiasko deleted the pub-basic-blocks branch July 7, 2022 19:37
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jul 18, 2022
Make MIR basic blocks field public
This makes it possible to mutably borrow different fields of the MIR
body without resorting to methods like `basic_blocks_local_decls_mut_and_var_debug_info`.
To preserve validity of control flow graph caches in the presence of
modifications, a new struct `BasicBlocks` wraps together basic blocks
and control flow graph caches.
The `BasicBlocks` dereferences to `IndexVec<BasicBlock, BasicBlockData>`.
On the other hand a mutable access requires explicit `as_mut()` call.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Aug 28, 2022
Replace `Body::basic_blocks()` with field access
Since the refactoring in rust-lang#98930, it is possible to borrow the basic blocks
independently from other parts of MIR by accessing the `basic_blocks` field
directly.
Replace unnecessary `Body::basic_blocks()` method with a direct field access,
which has an additional benefit of borrowing the basic blocks only.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Aug 28, 2022
Replace `Body::basic_blocks()` with field access
Since the refactoring in rust-lang#98930, it is possible to borrow the basic blocks
independently from other parts of MIR by accessing the `basic_blocks` field
directly.
Replace unnecessary `Body::basic_blocks()` method with a direct field access,
which has an additional benefit of borrowing the basic blocks only.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 28, 2022
Replace `Body::basic_blocks()` with field access
Since the refactoring in rust-lang#98930, it is possible to borrow the basic blocks
independently from other parts of MIR by accessing the `basic_blocks` field
directly.
Replace unnecessary `Body::basic_blocks()` method with a direct field access,
which has an additional benefit of borrowing the basic blocks only.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 28, 2022
Replace `Body::basic_blocks()` with field access
Since the refactoring in rust-lang#98930, it is possible to borrow the basic blocks
independently from other parts of MIR by accessing the `basic_blocks` field
directly.
Replace unnecessary `Body::basic_blocks()` method with a direct field access,
which has an additional benefit of borrowing the basic blocks only.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 28, 2022
Replace `Body::basic_blocks()` with field access
Since the refactoring in rust-lang#98930, it is possible to borrow the basic blocks
independently from other parts of MIR by accessing the `basic_blocks` field
directly.
Replace unnecessary `Body::basic_blocks()` method with a direct field access,
which has an additional benefit of borrowing the basic blocks only.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 29, 2022
Replace `Body::basic_blocks()` with field access
Since the refactoring in rust-lang#98930, it is possible to borrow the basic blocks
independently from other parts of MIR by accessing the `basic_blocks` field
directly.
Replace unnecessary `Body::basic_blocks()` method with a direct field access,
which has an additional benefit of borrowing the basic blocks only.
bjorn3 pushed a commit to bjorn3/rust that referenced this pull request Oct 23, 2022
Replace `Body::basic_blocks()` with field access
Since the refactoring in rust-lang#98930, it is possible to borrow the basic blocks
independently from other parts of MIR by accessing the `basic_blocks` field
directly.
Replace unnecessary `Body::basic_blocks()` method with a direct field access,
which has an additional benefit of borrowing the basic blocks only.
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.

9 participants

@tmiasko@rustbot@rust-highfive@oli-obk@JakobDegen@bors@Dylan-DPC@eddyb@petrochenkov