Skip to content

Conversation

@SATVIKsynopsis
Copy link
Contributor

@SATVIKsynopsis SATVIKsynopsis commented Dec 22, 2025

Fixes #150242

Hi

While looking into this, I noticed that after SimplifyCfg runs we still end up with some assume(RuntimeChecks) statements in MIR.

At that point these checks are already effectively fixed, so keeping the assume doesn’t really help anything and just adds unwanted things. Since the control flow is already simplified and dead blocks are removed, the assume never provides additional information.

This PR removes those leftover assume(RuntimeChecks) statements after SimplifyCfg finishes.

I also added a small MIR opt test to make sure the assume doesn’t show up after SimplifyCfg final, so we don’t do on this later.

All existing tests pass, and the new test passes also pass.

Let me know if you would like this to be handled in a different pass or adjusted further.

@rustbot
Copy link
Collaborator

rustbot commented Dec 22, 2025

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@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 Dec 22, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 22, 2025

r? @lcnr

rustbot has assigned @lcnr.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-20-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
---- [coverage-map] tests/coverage/unreachable.rs stdout ----
Saved the actual cov-map to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/coverage/unreachable.coverage-map/unreachable.cov-map`
diff of cov-map:

- Function name: unreachable::UNREACHABLE_CLOSURE::{closure#0} (unused)
- Raw bytes (9): 0x[01, 01, 00, 01, 00, 0e, 30, 00, 45]
+ Function name: unreachable::UNREACHABLE_CLOSURE::{closure#0}
+ Raw bytes (9): 0x[01, 01, 00, 01, 01, 0e, 30, 00, 45]
3 Number of files: 1
4 - file 0 => $DIR/unreachable.rs
5 Number of expressions: 0

6 Number of file 0 mappings: 1
- - Code(Zero) at (prev + 14, 48) to (start + 0, 69)
- Highest counter ID seen: (none)
+ - Code(Counter(0)) at (prev + 14, 48) to (start + 0, 69)
+ Highest counter ID seen: c0
9 
- Function name: unreachable::unreachable_function (unused)
- Raw bytes (14): 0x[01, 01, 00, 02, 00, 10, 01, 00, 1a, 00, 01, 0e, 00, 23]
+ Function name: unreachable::unreachable_function
+ Raw bytes (14): 0x[01, 01, 00, 02, 01, 10, 01, 00, 1a, 01, 01, 0e, 00, 23]
12 Number of files: 1
13 - file 0 => $DIR/unreachable.rs
14 Number of expressions: 0

15 Number of file 0 mappings: 2
- - Code(Zero) at (prev + 16, 1) to (start + 0, 26)
- - Code(Zero) at (prev + 1, 14) to (start + 0, 35)
- Highest counter ID seen: (none)
+ - Code(Counter(0)) at (prev + 16, 1) to (start + 0, 26)
+ - Code(Counter(0)) at (prev + 1, 14) to (start + 0, 35)
+ Highest counter ID seen: c0
19 
20 Function name: unreachable::unreachable_intrinsic (unused)
21 Raw bytes (14): 0x[01, 01, 00, 02, 00, 15, 01, 00, 1b, 00, 01, 0e, 00, 2a]


The actual cov-map differed from the expected cov-map

error: an error occurred comparing coverage output.
status: exit status: 0
command: "/checkout/obj/build/aarch64-unknown-linux-gnu/stage1-tools-bin/coverage-dump" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/coverage/unreachable.coverage-map/unreachable.ll"
--- stdout -------------------------------
Function name: unreachable::UNREACHABLE_CLOSURE::{closure#0}
Raw bytes (9): 0x[01, 01, 00, 01, 01, 0e, 30, 00, 45]
Number of files: 1
- file 0 => /checkout/tests/coverage/unreachable.rs
Number of expressions: 0
Number of file 0 mappings: 1
- Code(Counter(0)) at (prev + 14, 48) to (start + 0, 69)
Highest counter ID seen: c0

Function name: unreachable::unreachable_function
Raw bytes (14): 0x[01, 01, 00, 02, 01, 10, 01, 00, 1a, 01, 01, 0e, 00, 23]
Number of files: 1
- file 0 => /checkout/tests/coverage/unreachable.rs
Number of expressions: 0
Number of file 0 mappings: 2
- Code(Counter(0)) at (prev + 16, 1) to (start + 0, 26)
- Code(Counter(0)) at (prev + 1, 14) to (start + 0, 35)
Highest counter ID seen: c0

Function name: unreachable::unreachable_intrinsic (unused)
Raw bytes (14): 0x[01, 01, 00, 02, 00, 15, 01, 00, 1b, 00, 01, 0e, 00, 2a]
Number of files: 1
- file 0 => /checkout/tests/coverage/unreachable.rs
Number of expressions: 0
Number of file 0 mappings: 2
- Code(Zero) at (prev + 21, 1) to (start + 0, 27)
- Code(Zero) at (prev + 1, 14) to (start + 0, 42)
Highest counter ID seen: (none)
------------------------------------------
stderr: none

---- [coverage-map] tests/coverage/unreachable.rs stdout end ----

@Kivooeo
Copy link
Member

Kivooeo commented Dec 22, 2025

Please squash the last commit into the first

And it seems like you want to run ./x test tests/coverage --bless

@saethlin
Copy link
Member

Closing, see rust-lang/compiler-team#893

@saethlin saethlin closed this Dec 23, 2025
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Remove assume(UbChecks) statements in MIR

6 participants