summaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2009-07-30 23:03:37 +0000
committerOwen Anderson <resistor@mac.com>2009-07-30 23:03:37 +0000
commit9e9a0d5fc26878e51a58a8b57900fcbf952c2691 (patch)
tree477eb7b58abe6134ff6accc805279396a77892e8 /lib/Transforms
parent124e6eb09d47674a4bac48a522e83e4513a970e5 (diff)
downloadllvm-9e9a0d5fc26878e51a58a8b57900fcbf952c2691.tar.gz
llvm-9e9a0d5fc26878e51a58a8b57900fcbf952c2691.tar.bz2
llvm-9e9a0d5fc26878e51a58a8b57900fcbf952c2691.tar.xz
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')
-rw-r--r--lib/Transforms/IPO/DeadArgumentElimination.cpp6
-rw-r--r--lib/Transforms/IPO/GlobalOpt.cpp12
-rw-r--r--lib/Transforms/IPO/IPConstantPropagation.cpp6
-rw-r--r--lib/Transforms/IPO/LowerSetJmp.cpp3
-rw-r--r--lib/Transforms/IPO/PruneEH.cpp2
-rw-r--r--lib/Transforms/IPO/RaiseAllocations.cpp4
-rw-r--r--lib/Transforms/IPO/StripSymbols.cpp2
-rw-r--r--lib/Transforms/Instrumentation/ProfilingUtils.cpp2
-rw-r--r--lib/Transforms/Scalar/GVN.cpp8
-rw-r--r--lib/Transforms/Scalar/IndVarSimplify.cpp4
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp98
-rw-r--r--lib/Transforms/Scalar/JumpThreading.cpp3
-rw-r--r--lib/Transforms/Scalar/LICM.cpp4
-rw-r--r--lib/Transforms/Scalar/LoopUnswitch.cpp2
-rw-r--r--lib/Transforms/Scalar/Reassociate.cpp6
-rw-r--r--lib/Transforms/Scalar/SCCP.cpp14
-rw-r--r--lib/Transforms/Scalar/ScalarReplAggregates.cpp8
-rw-r--r--lib/Transforms/Scalar/SimplifyCFGPass.cpp2
-rw-r--r--lib/Transforms/Utils/BasicBlockUtils.cpp7
-rw-r--r--lib/Transforms/Utils/CloneFunction.cpp2
-rw-r--r--lib/Transforms/Utils/InlineFunction.cpp6
-rw-r--r--lib/Transforms/Utils/LCSSA.cpp2
-rw-r--r--lib/Transforms/Utils/Local.cpp6
-rw-r--r--lib/Transforms/Utils/LoopSimplify.cpp2
-rw-r--r--lib/Transforms/Utils/PromoteMemoryToRegister.cpp8
-rw-r--r--lib/Transforms/Utils/SimplifyCFG.cpp4
26 files changed, 105 insertions, 118 deletions
diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp
index 0b7e9d9874..fbdca723f6 100644
--- a/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -758,7 +758,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
}
if (ExtraArgHack)
- Args.push_back(Context.getUndef(Type::Int32Ty));
+ Args.push_back(UndefValue::get(Type::Int32Ty));
// Push any varargs arguments on the list. Don't forget their attributes.
for (CallSite::arg_iterator E = CS.arg_end(); I != E; ++I, ++i) {
@@ -814,7 +814,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
// extract/insertvalue chaining and let instcombine clean that up.
//
// Start out building up our return value from undef
- Value *RetVal = Context.getUndef(RetTy);
+ Value *RetVal = UndefValue::get(RetTy);
for (unsigned i = 0; i != RetCount; ++i)
if (NewRetIdxs[i] != -1) {
Value *V;
@@ -881,7 +881,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
// clean that up.
Value *OldRet = RI->getOperand(0);
// Start out building up our return value from undef
- RetVal = Context.getUndef(NRetTy);
+ RetVal = UndefValue::get(NRetTy);
for (unsigned i = 0; i != RetCount; ++i)
if (NewRetIdxs[i] != -1) {
ExtractValueInst *EV = ExtractValueInst::Create(OldRet, i,
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp
index e0e5b60b0e..d2a53138cb 100644
--- a/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/lib/Transforms/IPO/GlobalOpt.cpp
@@ -269,10 +269,10 @@ static Constant *getAggregateConstantElement(Constant *Agg, Constant *Idx,
} else if (isa<UndefValue>(Agg)) {
if (const StructType *STy = dyn_cast<StructType>(Agg->getType())) {
if (IdxV < STy->getNumElements())
- return Context.getUndef(STy->getElementType(IdxV));
+ return UndefValue::get(STy->getElementType(IdxV));
} else if (const SequentialType *STy =
dyn_cast<SequentialType>(Agg->getType())) {
- return Context.getUndef(STy->getElementType());
+ return UndefValue::get(STy->getElementType());
}
}
return 0;
@@ -844,7 +844,7 @@ static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV,
// FIXME: This new global should have the alignment returned by malloc. Code
// could depend on malloc returning large alignment (on the mac, 16 bytes) but
// this would only guarantee some lower alignment.
- Constant *Init = Context.getUndef(MI->getAllocatedType());
+ Constant *Init = UndefValue::get(MI->getAllocatedType());
GlobalVariable *NewGV = new GlobalVariable(*GV->getParent(),
MI->getAllocatedType(), false,
GlobalValue::InternalLinkage, Init,
@@ -2056,7 +2056,7 @@ static Constant *EvaluateStoreInto(Constant *Init, Constant *Val,
Elts.push_back(Context.getNullValue(STy->getElementType(i)));
} else if (isa<UndefValue>(Init)) {
for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i)
- Elts.push_back(Context.getUndef(STy->getElementType(i)));
+ Elts.push_back(UndefValue::get(STy->getElementType(i)));
} else {
llvm_unreachable("This code is out of sync with "
" ConstantFoldLoadThroughGEPConstantExpr");
@@ -2083,7 +2083,7 @@ static Constant *EvaluateStoreInto(Constant *Init, Constant *Val,
Constant *Elt = Context.getNullValue(ATy->getElementType());
Elts.assign(ATy->getNumElements(), Elt);
} else if (isa<UndefValue>(Init)) {
- Constant *Elt = Context.getUndef(ATy->getElementType());
+ Constant *Elt = UndefValue::get(ATy->getElementType());
Elts.assign(ATy->getNumElements(), Elt);
} else {
llvm_unreachable("This code is out of sync with "
@@ -2227,7 +2227,7 @@ static bool EvaluateFunction(Function *F, Constant *&RetVal,
const Type *Ty = AI->getType()->getElementType();
AllocaTmps.push_back(new GlobalVariable(Context, Ty, false,
GlobalValue::InternalLinkage,
- Context.getUndef(Ty),
+ UndefValue::get(Ty),
AI->getName()));
InstResult = AllocaTmps.back();
} else if (CallInst *CI = dyn_cast<CallInst>(CurInst)) {
diff --git a/lib/Transforms/IPO/IPConstantPropagation.cpp b/lib/Transforms/IPO/IPConstantPropagation.cpp
index adb5242639..4edecc2b23 100644
--- a/lib/Transforms/IPO/IPConstantPropagation.cpp
+++ b/lib/Transforms/IPO/IPConstantPropagation.cpp
@@ -134,7 +134,7 @@ bool IPCP::PropagateConstantsIntoArguments(Function &F) {
continue;
Value *V = ArgumentConstants[i].first;
- if (V == 0) V = F.getContext().getUndef(AI->getType());
+ if (V == 0) V = UndefValue::get(AI->getType());
AI->replaceAllUsesWith(V);
++NumArgumentsProped;
MadeChange = true;
@@ -167,9 +167,9 @@ bool IPCP::PropagateConstantReturn(Function &F) {
const StructType *STy = dyn_cast<StructType>(F.getReturnType());
if (STy)
for (unsigned i = 0, e = STy->getNumElements(); i < e; ++i)
- RetVals.push_back(Context.getUndef(STy->getElementType(i)));
+ RetVals.push_back(UndefValue::get(STy->getElementType(i)));
else
- RetVals.push_back(Context.getUndef(F.getReturnType()));
+ RetVals.push_back(UndefValue::get(F.getReturnType()));
unsigned NumNonConstant = 0;
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
diff --git a/lib/Transforms/IPO/LowerSetJmp.cpp b/lib/Transforms/IPO/LowerSetJmp.cpp
index d2837a30ed..3a65ac7a8f 100644
--- a/lib/Transforms/IPO/LowerSetJmp.cpp
+++ b/lib/Transforms/IPO/LowerSetJmp.cpp
@@ -289,8 +289,7 @@ void LowerSetJmp::TransformLongJmpCall(CallInst* Inst)
Removed = &BB->back();
// If the removed instructions have any users, replace them now.
if (!Removed->use_empty())
- Removed->replaceAllUsesWith(
- Inst->getContext().getUndef(Removed->getType()));
+ Removed->replaceAllUsesWith(UndefValue::get(Removed->getType()));
Removed->eraseFromParent();
} while (Removed != Inst);
diff --git a/lib/Transforms/IPO/PruneEH.cpp b/lib/Transforms/IPO/PruneEH.cpp
index a98a793461..d2a6530cd9 100644
--- a/lib/Transforms/IPO/PruneEH.cpp
+++ b/lib/Transforms/IPO/PruneEH.cpp
@@ -243,7 +243,7 @@ void PruneEH::DeleteBasicBlock(BasicBlock *BB) {
} else if (InvokeInst *II = dyn_cast<InvokeInst>(I))
CGN->removeCallEdgeFor(II);
if (!I->use_empty())
- I->replaceAllUsesWith(BB->getContext().getUndef(I->getType()));
+ I->replaceAllUsesWith(UndefValue::get(I->getType()));
}
// Get the list of successors of this block.
diff --git a/lib/Transforms/IPO/RaiseAllocations.cpp b/lib/Transforms/IPO/RaiseAllocations.cpp
index 943d3cf160..0ef0991637 100644
--- a/lib/Transforms/IPO/RaiseAllocations.cpp
+++ b/lib/Transforms/IPO/RaiseAllocations.cpp
@@ -142,8 +142,6 @@ bool RaiseAllocations::runOnModule(Module &M) {
// Find the malloc/free prototypes...
doInitialization(M);
- LLVMContext &Context = M.getContext();
-
bool Changed = false;
// First, process all of the malloc calls...
@@ -233,7 +231,7 @@ bool RaiseAllocations::runOnModule(Module &M) {
// Delete the old call site
if (I->getType() != Type::VoidTy)
- I->replaceAllUsesWith(Context.getUndef(I->getType()));
+ I->replaceAllUsesWith(UndefValue::get(I->getType()));
I->eraseFromParent();
Changed = true;
++NumRaised;
diff --git a/lib/Transforms/IPO/StripSymbols.cpp b/lib/Transforms/IPO/StripSymbols.cpp
index f2b561da80..1bbda3cd22 100644
--- a/lib/Transforms/IPO/StripSymbols.cpp
+++ b/lib/Transforms/IPO/StripSymbols.cpp
@@ -232,7 +232,7 @@ bool StripDebugInfo(Module &M) {
if (!GV) continue;
if (!GV->use_empty() && llvmUsedValues.count(I) == 0) {
if (GV->getName().startswith("llvm.dbg")) {
- GV->replaceAllUsesWith(M.getContext().getUndef(GV->getType()));
+ GV->replaceAllUsesWith(UndefValue::get(GV->getType()));
}
}
}
diff --git a/lib/Transforms/Instrumentation/ProfilingUtils.cpp b/lib/Transforms/Instrumentation/ProfilingUtils.cpp
index d5752b72d2..6e5b523d6c 100644
--- a/lib/Transforms/Instrumentation/ProfilingUtils.cpp
+++ b/lib/Transforms/Instrumentation/ProfilingUtils.cpp
@@ -53,7 +53,7 @@ void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName,
} else {
// If this profiling instrumentation doesn't have a constant array, just
// pass null.
- Args[2] = Context.getConstantPointerNull(UIntPtr);
+ Args[2] = ConstantPointerNull::get(UIntPtr);
}
Args[3] = ConstantInt::get(Type::Int32Ty, NumElements);
diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp
index 0b0968af21..ea8108153c 100644
--- a/lib/Transforms/Scalar/GVN.cpp
+++ b/lib/Transforms/Scalar/GVN.cpp
@@ -798,7 +798,7 @@ Value *GVN::GetValueForBlock(BasicBlock *BB, Instruction* orig,
// If the block is unreachable, just return undef, since this path
// can't actually occur at runtime.
if (!DT->isReachableFromEntry(BB))
- return Phis[BB] = BB->getContext().getUndef(orig->getType());
+ return Phis[BB] = UndefValue::get(orig->getType());
if (BasicBlock *Pred = BB->getSinglePredecessor()) {
Value *ret = GetValueForBlock(Pred, orig, Phis);
@@ -985,8 +985,8 @@ bool GVN::processNonLocalLoad(LoadInst *LI,
// Loading the allocation -> undef.
if (isa<AllocationInst>(DepInst)) {
- ValuesPerBlock.push_back(std::make_pair(DepBB,
- DepBB->getContext().getUndef(LI->getType())));
+ ValuesPerBlock.push_back(std::make_pair(DepBB,
+ UndefValue::get(LI->getType())));
continue;
}
@@ -1273,7 +1273,7 @@ bool GVN::processLoad(LoadInst *L, SmallVectorImpl<Instruction*> &toErase) {
// undef value. This can happen when loading for a fresh allocation with no
// intervening stores, for example.
if (isa<AllocationInst>(DepInst)) {
- L->replaceAllUsesWith(DepInst->getContext().getUndef(L->getType()));
+ L->replaceAllUsesWith(UndefValue::get(L->getType()));
toErase.push_back(L);
NumGVNLoad++;
return true;
diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp
index a4b7da23d4..b33c805903 100644
--- a/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -713,8 +713,6 @@ void IndVarSimplify::HandleFloatingPointIV(Loop *L, PHINode *PH) {
}
if (NewPred == CmpInst::BAD_ICMP_PREDICATE) return;
- LLVMContext &Context = PH->getContext();
-
// Insert new integer induction variable.
PHINode *NewPHI = PHINode::Create(Type::Int32Ty,
PH->getName()+".int", PH);
@@ -745,7 +743,7 @@ void IndVarSimplify::HandleFloatingPointIV(Loop *L, PHINode *PH) {
RecursivelyDeleteTriviallyDeadInstructions(EC);
// Delete old, floating point, increment instruction.
- Incr->replaceAllUsesWith(Context.getUndef(Incr->getType()));
+ Incr->replaceAllUsesWith(UndefValue::get(Incr->getType()));
RecursivelyDeleteTriviallyDeadInstructions(Incr);
// Replace floating induction variable, if it isn't already deleted.
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 554591ac25..e0dfe29e0f 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -147,7 +147,7 @@ namespace {
if (Instruction *Op = dyn_cast<Instruction>(*i)) {
AddToWorkList(Op);
// Set the operand to undef to drop the use.
- *i = Context->getUndef(Op->getType());
+ *i = UndefValue::get(Op->getType());
}
return R;
@@ -312,7 +312,7 @@ namespace {
} else {
// If we are replacing the instruction with itself, this must be in a
// segment of unreachable code, so just clobber the instruction.
- I.replaceAllUsesWith(Context->getUndef(I.getType()));
+ I.replaceAllUsesWith(UndefValue::get(I.getType()));
return &I;
}
}
@@ -815,7 +815,7 @@ Value *InstCombiner::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
if (DemandedMask == 0) { // Not demanding any bits from V.
if (isa<UndefValue>(V))
return 0;
- return Context->getUndef(VTy);
+ return UndefValue::get(VTy);
}
if (Depth == 6) // Limit search depth.
@@ -1437,13 +1437,13 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts,
return 0;
} else if (DemandedElts == 0) { // If nothing is demanded, provide undef.
UndefElts = EltMask;
- return Context->getUndef(V->getType());
+ return UndefValue::get(V->getType());
}
UndefElts = 0;
if (ConstantVector *CP = dyn_cast<ConstantVector>(V)) {
const Type *EltTy = cast<VectorType>(V->getType())->getElementType();
- Constant *Undef = Context->getUndef(EltTy);
+ Constant *Undef = UndefValue::get(EltTy);
std::vector<Constant*> Elts;
for (unsigned i = 0; i != VWidth; ++i)
@@ -1471,7 +1471,7 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts,
const Type *EltTy = cast<VectorType>(V->getType())->getElementType();
Constant *Zero = Context->getNullValue(EltTy);
- Constant *Undef = Context->getUndef(EltTy);
+ Constant *Undef = UndefValue::get(EltTy);
std::vector<Constant*> Elts;
for (unsigned i = 0; i != VWidth; ++i) {
Constant *Elt = DemandedElts[i] ? Zero : Undef;
@@ -1592,7 +1592,7 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts,
std::vector<Constant*> Elts;
for (unsigned i = 0; i < VWidth; ++i) {
if (UndefElts[i])
- Elts.push_back(Context->getUndef(Type::Int32Ty));
+ Elts.push_back(UndefValue::get(Type::Int32Ty));
else
Elts.push_back(ConstantInt::get(Type::Int32Ty,
Shuffle->getMaskValue(i)));
@@ -1745,7 +1745,7 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts,
Instruction *New =
InsertElementInst::Create(
- Context->getUndef(II->getType()), TmpV,
+ UndefValue::get(II->getType()), TmpV,
ConstantInt::get(Type::Int32Ty, 0U, false), II->getName());
InsertNewInstBefore(New, *II);
AddSoonDeadInstToWorklist(*II, 0);
@@ -3138,7 +3138,7 @@ Instruction *InstCombiner::commonIRemTransforms(BinaryOperator &I) {
if (ConstantInt *RHS = dyn_cast<ConstantInt>(Op1)) {
// X % 0 == undef, we don't need to preserve faults!
if (RHS->equalsInt(0))
- return ReplaceInstUsesWith(I, Context->getUndef(I.getType()));
+ return ReplaceInstUsesWith(I, UndefValue::get(I.getType()));
if (RHS->equalsInt(1)) // X % 1 == 0
return ReplaceInstUsesWith(I, Context->getNullValue(I.getType()));
@@ -5907,7 +5907,7 @@ Instruction *InstCombiner::visitFCmpInst(FCmpInst &I) {
}
if (isa<UndefValue>(Op1)) // fcmp pred X, undef -> undef
- return ReplaceInstUsesWith(I, Context->getUndef(Type::Int1Ty));
+ return ReplaceInstUsesWith(I, UndefValue::get(Type::Int1Ty));
// Handle fcmp with constant RHS
if (Constant *RHSC = dyn_cast<Constant>(Op1)) {
@@ -5981,7 +5981,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
I.isTrueWhenEqual()));
if (isa<UndefValue>(Op1)) // X icmp undef -> undef
- return ReplaceInstUsesWith(I, Context->getUndef(Type::Int1Ty));
+ return ReplaceInstUsesWith(I, UndefValue::get(Type::Int1Ty));
// icmp <global/alloca*/null>, <global/alloca*/null> - Global/Stack value
// addresses never equal each other! We already know that Op0 != Op1.
@@ -8995,7 +8995,7 @@ Instruction *InstCombiner::visitBitCast(BitCastInst &CI) {
if (!isa<VectorType>(SrcTy)) {
Value *Elem = InsertCastBefore(Instruction::BitCast, Src,
DestVTy->getElementType(), CI);
- return InsertElementInst::Create(Context->getUndef(DestTy), Elem,
+ return InsertElementInst::Create(UndefValue::get(DestTy), Elem,
Context->getNullValue(Type::Int32Ty));
}
// FIXME: Canonicalize bitcast(insertelement) -> insertelement(bitcast)
@@ -9936,7 +9936,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
// Cast the input vectors to byte vectors.
Value *Op0 =InsertBitCastBefore(II->getOperand(1),Mask->getType(),CI);
Value *Op1 =InsertBitCastBefore(II->getOperand(2),Mask->getType(),CI);
- Value *Result = Context->getUndef(Op0->getType());
+ Value *Result = UndefValue::get(Op0->getType());
// Only extract each element once.
Value *ExtractedElts[32];
@@ -10062,10 +10062,10 @@ Instruction *InstCombiner::visitCallSite(CallSite CS) {
// If the call and callee calling conventions don't match, this call must
// be unreachable, as the call is undefined.
new StoreInst(Context->getTrue(),
- Context->getUndef(PointerType::getUnqual(Type::Int1Ty)),
+ UndefValue::get(PointerType::getUnqual(Type::Int1Ty)),
OldCall);
if (!OldCall->use_empty())
- OldCall->replaceAllUsesWith(Context->getUndef(OldCall->getType()));
+ OldCall->replaceAllUsesWith(UndefValue::get(OldCall->getType()));
if (isa<CallInst>(OldCall)) // Not worth removing an invoke here.
return EraseInstFromFunction(*OldCall);
return 0;
@@ -10076,12 +10076,12 @@ Instruction *InstCombiner::visitCallSite(CallSite CS) {
// undef so that we know that this code is not reachable, despite the fact
// that we can't modify the CFG here.
new StoreInst(Context->getTrue(),
- Context->getUndef(PointerType::getUnqual(Type::Int1Ty)),
+ UndefValue::get(PointerType::getUnqual(Type::Int1Ty)),
CS.getInstruction());
if (!CS.getInstruction()->use_empty())
CS.getInstruction()->
- replaceAllUsesWith(Context->getUndef(CS.getInstruction()->getType()));
+ replaceAllUsesWith(UndefValue::get(CS.getInstruction()->getType()));
if (InvokeInst *II = dyn_cast<InvokeInst>(CS.getInstruction())) {
// Don't break the CFG, insert a dummy cond branch.
@@ -10333,7 +10333,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
}
AddUsersToWorkList(*Caller);
} else {
- NV = Context->getUndef(Caller->getType());
+ NV = UndefValue::get(Caller->getType());
}
}
@@ -10921,7 +10921,7 @@ Instruction *InstCombiner::visitPHINode(PHINode &PN) {
SmallPtrSet<PHINode*, 16> PotentiallyDeadPHIs;
PotentiallyDeadPHIs.insert(&PN);
if (DeadPHICycle(PU, PotentiallyDeadPHIs))
- return ReplaceInstUsesWith(PN, Context->getUndef(PN.getType()));
+ return ReplaceInstUsesWith(PN, UndefValue::get(PN.getType()));
}
// If this phi has a single use, and if that use just computes a value for
@@ -10933,7 +10933,7 @@ Instruction *InstCombiner::visitPHINode(PHINode &PN) {
if (PHIUser->hasOneUse() &&
(isa<BinaryOperator>(PHIUser) || isa<GetElementPtrInst>(PHIUser)) &&
PHIUser->use_back() == &PN) {
- return ReplaceInstUsesWith(PN, Context->getUndef(PN.getType()));
+ return ReplaceInstUsesWith(PN, UndefValue::get(PN.getType()));
}
}
@@ -10997,7 +10997,7 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
return ReplaceInstUsesWith(GEP, PtrOp);
if (isa<UndefValue>(GEP.getOperand(0)))
- return ReplaceInstUsesWith(GEP, Context->getUndef(GEP.getType()));
+ return ReplaceInstUsesWith(GEP, UndefValue::get(GEP.getType()));
bool HasZeroPointerIndex = false;
if (Constant *C = dyn_cast<Constant>(GEP.getOperand(1)))
@@ -11426,7 +11426,7 @@ Instruction *InstCombiner::visitFreeInst(FreeInst &FI) {
if (isa<UndefValue>(Op)) {
// Insert a new store to null because we cannot modify the CFG here.
new StoreInst(Context->getTrue(),
- Context->getUndef(PointerType::getUnqual(Type::Int1Ty)), &FI);
+ UndefValue::get(PointerType::getUnqual(Type::Int1Ty)), &FI);
return EraseInstFromFunction(FI);
}
@@ -11587,9 +11587,9 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) {
// that this code is not reachable. We do this instead of inserting
// an unreachable instruction directly because we cannot modify the
// CFG.
- new StoreInst(Context->getUndef(LI.getType()),
+ new StoreInst(UndefValue::get(LI.getType()),
Context->getNullValue(Op->getType()), &LI);
- return ReplaceInstUsesWith(LI, Context->getUndef(LI.getType()));
+ return ReplaceInstUsesWith(LI, UndefValue::get(LI.getType()));
}
}
@@ -11601,9 +11601,9 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) {
// Insert a new store to null instruction before the load to indicate that
// this code is not reachable. We do this instead of inserting an
// unreachable instruction directly because we cannot modify the CFG.
- new StoreInst(Context->getUndef(LI.getType()),
+ new StoreInst(UndefValue::get(LI.getType()),
Context->getNullValue(Op->getType()), &LI);
- return ReplaceInstUsesWith(LI, Context->getUndef(LI.getType()));
+ return ReplaceInstUsesWith(LI, UndefValue::get(LI.getType()));
}
// Instcombine load (constant global) into the value loaded.
@@ -11625,9 +11625,9 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) {
// that this code is not reachable. We do this instead of inserting
// an unreachable instruction directly because we cannot modify the
// CFG.
- new StoreInst(Context->getUndef(LI.getType()),
+ new StoreInst(UndefValue::get(LI.getType()),
Context->getNullValue(Op->getType()), &LI);
- return ReplaceInstUsesWith(LI, Context->getUndef(LI.getType()));
+ return ReplaceInstUsesWith(LI, UndefValue::get(LI.getType()));
}
} else if (CE->isCast()) {
@@ -11644,7 +11644,7 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) {
if (GV->getInitializer()->isNullValue())
return ReplaceInstUsesWith(LI, Context->getNullValue(LI.getType()));
else if (isa<UndefValue>(GV->getInitializer()))
- return ReplaceInstUsesWith(LI, Context->getUndef(LI.getType()));
+ return ReplaceInstUsesWith(LI, UndefValue::get(LI.getType()));
}
}
@@ -11941,7 +11941,7 @@ Instruction *InstCombiner::visitStoreInst(StoreInst &SI) {
if (isa<ConstantPointerNull>(Ptr) &&
cast<PointerType>(Ptr->getType())->getAddressSpace() == 0) {
if (!isa<UndefValue>(Val)) {
- SI.setOperand(0, Context->getUndef(Val->getType()));
+ SI.setOperand(0, UndefValue::get(Val->getType()));
if (Instruction *U = dyn_cast<Instruction>(Val))
AddToWorkList(U); // Dropped a use.
++NumCombined;
@@ -12187,7 +12187,7 @@ Instruction *InstCombiner::visitExtractValueInst(ExtractValueInst &EV) {
if (Constant *C = dyn_cast<Constant>(Agg)) {
if (isa<UndefValue>(C))
- return ReplaceInstUsesWith(EV, Context->getUndef(EV.getType()));
+ return ReplaceInstUsesWith(EV, UndefValue::get(EV.getType()));
if (isa<ConstantAggregateZero>(C))
return ReplaceInstUsesWith(EV, Context->getNullValue(EV.getType()));
@@ -12332,10 +12332,10 @@ static Value *FindScalarElement(Value *V, unsigned EltNo,
const VectorType *PTy = cast<VectorType>(V->getType());
unsigned Width = PTy->getNumElements();
if (EltNo >= Width) // Out of range access.
- return Context->getUndef(PTy->getElementType());
+ return UndefValue::get(PTy->getElementType());
if (isa<UndefValue>(V))
- return Context->getUndef(PTy->getElementType());
+ return UndefValue::get(PTy->getElementType());
else if (isa<ConstantAggregateZero>(V))
return Context->getNullValue(PTy->getElementType());
else if (ConstantVector *CP = dyn_cast<ConstantVector>(V))
@@ -12363,7 +12363,7 @@ static Value *FindScalarElement(Value *V, unsigned EltNo,
else if (InEl < LHSWidth*2)
return FindScalarElement(SVI->getOperand(1), InEl - LHSWidth, Context);
else
- return Context->getUndef(PTy->getElementType());
+ return UndefValue::get(PTy->getElementType());
}
// Otherwise, we don't know.
@@ -12373,7 +12373,7 @@ static Value *FindScalarElement(Value *V, unsigned EltNo,
Instruction *InstCombiner::visitExtractElementInst(ExtractElementInst &EI) {
// If vector val is undef, replace extract with scalar undef.
if (isa<UndefValue>(EI.getOperand(0)))
- return ReplaceInstUsesWith(EI, Context->getUndef(EI.getType()));
+ return ReplaceInstUsesWith(EI, UndefValue::get(EI.getType()));
// If vector val is constant 0, replace extract with scalar 0.
if (isa<ConstantAggregateZero>(EI.getOperand(0)))
@@ -12403,7 +12403,7 @@ Instruction *InstCombiner::visitExtractElementInst(ExtractElementInst &EI) {
// If this is extracting an invalid index, turn this into undef, to avoid
// crashing the code below.
if (IndexVal >= VectorWidth)
- return ReplaceInstUsesWith(EI, Context->getUndef(EI.getType()));
+ return ReplaceInstUsesWith(EI, UndefValue::get(EI.getType()));
// This instruction only demands the single element from the input vector.
// If the input vector has a single use, simplify it based on this use
@@ -12490,7 +12490,7 @@ Instruction *InstCombiner::visitExtractElementInst(ExtractElementInst &EI) {
SrcIdx -= LHSWidth;
Src = SVI->getOperand(1);
} else {
- return ReplaceInstUsesWith(EI, Context->getUndef(EI.getType()));
+ return ReplaceInstUsesWith(EI, UndefValue::get(EI.getType()));
}
return ExtractElementInst::Create(Src,
ConstantInt::get(Type::Int32Ty, SrcIdx, false));
@@ -12512,7 +12512,7 @@ static bool CollectSingleShuffleElements(Value *V, Value *LHS, Value *RHS,
unsigned NumElts = cast<VectorType>(V->getType())->getNumElements();
if (isa<UndefValue>(V)) {
- Mask.assign(NumElts, Context->getUndef(Type::Int32Ty));
+ Mask.assign(NumElts, UndefValue::get(Type::Int32Ty));
return true;
} else if (V == LHS) {
for (unsigned i = 0; i != NumElts; ++i)
@@ -12537,7 +12537,7 @@ static bool CollectSingleShuffleElements(Value *V, Value *LHS, Value *RHS,
// transitively ok.
if (CollectSingleShuffleElements(VecOp, LHS, RHS, Mask, Context)) {
// If so, update the mask to reflect the inserted undef.
- Mask[InsertedIdx] = Context->getUndef(Type::Int32Ty);
+ Mask[InsertedIdx] = UndefValue::get(Type::Int32Ty);
return true;
}
} else if (ExtractElementInst *EI = dyn_cast<ExtractElementInst>(ScalarOp)){
@@ -12583,7 +12583,7 @@ static Value *CollectShuffleElements(Value *V, std::vector<Constant*> &Mask,
unsigned NumElts = cast<VectorType>(V->getType())->getNumElements();
if (isa<UndefValue>(V)) {
- Mask.assign(NumElts, Context->getUndef(Type::Int32Ty));
+ Mask.assign(NumElts, UndefValue::get(Type::Int32Ty));
return V;
} else if (isa<ConstantAggregateZero>(V)) {
Mask.assign(NumElts, ConstantInt::get(Type::Int32Ty, 0));
@@ -12662,7 +12662,7 @@ Instruction *InstCombiner::visitInsertElementInst(InsertElementInst &IE) {
return ReplaceInstUsesWith(IE, VecOp);
if (InsertedIdx >= NumVectorElts) // Out of range insert.
- return ReplaceInstUsesWith(IE, Context->getUndef(IE.getType()));
+ return ReplaceInstUsesWith(IE, UndefValue::get(IE.getType()));
// If we are extracting a value from a vector, then inserting it right
// back into the same place, just use the input vector.
@@ -12679,7 +12679,7 @@ Instruction *InstCombiner::visitInsertElementInst(InsertElementInst &IE) {
// Build a new shuffle mask.
std::vector<Constant*> Mask;
if (isa<UndefValue>(VecOp))
- Mask.assign(NumVectorElts, Context->getUndef(Type::Int32Ty));
+ Mask.assign(NumVectorElts, UndefValue::get(Type::Int32Ty));
else {
assert(isa<ConstantAggregateZero>(VecOp) && "Unknown thing");
Mask.assign(NumVectorElts, ConstantInt::get(Type::Int32Ty,
@@ -12697,7 +12697,7 @@ Instruction *InstCombiner::visitInsertElementInst(InsertElementInst &IE) {
std::vector<Constant*> Mask;
Value *RHS = 0;
Value *LHS = CollectShuffleElements(&IE, Mask, RHS, Context);
- if (RHS == 0) RHS = Context->getUndef(LHS->getType());
+ if (RHS == 0) RHS = UndefValue::get(LHS->getType());
// We now have a shuffle of LHS, RHS, Mask.
return new ShuffleVectorInst(LHS, RHS,
ConstantVector::get(Mask));
@@ -12724,7 +12724,7 @@ Instruction *InstCombiner::visitShuffleVectorInst(ShuffleVectorInst &SVI) {
// Undefined shuffle mask -> undefined value.
if (isa<UndefValue>(SVI.getOperand(2)))
- return ReplaceInstUsesWith(SVI, Context->getUndef(SVI.getType()));
+ return ReplaceInstUsesWith(SVI, UndefValue::get(SVI.getType()));
unsigned VWidth = cast<VectorType>(SVI.getType())->getNumElements();
@@ -12751,12 +12751,12 @@ Instruction *InstCombiner::visitShuffleVectorInst(ShuffleVectorInst &SVI) {
std::vector<Constant*> Elts;
for (unsigned i = 0, e = Mask.size(); i != e; ++i) {
if (Mask[i] >= 2*e)
- Elts.push_back(Context->getUndef(Type::Int32Ty));
+ Elts.push_back(UndefValue::get(Type::Int32Ty));
else {
if ((Mask[i] >= e && isa<UndefValue>(RHS)) ||
(Mask[i] < e && isa<UndefValue>(LHS))) {
Mask[i] = 2*e; // Turn into undef.
- Elts.push_back(Context->getUndef(Type::Int32Ty));
+ Elts.push_back(UndefValue::get(Type::Int32Ty));
} else {
Mask[i] = Mask[i] % e; // Force to LHS.
Elts.push_back(ConstantInt::get(Type::Int32Ty, Mask[i]));
@@ -12764,7 +12764,7 @@ Instruction *InstCombiner::visitShuffleVectorInst(ShuffleVectorInst &SVI) {
}
}
SVI.setOperand(0, SVI.getOperand(1));
- SVI.setOperand(1, Context->getUndef(RHS->getType()));
+ SVI.setOperand(1, UndefValue::get(RHS->getType()));
SVI.setOperand(2, ConstantVector::get(Elts));
LHS = SVI.getOperand(0);
RHS = SVI.getOperand(1);
@@ -12815,7 +12815,7 @@ Instruction *InstCombiner::visitShuffleVectorInst(ShuffleVectorInst &SVI) {
std::vector<Constant*> Elts;
for (unsigned i = 0, e = NewMask.size(); i != e; ++i) {
if (NewMask[i] >= LHSInNElts*2) {
- Elts.push_back(Context->getUndef(Type::Int32Ty));
+ Elts.push_back(UndefValue::get(Type::Int32Ty));
} else {
Elts.push_back(ConstantInt::get(Type::Int32Ty, NewMask[i]));
}
@@ -12992,7 +12992,7 @@ bool InstCombiner::DoOneIteration(Function &F, unsigned Iteration) {
Changed = true;
}
if (!I->use_empty())
- I->replaceAllUsesWith(Context->getUndef(I->getType()));
+ I->replaceAllUsesWith(UndefValue::get(I->getType()));
I->eraseFromParent();
}
}
diff --git a/lib/Transforms/Scalar/JumpThreading.cpp b/lib/Transforms/Scalar/JumpThreading.cpp
index 2360ea9c6b..5cdd0947ab 100644
--- a/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/lib/Transforms/Scalar/JumpThreading.cpp
@@ -564,8 +564,7 @@ bool JumpThreading::SimplifyPartiallyRedundantLoad(LoadInst *LI) {
// If the returned value is the load itself, replace with an undef. This can
// only happen in dead loops.
- if (AvailableVal == LI) AvailableVal =
- AvailableVal->getContext().getUndef(LI->getType());
+ if (AvailableVal == LI) AvailableVal = UndefValue::get(LI->getType());
LI->replaceAllUsesWith(AvailableVal);
LI->eraseFromParent();
return true;
diff --git a/lib/Transforms/Scalar/LICM.cpp b/lib/Transforms/Scalar/LICM.cpp
index dc34cf0cc4..02a33a7889 100644
--- a/lib/Transforms/Scalar/LICM.cpp
+++ b/lib/Transforms/Scalar/LICM.cpp
@@ -486,7 +486,7 @@ void LICM::sink(Instruction &I) {
// Instruction is not used, just delete it.
CurAST->deleteValue(&I);
if (!I.use_empty()) // If I has users in unreachable blocks, eliminate.
- I.replaceAllUsesWith(Context.getUndef(I.getType()));
+ I.replaceAllUsesWith(UndefValue::get(I.getType()));
I.eraseFromParent();
} else {
// Move the instruction to the start of the exit block, after any PHI
@@ -500,7 +500,7 @@ void LICM::sink(Instruction &I) {
// The instruction is actually dead if there ARE NO exit blocks.
CurAST->deleteValue(&I);
if (!I.use_empty()) // If I has users in unreachable blocks, eliminate.
- I.replaceAllUsesWith(Context.getUndef(I.getType()));
+ I.replaceAllUsesWith(UndefValue::get(I.getType()));
I.eraseFromParent();
} else {
// Otherwise, if we have multiple exits, use the PromoteMem2Reg function to
diff --git a/lib/Transforms/Scalar/LoopUnswitch.cpp b/lib/Transforms/Scalar/LoopUnswitch.cpp
index 5bba625009..95eb3cf218 100644
--- a/lib/Transforms/Scalar/LoopUnswitch.cpp
+++ b/lib/Transforms/Scalar/LoopUnswitch.cpp
@@ -821,7 +821,7 @@ void LoopUnswitch::RemoveBlockIfDead(BasicBlock *BB,
// Anything that uses the instructions in this basic block should have their
// uses replaced with undefs.
if (!I->use_empty())
- I->replaceAllUsesWith(I->getContext().getUndef(I->getType()));
+ I->replaceAllUsesWith(UndefValue::get(I->getType()));
}
// If this is the edge to the header block for a loop, remove the loop and
diff --git a/lib/Transforms/Scalar/Reassociate.cpp b/lib/Transforms/Scalar/Reassociate.cpp
index 24fadb6003..cade3e6c04 100644
--- a/lib/Transforms/Scalar/Reassociate.cpp
+++ b/lib/Transforms/Scalar/Reassociate.cpp
@@ -285,8 +285,8 @@ void Reassociate::LinearizeExprTree(BinaryOperator *I,
Ops.push_back(ValueEntry(getRank(RHS), RHS));
// Clear the leaves out.
- I->setOperand(0, Context.getUndef(I->getType()));
- I->setOperand(1, Context.getUndef(I->getType()));
+ I->setOperand(0, UndefValue::get(I->getType()));
+ I->setOperand(1, UndefValue::get(I->getType()));
return;
} else {
// Turn X+(Y+Z) -> (Y+Z)+X
@@ -321,7 +321,7 @@ void Reassociate::LinearizeExprTree(BinaryOperator *I,
Ops.push_back(ValueEntry(getRank(RHS), RHS));
// Clear the RHS leaf out.
- I->setOperand(1, Context.getUndef(I->getType()));
+ I->setOperand(1, UndefValue::get(I->getType()));
}
// RewriteExprTree - Now that the operands for this expression tree are
diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp
index c3a1ae2ce3..91fcd209b2 100644
--- a/lib/Transforms/Scalar/SCCP.cpp
+++ b/lib/Transforms/Scalar/SCCP.cpp
@@ -1578,7 +1578,7 @@ bool SCCP::runOnFunction(Function &F) {
Instruction *I = Insts.back();
Insts.pop_back();
if (!I->use_empty())
- I->replaceAllUsesWith(F.getContext().getUndef(I->getType()));
+ I->replaceAllUsesWith(UndefValue::get(I->getType()));
BB->getInstList().erase(I);
MadeChanges = true;
++NumInstRemoved;
@@ -1598,7 +1598,7 @@ bool SCCP::runOnFunction(Function &F) {
continue;
Constant *Const = IV.isConstant()
- ? IV.getConstant() : F.getContext().getUndef(Inst->getType());
+ ? IV.getConstant() : UndefValue::get(Inst->getType());
DEBUG(errs() << " Constant: " << *Const << " = " << *Inst);
// Replaces all of the uses of a variable with uses of the constant.
@@ -1717,7 +1717,7 @@ bool IPSCCP::runOnModule(Module &M) {
LatticeVal &IV = Values[AI];
if (IV.isConstant() || IV.isUndefined()) {
Constant *CST = IV.isConstant() ?
- IV.getConstant() : Context->getUndef(AI->getType());
+ IV.getConstant() : UndefValue::get(AI->getType());
DEBUG(errs() << "*** Arg " << *AI << " = " << *CST <<"\n");
// Replaces all of the uses of a variable with uses of the
@@ -1742,7 +1742,7 @@ bool IPSCCP::runOnModule(Module &M) {
Instruction *I = Insts.back();
Insts.pop_back();
if (!I->use_empty())
- I->replaceAllUsesWith(Context->getUndef(I->getType()));
+ I->replaceAllUsesWith(UndefValue::get(I->getType()));
BB->getInstList().erase(I);
MadeChanges = true;
++IPNumInstRemoved;
@@ -1754,7 +1754,7 @@ bool IPSCCP::runOnModule(Module &M) {
TI->getSuccessor(i)->removePredecessor(BB);
}
if (!TI->use_empty())
- TI->replaceAllUsesWith(Context->getUndef(TI->getType()));
+ TI->replaceAllUsesWith(UndefValue::get(TI->getType()));
BB->getInstList().erase(TI);
if (&*BB != &F->front())
@@ -1773,7 +1773,7 @@ bool IPSCCP::runOnModule(Module &M) {
continue;
Constant *Const = IV.isConstant()
- ? IV.getConstant() : Context->getUndef(Inst->getType());
+ ? IV.getConstant() : UndefValue::get(Inst->getType());
DEBUG(errs() << " Constant: " << *Const << " = " << *Inst);
// Replaces all of the uses of a variable with uses of the
@@ -1847,7 +1847,7 @@ bool IPSCCP::runOnModule(Module &M) {
for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB)
if (ReturnInst *RI = dyn_cast<ReturnInst>(BB->getTerminator()))
if (!isa<UndefValue>(RI->getOperand(0)))
- RI->setOperand(0, Context->getUndef(F->getReturnType()));
+ RI->setOperand(0, UndefValue::get(F->getReturnType()));
}
// If we infered constant or undef values for globals variables, we can delete
diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp
index 7eec908ac5..7877db4e4f 100644
--- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp
+++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp
@@ -371,7 +371,7 @@ void SROA::DoScalarReplacement(AllocationInst *AI,
// %insert = insertvalue { i32, i32 } %insert.0, i32 %load.1, 1
// (Also works for arrays instead of structs)
if (LoadInst *LI = dyn_cast<LoadInst>(User)) {
- Value *Insert = Context.getUndef(LI->getType());
+ Value *Insert = UndefValue::get(LI->getType());
for (unsigned i = 0, e = ElementAllocas.size(); i != e; ++i) {
Value *Load = new LoadInst(ElementAllocas[i], "load", LI);
Insert = InsertValueInst::Create(Insert, Load, i, "insert", LI);
@@ -1540,8 +1540,6 @@ Value *SROA::ConvertScalar_ExtractValue(Value *FromVal, const Type *ToType,
if (FromVal->getType() == ToType && Offset == 0)
return FromVal;
- LLVMContext &Context = FromVal->getContext();
-
// If the result alloca is a vector type, this is either an element
// access or a bitcast to another vector type of the same size.
if (const VectorType *VTy = dyn_cast<VectorType>(FromVal->getType())) {
@@ -1568,7 +1566,7 @@ Value *SROA::ConvertScalar_ExtractValue(Value *FromVal, const Type *ToType,
// use insertvalue's to form the FCA.
if (const StructType *ST = dyn_cast<StructType>(ToType)) {
const StructLayout &Layout = *TD->getStructLayout(ST);
- Value *Res = Context.getUndef(ST);
+ Value *Res = UndefValue::get(ST);
for (unsigned i = 0, e = ST->getNumElements(); i != e; ++i) {
Value *Elt = ConvertScalar_ExtractValue(FromVal, ST->getElementType(i),
Offset+Layout.getElementOffsetInBits(i),
@@ -1580,7 +1578,7 @@ Value *SROA::ConvertScalar_ExtractValue(Value *FromVal, const Type *ToType,
if (const ArrayType *AT = dyn_cast<ArrayType>(ToType)) {
uint64_t EltSize = TD->getTypeAllocSizeInBits(AT->getElementType());
- Value *Res = Context.getUndef(AT);
+ Value *Res = UndefValue::get(AT);
for (unsigned i = 0, e = AT->getNumElements(); i != e; ++i) {
Value *Elt = ConvertScalar_ExtractValue(FromVal, AT->getElementType(),
Offset+i*EltSize, Builder);
diff --git a/lib/Transforms/Scalar/SimplifyCFGPass.cpp b/lib/Transforms/Scalar/SimplifyCFGPass.cpp
index 3596ed6b14..3ea6ddd67c 100644
--- a/lib/Transforms/Scalar/SimplifyCFGPass.cpp
+++ b/lib/Transforms/Scalar/SimplifyCFGPass.cpp
@@ -71,7 +71,7 @@ static void ChangeToUnreachable(Instruction *I, LLVMContext &Context) {
BasicBlock::iterator BBI = I, BBE = BB->end();
while (BBI != BBE) {
if (!BBI->use_empty())
- BBI->replaceAllUsesWith(Context.getUndef(BBI->getType()));
+ BBI->replaceAllUsesWith(UndefValue::get(BBI->getType()));
BB->getInstList().erase(BBI++);
}
}
diff --git a/lib/Transforms/Utils/BasicBlockUtils.cpp b/lib/Transforms/Utils/BasicBlockUtils.cpp
index 5f6edcf336..e6522749bc 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 7b8a8a498b..2b2fcb1052 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 43b996af3f..d6382af379 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 1b72849528..84fcc643bf 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 e9be0e263b..18ce81d143 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 045b428df9..69a208405d 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 5645110db6..3cfaed6a66 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 b0643d6096..0f9493dac2 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,