From 259a7a75ae67a7cafcb0db324f66af054e7a3600 Mon Sep 17 00:00:00 2001 From: David Venhoek Date: Sat, 25 Jun 2022 16:40:41 +0200 Subject: [PATCH] Added test for const arg lifetimes suggested by erikdesjardins. --- .../issue-98156-const-arg-temp-lifetime.rs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/test/codegen/issue-98156-const-arg-temp-lifetime.rs diff --git a/src/test/codegen/issue-98156-const-arg-temp-lifetime.rs b/src/test/codegen/issue-98156-const-arg-temp-lifetime.rs new file mode 100644 index 00000000000..12ace5fff6b --- /dev/null +++ b/src/test/codegen/issue-98156-const-arg-temp-lifetime.rs @@ -0,0 +1,27 @@ +// This test checks that temporaries for indirectly-passed arguments get lifetime markers. + +// compile-flags: -O -C no-prepopulate-passes -Zmir-opt-level=0 + +#![crate_type = "lib"] + +extern "Rust" { + fn f(x: [u8; 1024]); +} + +const A: [u8; 1024] = [0; 1024]; + +// CHECK-LABEL: @const_arg_indirect +#[no_mangle] +pub unsafe fn const_arg_indirect() { + // Ensure that the live ranges for the two argument temporaries don't overlap. + + // CHECK: call void @llvm.lifetime.start + // CHECK: call void @f + // CHECK: call void @llvm.lifetime.end + // CHECK: call void @llvm.lifetime.start + // CHECK: call void @f + // CHECK: call void @llvm.lifetime.end + + f(A); + f(A); +}