[PATCH] D64083: [OpenCL][Sema] Improve address space support for blocks

Anastasia Stulova via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 10 05:13:40 PDT 2019


Anastasia added inline comments.


================
Comment at: cfe/trunk/lib/Sema/SemaExprCXX.cpp:4229
+    LangAS AddrSpaceR =
+        RHSType->getAs<BlockPointerType>()->getPointeeType().getAddressSpace();
+    CastKind Kind =
----------------
rjmccall wrote:
> All of this can be much simpler:
> 
> ```
> LangAS AddrSpaceL = ToType->castAs<BlockPointerType>()->getPointeeType().getAddressSpace();
> LangAS AddrSpaceR = FromType->castAs<BlockPointerType>()->getPointeeType().getAddressSpace();
> ```
> 
> Is there something actually checking the validity of this address-space cast somewhere?
> Is there something actually checking the validity of this address-space cast somewhere?

The address spaces for blocks are currently added by clang implicitly. It doesn't seem possible to write kernel code qualifying blocks with address spaces. Although I have to say the error is not given properly because the parser gets confused at least for the examples I have tried. The OpenCL spec doesn't detail much regarding this use case. Potentially this is the area for improvement.

So for now we can add an assert to check the cast validity if you think it makes sense and maybe a FIXME in the  code to explain that address spaces aren't working with blocks....


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64083/new/

https://reviews.llvm.org/D64083





More information about the cfe-commits mailing list