diff options
author | Chris Lattner <sabre@nondot.org> | 2002-11-17 22:17:12 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-11-17 22:17:12 +0000 |
commit | 29a320bfcf97890a2c290b7e6d7780daa370a74d (patch) | |
tree | 301ed1365928a5f6d3f1f997b0f6c7784637d540 /llvm/lib/Analysis/DataStructure/DataStructureStats.cpp | |
parent | 1e3652955b39f92e8fcdb4adee722bf9e7ec9ce4 (diff) | |
download | bcm5719-llvm-29a320bfcf97890a2c290b7e6d7780daa370a74d.tar.gz bcm5719-llvm-29a320bfcf97890a2c290b7e6d7780daa370a74d.zip |
Add hack to only consider indirect calls indirect if they do more than cast
their source function
llvm-svn: 4723
Diffstat (limited to 'llvm/lib/Analysis/DataStructure/DataStructureStats.cpp')
-rw-r--r-- | llvm/lib/Analysis/DataStructure/DataStructureStats.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/llvm/lib/Analysis/DataStructure/DataStructureStats.cpp b/llvm/lib/Analysis/DataStructure/DataStructureStats.cpp index 1548bc50d7d..36d060edd56 100644 --- a/llvm/lib/Analysis/DataStructure/DataStructureStats.cpp +++ b/llvm/lib/Analysis/DataStructure/DataStructureStats.cpp @@ -11,7 +11,7 @@ #include <vector> namespace { - Statistic<double> TotalNumCallees("totalcallees", + Statistic<> TotalNumCallees("totalcallees", "Total number of callee functions at all indirect call sites"); Statistic<> NumIndirectCalls("numindirect", "Total number of indirect call sites in the program"); @@ -39,6 +39,14 @@ namespace { static RegisterAnalysis<DSGraphStats> Z("dsstats", "DS Graph Statistics"); } +static bool isIndirectCallee(Value *V) { + if (isa<Function>(V)) return false; + + if (CastInst *CI = dyn_cast<CastInst>(V)) + return isIndirectCallee(CI->getOperand(0)); + return true; +} + void DSGraphStats::countCallees(const Function& F, const DSGraph& tdGraph) @@ -47,7 +55,7 @@ void DSGraphStats::countCallees(const Function& F, const std::vector<DSCallSite>& callSites = tdGraph.getFunctionCalls(); for (unsigned i=0, N = callSites.size(); i < N; ++i) - if (callSites[i].getCallInst().getCalledFunction() == NULL) + if (isIndirectCallee(callSites[i].getCallInst().getCalledValue())) { // This is an indirect function call std::vector<GlobalValue*> Callees = callSites[i].getCallee().getNode()->getGlobals(); @@ -66,10 +74,10 @@ void DSGraphStats::countCallees(const Function& F, TotalNumCallees += totalNumCallees; NumIndirectCalls += numIndirectCalls; - std::cout << " In function " << F.getName() << " : " - << (double) (numIndirectCalls == 0? 0.0 - : (totalNumCallees / (double) numIndirectCalls)) - << " avg. callees per indirect call\n"; + if (numIndirectCalls) + std::cout << " In function " << F.getName() << ": " + << (totalNumCallees / (double) numIndirectCalls) + << " average callees per indirect call\n"; } |