[llvm-commits] [poolalloc] r57830 - in /poolalloc/trunk: include/dsa/ include/poolalloc/ lib/DSA/ lib/PoolAllocate/
Andrew Lenharth
alenhar2 at cs.uiuc.edu
Mon Oct 20 08:48:54 PDT 2008
Author: alenhar2
Date: Mon Oct 20 10:48:53 2008
New Revision: 57830
URL: http://llvm.org/viewvc/llvm-project?rev=57830&view=rev
Log:
fix use after free errors and make interfaces more uniform
Modified:
poolalloc/trunk/include/dsa/DSGraph.h
poolalloc/trunk/include/dsa/DataStructure.h
poolalloc/trunk/include/poolalloc/PoolAllocate.h
poolalloc/trunk/lib/DSA/BottomUpClosure.cpp
poolalloc/trunk/lib/DSA/CallTargets.cpp
poolalloc/trunk/lib/DSA/DataStructure.cpp
poolalloc/trunk/lib/DSA/DataStructureAA.cpp
poolalloc/trunk/lib/DSA/DataStructureOpt.cpp
poolalloc/trunk/lib/DSA/DataStructureStats.cpp
poolalloc/trunk/lib/DSA/EquivClassGraphs.cpp
poolalloc/trunk/lib/DSA/GraphChecker.cpp
poolalloc/trunk/lib/DSA/Local.cpp
poolalloc/trunk/lib/DSA/Printer.cpp
poolalloc/trunk/lib/DSA/StdLibPass.cpp
poolalloc/trunk/lib/DSA/TopDownClosure.cpp
poolalloc/trunk/lib/PoolAllocate/AccessTrace.cpp
poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp
poolalloc/trunk/lib/PoolAllocate/Heuristic.h
poolalloc/trunk/lib/PoolAllocate/PASimple.cpp
poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp
poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp
poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp
Modified: poolalloc/trunk/include/dsa/DSGraph.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DSGraph.h?rev=57830&r1=57829&r2=57830&view=diff
==============================================================================
--- poolalloc/trunk/include/dsa/DSGraph.h (original)
+++ poolalloc/trunk/include/dsa/DSGraph.h Mon Oct 20 10:48:53 2008
@@ -250,7 +250,7 @@
// source. You need to set a new GlobalsGraph with the setGlobalsGraph
// method.
//
- DSGraph( DSGraph &DSG, EquivalenceClasses<const GlobalValue*> &ECs,
+ DSGraph( DSGraph* DSG, EquivalenceClasses<const GlobalValue*> &ECs,
unsigned CloneFlags = 0);
~DSGraph();
@@ -316,6 +316,10 @@
return AuxFunctionCalls;
}
+ // addAuxFunctionCall - Add a call site to the AuxFunctionCallList
+ void addAuxFunctionCall(DSCallSite D) { AuxFunctionCalls.push_front(D); }
+
+
/// removeFunction - Specify that all call sites to the function have been
/// fully specified by a pass such as StdLibPass.
void removeFunctionCalls(Function& F);
@@ -498,13 +502,13 @@
/// this graph, then clearing the RHS graph. Instead of performing this as
/// two seperate operations, do it as a single, much faster, one.
///
- void spliceFrom(DSGraph &RHS);
+ void spliceFrom(DSGraph* RHS);
/// cloneInto - Clone the specified DSGraph into the current graph.
///
/// The CloneFlags member controls various aspects of the cloning process.
///
- void cloneInto(DSGraph &G, unsigned CloneFlags = 0);
+ void cloneInto(DSGraph* G, unsigned CloneFlags = 0);
/// getFunctionArgumentsForCall - Given a function that is currently in this
/// graph, return the DSNodeHandles that correspond to the pointer-compatible
@@ -567,8 +571,8 @@
/// all of the nodes reachable from it are automatically brought over as well.
///
class ReachabilityCloner {
- DSGraph &Dest;
- const DSGraph &Src;
+ DSGraph* Dest;
+ const DSGraph* Src;
/// BitsToKeep - These bits are retained from the source node when the
/// source nodes are merged into the destination graph.
@@ -579,9 +583,9 @@
// represent them in the destination graph.
DSGraph::NodeMapTy NodeMap;
public:
- ReachabilityCloner(DSGraph &dest, const DSGraph &src, unsigned cloneFlags)
+ ReachabilityCloner(DSGraph* dest, const DSGraph* src, unsigned cloneFlags)
: Dest(dest), Src(src), CloneFlags(cloneFlags) {
- assert(&Dest != &Src && "Cannot clone from graph to same graph!");
+ assert(Dest != Src && "Cannot clone from graph to same graph!");
BitsToKeep = ~DSNode::DeadNode;
if (CloneFlags & DSGraph::StripAllocaBit)
BitsToKeep &= ~DSNode::AllocaNode;
Modified: poolalloc/trunk/include/dsa/DataStructure.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DataStructure.h?rev=57830&r1=57829&r2=57830&view=diff
==============================================================================
--- poolalloc/trunk/include/dsa/DataStructure.h (original)
+++ poolalloc/trunk/include/dsa/DataStructure.h Mon Oct 20 10:48:53 2008
@@ -140,19 +140,19 @@
/// getDSGraph - Return the data structure graph for the specified function.
///
- DSGraph &getDSGraph(const Function &F) const {
+ DSGraph *getDSGraph(const Function &F) const {
hash_map<const Function*, DSGraph*>::const_iterator I = DSInfo.find(&F);
assert(I != DSInfo.end() && "Function not in module!");
- return *I->second;
+ return I->second;
}
void setDSGraph(const Function& F, DSGraph* G) {
DSInfo[&F] = G;
}
- DSGraph& getOrCreateGraph(const Function* F);
+ DSGraph* getOrCreateGraph(const Function* F);
- DSGraph &getGlobalsGraph() const { return *GlobalsGraph; }
+ DSGraph* getGlobalsGraph() const { return GlobalsGraph; }
EquivalenceClasses<const GlobalValue*> &getGlobalECs() { return GlobalECs; }
@@ -246,9 +246,9 @@
bool runOnModuleInternal(Module &M);
private:
- void calculateGraph(DSGraph &G);
+ void calculateGraph(DSGraph* G);
- void inlineUnresolved(DSGraph &G);
+ void inlineUnresolved(DSGraph* G);
unsigned calculateGraphs(const Function *F,
std::vector<const Function*> &Stack,
@@ -256,7 +256,7 @@
hash_map<const Function*, unsigned> &ValMap);
- void CloneAuxIntoGlobal(DSGraph& G);
+ void CloneAuxIntoGlobal(DSGraph* G);
void finalizeGlobals(void);
};
@@ -367,7 +367,7 @@
void markReachableFunctionsExternallyAccessible(DSNode *N,
hash_set<DSNode*> &Visited);
- void InlineCallersIntoGraph(DSGraph &G);
+ void InlineCallersIntoGraph(DSGraph* G);
void ComputePostOrder(const Function &F, hash_set<DSGraph*> &Visited,
std::vector<DSGraph*> &PostOrder);
};
Modified: poolalloc/trunk/include/poolalloc/PoolAllocate.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/poolalloc/PoolAllocate.h?rev=57830&r1=57829&r2=57830&view=diff
==============================================================================
--- poolalloc/trunk/include/poolalloc/PoolAllocate.h (original)
+++ poolalloc/trunk/include/poolalloc/PoolAllocate.h Mon Oct 20 10:48:53 2008
@@ -121,11 +121,11 @@
return Graphs->hasDSGraph (F);
}
- virtual DSGraph & getDSGraph (const Function & F) const {
+ virtual DSGraph* getDSGraph (const Function & F) const {
return Graphs->getDSGraph (F);
}
- virtual DSGraph & getGlobalsGraph () const {
+ virtual DSGraph* getGlobalsGraph () const {
return Graphs->getGlobalsGraph ();
}
@@ -237,11 +237,11 @@
return ArrayType::get(VoidPtrType, 16);
}
- virtual DSGraph & getDSGraph (const Function & F) const {
+ virtual DSGraph* getDSGraph (const Function & F) const {
return Graphs->getDSGraph (F);
}
- virtual DSGraph & getGlobalsGraph () const {
+ virtual DSGraph* getGlobalsGraph () const {
return Graphs->getGlobalsGraph ();
}
@@ -320,11 +320,11 @@
/// pools specified in the NodesToPA list. This adds an entry to the
/// PoolDescriptors map for each DSNode.
///
- void CreatePools(Function &F, DSGraph &G,
+ void CreatePools(Function &F, DSGraph* G,
const std::vector<const DSNode*> &NodesToPA,
std::map<const DSNode*, Value*> &PoolDescriptors);
- void TransformBody(DSGraph &g, PA::FuncInfo &fi,
+ void TransformBody(DSGraph* g, PA::FuncInfo &fi,
std::multimap<AllocaInst*, Instruction*> &poolUses,
std::multimap<AllocaInst*, CallInst*> &poolFrees,
Function &F);
@@ -378,12 +378,12 @@
void ProcessFunctionBodySimple(Function& F, TargetData & TD);
- virtual DSGraph & getDSGraph (const Function & F) const {
- return *CombinedDSGraph;
+ virtual DSGraph* getDSGraph (const Function & F) const {
+ return CombinedDSGraph;
}
- virtual DSGraph & getGlobalsGraph () const {
- return *CombinedDSGraph;
+ virtual DSGraph* getGlobalsGraph () const {
+ return CombinedDSGraph;
}
virtual Value * getGlobalPool (const DSNode * Node) {
Modified: poolalloc/trunk/lib/DSA/BottomUpClosure.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/BottomUpClosure.cpp?rev=57830&r1=57829&r2=57830&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/BottomUpClosure.cpp (original)
+++ poolalloc/trunk/lib/DSA/BottomUpClosure.cpp Mon Oct 20 10:48:53 2008
@@ -95,21 +95,21 @@
// into the main function's graph so that the main function contains all of
// the information about global pools and GV usage in the program.
if (MainFunc && !MainFunc->isDeclaration()) {
- DSGraph &MainGraph = getOrCreateGraph(MainFunc);
- const DSGraph &GG = *MainGraph.getGlobalsGraph();
+ DSGraph* MainGraph = getOrCreateGraph(MainFunc);
+ const DSGraph* GG = MainGraph->getGlobalsGraph();
ReachabilityCloner RC(MainGraph, GG,
DSGraph::DontCloneCallNodes |
DSGraph::DontCloneAuxCallNodes);
// Clone the global nodes into this graph.
- for (DSScalarMap::global_iterator I = GG.getScalarMap().global_begin(),
- E = GG.getScalarMap().global_end(); I != E; ++I)
+ for (DSScalarMap::global_iterator I = GG->getScalarMap().global_begin(),
+ E = GG->getScalarMap().global_end(); I != E; ++I)
if (isa<GlobalVariable>(*I))
- RC.getClonedNH(GG.getNodeForValue(*I));
+ RC.getClonedNH(GG->getNodeForValue(*I));
- MainGraph.maskIncompleteMarkers();
- MainGraph.markIncompleteNodes(DSGraph::MarkFormalArgs |
- DSGraph::IgnoreGlobals);
+ MainGraph->maskIncompleteMarkers();
+ MainGraph->markIncompleteNodes(DSGraph::MarkFormalArgs |
+ DSGraph::IgnoreGlobals);
}
NumCallEdges += callee_size();
@@ -194,17 +194,17 @@
/// GetAllAuxCallees - Return a list containing all of the resolvable callees in
/// the aux list for the specified graph in the Callees vector.
-static void GetAllAuxCallees(DSGraph &G, std::vector<const Function*> &Callees) {
+static void GetAllAuxCallees(DSGraph* G, std::vector<const Function*> &Callees) {
Callees.clear();
- for (DSGraph::afc_iterator I = G.afc_begin(), E = G.afc_end(); I != E; ++I)
+ for (DSGraph::afc_iterator I = G->afc_begin(), E = G->afc_end(); I != E; ++I)
GetAllCallees(*I, Callees);
}
/// GetAnyAuxCallees - Return a list containing all of the callees in
/// the aux list for the specified graph in the Callees vector.
-static void GetAnyAuxCallees(DSGraph &G, std::vector<const Function*> &Callees) {
+static void GetAnyAuxCallees(DSGraph* G, std::vector<const Function*> &Callees) {
Callees.clear();
- for (DSGraph::afc_iterator I = G.afc_begin(), E = G.afc_end(); I != E; ++I)
+ for (DSGraph::afc_iterator I = G->afc_begin(), E = G->afc_end(); I != E; ++I)
GetAnyCallees(*I, Callees);
}
@@ -227,7 +227,7 @@
return Min;
}
- DSGraph &Graph = getOrCreateGraph(F);
+ DSGraph* Graph = getOrCreateGraph(F);
// Find all callee functions.
std::vector<const Function*> CalleeFunctions;
@@ -261,7 +261,7 @@
DOUT << " [BU] Calculating graph for: " << F->getName()<< "\n";
calculateGraph(Graph);
DOUT << " [BU] Done inlining: " << F->getName() << " ["
- << Graph.getGraphSize() << "+" << Graph.getAuxFunctionCalls().size()
+ << Graph->getGraphSize() << "+" << Graph->getAuxFunctionCalls().size()
<< "]\n";
if (MaxSCC < 1) MaxSCC = 1;
@@ -295,7 +295,7 @@
unsigned SCCSize = 1;
const Function *NF = Stack.back();
ValMap[NF] = ~0U;
- DSGraph &SCCGraph = getDSGraph(*NF);
+ DSGraph* SCCGraph = getDSGraph(*NF);
// First thing first, collapse all of the DSGraphs into a single graph for
// the entire SCC. Splice all of the graphs into one and discard all of the
@@ -306,17 +306,18 @@
NF = Stack.back();
ValMap[NF] = ~0U;
- DSGraph &NFG = getDSGraph(*NF);
+ DSGraph* NFG = getDSGraph(*NF);
- // Update the Function -> DSG map.
- for (DSGraph::retnodes_iterator I = NFG.retnodes_begin(),
- E = NFG.retnodes_end(); I != E; ++I)
- setDSGraph(*I->first, &SCCGraph);
-
- SCCGraph.spliceFrom(NFG);
- delete &NFG;
-
- ++SCCSize;
+ if (NFG != SCCGraph) {
+ // Update the Function -> DSG map.
+ for (DSGraph::retnodes_iterator I = NFG->retnodes_begin(),
+ E = NFG->retnodes_end(); I != E; ++I)
+ setDSGraph(*I->first, SCCGraph);
+
+ SCCGraph->spliceFrom(NFG);
+ delete NFG;
+ ++SCCSize;
+ }
}
Stack.pop_back();
@@ -328,13 +329,13 @@
MaxSCC = SCCSize;
// Clean up the graph before we start inlining a bunch again...
- SCCGraph.removeDeadNodes(DSGraph::KeepUnreachableGlobals);
+ SCCGraph->removeDeadNodes(DSGraph::KeepUnreachableGlobals);
// Now that we have one big happy family, resolve all of the call sites in
// the graph...
calculateGraph(SCCGraph);
- DOUT << " [BU] Done inlining SCC [" << SCCGraph.getGraphSize()
- << "+" << SCCGraph.getAuxFunctionCalls().size() << "]\n"
+ DOUT << " [BU] Done inlining SCC [" << SCCGraph->getGraphSize()
+ << "+" << SCCGraph->getAuxFunctionCalls().size() << "]\n"
<< "DONE with SCC #: " << MyID << "\n";
// We never have to revisit "SCC" processed functions...
@@ -346,35 +347,35 @@
return MyID; // == Min
}
-void BUDataStructures::CloneAuxIntoGlobal(DSGraph& G) {
- DSGraph& GG = *G.getGlobalsGraph();
+void BUDataStructures::CloneAuxIntoGlobal(DSGraph* G) {
+ DSGraph* GG = G->getGlobalsGraph();
ReachabilityCloner RC(GG, G, 0);
- for(DSGraph::afc_iterator ii = G.afc_begin(), ee = G.afc_end();
+ for(DSGraph::afc_iterator ii = G->afc_begin(), ee = G->afc_end();
ii != ee; ++ii) {
//cerr << "Pushing " << ii->getCallSite().getInstruction()->getOperand(0) << "\n";
//If we can, merge with an existing call site for this instruction
- if (GG.hasNodeForValue(ii->getCallSite().getInstruction()->getOperand(0))) {
+ if (GG->hasNodeForValue(ii->getCallSite().getInstruction()->getOperand(0))) {
DSGraph::afc_iterator GGii;
- for(GGii = GG.afc_begin(); GGii != GG.afc_end(); ++GGii)
+ for(GGii = GG->afc_begin(); GGii != GG->afc_end(); ++GGii)
if (GGii->getCallSite().getInstruction()->getOperand(0) ==
ii->getCallSite().getInstruction()->getOperand(0))
break;
- if (GGii != GG.afc_end())
+ if (GGii != GG->afc_end())
RC.cloneCallSite(*ii).mergeWith(*GGii);
else
- GG.getAuxFunctionCalls().push_front(RC.cloneCallSite(*ii));
+ GG->addAuxFunctionCall(RC.cloneCallSite(*ii));
} else {
- GG.getAuxFunctionCalls().push_front(RC.cloneCallSite(*ii));
+ GG->addAuxFunctionCall(RC.cloneCallSite(*ii));
}
}
}
-void BUDataStructures::calculateGraph(DSGraph &Graph) {
+void BUDataStructures::calculateGraph(DSGraph* Graph) {
// If this graph contains the main function, clone the globals graph into this
// graph before we inline callees and other fun stuff.
bool ContainsMain = false;
- DSGraph::ReturnNodesTy &ReturnNodes = Graph.getReturnNodes();
+ DSGraph::ReturnNodesTy &ReturnNodes = Graph->getReturnNodes();
for (DSGraph::ReturnNodesTy::iterator I = ReturnNodes.begin(),
E = ReturnNodes.end(); I != E; ++I)
@@ -388,22 +389,22 @@
// of a global, we have to make sure to link up nodes due to global-argument
// bindings.
if (ContainsMain || ReInlineGlobals) {
- const DSGraph &GG = *Graph.getGlobalsGraph();
+ const DSGraph* GG = Graph->getGlobalsGraph();
ReachabilityCloner RC(Graph, GG,
DSGraph::DontCloneCallNodes |
DSGraph::DontCloneAuxCallNodes);
if (ContainsMain) {
// Clone the global nodes into this graph.
- for (DSScalarMap::global_iterator I = GG.getScalarMap().global_begin(),
- E = GG.getScalarMap().global_end(); I != E; ++I)
+ for (DSScalarMap::global_iterator I = GG->getScalarMap().global_begin(),
+ E = GG->getScalarMap().global_end(); I != E; ++I)
if (isa<GlobalVariable>(*I))
- RC.getClonedNH(GG.getNodeForValue(*I));
+ RC.getClonedNH(GG->getNodeForValue(*I));
} else {
// Clone used the global nodes into this graph.
- for (DSScalarMap::global_iterator I = Graph.getScalarMap().global_begin(),
- E = Graph.getScalarMap().global_end(); I != E; ++I)
+ for (DSScalarMap::global_iterator I = Graph->getScalarMap().global_begin(),
+ E = Graph->getScalarMap().global_end(); I != E; ++I)
if (isa<GlobalVariable>(*I))
- RC.getClonedNH(GG.getNodeForValue(*I));
+ RC.getClonedNH(GG->getNodeForValue(*I));
}
}
@@ -411,7 +412,7 @@
// Move our call site list into TempFCs so that inline call sites go into the
// new call site list and doesn't invalidate our iterators!
std::list<DSCallSite> TempFCs;
- std::list<DSCallSite> &AuxCallsList = Graph.getAuxFunctionCalls();
+ std::list<DSCallSite> &AuxCallsList = Graph->getAuxFunctionCalls();
TempFCs.swap(AuxCallsList);
std::vector<const Function*> CalledFuncs;
@@ -447,18 +448,18 @@
const Function *Callee = CalledFuncs[0];
// Get the data structure graph for the called function.
- GI = &getDSGraph(*Callee); // Graph to inline
+ GI = getDSGraph(*Callee); // Graph to inline
DOUT << " Inlining graph for " << Callee->getName()
<< "[" << GI->getGraphSize() << "+"
<< GI->getAuxFunctionCalls().size() << "] into '"
- << Graph.getFunctionNames() << "' [" << Graph.getGraphSize() <<"+"
- << Graph.getAuxFunctionCalls().size() << "]\n";
- Graph.mergeInGraph(CS, *Callee, *GI,
- DSGraph::StripAllocaBit|DSGraph::DontCloneCallNodes|
- (isComplete?0:DSGraph::DontCloneAuxCallNodes));
+ << Graph->getFunctionNames() << "' [" << Graph->getGraphSize() <<"+"
+ << Graph->getAuxFunctionCalls().size() << "]\n";
+ Graph->mergeInGraph(CS, *Callee, *GI,
+ DSGraph::StripAllocaBit|DSGraph::DontCloneCallNodes|
+ (isComplete?0:DSGraph::DontCloneAuxCallNodes));
++NumInlines;
} else if (CalledFuncs.size() > 1) {
- DEBUG(std::cerr << "In Fns: " << Graph.getFunctionNames() << "\n");
+ DEBUG(std::cerr << "In Fns: " << Graph->getFunctionNames() << "\n");
DEBUG(std::cerr << " calls " << CalledFuncs.size()
<< " fns from site: " << CS.getCallSite().getInstruction()
<< " " << *CS.getCallSite().getInstruction());
@@ -489,7 +490,7 @@
// Start with a copy of the first graph.
GI = IndCallGraph.first = new DSGraph(getDSGraph(**I), GlobalECs);
- GI->setGlobalsGraph(Graph.getGlobalsGraph());
+ GI->setGlobalsGraph(Graph->getGlobalsGraph());
std::vector<DSNodeHandle> &Args = IndCallGraph.second;
// Get the argument nodes for the first callee. The return value is
@@ -528,13 +529,13 @@
DOUT << " Inlining multi callee graph "
<< "[" << GI->getGraphSize() << "+"
<< GI->getAuxFunctionCalls().size() << "] into '"
- << Graph.getFunctionNames() << "' [" << Graph.getGraphSize() <<"+"
- << Graph.getAuxFunctionCalls().size() << "]\n";
+ << Graph->getFunctionNames() << "' [" << Graph->getGraphSize() <<"+"
+ << Graph->getAuxFunctionCalls().size() << "]\n";
- Graph.mergeInGraph(CS, IndCallGraph.second, *GI,
- DSGraph::StripAllocaBit |
- DSGraph::DontCloneCallNodes|
- (isComplete?0:DSGraph::DontCloneAuxCallNodes));
+ Graph->mergeInGraph(CS, IndCallGraph.second, *GI,
+ DSGraph::StripAllocaBit |
+ DSGraph::DontCloneCallNodes|
+ (isComplete?0:DSGraph::DontCloneAuxCallNodes));
++NumInlines;
}
}
@@ -544,17 +545,17 @@
}
// Recompute the Incomplete markers
- Graph.maskIncompleteMarkers();
- Graph.markIncompleteNodes(DSGraph::MarkFormalArgs);
+ Graph->maskIncompleteMarkers();
+ Graph->markIncompleteNodes(DSGraph::MarkFormalArgs);
// Delete dead nodes. Treat globals that are unreachable but that can
// reach live nodes as live.
- Graph.removeDeadNodes(DSGraph::KeepUnreachableGlobals);
+ Graph->removeDeadNodes(DSGraph::KeepUnreachableGlobals);
// When this graph is finalized, clone the globals in the graph into the
// globals graph to make sure it has everything, from all graphs.
- DSScalarMap &MainSM = Graph.getScalarMap();
- ReachabilityCloner RC(*GlobalsGraph, Graph, DSGraph::StripAllocaBit);
+ DSScalarMap &MainSM = Graph->getScalarMap();
+ ReachabilityCloner RC(GlobalsGraph, Graph, DSGraph::StripAllocaBit);
// Clone everything reachable from globals in the function graph into the
// globals graph.
@@ -565,8 +566,8 @@
//Graph.writeGraphToFile(cerr, "bu_" + F.getName());
}
-void BUDataStructures::inlineUnresolved(DSGraph &Graph) {
- for (DSGraph::afc_iterator aii = Graph.afc_begin(), aee = Graph.afc_end();
+void BUDataStructures::inlineUnresolved(DSGraph* Graph) {
+ for (DSGraph::afc_iterator aii = Graph->afc_begin(), aee = Graph->afc_end();
aii != aee; ++aii) {
std::vector<const Function*> CalledFuncs;
DSCallSite CS = *aii;
@@ -585,18 +586,18 @@
const Function *Callee = CalledFuncs[0];
// Get the data structure graph for the called function.
- GI = &getDSGraph(*Callee); // Graph to inline
- if (GI == &Graph) continue;
+ GI = getDSGraph(*Callee); // Graph to inline
+ if (GI == Graph) continue;
DOUT << " Inlining graph for " << Callee->getName()
<< "[" << GI->getGraphSize() << "+"
<< GI->getAuxFunctionCalls().size() << "] into '"
- << Graph.getFunctionNames() << "' [" << Graph.getGraphSize() <<"+"
- << Graph.getAuxFunctionCalls().size() << "]\n";
- Graph.mergeInGraph(CS, *Callee, *GI,
+ << Graph->getFunctionNames() << "' [" << Graph->getGraphSize() <<"+"
+ << Graph->getAuxFunctionCalls().size() << "]\n";
+ Graph->mergeInGraph(CS, *Callee, *GI,
DSGraph::StripAllocaBit|DSGraph::DontCloneCallNodes);
++NumInlines;
} else {
- DEBUG(std::cerr << "In Fns: " << Graph.getFunctionNames() << "\n");
+ DEBUG(std::cerr << "In Fns: " << Graph->getFunctionNames() << "\n");
DEBUG(std::cerr << " calls " << CalledFuncs.size()
<< " fns from site: " << CS.getCallSite().getInstruction()
<< " " << *CS.getCallSite().getInstruction());
@@ -621,7 +622,7 @@
std::pair<DSGraph*, std::vector<DSNodeHandle> > &IndCallGraph =
IndCallGraphMap[CalledFuncs];
- if (IndCallGraph.first == &Graph) continue;
+ if (IndCallGraph.first == Graph) continue;
if (IndCallGraph.first == 0) {
std::vector<const Function*>::iterator I = CalledFuncs.begin(),
@@ -629,7 +630,7 @@
// Start with a copy of the first graph.
GI = IndCallGraph.first = new DSGraph(getDSGraph(**I), GlobalECs);
- GI->setGlobalsGraph(Graph.getGlobalsGraph());
+ GI->setGlobalsGraph(Graph->getGlobalsGraph());
std::vector<DSNodeHandle> &Args = IndCallGraph.second;
// Get the argument nodes for the first callee. The return value is
@@ -668,28 +669,28 @@
DOUT << " Inlining multi callee graph "
<< "[" << GI->getGraphSize() << "+"
<< GI->getAuxFunctionCalls().size() << "] into '"
- << Graph.getFunctionNames() << "' [" << Graph.getGraphSize() <<"+"
- << Graph.getAuxFunctionCalls().size() << "]\n";
+ << Graph->getFunctionNames() << "' [" << Graph->getGraphSize() <<"+"
+ << Graph->getAuxFunctionCalls().size() << "]\n";
- Graph.mergeInGraph(CS, IndCallGraph.second, *GI,
- DSGraph::StripAllocaBit |
- DSGraph::DontCloneCallNodes);
+ Graph->mergeInGraph(CS, IndCallGraph.second, *GI,
+ DSGraph::StripAllocaBit |
+ DSGraph::DontCloneCallNodes);
++NumInlines;
}
}
// Recompute the Incomplete markers
- Graph.maskIncompleteMarkers();
- Graph.markIncompleteNodes(DSGraph::MarkFormalArgs);
+ Graph->maskIncompleteMarkers();
+ Graph->markIncompleteNodes(DSGraph::MarkFormalArgs);
// Delete dead nodes. Treat globals that are unreachable but that can
// reach live nodes as live.
- Graph.removeDeadNodes(DSGraph::KeepUnreachableGlobals);
+ Graph->removeDeadNodes(DSGraph::KeepUnreachableGlobals);
// When this graph is finalized, clone the globals in the graph into the
// globals graph to make sure it has everything, from all graphs.
- DSScalarMap &MainSM = Graph.getScalarMap();
- ReachabilityCloner RC(*GlobalsGraph, Graph, DSGraph::StripAllocaBit);
+ DSScalarMap &MainSM = Graph->getScalarMap();
+ ReachabilityCloner RC(GlobalsGraph, Graph, DSGraph::StripAllocaBit);
// Clone everything reachable from globals in the function graph into the
// globals graph.
Modified: poolalloc/trunk/lib/DSA/CallTargets.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/CallTargets.cpp?rev=57830&r1=57829&r2=57830&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/CallTargets.cpp (original)
+++ poolalloc/trunk/lib/DSA/CallTargets.cpp Mon Oct 20 10:48:53 2008
@@ -53,7 +53,7 @@
if (!cs.getCalledFunction()) {
IndCall++;
DSNode* N = T->getDSGraph(*cs.getCaller())
- .getNodeForValue(cs.getCalledValue()).getNode();
+ ->getNodeForValue(cs.getCalledValue()).getNode();
N->addFullFunctionList(IndMap[cs]);
if (N->isCompleteNode() && IndMap[cs].size()) {
CompleteSites.insert(cs);
Modified: poolalloc/trunk/lib/DSA/DataStructure.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructure.cpp?rev=57830&r1=57829&r2=57830&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/DataStructure.cpp (original)
+++ poolalloc/trunk/lib/DSA/DataStructure.cpp Mon Oct 20 10:48:53 2008
@@ -1040,14 +1040,14 @@
// If SrcNH has globals and the destination graph has one of the same globals,
// merge this node with the destination node, which is much more efficient.
if (SN->globals_begin() != SN->globals_end()) {
- DSScalarMap &DestSM = Dest.getScalarMap();
+ DSScalarMap &DestSM = Dest->getScalarMap();
for (DSNode::globals_iterator I = SN->globals_begin(),E = SN->globals_end();
I != E; ++I) {
const GlobalValue *GV = *I;
DSScalarMap::iterator GI = DestSM.find(GV);
if (GI != DestSM.end() && !GI->second.isNull()) {
// We found one, use merge instead!
- merge(GI->second, Src.getNodeForValue(GV));
+ merge(GI->second, Src->getNodeForValue(GV));
assert(!NH.isNull() && "Didn't merge node!");
DSNode *NHN = NH.getNode();
return DSNodeHandle(NHN, NH.getOffset()+SrcNH.getOffset());
@@ -1055,7 +1055,7 @@
}
}
- DSNode *DN = new DSNode(*SN, &Dest, true /* Null out all links */);
+ DSNode *DN = new DSNode(*SN, Dest, true /* Null out all links */);
DN->maskNodeTypes(BitsToKeep);
NH = DN;
//DOUT << "getClonedNH: " << SN << " becomes " << DN << "\n";
@@ -1100,11 +1100,11 @@
for (DSNode::globals_iterator I = SN->globals_begin(), E = SN->globals_end();
I != E; ++I) {
const GlobalValue *GV = *I;
- const DSNodeHandle &SrcGNH = Src.getNodeForValue(GV);
+ const DSNodeHandle &SrcGNH = Src->getNodeForValue(GV);
DSNodeHandle &DestGNH = NodeMap[SrcGNH.getNode()];
assert(DestGNH.getNode() == NH.getNode() &&"Global mapping inconsistent");
- Dest.getNodeForValue(GV).mergeWith(DSNodeHandle(DestGNH.getNode(),
- DestGNH.getOffset()+SrcGNH.getOffset()));
+ Dest->getNodeForValue(GV).mergeWith(DSNodeHandle(DestGNH.getNode(),
+ DestGNH.getOffset()+SrcGNH.getOffset()));
}
NH.getNode()->mergeGlobals(SN->getGlobalsList());
@@ -1189,10 +1189,10 @@
for (DSNode::globals_iterator I = SN->globals_begin(),
E = SN->globals_end(); I != E; ++I) {
const GlobalValue *GV = *I;
- const DSNodeHandle &SrcGNH = Src.getNodeForValue(GV);
+ const DSNodeHandle &SrcGNH = Src->getNodeForValue(GV);
DSNodeHandle &DestGNH = NodeMap[SrcGNH.getNode()];
assert(DestGNH.getNode()==NH.getNode() &&"Global mapping inconsistent");
- Dest.getNodeForValue(GV).mergeWith(DSNodeHandle(DestGNH.getNode(),
+ Dest->getNodeForValue(GV).mergeWith(DSNodeHandle(DestGNH.getNode(),
DestGNH.getOffset()+SrcGNH.getOffset()));
}
NH.getNode()->mergeGlobals(SN->getGlobalsList());
@@ -1200,7 +1200,7 @@
} else {
// We cannot handle this case without allocating a temporary node. Fall
// back on being simple.
- DSNode *NewDN = new DSNode(*SN, &Dest, true /* Null out all links */);
+ DSNode *NewDN = new DSNode(*SN, Dest, true /* Null out all links */);
NewDN->maskNodeTypes(BitsToKeep);
unsigned NHOffset = NH.getOffset();
@@ -1220,11 +1220,11 @@
for (DSNode::globals_iterator I = SN->globals_begin(),
E = SN->globals_end(); I != E; ++I) {
const GlobalValue *GV = *I;
- const DSNodeHandle &SrcGNH = Src.getNodeForValue(GV);
+ const DSNodeHandle &SrcGNH = Src->getNodeForValue(GV);
DSNodeHandle &DestGNH = NodeMap[SrcGNH.getNode()];
assert(DestGNH.getNode()==NH.getNode() &&"Global mapping inconsistent");
assert(SrcGNH.getNode() == SN && "Global mapping inconsistent");
- Dest.getNodeForValue(GV).mergeWith(DSNodeHandle(DestGNH.getNode(),
+ Dest->getNodeForValue(GV).mergeWith(DSNodeHandle(DestGNH.getNode(),
DestGNH.getOffset()+SrcGNH.getOffset()));
}
}
@@ -1428,9 +1428,9 @@
}
-DSGraph::DSGraph(DSGraph &G, EquivalenceClasses<const GlobalValue*> &ECs,
+DSGraph::DSGraph(DSGraph* G, EquivalenceClasses<const GlobalValue*> &ECs,
unsigned CloneFlags)
- : GlobalsGraph(0), ScalarMap(ECs), TD(G.TD) {
+ : GlobalsGraph(0), ScalarMap(ECs), TD(G->TD) {
PrintAuxCalls = false;
cloneInto(G, CloneFlags);
}
@@ -1514,9 +1514,9 @@
///
/// The CloneFlags member controls various aspects of the cloning process.
///
-void DSGraph::cloneInto( DSGraph &G, unsigned CloneFlags) {
+void DSGraph::cloneInto( DSGraph* G, unsigned CloneFlags) {
TIME_REGION(X, "cloneInto");
- assert(&G != this && "Cannot clone graph into itself!");
+ assert(G != this && "Cannot clone graph into itself!");
NodeMapTy OldNodeMap;
@@ -1526,7 +1526,7 @@
| ((CloneFlags & StripIncompleteBit)? DSNode::IncompleteNode : 0);
BitsToClear |= DSNode::DeadNode; // Clear dead flag...
- for (node_const_iterator I = G.node_begin(), E = G.node_end(); I != E; ++I) {
+ for (node_const_iterator I = G->node_begin(), E = G->node_end(); I != E; ++I) {
assert(!I->isForwarding() &&
"Forward nodes shouldn't be in node list!");
DSNode *New = new DSNode(*I, this);
@@ -1550,8 +1550,8 @@
I->second.getNode()->remapLinks(OldNodeMap);
// Copy the scalar map... merging all of the global nodes...
- for (DSScalarMap::const_iterator I = G.ScalarMap.begin(),
- E = G.ScalarMap.end(); I != E; ++I) {
+ for (DSScalarMap::const_iterator I = G->ScalarMap.begin(),
+ E = G->ScalarMap.end(); I != E; ++I) {
DSNodeHandle &MappedNode = OldNodeMap[I->second.getNode()];
DSNodeHandle &H = ScalarMap.getRawEntryRef(I->first);
DSNode *MappedNodeN = MappedNode.getNode();
@@ -1561,19 +1561,19 @@
if (!(CloneFlags & DontCloneCallNodes)) {
// Copy the function calls list.
- for (fc_iterator I = G.fc_begin(), E = G.fc_end(); I != E; ++I)
+ for (fc_iterator I = G->fc_begin(), E = G->fc_end(); I != E; ++I)
FunctionCalls.push_back(DSCallSite(*I, OldNodeMap));
}
if (!(CloneFlags & DontCloneAuxCallNodes)) {
// Copy the auxiliary function calls list.
- for (afc_iterator I = G.afc_begin(), E = G.afc_end(); I != E; ++I)
+ for (afc_iterator I = G->afc_begin(), E = G->afc_end(); I != E; ++I)
AuxFunctionCalls.push_back(DSCallSite(*I, OldNodeMap));
}
// Map the return node pointers over...
- for (retnodes_iterator I = G.retnodes_begin(),
- E = G.retnodes_end(); I != E; ++I) {
+ for (retnodes_iterator I = G->retnodes_begin(),
+ E = G->retnodes_end(); I != E; ++I) {
const DSNodeHandle &Ret = I->second;
DSNodeHandle &MappedRet = OldNodeMap[Ret.getNode()];
DSNode *MappedRetN = MappedRet.getNode();
@@ -1587,28 +1587,29 @@
/// this graph, then clearing the RHS graph. Instead of performing this as
/// two seperate operations, do it as a single, much faster, one.
///
-void DSGraph::spliceFrom(DSGraph &RHS) {
+void DSGraph::spliceFrom(DSGraph* RHS) {
+ assert(this != RHS && "Splicing self");
// Change all of the nodes in RHS to think we are their parent.
- for (NodeListTy::iterator I = RHS.Nodes.begin(), E = RHS.Nodes.end();
+ for (NodeListTy::iterator I = RHS->Nodes.begin(), E = RHS->Nodes.end();
I != E; ++I)
I->setParentGraph(this);
// Take all of the nodes.
- Nodes.splice(Nodes.end(), RHS.Nodes);
+ Nodes.splice(Nodes.end(), RHS->Nodes);
// Take all of the calls.
- FunctionCalls.splice(FunctionCalls.end(), RHS.FunctionCalls);
- AuxFunctionCalls.splice(AuxFunctionCalls.end(), RHS.AuxFunctionCalls);
+ FunctionCalls.splice(FunctionCalls.end(), RHS->FunctionCalls);
+ AuxFunctionCalls.splice(AuxFunctionCalls.end(), RHS->AuxFunctionCalls);
// Take all of the return nodes.
if (ReturnNodes.empty()) {
- ReturnNodes.swap(RHS.ReturnNodes);
+ ReturnNodes.swap(RHS->ReturnNodes);
} else {
- ReturnNodes.insert(RHS.ReturnNodes.begin(), RHS.ReturnNodes.end());
- RHS.ReturnNodes.clear();
+ ReturnNodes.insert(RHS->ReturnNodes.begin(), RHS->ReturnNodes.end());
+ RHS->ReturnNodes.clear();
}
// Merge the scalar map in.
- ScalarMap.spliceFrom(RHS.ScalarMap);
+ ScalarMap.spliceFrom(RHS->ScalarMap);
}
/// spliceFrom - Copy all entries from RHS, then clear RHS.
@@ -1783,7 +1784,7 @@
// Clone the callee's graph into the current graph, keeping track of where
// scalars in the old graph _used_ to point, and of the new nodes matching
// nodes of the old graph.
- ReachabilityCloner RC(*this, Graph, CloneFlags);
+ ReachabilityCloner RC(this, &Graph, CloneFlags);
// Map the return node pointer over.
if (!CS.getRetVal().isNull())
@@ -2348,7 +2349,7 @@
// Strip all incomplete bits since they are short-lived properties and they
// will be correctly computed when rematerializing nodes into the functions.
//
- ReachabilityCloner GGCloner(*GlobalsGraph, *this, DSGraph::StripAllocaBit |
+ ReachabilityCloner GGCloner(GlobalsGraph, this, DSGraph::StripAllocaBit |
DSGraph::StripIncompleteBit);
// Mark all nodes reachable by (non-global) scalar nodes as alive...
@@ -2647,7 +2648,7 @@
///
void DSGraph::updateFromGlobalGraph() {
TIME_REGION(X, "updateFromGlobalGraph");
- ReachabilityCloner RC(*this, *GlobalsGraph, 0);
+ ReachabilityCloner RC(this, GlobalsGraph, 0);
// Clone the non-up-to-date global nodes into this graph.
for (DSScalarMap::global_iterator I = getScalarMap().global_begin(),
@@ -2678,12 +2679,12 @@
void DataStructures::deleteValue(Value *V) {
if (const Function *F = getFnForValue(V)) { // Function local value?
// If this is a function local value, just delete it from the scalar map!
- getDSGraph(*F).getScalarMap().eraseIfExists(V);
+ getDSGraph(*F)->getScalarMap().eraseIfExists(V);
return;
}
if (Function *F = dyn_cast<Function>(V)) {
- assert(getDSGraph(*F).getReturnNodes().size() == 1 &&
+ assert(getDSGraph(*F)->getReturnNodes().size() == 1 &&
"cannot handle scc's");
delete DSInfo[F];
DSInfo.erase(F);
@@ -2697,7 +2698,7 @@
if (From == To) return;
if (const Function *F = getFnForValue(From)) { // Function local value?
// If this is a function local value, just delete it from the scalar map!
- getDSGraph(*F).getScalarMap().copyScalarIfExists(From, To);
+ getDSGraph(*F)->getScalarMap().copyScalarIfExists(From, To);
return;
}
@@ -2716,8 +2717,7 @@
}
if (const Function *F = getFnForValue(To)) {
- DSGraph &G = getDSGraph(*F);
- G.getScalarMap().copyScalarIfExists(From, To);
+ getDSGraph(*F)->getScalarMap().copyScalarIfExists(From, To);
return;
}
@@ -2727,12 +2727,12 @@
abort();
}
-DSGraph& DataStructures::getOrCreateGraph(const Function* F) {
+DSGraph* DataStructures::getOrCreateGraph(const Function* F) {
assert(F && "No function");
DSGraph *&G = DSInfo[F];
if (!G) {
//Clone or Steal the Source Graph
- DSGraph &BaseGraph = GraphSource->getDSGraph(*F);
+ DSGraph* BaseGraph = GraphSource->getDSGraph(*F);
if (Clone) {
G = new DSGraph(BaseGraph, GlobalECs, DSGraph::DontCloneAuxCallNodes);
} else {
@@ -2751,7 +2751,7 @@
if (RI->first != F)
DSInfo[RI->first] = G;
}
- return *G;
+ return G;
}
@@ -2873,11 +2873,13 @@
}
void DataStructures::releaseMemory() {
+ hash_set<DSGraph*> toDelete;
for (DSInfoTy::iterator I = DSInfo.begin(), E = DSInfo.end(); I != E; ++I) {
- I->second->getReturnNodes().erase(I->first);
- if (I->second->getReturnNodes().empty())
- delete I->second;
+ I->second->getReturnNodes().clear();
+ toDelete.insert(I->second);
}
+ for (hash_set<DSGraph*>::iterator I = toDelete.begin(), E = toDelete.end(); I != E; ++I)
+ delete *I;
// Empty map so next time memory is released, data structures are not
// re-deleted.
Modified: poolalloc/trunk/lib/DSA/DataStructureAA.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructureAA.cpp?rev=57830&r1=57829&r2=57830&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/DataStructureAA.cpp (original)
+++ poolalloc/trunk/lib/DSA/DataStructureAA.cpp Mon Oct 20 10:48:53 2008
@@ -113,11 +113,11 @@
//
DSGraph *DSAA::getGraphForValue(const Value *V) {
if (const Instruction *I = dyn_cast<Instruction>(V))
- return &TD->getDSGraph(*I->getParent()->getParent());
+ return TD->getDSGraph(*I->getParent()->getParent());
else if (const Argument *A = dyn_cast<Argument>(V))
- return &TD->getDSGraph(*A->getParent());
+ return TD->getDSGraph(*A->getParent());
else if (const BasicBlock *BB = dyn_cast<BasicBlock>(V))
- return &TD->getDSGraph(*BB->getParent());
+ return TD->getDSGraph(*BB->getParent());
return 0;
}
@@ -130,9 +130,9 @@
assert((!G1 || !G2 || G1 == G2) && "Alias query for 2 different functions?");
// Get the graph to use...
- DSGraph &G = *(G1 ? G1 : (G2 ? G2 : &TD->getGlobalsGraph()));
+ DSGraph* G = G1 ? G1 : (G2 ? G2 : TD->getGlobalsGraph());
- const DSGraph::ScalarMapTy &GSM = G.getScalarMap();
+ const DSGraph::ScalarMapTy &GSM = G->getScalarMap();
DSGraph::ScalarMapTy::const_iterator I = GSM.find((Value*)V1);
if (I == GSM.end()) return NoAlias;
@@ -178,10 +178,10 @@
if (CS.getInstruction() == MapCS.getInstruction()) {
{
const Function *Caller = CS.getInstruction()->getParent()->getParent();
- DSGraph &CallerTDGraph = TD->getDSGraph(*Caller);
+ DSGraph* CallerTDGraph = TD->getDSGraph(*Caller);
// Figure out which node in the TD graph this pointer corresponds to.
- DSScalarMap &CallerSM = CallerTDGraph.getScalarMap();
+ DSScalarMap &CallerSM = CallerTDGraph->getScalarMap();
DSScalarMap::iterator NI = CallerSM.find(P);
if (NI == CallerSM.end()) {
InvalidateCache();
@@ -229,7 +229,7 @@
// the portion of the program we have analyzed, we can draw conclusions
// based on whether the global escapes the program.
Function *Caller = CS.getInstruction()->getParent()->getParent();
- DSGraph *G = &TD->getDSGraph(*Caller);
+ DSGraph *G = TD->getDSGraph(*Caller);
DSScalarMap::iterator NI = G->getScalarMap().find(P);
if (NI == G->getScalarMap().end()) {
// If it wasn't in the local function graph, check the global graph. This
@@ -251,11 +251,11 @@
// Get the graphs for the callee and caller. Note that we want the BU graph
// for the callee because we don't want all caller's effects incorporated!
const Function *Caller = CS.getInstruction()->getParent()->getParent();
- DSGraph &CallerTDGraph = TD->getDSGraph(*Caller);
- DSGraph &CalleeBUGraph = BU->getDSGraph(*F);
+ DSGraph* CallerTDGraph = TD->getDSGraph(*Caller);
+ DSGraph* CalleeBUGraph = BU->getDSGraph(*F);
// Figure out which node in the TD graph this pointer corresponds to.
- DSScalarMap &CallerSM = CallerTDGraph.getScalarMap();
+ DSScalarMap &CallerSM = CallerTDGraph->getScalarMap();
DSScalarMap::iterator NI = CallerSM.find(P);
if (NI == CallerSM.end()) {
ModRefResult Result = ModRef;
@@ -267,9 +267,9 @@
"This isn't a global that DSA inconsiderately dropped "
"from the graph?");
- DSGraph &GG = *CallerTDGraph.getGlobalsGraph();
- DSScalarMap::iterator NI = GG.getScalarMap().find(P);
- if (NI != GG.getScalarMap().end() && !NI->second.isNull()) {
+ DSGraph* GG = CallerTDGraph->getGlobalsGraph();
+ DSScalarMap::iterator NI = GG->getScalarMap().find(P);
+ if (NI != GG->getScalarMap().end() && !NI->second.isNull()) {
// Otherwise, if the node is only M or R, return this. This can be
// useful for globals that should be marked const but are not.
DSNode *N = NI->second.getNode();
@@ -287,9 +287,9 @@
// Compute the mapping from nodes in the callee graph to the nodes in the
// caller graph for this call site.
DSGraph::NodeMapTy CalleeCallerMap;
- DSCallSite DSCS = CallerTDGraph.getDSCallSiteForCallSite(CS);
- CallerTDGraph.computeCalleeCallerMapping(DSCS, *F, CalleeBUGraph,
- CalleeCallerMap);
+ DSCallSite DSCS = CallerTDGraph->getDSCallSiteForCallSite(CS);
+ CallerTDGraph->computeCalleeCallerMapping(DSCS, *F, *CalleeBUGraph,
+ CalleeCallerMap);
// Remember the mapping and the call site for future queries.
MapCS = CS;
Modified: poolalloc/trunk/lib/DSA/DataStructureOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructureOpt.cpp?rev=57830&r1=57829&r2=57830&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/DataStructureOpt.cpp (original)
+++ poolalloc/trunk/lib/DSA/DataStructureOpt.cpp Mon Oct 20 10:48:53 2008
@@ -60,8 +60,8 @@
/// global variables.
///
bool DSOpt::OptimizeGlobals(Module &M) {
- DSGraph &GG = TD->getGlobalsGraph();
- const DSGraph::ScalarMapTy &SM = GG.getScalarMap();
+ DSGraph* GG = TD->getGlobalsGraph();
+ const DSGraph::ScalarMapTy &SM = GG->getScalarMap();
bool Changed = false;
for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I)
Modified: poolalloc/trunk/lib/DSA/DataStructureStats.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructureStats.cpp?rev=57830&r1=57829&r2=57830&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/DataStructureStats.cpp (original)
+++ poolalloc/trunk/lib/DSA/DataStructureStats.cpp Mon Oct 20 10:48:53 2008
@@ -146,7 +146,7 @@
bool DSGraphStats::runOnFunction(Function& F) {
- TDGraph = &getAnalysis<TDDataStructures>().getDSGraph(F);
+ TDGraph = getAnalysis<TDDataStructures>().getDSGraph(F);
countCallees(F);
visit(F);
return true;
Modified: poolalloc/trunk/lib/DSA/EquivClassGraphs.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/EquivClassGraphs.cpp?rev=57830&r1=57829&r2=57830&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/EquivClassGraphs.cpp (original)
+++ poolalloc/trunk/lib/DSA/EquivClassGraphs.cpp Mon Oct 20 10:48:53 2008
@@ -65,7 +65,7 @@
MI != GlobalECs.member_end(); ++MI) {
if (const Function* F = dyn_cast<Function>(*MI)) {
if (!BaseGraph) {
- BaseGraph = &getOrCreateGraph(F);
+ BaseGraph = getOrCreateGraph(F);
BaseGraph->getFunctionArgumentsForCall(F, Args);
} else if (BaseGraph->containsFunction(F)) {
//already merged
Modified: poolalloc/trunk/lib/DSA/GraphChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/GraphChecker.cpp?rev=57830&r1=57829&r2=57830&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/GraphChecker.cpp (original)
+++ poolalloc/trunk/lib/DSA/GraphChecker.cpp Mon Oct 20 10:48:53 2008
@@ -71,7 +71,7 @@
void print(std::ostream &O, const Module *M) const {}
private:
- void verify(const DSGraph &G);
+ void verify(const DSGraph* G);
};
RegisterPass<DSGC> X("datastructure-gc", "DSA Graph Checking Pass");
@@ -120,14 +120,14 @@
/// verify - This is the function which checks to make sure that all of the
/// invariants established on the command line are true.
///
-void DSGC::verify(const DSGraph &G) {
+void DSGC::verify(const DSGraph* G) {
// Loop over all of the nodes, checking to see if any are collapsed...
if (AbortIfAnyCollapsed) {
- for (DSGraph::node_const_iterator I = G.node_begin(), E = G.node_end();
+ for (DSGraph::node_const_iterator I = G->node_begin(), E = G->node_end();
I != E; ++I)
if (I->isNodeCompletelyFolded()) {
cerr << "Node is collapsed: ";
- I->print(cerr, &G);
+ I->print(cerr, G);
abort();
}
}
@@ -168,7 +168,7 @@
// Now we loop over all of the scalars, checking to see if any are collapsed
// that are not supposed to be, or if any are merged together.
- const DSGraph::ScalarMapTy &SM = G.getScalarMap();
+ const DSGraph::ScalarMapTy &SM = G->getScalarMap();
std::map<DSNode*, std::string> AbortIfMergedNodes;
for (DSGraph::ScalarMapTy::const_iterator I = SM.begin(), E = SM.end();
@@ -180,7 +180,7 @@
// Verify it is not collapsed if it is not supposed to be...
if (N->isNodeCompletelyFolded() && AbortIfCollapsedS.count(Name)) {
cerr << "Node for value '%" << Name << "' is collapsed: ";
- N->print(cerr, &G);
+ N->print(cerr, G);
abort();
}
@@ -188,7 +188,7 @@
cerr << "Node flags are not as expected for node: " << Name
<< " (" << CheckFlagsM[Name] << ":" <<N->getNodeFlags()
<< ")\n";
- N->print(cerr, &G);
+ N->print(cerr, G);
abort();
}
@@ -197,7 +197,7 @@
if (AbortIfMergedNodes.count(N)) {
cerr << "Nodes for values '%" << Name << "' and '%"
<< AbortIfMergedNodes[N] << "' is merged: ";
- N->print(cerr, &G);
+ N->print(cerr, G);
abort();
}
AbortIfMergedNodes[N] = Name;
Modified: poolalloc/trunk/lib/DSA/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=57830&r1=57829&r2=57830&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/Local.cpp (original)
+++ poolalloc/trunk/lib/DSA/Local.cpp Mon Oct 20 10:48:53 2008
@@ -140,7 +140,7 @@
// If there are any constant globals referenced in this function, merge their
// initializers into the local graph from the globals graph.
if (g.getScalarMap().global_begin() != g.getScalarMap().global_end()) {
- ReachabilityCloner RC(g, *g.getGlobalsGraph(), 0);
+ ReachabilityCloner RC(&g, g.getGlobalsGraph(), 0);
for (DSScalarMap::global_iterator I = g.getScalarMap().global_begin();
I != g.getScalarMap().global_end(); ++I)
Modified: poolalloc/trunk/lib/DSA/Printer.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Printer.cpp?rev=57830&r1=57829&r2=57830&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/Printer.cpp (original)
+++ poolalloc/trunk/lib/DSA/Printer.cpp Mon Oct 20 10:48:53 2008
@@ -283,15 +283,15 @@
unsigned TotalNumNodes = 0, TotalCallNodes = 0;
for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I)
if (C.hasDSGraph(*I)) {
- DSGraph &Gr = C.getDSGraph((Function&)*I);
- unsigned NumCalls = Gr.shouldPrintAuxCalls() ?
- Gr.getAuxFunctionCalls().size() : Gr.getFunctionCalls().size();
+ DSGraph* Gr = C.getDSGraph((Function&)*I);
+ unsigned NumCalls = Gr->shouldPrintAuxCalls() ?
+ Gr->getAuxFunctionCalls().size() : Gr->getFunctionCalls().size();
bool IsDuplicateGraph = false;
if (I->getName() == "main" || !OnlyPrintMain) {
- const Function *SCCFn = Gr.retnodes_begin()->first;
+ const Function *SCCFn = Gr->retnodes_begin()->first;
if (&*I == SCCFn) {
- Gr.writeGraphToFile(O, Prefix+I->getName());
+ Gr->writeGraphToFile(O, Prefix+I->getName());
} else {
IsDuplicateGraph = true; // Don't double count node/call nodes.
O << "Didn't write '" << Prefix+I->getName()
@@ -299,36 +299,36 @@
<< "\n";
}
} else {
- const Function *SCCFn = Gr.retnodes_begin()->first;
+ const Function *SCCFn = Gr->retnodes_begin()->first;
if (&*I == SCCFn) {
O << "Skipped Writing '" << Prefix+I->getName() << ".dot'... ["
- << Gr.getGraphSize() << "+" << NumCalls << "]\n";
+ << Gr->getGraphSize() << "+" << NumCalls << "]\n";
} else {
IsDuplicateGraph = true; // Don't double count node/call nodes.
}
}
if (!IsDuplicateGraph) {
- unsigned GraphSize = Gr.getGraphSize();
+ unsigned GraphSize = Gr->getGraphSize();
if (MaxGraphSize < GraphSize) MaxGraphSize = GraphSize;
- TotalNumNodes += Gr.getGraphSize();
+ TotalNumNodes += Gr->getGraphSize();
TotalCallNodes += NumCalls;
- for (DSGraph::node_iterator NI = Gr.node_begin(), E = Gr.node_end();
+ for (DSGraph::node_iterator NI = Gr->node_begin(), E = Gr->node_end();
NI != E; ++NI)
if (NI->isNodeCompletelyFolded())
++NumFoldedNodes;
}
}
- DSGraph &GG = C.getGlobalsGraph();
- TotalNumNodes += GG.getGraphSize();
- TotalCallNodes += GG.getFunctionCalls().size();
+ DSGraph* GG = C.getGlobalsGraph();
+ TotalNumNodes += GG->getGraphSize();
+ TotalCallNodes += GG->getFunctionCalls().size();
if (!OnlyPrintMain) {
- GG.writeGraphToFile(O, Prefix+"GlobalsGraph");
+ GG->writeGraphToFile(O, Prefix+"GlobalsGraph");
} else {
O << "Skipped Writing '" << Prefix << "GlobalsGraph.dot'... ["
- << GG.getGraphSize() << "+" << GG.getFunctionCalls().size() << "]\n";
+ << GG->getGraphSize() << "+" << GG->getFunctionCalls().size() << "]\n";
}
O << "\nGraphs contain [" << TotalNumNodes << "+" << TotalCallNodes
Modified: poolalloc/trunk/lib/DSA/StdLibPass.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/StdLibPass.cpp?rev=57830&r1=57829&r2=57830&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/StdLibPass.cpp (original)
+++ poolalloc/trunk/lib/DSA/StdLibPass.cpp Mon Oct 20 10:48:53 2008
@@ -170,10 +170,10 @@
ii != ee; ++ii)
if (CallInst* CI = dyn_cast<CallInst>(ii))
if (CI->getOperand(0) == F) {
- DSGraph& Graph = getDSGraph(*CI->getParent()->getParent());
+ DSGraph* Graph = getDSGraph(*CI->getParent()->getParent());
//delete the call
DOUT << "Removing " << F->getName() << " from " << CI->getParent()->getParent()->getName() << "\n";
- Graph.removeFunctionCalls(*F);
+ Graph->removeFunctionCalls(*F);
}
}
@@ -194,46 +194,46 @@
ii != ee; ++ii)
if (CallInst* CI = dyn_cast<CallInst>(ii))
if (CI->getOperand(0) == F) {
- DSGraph& Graph = getDSGraph(*CI->getParent()->getParent());
+ DSGraph* Graph = getDSGraph(*CI->getParent()->getParent());
if (recFuncs[x].action.read[0])
- Graph.getNodeForValue(CI).getNode()->setReadMarker();
+ Graph->getNodeForValue(CI).getNode()->setReadMarker();
if (recFuncs[x].action.write[0])
- Graph.getNodeForValue(CI).getNode()->setModifiedMarker();
+ Graph->getNodeForValue(CI).getNode()->setModifiedMarker();
if (recFuncs[x].action.heap[0])
- Graph.getNodeForValue(CI).getNode()->setHeapMarker();
+ Graph->getNodeForValue(CI).getNode()->setHeapMarker();
for (unsigned y = 1; y < CI->getNumOperands(); ++y)
if (recFuncs[x].action.read[y])
if (isa<PointerType>(CI->getOperand(y)->getType()))
- if (DSNode * Node=Graph.getNodeForValue(CI->getOperand(y)).getNode())
+ if (DSNode * Node=Graph->getNodeForValue(CI->getOperand(y)).getNode())
Node->setReadMarker();
for (unsigned y = 1; y < CI->getNumOperands(); ++y)
if (recFuncs[x].action.write[y])
if (isa<PointerType>(CI->getOperand(y)->getType()))
- if (DSNode * Node=Graph.getNodeForValue(CI->getOperand(y)).getNode())
+ if (DSNode * Node=Graph->getNodeForValue(CI->getOperand(y)).getNode())
Node->setModifiedMarker();
for (unsigned y = 1; y < CI->getNumOperands(); ++y)
if (recFuncs[x].action.heap[y])
if (isa<PointerType>(CI->getOperand(y)->getType()))
- if (DSNode * Node=Graph.getNodeForValue(CI->getOperand(y)).getNode())
+ if (DSNode * Node=Graph->getNodeForValue(CI->getOperand(y)).getNode())
Node->setHeapMarker();
std::vector<DSNodeHandle> toMerge;
if (recFuncs[x].action.mergeWithRet)
- toMerge.push_back(Graph.getNodeForValue(CI));
+ toMerge.push_back(Graph->getNodeForValue(CI));
if (recFuncs[x].action.mergeAllArgs || recFuncs[x].action.mergeWithRet)
for (unsigned y = 1; y < CI->getNumOperands(); ++y)
if (isa<PointerType>(CI->getOperand(y)->getType()))
- toMerge.push_back(Graph.getNodeForValue(CI->getOperand(y)));
+ toMerge.push_back(Graph->getNodeForValue(CI->getOperand(y)));
for (unsigned y = 1; y < toMerge.size(); ++y)
toMerge[0].mergeWith(toMerge[y]);
if (recFuncs[x].action.collapse) {
if (isa<PointerType>(CI->getType()))
- Graph.getNodeForValue(CI).getNode()->foldNodeCompletely();
+ Graph->getNodeForValue(CI).getNode()->foldNodeCompletely();
for (unsigned y = 1; y < CI->getNumOperands(); ++y)
if (isa<PointerType>(CI->getOperand(y)->getType()))
- if (DSNode * Node=Graph.getNodeForValue(CI->getOperand(y)).getNode())
+ if (DSNode * Node=Graph->getNodeForValue(CI->getOperand(y)).getNode())
Node->foldNodeCompletely();
}
}
@@ -241,10 +241,10 @@
ii != ee; ++ii)
if (CallInst* CI = dyn_cast<CallInst>(ii))
if (CI->getOperand(0) == F) {
- DSGraph& Graph = getDSGraph(*CI->getParent()->getParent());
+ DSGraph* Graph = getDSGraph(*CI->getParent()->getParent());
//delete the call
DOUT << "Removing " << F->getName() << " from " << CI->getParent()->getParent()->getName() << "\n";
- Graph.removeFunctionCalls(*F);
+ Graph->removeFunctionCalls(*F);
}
}
Modified: poolalloc/trunk/lib/DSA/TopDownClosure.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/TopDownClosure.cpp?rev=57830&r1=57829&r2=57830&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/TopDownClosure.cpp (original)
+++ poolalloc/trunk/lib/DSA/TopDownClosure.cpp Mon Oct 20 10:48:53 2008
@@ -125,7 +125,7 @@
// Visit each of the graphs in reverse post-order now!
while (!PostOrder.empty()) {
- InlineCallersIntoGraph(*PostOrder.back());
+ InlineCallersIntoGraph(PostOrder.back());
PostOrder.pop_back();
}
}
@@ -148,29 +148,29 @@
hash_set<DSGraph*> &Visited,
std::vector<DSGraph*> &PostOrder) {
if (F.isDeclaration()) return;
- DSGraph &G = getOrCreateGraph(&F);
- if (Visited.count(&G)) return;
- Visited.insert(&G);
+ DSGraph* G = getOrCreateGraph(&F);
+ if (Visited.count(G)) return;
+ Visited.insert(G);
// Recursively traverse all of the callee graphs.
- for (DSGraph::fc_iterator CI = G.fc_begin(), CE = G.fc_end(); CI != CE; ++CI){
+ for (DSGraph::fc_iterator CI = G->fc_begin(), CE = G->fc_end(); CI != CE; ++CI){
Instruction *CallI = CI->getCallSite().getInstruction();
for (callee_iterator I = callee_begin(CallI),
E = callee_end(CallI); I != E; ++I)
ComputePostOrder(**I, Visited, PostOrder);
}
- PostOrder.push_back(&G);
+ PostOrder.push_back(G);
}
/// InlineCallersIntoGraph - Inline all of the callers of the specified DS graph
/// into it, then recompute completeness of nodes in the resultant graph.
-void TDDataStructures::InlineCallersIntoGraph(DSGraph &DSG) {
+void TDDataStructures::InlineCallersIntoGraph(DSGraph* DSG) {
// Inline caller graphs into this graph. First step, get the list of call
// sites that call into this graph.
std::vector<CallerCallEdge> EdgesFromCaller;
std::map<DSGraph*, std::vector<CallerCallEdge> >::iterator
- CEI = CallerEdges.find(&DSG);
+ CEI = CallerEdges.find(DSG);
if (CEI != CallerEdges.end()) {
std::swap(CEI->second, EdgesFromCaller);
CallerEdges.erase(CEI);
@@ -186,21 +186,21 @@
// post-pass over all of the graphs. We need to take cloning out of
// removeDeadNodes and gut removeDeadNodes at the same time first though. :(
{
- DSGraph &GG = *DSG.getGlobalsGraph();
+ DSGraph* GG = DSG->getGlobalsGraph();
ReachabilityCloner RC(DSG, GG,
DSGraph::DontCloneCallNodes |
DSGraph::DontCloneAuxCallNodes);
for (DSScalarMap::global_iterator
- GI = DSG.getScalarMap().global_begin(),
- E = DSG.getScalarMap().global_end(); GI != E; ++GI)
- RC.getClonedNH(GG.getNodeForValue(*GI));
+ GI = DSG->getScalarMap().global_begin(),
+ E = DSG->getScalarMap().global_end(); GI != E; ++GI)
+ RC.getClonedNH(GG->getNodeForValue(*GI));
}
- DOUT << "[TD] Inlining callers into '" << DSG.getFunctionNames() << "'\n";
+ DOUT << "[TD] Inlining callers into '" << DSG->getFunctionNames() << "'\n";
// Iteratively inline caller graphs into this graph.
while (!EdgesFromCaller.empty()) {
- DSGraph &CallerGraph = *EdgesFromCaller.back().CallerGraph;
+ DSGraph* CallerGraph = EdgesFromCaller.back().CallerGraph;
// Iterate through all of the call sites of this graph, cloning and merging
// any nodes required by the call.
@@ -213,7 +213,7 @@
const DSCallSite &CS = *EdgesFromCaller.back().CS;
const Function &CF = *EdgesFromCaller.back().CalledFunction;
DOUT << " [TD] Inlining graph into Fn '" << CF.getName() << "' from ";
- if (CallerGraph.getReturnNodes().empty())
+ if (CallerGraph->getReturnNodes().empty())
DOUT << "SYNTHESIZED INDIRECT GRAPH";
else
DOUT << "Fn '" << CS.getCallSite().getInstruction()->
@@ -222,25 +222,25 @@
// Get the formal argument and return nodes for the called function and
// merge them with the cloned subgraph.
- DSCallSite T1 = DSG.getCallSiteForArguments(CF);
+ DSCallSite T1 = DSG->getCallSiteForArguments(CF);
RC.mergeCallSite(T1, CS);
++NumTDInlines;
EdgesFromCaller.pop_back();
} while (!EdgesFromCaller.empty() &&
- EdgesFromCaller.back().CallerGraph == &CallerGraph);
+ EdgesFromCaller.back().CallerGraph == CallerGraph);
}
// Next, now that this graph is finalized, we need to recompute the
// incompleteness markers for this graph and remove unreachable nodes.
- DSG.maskIncompleteMarkers();
+ DSG->maskIncompleteMarkers();
// If any of the functions has incomplete incoming arguments, don't mark any
// of them as complete.
bool HasIncompleteArgs = false;
- for (DSGraph::retnodes_iterator I = DSG.retnodes_begin(),
- E = DSG.retnodes_end(); I != E; ++I)
+ for (DSGraph::retnodes_iterator I = DSG->retnodes_begin(),
+ E = DSG->retnodes_end(); I != E; ++I)
if (ArgsRemainIncomplete.count(I->first)) {
HasIncompleteArgs = true;
break;
@@ -249,28 +249,28 @@
// Recompute the Incomplete markers. Depends on whether args are complete
unsigned Flags
= HasIncompleteArgs ? DSGraph::MarkFormalArgs : DSGraph::IgnoreFormalArgs;
- DSG.markIncompleteNodes(Flags | DSGraph::IgnoreGlobals);
+ DSG->markIncompleteNodes(Flags | DSGraph::IgnoreGlobals);
// Delete dead nodes. Treat globals that are unreachable as dead also.
- DSG.removeDeadNodes(DSGraph::RemoveUnreachableGlobals);
+ DSG->removeDeadNodes(DSGraph::RemoveUnreachableGlobals);
// We are done with computing the current TD Graph! Finally, before we can
// finish processing this function, we figure out which functions it calls and
// records these call graph edges, so that we have them when we process the
// callee graphs.
- if (DSG.fc_begin() == DSG.fc_end()) return;
+ if (DSG->fc_begin() == DSG->fc_end()) return;
// Loop over all the call sites and all the callees at each call site, and add
// edges to the CallerEdges structure for each callee.
- for (DSGraph::fc_iterator CI = DSG.fc_begin(), E = DSG.fc_end();
+ for (DSGraph::fc_iterator CI = DSG->fc_begin(), E = DSG->fc_end();
CI != E; ++CI) {
// Handle direct calls efficiently.
if (CI->isDirectCall()) {
if (!CI->getCalleeFunc()->isDeclaration() &&
- !DSG.getReturnNodes().count(CI->getCalleeFunc()))
- CallerEdges[&getOrCreateGraph(CI->getCalleeFunc())]
- .push_back(CallerCallEdge(&DSG, &*CI, CI->getCalleeFunc()));
+ !DSG->getReturnNodes().count(CI->getCalleeFunc()))
+ CallerEdges[getOrCreateGraph(CI->getCalleeFunc())]
+ .push_back(CallerCallEdge(DSG, &*CI, CI->getCalleeFunc()));
continue;
}
@@ -280,7 +280,7 @@
callee_begin(CallI), IPE = callee_end(CallI);
// Skip over all calls to this graph (SCC calls).
- while (IPI != IPE && &getDSGraph(**IPI) == &DSG)
+ while (IPI != IPE && getDSGraph(**IPI) == DSG)
++IPI;
// All SCC calls?
@@ -290,15 +290,15 @@
++IPI;
// Skip over more SCC calls.
- while (IPI != IPE && &getDSGraph(**IPI) == &DSG)
+ while (IPI != IPE && getDSGraph(**IPI) == DSG)
++IPI;
// If there is exactly one callee from this call site, remember the edge in
// CallerEdges.
if (IPI == IPE) {
if (!FirstCallee->isDeclaration())
- CallerEdges[&getOrCreateGraph(FirstCallee)]
- .push_back(CallerCallEdge(&DSG, &*CI, FirstCallee));
+ CallerEdges[getOrCreateGraph(FirstCallee)]
+ .push_back(CallerCallEdge(DSG, &*CI, FirstCallee));
continue;
}
@@ -326,7 +326,7 @@
IndCallGraph = IndCallRecI->second;
} else {
// Otherwise, create a new DSGraph to represent this.
- IndCallGraph = new DSGraph(DSG.getGlobalECs(), DSG.getTargetData());
+ IndCallGraph = new DSGraph(DSG->getGlobalECs(), DSG->getTargetData());
// Make a nullary dummy call site, which will eventually get some content
// merged into it. The actual callee function doesn't matter here, so we
// just pass it something to keep the ctor happy.
@@ -342,16 +342,16 @@
// exactly once.
DSCallSite *NCS = &IndCallGraph->getFunctionCalls().front();
for (unsigned i = 0, e = Callees.size(); i != e; ++i) {
- DSGraph& CalleeGraph = getDSGraph(*Callees[i]);
- if (&CalleeGraph != &DSG)
- CallerEdges[&CalleeGraph].push_back(CallerCallEdge(IndCallGraph, NCS,
- Callees[i]));
+ DSGraph* CalleeGraph = getDSGraph(*Callees[i]);
+ if (CalleeGraph != DSG)
+ CallerEdges[CalleeGraph].push_back(CallerCallEdge(IndCallGraph, NCS,
+ Callees[i]));
}
}
// Now that we know which graph to use for this, merge the caller
// information into the graph, based on information from the call site.
- ReachabilityCloner RC(*IndCallGraph, DSG, 0);
+ ReachabilityCloner RC(IndCallGraph, DSG, 0);
RC.mergeCallSite(IndCallGraph->getFunctionCalls().front(), *CI);
}
}
Modified: poolalloc/trunk/lib/PoolAllocate/AccessTrace.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/AccessTrace.cpp?rev=57830&r1=57829&r2=57830&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/AccessTrace.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/AccessTrace.cpp Mon Oct 20 10:48:53 2008
@@ -38,7 +38,7 @@
void getAnalysisUsage(AnalysisUsage &AU) const;
- const DSGraph &getGraphForFunc(PA::FuncInfo *FI) const {
+ const DSGraph* getGraphForFunc(PA::FuncInfo *FI) const {
return G->getDSGraph(FI->F);
}
static char ID;
@@ -46,7 +46,7 @@
private:
void InitializeLibraryFunctions(Module &M);
void InstrumentAccess(Instruction *I, Value *Ptr,
- PA::FuncInfo *FI, DSGraph &DSG);
+ PA::FuncInfo *FI, DSGraph* DSG);
};
char PoolAccessTrace::ID = 0;
@@ -72,7 +72,7 @@
}
void PoolAccessTrace::InstrumentAccess(Instruction *I, Value *Ptr,
- PA::FuncInfo *FI, DSGraph &DSG) {
+ PA::FuncInfo *FI, DSGraph* DSG) {
// Don't trace loads of globals or the stack.
if (isa<Constant>(Ptr) || isa<AllocaInst>(Ptr)) return;
@@ -82,7 +82,7 @@
// Value didn't exist in the orig program (pool desc?).
return;
}
- DSNode *Node = DSG.getNodeForValue(MappedPtr).getNode();
+ DSNode *Node = DSG->getNodeForValue(MappedPtr).getNode();
if (Node == 0) return;
Value *PD = FI->PoolDescriptors[Node];
@@ -124,7 +124,7 @@
continue;
// Get the DSGraph for this function.
- DSGraph &DSG = G->getDSGraph(FI->F);
+ DSGraph* DSG = G->getDSGraph(FI->F);
for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB)
for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I)
Modified: poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp?rev=57830&r1=57829&r2=57830&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp Mon Oct 20 10:48:53 2008
@@ -127,7 +127,7 @@
struct AllNodesHeuristic : public Heuristic {
void AssignToPools(const std::vector<const DSNode*> &NodesToPA,
- Function *F, DSGraph &G,
+ Function *F, DSGraph* G,
std::vector<OnePool> &ResultPools) {
for (unsigned i = 0, e = NodesToPA.size(); i != e; ++i)
ResultPools.push_back(OnePool(NodesToPA[i]));
@@ -145,13 +145,13 @@
struct AllButUnreachableFromMemoryHeuristic : public Heuristic {
void AssignToPools(const std::vector<const DSNode*> &NodesToPA,
- Function *F, DSGraph &G,
+ Function *F, DSGraph* G,
std::vector<OnePool> &ResultPools) {
// Build a set of all nodes that are reachable from another node in the
// graph. Here we ignore scalar nodes that are only globals as they are
// often global pointers to big arrays.
std::set<const DSNode*> ReachableFromMemory;
- for (DSGraph::node_iterator I = G.node_begin(), E = G.node_end();
+ for (DSGraph::node_iterator I = G->node_begin(), E = G->node_end();
I != E; ++I) {
DSNode *N = I;
// Ignore nodes that are just globals and not arrays.
@@ -183,7 +183,7 @@
struct CyclicNodesHeuristic : public Heuristic {
void AssignToPools(const std::vector<const DSNode*> &NodesToPA,
- Function *F, DSGraph &G,
+ Function *F, DSGraph* G,
std::vector<OnePool> &ResultPools);
};
@@ -196,7 +196,7 @@
void CyclicNodesHeuristic::AssignToPools(const std::vector<const
DSNode*> &NodesToPA,
- Function *F, DSGraph &G,
+ Function *F, DSGraph* G,
std::vector<OnePool> &ResultPools) {
for (unsigned i = 0, e = NodesToPA.size(); i != e; ++i)
if (NodeExistsInCycle(NodesToPA[i]))
@@ -212,7 +212,7 @@
struct SmartCoallesceNodesHeuristic : public Heuristic {
void AssignToPools(const std::vector<const DSNode*> &NodesToPA,
- Function *F, DSGraph &G,
+ Function *F, DSGraph* G,
std::vector<OnePool> &ResultPools) {
// For globals, do not pool allocate unless the node is cyclic and not an
// array (unless it's collapsed).
@@ -397,7 +397,7 @@
virtual bool IsRealHeuristic() { return false; }
void AssignToPools(const std::vector<const DSNode*> &NodesToPA,
- Function *F, DSGraph &G,
+ Function *F, DSGraph* G,
std::vector<OnePool> &ResultPools) {
if (TheGlobalPD == 0)
TheGlobalPD = PA->CreateGlobalPool(0, 0);
@@ -421,7 +421,7 @@
virtual bool IsRealHeuristic() { return false; }
void AssignToPools(const std::vector<const DSNode*> &NodesToPA,
- Function *F, DSGraph &G,
+ Function *F, DSGraph* G,
std::vector<OnePool> &ResultPools) {
// For this heuristic, we assign everything possible to its own pool.
for (unsigned i = 0, e = NodesToPA.size(); i != e; ++i)
@@ -485,7 +485,7 @@
virtual bool IsRealHeuristic() { return false; }
void AssignToPools(const std::vector<const DSNode*> &NodesToPA,
- Function *F, DSGraph &G,
+ Function *F, DSGraph* G,
std::vector<OnePool> &ResultPools) {
// Nothing to pool allocate here.
}
Modified: poolalloc/trunk/lib/PoolAllocate/Heuristic.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/Heuristic.h?rev=57830&r1=57829&r2=57830&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/Heuristic.h (original)
+++ poolalloc/trunk/lib/PoolAllocate/Heuristic.h Mon Oct 20 10:48:53 2008
@@ -37,8 +37,8 @@
Heuristic() {}
public:
- void Initialize(Module &m, DSGraph &gg, PoolAllocate &pa) {
- M = &m; GG = ≫ PA = &pa;
+ void Initialize(Module &m, DSGraph* gg, PoolAllocate &pa) {
+ M = &m; GG = gg; PA = &pa;
}
virtual ~Heuristic();
@@ -79,7 +79,7 @@
/// returning the result in ResultPools. If this is a function being pool
/// allocated, F will not be null.
virtual void AssignToPools(const std::vector<const DSNode*> &NodesToPA,
- Function *F, DSGraph &G,
+ Function *F, DSGraph* G,
std::vector<OnePool> &ResultPools) = 0;
// Hacks for the OnlyOverhead heuristic.
Modified: poolalloc/trunk/lib/PoolAllocate/PASimple.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PASimple.cpp?rev=57830&r1=57829&r2=57830&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/PASimple.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PASimple.cpp Mon Oct 20 10:48:53 2008
@@ -18,7 +18,6 @@
#include "dsa/DSGraph.h"
#include "dsa/CallTargets.h"
#include "poolalloc/PoolAllocate.h"
-#include "Heuristic.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Instructions.h"
@@ -121,7 +120,7 @@
// Merge all of the DSNodes in the DSGraphs.
//
GlobalECs = Graphs->getGlobalECs();
- CombinedDSGraph = new DSGraph (GlobalECs, TD, &(Graphs->getGlobalsGraph()));
+ CombinedDSGraph = new DSGraph (GlobalECs, TD, Graphs->getGlobalsGraph());
//CombinedDSGraph.cloneInto (getGlobalsGraph());
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
if (Graphs->hasDSGraph (*I))
@@ -161,13 +160,13 @@
//
// Get the DSGraph for this function.
//
- DSGraph &ECG = Graphs->getDSGraph(F);
+ DSGraph* ECG = Graphs->getDSGraph(F);
for (Function::iterator i = F.begin(), e = F.end(); i != e; ++i)
for (BasicBlock::iterator ii = i->begin(), ee = i->end(); ii != ee; ++ii) {
if (MallocInst * MI = dyn_cast<MallocInst>(ii)) {
// Associate the global pool decriptor with the DSNode
- DSNode * Node = ECG.getNodeForValue(MI).getNode();
+ DSNode * Node = ECG->getNodeForValue(MI).getNode();
FInfo.PoolDescriptors.insert(std::make_pair(Node,TheGlobalPool));
// Mark the malloc as an instruction to delete
@@ -202,7 +201,7 @@
CF = cast<Function>(CE->getOperand(0));
if (CF && (CF->isDeclaration()) && (CF->getName() == "realloc")) {
// Associate the global pool decriptor with the DSNode
- DSNode * Node = ECG.getNodeForValue(CI).getNode();
+ DSNode * Node = ECG->getNodeForValue(CI).getNode();
FInfo.PoolDescriptors.insert(std::make_pair(Node,TheGlobalPool));
// Mark the realloc as an instruction to delete
@@ -243,7 +242,7 @@
CI->replaceAllUsesWith(Casted);
} else if (CF && (CF->isDeclaration()) && (CF->getName() == "calloc")) {
// Associate the global pool decriptor with the DSNode
- DSNode * Node = ECG.getNodeForValue(CI).getNode();
+ DSNode * Node = ECG->getNodeForValue(CI).getNode();
FInfo.PoolDescriptors.insert(std::make_pair(Node,TheGlobalPool));
// Mark the realloc as an instruction to delete
@@ -285,7 +284,7 @@
CI->replaceAllUsesWith(Casted);
} else if (CF && (CF->isDeclaration()) && (CF->getName() == "strdup")) {
// Associate the global pool decriptor with the DSNode
- DSNode * Node = ECG.getNodeForValue(CI).getNode();
+ DSNode * Node = ECG->getNodeForValue(CI).getNode();
FInfo.PoolDescriptors.insert(std::make_pair(Node,TheGlobalPool));
// Mark the realloc as an instruction to delete
Modified: poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp?rev=57830&r1=57829&r2=57830&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp Mon Oct 20 10:48:53 2008
@@ -134,7 +134,7 @@
PoolAllocate *getPoolAlloc() const { return PoolAlloc; }
- const DSGraph &getGraphForFunc(PA::FuncInfo *FI) const {
+ const DSGraph* getGraphForFunc(PA::FuncInfo *FI) const {
return ECG->getDSGraph(FI->F);
}
@@ -161,7 +161,7 @@
void FindPoolsToCompress(std::set<const DSNode*> &Pools,
std::map<const DSNode*, Value*> &PreassignedPools,
- Function &F, DSGraph &DSG, PA::FuncInfo *FI);
+ Function &F, DSGraph* DSG, PA::FuncInfo *FI);
};
char PointerCompress::ID = 0;
@@ -348,7 +348,7 @@
const TargetData &TD;
- DSGraph &DSG;
+ DSGraph* DSG;
/// PAFuncInfo - Information about the transformation the pool allocator did
/// to the original function.
@@ -362,9 +362,9 @@
PointerCompress &PtrComp;
public:
InstructionRewriter(const PointerCompress::PoolInfoMap &poolInfo,
- DSGraph &dsg, PA::FuncInfo &pafi,
+ DSGraph* dsg, PA::FuncInfo &pafi,
FunctionCloneRecord *fcr, PointerCompress &ptrcomp)
- : PoolInfo(poolInfo), TD(dsg.getTargetData()), DSG(dsg),
+ : PoolInfo(poolInfo), TD(dsg->getTargetData()), DSG(dsg),
PAFuncInfo(pafi), FCR(fcr), PtrComp(ptrcomp) {
}
@@ -425,7 +425,7 @@
// Value didn't exist in the orig program (pool desc?).
return DSNodeHandle();
- return DSG.getNodeForValue(V);
+ return DSG->getNodeForValue(V);
}
/// getNodeIfCompressed - If the specified value is a pointer that will be
@@ -479,7 +479,7 @@
} else {
// Otherwise if this was in the original function, remove it from the
// DSG scalar map if it is there.
- DSG.getScalarMap().eraseIfExists(V);
+ DSG->getScalarMap().eraseIfExists(V);
}
}
@@ -507,8 +507,8 @@
// Finally, if this occurred in a function that neither the pool
// allocator nor the ptr compression implementation had to change,
// update the DSGraph.
- if (DSG.getScalarMap().count(&Old))
- DSG.getScalarMap().replaceScalar(&Old, New);
+ if (DSG->getScalarMap().count(&Old))
+ DSG->getScalarMap().replaceScalar(&Old, New);
}
}
@@ -946,7 +946,7 @@
Function *Callee = CI.getCalledFunction();
if (Callee)
if ((FI = PtrComp.getPoolAlloc()->getFuncInfoOrClone(*Callee)))
- CG = &PtrComp.getGraphForFunc(FI);
+ CG = PtrComp.getGraphForFunc(FI);
if (!Callee) {
// Indirect call: you CAN'T passed compress pointers in. Don't even think
@@ -1183,7 +1183,7 @@
void PointerCompress::FindPoolsToCompress(std::set<const DSNode*> &Pools,
std::map<const DSNode*,
Value*> &PreassignedPools,
- Function &F, DSGraph &DSG,
+ Function &F, DSGraph* DSG,
PA::FuncInfo *FI) {
DEBUG(std::cerr << "In function '" << F.getName() << "':\n");
for (unsigned i = 0, e = FI->NodesToPA.size(); i != e; ++i) {
@@ -1212,11 +1212,11 @@
// Map all node reachable from this global to the corresponding nodes in the
// globals graph.
DSGraph::NodeMapTy GlobalsGraphNodeMapping;
- DSG.computeGToGGMapping(GlobalsGraphNodeMapping);
+ DSG->computeGToGGMapping(GlobalsGraphNodeMapping);
// See if there are nodes in this graph that correspond to nodes in the
// globals graph, and if so, if it is compressed.
- for (DSGraph::node_iterator I = DSG.node_begin(), E = DSG.node_end();
+ for (DSGraph::node_iterator I = DSG->node_begin(), E = DSG->node_end();
I != E;++I)
if (GlobalsGraphNodeMapping.count(I)) {
// If it is a global pool, set up the pool descriptor appropriately.
@@ -1262,7 +1262,7 @@
return false;
// Get the DSGraph for this function.
- DSGraph &DSG = ECG->getDSGraph(FI->F);
+ DSGraph* DSG = ECG->getDSGraph(FI->F);
std::set<const DSNode*> PoolsToCompressSet;
@@ -1301,7 +1301,7 @@
// Use these to compute the closure of compression information. In
// particular, if one pool points to another, we need to know if the outgoing
// pointer is compressed.
- const TargetData &TD = DSG.getTargetData();
+ const TargetData &TD = DSG->getTargetData();
std::cerr << "In function '" << F.getName() << "':\n";
for (std::map<const DSNode*, CompressedPoolInfo>::iterator
I = PoolsToCompress.begin(), E = PoolsToCompress.end(); I != E; ++I) {
Modified: poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp?rev=57830&r1=57829&r2=57830&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp Mon Oct 20 10:48:53 2008
@@ -294,30 +294,30 @@
-static void GetNodesReachableFromGlobals(DSGraph &G,
+static void GetNodesReachableFromGlobals(DSGraph* G,
hash_set<const DSNode*> &NodesFromGlobals) {
- for (DSScalarMap::global_iterator I = G.getScalarMap().global_begin(),
- E = G.getScalarMap().global_end(); I != E; ++I)
- G.getNodeForValue(*I).getNode()->markReachableNodes(NodesFromGlobals);
+ for (DSScalarMap::global_iterator I = G->getScalarMap().global_begin(),
+ E = G->getScalarMap().global_end(); I != E; ++I)
+ G->getNodeForValue(*I).getNode()->markReachableNodes(NodesFromGlobals);
}
static void MarkNodesWhichMustBePassedIn(hash_set<const DSNode*> &MarkedNodes,
- Function &F, DSGraph &G,
+ Function &F, DSGraph* G,
bool PassAllArguments) {
// Mark globals and incomplete nodes as live... (this handles arguments)
if (F.getName() != "main") {
// All DSNodes reachable from arguments must be passed in.
for (Function::arg_iterator I = F.arg_begin(), E = F.arg_end();
I != E; ++I) {
- DSGraph::ScalarMapTy::iterator AI = G.getScalarMap().find(I);
- if (AI != G.getScalarMap().end())
+ DSGraph::ScalarMapTy::iterator AI = G->getScalarMap().find(I);
+ if (AI != G->getScalarMap().end())
if (DSNode *N = AI->second.getNode())
N->markReachableNodes(MarkedNodes);
}
}
// Marked the returned node as needing to be passed in.
- if (DSNode *RetNode = G.getReturnNodeFor(F).getNode())
+ if (DSNode *RetNode = G->getReturnNodeFor(F).getNode())
RetNode->markReachableNodes(MarkedNodes);
// Calculate which DSNodes are reachable from globals. If a node is reachable
@@ -343,14 +343,14 @@
/// arguments will have to be added for each function, build the FunctionInfo
/// map and recording this info in the ArgNodes set.
void PoolAllocate::FindFunctionPoolArgs(Function &F) {
- DSGraph &G = Graphs->getDSGraph(F);
+ DSGraph* G = Graphs->getDSGraph(F);
// Create a new entry for F.
FuncInfo &FI =
FunctionInfo.insert(std::make_pair(&F, FuncInfo(F))).first->second;
hash_set<const DSNode*> &MarkedNodes = FI.MarkedNodes;
- if (G.node_begin() == G.node_end())
+ if (G->node_begin() == G->node_end())
return; // No memory activity, nothing is required
// Find DataStructure nodes which are allocated in pools non-local to the
@@ -366,8 +366,8 @@
// necessary, and return it. If not, just return null.
//
Function *PoolAllocate::MakeFunctionClone(Function &F) {
- DSGraph &G = Graphs->getDSGraph(F);
- if (G.node_begin() == G.node_end()) return 0;
+ DSGraph* G = Graphs->getDSGraph(F);
+ if (G->node_begin() == G->node_end()) return 0;
FuncInfo &FI = *getFuncInfo(F);
if (FI.ArgNodes.empty())
@@ -471,7 +471,7 @@
//
bool PoolAllocate::SetupGlobalPools(Module &M) {
// Get the globals graph for the program.
- DSGraph &GG = Graphs->getGlobalsGraph();
+ DSGraph* GG = Graphs->getGlobalsGraph();
// Get all of the nodes reachable from globals.
hash_set<const DSNode*> GlobalHeapNodes;
@@ -557,7 +557,7 @@
CurModule);
// Update the global DSGraph to include this.
- DSNode *GNode = Graphs->getGlobalsGraph().addObjectToGraph(GV);
+ DSNode *GNode = Graphs->getGlobalsGraph()->addObjectToGraph(GV);
GNode->setModifiedMarker()->setReadMarker();
Function *MainFunc = CurModule->getFunction("main");
@@ -584,7 +584,7 @@
// the DSNodes specified by the NodesToPA list. This adds an entry to the
// PoolDescriptors map for each DSNode.
//
-void PoolAllocate::CreatePools(Function &F, DSGraph &DSG,
+void PoolAllocate::CreatePools(Function &F, DSGraph* DSG,
const std::vector<const DSNode*> &NodesToPA,
std::map<const DSNode*,
Value*> &PoolDescriptors) {
@@ -592,7 +592,7 @@
TIME_REGION(X, "CreatePools");
std::vector<Heuristic::OnePool> ResultPools;
- CurHeuristic->AssignToPools(NodesToPA, &F, *NodesToPA[0]->getParentGraph(),
+ CurHeuristic->AssignToPools(NodesToPA, &F, NodesToPA[0]->getParentGraph(),
ResultPools);
std::set<const DSNode*> UnallocatedNodes(NodesToPA.begin(), NodesToPA.end());
@@ -614,14 +614,14 @@
PoolDesc = new AllocaInst(PoolDescType, 0, "PD", InsertPoint);
// Create a node in DSG to represent the new alloca.
- DSNode *NewNode = DSG.addObjectToGraph(PoolDesc);
+ DSNode *NewNode = DSG->addObjectToGraph(PoolDesc);
NewNode->setModifiedMarker()->setReadMarker(); // This is M/R
} else {
PoolDesc = CreateGlobalPool(Pool.PoolSize, Pool.PoolAlignment,
InsertPoint);
// Add the global node to main's graph.
- DSNode *NewNode = DSG.addObjectToGraph(PoolDesc);
+ DSNode *NewNode = DSG->addObjectToGraph(PoolDesc);
NewNode->setModifiedMarker()->setReadMarker(); // This is M/R
if (Pool.NodesInPool.size() == 1 &&
@@ -647,9 +647,9 @@
// the specified function.
//
void PoolAllocate::ProcessFunctionBody(Function &F, Function &NewF) {
- DSGraph &G = Graphs->getDSGraph(F);
+ DSGraph* G = Graphs->getDSGraph(F);
- if (G.node_begin() == G.node_end()) return; // Quick exit if nothing to do.
+ if (G->node_begin() == G->node_end()) return; // Quick exit if nothing to do.
FuncInfo &FI = *getFuncInfo(F);
hash_set<const DSNode*> &MarkedNodes = FI.MarkedNodes;
@@ -662,11 +662,11 @@
// Map all node reachable from this global to the corresponding nodes in
// the globals graph.
DSGraph::NodeMapTy GlobalsGraphNodeMapping;
- G.computeGToGGMapping(GlobalsGraphNodeMapping);
+ G->computeGToGGMapping(GlobalsGraphNodeMapping);
// Loop over all of the nodes which are non-escaping, adding pool-allocatable
// ones to the NodesToPA vector.
- for (DSGraph::node_iterator I = G.node_begin(), E = G.node_end(); I != E;++I){
+ for (DSGraph::node_iterator I = G->node_begin(), E = G->node_end(); I != E;++I){
// We only need to make a pool if there is a heap object in it...
DSNode *N = I;
if ((N->isHeapNode()) || (BoundsChecksEnabled && (N->isArray()))) {
Modified: poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp?rev=57830&r1=57829&r2=57830&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp Mon Oct 20 10:48:53 2008
@@ -34,7 +34,7 @@
/// allocated functions.
struct FuncTransform : public InstVisitor<FuncTransform> {
PoolAllocate &PAInfo;
- DSGraph &G; // The Bottom-up DS Graph
+ DSGraph* G; // The Bottom-up DS Graph
FuncInfo &FI;
// PoolUses - For each pool (identified by the pool descriptor) keep track
@@ -47,7 +47,7 @@
// inserted into the code. This is seperated out from PoolUses.
std::multimap<AllocaInst*, CallInst*> &PoolFrees;
- FuncTransform(PoolAllocate &P, DSGraph &g, FuncInfo &fi,
+ FuncTransform(PoolAllocate &P, DSGraph* g, FuncInfo &fi,
std::multimap<AllocaInst*, Instruction*> &poolUses,
std::multimap<AllocaInst*, CallInst*> &poolFrees)
: PAInfo(P), G(g), FI(fi),
@@ -105,7 +105,7 @@
}
DSNodeHandle& getDSNodeHFor(Value *V) {
- return G.getScalarMap()[getOldValueIfAvailable(V)];
+ return G->getScalarMap()[getOldValueIfAvailable(V)];
}
Value *getPoolHandle(Value *V) {
@@ -120,7 +120,7 @@
};
}
-void PoolAllocate::TransformBody(DSGraph &g, PA::FuncInfo &fi,
+void PoolAllocate::TransformBody(DSGraph* g, PA::FuncInfo &fi,
std::multimap<AllocaInst*,Instruction*> &poolUses,
std::multimap<AllocaInst*, CallInst*> &poolFrees,
Function &F) {
@@ -180,9 +180,9 @@
// If we are modifying the original function, update the DSGraph.
if (!FI.Clone) {
// V and Casted now point to whatever the original allocation did.
- G.getScalarMap().replaceScalar(I, V);
+ G->getScalarMap().replaceScalar(I, V);
if (V != Casted)
- G.getScalarMap()[Casted] = G.getScalarMap()[V];
+ G->getScalarMap()[Casted] = G->getScalarMap()[V];
} else { // Otherwise, update the NewToOldValueMap
UpdateNewToOldValueMap(I, V, V != Casted ? Casted : 0);
}
@@ -296,7 +296,7 @@
if (Arg->getType() != PointerType::getUnqual(Type::Int8Ty)) {
Casted = CastInst::CreatePointerCast(Arg, PointerType::getUnqual(Type::Int8Ty),
Arg->getName()+".casted", Where);
- G.getScalarMap()[Casted] = G.getScalarMap()[Arg];
+ G->getScalarMap()[Casted] = G->getScalarMap()[Arg];
}
Value* Opts[2] = {PH, Casted};
@@ -395,9 +395,9 @@
// If we are modifying the original function, update the DSGraph.
if (!FI.Clone) {
// V and Casted now point to whatever the original allocation did.
- G.getScalarMap().replaceScalar(I, V);
+ G->getScalarMap().replaceScalar(I, V);
if (V != Casted)
- G.getScalarMap()[Casted] = G.getScalarMap()[V];
+ G->getScalarMap()[Casted] = G->getScalarMap()[V];
} else { // Otherwise, update the NewToOldValueMap
UpdateNewToOldValueMap(I, V, V != Casted ? Casted : 0);
}
@@ -466,9 +466,9 @@
// If we are modifying the original function, update the DSGraph.
if (!FI.Clone) {
// V and Casted now point to whatever the original allocation did.
- G.getScalarMap().replaceScalar(I, V);
+ G->getScalarMap().replaceScalar(I, V);
if (V != Casted)
- G.getScalarMap()[Casted] = G.getScalarMap()[V];
+ G->getScalarMap()[Casted] = G->getScalarMap()[V];
} else { // Otherwise, update the NewToOldValueMap
UpdateNewToOldValueMap(I, V, V != Casted ? Casted : 0);
}
@@ -518,9 +518,9 @@
// If we are modifying the original function, update the DSGraph.
if (!FI.Clone) {
// V and Casted now point to whatever the original allocation did.
- G.getScalarMap().replaceScalar(I, V);
+ G->getScalarMap().replaceScalar(I, V);
if (V != Casted)
- G.getScalarMap()[Casted] = G.getScalarMap()[V];
+ G->getScalarMap()[Casted] = G->getScalarMap()[V];
} else { // Otherwise, update the NewToOldValueMap
UpdateNewToOldValueMap(I, V, V != Casted ? Casted : 0);
}
@@ -602,7 +602,7 @@
ArgNodes = CFI->ArgNodes;
assert ((Graphs.hasDSGraph (*CF)) && "Function has no ECGraph!\n");
- CalleeGraph = &Graphs.getDSGraph(*CF);
+ CalleeGraph = Graphs.getDSGraph(*CF);
} else {
DEBUG(std::cerr << " Handling indirect call: " << *TheCall);
@@ -619,14 +619,14 @@
CF = *I;
// Get the common graph for the set of functions this call may invoke.
- CalleeGraph = &Graphs.getDSGraph(*CF);
+ CalleeGraph = Graphs.getDSGraph(*CF);
#ifndef NDEBUG
// Verify that all potential callees at call site have the same DS graph.
DataStructures::callee_iterator E = Graphs.callee_end(OrigInst);
for (; I != E; ++I)
if (!(*I)->isDeclaration())
- assert(CalleeGraph == &Graphs.getDSGraph(**I) &&
+ assert(CalleeGraph == Graphs.getDSGraph(**I) &&
"Callees at call site do not have a common graph!");
#endif
@@ -750,7 +750,7 @@
if (TheCall->getType() != Type::VoidTy) {
// If we are modifying the original function, update the DSGraph...
- DSGraph::ScalarMapTy &SM = G.getScalarMap();
+ DSGraph::ScalarMapTy &SM = G->getScalarMap();
DSGraph::ScalarMapTy::iterator CII = SM.find(TheCall);
if (CII != SM.end()) {
SM[NewCall] = CII->second;
More information about the llvm-commits
mailing list