Jin Gu Kang
2011-Feb-10 11:31 UTC
[LLVMdev] ConstantExpr::replaceUsesOfWithOnConstant() function for llvm::GetElementPtrConstantExpr
Hi LLVMdev members I found something strange in ConstantExpr::replaceUsesOfWithOnConstant() function. in lib/VMCore/Constants.cpp file 2118 if (getOpcode() == Instruction::GetElementPtr) { 2119 SmallVector<Constant*, 8> Indices; 2120 Constant *Pointer = getOperand(0); 2121 Indices.reserve(getNumOperands()-1); 2122 if (Pointer == From) Pointer = To; 2123 2124 for (unsigned i = 1, e = getNumOperands(); i != e; ++i) { 2125 Constant *Val = getOperand(i); 2126 if (Val == From) Val = To; 2127 Indices.push_back(Val); 2128 } 2129 Replacement = ConstantExpr::getGetElementPtr(Pointer, 2130 &Indices[0], Indices.size()); when making replacement for GetElementPtr, above codes do not consider inbounds factor. so, I thought codes to inbounds factor as follows: original 2129 Replacement = ConstantExpr::getGetElementPtr(Pointer, 2130 &Indices[0], Indices.size()); -------------------------------------------------------------------------------------------> modified 2129 if(cast<GEPOperator>(this)->isInBounds()) 2130 Replacement = ConstantExpr::getInBoundsGetElementPtr(Pointer, 2131 &Indices[0], Indices.size()); 2132 else 2133 Replacement = ConstantExpr::getGetElementPtr(Pointer, 2134 &Indices[0], Indices.size()); What do you think about above codes? Best regards, Jin-Gu Kang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110210/3e2d880c/attachment.html>
Maybe Matching Threads
- [LLVMdev] Convenience methods in ConstantExpr et al
- [LLVMdev] Convenience methods in ConstantExpr et al
- [LLVMdev] Convenience methods in ConstantExpr et al
- [LLVMdev] Convenience methods in ConstantExpr et al
- [LLVMdev] InstCombine strips the inBounds attribute in GetElementPtr ConstantExpr