@@ -2122,15 +2122,18 @@ class SyclKernelDeclCreator : public SyclKernelFieldHandler {
2122
2122
2123
2123
bool handlePointerType (FieldDecl *FD, QualType FieldTy) final {
2124
2124
// USM allows to use raw pointers instead of buffers/accessors, but these
2125
- // pointers point to the specially allocated memory. For pointer fields we
2126
- // add a kernel argument with the same type as field but global address
2127
- // space, because OpenCL requires it.
2125
+ // pointers point to the specially allocated memory. For pointer fields,
2126
+ // except for function pointer fields, we add a kernel argument with the
2127
+ // same type as field but global address space, because OpenCL requires it.
2128
+ // Function pointers should have program address space. This is set in
2129
+ // CodeGen.
2128
2130
QualType PointeeTy = FieldTy->getPointeeType ();
2129
2131
Qualifiers Quals = PointeeTy.getQualifiers ();
2130
2132
auto AS = Quals.getAddressSpace ();
2131
2133
// Leave global_device and global_host address spaces as is to help FPGA
2132
2134
// device in memory allocations
2133
- if (AS != LangAS::sycl_global_device && AS != LangAS::sycl_global_host)
2135
+ if (!PointeeTy->isFunctionType () && AS != LangAS::sycl_global_device &&
2136
+ AS != LangAS::sycl_global_host)
2134
2137
Quals.setAddressSpace (LangAS::sycl_global);
2135
2138
PointeeTy = SemaRef.getASTContext ().getQualifiedType (
2136
2139
PointeeTy.getUnqualifiedType (), Quals);
0 commit comments