[llvm-commits] CVS: llvm/lib/Analysis/DataStructure/DataStructureStats.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sun Nov 17 16:18:01 PST 2002
Changes in directory llvm/lib/Analysis/DataStructure:
DataStructureStats.cpp updated: 1.1 -> 1.2
---
Log message:
Add hack to only consider indirect calls indirect if they do more than cast
their source function
---
Diffs of the changes:
Index: llvm/lib/Analysis/DataStructure/DataStructureStats.cpp
diff -u llvm/lib/Analysis/DataStructure/DataStructureStats.cpp:1.1 llvm/lib/Analysis/DataStructure/DataStructureStats.cpp:1.2
--- llvm/lib/Analysis/DataStructure/DataStructureStats.cpp:1.1 Wed Nov 13 09:41:00 2002
+++ llvm/lib/Analysis/DataStructure/DataStructureStats.cpp Sun Nov 17 16:17:12 2002
@@ -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 @@
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 @@
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 @@
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";
}
More information about the llvm-commits
mailing list