diff options
| author | David Koloski <dkoloski@google.com> | 2023-09-06 02:21:56 +0000 |
|---|---|---|
| committer | David Koloski <dkoloski@google.com> | 2023-09-06 02:23:48 +0000 |
| commit | c18da3ccd4cca6295bba599324962a469aae9aa9 (patch) | |
| tree | 321dc20f6e5eceb282d3cd6234b0226247148ed6 /tests/codegen | |
| parent | ab45885dec2a6552cb060a5b7183653baaecd580 (diff) | |
| download | rust-c18da3ccd4cca6295bba599324962a469aae9aa9.tar.gz rust-c18da3ccd4cca6295bba599324962a469aae9aa9.zip | |
Add regression test for LLVM 17-rc3 miscompile
See #115385 for more details.
Diffstat (limited to 'tests/codegen')
| -rw-r--r-- | tests/codegen/issues/issue-115385.rs | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/codegen/issues/issue-115385.rs b/tests/codegen/issues/issue-115385.rs new file mode 100644 index 00000000000..773b3507f23 --- /dev/null +++ b/tests/codegen/issues/issue-115385.rs @@ -0,0 +1,50 @@ +// compile-flags: -O -Ccodegen-units=1 +// only-x86_64-unknown-linux-gnu + +#![crate_type = "lib"] + +#[repr(i64)] +pub enum Boolean { + False = 0, + True = 1, +} + +impl Clone for Boolean { + fn clone(&self) -> Self { + *self + } +} + +impl Copy for Boolean {} + +extern "C" { + fn set_value(foo: *mut i64); +} + +pub fn foo(x: bool) { + let mut foo = core::mem::MaybeUninit::<i64>::uninit(); + unsafe { + set_value(foo.as_mut_ptr()); + } + + if x { + let l1 = unsafe { *foo.as_mut_ptr().cast::<Boolean>() }; + if matches!(l1, Boolean::False) { + unsafe { + *foo.as_mut_ptr() = 0; + } + } + } + + let l2 = unsafe { *foo.as_mut_ptr() }; + if l2 == 2 { + // CHECK: call void @bar + bar(); + } +} + +#[no_mangle] +#[inline(never)] +pub fn bar() { + println!("Working correctly!"); +} |
