1 // no-system-llvm: needs #92110 + patch for Rust alloc/dealloc functions
2 // compile-flags: -Copt-level=3
5 // This test checks that we can inline drop_in_place in
6 // unwind landing pads.
8 // Without inlining, the box pointers escape via the call to drop_in_place,
9 // and LLVM will not optimize out the pointer comparison.
10 // With inlining, everything should be optimized out.
11 // See https://github.com/rust-lang/rust/issues/46515
12 // CHECK-LABEL: @check_no_escape_in_landingpad
14 // CHECK-NEXT: ret void
16 pub fn check_no_escape_in_landingpad(f: fn()) {
17 let x = &*Box::new(0);
18 let y = &*Box::new(0);
20 if x as *const _ == y as *const _ {
25 // Without inlining, the compiler can't tell that
26 // dropping an empty string (in a landing pad) does nothing.
27 // With inlining, the landing pad should be optimized out.
28 // See https://github.com/rust-lang/rust/issues/87055
29 // CHECK-LABEL: @check_eliminate_noop_drop
31 // CHECK-NEXT: call void %g()
32 // CHECK-NEXT: ret void
34 pub fn check_eliminate_noop_drop(g: fn()) {
35 let _var = String::new();