diff options
author | Owen Anderson <resistor@mac.com> | 2009-07-05 22:41:43 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-07-05 22:41:43 +0000 |
commit | 0a205a459884ec745df1c529396dd921f029dafd (patch) | |
tree | 905109491ef6c2ea3d99d01fc48af9c2c633e645 /lib/Transforms/Utils/PromoteMemoryToRegister.cpp | |
parent | db882950f3bcf7f710843610e917988daeafffc2 (diff) |
More LLVMContext-ification.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74807 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/PromoteMemoryToRegister.cpp')
-rw-r--r-- | lib/Transforms/Utils/PromoteMemoryToRegister.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp index b717699b7e..d3a6300611 100644 --- a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp +++ b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp @@ -23,6 +23,7 @@ #include "llvm/Function.h" #include "llvm/Instructions.h" #include "llvm/IntrinsicInst.h" +#include "llvm/LLVMContext.h" #include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/AliasSetTracker.h" #include "llvm/ADT/DenseMap.h" @@ -181,6 +182,8 @@ namespace { /// AST - An AliasSetTracker object to update. If null, don't update it. /// AliasSetTracker *AST; + + LLVMContext* Context; /// AllocaLookup - Reverse mapping of Allocas. /// @@ -212,8 +215,9 @@ namespace { DenseMap<const BasicBlock*, unsigned> BBNumPreds; public: PromoteMem2Reg(const std::vector<AllocaInst*> &A, DominatorTree &dt, - DominanceFrontier &df, AliasSetTracker *ast) - : Allocas(A), DT(dt), DF(df), AST(ast) {} + DominanceFrontier &df, AliasSetTracker *ast, + LLVMContext* C) + : Allocas(A), DT(dt), DF(df), AST(ast), Context(C) {} void run(); @@ -445,7 +449,7 @@ void PromoteMem2Reg::run() { // RenamePassData::ValVector Values(Allocas.size()); for (unsigned i = 0, e = Allocas.size(); i != e; ++i) - Values[i] = UndefValue::get(Allocas[i]->getAllocatedType()); + Values[i] = Context->getUndef(Allocas[i]->getAllocatedType()); // Walks all basic blocks in the function performing the SSA rename algorithm // and inserting the phi nodes we marked as necessary @@ -472,7 +476,7 @@ void PromoteMem2Reg::run() { // Just delete the users now. // if (!A->use_empty()) - A->replaceAllUsesWith(UndefValue::get(A->getType())); + A->replaceAllUsesWith(Context->getUndef(A->getType())); if (AST) AST->deleteValue(A); A->eraseFromParent(); } @@ -558,7 +562,7 @@ void PromoteMem2Reg::run() { BasicBlock::iterator BBI = BB->begin(); while ((SomePHI = dyn_cast<PHINode>(BBI++)) && SomePHI->getNumIncomingValues() == NumBadPreds) { - Value *UndefVal = UndefValue::get(SomePHI->getType()); + Value *UndefVal = Context->getUndef(SomePHI->getType()); for (unsigned pred = 0, e = Preds.size(); pred != e; ++pred) SomePHI->addIncoming(UndefVal, Preds[pred]); } @@ -804,7 +808,7 @@ void PromoteMem2Reg::PromoteSingleBlockAlloca(AllocaInst *AI, AllocaInfo &Info, if (StoresByIndex.empty()) { for (Value::use_iterator UI = AI->use_begin(), E = AI->use_end(); UI != E;) if (LoadInst *LI = dyn_cast<LoadInst>(*UI++)) { - LI->replaceAllUsesWith(UndefValue::get(LI->getType())); + LI->replaceAllUsesWith(Context->getUndef(LI->getType())); if (AST && isa<PointerType>(LI->getType())) AST->deleteValue(LI); LBI.deleteValue(LI); @@ -995,9 +999,9 @@ NextIteration: /// void llvm::PromoteMemToReg(const std::vector<AllocaInst*> &Allocas, DominatorTree &DT, DominanceFrontier &DF, - AliasSetTracker *AST) { + LLVMContext* Context, AliasSetTracker *AST) { // If there is nothing to do, bail out... if (Allocas.empty()) return; - PromoteMem2Reg(Allocas, DT, DF, AST).run(); + PromoteMem2Reg(Allocas, DT, DF, AST, Context).run(); } |