[llvm-commits] CVS: poolalloc/lib/PoolAllocate/EquivClassGraphs.cpp
Chris Lattner
lattner at cs.uiuc.edu
Mon Nov 1 22:39:08 PST 2004
Changes in directory poolalloc/lib/PoolAllocate:
EquivClassGraphs.cpp updated: 1.13 -> 1.14
---
Log message:
Minor cleanups
---
Diffs of the changes: (+21 -25)
Index: poolalloc/lib/PoolAllocate/EquivClassGraphs.cpp
diff -u poolalloc/lib/PoolAllocate/EquivClassGraphs.cpp:1.13 poolalloc/lib/PoolAllocate/EquivClassGraphs.cpp:1.14
--- poolalloc/lib/PoolAllocate/EquivClassGraphs.cpp:1.13 Mon Nov 1 15:07:05 2004
+++ poolalloc/lib/PoolAllocate/EquivClassGraphs.cpp Tue Nov 2 00:38:58 2004
@@ -179,57 +179,54 @@
Function* LF = *LI;
const std::set<Function*>& EqClass = FuncECs.getEqClass(LF);
-#ifndef NDEBUG
if (EqClass.size() > 1) {
+#ifndef NDEBUG
DEBUG(std::cerr <<" Equivalence set for leader " <<LF->getName()<<" = ");
for (std::set<Function*>::const_iterator EqI = EqClass.begin(),
EqEnd = EqClass.end(); EqI != EqEnd; ++EqI)
DEBUG(std::cerr << " " << (*EqI)->getName() << ",");
DEBUG(std::cerr << "\n");
- }
#endif
- if (EqClass.size() > 1) {
// This equiv class has multiple functions: merge their graphs. First,
// clone the CBU graph for the leader and make it the common graph for the
// equivalence graph.
- DSGraph *mergedG = &getOrCreateGraph(*LF);
+ DSGraph &MergedG = getOrCreateGraph(*LF);
// Record the argument nodes for use in merging later below.
std::vector<DSNodeHandle> ArgNodes;
for (Function::aiterator AI1 = LF->abegin(); AI1 != LF->aend(); ++AI1)
if (DS::isPointerType(AI1->getType()))
- ArgNodes.push_back(mergedG->getNodeForValue(AI1));
+ ArgNodes.push_back(MergedG.getNodeForValue(AI1));
// Merge in the graphs of all other functions in this equiv. class. Note
// that two or more functions may have the same graph, and it only needs
- // to be merged in once. Use a set to find repetitions.
+ // to be merged in once.
std::set<DSGraph*> GraphsMerged;
+ GraphsMerged.insert(&CBU->getDSGraph(*LF));
+
for (std::set<Function*>::const_iterator EqI = EqClass.begin(),
- EqEnd = EqClass.end(); EqI != EqEnd; ++EqI) {
- Function* F = *EqI;
- DSGraph*& FG = DSInfo[F];
+ E = EqClass.end(); EqI != E; ++EqI) {
+ Function *F = *EqI;
+ DSGraph *&FG = DSInfo[F];
- if (F == LF || FG == mergedG)
+ DSGraph &CBUGraph = CBU->getDSGraph(*F);
+ if (!GraphsMerged.insert(&CBUGraph).second)
continue;
+ assert(FG == 0 && "Remerged a graph?");
// Record the "folded" graph for the function.
- FG = mergedG;
-
- // Clone this member of the equivalence class into mergedG
- DSGraph* CBUGraph = &CBU->getDSGraph(*F);
- if (GraphsMerged.count(CBUGraph) > 0)
- continue;
+ FG = &MergedG;
- GraphsMerged.insert(CBUGraph);
+ // Clone this member of the equivalence class into MergedG.
DSGraph::NodeMapTy NodeMap;
- mergedG->cloneInto(*CBUGraph, mergedG->getScalarMap(),
- mergedG->getReturnNodes(), NodeMap, 0);
+ MergedG.cloneInto(CBUGraph, MergedG.getScalarMap(),
+ MergedG.getReturnNodes(), NodeMap, 0);
// Merge the return nodes of all functions together.
- mergedG->getReturnNodes()[LF].mergeWith(mergedG->getReturnNodes()[F]);
+ MergedG.getReturnNodes()[LF].mergeWith(MergedG.getReturnNodes()[F]);
// Merge the function arguments with all argument nodes found so far.
// If there are extra function args, add them to the vector of argNodes
@@ -237,12 +234,12 @@
for (unsigned arg=0, numArgs = ArgNodes.size();
arg != numArgs && AI2 != AI2end; ++AI2, ++arg)
if (DS::isPointerType(AI2->getType()))
- ArgNodes[arg].mergeWith(mergedG->getNodeForValue(AI2));
+ ArgNodes[arg].mergeWith(MergedG.getNodeForValue(AI2));
for ( ; AI2 != AI2end; ++AI2)
if (DS::isPointerType(AI2->getType()))
- ArgNodes.push_back(mergedG->getNodeForValue(AI2));
- DEBUG(mergedG->AssertGraphOK());
+ ArgNodes.push_back(MergedG.getNodeForValue(AI2));
+ DEBUG(MergedG.AssertGraphOK());
}
}
}
@@ -267,8 +264,7 @@
I != Graph->getReturnNodes().end(); ++I)
if (I->first != &F) {
DSGraph *&FG = DSInfo[I->first];
- assert(FG == NULL || FG == &CBU->getDSGraph(*I->first) &&
- "Merging function in SCC twice?");
+ assert(FG == 0 && "Merging function in SCC twice?");
FG = Graph;
}
More information about the llvm-commits
mailing list