2024-02-22 06:10:29 -06:00
|
|
|
//@ compile-flags: -O
|
2023-03-12 15:23:22 -05:00
|
|
|
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
|
|
|
|
// Adapted from <https://github.com/rust-lang/rust/issues/73258#issue-637346014>
|
|
|
|
|
|
|
|
#[derive(Clone, Copy)]
|
|
|
|
#[repr(u8)]
|
|
|
|
pub enum Foo {
|
2024-05-28 23:11:20 -05:00
|
|
|
A,
|
|
|
|
B,
|
|
|
|
C,
|
|
|
|
D,
|
2023-03-12 15:23:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: @issue_73258(
|
|
|
|
#[no_mangle]
|
|
|
|
pub unsafe fn issue_73258(ptr: *const Foo) -> Foo {
|
|
|
|
// CHECK-NOT: icmp
|
|
|
|
// CHECK-NOT: call
|
|
|
|
// CHECK-NOT: br
|
|
|
|
// CHECK-NOT: select
|
|
|
|
|
|
|
|
// CHECK: %[[R:.+]] = load i8
|
|
|
|
// CHECK-SAME: !range !
|
|
|
|
|
|
|
|
// CHECK-NOT: icmp
|
|
|
|
// CHECK-NOT: call
|
|
|
|
// CHECK-NOT: br
|
|
|
|
// CHECK-NOT: select
|
|
|
|
|
|
|
|
// CHECK: ret i8 %[[R]]
|
|
|
|
|
|
|
|
// CHECK-NOT: icmp
|
|
|
|
// CHECK-NOT: call
|
|
|
|
// CHECK-NOT: br
|
|
|
|
// CHECK-NOT: select
|
|
|
|
let k: Option<Foo> = Some(ptr.read());
|
|
|
|
return k.unwrap();
|
|
|
|
}
|