aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/DataStructure/CompleteBottomUp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Analysis/DataStructure/CompleteBottomUp.cpp')
-rw-r--r--lib/Analysis/DataStructure/CompleteBottomUp.cpp45
1 files changed, 9 insertions, 36 deletions
diff --git a/lib/Analysis/DataStructure/CompleteBottomUp.cpp b/lib/Analysis/DataStructure/CompleteBottomUp.cpp
index 3cb0b6eb84..834ae9738f 100644
--- a/lib/Analysis/DataStructure/CompleteBottomUp.cpp
+++ b/lib/Analysis/DataStructure/CompleteBottomUp.cpp
@@ -13,6 +13,7 @@
//
//===----------------------------------------------------------------------===//
+#define DEBUG_TYPE "cbudatastructure"
#include "llvm/Analysis/DataStructure/DataStructure.h"
#include "llvm/Module.h"
#include "llvm/Analysis/DataStructure/DSGraph.h"
@@ -37,39 +38,8 @@ bool CompleteBUDataStructures::runOnModule(Module &M) {
GlobalsGraph = new DSGraph(BU.getGlobalsGraph(), GlobalECs);
GlobalsGraph->setPrintAuxCalls();
-#if 1 // REMOVE ME EVENTUALLY
- // FIXME: TEMPORARY (remove once finalization of indirect call sites in the
- // globals graph has been implemented in the BU pass)
- TDDataStructures &TD = getAnalysis<TDDataStructures>();
-
- ActualCallees.clear();
-
- // The call graph extractable from the TD pass is _much more complete_ and
- // trustable than that generated by the BU pass so far. Until this is fixed,
- // we hack it like this:
- for (Module::iterator MI = M.begin(), ME = M.end(); MI != ME; ++MI) {
- if (MI->isExternal()) continue;
- const std::list<DSCallSite> &CSs = TD.getDSGraph(*MI).getFunctionCalls();
-
- for (std::list<DSCallSite>::const_iterator CSI = CSs.begin(), E = CSs.end();
- CSI != E; ++CSI) {
- Instruction *TheCall = CSI->getCallSite().getInstruction();
-
- if (CSI->isIndirectCall()) { // indirect call: insert all callees
- std::vector<Function*> Callees;
- CSI->getCalleeNode()->addFullFunctionList(Callees);
- for (unsigned i = 0, e = Callees.size(); i != e; ++i)
- ActualCallees.insert(std::make_pair(TheCall, Callees[i]));
- } else { // direct call: insert the single callee directly
- ActualCallees.insert(std::make_pair(TheCall,
- CSI->getCalleeFunc()));
- }
- }
- }
-#else
// Our call graph is the same as the BU data structures call graph
ActualCallees = BU.getActualCallees();
-#endif
std::vector<DSGraph*> Stack;
hash_map<DSGraph*, unsigned> ValMap;
@@ -150,8 +120,9 @@ unsigned CompleteBUDataStructures::calculateSCCGraphs(DSGraph &FG,
Instruction *Call = CI->getCallSite().getInstruction();
// Loop over all of the actually called functions...
- ActualCalleesTy::iterator I, E;
- for (tie(I, E) = ActualCallees.equal_range(Call); I != E; ++I)
+ ActualCalleesTy::iterator I = callee_begin(Call), E = callee_end(Call);
+ for (; I != E && I->first == Call; ++I) {
+ assert(I->first == Call && "Bad callee construction!");
if (!I->second->isExternal()) {
DSGraph &Callee = getOrCreateGraph(*I->second);
unsigned M;
@@ -163,6 +134,7 @@ unsigned CompleteBUDataStructures::calculateSCCGraphs(DSGraph &FG,
M = It->second;
if (M < Min) Min = M;
}
+ }
}
assert(ValMap[&FG] == MyID && "SCC construction assumption wrong!");
@@ -225,10 +197,11 @@ void CompleteBUDataStructures::processGraph(DSGraph &G) {
// Inline direct calls as well as indirect calls because the direct
// callee may have indirect callees and so may have changed.
//
- ActualCalleesTy::iterator I, E;
- tie(I, E) = ActualCallees.equal_range(TheCall);
- unsigned TNum = 0, Num = std::distance(I, E);
+ ActualCalleesTy::iterator I = callee_begin(TheCall),E = callee_end(TheCall);
+ unsigned TNum = 0, Num = 0;
+ DEBUG(Num = std::distance(I, E));
for (; I != E; ++I, ++TNum) {
+ assert(I->first == TheCall && "Bad callee construction!");
Function *CalleeFunc = I->second;
if (!CalleeFunc->isExternal()) {
// Merge the callee's graph into this graph. This works for normal