[llvm] r189000 - Add a new helper method to Value to strip in-bounds constant offsets of
Duncan Sands
duncan.sands at gmail.com
Tue Sep 17 00:30:18 PDT 2013
>> --- llvm/trunk/lib/IR/Value.cpp (original)
>> +++ llvm/trunk/lib/IR/Value.cpp Thu Aug 22 06:25:11 2013
>> @@ -393,6 +393,40 @@ Value *Value::stripInBoundsConstantOffse
>> return stripPointerCastsAndOffsets<PSK_InBoundsConstantIndices>(this);
>> }
>>
>> +Value *Value::stripAndAccumulateInBoundsConstantOffsets(const DataLayout &DL,
>> + APInt &Offset) {
>> + if (!getType()->isPointerTy())
>> + return this;
>> +
>> + assert(Offset.getBitWidth() == DL.getPointerSizeInBits(cast<PointerType>(
>> + getType())->getAddressSpace()) &&
>> + "The offset must have exactly as many bits as our pointer.");
>
> Is there really no neater way of getting the pointer size in bits? If not,
> maybe add a helper for that?
For example, you could just use DL's getTypeSizeInBits, or
getPointerTypeSizeInBits which just calls getTypeSizeInBits
after doing some sanity checking.
Ciao, Duncan.
More information about the llvm-commits
mailing list