[PATCH] D111566: [SYCL] Fix function pointer address space
Elizabeth Andrews via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 11 10:57:55 PDT 2021
eandrews created this revision.
eandrews added reviewers: vlastik, dylanmckay, bader.
Herald added subscribers: Naghasan, Anastasia, ebevhan, yaxunl.
eandrews requested review of this revision.
Functions pointers should be created with program address space. This patch fixes a crash on lvalue reference to function pointer (in device code) when using oneAPI DPC++ compiler.
https://reviews.llvm.org/D111566
Files:
clang/lib/CodeGen/CodeGenTypes.cpp
Index: clang/lib/CodeGen/CodeGenTypes.cpp
===================================================================
--- clang/lib/CodeGen/CodeGenTypes.cpp
+++ clang/lib/CodeGen/CodeGenTypes.cpp
@@ -633,7 +633,9 @@
const ReferenceType *RTy = cast<ReferenceType>(Ty);
QualType ETy = RTy->getPointeeType();
llvm::Type *PointeeType = ConvertTypeForMem(ETy);
- unsigned AS = Context.getTargetAddressSpace(ETy);
+ unsigned AS = PointeeType->isFunctionTy()
+ ? getDataLayout().getProgramAddressSpace()
+ : Context.getTargetAddressSpace(ETy);
ResultType = llvm::PointerType::get(PointeeType, AS);
break;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111566.378726.patch
Type: text/x-patch
Size: 668 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211011/62f90e46/attachment.bin>
More information about the cfe-commits
mailing list