[llvm-commits] [poolalloc] r50482 - in /poolalloc/trunk: include/poolalloc/PoolAllocate.h lib/PoolAllocate/PASimple.cpp
John Criswell
criswell at uiuc.edu
Wed Apr 30 07:28:02 PDT 2008
Author: criswell
Date: Wed Apr 30 09:28:01 2008
New Revision: 50482
URL: http://llvm.org/viewvc/llvm-project?rev=50482&view=rev
Log:
Made the simple pool allocation pass merge all DSNodes. This is required
because all objects will reside in the same pool.
Modified:
poolalloc/trunk/include/poolalloc/PoolAllocate.h
poolalloc/trunk/lib/PoolAllocate/PASimple.cpp
Modified: poolalloc/trunk/include/poolalloc/PoolAllocate.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/poolalloc/PoolAllocate.h?rev=50482&r1=50481&r2=50482&view=diff
==============================================================================
--- poolalloc/trunk/include/poolalloc/PoolAllocate.h (original)
+++ poolalloc/trunk/include/poolalloc/PoolAllocate.h Wed Apr 30 09:28:01 2008
@@ -111,7 +111,7 @@
static char ID;
Constant *PoolRegister;
- virtual ~PoolAllocateGroup () {}
+ virtual ~PoolAllocateGroup () {return;}
virtual PA::FuncInfo *getFuncInfo(Function &F) { return 0;}
virtual PA::FuncInfo *getFuncInfoOrClone(Function &F) {return 0;}
virtual Function *getOrigFunctionFromClone(Function *F) const {return 0;}
@@ -363,14 +363,27 @@
/// implementation.
class PoolAllocateSimple : public PoolAllocate {
Value * TheGlobalPool;
+ DSGraph * CombinedDSGraph;
+ EquivalenceClasses<GlobalValue*> * GlobalECs;
+ TargetData * TD;
public:
static char ID;
PoolAllocateSimple() : PoolAllocate(false, (intptr_t)&ID) {}
+ ~PoolAllocateSimple() {return;}
void getAnalysisUsage(AnalysisUsage &AU) const;
bool runOnModule(Module &M);
GlobalVariable *CreateGlobalPool(unsigned RecSize, unsigned Align,
Instruction *IPHint, Module& M);
- void ProcessFunctionBodySimple(Function& F);
+ void ProcessFunctionBodySimple(Function& F, TargetData & TD);
+
+
+ virtual DSGraph & getDSGraph (const Function & F) const {
+ return *CombinedDSGraph;
+ }
+
+ virtual DSGraph & getGlobalsGraph () const {
+ return *CombinedDSGraph;
+ }
virtual Value * getGlobalPool (const DSNode * Node) {
return TheGlobalPool;
Modified: poolalloc/trunk/lib/PoolAllocate/PASimple.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PASimple.cpp?rev=50482&r1=50481&r2=50482&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/PASimple.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PASimple.cpp Wed Apr 30 09:28:01 2008
@@ -79,11 +79,24 @@
AU.setPreservesAll();
}
+static void
+MergeNodesInDSGraph (DSGraph & Graph) {
+ while ((Graph.node_begin() != Graph.node_end()) &&
+ ((++(Graph.node_begin())) != Graph.node_end())) {
+ DSNodeHandle Node (Graph.node_begin());
+ DSNodeHandle Target(++(Graph.node_begin()));
+ Node.mergeWith (Target);
+ }
+ return;
+}
+
bool PoolAllocateSimple::runOnModule(Module &M) {
if (M.begin() == M.end()) return false;
// Get the Target Data information and the ECGraphs
ECGraphs = &getAnalysis<EquivClassGraphs>(); // folded inlined CBU graphs
+ assert (ECGraphs && "No ECGraphs pass available!\n");
+ TargetData & TD = getAnalysis<TargetData>();
// Add the pool* prototypes to the module
AddPoolPrototypes(&M);
@@ -98,26 +111,40 @@
}
//
+ // Merge all of the DSNodes in the DSGraphs.
+ //
+ GlobalECs = &(ECGraphs->getGlobalECs());
+ CombinedDSGraph = new DSGraph (*GlobalECs, TD, &(ECGraphs->getGlobalsGraph()));
+ //CombinedDSGraph.cloneInto (ECGraphs->getGlobalsGraph());
+ for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
+ if (ECGraphs->hasGraph (*I))
+ CombinedDSGraph->cloneInto (ECGraphs->getDSGraph(*I));
+ }
+ CombinedDSGraph->cloneInto (ECGraphs->getGlobalsGraph());
+ MergeNodesInDSGraph (*CombinedDSGraph);
+
+ //
// Create the global pool.
//
TheGlobalPool = CreateGlobalPool(1, 1, MainFunc->getEntryBlock().begin(), M);
+ //
// Now that all call targets are available, rewrite the function bodies of the
// clones.
- for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
+ for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
if (!(I->isDeclaration()))
- ProcessFunctionBodySimple(*I);
+ ProcessFunctionBodySimple(*I, TD);
+ }
+
return true;
}
-void PoolAllocateSimple::ProcessFunctionBodySimple(Function& F) {
+void
+PoolAllocateSimple::ProcessFunctionBodySimple (Function& F, TargetData & TD) {
std::vector<Instruction*> toDelete;
std::vector<ReturnInst*> Returns;
std::vector<Instruction*> ToFree;
- // Get the target data information
- TargetData &TD = getAnalysis<TargetData>();
-
//
// Create a silly Function Info structure for this function.
//
More information about the llvm-commits
mailing list