1 ; RUN: opt -inline -S < %s | FileCheck %s
2 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
4 declare void @llvm.lifetime.start(i64, i8*)
5 declare void @llvm.lifetime.end(i64, i8*)
7 define void @helper_both_markers() {
9 ; Size in llvm.lifetime.start / llvm.lifetime.end differs from
10 ; allocation size. We should use the former.
11 call void @llvm.lifetime.start(i64 2, i8* %a)
12 call void @llvm.lifetime.end(i64 2, i8* %a)
16 define void @test_both_markers() {
17 ; CHECK: @test_both_markers
18 ; CHECK: llvm.lifetime.start(i64 2
19 ; CHECK-NEXT: llvm.lifetime.end(i64 2
20 call void @helper_both_markers()
21 ; CHECK-NEXT: llvm.lifetime.start(i64 2
22 ; CHECK-NEXT: llvm.lifetime.end(i64 2
23 call void @helper_both_markers()
24 ; CHECK-NEXT: ret void
28 ;; Without this, the inliner will simplify out @test_no_marker before adding
29 ;; any lifetime markers.
30 declare void @use(i8* %a)
32 define void @helper_no_markers() {
33 %a = alloca i8 ; Allocation size is 1 byte.
34 call void @use(i8* %a)
38 ;; We can't use CHECK-NEXT because there's an extra call void @use in between.
39 ;; Instead, we use CHECK-NOT to verify that there are no other lifetime calls.
40 define void @test_no_marker() {
41 ; CHECK: @test_no_marker
43 ; CHECK: llvm.lifetime.start(i64 1
45 ; CHECK: llvm.lifetime.end(i64 1
46 call void @helper_no_markers()
48 ; CHECK: llvm.lifetime.start(i64 1
50 ; CHECK: llvm.lifetime.end(i64 1
51 call void @helper_no_markers()
57 define void @helper_two_casts() {
59 %b = bitcast i32* %a to i8*
60 call void @llvm.lifetime.start(i64 4, i8* %b)
61 %c = bitcast i32* %a to i8*
62 call void @llvm.lifetime.end(i64 4, i8* %c)
66 define void @test_two_casts() {
67 ; CHECK: @test_two_casts
69 ; CHECK: llvm.lifetime.start(i64 4
71 ; CHECK: llvm.lifetime.end(i64 4
72 call void @helper_two_casts()
74 ; CHECK: llvm.lifetime.start(i64 4
76 ; CHECK: llvm.lifetime.end(i64 4
77 call void @helper_two_casts()
83 define void @helper_arrays_alloca() {
84 %a = alloca [10 x i32], align 16
85 %1 = bitcast [10 x i32]* %a to i8*
86 call void @use(i8* %1)
90 define void @test_arrays_alloca() {
91 ; CHECK: @test_arrays_alloca
93 ; CHECK: llvm.lifetime.start(i64 40,
95 ; CHECK: llvm.lifetime.end(i64 40,
96 call void @helper_arrays_alloca()