about summary refs log tree commit diff
path: root/src/test/codegen
diff options
context:
space:
mode:
authorErik Desjardins <erikdesjardins@users.noreply.github.com>2021-12-30 01:03:17 -0500
committerErik Desjardins <erikdesjardins@users.noreply.github.com>2021-12-30 01:03:17 -0500
commit64da730a41ac7df5fa8e03a82beb50abcdf5123e (patch)
treea17ef91c396879d66e4d461e38573121827423db /src/test/codegen
parente4463b2453f3b2665076e5daec23040976b8792e (diff)
downloadrust-64da730a41ac7df5fa8e03a82beb50abcdf5123e.tar.gz
rust-64da730a41ac7df5fa8e03a82beb50abcdf5123e.zip
add test for noop drop in landing pad
Diffstat (limited to 'src/test/codegen')
-rw-r--r--src/test/codegen/unwind-landingpad-inline.rs21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/test/codegen/unwind-landingpad-inline.rs b/src/test/codegen/unwind-landingpad-inline.rs
index 4f13b60b1f9..ce78d075dd0 100644
--- a/src/test/codegen/unwind-landingpad-inline.rs
+++ b/src/test/codegen/unwind-landingpad-inline.rs
@@ -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,
+// unwind landing pads.
+
+// 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
-
-// Everything should be optimized out.
 // 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();
+}