Skip to content

Commit 7626d22

Browse files
committed
Add a MIR test for integer methods in debug
1 parent f34ba77 commit 7626d22

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// MIR for `cast_and_add` after PreCodegen
2+
3+
fn cast_and_add(_1: i32) -> u32 {
4+
debug x => _1;
5+
let mut _0: u32;
6+
let mut _2: u32;
7+
8+
bb0: {
9+
_2 = core::num::<impl i32>::cast_unsigned(copy _1) -> [return: bb1, unwind unreachable];
10+
}
11+
12+
bb1: {
13+
_0 = core::num::<impl u32>::wrapping_add(move _2, const 42_u32) -> [return: bb2, unwind unreachable];
14+
}
15+
16+
bb2: {
17+
return;
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// MIR for `cast_and_add` after PreCodegen
2+
3+
fn cast_and_add(_1: i32) -> u32 {
4+
debug x => _1;
5+
let mut _0: u32;
6+
let mut _2: u32;
7+
8+
bb0: {
9+
_2 = core::num::<impl i32>::cast_unsigned(copy _1) -> [return: bb1, unwind continue];
10+
}
11+
12+
bb1: {
13+
_0 = core::num::<impl u32>::wrapping_add(move _2, const 42_u32) -> [return: bb2, unwind continue];
14+
}
15+
16+
bb2: {
17+
return;
18+
}
19+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@ compile-flags: -Copt-level=0 -Zmir-opt-level=1 -Cdebuginfo=limited
2+
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
3+
4+
#![crate_type = "lib"]
5+
6+
// EMIT_MIR integer_methods_debug.cast_and_add.PreCodegen.after.mir
7+
pub fn cast_and_add(x: i32) -> u32 {
8+
// CHECK-LABEL: fn cast_and_add(_1: i32) -> u32
9+
// CHECK: _2 = {{.+}}<impl i32>::cast_unsigned(copy _1)
10+
// CHECK: _0 = {{.+}}<impl u32>::wrapping_add(move _2, const 42_u32) ->
11+
x.cast_unsigned().wrapping_add(42)
12+
}

0 commit comments

Comments
 (0)