Hi,
I have a llvm-pass in hand written by other people. There are following
statements that I couldn't understand:
-------------------------------program----------------------------------------------------
...
if (isa<CallInst>(inst) || isa<InvokeInst>(inst)) {
const CallSite cs(inst);
if (cs.getCalledFunction() == NULL)
return dealAtIndirectCall(cs);
else
return dealAtDirectCall(cs);
}
...
-------------------------------------------------------------------------------------------
My question is:
When does the called function equal NULL, could you give an example? I mean
what kind of call in source code could change to this case in llvm-IR, could you
give an example?
Thank you for your time.
Best Regards
2010-11-30
WeiHu
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20101130/d8195167/attachment.html>
On Nov 29, 2010, at 5:22 PM, huwei8717 wrote:> Hi, > > I have a llvm-pass in hand written by other people. There are following statements that I couldn't understand: > > -------------------------------program---------------------------------------------------- > ... > if (isa<CallInst>(inst) || isa<InvokeInst>(inst)) { > const CallSite cs(inst); > if (cs.getCalledFunction() == NULL) > return dealAtIndirectCall(cs); > else > return dealAtDirectCall(cs); > } > ... > ------------------------------------------------------------------------------------------- > > My question is: > > When does the called function equal NULL, could you give an example? I mean what kind of call in source code could change to this case in llvm-IR, could you give an example?A call to a value of function-pointer type, e.g. void callit(void (*f)()) { f(); } Virtual calls in C++ would also have no known called function. John. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20101129/74dc2a75/attachment.html>
Than you John, It's very nice of you.
Best Regards
2010-11-30
-Wei
发件人: John McCall
发送时间: 2010-11-30 09:26:17
收件人: huwei8717
抄送: llvmdev
主题: Re: [LLVMdev] the called function equal NULL
On Nov 29, 2010, at 5:22 PM, huwei8717 wrote:
Hi,
I have a llvm-pass in hand written by other people. There are following
statements that I couldn't understand:
-------------------------------program----------------------------------------------------
...
if (isa<CallInst>(inst) || isa<InvokeInst>(inst)) {
const CallSite cs(inst);
if (cs.getCalledFunction() == NULL)
return dealAtIndirectCall(cs);
else
return dealAtDirectCall(cs);
}
...
-------------------------------------------------------------------------------------------
My question is:
When does the called function equal NULL, could you give an example? I mean
what kind of call in source code could change to this case in llvm-IR, could you
give an example?
A call to a value of function-pointer type, e.g.
void callit(void (*f)()) { f(); }
Virtual calls in C++ would also have no known called function.
John.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20101130/26d78c3a/attachment.html>