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

Jin Gu Kang jaykang10 at imrc.kist.re.kr
Thu Feb 10 16:56:29 PST 2011


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:

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110211/97b09662/attachment.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110211/97b09662/attachment.ksh>


More information about the llvm-commits mailing list