[PATCH] D64083: [OpenCL][Sema] Improve address space support for blocks
Marco Antognini via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 2 08:56:34 PDT 2019
mantognini created this revision.
mantognini added reviewers: rjmccall, Anastasia.
Herald added subscribers: cfe-commits, yaxunl.
Herald added a project: clang.
This patch ensures that the following code is compiled identically with
-cl-std=CL2.0 and -fblocks -cl-std=c++.
kernel void test(void) {
void (^const block_A)(void) = ^{
return;
};
}
A new test is not added because cl20-device-side-enqueue.cl will cover
this once blocks are further improved for C++ for OpenCL.
The changes to Sema::PerformImplicitConversion are based on
the parts of Sema::CheckAssignmentConstraints on block pointer
conversions.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D64083
Files:
clang/lib/Sema/SemaExprCXX.cpp
Index: clang/lib/Sema/SemaExprCXX.cpp
===================================================================
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -4216,7 +4216,20 @@
break;
case ICK_Block_Pointer_Conversion: {
- From = ImpCastExprToType(From, ToType.getUnqualifiedType(), CK_BitCast,
+ QualType LHSType = Context.getCanonicalType(ToType).getUnqualifiedType();
+ QualType RHSType = Context.getCanonicalType(FromType).getUnqualifiedType();
+
+ // Assumptions based on Sema::IsBlockPointerConversion.
+ assert(isa<BlockPointerType>(LHSType) && "BlockPointerType expected");
+ assert(isa<BlockPointerType>(RHSType) && "BlockPointerType expected");
+
+ LangAS AddrSpaceL =
+ LHSType->getAs<BlockPointerType>()->getPointeeType().getAddressSpace();
+ LangAS AddrSpaceR =
+ RHSType->getAs<BlockPointerType>()->getPointeeType().getAddressSpace();
+ CastKind Kind =
+ AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
+ From = ImpCastExprToType(From, ToType.getUnqualifiedType(), Kind,
VK_RValue, /*BasePath=*/nullptr, CCK).get();
break;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64083.207573.patch
Type: text/x-patch
Size: 1179 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190702/9ddf7afb/attachment.bin>
More information about the cfe-commits
mailing list