[PATCH] Support for address space casting in order to map these on the new 'addrspacecast' IR instruction

David Tweed david.tweed at gmail.com
Fri Dec 6 03:21:00 PST 2013


  Some comments from someone who doesn't do much front-end stuff, but overall looks reasonable to me.


================
Comment at: lib/CodeGen/CGExprScalar.cpp:1304
@@ +1303,3 @@
+    unsigned SrcAS = Src->getType()->getPointerAddressSpace();
+    if (Ty->isPtrOrPtrVectorTy() && Ty->getPointerAddressSpace() != SrcAS) {
+      llvm::Type *IntTy = CGF.CGM.getDataLayout().getIntPtrType(Src->getType());
----------------
I'm not very experienced in this part of the codebase: by what paths would we now end up with a CK_BitCast that's actually an address space cast (that hasn't be actually generated as an CK_AddressSpaceConversion by the front end)?

================
Comment at: test/CodeGenCUDA/address-space-conversion.cu:16
@@ +15,3 @@
+     ((unsigned int *)x)[i] = 0;
+		// CHECK: addrspacecast
+   }
----------------
Probably unnecessary paranoia, but if the compiler decides (for some reason) to unroll this loop might you get multiple addrspacecast nodes, in which case  shouldn't the next check have a function name CHECK just in case.


http://llvm-reviews.chandlerc.com/D2241



More information about the cfe-commits mailing list