[PATCH] Teach ConstantFolding about address space pointer sizes

Matt Arsenault arsenm2 at gmail.com
Sat Aug 10 09:34:16 PDT 2013


On Aug 10, 2013, at 9:29 , Matt Arsenault <arsenm2 at gmail.com> wrote:

> 
> On Aug 9, 2013, at 21:15 , Eli Friedman <eli.friedman at gmail.com> wrote:
> 
>> 
>> 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: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?
> 
> I've found that in many places (I believe these ones count) where using those is more error prone when there are vectors of pointers. When given a pointer vector, getIntPtrType returns an integer vector type. This makes sense in many places, but not in others. The alternative would be to remember to use getIntPtrType()->getScalarType() in some situations.
This doesn't really apply for the getPointerSizeInBits / getPointerTypeSizeInBits cases



More information about the llvm-commits mailing list