1; RUN: opt -inline %s -S -o - | FileCheck %s 2 3declare void @llvm.lifetime.start(i64, i8*) 4declare void @llvm.lifetime.end(i64, i8*) 5 6define void @helper_both_markers() { 7 %a = alloca i8 8 call void @llvm.lifetime.start(i64 1, i8* %a) 9 call void @llvm.lifetime.end(i64 1, i8* %a) 10 ret void 11} 12 13define void @test_both_markers() { 14; CHECK: @test_both_markers 15; CHECK: llvm.lifetime.start(i64 1 16; CHECK-NEXT: llvm.lifetime.end(i64 1 17 call void @helper_both_markers() 18; CHECK-NEXT: llvm.lifetime.start(i64 1 19; CHECK-NEXT: llvm.lifetime.end(i64 1 20 call void @helper_both_markers() 21; CHECK-NEXT: ret void 22 ret void 23} 24 25;; Without this, the inliner will simplify out @test_no_marker before adding 26;; any lifetime markers. 27declare void @use(i8* %a) 28 29define void @helper_no_markers() { 30 %a = alloca i8 31 call void @use(i8* %a) 32 ret void 33} 34 35;; We can't use CHECK-NEXT because there's an extra call void @use in between. 36;; Instead, we use CHECK-NOT to verify that there are no other lifetime calls. 37define void @test_no_marker() { 38; CHECK: @test_no_marker 39; CHECK-NOT: lifetime 40; CHECK: llvm.lifetime.start(i64 -1 41; CHECK-NOT: lifetime 42; CHECK: llvm.lifetime.end(i64 -1 43 call void @helper_no_markers() 44; CHECK-NOT: lifetime 45; CHECK: llvm.lifetime.start(i64 -1 46; CHECK-NOT: lifetime 47; CHECK: llvm.lifetime.end(i64 -1 48 call void @helper_no_markers() 49; CHECK-NOT: lifetime 50; CHECK: ret void 51 ret void 52} 53 54define void @helper_two_casts() { 55 %a = alloca i32 56 %b = bitcast i32* %a to i8* 57 call void @llvm.lifetime.start(i64 4, i8* %b) 58 %c = bitcast i32* %a to i8* 59 call void @llvm.lifetime.end(i64 4, i8* %c) 60 ret void 61} 62 63define void @test_two_casts() { 64; CHECK: @test_two_casts 65; CHECK-NOT: lifetime 66; CHECK: llvm.lifetime.start(i64 4 67; CHECK-NOT: lifetime 68; CHECK: llvm.lifetime.end(i64 4 69 call void @helper_two_casts() 70; CHECK-NOT: lifetime 71; CHECK: llvm.lifetime.start(i64 4 72; CHECK-NOT: lifetime 73; CHECK: llvm.lifetime.end(i64 4 74 call void @helper_two_casts() 75; CHECK-NOT: lifetime 76; CHECK: ret void 77 ret void 78} 79