1 ; RUN: opt -inline -S < %s | FileCheck %s
2 ; RUN: opt -passes='cgscc(inline)' -S < %s | FileCheck %s
3 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"
5 declare void @llvm.lifetime.start.p0i8(i64, i8*)
6 declare void @llvm.lifetime.end.p0i8(i64, i8*)
8 define void @helper_both_markers() {
10 ; Size in llvm.lifetime.start / llvm.lifetime.end differs from
11 ; allocation size. We should use the former.
12 call void @llvm.lifetime.start.p0i8(i64 2, i8* %a)
13 call void @llvm.lifetime.end.p0i8(i64 2, i8* %a)
17 define void @test_both_markers() {
18 ; CHECK-LABEL: @test_both_markers(
19 ; CHECK: llvm.lifetime.start.p0i8(i64 2
20 ; CHECK-NEXT: llvm.lifetime.end.p0i8(i64 2
21 call void @helper_both_markers()
22 ; CHECK-NEXT: llvm.lifetime.start.p0i8(i64 2
23 ; CHECK-NEXT: llvm.lifetime.end.p0i8(i64 2
24 call void @helper_both_markers()
25 ; CHECK-NEXT: ret void
29 ;; Without this, the inliner will simplify out @test_no_marker before adding
30 ;; any lifetime markers.
31 declare void @use(i8* %a)
33 define void @helper_no_markers() {
34 %a = alloca i8 ; Allocation size is 1 byte.
35 call void @use(i8* %a)
39 ;; We can't use CHECK-NEXT because there's an extra call void @use in between.
40 ;; Instead, we use CHECK-NOT to verify that there are no other lifetime calls.
41 define void @test_no_marker() {
42 ; CHECK-LABEL: @test_no_marker(
44 ; CHECK: llvm.lifetime.start.p0i8(i64 1
46 ; CHECK: llvm.lifetime.end.p0i8(i64 1
47 call void @helper_no_markers()
49 ; CHECK: llvm.lifetime.start.p0i8(i64 1
51 ; CHECK: llvm.lifetime.end.p0i8(i64 1
52 call void @helper_no_markers()
58 define void @helper_two_casts() {
60 %b = bitcast i32* %a to i8*
61 call void @llvm.lifetime.start.p0i8(i64 4, i8* %b)
62 %c = bitcast i32* %a to i8*
63 call void @llvm.lifetime.end.p0i8(i64 4, i8* %c)
67 define void @test_two_casts() {
68 ; CHECK-LABEL: @test_two_casts(
70 ; CHECK: llvm.lifetime.start.p0i8(i64 4
72 ; CHECK: llvm.lifetime.end.p0i8(i64 4
73 call void @helper_two_casts()
75 ; CHECK: llvm.lifetime.start.p0i8(i64 4
77 ; CHECK: llvm.lifetime.end.p0i8(i64 4
78 call void @helper_two_casts()
84 define void @helper_arrays_alloca() {
85 %a = alloca [10 x i32], align 16
86 %1 = bitcast [10 x i32]* %a to i8*
87 call void @use(i8* %1)
91 define void @test_arrays_alloca() {
92 ; CHECK-LABEL: @test_arrays_alloca(
94 ; CHECK: llvm.lifetime.start.p0i8(i64 40,
96 ; CHECK: llvm.lifetime.end.p0i8(i64 40,
97 call void @helper_arrays_alloca()
103 %swift.error = type opaque
105 define void @helper_swifterror_alloca() {
107 %swifterror = alloca swifterror %swift.error*, align 8
108 store %swift.error* null, %swift.error** %swifterror, align 8
112 define void @test_swifterror_alloca() {
113 ; CHECK-LABEL: @test_swifterror_alloca(
114 ; CHECK-NOT: lifetime
115 call void @helper_swifterror_alloca()