[LLVMdev] How to use the return value of a CallInst

Guowei Xu myesis at gmail.com
Mon Jul 26 20:29:40 PDT 2010


Hi all:
   I am trying to compare the return value of a call instruction with 0. The
called function's return type is uint32. The return value is 1 or 0. But the
icmp instruction cannot be created.

  CallInst *ret = CallInst::Create(ptr_func, params.begin(), params.end(),
"", bb);
  Value *cmp = new ICmpInst(*bb, ICmpInst::ICMP_EQ, ret,
,ConstantInt::get(getIntegerType(32), 0) "")

The runtime error is:
/usr/local/include/llvm/Instructions.h:690:
llvm::ICmpInst::ICmpInst(llvm::BasicBlock&, llvm::CmpInst::Predicate,
llvm::Value*, llvm::Value*, const llvm::Twine&): Assertion
`getOperand(0)->getType() == getOperand(1)->getType() && "Both operands to
ICmp instruction are not of the same type!"' failed.
Aborted

I don't know how to use the return value of function .

Thanks for any input in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100726/0613036c/attachment.html>


More information about the llvm-dev mailing list