diff options
author | Owen Anderson <resistor@mac.com> | 2009-07-30 23:03:37 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-07-30 23:03:37 +0000 |
commit | b99ecca4954cbc3fbff77ffb252952cc19c4d799 (patch) | |
tree | 477eb7b58abe6134ff6accc805279396a77892e8 /lib/Transforms/Utils | |
parent | 5288eaeffedc8178bcd69de55f87fd4f27008a8e (diff) | |
download | external_llvm-b99ecca4954cbc3fbff77ffb252952cc19c4d799.zip external_llvm-b99ecca4954cbc3fbff77ffb252952cc19c4d799.tar.gz external_llvm-b99ecca4954cbc3fbff77ffb252952cc19c4d799.tar.bz2 |
Move more code back to 2.5 APIs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77635 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils')
-rw-r--r-- | lib/Transforms/Utils/BasicBlockUtils.cpp | 7 | ||||
-rw-r--r-- | lib/Transforms/Utils/CloneFunction.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/Utils/InlineFunction.cpp | 6 | ||||
-rw-r--r-- | lib/Transforms/Utils/LCSSA.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/Utils/Local.cpp | 6 | ||||
-rw-r--r-- | lib/Transforms/Utils/LoopSimplify.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/Utils/PromoteMemoryToRegister.cpp | 8 | ||||
-rw-r--r-- | lib/Transforms/Utils/SimplifyCFG.cpp | 4 |
8 files changed, 16 insertions, 21 deletions
diff --git a/lib/Transforms/Utils/BasicBlockUtils.cpp b/lib/Transforms/Utils/BasicBlockUtils.cpp index 5f6edcf..e652274 100644 --- a/lib/Transforms/Utils/BasicBlockUtils.cpp +++ b/lib/Transforms/Utils/BasicBlockUtils.cpp @@ -51,7 +51,7 @@ void llvm::DeleteDeadBlock(BasicBlock *BB) { // contained within it must dominate their uses, that all uses will // eventually be removed (they are themselves dead). if (!I.use_empty()) - I.replaceAllUsesWith(BB->getContext().getUndef(I.getType())); + I.replaceAllUsesWith(UndefValue::get(I.getType())); BB->getInstList().pop_back(); } @@ -71,7 +71,7 @@ void llvm::FoldSingleEntryPHINodes(BasicBlock *BB) { if (PN->getIncomingValue(0) != PN) PN->replaceAllUsesWith(PN->getIncomingValue(0)); else - PN->replaceAllUsesWith(BB->getContext().getUndef(PN->getType())); + PN->replaceAllUsesWith(UndefValue::get(PN->getType())); PN->eraseFromParent(); } } @@ -387,8 +387,7 @@ BasicBlock *llvm::SplitBlockPredecessors(BasicBlock *BB, if (NumPreds == 0) { // Insert dummy values as the incoming value. for (BasicBlock::iterator I = BB->begin(); isa<PHINode>(I); ++I) - cast<PHINode>(I)->addIncoming(BB->getContext().getUndef(I->getType()), - NewBB); + cast<PHINode>(I)->addIncoming(UndefValue::get(I->getType()), NewBB); return NewBB; } diff --git a/lib/Transforms/Utils/CloneFunction.cpp b/lib/Transforms/Utils/CloneFunction.cpp index 7b8a8a4..2b2fcb1 100644 --- a/lib/Transforms/Utils/CloneFunction.cpp +++ b/lib/Transforms/Utils/CloneFunction.cpp @@ -489,7 +489,7 @@ void llvm::CloneAndPruneFunctionInto(Function *NewFunc, const Function *OldFunc, BasicBlock::iterator I = NewBB->begin(); BasicBlock::const_iterator OldI = OldBB->begin(); while ((PN = dyn_cast<PHINode>(I++))) { - Value *NV = OldFunc->getContext().getUndef(PN->getType()); + Value *NV = UndefValue::get(PN->getType()); PN->replaceAllUsesWith(NV); assert(ValueMap[OldI] == PN && "ValueMap mismatch"); ValueMap[OldI] = NV; diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp index 43b996af..d6382af 100644 --- a/lib/Transforms/Utils/InlineFunction.cpp +++ b/lib/Transforms/Utils/InlineFunction.cpp @@ -521,7 +521,7 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) { if (!TheCall->use_empty()) { ReturnInst *R = Returns[0]; if (TheCall == R->getReturnValue()) - TheCall->replaceAllUsesWith(Context.getUndef(TheCall->getType())); + TheCall->replaceAllUsesWith(UndefValue::get(TheCall->getType())); else TheCall->replaceAllUsesWith(R->getReturnValue()); } @@ -614,7 +614,7 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) { // using the return value of the call with the computed value. if (!TheCall->use_empty()) { if (TheCall == Returns[0]->getReturnValue()) - TheCall->replaceAllUsesWith(Context.getUndef(TheCall->getType())); + TheCall->replaceAllUsesWith(UndefValue::get(TheCall->getType())); else TheCall->replaceAllUsesWith(Returns[0]->getReturnValue()); } @@ -634,7 +634,7 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) { } else if (!TheCall->use_empty()) { // No returns, but something is using the return value of the call. Just // nuke the result. - TheCall->replaceAllUsesWith(Context.getUndef(TheCall->getType())); + TheCall->replaceAllUsesWith(UndefValue::get(TheCall->getType())); } // Since we are now done with the Call/Invoke, we can delete it. diff --git a/lib/Transforms/Utils/LCSSA.cpp b/lib/Transforms/Utils/LCSSA.cpp index 1b72849..84fcc64 100644 --- a/lib/Transforms/Utils/LCSSA.cpp +++ b/lib/Transforms/Utils/LCSSA.cpp @@ -243,7 +243,7 @@ Value *LCSSA::GetValueForBlock(DomTreeNode *BB, Instruction *OrigInst, DenseMap<DomTreeNode*, Value*> &Phis) { // If there is no dominator info for this BB, it is unreachable. if (BB == 0) - return OrigInst->getContext().getUndef(OrigInst->getType()); + return UndefValue::get(OrigInst->getType()); // If we have already computed this value, return the previously computed val. if (Phis.count(BB)) return Phis[BB]; diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp index e9be0e2..18ce81d 100644 --- a/lib/Transforms/Utils/Local.cpp +++ b/lib/Transforms/Utils/Local.cpp @@ -263,8 +263,6 @@ void llvm::RecursivelyDeleteTriviallyDeadInstructions(Value *V) { /// too, recursively. void llvm::RecursivelyDeleteDeadPHINode(PHINode *PN) { - LLVMContext &Context = PN->getContext(); - // We can remove a PHI if it is on a cycle in the def-use graph // where each node in the cycle has degree one, i.e. only one use, // and is an instruction with no side effects. @@ -281,7 +279,7 @@ llvm::RecursivelyDeleteDeadPHINode(PHINode *PN) { if (PHINode *JP = dyn_cast<PHINode>(J)) if (!PHIs.insert(cast<PHINode>(JP))) { // Break the cycle and delete the PHI and its operands. - JP->replaceAllUsesWith(Context.getUndef(JP->getType())); + JP->replaceAllUsesWith(UndefValue::get(JP->getType())); RecursivelyDeleteTriviallyDeadInstructions(JP); break; } @@ -301,7 +299,7 @@ void llvm::MergeBasicBlockIntoOnlyPred(BasicBlock *DestBB) { while (PHINode *PN = dyn_cast<PHINode>(DestBB->begin())) { Value *NewVal = PN->getIncomingValue(0); // Replace self referencing PHI with undef, it must be dead. - if (NewVal == PN) NewVal = DestBB->getContext().getUndef(PN->getType()); + if (NewVal == PN) NewVal = UndefValue::get(PN->getType()); PN->replaceAllUsesWith(NewVal); PN->eraseFromParent(); } diff --git a/lib/Transforms/Utils/LoopSimplify.cpp b/lib/Transforms/Utils/LoopSimplify.cpp index 045b428..69a2084 100644 --- a/lib/Transforms/Utils/LoopSimplify.cpp +++ b/lib/Transforms/Utils/LoopSimplify.cpp @@ -166,7 +166,7 @@ bool LoopSimplify::runOnFunction(Function &F) { // Delete the dead terminator. if (AA) AA->deleteValue(TI); if (!TI->use_empty()) - TI->replaceAllUsesWith(F.getContext().getUndef(TI->getType())); + TI->replaceAllUsesWith(UndefValue::get(TI->getType())); TI->eraseFromParent(); Changed |= true; } diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp index 5645110..3cfaed6 100644 --- a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp +++ b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp @@ -448,7 +448,7 @@ void PromoteMem2Reg::run() { // RenamePassData::ValVector Values(Allocas.size()); for (unsigned i = 0, e = Allocas.size(); i != e; ++i) - Values[i] = Context.getUndef(Allocas[i]->getAllocatedType()); + Values[i] = UndefValue::get(Allocas[i]->getAllocatedType()); // Walks all basic blocks in the function performing the SSA rename algorithm // and inserting the phi nodes we marked as necessary @@ -475,7 +475,7 @@ void PromoteMem2Reg::run() { // Just delete the users now. // if (!A->use_empty()) - A->replaceAllUsesWith(Context.getUndef(A->getType())); + A->replaceAllUsesWith(UndefValue::get(A->getType())); if (AST) AST->deleteValue(A); A->eraseFromParent(); } @@ -561,7 +561,7 @@ void PromoteMem2Reg::run() { BasicBlock::iterator BBI = BB->begin(); while ((SomePHI = dyn_cast<PHINode>(BBI++)) && SomePHI->getNumIncomingValues() == NumBadPreds) { - Value *UndefVal = Context.getUndef(SomePHI->getType()); + Value *UndefVal = UndefValue::get(SomePHI->getType()); for (unsigned pred = 0, e = Preds.size(); pred != e; ++pred) SomePHI->addIncoming(UndefVal, Preds[pred]); } @@ -807,7 +807,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(Context.getUndef(LI->getType())); + LI->replaceAllUsesWith(UndefValue::get(LI->getType())); if (AST && isa<PointerType>(LI->getType())) AST->deleteValue(LI); LBI.deleteValue(LI); diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index b0643d6..0f9493d 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/lib/Transforms/Utils/SimplifyCFG.cpp @@ -1266,8 +1266,6 @@ static bool FoldCondBranchOnPHI(BranchInst *BI) { /// FoldTwoEntryPHINode - Given a BB that starts with the specified two-entry /// PHI node, see if we can eliminate it. static bool FoldTwoEntryPHINode(PHINode *PN) { - LLVMContext &Context = PN->getParent()->getContext(); - // Ok, this is a two entry PHI node. Check to see if this is a simple "if // statement", which has a very simple dominance structure. Basically, we // are trying to find the condition that is being branched on, which @@ -1305,7 +1303,7 @@ static bool FoldTwoEntryPHINode(PHINode *PN) { if (PN->getIncomingValue(0) != PN) PN->replaceAllUsesWith(PN->getIncomingValue(0)); else - PN->replaceAllUsesWith(Context.getUndef(PN->getType())); + PN->replaceAllUsesWith(UndefValue::get(PN->getType())); } else if (!DominatesMergePoint(PN->getIncomingValue(0), BB, &AggressiveInsts) || !DominatesMergePoint(PN->getIncomingValue(1), BB, |