Skip to content

Simplify apply_effects_in_range#159285

Open
nnethercote wants to merge 3 commits into
rust-lang:mainfrom
nnethercote:simplify-apply_effects_in_range
Open

Simplify apply_effects_in_range#159285
nnethercote wants to merge 3 commits into
rust-lang:mainfrom
nnethercote:simplify-apply_effects_in_range

Conversation

@nnethercote

Copy link
Copy Markdown
Contributor

Details in individual commits.

r? @cjgillot

`ResultsVisitor` has `visit_block_start` which is called on entry to a
a block in a forwards analysis and on exit from a block in a backwards
analysis. And vice versa for `visit_block_end`.

The only visitor that impls these methods is `StateDiffCollector`, which
does something in `visit_block_start` for a forwards analysis and the
same thing in `visit_block_end` for a backwards analysis. In other
words, `StateDiffCollector` wants to always do the same thing on entry
to a block and never do anything on exit from a block.

This commit replaces `visit_block_{start,end}` with `visit_block_entry`,
which is always called on entry to a block. This is simpler overall.
By adding more methods to `Direction`. This makes things more concise,
and these new methods will be used more in subsequent commits.
This commit adds `Analysis::apply_effect`, which takes an `EffectIndex`
and calls the appropriate `Analysis::apply_*` method.

Once that is in place, it is possible to use it with `next_index` to
write a simple `apply_effects_in_range` method that can be shared
between `Forward` and `Backward`. The end result is much easier to
understand.
@rustbot rustbot 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 Jul 14, 2026
@nnethercote

Copy link
Copy Markdown
Contributor Author

Shouldn't affect perf, let's check:

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 14, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jul 14, 2026
…r=<try>

Simplify `apply_effects_in_range`
@rust-bors

rust-bors Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 83bb0c9 (83bb0c96ef4d314870c0d145dff898c1e7326c9e)
Base parent: da80ed0 (da80ed0708a09dc096c184345d6eb42cbcd50a1e)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (83bb0c9): comparison URL.

Overall result: ❌ regressions - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

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

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.2% [0.2%, 0.3%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary -2.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.4% [-2.4%, -2.4%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.4% [-2.4%, -2.4%] 1

Cycles

Results (secondary -2.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.4% [-2.7%, -2.1%] 2
All ❌✅ (primary) - - 0

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 491.202s -> 491.32s (0.02%)
Artifact size: 389.32 MiB -> 389.43 MiB (0.03%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants