[LLVMdev] InstCombine strips the inBounds attribute in GetElementPtr ConstantExpr

Jingyue Wu jingyue at google.com
Mon Apr 21 19:59:22 PDT 2014


I can't upload my program due to confidentiality, but the problem is
obvious.

At lib/Analysis/ConstantFolding.cpp:646

  Constant *C = ConstantExpr::getGetElementPtr(Ops[0], NewIdxs);

  if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {

    if (Constant *Folded = ConstantFoldConstantExpression(CE, TD, TLI))

      C = Folded;

  }

The generated ConstantExpr C doesn't inherit the inBounds attribute of the
original GEP.

FYI, the callstack is

#0  CastGEPIndices (Ops=..., ResultTy=0x2fb2850, TD=0x2fc8830,
TLI=0x2feb390)
    at ConstantFolding.cpp:623

#1  0x0000000001892dd1 in llvm::ConstantFoldInstOperands (Opcode=29,

    DestTy=0x2fb2850, Ops=..., TD=0x2fc8830, TLI=0x2feb390)

    at ConstantFolding.cpp:1040

#2  0x0000000001892647 in ConstantFoldConstantExpressionImpl (CE=0x2fcb0f8,

    TD=0x2fc8830, TLI=0x2feb390, FoldedOps=...) at ConstantFolding.cpp:931

#3  0x00000000018926d5 in llvm::ConstantFoldConstantExpression
(CE=0x2fcb0f8,
    TD=0x2fc8830, TLI=0x2feb390) at ConstantFolding.cpp:941

#4  0x0000000001892226 in llvm::ConstantFoldInstruction (I=0x2fcb208,

TD=0x2fc8830,

    TLI=0x2feb390) at ConstantFolding.cpp:883

#5  0x000000000171284e in AddReachableCodeToWorklist (BB=0x2fca970,
Visited=...,
    IC=..., DL=0x2fc8830, TLI=0x2feb390) at InstructionCombining.cpp:2283

#6  0x0000000001712e91 in llvm::InstCombiner::DoOneIteration
(this=0x2ff3be0,
F=...,

    Iteration=0) at InstructionCombining.cpp:2369

#7  0x0000000001713bf2 in llvm::InstCombiner::runOnFunction
(this=0x2ff3be0,
F=...)

    at InstructionCombining.cpp:2568

Jingyue
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140421/faad8378/attachment.html>


More information about the llvm-dev mailing list