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 | 9e9a0d5fc26878e51a58a8b57900fcbf952c2691 (patch) | |
tree | 477eb7b58abe6134ff6accc805279396a77892e8 | |
parent | 124e6eb09d47674a4bac48a522e83e4513a970e5 (diff) |
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
47 files changed, 188 insertions, 236 deletions
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index e8ecfa3bad..dfcc707b5e 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -305,6 +305,8 @@ protected: return User::operator new(s, 0); } public: + static ConstantAggregateZero* get(const Type* Ty); + /// isNullValue - Return true if this is the value that would be returned by /// getNullValue. virtual bool isNullValue() const { return true; } diff --git a/include/llvm/LLVMContext.h b/include/llvm/LLVMContext.h index 00a6581dab..ab2df1b70a 100644 --- a/include/llvm/LLVMContext.h +++ b/include/llvm/LLVMContext.h @@ -60,6 +60,7 @@ class LLVMContext { friend class ConstantStruct; friend class ConstantArray; friend class ConstantVector; + friend class ConstantAggregateZero; public: LLVMContext(); ~LLVMContext(); @@ -72,19 +73,10 @@ public: /// @brief Get the all ones value Constant* getAllOnesValue(const Type* Ty); - // UndefValue accessors - UndefValue* getUndef(const Type* Ty); - // ConstantInt accessors ConstantInt* getTrue(); ConstantInt* getFalse(); - - // ConstantPointerNull accessors - ConstantPointerNull* getConstantPointerNull(const PointerType* T); - - // ConstantAggregateZero accessors - ConstantAggregateZero* getConstantAggregateZero(const Type* Ty); - + // MDNode accessors MDNode* getMDNode(Value* const* Vals, unsigned NumVals); @@ -95,7 +87,6 @@ public: // Methods for erasing constants void erase(MDString *M); void erase(MDNode *M); - void erase(ConstantAggregateZero *Z); }; /// FOR BACKWARDS COMPATIBILITY - Returns a global context. diff --git a/include/llvm/Support/IRBuilder.h b/include/llvm/Support/IRBuilder.h index 058a9bbd1e..223fe028e2 100644 --- a/include/llvm/Support/IRBuilder.h +++ b/include/llvm/Support/IRBuilder.h @@ -146,7 +146,7 @@ public: /// ReturnInst *CreateAggregateRet(Value * const* retVals, unsigned N) { const Type *RetType = BB->getParent()->getReturnType(); - Value *V = Context.getUndef(RetType); + Value *V = UndefValue::get(RetType); for (unsigned i = 0; i != N; ++i) V = CreateInsertValue(V, retVals[i], i, "mrv"); return Insert(ReturnInst::Create(V)); diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp index 126f850331..12ef0174e4 100644 --- a/lib/Analysis/ConstantFolding.cpp +++ b/lib/Analysis/ConstantFolding.cpp @@ -286,7 +286,7 @@ Constant *llvm::ConstantFoldInstruction(Instruction *I, LLVMContext &Context, const TargetData *TD) { if (PHINode *PN = dyn_cast<PHINode>(I)) { if (PN->getNumIncomingValues() == 0) - return Context.getUndef(PN->getType()); + return UndefValue::get(PN->getType()); Constant *Result = dyn_cast<Constant>(PN->getIncomingValue(0)); if (Result == 0) return 0; @@ -560,7 +560,7 @@ Constant *llvm::ConstantFoldLoadThroughGEPConstantExpr(Constant *C, } else if (isa<ConstantAggregateZero>(C)) { C = Context.getNullValue(STy->getElementType(El)); } else if (isa<UndefValue>(C)) { - C = Context.getUndef(STy->getElementType(El)); + C = UndefValue::get(STy->getElementType(El)); } else { return 0; } @@ -573,7 +573,7 @@ Constant *llvm::ConstantFoldLoadThroughGEPConstantExpr(Constant *C, else if (isa<ConstantAggregateZero>(C)) C = Context.getNullValue(ATy->getElementType()); else if (isa<UndefValue>(C)) - C = Context.getUndef(ATy->getElementType()); + C = UndefValue::get(ATy->getElementType()); else return 0; } else if (const VectorType *PTy = dyn_cast<VectorType>(*I)) { @@ -584,7 +584,7 @@ Constant *llvm::ConstantFoldLoadThroughGEPConstantExpr(Constant *C, else if (isa<ConstantAggregateZero>(C)) C = Context.getNullValue(PTy->getElementType()); else if (isa<UndefValue>(C)) - C = Context.getUndef(PTy->getElementType()); + C = UndefValue::get(PTy->getElementType()); else return 0; } else { diff --git a/lib/Analysis/DebugInfo.cpp b/lib/Analysis/DebugInfo.cpp index 635b6b9ee8..1899623287 100644 --- a/lib/Analysis/DebugInfo.cpp +++ b/lib/Analysis/DebugInfo.cpp @@ -497,7 +497,7 @@ Constant *DIFactory::GetStringConstant(const std::string &String) { // If empty string then use a i8* null instead. if (String.empty()) - return Slot = VMContext.getConstantPointerNull(DestTy); + return Slot = ConstantPointerNull::get(DestTy); // Construct string as an llvm constant. Constant *ConstStr = ConstantArray::get(String); diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp index fcb81889e0..70f11f4f72 100644 --- a/lib/Analysis/ValueTracking.cpp +++ b/lib/Analysis/ValueTracking.cpp @@ -884,7 +884,7 @@ Value *BuildSubAggregate(Value *From, const unsigned *idx_begin, const Type *IndexedType = ExtractValueInst::getIndexedType(From->getType(), idx_begin, idx_end); - Value *To = Context.getUndef(IndexedType); + Value *To = UndefValue::get(IndexedType); SmallVector<unsigned, 10> Idxs(idx_begin, idx_end); unsigned IdxSkip = Idxs.size(); @@ -913,7 +913,7 @@ Value *llvm::FindInsertedValue(Value *V, const unsigned *idx_begin, const CompositeType *PTy = cast<CompositeType>(V->getType()); if (isa<UndefValue>(V)) - return Context.getUndef(ExtractValueInst::getIndexedType(PTy, + return UndefValue::get(ExtractValueInst::getIndexedType(PTy, idx_begin, idx_end)); else if (isa<ConstantAggregateZero>(V)) diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index 359a733cd9..d8ff4cc462 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -1481,7 +1481,7 @@ LLParser::PerFunctionState::~PerFunctionState() { I = ForwardRefVals.begin(), E = ForwardRefVals.end(); I != E; ++I) if (!isa<BasicBlock>(I->second.first)) { I->second.first->replaceAllUsesWith( - P.getContext().getUndef(I->second.first->getType())); + UndefValue::get(I->second.first->getType())); delete I->second.first; I->second.first = 0; } @@ -1490,7 +1490,7 @@ LLParser::PerFunctionState::~PerFunctionState() { I = ForwardRefValIDs.begin(), E = ForwardRefValIDs.end(); I != E; ++I) if (!isa<BasicBlock>(I->second.first)) { I->second.first->replaceAllUsesWith( - P.getContext().getUndef(I->second.first->getType())); + UndefValue::get(I->second.first->getType())); delete I->second.first; I->second.first = 0; } @@ -2193,19 +2193,19 @@ bool LLParser::ConvertGlobalValIDToValue(const Type *Ty, ValID &ID, case ValID::t_Null: if (!isa<PointerType>(Ty)) return Error(ID.Loc, "null must be a pointer type"); - V = Context.getConstantPointerNull(cast<PointerType>(Ty)); + V = ConstantPointerNull::get(cast<PointerType>(Ty)); return false; case ValID::t_Undef: // FIXME: LabelTy should not be a first-class type. if ((!Ty->isFirstClassType() || Ty == Type::LabelTy) && !isa<OpaqueType>(Ty)) return Error(ID.Loc, "invalid type for undef constant"); - V = Context.getUndef(Ty); + V = UndefValue::get(Ty); return false; case ValID::t_EmptyArray: if (!isa<ArrayType>(Ty) || cast<ArrayType>(Ty)->getNumElements() != 0) return Error(ID.Loc, "invalid empty array initializer"); - V = Context.getUndef(Ty); + V = UndefValue::get(Ty); return false; case ValID::t_Zero: // FIXME: LabelTy should not be a first-class type. @@ -2764,7 +2764,7 @@ bool LLParser::ParseRet(Instruction *&Inst, BasicBlock *BB, RVs.push_back(RV); } - RV = Context.getUndef(PFS.getFunction().getReturnType()); + RV = UndefValue::get(PFS.getFunction().getReturnType()); for (unsigned i = 0, e = RVs.size(); i != e; ++i) { Instruction *I = InsertValueInst::Create(RV, RVs[i], i, "mrv"); BB->getInstList().push_back(I); diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 35fe7b27c5..a58e68f183 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -142,7 +142,7 @@ namespace { } explicit ConstantPlaceHolder(const Type *Ty, LLVMContext& Context) : ConstantExpr(Ty, Instruction::UserOp1, &Op<0>(), 1) { - Op<0>() = Context.getUndef(Type::Int32Ty); + Op<0>() = UndefValue::get(Type::Int32Ty); } /// @brief Methods to support type inquiry through isa, cast, and dyn_cast. @@ -888,7 +888,7 @@ bool BitcodeReader::ParseConstants() { switch (BitCode) { default: // Default behavior: unknown constant case bitc::CST_CODE_UNDEF: // UNDEF - V = Context.getUndef(CurTy); + V = UndefValue::get(CurTy); break; case bitc::CST_CODE_SETTYPE: // SETTYPE: [typeid] if (Record.empty()) @@ -937,7 +937,7 @@ bool BitcodeReader::ParseConstants() { else if (CurTy == Type::PPC_FP128Ty) V = ConstantFP::get(Context, APFloat(APInt(128, 2, &Record[0]))); else - V = Context.getUndef(CurTy); + V = UndefValue::get(CurTy); break; } @@ -964,7 +964,7 @@ bool BitcodeReader::ParseConstants() { Elts.push_back(ValueList.getConstantFwdRef(Record[i], EltTy)); V = ConstantVector::get(Elts); } else { - V = Context.getUndef(CurTy); + V = UndefValue::get(CurTy); } break; } @@ -1001,7 +1001,7 @@ bool BitcodeReader::ParseConstants() { if (Record.size() < 3) return Error("Invalid CE_BINOP record"); int Opc = GetDecodedBinaryOpcode(Record[0], CurTy); if (Opc < 0) { - V = Context.getUndef(CurTy); // Unknown binop. + V = UndefValue::get(CurTy); // Unknown binop. } else { Constant *LHS = ValueList.getConstantFwdRef(Record[1], CurTy); Constant *RHS = ValueList.getConstantFwdRef(Record[2], CurTy); @@ -1015,7 +1015,7 @@ bool BitcodeReader::ParseConstants() { if (Record.size() < 3) return Error("Invalid CE_CAST record"); int Opc = GetDecodedCastOpcode(Record[0]); if (Opc < 0) { - V = Context.getUndef(CurTy); // Unknown cast. + V = UndefValue::get(CurTy); // Unknown cast. } else { const Type *OpTy = getTypeByID(Record[1]); if (!OpTy) return Error("Invalid CE_CAST record"); @@ -1780,7 +1780,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { if (Vs.size() > 1 || (isa<StructType>(ReturnType) && (Vs.empty() || Vs[0]->getType() != ReturnType))) { - Value *RV = Context.getUndef(ReturnType); + Value *RV = UndefValue::get(ReturnType); for (unsigned i = 0, e = Vs.size(); i != e; ++i) { I = InsertValueInst::Create(RV, Vs[i], i, "mrv"); CurBB->getInstList().push_back(I); @@ -2060,7 +2060,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { // We found at least one unresolved value. Nuke them all to avoid leaks. for (unsigned i = ModuleValueListSize, e = ValueList.size(); i != e; ++i){ if ((A = dyn_cast<Argument>(ValueList.back())) && A->getParent() == 0) { - A->replaceAllUsesWith(Context.getUndef(A->getType())); + A->replaceAllUsesWith(UndefValue::get(A->getType())); delete A; } } diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 7293144b4e..189d2556b9 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -1789,7 +1789,6 @@ SDValue SelectionDAGLegalize::ExpandSCALAR_TO_VECTOR(SDNode *Node) { /// ExpandBUILD_VECTOR - Expand a BUILD_VECTOR node on targets that don't /// support the operation, but do support the resultant vector type. SDValue SelectionDAGLegalize::ExpandBUILD_VECTOR(SDNode *Node) { - LLVMContext *Context = DAG.getContext(); unsigned NumElems = Node->getNumOperands(); SDValue Value1, Value2; DebugLoc dl = Node->getDebugLoc(); @@ -1840,7 +1839,7 @@ SDValue SelectionDAGLegalize::ExpandBUILD_VECTOR(SDNode *Node) { } else { assert(Node->getOperand(i).getOpcode() == ISD::UNDEF); const Type *OpNTy = OpVT.getTypeForMVT(); - CV.push_back(Context->getUndef(OpNTy)); + CV.push_back(UndefValue::get(OpNTy)); } } Constant *CP = ConstantVector::get(CV); 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) |