aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-04-13 19:52:54 +0000
committerChris Lattner <sabre@nondot.org>2002-04-13 19:52:54 +0000
commitddcbd34f566e1b3cb1e91cab128703cf9d13136d (patch)
treeef10969333b038a5f8f4e6d6d757e36d148cc5d6
parent027a6755f8c68818eca9cfa6b24b1f7fa105f100 (diff)
* Give alloca's for pool descriptors better names than "pool<n>".
* Fill in the pool descriptor links in the pool descriptors. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2239 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/IPO/OldPoolAllocate.cpp33
1 files changed, 28 insertions, 5 deletions
diff --git a/lib/Transforms/IPO/OldPoolAllocate.cpp b/lib/Transforms/IPO/OldPoolAllocate.cpp
index 24a51c298f..1d1e2fe14c 100644
--- a/lib/Transforms/IPO/OldPoolAllocate.cpp
+++ b/lib/Transforms/IPO/OldPoolAllocate.cpp
@@ -1183,8 +1183,9 @@ void PoolAllocate::CreatePools(Function *F, const vector<AllocDSNode*> &Allocs,
"Pool type should not be abstract anymore!");
// Add an allocation and a free for each pool...
- AllocaInst *PoolAlloc = new AllocaInst(PointerType::get(PI.PoolType),
- 0, "pool");
+ AllocaInst *PoolAlloc
+ = new AllocaInst(PointerType::get(PI.PoolType), 0,
+ CurModule->getTypeName(PI.PoolType));
PI.Handle = PoolAlloc;
EntryNodeInsts.push_back(PoolAlloc);
AllocationInst *AI = Allocs[i]->getAllocation();
@@ -1201,9 +1202,6 @@ void PoolAllocate::CreatePools(Function *F, const vector<AllocDSNode*> &Allocs,
Args.push_back(PoolAlloc); // Pool to initialize
EntryNodeInsts.push_back(new CallInst(PoolInit, Args));
- // FIXME: add code to initialize inter pool links
- cerr << "TODO: add code to initialize inter pool links!\n";
-
// Add code to destroy the pool in all of the exit nodes of the function...
Args.clear();
Args.push_back(PoolAlloc); // Pool to initialize
@@ -1217,6 +1215,31 @@ void PoolAllocate::CreatePools(Function *F, const vector<AllocDSNode*> &Allocs,
}
}
+ // Now that all of the pool descriptors have been created, link them together
+ // so that called functions can get links as neccesary...
+ //
+ for (unsigned i = 0, e = Allocs.size(); i != e; ++i) {
+ PoolInfo &PI = PoolDescs[Allocs[i]];
+
+ // For every pointer in the data structure, initialize a link that
+ // indicates which pool to access...
+ //
+ vector<Value*> Indices(2);
+ Indices[0] = ConstantUInt::get(Type::UIntTy, 0);
+ for (unsigned l = 0, le = PI.Node->getNumLinks(); l != le; ++l)
+ // Only store an entry for the field if the field is used!
+ if (!PI.Node->getLink(l).empty()) {
+ assert(PI.Node->getLink(l).size() == 1 && "Should have only one link!");
+ PointerVal PV = PI.Node->getLink(l)[0];
+ assert(PV.Index == 0 && "Subindexing not supported yet!");
+ PoolInfo &LinkedPool = PoolDescs[PV.Node];
+ Indices[1] = ConstantUInt::get(Type::UByteTy, 1+l);
+
+ EntryNodeInsts.push_back(new StoreInst(LinkedPool.Handle, PI.Handle,
+ Indices));
+ }
+ }
+
// Insert the entry node code into the entry block...
F->getEntryNode()->getInstList().insert(F->getEntryNode()->begin()+1,
EntryNodeInsts.begin(),