summaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-06-19 08:42:40 +0000
committerChris Lattner <sabre@nondot.org>2004-06-19 08:42:40 +0000
commitabc35bcad3011d582bad3717e14c7398c8c51282 (patch)
tree5f92366ffa903a63198e23afdd1c04a4ec04a9fd /lib/Transforms/Utils/PromoteMemoryToRegister.cpp
parentc8fd918aa169b1f193cfe24f413167dad0a91214 (diff)
downloadllvm-abc35bcad3011d582bad3717e14c7398c8c51282.tar.gz
llvm-abc35bcad3011d582bad3717e14c7398c8c51282.tar.bz2
llvm-abc35bcad3011d582bad3717e14c7398c8c51282.tar.xz
Change to use the StableBasicBlockNumbering class
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14247 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/PromoteMemoryToRegister.cpp')
-rw-r--r--lib/Transforms/Utils/PromoteMemoryToRegister.cpp22
1 files changed, 7 insertions, 15 deletions
diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
index b25a776f57..d35b457125 100644
--- a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
+++ b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
@@ -24,6 +24,7 @@
#include "llvm/Function.h"
#include "llvm/Constant.h"
#include "llvm/Support/CFG.h"
+#include "llvm/Support/StableBasicBlockNumbering.h"
#include "Support/StringExtras.h"
using namespace llvm;
@@ -131,12 +132,9 @@ namespace {
// Visited - The set of basic blocks the renamer has already visited.
std::set<BasicBlock*> Visited;
- // BasicBlockNumbering - Holds a numbering of the basic blocks in the
- // function in a stable order that does not depend on their address.
- std::map<BasicBlock*, unsigned> BasicBlockNumbering;
-
- // NumberedBasicBlock - Holds the inverse mapping of BasicBlockNumbering.
- std::vector<BasicBlock*> NumberedBasicBlock;
+ // BBNumbers - Contains a stable numbering of basic blocks to avoid
+ // non-determinstic behavior.
+ StableBasicBlockNumbering BBNumbers;
public:
PromoteMem2Reg(const std::vector<AllocaInst*> &A, DominatorTree &dt,
@@ -288,13 +286,7 @@ void PromoteMem2Reg::run() {
// If we haven't computed a numbering for the BB's in the function, do so
// now.
- if (NumberedBasicBlock.empty()) {
- unsigned n = 0;
- for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I, ++n) {
- NumberedBasicBlock.push_back(I);
- BasicBlockNumbering[I] = n;
- }
- }
+ BBNumbers.compute(F);
// Compute the locations where PhiNodes need to be inserted. Look at the
// dominance frontier of EACH basic-block we have a write in.
@@ -318,13 +310,13 @@ void PromoteMem2Reg::run() {
// processing blocks in order of the occurance in the function.
for (DominanceFrontier::DomSetType::iterator P = S.begin(),PE = S.end();
P != PE; ++P)
- DFBlocks.push_back(BasicBlockNumbering[*P]);
+ DFBlocks.push_back(BBNumbers.getNumber(*P));
// Sort by which the block ordering in the function.
std::sort(DFBlocks.begin(), DFBlocks.end());
for (unsigned i = 0, e = DFBlocks.size(); i != e; ++i) {
- BasicBlock *BB = NumberedBasicBlock[DFBlocks[i]];
+ BasicBlock *BB = BBNumbers.getBlock(DFBlocks[i]);
if (QueuePhiNode(BB, AllocaNum, CurrentVersion, InsertedPHINodes))
DefiningBlocks.push_back(BB);
}