diff options
author | Chris Lattner <sabre@nondot.org> | 2002-06-25 16:13:24 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-06-25 16:13:24 +0000 |
commit | 7e70829632f82de15db187845666aaca6e04b792 (patch) | |
tree | 48dd2d804e7ebec9a3cbd8bf229cb2a2aa20dce5 /lib/Transforms/Utils/PromoteMemoryToRegister.cpp | |
parent | 0b12b5f50ec77a8bd01b92d287c52d748619bb4b (diff) |
MEGAPATCH checkin.
For details, See: docs/2002-06-25-MegaPatchInfo.txt
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2779 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/PromoteMemoryToRegister.cpp')
-rw-r--r-- | lib/Transforms/Utils/PromoteMemoryToRegister.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp index 1afb11a986..8a81ac7131 100644 --- a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp +++ b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp @@ -52,7 +52,7 @@ namespace { // runOnFunction - To run this pass, first we calculate the alloca // instructions that are safe for promotion, then we promote each one. // - virtual bool runOnFunction(Function *F); + virtual bool runOnFunction(Function &F); // getAnalysisUsage - We need dominance frontiers // @@ -65,7 +65,7 @@ namespace { void Traverse(BasicBlock *BB, BasicBlock *Pred, vector<Value*> &IncVals, set<BasicBlock*> &Visited); bool QueuePhiNode(BasicBlock *BB, unsigned AllocaIdx); - void FindSafeAllocas(Function *F); + void FindSafeAllocas(Function &F); }; } // end of anonymous namespace @@ -102,12 +102,12 @@ static inline bool isSafeAlloca(const AllocaInst *AI) { // FindSafeAllocas - Find allocas that are safe to promote // -void PromotePass::FindSafeAllocas(Function *F) { - BasicBlock *BB = F->getEntryNode(); // Get the entry node for the function +void PromotePass::FindSafeAllocas(Function &F) { + BasicBlock &BB = F.getEntryNode(); // Get the entry node for the function // Look at all instructions in the entry node - for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) - if (AllocaInst *AI = dyn_cast<AllocaInst>(*I)) // Is it an alloca? + for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E; ++I) + if (AllocaInst *AI = dyn_cast<AllocaInst>(&*I)) // Is it an alloca? if (isSafeAlloca(AI)) { // If safe alloca, add alloca to safe list AllocaLookup[AI] = Allocas.size(); // Keep reverse mapping Allocas.push_back(AI); @@ -116,7 +116,7 @@ void PromotePass::FindSafeAllocas(Function *F) { -bool PromotePass::runOnFunction(Function *F) { +bool PromotePass::runOnFunction(Function &F) { // Calculate the set of safe allocas FindSafeAllocas(F); @@ -178,7 +178,7 @@ bool PromotePass::runOnFunction(Function *F) { // and inserting the phi nodes we marked as necessary // set<BasicBlock*> Visited; // The basic blocks we've already visited - Traverse(F->front(), 0, Values, Visited); + Traverse(F.begin(), 0, Values, Visited); // Remove all instructions marked by being placed in the KillList... // @@ -186,8 +186,7 @@ bool PromotePass::runOnFunction(Function *F) { Instruction *I = KillList.back(); KillList.pop_back(); - I->getParent()->getInstList().remove(I); - delete I; + I->getParent()->getInstList().erase(I); } NumPromoted += Allocas.size(); @@ -248,7 +247,7 @@ void PromotePass::Traverse(BasicBlock *BB, BasicBlock *Pred, // keep track of the value of each variable we're watching.. how? for (BasicBlock::iterator II = BB->begin(); II != BB->end(); ++II) { - Instruction *I = *II; //get the instruction + Instruction *I = II; // get the instruction if (LoadInst *LI = dyn_cast<LoadInst>(I)) { Value *Ptr = LI->getPointerOperand(); |