[PATCH] Fix assert with GEP ptr vector indexing structs

Eli Friedman eli.friedman at gmail.com
Fri Aug 16 17:51:33 PDT 2013


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?

-Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130816/543292c3/attachment.html>


More information about the llvm-commits mailing list