[llvm-commits] [poolalloc] r57842 - in /poolalloc/trunk: include/dsa/DSNode.h lib/DSA/BottomUpClosure.cpp lib/DSA/DataStructure.cpp lib/DSA/Printer.cpp
Andrew Lenharth
alenhar2 at cs.uiuc.edu
Mon Oct 20 12:37:55 PDT 2008
Author: alenhar2
Date: Mon Oct 20 14:37:54 2008
New Revision: 57842
URL: http://llvm.org/viewvc/llvm-project?rev=57842&view=rev
Log:
remove direct access to Globals List
Modified:
poolalloc/trunk/include/dsa/DSNode.h
poolalloc/trunk/lib/DSA/BottomUpClosure.cpp
poolalloc/trunk/lib/DSA/DataStructure.cpp
poolalloc/trunk/lib/DSA/Printer.cpp
Modified: poolalloc/trunk/include/dsa/DSNode.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DSNode.h?rev=57842&r1=57841&r2=57842&view=diff
==============================================================================
--- poolalloc/trunk/include/dsa/DSNode.h (original)
+++ poolalloc/trunk/include/dsa/DSNode.h Mon Oct 20 14:37:54 2008
@@ -297,13 +297,11 @@
/// globals list.
void removeGlobal(const GlobalValue *GV);
- void mergeGlobals(const std::vector<const GlobalValue*> &RHS);
+ void mergeGlobals(const DSNode& RHS);
void clearGlobals() { Globals.clear(); }
- /// getGlobalsList - Return the set of global leaders that are represented by
- /// this node. Note that globals that are in this equivalence class but are
- /// not leaders are not returned: for that, use addFullGlobalsList().
- const std::vector<const GlobalValue*> &getGlobalsList() const { return Globals; }
+ bool isEmptyGlobals() const { return Globals.empty(); }
+ unsigned numGlobals() const { return Globals.size(); }
/// addFullGlobalsList - Compute the full set of global values that are
/// represented by this node. Unlike getGlobalsList(), this requires fair
Modified: poolalloc/trunk/lib/DSA/BottomUpClosure.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/BottomUpClosure.cpp?rev=57842&r1=57841&r2=57842&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/BottomUpClosure.cpp (original)
+++ poolalloc/trunk/lib/DSA/BottomUpClosure.cpp Mon Oct 20 14:37:54 2008
@@ -372,6 +372,8 @@
}
void BUDataStructures::calculateGraph(DSGraph* Graph) {
+ DEBUG(Graph->AssertGraphOK(); Graph->getGlobalsGraph()->AssertGraphOK());
+
// 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;
@@ -408,7 +410,6 @@
}
}
-
// 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;
@@ -417,6 +418,8 @@
std::vector<const Function*> CalledFuncs;
while (!TempFCs.empty()) {
+ DEBUG(Graph->AssertGraphOK(); Graph->getGlobalsGraph()->AssertGraphOK());
+
DSCallSite &CS = *TempFCs.begin();
Instruction *TheCall = CS.getCallSite().getInstruction();
@@ -449,6 +452,7 @@
// Get the data structure graph for the called function.
GI = getDSGraph(*Callee); // Graph to inline
+ DEBUG(GI->AssertGraphOK(); GI->getGlobalsGraph()->AssertGraphOK());
DOUT << " Inlining graph for " << Callee->getName()
<< "[" << GI->getGraphSize() << "+"
<< GI->getAuxFunctionCalls().size() << "] into '"
@@ -539,6 +543,7 @@
++NumInlines;
}
}
+ DEBUG(Graph->AssertGraphOK(); Graph->getGlobalsGraph()->AssertGraphOK());
if (!isComplete)
AuxCallsList.push_front(CS);
TempFCs.erase(TempFCs.begin());
Modified: poolalloc/trunk/lib/DSA/DataStructure.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructure.cpp?rev=57842&r1=57841&r2=57842&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/DataStructure.cpp (original)
+++ poolalloc/trunk/lib/DSA/DataStructure.cpp Mon Oct 20 14:37:54 2008
@@ -802,11 +802,11 @@
}
-void DSNode::mergeGlobals(const std::vector<const GlobalValue*> &RHS) {
+void DSNode::mergeGlobals(const DSNode &RHS) {
std::vector<const GlobalValue*> Temp;
std::back_insert_iterator< std::vector<const GlobalValue*> > back_it (Temp);
std::set_union(Globals.begin(), Globals.end(),
- RHS.begin(), RHS.end(),
+ RHS.Globals.begin(), RHS.Globals.end(),
back_it);
Globals.swap(Temp);
}
@@ -961,7 +961,7 @@
// Merge the globals list...
if (!N->Globals.empty()) {
- CurNodeH.getNode()->mergeGlobals(N->Globals);
+ CurNodeH.getNode()->mergeGlobals(*N);
// Delete the globals from the old node...
N->Globals.clear();
@@ -1106,7 +1106,7 @@
Dest->getNodeForValue(GV).mergeWith(DSNodeHandle(DestGNH.getNode(),
DestGNH.getOffset()+SrcGNH.getOffset()));
}
- NH.getNode()->mergeGlobals(SN->getGlobalsList());
+ NH.getNode()->mergeGlobals(*SN);
return DSNodeHandle(NH.getNode(), NH.getOffset()+SrcNH.getOffset());
}
@@ -1182,7 +1182,7 @@
// scalar map with the correct offset.
if (SN->globals_begin() != SN->globals_end()) {
// Update the globals in the destination node itself.
- DN->mergeGlobals(SN->getGlobalsList());
+ DN->mergeGlobals(*SN);
// Update the scalar map for the graph we are merging the source node
// into.
@@ -1195,7 +1195,7 @@
Dest->getNodeForValue(GV).mergeWith(DSNodeHandle(DestGNH.getNode(),
DestGNH.getOffset()+SrcGNH.getOffset()));
}
- NH.getNode()->mergeGlobals(SN->getGlobalsList());
+ NH.getNode()->mergeGlobals(*SN);
}
} else {
// We cannot handle this case without allocating a temporary node. Fall
@@ -2030,7 +2030,7 @@
// If the Callee is a useless edge, this must be an unreachable call site,
// eliminate it.
if (Callee->getNumReferrers() == 1 && Callee->isCompleteNode() &&
- Callee->getGlobalsList().empty()) { // No useful info?
+ Callee->isEmptyGlobals()) { // No useful info?
DOUT << "WARNING: Useless call site found.\n";
Calls.erase(OldIt);
++NumDeleted;
@@ -2214,20 +2214,21 @@
// have all of these properties and still have incoming edges, due to the
// scalar map, so we check those now.
//
- if (Node.getNumReferrers() == Node.getGlobalsList().size()) {
- const std::vector<const GlobalValue*> &Globals = Node.getGlobalsList();
+ if (Node.getNumReferrers() == Node.numGlobals()) {
// Loop through and make sure all of the globals are referring directly
// to the node...
- for (unsigned j = 0, e = Globals.size(); j != e; ++j) {
- DSNode *N = getNodeForValue(Globals[j]).getNode();
+ for (DSNode::globals_iterator j = Node.globals_begin(), e = Node.globals_end();
+ j != e; ++j) {
+ DSNode *N = getNodeForValue(*j).getNode();
assert(N == &Node && "ScalarMap doesn't match globals list!");
}
// Make sure NumReferrers still agrees, if so, the node is truly dead.
- if (Node.getNumReferrers() == Globals.size()) {
- for (unsigned j = 0, e = Globals.size(); j != e; ++j)
- ScalarMap.erase(Globals[j]);
+ if (Node.getNumReferrers() == Node.numGlobals()) {
+ for (DSNode::globals_iterator j = Node.globals_begin(), e = Node.globals_end();
+ j != e; ++j)
+ ScalarMap.erase(*j);
Node.makeNodeDead();
++NumTrivialGlobalDNE;
}
@@ -2779,7 +2780,7 @@
for (DSGraph::node_iterator I = GlobalsGraph->node_begin(),
E = GlobalsGraph->node_end();
I != E; ++I) {
- if (I->getGlobalsList().size() <= 1) continue;
+ if (I->numGlobals() <= 1) continue;
// First, build up the equivalence set for this block of globals.
DSNode::globals_iterator i = I->globals_begin();
Modified: poolalloc/trunk/lib/DSA/Printer.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Printer.cpp?rev=57842&r1=57841&r2=57842&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/Printer.cpp (original)
+++ poolalloc/trunk/lib/DSA/Printer.cpp Mon Oct 20 14:37:54 2008
@@ -87,13 +87,14 @@
EquivalenceClasses<const GlobalValue*> *GlobalECs = 0;
if (G) GlobalECs = &G->getGlobalECs();
- for (unsigned i = 0, e = N->getGlobalsList().size(); i != e; ++i) {
- WriteAsOperand(OS, N->getGlobalsList()[i], false, M);
+ for (DSNode::globals_iterator i = N->globals_begin(), e = N->globals_end();
+ i != e; ++i) {
+ WriteAsOperand(OS, *i, false, M);
// Figure out how many globals are equivalent to this one.
if (GlobalECs) {
EquivalenceClasses<const GlobalValue*>::iterator I =
- GlobalECs->findValue(N->getGlobalsList()[i]);
+ GlobalECs->findValue(*i);
if (I != GlobalECs->end()) {
unsigned NumMembers =
std::distance(GlobalECs->member_begin(I), GlobalECs->member_end());
More information about the llvm-commits
mailing list