File: lifetime.ll

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.6-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,304 kB
  • sloc: cpp: 7,438,677; ansic: 1,393,822; asm: 1,012,926; python: 241,650; f90: 86,635; objc: 75,479; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (64 lines) | stat: -rw-r--r-- 2,911 bytes parent folder | download | duplicates (2)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}

; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %}

; CHECK-DAG: %[[#Char:]] = OpTypeInt 8 0
; CHECK-DAG: %[[#PtrChar:]] = OpTypePointer Function %[[#Char]]

%tprange = type { %tparray }
%tparray = type { [2 x i64] }

; CHECK: OpFunction
; CHECK: %[[#FooVar:]] = OpVariable
; CHECK: %[[#Casted1:]] = OpBitcast %[[#PtrChar]] %[[#FooVar]]
; CHECK: OpLifetimeStart %[[#Casted1]], 72
; CHECK: OpCopyMemorySized
; CHECK: OpBitcast
; CHECK: OpInBoundsPtrAccessChain
; CHECK: %[[#Casted2:]] = OpBitcast %[[#PtrChar]] %[[#FooVar]]
; CHECK: OpLifetimeStop %[[#Casted2]], 72
define spir_func void @foo(ptr noundef byval(%tprange) align 8 %_arg_UserRange) {
  %RoundedRangeKernel = alloca %tprange, align 8
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %RoundedRangeKernel)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %RoundedRangeKernel, ptr align 8 %_arg_UserRange, i64 16, i1 false)
  %KernelFunc = getelementptr inbounds i8, ptr %RoundedRangeKernel, i64 16
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %RoundedRangeKernel)
  ret void
}

; CHECK: OpFunction
; CHECK: %[[#BarVar:]] = OpVariable
; CHECK: OpLifetimeStart %[[#BarVar]], 0
; CHECK: OpCopyMemorySized
; CHECK: OpBitcast
; CHECK: OpInBoundsPtrAccessChain
; CHECK: OpLifetimeStop %[[#BarVar]], 0
define spir_func void @bar(ptr noundef byval(%tprange) align 8 %_arg_UserRange) {
  %RoundedRangeKernel = alloca %tprange, align 8
  call void @llvm.lifetime.start.p0(i64 -1, ptr nonnull %RoundedRangeKernel)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %RoundedRangeKernel, ptr align 8 %_arg_UserRange, i64 16, i1 false)
  %KernelFunc = getelementptr inbounds i8, ptr %RoundedRangeKernel, i64 16
  call void @llvm.lifetime.end.p0(i64 -1, ptr nonnull %RoundedRangeKernel)
  ret void
}

; CHECK: OpFunction
; CHECK: %[[#TestVar:]] = OpVariable
; CHECK: OpLifetimeStart %[[#TestVar]], 1
; CHECK: OpCopyMemorySized
; CHECK: OpInBoundsPtrAccessChain
; CHECK: OpLifetimeStop %[[#TestVar]], 1
define spir_func void @test(ptr noundef align 8 %_arg) {
  %var = alloca i8, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %var)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %var, ptr align 8 %_arg, i64 1, i1 false)
  %KernelFunc = getelementptr inbounds i8, ptr %var, i64 0
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %var)
  ret void
}

declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)