Skip to content

Add FileCheck annotations to 5 MIR-opt tests#153147

Open
sivadeilra wants to merge 1 commit intorust-lang:mainfrom
sivadeilra:filecheck-mir-opt-annotations
Open

Add FileCheck annotations to 5 MIR-opt tests#153147
sivadeilra wants to merge 1 commit intorust-lang:mainfrom
sivadeilra:filecheck-mir-opt-annotations

Conversation

@sivadeilra
Copy link
Contributor

@sivadeilra sivadeilra commented Feb 26, 2026

Add FileCheck annotations to 5 MIR-opt tests that previously used // skip-filecheck

Changes

File Pass Tested What the Annotations Check
byte_slice.rs SimplifyCfg Byte string literal b"foo" and byte array [5u8, b'x'] appear in MIR
multiple_return_terminators.rs MultipleReturnTerminators After optimization, fn test collapses to a single bb0: { return; }
impossible_predicates.rs ImpossiblePredicates Function with impossible where-clause (&mut i32: Copy) becomes bb0: { unreachable; }
lower_array_len.rs GVN (after LowerSliceLenCalls) Array .len() lowered to const N, bounds checks use Lt(_, const N)
remove_zsts.rs RemoveZsts Union ZST preserved, generic zero-length arrays replaced with const ZeroSized

All annotations follow the patterns established in existing annotated tests (e.g., simd-intrinsic-mask-reduce.rs). Each uses CHECK-LABEL to anchor on the function, then CHECK / CHECK-NOT / CHECK-NEXT to verify the key optimization results.

r? cjgillot

@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 Feb 26, 2026
@rustbot

This comment has been minimized.

Remove skip-filecheck and add FileCheck directives for:
- multiple_return_terminators.rs: verify pass collapses to single bb0 with return
- impossible_predicates.rs: verify body becomes unreachable when predicates impossible
- byte_slice.rs: verify byte slice literal lowering in MIR
- lower_array_len.rs: verify array .len() lowered to const N by GVN
- remove_zsts.rs: verify zero-sized types replaced with const ZeroSized
@sivadeilra sivadeilra force-pushed the filecheck-mir-opt-annotations branch from 60ad693 to bf43e31 Compare February 26, 2026 19:31
}
fn main() {
// CHECK-LABEL: fn main(
// CHECK-NOT: deref_copy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A single CHECK-NOT can be very brittle. Do you mind adding some positive CHECKs?

//@ compile-flags: -Zmir-opt-level=1 -Zinline-mir
pub fn f<T>(a: &T) -> *const T {
// CHECK-LABEL: fn f(
// CHECK: &raw const (*_1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not what the PR introducing this test was aiming for. If you look at 57d01a9aeea5, we are testing that _0 = (*_2) does not become _0 = (*_3), as _3 has no storage at that statement.

@@ -1,8 +1,11 @@
// skip-filecheck
//@ compile-flags: -Z mir-opt-level=4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file does not test what it's meant to test. Do you mind changing this line to the following? We should get two return; statements in the MIR for test.

Suggested change
//@ compile-flags: -Z mir-opt-level=4
//@ test-mir-pass: MultipleReturnTerminators

@cjgillot
Copy link
Contributor

cjgillot commented Mar 1, 2026

Thank you very much for continuing this. This is also an opportunity to cleanup the mir-opt test suite, which is why some comments discuss more than just the FileCheck annotations.

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.

3 participants