[PATCH] D37804: [OpenCL] Handle address space conversion while setting type alignment

Anastasia Stulova via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 19 09:04:07 PDT 2017


Anastasia added inline comments.


================
Comment at: lib/CodeGen/CGExpr.cpp:957
 
-        return Builder.CreateBitCast(Addr, ConvertType(E->getType()));
+        return Builder.CreatePointerBitCastOrAddrSpaceCast(
+            Addr, ConvertType(E->getType()));
----------------
Anastasia wrote:
> yaxunl wrote:
> > Better assert that only CK_AddressSpaceConversion allows different addr spaces in target type.
> It seems for consistency then we would have to assert for both different ASes in non-`addrspacecast` case and equivalent ASes in the other case.
> 
> As condition becomes complicated then, I could as well split into either creating `bitcast` or `addrspacecast` explicitly at a cost of one simple check in the return statement but that would be in release build too. 
Sam, do you prefer an assert that will check both things or a runtime check that would make sure to build the right IR node here?


https://reviews.llvm.org/D37804





More information about the cfe-commits mailing list