mirror of
https://github.com/allankoechke/rust.git
synced 2026-12-01 01:26:32 +00:00
43 lines
980 B
Rust
43 lines
980 B
Rust
//@ compile-flags: -Copt-level=3
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
// Adapted from <https://github.com/rust-lang/rust/issues/73258#issue-637346014>
|
|
// We explicitly match against `call{{.*}}(` because the emitted call may carry attributes (e.g.
|
|
// `ptrauth-calls`), which would otherwise make a plain `call` pattern too permissive.
|
|
|
|
#[derive(Clone, Copy)]
|
|
#[repr(u8)]
|
|
pub enum Foo {
|
|
A,
|
|
B,
|
|
C,
|
|
D,
|
|
}
|
|
|
|
// 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();
|
|
}
|