diff options
| author | Scott McMurray <scottmcm@users.noreply.github.com> | 2023-03-12 13:23:22 -0700 |
|---|---|---|
| committer | Scott McMurray <scottmcm@users.noreply.github.com> | 2023-03-12 13:23:22 -0700 |
| commit | 1f70bb8c43054d3948ffb579ba3809822a889c62 (patch) | |
| tree | 2d0e612f0f3beb6d769659659c038f206a89a56b | |
| parent | 0b96fee34315b75c8f05ce338d3beb6c85772056 (diff) | |
| download | rust-1f70bb8c43054d3948ffb579ba3809822a889c62.tar.gz rust-1f70bb8c43054d3948ffb579ba3809822a889c62.zip | |
Add a codegen test to confirm this fixes 73258
| -rw-r--r-- | tests/codegen/issues/issue-73258.rs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/codegen/issues/issue-73258.rs b/tests/codegen/issues/issue-73258.rs new file mode 100644 index 00000000000..0134f929b29 --- /dev/null +++ b/tests/codegen/issues/issue-73258.rs @@ -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(); +} |
