Skip to content

Commit 1f70bb8

Browse files
committed
Add a codegen test to confirm this fixes 73258
1 parent 0b96fee commit 1f70bb8

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/codegen/issues/issue-73258.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// compile-flags: -O
2+
// ignore-debug (the extra assertions get in the way)
3+
4+
#![crate_type = "lib"]
5+
6+
// Adapted from <https://github.com/rust-lang/rust/issues/73258#issue-637346014>
7+
8+
#[derive(Clone, Copy)]
9+
#[repr(u8)]
10+
pub enum Foo {
11+
A, B, C, D,
12+
}
13+
14+
// CHECK-LABEL: @issue_73258(
15+
#[no_mangle]
16+
pub unsafe fn issue_73258(ptr: *const Foo) -> Foo {
17+
// CHECK-NOT: icmp
18+
// CHECK-NOT: call
19+
// CHECK-NOT: br
20+
// CHECK-NOT: select
21+
22+
// CHECK: %[[R:.+]] = load i8
23+
// CHECK-SAME: !range !
24+
25+
// CHECK-NOT: icmp
26+
// CHECK-NOT: call
27+
// CHECK-NOT: br
28+
// CHECK-NOT: select
29+
30+
// CHECK: ret i8 %[[R]]
31+
32+
// CHECK-NOT: icmp
33+
// CHECK-NOT: call
34+
// CHECK-NOT: br
35+
// CHECK-NOT: select
36+
let k: Option<Foo> = Some(ptr.read());
37+
return k.unwrap();
38+
}

0 commit comments

Comments
 (0)