Skip to content

Commit 7a4904c

Browse files
authored
Rollup merge of #115591 - djkoloski:issue_115385, r=cuviper
Add regression test for LLVM 17-rc3 miscompile Closes #115385, see that issue for more details.
2 parents f3cc59b + ddd8878 commit 7a4904c

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// compile-flags: -O -Ccodegen-units=1
2+
3+
#![crate_type = "lib"]
4+
5+
#[repr(i64)]
6+
pub enum Boolean {
7+
False = 0,
8+
True = 1,
9+
}
10+
11+
impl Clone for Boolean {
12+
fn clone(&self) -> Self {
13+
*self
14+
}
15+
}
16+
17+
impl Copy for Boolean {}
18+
19+
extern "C" {
20+
fn set_value(foo: *mut i64);
21+
fn bar();
22+
}
23+
24+
pub fn foo(x: bool) {
25+
let mut foo = core::mem::MaybeUninit::<i64>::uninit();
26+
unsafe {
27+
set_value(foo.as_mut_ptr());
28+
}
29+
30+
if x {
31+
let l1 = unsafe { *foo.as_mut_ptr().cast::<Boolean>() };
32+
if matches!(l1, Boolean::False) {
33+
unsafe {
34+
*foo.as_mut_ptr() = 0;
35+
}
36+
}
37+
}
38+
39+
let l2 = unsafe { *foo.as_mut_ptr() };
40+
if l2 == 2 {
41+
// CHECK: call void @bar
42+
unsafe {
43+
bar();
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)