summaryrefslogtreecommitdiffstats
path: root/tests/codegen/issues/issue-98156-const-arg-temp-lifetime.rs
blob: 12ace5fff6b6eb69285714c2efe6cc9dae5692c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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);
}