Region inference: Simplify initialisation of region values#157672
Merged
rust-bors[bot] merged 3 commits intoJun 12, 2026
Merged
Region inference: Simplify initialisation of region values#157672rust-bors[bot] merged 3 commits into
rust-bors[bot] merged 3 commits into
Conversation
Collaborator
|
r? @davidtwco rustbot has assigned @davidtwco. Use Why was this reviewer chosen?The reviewer was selected based on:
|
Contributor
Author
|
Dammit, it seems to be weirdly based on something. I'll have to rebase it. |
ffc1eec to
9602230
Compare
- `RegionInferenceContext::init_free_and_bound_regions()` is inlined into `::new()` and pulled to before initial SCC values are assigned - A couple of iteration-then-index patterns are changed into `iter_enumerated()`-style patterns - Some leftover code comments are removed and revised to actually describe the initialisation - Free regions are now marked as live everywhere in liveness constraints, then copied to scc_values upon initialisation, avoiding performing that logic twice It should do strictly less work, but almost all of it would only happen on free regions, and there shouldn't be large numbers of those. Depending on the cleverness of the optimiser most of the option/some checks should have been compiled away anyway. The key advantage as I see it is clearer flow: first liveness constraints are set up, then initial values are initialised, then region inference is ready to run.
9602230 to
219a65f
Compare
amandasystems
commented
Jun 9, 2026
|
|
||
| // Add all nodes in the CFG to liveness constraints | ||
| self.liveness_constraints.add_all_points(variable); | ||
| self.scc_values.add_all_points(scc); |
Contributor
Author
There was a problem hiding this comment.
Note this!
610be6c to
0b6f400
Compare
Member
|
@bors r+ |
Contributor
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Jun 12, 2026
…tialisation, r=davidtwco Region inference: Simplify initialisation of region values This PR simplifies the initialisation of region values in `region_infer` - `RegionInferenceContext::init_free_and_bound_regions()` is inlined into `::new()` and pulled to before initial SCC values are assigned - A couple of iteration-then-index patterns are changed into `iter_enumerated()`-style patterns - Some leftover code comments are removed and revised to actually describe the initialisation - Free regions are now marked as live everywhere in liveness constraints, then copied to scc_values upon initialisation, avoiding performing that logic twice - The trait used to index into SCC values goes away and the relevant methods are monomorphised and static-dispatched. This makes it easier to follow what's going on where, and possibly also shows a potential optimiser how insanely inline:able those methods are since they are used in exactly one place with exactly one type of value (though maybe it already saw that). It should do strictly less work, but almost all of it would only happen on free regions, and there shouldn't be large numbers of those. Depending on the cleverness of the optimiser most of the option/some checks should have been compiled away anyway. The key advantage as I see it is clearer flow: first liveness constraints are set up, then initial values are initialised, then region inference is ready to run.
This was referenced Jun 12, 2026
rust-bors Bot
pushed a commit
that referenced
this pull request
Jun 12, 2026
…uwer Rollup of 23 pull requests Successful merges: - #144220 (Add powerpc64-unknown-linux-gnuelfv2 target) - #153238 (debuginfo: slices are DW_TAG_array_type's) - #157112 (Update aarch64-unknown-freebsd target description) - #157322 (test pre-stabilization items on CI) - #157348 (Don't track cwd for `-Zremap-cwd-prefix` in incremental compilation) - #157490 (Add field-wise CoerceShared reborrow tests) - #157655 (Make Share::share final and improve docs) - #157672 (Region inference: Simplify initialisation of region values) - #157680 (Require `#[pin_v2]` for explicit pin-projection patterns) - #157688 (Create experimental test job `aarch64-apple-macos-26` for evaluating `macos-26` runner images) - #157796 (rustdoc: Some more lazy formatting) - #157818 (miri subtree update) - #157069 (Test that you can't implement Unpin for a compiler-generated future using TAIT) - #157079 (Don't recover `&raw EXPR` as a missing comma) - #157202 (add #[rustc_no_writable] to slice::get_unchecked_mut) - #157622 (Disable retagging for variadic arguments in const-eval) - #157684 (-Zassumptions-on-binders: insert empty assumptions when entering binders in the solver) - #157695 (Extend capabilities of `TypeFoldable_Generic`) - #157766 (interpret: avoid computing layout of sized raw pointee) - #157785 (fuchsia: Support AddressSanitizer on riscv64gc-unknown-fuchsia) - #157795 (revert 157013) - #157798 (Prevent approving PRs that wait for Crater or formal decisions) - #157803 (Rename `errors.rs` file to `diagnostics.rs` (7/N)) Failed merges: - #157752 (Rename `errors.rs` file to `diagnostics.rs` (6/N))
rust-timer
added a commit
that referenced
this pull request
Jun 13, 2026
Rollup merge of #157672 - amandasystems:region-inference-initialisation, r=davidtwco Region inference: Simplify initialisation of region values This PR simplifies the initialisation of region values in `region_infer` - `RegionInferenceContext::init_free_and_bound_regions()` is inlined into `::new()` and pulled to before initial SCC values are assigned - A couple of iteration-then-index patterns are changed into `iter_enumerated()`-style patterns - Some leftover code comments are removed and revised to actually describe the initialisation - Free regions are now marked as live everywhere in liveness constraints, then copied to scc_values upon initialisation, avoiding performing that logic twice - The trait used to index into SCC values goes away and the relevant methods are monomorphised and static-dispatched. This makes it easier to follow what's going on where, and possibly also shows a potential optimiser how insanely inline:able those methods are since they are used in exactly one place with exactly one type of value (though maybe it already saw that). It should do strictly less work, but almost all of it would only happen on free regions, and there shouldn't be large numbers of those. Depending on the cleverness of the optimiser most of the option/some checks should have been compiled away anyway. The key advantage as I see it is clearer flow: first liveness constraints are set up, then initial values are initialised, then region inference is ready to run.
pull Bot
pushed a commit
to xtqqczze/rust-lang-miri
that referenced
this pull request
Jun 13, 2026
…uwer Rollup of 23 pull requests Successful merges: - rust-lang/rust#144220 (Add powerpc64-unknown-linux-gnuelfv2 target) - rust-lang/rust#153238 (debuginfo: slices are DW_TAG_array_type's) - rust-lang/rust#157112 (Update aarch64-unknown-freebsd target description) - rust-lang/rust#157322 (test pre-stabilization items on CI) - rust-lang/rust#157348 (Don't track cwd for `-Zremap-cwd-prefix` in incremental compilation) - rust-lang/rust#157490 (Add field-wise CoerceShared reborrow tests) - rust-lang/rust#157655 (Make Share::share final and improve docs) - rust-lang/rust#157672 (Region inference: Simplify initialisation of region values) - rust-lang/rust#157680 (Require `#[pin_v2]` for explicit pin-projection patterns) - rust-lang/rust#157688 (Create experimental test job `aarch64-apple-macos-26` for evaluating `macos-26` runner images) - rust-lang/rust#157796 (rustdoc: Some more lazy formatting) - rust-lang/rust#157818 (miri subtree update) - rust-lang/rust#157069 (Test that you can't implement Unpin for a compiler-generated future using TAIT) - rust-lang/rust#157079 (Don't recover `&raw EXPR` as a missing comma) - rust-lang/rust#157202 (add #[rustc_no_writable] to slice::get_unchecked_mut) - rust-lang/rust#157622 (Disable retagging for variadic arguments in const-eval) - rust-lang/rust#157684 (-Zassumptions-on-binders: insert empty assumptions when entering binders in the solver) - rust-lang/rust#157695 (Extend capabilities of `TypeFoldable_Generic`) - rust-lang/rust#157766 (interpret: avoid computing layout of sized raw pointee) - rust-lang/rust#157785 (fuchsia: Support AddressSanitizer on riscv64gc-unknown-fuchsia) - rust-lang/rust#157795 (revert 157013) - rust-lang/rust#157798 (Prevent approving PRs that wait for Crater or formal decisions) - rust-lang/rust#157803 (Rename `errors.rs` file to `diagnostics.rs` (7/N)) Failed merges: - rust-lang/rust#157752 (Rename `errors.rs` file to `diagnostics.rs` (6/N))
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR simplifies the initialisation of region values in
region_inferRegionInferenceContext::init_free_and_bound_regions()is inlined into::new()and pulled to before initial SCC values are assignediter_enumerated()-style patternsIt should do strictly less work, but almost all of it would only happen on free regions, and there shouldn't be large numbers of those. Depending on the cleverness of the optimiser most of the option/some checks should have been compiled away anyway.
The key advantage as I see it is clearer flow: first liveness constraints are set up, then initial values are initialised, then region inference is ready to run.