The current BasicCallGraph will miss call sites like this:<br>%tmp86 = call i8* (...)* bitcast (i8* ()* @find_ispell to i8* (...)*)( ) ; <i8*> [#uses=1]<br><br>Here the direct user of @find_ispell is a ConstantExpr.
<br>I added several lines of code to address this case.<br>Below is the output of command: svn diff lib/Analysis/IPA/CallGraph.cpp<br>Attached is LLVM asm files with such function calls.<br><br>Index: lib/Analysis/IPA/CallGraph.cpp
<br>==============================<div id="mb_0">=====================================<br>--- lib/Analysis/IPA/CallGraph.cpp (revision 39771)<br>+++ lib/Analysis/IPA/CallGraph.cpp (working copy)<br>@@ -13,6 +13,7 @@
<br> //===----------------------------------------------------------------------===//
<br> <br> #include "llvm/Analysis/CallGraph.h"<br>+#include "llvm/Constants.h"<br> #include "llvm/Module.h"<br> #include "llvm/Instructions.h"<br> #include "llvm/Support/CallSite.h"
<br>@@ -150,6 +151,19 @@<br> ->addCalledFunction(CS, Node);<br> else<br> isUsedExternally = true;<br>+ } else if (ConstantExpr* CE = dyn_cast<ConstantExpr>(*I)) {<br>+ for (Value::use_iterator I = CE->use_begin(), E = CE->use_end();
<br>+ I != E; ++I)<br>+ if (Instruction* Inst = dyn_cast<Instruction>(*I)) {<br>+ CallSite CS = CallSite::get(Inst);<br>+ if (isOnlyADirectCall(F, CS))<br>+ getOrInsertFunction(Inst->getParent()->getParent())
<br>+ ->addCalledFunction(CS, Node);<br>+ else<br>+ isUsedExternally = true;<br>+ } else {<br>+ isUsedExternally = true;<br>+ }<br> } else if (GlobalValue *GV = dyn_cast<GlobalValue>(*I)) {
<br> for (Value::use_iterator I = GV->use_begin(), E = GV->use_end();<br> I != E; ++I)</div>