Skip to content

Commit

Permalink
Added test for const arg lifetimes suggested by erikdesjardins.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidv1992 committed Jun 25, 2022
1 parent 8f529ab commit 259a7a7
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/test/codegen/issue-98156-const-arg-temp-lifetime.rs
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 259a7a7

Please sign in to comment.