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...
if you just want to get the operands ,may be you can try,
Value* opl = iCmpInst -> getOperand(0);
Value* opr = iCmpInst -> getOperand(1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With