Debian Codegraph @

llvm-project/llvm/projects/llvm-spirv/test/extensions/INTEL/SPV_INTEL_function_pointers/referenced-indirectly.ll

raw
1 ; RUN: llvm-as -opaque-pointers=0 %s -o %t.bc
2 ; RUN: llvm-spirv %t.bc -opaque-pointers=0 -spirv-text --spirv-ext=+SPV_INTEL_function_pointers -o %t.spt
3 ; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
4 ; RUN: llvm-spirv %t.bc -opaque-pointers=0 --spirv-ext=+SPV_INTEL_function_pointers -o %t.spv
5 ; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o %t.r.bc
6 ; RUN: llvm-dis %t.r.bc -o %t.r.ll
7 ; RUN: FileCheck < %t.r.ll %s --check-prefix=CHECK-LLVM
8 ;
9 ; Generated from:
10 ; __attribute__((referenced_indirectly))
11 ; int foo(int arg) {
12 ; return arg + 10;
13 ; }
14 ;
15 ; void __kernel test(__global int *data, int input) {
16 ; int (__constant *fp)(int) = &foo;
17 ;
18 ; *data = fp(input);
19 ; }
20 ;
21 ; CHECK-SPIRV: Capability FunctionPointersINTEL
22 ; CHECK-SPIRV: Capability IndirectReferencesINTEL
23 ; CHECK-SPIRV: Extension "SPV_INTEL_function_pointers"
24 ;
25 ; CHECK-SPIRV: Name [[FOO_ID:[0-9]+]] "foo"
26 ; CHECK-SPIRV: Decorate [[FOO_ID]] ReferencedIndirectlyINTEL
27 ; CHECK-SPIRV: Function {{[0-9]+}} [[FOO_ID]]
28 ;
29 ; CHECK-LLVM: define spir_func i32 @foo(i32 %arg) #[[ATTRS:[0-9]+]]
30 ; CHECK-LLVM: attributes #[[ATTRS]] = {{.*}} "referenced-indirectly"
31
32 target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
33 target triple = "spir64-unknown-unknown"
34
35 ; Function Attrs: convergent noinline nounwind optnone
36 define spir_func i32 @foo(i32 %arg) #0 {
37 entry:
38 %arg.addr = alloca i32, align 4
39 store i32 %arg, i32* %arg.addr, align 4
40 %0 = load i32, i32* %arg.addr, align 4
41 %add = add nsw i32 %0, 10
42 ret i32 %add
43 }
44
45 ; Function Attrs: convergent noinline nounwind optnone
46 define spir_kernel void @test(i32 addrspace(1)* %data, i32 %input) #1 !kernel_arg_addr_space !1 !kernel_arg_access_qual !5 !kernel_arg_type !6 !kernel_arg_base_type !6 !kernel_arg_type_qual !7 {
47 entry:
48 %data.addr = alloca i32 addrspace(1)*, align 8
49 %input.addr = alloca i32, align 4
50 %fp = alloca i32 (i32)*, align 8
51 store i32 addrspace(1)* %data, i32 addrspace(1)** %data.addr, align 8
52 store i32 %input, i32* %input.addr, align 4
53 store i32 (i32)* @foo, i32 (i32)** %fp, align 8
54 %0 = load i32 (i32)*, i32 (i32)** %fp, align 8
55 %1 = load i32, i32* %input.addr, align 4
56 %call = call spir_func i32 %0(i32 %1) #2
57 %2 = load i32 addrspace(1)*, i32 addrspace(1)** %data.addr, align 8
58 store i32 %call, i32 addrspace(1)* %2, align 4
59 ret void
60 }
61
62 attributes #0 = { convergent noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "denorms-are-zero"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" "referenced-indirectly" }
63 attributes #1 = { convergent noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "denorms-are-zero"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "uniform-work-group-size"="true" "unsafe-fp-math"="false" "use-soft-float"="false" }
64 attributes #2 = { convergent }
65
66 !llvm.module.flags = !{!0}
67 !opencl.ocl.version = !{!1}
68 !opencl.spir.version = !{!2}
69 !opencl.used.extensions = !{!3}
70 !opencl.used.optional.core.features = !{!3}
71 !opencl.compiler.options = !{!3}
72 !llvm.ident = !{!4}
73
74 !0 = !{i32 1, !"wchar_size", i32 4}
75 !1 = !{i32 1, i32 0}
76 !2 = !{i32 1, i32 2}
77 !3 = !{}
78 !4 = !{!"clang version 7.0.0 "}
79 !5 = !{!"none", !"none"}
80 !6 = !{!"int*", !"int"}
81 !7 = !{!"", !""}
82