[llvm-commits] ConstantExpr::replaceUsesOfWithOnConstant() function for GetElementPtrConstantExpr

Chris Lattner clattner at apple.com
Thu Feb 10 21:41:19 PST 2011


On Feb 10, 2011, at 4:56 PM, Jin Gu Kang wrote:

> Hi llvm-commits members
>  
> when making replacement for GetElementPtr, I think inbounds factor is missed
> so, I made a patch to consider inbounds factor as follows:

Great catch.  I reworked the constantexpr interfaces to make this a bit easier (125365) and then fixed the bug in (125366).  Thanks!

-Chris

>  
> Index: lib/VMCore/Constants.cpp
> ===================================================================
> --- lib/VMCore/Constants.cpp  (revision 125324)
> +++ lib/VMCore/Constants.cpp  (working copy)
> @@ -2106,8 +2106,12 @@
>        if (Val == From) Val = To;
>        Indices.push_back(Val);
>      }
> -    Replacement = ConstantExpr::getGetElementPtr(Pointer,
> -                                                 &Indices[0], Indices.size());
> +    if(cast<GEPOperator>(this)->isInBounds())
> +      Replacement = ConstantExpr::getInBoundsGetElementPtr(Pointer,
> +                                                  &Indices[0], Indices.size());
> +    else
> +      Replacement = ConstantExpr::getGetElementPtr(Pointer,
> +                                                  &Indices[0], Indices.size());
>    } else if (getOpcode() == Instruction::ExtractValue) {
>      Constant *Agg = getOperand(0);
>      if (Agg == From) Agg = To;
> Please review the attached patch.
> Thank you,
> Jin-Gu Kang
> <patch.txt>_______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110210/19aabf8f/attachment.html>


More information about the llvm-commits mailing list