add codegen tests for some issues closed by LLVM 12
This commit is contained in:
parent
66ec64ccf3
commit
938637033c
|
@ -0,0 +1,27 @@
|
||||||
|
// min-llvm-version: 12.0.0
|
||||||
|
// compile-flags: -O
|
||||||
|
#![crate_type = "lib"]
|
||||||
|
|
||||||
|
// Test that LLVM can eliminate the unreachable `All::None` branch.
|
||||||
|
|
||||||
|
pub enum All {
|
||||||
|
None,
|
||||||
|
Foo,
|
||||||
|
Bar,
|
||||||
|
}
|
||||||
|
|
||||||
|
// CHECK-LABEL: @issue_73031
|
||||||
|
#[no_mangle]
|
||||||
|
pub fn issue_73031(a: &mut All, q: i32) -> i32 {
|
||||||
|
*a = if q == 5 {
|
||||||
|
All::Foo
|
||||||
|
} else {
|
||||||
|
All::Bar
|
||||||
|
};
|
||||||
|
match *a {
|
||||||
|
// CHECK-NOT: panic
|
||||||
|
All::None => panic!(),
|
||||||
|
All::Foo => 1,
|
||||||
|
All::Bar => 2,
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
// min-llvm-version: 12.0.0
|
||||||
|
// compile-flags: -O
|
||||||
|
#![crate_type = "lib"]
|
||||||
|
|
||||||
|
// Test that LLVM can eliminate the impossible `i == 0` check.
|
||||||
|
|
||||||
|
// CHECK-LABEL: @issue_75546
|
||||||
|
#[no_mangle]
|
||||||
|
pub fn issue_75546() {
|
||||||
|
let mut i = 1u32;
|
||||||
|
while i < u32::MAX {
|
||||||
|
// CHECK-NOT: panic
|
||||||
|
if i == 0 { panic!(); }
|
||||||
|
i += 1;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
// min-llvm-version: 12.0.0
|
||||||
|
// compile-flags: -O
|
||||||
|
#![crate_type = "lib"]
|
||||||
|
|
||||||
|
// Test that LLVM can eliminate the unreachable `Variant::Zero` branch.
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Eq, PartialEq)]
|
||||||
|
pub enum Variant {
|
||||||
|
Zero,
|
||||||
|
One,
|
||||||
|
Two,
|
||||||
|
}
|
||||||
|
|
||||||
|
extern {
|
||||||
|
fn exf1();
|
||||||
|
fn exf2();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub static mut GLOBAL: Variant = Variant::Zero;
|
||||||
|
|
||||||
|
// CHECK-LABEL: @issue_77812
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe fn issue_77812() {
|
||||||
|
let g = GLOBAL;
|
||||||
|
if g != Variant::Zero {
|
||||||
|
match g {
|
||||||
|
Variant::One => exf1(),
|
||||||
|
Variant::Two => exf2(),
|
||||||
|
// CHECK-NOT: panic
|
||||||
|
Variant::Zero => panic!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue