Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit c71c246

Browse files
committed
Auto merge of rust-lang#118550 - cjgillot:filecheck-const-prop, r=Mark-Simulacrum
Add FileCheck annotations to const_prop tests Unblocks rust-lang#116012 Advances rust-lang#116971
2 parents f7253f2 + 30a95b7 commit c71c246

File tree

52 files changed

+290
-253
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+290
-253
lines changed

tests/mir-opt/const_prop/address_of_pair.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1-
// skip-filecheck
21
// unit-test: ConstProp
32

43
// EMIT_MIR address_of_pair.fn0.ConstProp.diff
54
pub fn fn0() -> bool {
5+
// CHECK-LABEL: fn fn0(
6+
// CHECK: debug pair => [[pair:_.*]];
7+
// CHECK: debug ptr => [[ptr:_.*]];
8+
// CHECK: debug ret => [[ret:_.*]];
9+
// CHECK: (*[[ptr]]) = const true;
10+
// CHECK-NOT: = const false;
11+
// CHECK-NOT: = const true;
12+
// CHECK: [[tmp:_.*]] = ([[pair]].1: bool);
13+
// CHECK-NOT: = const false;
14+
// CHECK-NOT: = const true;
15+
// CHECK: [[ret]] = Not(move [[tmp]]);
16+
// CHECK-NOT: = const false;
17+
// CHECK-NOT: = const true;
18+
// CHECK: _0 = [[ret]];
619
let mut pair = (1, false);
720
let ptr = core::ptr::addr_of_mut!(pair.1);
821
pair = (1, false);

tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.panic-abort.mir

Lines changed: 0 additions & 49 deletions
This file was deleted.

tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.panic-unwind.mir

Lines changed: 0 additions & 49 deletions
This file was deleted.

tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-abort.mir

Lines changed: 0 additions & 36 deletions
This file was deleted.

tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-unwind.mir

Lines changed: 0 additions & 36 deletions
This file was deleted.

tests/mir-opt/const_prop/aggregate.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
1-
// skip-filecheck
21
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
32
// unit-test: ConstProp
43
// compile-flags: -O
54

65
// EMIT_MIR aggregate.main.ConstProp.diff
7-
// EMIT_MIR aggregate.main.PreCodegen.after.mir
86
fn main() {
7+
// CHECK-LABEL: fn main(
8+
// CHECK: debug x => [[x:_.*]];
9+
// CHECK-NOT: = Add(
10+
// CHECK: [[x]] = const 1_u8;
11+
// CHECK-NOT: = Add(
12+
// CHECK: foo(const 1_u8)
913
let x = (0, 1, 2).1 + 0;
1014
foo(x);
1115
}
1216

17+
// Verify that we still propagate if part of the aggregate is not known.
1318
// EMIT_MIR aggregate.foo.ConstProp.diff
14-
// EMIT_MIR aggregate.foo.PreCodegen.after.mir
1519
fn foo(x: u8) {
16-
// Verify that we still propagate if part of the aggregate is not known.
20+
// CHECK-LABEL: fn foo(
21+
// CHECK: debug first => [[first:_.*]];
22+
// CHECK: debug second => [[second:_.*]];
23+
// CHECK-NOT: = Add(
24+
// CHECK: [[first]] = const 1_i32;
25+
// CHECK-NOT: = Add(
26+
// CHECK: [[second]] = const 3_i32;
1727
let first = (0, x).0 + 1;
1828
let second = (x, 1).1 + 2;
1929
}
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
// skip-filecheck
2-
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
31
// unit-test: ConstProp
2+
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
43
// EMIT_MIR_FOR_EACH_BIT_WIDTH
54

65
// EMIT_MIR array_index.main.ConstProp.diff
76
fn main() {
7+
// CHECK-LABEL: fn main(
8+
// CHECK: debug x => [[x:_.*]];
9+
// CHECK: [[x]] = const 2_u32;
810
let x: u32 = [0, 1, 2, 3][2];
911
}
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
// skip-filecheck
2-
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
31
// unit-test: ConstProp
2+
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
3+
44
// EMIT_MIR bad_op_div_by_zero.main.ConstProp.diff
55
#[allow(unconditional_panic)]
66
fn main() {
7+
// CHECK-LABEL: fn main(
8+
// CHECK: debug y => [[y:_.*]];
9+
// CHECK: debug _z => [[z:_.*]];
10+
// CHECK: assert(!const true, "attempt to divide `{}` by zero", const 1_i32)
11+
// CHECK: assert(!const false, "attempt to compute `{} / {}`, which would overflow", const 1_i32, const 0_i32)
12+
// CHECK: [[z]] = Div(const 1_i32, const 0_i32);
713
let y = 0;
814
let _z = 1 / y;
915
}
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
// skip-filecheck
21
// unit-test: ConstProp
32
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
3+
44
// EMIT_MIR bad_op_mod_by_zero.main.ConstProp.diff
55
#[allow(unconditional_panic)]
66
fn main() {
7+
// CHECK-LABEL: fn main(
8+
// CHECK: debug y => [[y:_.*]];
9+
// CHECK: debug _z => [[z:_.*]];
10+
// CHECK: assert(!const true, "attempt to calculate the remainder of `{}` with a divisor of
11+
// zero", const 1_i32)
12+
// CHECK: assert(!const false, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, const 0_i32)
13+
// CHECK: [[z]] = Rem(const 1_i32, const 0_i32);
714
let y = 0;
815
let _z = 1 % y;
916
}

tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
// skip-filecheck
21
// unit-test: ConstProp
32
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
43
// EMIT_MIR_FOR_EACH_BIT_WIDTH
54

65
// EMIT_MIR bad_op_unsafe_oob_for_slices.main.ConstProp.diff
76
#[allow(unconditional_panic)]
87
fn main() {
8+
// CHECK-LABEL: fn main(
9+
// CHECK: debug a => [[a:_.*]];
10+
// CHECK: debug _b => [[b:_.*]];
11+
// CHECK: [[b]] = (*[[a]])[3 of 4];
912
let a: *const [_] = &[1, 2, 3];
1013
unsafe {
1114
let _b = (*a)[3];

0 commit comments

Comments
 (0)