xref: /llvm-project/clang/test/CodeGenSYCL/functionptr-addrspace.cpp (revision 7c1d9b15eee3a34678addab2bab66f3020ac0753)
1 // RUN: %clang_cc1 -fsycl-is-device -triple spir64 -verify -emit-llvm %s -o - | FileCheck %s
2 
3 // expected-no-diagnostics
4 
5 template <typename Name, typename Func>
kernel_single_task(const Func & kernelFunc)6 __attribute__((sycl_kernel)) void kernel_single_task(const Func &kernelFunc) {
7   kernelFunc();
8 }
9 
10 // CHECK: define dso_local spir_func{{.*}}invoke_function{{.*}}(ptr noundef %fptr, ptr addrspace(4) noundef %ptr)
invoke_function(int (* fptr)(),int * ptr)11 void invoke_function(int (*fptr)(), int *ptr) {}
12 
f()13 int f() { return 0; }
14 
main()15 int main() {
16   kernel_single_task<class fake_kernel>([=]() {
17     int (*p)() = f;
18     int (&r)() = *p;
19     int a = 10;
20     invoke_function(p, &a);
21     invoke_function(r, &a);
22     invoke_function(f, &a);
23   });
24   return 0;
25 }
26