[PATCH] Teach ConstantFolding about address space pointer sizes

Eli Friedman eli.friedman at gmail.com
Fri Aug 9 21:15:12 PDT 2013


  This is a little on the large side to review easily; maybe commit a few formatting changes first to reduce the size of the patch?  Or maybe I'm just tired. :)


================
Comment at: lib/Analysis/ConstantFolding.cpp:667
@@ -659,1 +666,3 @@
+  unsigned AS = Ptr->getType()->getPointerAddressSpace();
+  Type *IntPtrTy = TD->getIntPtrType(Ptr->getContext(), AS);
 
----------------
Why not pass in the type directly?

================
Comment at: lib/Analysis/ConstantFolding.cpp:636
@@ -628,2 +635,3 @@
       C = Folded;
+  }
   return C;
----------------
I don't disagree, but please commit separately.

================
Comment at: lib/Analysis/ConstantFolding.cpp:418
@@ -413,3 +417,3 @@
   GlobalValue *GVal;
-  APInt Offset(TD.getPointerSizeInBits(), 0);
+  APInt Offset(TD.getPointerSizeInBits(AS), 0);
   if (!IsConstantOffsetFromGlobal(C, GVal, Offset, TD))
----------------
getPointerTypeSizeInBits?


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



More information about the llvm-commits mailing list