Conversation
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
| /// | ||
| /// Used by `-Zmir-opt-bisect-limit` to assign an index to each | ||
| /// optimization-pass execution candidate during this compilation. | ||
| pub mir_opt_bisect_eval_count: AtomicUsize, |
There was a problem hiding this comment.
We used to have optimization fuel in the session, but removed it in #115293
| limit: usize, | ||
| pass: &P, | ||
| ) -> bool | ||
| static MIR_OPT_BISECT_COUNT: AtomicUsize = AtomicUsize::new(0); |
There was a problem hiding this comment.
This is actually worse. This now not only breaks incr comp, but also breaks running multiple rustc sessions in the same process. Optimization fuel is not really compatible with incr comp. Perhaps we should just warn against enabling incr comp when optimization fuel is used?
There was a problem hiding this comment.
We used to have optimization fuel in the session, but removed it in #115293
So, with this comment, should we remove the counter from Session while not making this feature broken when running multiple sessions in the same process?
Perhaps we should just warn against enabling incr comp when optimization fuel is used?
Thanks, this makes sense. I'll also add a warning when -Zmir-opt-bisect-limit is used together with incremental compilation.
There was a problem hiding this comment.
should we remove the counter from Session while not making this feature broken when running multiple sessions in the same process?
If so, I would like to know some possible ways to achieve it.
There was a problem hiding this comment.
It should definitively not be a static. Putting it in the Session breaks incr comp, but I don't think there is any easy way around that.
|
This might have weird interactions with -Zthreads, but I don't see a coherent way to resolve that, apart from mandating that the parallel compiler runs everything in a deterministic order. I think the current approach is good enough for a debugging tool. squash/fixup the commits into one and then I'll approve :) |
8922a59 to
6a9357a
Compare
This comment has been minimized.
This comment has been minimized.
FWIW, an interesting alternative that avoids this problem is hash based bisect. It's harder to implement than a binary search over a single integer, both for the program being bisected (here: rustc) and for doing the bisection (really annoying without automation, maybe the Go tool can be reused), but in return it's order/threading-independent and enables minimizing more precisely than the "fuel" approach. |
|
🤦 I missed that you actually squashed this down until I got the notification from the merge conflict |
|
This should prevent it from happening again: @bors delegate=sgasho |
|
Invalid command: Invalid delegation type |
|
@bors delegate |
6a9357a to
25c2191
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@bors r=saethlin rollup |
…thlin Implement opt-bisect-limit for MIR closes: rust-lang#150910 Enable bisecting MIR optimization passes to enhance debuggability. discussions on zulip: https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/MIR.20dump.20the.20pass.20names/with/573219207 ### Check it works #### Sample code ```rust fn abs(num: isize) -> usize { if num < 0 { -num as usize } else { num as usize } } fn main() { println!("{}", abs(-10)); } ``` #### Output ```shell rustc +mir -Zmir-opt-bisect-limit=30 src/main.rs BISECT: running pass (1) CheckAlignment on main[89d5]::main BISECT: running pass (2) CheckNull on main[89d5]::main BISECT: running pass (3) CheckEnums on main[89d5]::main BISECT: running pass (4) LowerSliceLenCalls on main[89d5]::main BISECT: running pass (5) InstSimplify-before-inline on main[89d5]::main BISECT: running pass (6) ForceInline on main[89d5]::main BISECT: running pass (7) RemoveStorageMarkers on main[89d5]::main BISECT: running pass (8) RemoveZsts on main[89d5]::main BISECT: running pass (9) RemoveUnneededDrops on main[89d5]::main BISECT: running pass (10) UnreachableEnumBranching on main[89d5]::main BISECT: running pass (11) SimplifyCfg-after-unreachable-enum-branching on main[89d5]::main BISECT: running pass (12) InstSimplify-after-simplifycfg on main[89d5]::main BISECT: running pass (13) SimplifyConstCondition-after-inst-simplify on main[89d5]::main BISECT: running pass (14) SimplifyLocals-before-const-prop on main[89d5]::main BISECT: running pass (15) SimplifyLocals-after-value-numbering on main[89d5]::main BISECT: running pass (16) MatchBranchSimplification on main[89d5]::main BISECT: running pass (17) SingleUseConsts on main[89d5]::main BISECT: running pass (18) SimplifyConstCondition-after-const-prop on main[89d5]::main BISECT: running pass (19) SimplifyConstCondition-final on main[89d5]::main BISECT: running pass (20) RemoveNoopLandingPads on main[89d5]::main BISECT: running pass (21) SimplifyCfg-final on main[89d5]::main BISECT: running pass (22) CopyProp on main[89d5]::main BISECT: running pass (23) SimplifyLocals-final on main[89d5]::main BISECT: running pass (24) AddCallGuards on main[89d5]::main BISECT: running pass (25) PreCodegen on main[89d5]::main BISECT: running pass (26) CheckAlignment on main[89d5]::abs BISECT: running pass (27) CheckNull on main[89d5]::abs BISECT: running pass (28) CheckEnums on main[89d5]::abs BISECT: running pass (29) LowerSliceLenCalls on main[89d5]::abs BISECT: running pass (30) InstSimplify-before-inline on main[89d5]::abs BISECT: NOT running pass (31) ForceInline on main[89d5]::abs BISECT: NOT running pass (32) RemoveStorageMarkers on main[89d5]::abs BISECT: NOT running pass (33) RemoveZsts on main[89d5]::abs BISECT: NOT running pass (34) RemoveUnneededDrops on main[89d5]::abs BISECT: NOT running pass (35) UnreachableEnumBranching on main[89d5]::abs BISECT: NOT running pass (36) SimplifyCfg-after-unreachable-enum-branching on main[89d5]::abs BISECT: NOT running pass (37) InstSimplify-after-simplifycfg on main[89d5]::abs BISECT: NOT running pass (38) SimplifyConstCondition-after-inst-simplify on main[89d5]::abs BISECT: NOT running pass (39) SimplifyLocals-before-const-prop on main[89d5]::abs BISECT: NOT running pass (40) SimplifyLocals-after-value-numbering on main[89d5]::abs BISECT: NOT running pass (41) MatchBranchSimplification on main[89d5]::abs BISECT: NOT running pass (42) SingleUseConsts on main[89d5]::abs BISECT: NOT running pass (43) SimplifyConstCondition-after-const-prop on main[89d5]::abs BISECT: NOT running pass (44) SimplifyConstCondition-final on main[89d5]::abs BISECT: NOT running pass (45) RemoveNoopLandingPads on main[89d5]::abs BISECT: NOT running pass (46) SimplifyCfg-final on main[89d5]::abs BISECT: NOT running pass (47) CopyProp on main[89d5]::abs BISECT: NOT running pass (48) SimplifyLocals-final on main[89d5]::abs BISECT: NOT running pass (49) AddCallGuards on main[89d5]::abs BISECT: NOT running pass (50) PreCodegen on main[89d5]::abs ``` r? @saethlin
Rollup of 4 pull requests Successful merges: - #152103 (Consider captures to be used by closures that unwind) - #152474 (Implement opt-bisect-limit for MIR) - #152648 (Remove timing assertion from `oneshot::send_before_recv_timeout`) - #152686 (bootstrap: Inline the `is_tool` check for setting `-Zforce-unstable-if-unmarked`)
Rollup of 4 pull requests Successful merges: - #152103 (Consider captures to be used by closures that unwind) - #152474 (Implement opt-bisect-limit for MIR) - #152648 (Remove timing assertion from `oneshot::send_before_recv_timeout`) - #152686 (bootstrap: Inline the `is_tool` check for setting `-Zforce-unstable-if-unmarked`)
|
@bors try jobs=dist-various-1 |
|
⌛ Trying commit 805b4a8 with merge 77ac94f… To cancel the try build, run the command Workflow: https://github.com/rust-lang/rust/actions/runs/22065265525 |
Implement opt-bisect-limit for MIR try-job: dist-various-1
closes: #150910
Enable bisecting MIR optimization passes to enhance debuggability.
discussions on zulip: https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/MIR.20dump.20the.20pass.20names/with/573219207
Check it works
Sample code
Output
r? @saethlin