[llvm-commits] [poolalloc] r76426 - in /poolalloc/trunk: include/poolalloc/PoolAllocate.h lib/DSA/Steensgaard.cpp lib/PoolAllocate/PAMultipleGlobalPool.cpp
Haohui Mai
mai4 at uiuc.edu
Mon Jul 20 09:16:52 PDT 2009
Author: mai4
Date: Mon Jul 20 11:16:52 2009
New Revision: 76426
URL: http://llvm.org/viewvc/llvm-project?rev=76426&view=rev
Log:
1. A global might have DSNode in both the result graph and the globals graph, which should be placed in the same pool in PAMultiGlobalPool.
2. Add a print() method for debugging.
3. Revert the deprecated flag.
Modified:
poolalloc/trunk/include/poolalloc/PoolAllocate.h
poolalloc/trunk/lib/DSA/Steensgaard.cpp
poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp
Modified: poolalloc/trunk/include/poolalloc/PoolAllocate.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/poolalloc/PoolAllocate.h?rev=76426&r1=76425&r2=76426&view=diff
==============================================================================
--- poolalloc/trunk/include/poolalloc/PoolAllocate.h (original)
+++ poolalloc/trunk/include/poolalloc/PoolAllocate.h Mon Jul 20 11:16:52 2009
@@ -187,7 +187,7 @@
PoolAllocate (bool passAllArguments,
bool SAFECode = true,
- intptr_t IDp = (intptr_t) (&ID)) __attribute__((__deprecated__))
+ intptr_t IDp = (intptr_t) (&ID))
: ModulePass((intptr_t)IDp),
PassAllArguments(passAllArguments)
{
@@ -511,10 +511,11 @@
void ProcessFunctionBodySimple(Function& F, TargetData & TD);
/// Mapping between DSNodes and Pool descriptors. For this pass, it is a
/// one-to-one relationship.
- DenseMap<const DSNode *, GlobalVariable *> PoolMap;
+ typedef DenseMap<const DSNode *, GlobalVariable *> PoolMapTy;
+ PoolMapTy PoolMap;
void generatePool(unsigned RecSize, unsigned Align,
Module& M, BasicBlock * InsertAtEnd, const DSNode * Node);
-
+ Module * currentModule;
public:
static char ID;
PoolAllocateMultipleGlobalPool(bool passAllArgs=false, bool SAFECode = true)
@@ -527,7 +528,8 @@
virtual Value * getGlobalPool (const DSNode * Node);
virtual Value * getPool (const DSNode * N, Function & F);
-
+ virtual void print(std::ostream &OS, const Module * M) const;
+ virtual void dump() const;
};
}
Modified: poolalloc/trunk/lib/DSA/Steensgaard.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Steensgaard.cpp?rev=76426&r1=76425&r2=76426&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/Steensgaard.cpp (original)
+++ poolalloc/trunk/lib/DSA/Steensgaard.cpp Mon Jul 20 11:16:52 2009
@@ -134,7 +134,7 @@
// Remove any nodes that are dead after all of the merging we have done...
- ResultGraph->removeDeadNodes(DSGraph::KeepUnreachableGlobals);
+ ResultGraph->removeDeadNodes(DSGraph::RemoveUnreachableGlobals);
print(DOUT, &M);
return false;
Modified: poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp?rev=76426&r1=76425&r2=76426&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp Mon Jul 20 11:16:52 2009
@@ -79,6 +79,7 @@
}
bool PoolAllocateMultipleGlobalPool::runOnModule(Module &M) {
+ currentModule = &M;
if (M.begin() == M.end()) return false;
Graphs = &getAnalysis<SteensgaardDataStructures>();
assert (Graphs && "No DSA pass available!\n");
@@ -350,7 +351,15 @@
DSGraph * GG = DS->getGlobalsGraph();
for(DSGraph::node_const_iterator I = GG->node_begin(),
E = GG->node_end(); I != E; ++I) {
- generatePool(I->getSize(), Align, M, BB, I);
+ if (I->globals_begin() != I->globals_end()) {
+ const GlobalValue * GV = *(I->globals_begin());
+ DSNodeHandle NH = G->getNodeForValue(GV);
+ if (!NH.isNull()) {
+ PoolMap[&*I] = PoolMap[NH.getNode()];
+ } else {
+ generatePool(I->getSize(), Align, M, BB, I);
+ }
+ }
}
ReturnInst::Create(BB);
@@ -393,4 +402,16 @@
return getGlobalPool(N);
}
+void
+PoolAllocateMultipleGlobalPool::print(std::ostream &OS, const Module * M) const {
+ for (PoolMapTy::const_iterator I = PoolMap.begin(), E = PoolMap.end(); I != E; ++I) {
+ OS << I->first << " -> " << I->second->getName() << "\n";
+ }
+}
+
+void
+PoolAllocateMultipleGlobalPool::dump() const {
+ print (std::cerr, currentModule);
+}
+
PoolAllocateMultipleGlobalPool::~PoolAllocateMultipleGlobalPool() {}
More information about the llvm-commits
mailing list