<div dir="ltr">I can't upload my program due to confidentiality, but the problem is obvious. <div><br></div><div>At lib/Analysis/ConstantFolding.cpp:646</div><div><br></div><div><div> Constant *C = ConstantExpr::getGetElementPtr(Ops[0], NewIdxs); </div>
<div> if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) { </div><div> if (Constant *Folded = ConstantFoldConstantExpression(CE, TD, TLI)) </div><div> C = Folded; </div>
<div> }</div></div><div><br></div><div>The generated ConstantExpr C doesn't inherit the inBounds attribute of the original GEP. </div><div><br></div><div>FYI, the callstack is</div><div><br></div><div><div>#0 CastGEPIndices (Ops=..., ResultTy=0x2fb2850, TD=0x2fc8830, TLI=0x2feb390) </div>
<div> at ConstantFolding.cpp:623 </div><div>#1 0x0000000001892dd1 in llvm::ConstantFoldInstOperands (Opcode=29, </div><div> DestTy=0x2fb2850, Ops=..., TD=0x2fc8830, TLI=0x2feb390) </div>
<div> at ConstantFolding.cpp:1040 </div><div>#2 0x0000000001892647 in ConstantFoldConstantExpressionImpl (CE=0x2fcb0f8, </div><div> TD=0x2fc8830, TLI=0x2feb390, FoldedOps=...) at ConstantFolding.cpp:931 </div>
<div>#3 0x00000000018926d5 in llvm::ConstantFoldConstantExpression (CE=0x2fcb0f8, </div><div> TD=0x2fc8830, TLI=0x2feb390) at ConstantFolding.cpp:941 </div><div>#4 0x0000000001892226 in llvm::ConstantFoldInstruction (I=0x2fcb208, </div>
<div>TD=0x2fc8830, </div><div> TLI=0x2feb390) at ConstantFolding.cpp:883 </div><div>#5 0x000000000171284e in AddReachableCodeToWorklist (BB=0x2fca970, Visited=..., </div>
<div> IC=..., DL=0x2fc8830, TLI=0x2feb390) at InstructionCombining.cpp:2283 </div><div>#6 0x0000000001712e91 in llvm::InstCombiner::DoOneIteration (this=0x2ff3be0, </div><div>F=..., </div>
<div> Iteration=0) at InstructionCombining.cpp:2369 </div><div>#7 0x0000000001713bf2 in llvm::InstCombiner::runOnFunction (this=0x2ff3be0, </div><div>F=...) </div>
<div> at InstructionCombining.cpp:2568</div></div><div><br></div><div>Jingyue</div></div>