mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-08 09:38:26 +03:00
add test for noop drop in landing pad
This commit is contained in:
@@ -3,11 +3,12 @@
|
||||
#![crate_type = "lib"]
|
||||
|
||||
// This test checks that we can inline drop_in_place in
|
||||
// unwind landing pads. Without this, the box pointers escape,
|
||||
// and LLVM will not optimize out the pointer comparison.
|
||||
// See https://github.com/rust-lang/rust/issues/46515
|
||||
// unwind landing pads.
|
||||
|
||||
// Everything should be optimized out.
|
||||
// Without inlining, the box pointers escape via the call to drop_in_place,
|
||||
// and LLVM will not optimize out the pointer comparison.
|
||||
// With inlining, everything should be optimized out.
|
||||
// See https://github.com/rust-lang/rust/issues/46515
|
||||
// CHECK-LABEL: @check_no_escape_in_landingpad
|
||||
// CHECK: start:
|
||||
// CHECK-NEXT: ret void
|
||||
@@ -20,3 +21,17 @@ pub fn check_no_escape_in_landingpad(f: fn()) {
|
||||
f();
|
||||
}
|
||||
}
|
||||
|
||||
// Without inlining, the compiler can't tell that
|
||||
// dropping an empty string (in a landing pad) does nothing.
|
||||
// With inlining, the landing pad should be optimized out.
|
||||
// See https://github.com/rust-lang/rust/issues/87055
|
||||
// CHECK-LABEL: @check_eliminate_noop_drop
|
||||
// CHECK: start:
|
||||
// CHECK-NEXT: call void %g()
|
||||
// CHECK-NEXT: ret void
|
||||
#[no_mangle]
|
||||
pub fn check_eliminate_noop_drop(g: fn()) {
|
||||
let _var = String::new();
|
||||
g();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user