Add a codegen test to confirm this fixes 73258
This commit is contained in:
parent
0b96fee343
commit
1f70bb8c43
1 changed files with 38 additions and 0 deletions
38
tests/codegen/issues/issue-73258.rs
Normal file
38
tests/codegen/issues/issue-73258.rs
Normal file
|
@ -0,0 +1,38 @@
|
|||
// compile-flags: -O
|
||||
// ignore-debug (the extra assertions get in the way)
|
||||
|
||||
#![crate_type = "lib"]
|
||||
|
||||
// Adapted from <https://github.com/rust-lang/rust/issues/73258#issue-637346014>
|
||||
|
||||
#[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();
|
||||
}
|
Loading…
Add table
Reference in a new issue