[PATCH] Fix assert with GEP ptr vector indexing structs
Eli Friedman
eli.friedman at gmail.com
Fri Aug 16 18:22:17 PDT 2013
On Fri, Aug 16, 2013 at 6:16 PM, Matt Arsenault <arsenm2 at gmail.com> wrote:
>
> On Aug 16, 2013, at 17:51 , Eli Friedman <eli.friedman at gmail.com> wrote:
>
> On Fri, Aug 16, 2013 at 5:21 PM, Matt Arsenault <Matthew.Arsenault at amd.com
> > wrote:
>
>> Also fix it calculating the wrong value. The struct index is not a
>> ConstantInt, so it was being interpreted as an array index.
>>
>> http://llvm-reviews.chandlerc.com/D1431
>>
>> Files:
>> include/llvm/Transforms/Utils/Local.h
>> lib/Analysis/ValueTracking.cpp
>> test/Transforms/InstCombine/getelementptr.ll
>>
>> Index: include/llvm/Transforms/Utils/Local.h
>> ===================================================================
>> --- include/llvm/Transforms/Utils/Local.h
>> +++ include/llvm/Transforms/Utils/Local.h
>> @@ -203,12 +203,17 @@
>> ++i, ++GTI) {
>> Value *Op = *i;
>> uint64_t Size = TD.getTypeAllocSize(GTI.getIndexedType()) &
>> PtrSizeMask;
>> - if (ConstantInt *OpC = dyn_cast<ConstantInt>(Op)) {
>> - if (OpC->isZero()) continue;
>> + if (Constant *OpC = dyn_cast<Constant>(Op)) {
>> + if (OpC->isZeroValue())
>> + continue;
>> +
>> + if (OpC->getType()->isVectorTy())
>> + OpC = OpC->getSplatValue();
>>
>> What if getSplatValue() returns null?
>
>
> It isn't allowed to have a vector struct index with different valued
> elements, so this should always work
>
>
The getSplatValue() call is before the check for whether the type refers to
a struct...
-Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130816/a6e3c33b/attachment.html>
More information about the llvm-commits
mailing list