[PATCH] MCInstrAnalysis::evaluateBranch() silently fails without asserts

Stephen Checkoway s at pahtak.org
Wed Oct 16 13:25:12 PDT 2013


On Oct 16, 2013, at 3:00 PM, Jim Grosbach <grosbach at apple.com> wrote:

> Can you elaborate a bit on the problem you’re encountering? I’m having a hard time following whether this change is correct without an example to work through.


Sure. Without the patch, running llvm-objdump on my ninja binary (a handy one to test since it has managed to exercise a number of bugs in this code)

$ bin/llvm-objdump -d -cfg -symbolize ~/ninja/ninja

asserts with

include/llvm/MC/MCInst.h:75: int64_t llvm::MCOperand::getImm() const: Assertion `isImm() && "This is not an immediate"' failed.

Checking out the MCOperand in gdb reveals that it is indeed not an immediate but rather has kind kExpr:

(gdb) p *this
$1 = {Kind = 4 '\004', {RegVal = 9287008, ImmVal = 9287008, FPImmVal = 4.5883916054528234e-317, ExprVal = 0x8db560, InstVal = 0x8db560}}

One simple option would be to simply check if it's an immediate and return false if it isn't. Maybe that's the correct thing to do.

I apologize for not producing a reduced test case (I need to create an exam for tomorrow). Here's my build of ninja: <https://www.cs.jhu.edu/~s/temp/ninja.bz2> if you want to run it yourself.

-- 
Stephen Checkoway









More information about the llvm-commits mailing list