forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#115591 - djkoloski:issue_115385, r=cuviper Add regression test for LLVM 17-rc3 miscompile Closes rust-lang#115385, see that issue for more details.
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// compile-flags: -O -Ccodegen-units=1 | ||
|
||
#![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); | ||
fn bar(); | ||
} | ||
|
||
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 | ||
unsafe { | ||
bar(); | ||
} | ||
} | ||
} |