Debian Codegraph @

llvm-project/llvm/projects/llvm-spirv/test/llvm-intrinsics/lifetime.ll

raw
1 ; RUN: llvm-as %s -o %t.bc
2 ; RUN: llvm-spirv %t.bc -o %t.spv
3 ; RUN: spirv-val %t.spv
4 ; RUN: llvm-spirv %t.spv -to-text -o %t.spt
5 ; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
6 ; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o %t.spv.bc
7 ; RUN: llvm-dis < %t.spv.bc | FileCheck %s --check-prefix=CHECK-LLVM
8
9 ; CHECK-SPIRV: 3 LifetimeStart [[tmp:[0-9]+]] 0
10 ; CHECK-SPIRV: 3 LifetimeStop [[tmp]] 0
11
12 ; CHECK-LLVM: %[[tmp1:[0-9]+]] = bitcast ptr %{{[0-9]+}} to ptr
13 ; CHECK-LLVM: call void @llvm.lifetime.start.p0(i64 -1, ptr %[[tmp1]])
14 ; CHECK-LLVM: call void @llvm.lifetime.end.p0(i64 -1, ptr %[[tmp1]])
15 ; CHECK-LLVM: declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture)
16 ; CHECK-LLVM: declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)
17
18 ; ModuleID = 'main'
19 target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
20 target triple = "spir64-unknown-unknown"
21
22 %class.anon = type { i8 }
23
24 ; Function Attrs: nounwind
25 define spir_kernel void @lifetime_simple(i32 addrspace(1)* nocapture %res, i32 addrspace(1)* nocapture %lhs, i32 addrspace(1)* nocapture %rhs) #0 !kernel_arg_addr_space !1 !kernel_arg_access_qual !2 !kernel_arg_type !3 !kernel_arg_base_type !5 !kernel_arg_type_qual !4 {
26 %1 = alloca i32
27 %2 = call spir_func i64 @_Z13get_global_idj(i32 0) #1
28 %3 = shl i64 %2, 32
29 %4 = ashr exact i64 %3, 32
30 %5 = getelementptr inbounds i32, i32 addrspace(1)* %lhs, i64 %4
31 %6 = load i32, i32 addrspace(1)* %5, align 4
32 %7 = getelementptr inbounds i32, i32 addrspace(1)* %rhs, i64 %4
33 %8 = load i32, i32 addrspace(1)* %7, align 4
34 %9 = sub i32 %6, %8
35 %10 = bitcast i32* %1 to i8*
36 call void @llvm.lifetime.start.p0i8(i64 -1, i8* %10)
37 store i32 %9, i32* %1
38 %11 = load i32, i32* %1
39 call void @llvm.lifetime.end.p0i8(i64 -1, i8* %10)
40 %12 = getelementptr inbounds i32, i32 addrspace(1)* %res, i64 %4
41 store i32 %11, i32 addrspace(1)* %12, align 4
42 ret void
43 }
44
45 define spir_kernel void @lifetime_sized() #0 !kernel_arg_addr_space !8 !kernel_arg_access_qual !8 !kernel_arg_type !8 !kernel_arg_base_type !8 !kernel_arg_type_qual !8 {
46 entry:
47 %0 = alloca %class.anon, align 1
48 %1 = bitcast %class.anon* %0 to i8*
49 call void @llvm.lifetime.start.p0i8(i64 1, i8* %1) #0
50 call spir_func void @foo(%class.anon* %0)
51 %2 = bitcast %class.anon* %0 to i8*
52 call void @llvm.lifetime.end.p0i8(i64 1, i8* %2) #0
53 ret void
54 }
55
56 ; Function Attrs: inlinehint nounwind
57 define internal spir_func void @foo(%class.anon* %this) #0 align 2 {
58 entry:
59 %this.addr = alloca %class.anon*, align 8
60 store %class.anon* %this, %class.anon** %this.addr, align 8
61 %this1 = load %class.anon*, %class.anon** %this.addr, align 8
62 ret void
63 }
64
65 ; Function Attrs: nounwind
66 declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #0
67
68 ; Function Attrs: nounwind
69 declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #0
70
71 ; Function Attrs: nounwind readnone
72 declare spir_func i64 @_Z13get_global_idj(i32) #1
73
74 attributes #0 = { nounwind }
75 attributes #1 = { nounwind readnone }
76
77 !opencl.enable.FP_CONTRACT = !{}
78 !spirv.Source = !{!6}
79 !opencl.spir.version = !{!7}
80 !opencl.ocl.version = !{!7}
81 !opencl.used.extensions = !{!8}
82 !opencl.used.optional.core.features = !{!8}
83 !spirv.Generator = !{!9}
84
85 !1 = !{i32 1, i32 1, i32 1}
86 !2 = !{!"none", !"none", !"none"}
87 !3 = !{!"int*", !"int*", !"int*"}
88 !4 = !{!"", !"", !""}
89 !5 = !{!"int*", !"int*", !"int*"}
90 !6 = !{i32 3, i32 102000}
91 !7 = !{i32 1, i32 2}
92 !8 = !{}
93 !9 = !{i16 7, i16 0}