Skip to content

Commit 64da730

Browse files
add test for noop drop in landing pad
1 parent e4463b2 commit 64da730

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/test/codegen/unwind-landingpad-inline.rs

+18-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
#![crate_type = "lib"]
44

55
// This test checks that we can inline drop_in_place in
6-
// unwind landing pads. Without this, the box pointers escape,
6+
// unwind landing pads.
7+
8+
// Without inlining, the box pointers escape via the call to drop_in_place,
79
// and LLVM will not optimize out the pointer comparison.
10+
// With inlining, everything should be optimized out.
811
// See https://github.com/rust-lang/rust/issues/46515
9-
10-
// Everything should be optimized out.
1112
// CHECK-LABEL: @check_no_escape_in_landingpad
1213
// CHECK: start:
1314
// CHECK-NEXT: ret void
@@ -20,3 +21,17 @@ pub fn check_no_escape_in_landingpad(f: fn()) {
2021
f();
2122
}
2223
}
24+
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
30+
// CHECK: start:
31+
// CHECK-NEXT: call void %g()
32+
// CHECK-NEXT: ret void
33+
#[no_mangle]
34+
pub fn check_eliminate_noop_drop(g: fn()) {
35+
let _var = String::new();
36+
g();
37+
}

0 commit comments

Comments
 (0)