diff options
author | Daniel Berlin <dberlin@dberlin.org> | 2016-08-22 19:14:30 +0000 |
---|---|---|
committer | Daniel Berlin <dberlin@dberlin.org> | 2016-08-22 19:14:30 +0000 |
commit | 3d512a2dc20aa43fc39c9bdea7067ff073ba7298 (patch) | |
tree | affb3a54a30c7e0d0357273d66bb2a48a5d8601a /llvm/lib/Transforms | |
parent | 868381bff6042d7d50e635a40bea2bf8b9011a87 (diff) | |
download | bcm5719-llvm-3d512a2dc20aa43fc39c9bdea7067ff073ba7298.tar.gz bcm5719-llvm-3d512a2dc20aa43fc39c9bdea7067ff073ba7298.zip |
MSSA: Factor out phi node placement
llvm-svn: 279462
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Utils/MemorySSA.cpp | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/llvm/lib/Transforms/Utils/MemorySSA.cpp b/llvm/lib/Transforms/Utils/MemorySSA.cpp index af2f954219c..e4acddd969b 100644 --- a/llvm/lib/Transforms/Utils/MemorySSA.cpp +++ b/llvm/lib/Transforms/Utils/MemorySSA.cpp @@ -1459,6 +1459,27 @@ void MemorySSA::OptimizeUses::optimizeUses() { LocStackInfo); } +void MemorySSA::placePHINodes( + const SmallPtrSetImpl<BasicBlock *> &DefiningBlocks, + const SmallPtrSetImpl<BasicBlock *> &LiveInBlocks) { + // Determine where our MemoryPhi's should go + ForwardIDFCalculator IDFs(*DT); + IDFs.setDefiningBlocks(DefiningBlocks); + IDFs.setLiveInBlocks(LiveInBlocks); + SmallVector<BasicBlock *, 32> IDFBlocks; + IDFs.calculate(IDFBlocks); + + // Now place MemoryPhi nodes. + for (auto &BB : IDFBlocks) { + // Insert phi node + AccessList *Accesses = getOrCreateAccessList(BB); + MemoryPhi *Phi = new MemoryPhi(BB->getContext(), BB, NextID++); + ValueToMemoryAccess[BB] = Phi; + // Phi's always are placed at the front of the block. + Accesses->push_front(Phi); + } +} + void MemorySSA::buildMemorySSA() { // We create an access to represent "live on entry", for things like // arguments or users of globals, where the memory they use is defined before @@ -1528,23 +1549,7 @@ void MemorySSA::buildMemorySSA() { // live into it to. LiveInBlockWorklist.append(pred_begin(BB), pred_end(BB)); } - - // Determine where our MemoryPhi's should go - ForwardIDFCalculator IDFs(*DT); - IDFs.setDefiningBlocks(DefiningBlocks); - IDFs.setLiveInBlocks(LiveInBlocks); - SmallVector<BasicBlock *, 32> IDFBlocks; - IDFs.calculate(IDFBlocks); - - // Now place MemoryPhi nodes. - for (auto &BB : IDFBlocks) { - // Insert phi node - AccessList *Accesses = getOrCreateAccessList(BB); - MemoryPhi *Phi = new MemoryPhi(BB->getContext(), BB, NextID++); - ValueToMemoryAccess[BB] = Phi; - // Phi's always are placed at the front of the block. - Accesses->push_front(Phi); - } + placePHINodes(DefiningBlocks, LiveInBlocks); // Now do regular SSA renaming on the MemoryDef/MemoryUse. Visited will get // filled in with all blocks. |