Ethan J. Johnson
2015-Jul-16 20:11 UTC
[LLVMdev] Identifying function call targets at the MachineInstr level
Thanks – extracting the call destination from the instruction operand is working much better! For my test bitcode, which contains only direct calls, this correctly matches all calls to their targets. I don’t suppose there’s an “easy” solution for identifying the targets of indirect calls (i.e., through function pointers)? I’ve been told that LLVM’s IR-level CallGraph analysis doesn’t account for indirect calls; is this still the case? Thanks, Ethan Johnson From: Hal Finkel [mailto:hfinkel at anl.gov] Sent: Thursday, July 16, 2015 1:34 AM To: Ethan J. Johnson <ejohns48 at cs.rochester.edu> Cc: llvmdev at cs.uiuc.edu Subject: Re: [LLVMdev] Identifying function call targets at the MachineInstr level This will not work in general, as you note below, this depends on a correspondence between calls on the IR and MI levels, and nothing guarantees this (and will not be true in practice because lowering of many different IR constructs inserts calls to libc, etc.). Instead, you can extract the call destination from the call instruction itself. If you iterate over the instruction's operands, you should find that one of them returns true for isGlobal(). On such an operand, you can call getGlobal() to get the IR-level GlobalValue* representing the function. You might also find that isSymbol() is true, in which case you can call getSymbolName() (which returns a const char * with the symbol name). -Hal -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150716/a74560b7/attachment.html>