I am trying to extract what operands are being used in an if
instruction in LLVM IR.
For example: for an instruction like if(x==10)
, I want x
and 10
as output.
Is this not how it should be done:
if (ICmpInst* iCmpInst = dyn_cast<ICmpInst>(&*i))
{
errs() << "Conditional Instruction found: ";
errs() << iCmpInst->getOpcodeName() << '\t';
errs() << iCmpInst->getPredicate() << '\t';
MDNode* metadata = iCmpInst->getMetadata("dbg");
llvm::MDNode::op_iterator o_begin = metadata->op_begin();
llvm::MDNode::op_iterator o_end = metadata->op_end();
for(; o_begin != o_end; ++o_begin)
{
errs() << o_begin << "\n";
}
}
For literals such as x
, I have to scan `store instructions I think...