r365500 - [OpenCL][Sema] Improve address space support for blocks
Marco Antognini via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 9 08:04:27 PDT 2019
Author: mantognini
Date: Tue Jul 9 08:04:27 2019
New Revision: 365500
URL: http://llvm.org/viewvc/llvm-project?rev=365500&view=rev
Log:
[OpenCL][Sema] Improve address space support for blocks
Summary:
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.
Reviewers: rjmccall, Anastasia
Subscribers: yaxunl, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D64083
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=365500&r1=365499&r2=365500&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Jul 9 08:04:27 2019
@@ -4216,7 +4216,20 @@ Sema::PerformImplicitConversion(Expr *Fr
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;
}
More information about the cfe-commits
mailing list