[PATCH] Make SROA handle addrspacecast

Chandler Carruth chandlerc at gmail.com
Tue Jun 16 13:36:04 PDT 2015


I'm actually quite alarmed at the idea of needing to handle addrspacecast of *alloca*s. I feel like their existence is a bigger problem.

I'd like to understand the use case that GPU folks have for this better. For an un-escaped alloca, why are there addrspacecasts at all? Why would they be useful? Why couldn't you lower them with arbitrarily fast loads and stores due to being unescaped allocas?


================
Comment at: lib/Transforms/Scalar/SROA.cpp:1825
@@ +1824,3 @@
+  if (Ptr->getType() != PointerTy) {
+    Ptr = IRB.CreatePointerBitCastOrAddrSpaceCast(Ptr, PointerTy,
+                                                  NamePrefix + "sroa_cast");
----------------
sanjoy wrote:
> Will this transform a "gep(addrspacecast X), Y)" to "addrspacecast(gep X, Y')"?  If so, I think we need a target specific hook that does a legality check on the addrspacecast we're about to insert -- I don't think "addrspacecast X" is legal implies an addrspacecast on a GEP derived from X is also legal.
The whole point of addrspacecast was to avoid the need for target specific checks... I think we just shouldn't transform GEPs around them if that isn't legal everywhere.

http://reviews.llvm.org/D10482

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list