diff options
Diffstat (limited to 'lib')
43 files changed, 331 insertions, 376 deletions
diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index 2badd266c2..a89505549f 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -308,8 +308,6 @@ BasicAliasAnalysis::getModRefInfo(CallSite CS1, CallSite CS2) { AliasAnalysis::AliasResult BasicAliasAnalysis::alias(const Value *V1, unsigned V1Size, const Value *V2, unsigned V2Size) { - LLVMContext &Context = V1->getType()->getContext(); - // Strip off any constant expression casts if they exist if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(V1)) if (CE->isCast() && isa<PointerType>(CE->getOperand(0)->getType())) @@ -394,13 +392,13 @@ BasicAliasAnalysis::alias(const Value *V1, unsigned V1Size, // the base pointers. while (isGEP(GEP1->getOperand(0)) && GEP1->getOperand(1) == - Context.getNullValue(GEP1->getOperand(1)->getType())) + Constant::getNullValue(GEP1->getOperand(1)->getType())) GEP1 = cast<User>(GEP1->getOperand(0)); const Value *BasePtr1 = GEP1->getOperand(0); while (isGEP(GEP2->getOperand(0)) && GEP2->getOperand(1) == - Context.getNullValue(GEP2->getOperand(1)->getType())) + Constant::getNullValue(GEP2->getOperand(1)->getType())) GEP2 = cast<User>(GEP2->getOperand(0)); const Value *BasePtr2 = GEP2->getOperand(0); @@ -480,7 +478,7 @@ BasicAliasAnalysis::alias(const Value *V1, unsigned V1Size, for (unsigned i = 0; i != GEPOperands.size(); ++i) if (!isa<ConstantInt>(GEPOperands[i])) GEPOperands[i] = - Context.getNullValue(GEPOperands[i]->getType()); + Constant::getNullValue(GEPOperands[i]->getType()); int64_t Offset = TD->getIndexedOffset(BasePtr->getType(), &GEPOperands[0], @@ -696,7 +694,7 @@ BasicAliasAnalysis::CheckGEPInstructions( // TargetData::getIndexedOffset. for (i = 0; i != MaxOperands; ++i) if (!isa<ConstantInt>(GEP1Ops[i])) - GEP1Ops[i] = Context.getNullValue(GEP1Ops[i]->getType()); + GEP1Ops[i] = Constant::getNullValue(GEP1Ops[i]->getType()); // Okay, now get the offset. This is the relative offset for the full // instruction. int64_t Offset1 = TD->getIndexedOffset(GEPPointerTy, GEP1Ops, @@ -740,7 +738,7 @@ BasicAliasAnalysis::CheckGEPInstructions( const Type *ZeroIdxTy = GEPPointerTy; for (unsigned i = 0; i != FirstConstantOper; ++i) { if (!isa<StructType>(ZeroIdxTy)) - GEP1Ops[i] = GEP2Ops[i] = Context.getNullValue(Type::Int32Ty); + GEP1Ops[i] = GEP2Ops[i] = Constant::getNullValue(Type::Int32Ty); if (const CompositeType *CT = dyn_cast<CompositeType>(ZeroIdxTy)) ZeroIdxTy = CT->getTypeAtIndex(GEP1Ops[i]); @@ -755,7 +753,7 @@ BasicAliasAnalysis::CheckGEPInstructions( // If they are equal, use a zero index... if (Op1 == Op2 && BasePtr1Ty == BasePtr2Ty) { if (!isa<ConstantInt>(Op1)) - GEP1Ops[i] = GEP2Ops[i] = Context.getNullValue(Op1->getType()); + GEP1Ops[i] = GEP2Ops[i] = Constant::getNullValue(Op1->getType()); // Otherwise, just keep the constants we have. } else { if (Op1) { @@ -800,7 +798,7 @@ BasicAliasAnalysis::CheckGEPInstructions( return MayAlias; // Be conservative with out-of-range accesses } } else { // Conservatively assume the minimum value for this index - GEP2Ops[i] = Context.getNullValue(Op2->getType()); + GEP2Ops[i] = Constant::getNullValue(Op2->getType()); } } } diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp index 12ef0174e4..57e781615a 100644 --- a/lib/Analysis/ConstantFolding.cpp +++ b/lib/Analysis/ConstantFolding.cpp @@ -215,7 +215,7 @@ static Constant *FoldBitCast(Constant *C, const Type *DestTy, SmallVector<Constant*, 32> Result; if (NumDstElt < NumSrcElt) { // Handle: bitcast (<4 x i32> <i32 0, i32 1, i32 2, i32 3> to <2 x i64>) - Constant *Zero = Context.getNullValue(DstEltTy); + Constant *Zero = Constant::getNullValue(DstEltTy); unsigned Ratio = NumSrcElt/NumDstElt; unsigned SrcBitSize = SrcEltTy->getPrimitiveSizeInBits(); unsigned SrcElt = 0; @@ -419,7 +419,7 @@ Constant *llvm::ConstantFoldInstOperands(unsigned Opcode, const Type *DestTy, if (ElemIdx.ult(APInt(ElemIdx.getBitWidth(), AT->getNumElements()))) { Constant *Index[] = { - Context.getNullValue(CE->getType()), + Constant::getNullValue(CE->getType()), ConstantInt::get(Context, ElemIdx) }; return @@ -486,7 +486,7 @@ Constant *llvm::ConstantFoldCompareInstOperands(unsigned Predicate, // proper extension or truncation. Constant *C = ConstantExpr::getIntegerCast(CE0->getOperand(0), IntPtrTy, false); - Constant *NewOps[] = { C, Context.getNullValue(C->getType()) }; + Constant *NewOps[] = { C, Constant::getNullValue(C->getType()) }; return ConstantFoldCompareInstOperands(Predicate, NewOps, 2, Context, TD); } @@ -496,7 +496,7 @@ Constant *llvm::ConstantFoldCompareInstOperands(unsigned Predicate, if (CE0->getOpcode() == Instruction::PtrToInt && CE0->getType() == IntPtrTy) { Constant *C = CE0->getOperand(0); - Constant *NewOps[] = { C, Context.getNullValue(C->getType()) }; + Constant *NewOps[] = { C, Constant::getNullValue(C->getType()) }; // FIXME! return ConstantFoldCompareInstOperands(Predicate, NewOps, 2, Context, TD); @@ -543,7 +543,7 @@ Constant *llvm::ConstantFoldCompareInstOperands(unsigned Predicate, Constant *llvm::ConstantFoldLoadThroughGEPConstantExpr(Constant *C, ConstantExpr *CE, LLVMContext &Context) { - if (CE->getOperand(1) != Context.getNullValue(CE->getOperand(1)->getType())) + if (CE->getOperand(1) != Constant::getNullValue(CE->getOperand(1)->getType())) return 0; // Do not allow stepping over the value! // Loop over all of the operands, tracking down which value we are @@ -558,7 +558,7 @@ Constant *llvm::ConstantFoldLoadThroughGEPConstantExpr(Constant *C, if (ConstantStruct *CS = dyn_cast<ConstantStruct>(C)) { C = CS->getOperand(El); } else if (isa<ConstantAggregateZero>(C)) { - C = Context.getNullValue(STy->getElementType(El)); + C = Constant::getNullValue(STy->getElementType(El)); } else if (isa<UndefValue>(C)) { C = UndefValue::get(STy->getElementType(El)); } else { @@ -571,7 +571,7 @@ Constant *llvm::ConstantFoldLoadThroughGEPConstantExpr(Constant *C, if (ConstantArray *CA = dyn_cast<ConstantArray>(C)) C = CA->getOperand(CI->getZExtValue()); else if (isa<ConstantAggregateZero>(C)) - C = Context.getNullValue(ATy->getElementType()); + C = Constant::getNullValue(ATy->getElementType()); else if (isa<UndefValue>(C)) C = UndefValue::get(ATy->getElementType()); else @@ -582,7 +582,7 @@ Constant *llvm::ConstantFoldLoadThroughGEPConstantExpr(Constant *C, if (ConstantVector *CP = dyn_cast<ConstantVector>(C)) C = CP->getOperand(CI->getZExtValue()); else if (isa<ConstantAggregateZero>(C)) - C = Context.getNullValue(PTy->getElementType()); + C = Constant::getNullValue(PTy->getElementType()); else if (isa<UndefValue>(C)) C = UndefValue::get(PTy->getElementType()); else @@ -741,7 +741,7 @@ llvm::ConstantFoldCall(Function *F, if (V >= -0.0) return ConstantFoldFP(sqrt, V, Ty, Context); else // Undefined - return Context.getNullValue(Ty); + return Constant::getNullValue(Ty); } break; case 's': diff --git a/lib/Analysis/DebugInfo.cpp b/lib/Analysis/DebugInfo.cpp index 5ecfdcdd44..1e2913477d 100644 --- a/lib/Analysis/DebugInfo.cpp +++ b/lib/Analysis/DebugInfo.cpp @@ -476,7 +476,7 @@ DIFactory::DIFactory(Module &m) /// getCastToEmpty - Return this descriptor as a Constant* with type '{}*'. /// This is only valid when the descriptor is non-null. Constant *DIFactory::getCastToEmpty(DIDescriptor D) { - if (D.isNull()) return VMContext.getNullValue(EmptyStructPtr); + if (D.isNull()) return llvm::Constant::getNullValue(EmptyStructPtr); return ConstantExpr::getBitCast(D.getGV(), EmptyStructPtr); } @@ -576,7 +576,7 @@ DICompileUnit DIFactory::CreateCompileUnit(unsigned LangID, unsigned RunTimeVer) { Constant *Elts[] = { GetTagConstant(dwarf::DW_TAG_compile_unit), - VMContext.getNullValue(EmptyStructPtr), + llvm::Constant::getNullValue(EmptyStructPtr), ConstantInt::get(Type::Int32Ty, LangID), GetStringConstant(Filename), GetStringConstant(Directory), @@ -737,7 +737,7 @@ DISubprogram DIFactory::CreateSubprogram(DIDescriptor Context, Constant *Elts[] = { GetTagConstant(dwarf::DW_TAG_subprogram), - VMContext.getNullValue(EmptyStructPtr), + llvm::Constant::getNullValue(EmptyStructPtr), getCastToEmpty(Context), GetStringConstant(Name), GetStringConstant(DisplayName), @@ -769,7 +769,7 @@ DIFactory::CreateGlobalVariable(DIDescriptor Context, const std::string &Name, bool isDefinition, llvm::GlobalVariable *Val) { Constant *Elts[] = { GetTagConstant(dwarf::DW_TAG_variable), - VMContext.getNullValue(EmptyStructPtr), + llvm::Constant::getNullValue(EmptyStructPtr), getCastToEmpty(Context), GetStringConstant(Name), GetStringConstant(DisplayName), diff --git a/lib/Analysis/IPA/Andersens.cpp b/lib/Analysis/IPA/Andersens.cpp index 84cde63f95..3c07d24bef 100644 --- a/lib/Analysis/IPA/Andersens.cpp +++ b/lib/Analysis/IPA/Andersens.cpp @@ -693,7 +693,7 @@ void Andersens::getMustAliases(Value *P, std::vector<Value*> &RetVals) { // If the object in the points-to set is the null object, then the null // pointer is a must alias. if (Pointee == &GraphNodes[NullObject]) - RetVals.push_back(P->getContext().getNullValue(P->getType())); + RetVals.push_back(Constant::getNullValue(P->getType())); } } AliasAnalysis::getMustAliases(P, RetVals); diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 8c4d191efb..03f3cd66ae 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -2100,7 +2100,7 @@ const SCEV *ScalarEvolution::getNegativeSCEV(const SCEV *V) { const Type *Ty = V->getType(); Ty = getEffectiveSCEVType(Ty); return getMulExpr(V, - getConstant(cast<ConstantInt>(getContext().getAllOnesValue(Ty)))); + getConstant(cast<ConstantInt>(Constant::getAllOnesValue(Ty)))); } /// getNotSCEV - Return a SCEV corresponding to ~V = -1-V @@ -2112,7 +2112,7 @@ const SCEV *ScalarEvolution::getNotSCEV(const SCEV *V) { const Type *Ty = V->getType(); Ty = getEffectiveSCEVType(Ty); const SCEV *AllOnes = - getConstant(cast<ConstantInt>(getContext().getAllOnesValue(Ty))); + getConstant(cast<ConstantInt>(Constant::getAllOnesValue(Ty))); return getMinusSCEV(AllOnes, V); } @@ -3479,10 +3479,10 @@ GetAddressedElementFromGlobal(LLVMContext &Context, GlobalVariable *GV, } else if (isa<ConstantAggregateZero>(Init)) { if (const StructType *STy = dyn_cast<StructType>(Init->getType())) { assert(Idx < STy->getNumElements() && "Bad struct index!"); - Init = Context.getNullValue(STy->getElementType(Idx)); + Init = Constant::getNullValue(STy->getElementType(Idx)); } else if (const ArrayType *ATy = dyn_cast<ArrayType>(Init->getType())) { if (Idx >= ATy->getNumElements()) return 0; // Bogus program - Init = Context.getNullValue(ATy->getElementType()); + Init = Constant::getNullValue(ATy->getElementType()); } else { llvm_unreachable("Unknown constant aggregate type!"); } diff --git a/lib/Analysis/ScalarEvolutionExpander.cpp b/lib/Analysis/ScalarEvolutionExpander.cpp index b6c30fbc67..40bf0a1a02 100644 --- a/lib/Analysis/ScalarEvolutionExpander.cpp +++ b/lib/Analysis/ScalarEvolutionExpander.cpp @@ -285,7 +285,7 @@ Value *SCEVExpander::expandAddToGEP(const SCEV *const *op_begin, Ops = NewOps; AnyNonZeroIndices |= !ScaledOps.empty(); Value *Scaled = ScaledOps.empty() ? - getContext().getNullValue(Ty) : + Constant::getNullValue(Ty) : expandCodeFor(SE.getAddExpr(ScaledOps), Ty); GepIndices.push_back(Scaled); @@ -401,7 +401,7 @@ Value *SCEVExpander::visitMulExpr(const SCEVMulExpr *S) { // -1 * ... ---> 0 - ... if (FirstOp == 1) - V = InsertBinop(Instruction::Sub, getContext().getNullValue(Ty), V); + V = InsertBinop(Instruction::Sub, Constant::getNullValue(Ty), V); return V; } @@ -523,7 +523,7 @@ Value *SCEVExpander::visitAddRecExpr(const SCEVAddRecExpr *S) { BasicBlock *Preheader = L->getLoopPreheader(); PHINode *PN = PHINode::Create(Ty, "indvar", Header->begin()); InsertedValues.insert(PN); - PN->addIncoming(getContext().getNullValue(Ty), Preheader); + PN->addIncoming(Constant::getNullValue(Ty), Preheader); pred_iterator HPI = pred_begin(Header); assert(HPI != pred_end(Header) && "Loop with zero preds???"); diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp index 70f11f4f72..0ed0bbdc33 100644 --- a/lib/Analysis/ValueTracking.cpp +++ b/lib/Analysis/ValueTracking.cpp @@ -917,7 +917,7 @@ Value *llvm::FindInsertedValue(Value *V, const unsigned *idx_begin, idx_begin, idx_end)); else if (isa<ConstantAggregateZero>(V)) - return Context.getNullValue(ExtractValueInst::getIndexedType(PTy, + return Constant::getNullValue(ExtractValueInst::getIndexedType(PTy, idx_begin, idx_end)); else if (Constant *C = dyn_cast<Constant>(V)) { diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index 16dc32f55d..ac3570216d 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -2211,7 +2211,7 @@ bool LLParser::ConvertGlobalValIDToValue(const Type *Ty, ValID &ID, // FIXME: LabelTy should not be a first-class type. if (!Ty->isFirstClassType() || Ty == Type::LabelTy) return Error(ID.Loc, "invalid type for null constant"); - V = Context.getNullValue(Ty); + V = Constant::getNullValue(Ty); return false; case ValID::t_Constant: if (ID.ConstantVal->getType() != Ty) diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index a58e68f183..40920d87e9 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -898,7 +898,7 @@ bool BitcodeReader::ParseConstants() { CurTy = TypeList[Record[0]]; continue; // Skip the ValueList manipulation. case bitc::CST_CODE_NULL: // NULL - V = Context.getNullValue(CurTy); + V = Constant::getNullValue(CurTy); break; case bitc::CST_CODE_INTEGER: // INTEGER: [intval] if (!isa<IntegerType>(CurTy) || Record.empty()) @@ -993,7 +993,7 @@ bool BitcodeReader::ParseConstants() { std::vector<Constant*> Elts; for (unsigned i = 0; i != Size; ++i) Elts.push_back(ConstantInt::get(EltTy, Record[i])); - Elts.push_back(Context.getNullValue(EltTy)); + Elts.push_back(Constant::getNullValue(EltTy)); V = ConstantArray::get(ATy, Elts); break; } diff --git a/lib/CodeGen/IntrinsicLowering.cpp b/lib/CodeGen/IntrinsicLowering.cpp index 113eea0777..67e4e6f762 100644 --- a/lib/CodeGen/IntrinsicLowering.cpp +++ b/lib/CodeGen/IntrinsicLowering.cpp @@ -346,7 +346,7 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) { } case Intrinsic::sigsetjmp: if (CI->getType() != Type::VoidTy) - CI->replaceAllUsesWith(Context.getNullValue(CI->getType())); + CI->replaceAllUsesWith(Constant::getNullValue(CI->getType())); break; case Intrinsic::longjmp: { @@ -393,7 +393,7 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) { "save" : "restore") << " intrinsic.\n"; Warned = true; if (Callee->getIntrinsicID() == Intrinsic::stacksave) - CI->replaceAllUsesWith(Context.getNullValue(CI->getType())); + CI->replaceAllUsesWith(Constant::getNullValue(CI->getType())); break; } @@ -428,7 +428,7 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) { case Intrinsic::eh_exception: case Intrinsic::eh_selector_i32: case Intrinsic::eh_selector_i64: - CI->replaceAllUsesWith(Context.getNullValue(CI->getType())); + CI->replaceAllUsesWith(Constant::getNullValue(CI->getType())); break; case Intrinsic::eh_typeid_for_i32: diff --git a/lib/CodeGen/SelectionDAG/FastISel.cpp b/lib/CodeGen/SelectionDAG/FastISel.cpp index 01493bbba7..1b38fca93d 100644 --- a/lib/CodeGen/SelectionDAG/FastISel.cpp +++ b/lib/CodeGen/SelectionDAG/FastISel.cpp @@ -92,7 +92,7 @@ unsigned FastISel::getRegForValue(Value *V) { } else if (isa<ConstantPointerNull>(V)) { // Translate this as an integer zero so that it can be // local-CSE'd with actual integer zeros. - Reg = getRegForValue(V->getContext().getNullValue(TD.getIntPtrType())); + Reg = getRegForValue(Constant::getNullValue(TD.getIntPtrType())); } else if (ConstantFP *CF = dyn_cast<ConstantFP>(V)) { Reg = FastEmit_f(VT, VT, ISD::ConstantFP, CF); @@ -481,7 +481,7 @@ bool FastISel::SelectCall(User *I) { UpdateValueMap(I, ResultReg); } else { unsigned ResultReg = - getRegForValue(I->getContext().getNullValue(I->getType())); + getRegForValue(Constant::getNullValue(I->getType())); UpdateValueMap(I, ResultReg); } return true; diff --git a/lib/CodeGen/ShadowStackGC.cpp b/lib/CodeGen/ShadowStackGC.cpp index b412532e33..3aa86d04f8 100644 --- a/lib/CodeGen/ShadowStackGC.cpp +++ b/lib/CodeGen/ShadowStackGC.cpp @@ -294,10 +294,10 @@ bool ShadowStackGC::initializeCustomLowering(Module &M) { // linkage! Head = new GlobalVariable(M, StackEntryPtrTy, false, GlobalValue::LinkOnceAnyLinkage, - M.getContext().getNullValue(StackEntryPtrTy), + Constant::getNullValue(StackEntryPtrTy), "llvm_gc_root_chain"); } else if (Head->hasExternalLinkage() && Head->isDeclaration()) { - Head->setInitializer(M.getContext().getNullValue(StackEntryPtrTy)); + Head->setInitializer(Constant::getNullValue(StackEntryPtrTy)); Head->setLinkage(GlobalValue::LinkOnceAnyLinkage); } diff --git a/lib/CodeGen/UnreachableBlockElim.cpp b/lib/CodeGen/UnreachableBlockElim.cpp index 27b9627e59..c3b213cebe 100644 --- a/lib/CodeGen/UnreachableBlockElim.cpp +++ b/lib/CodeGen/UnreachableBlockElim.cpp @@ -68,7 +68,7 @@ bool UnreachableBlockElim::runOnFunction(Function &F) { BasicBlock *BB = I; DeadBlocks.push_back(BB); while (PHINode *PN = dyn_cast<PHINode>(BB->begin())) { - PN->replaceAllUsesWith(F.getContext().getNullValue(PN->getType())); + PN->replaceAllUsesWith(Constant::getNullValue(PN->getType())); BB->getInstList().pop_front(); } for (succ_iterator SI = succ_begin(BB), E = succ_end(BB); SI != E; ++SI) diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index 4d9b061c08..ccab2de7eb 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -1108,8 +1108,6 @@ static bool LinkAppendingVars(Module *M, std::string *ErrorMsg) { if (AppendingVars.empty()) return false; // Nothing to do. - LLVMContext &Context = M->getContext(); - // Loop over the multimap of appending vars, processing any variables with the // same name, forming a new appending global variable with both of the // initializers merged together, then rewrite references to the old variables @@ -1169,7 +1167,7 @@ static bool LinkAppendingVars(Module *M, Inits.push_back(I->getOperand(i)); } else { assert(isa<ConstantAggregateZero>(G1->getInitializer())); - Constant *CV = Context.getNullValue(T1->getElementType()); + Constant *CV = Constant::getNullValue(T1->getElementType()); for (unsigned i = 0, e = T1->getNumElements(); i != e; ++i) Inits.push_back(CV); } @@ -1178,7 +1176,7 @@ static bool LinkAppendingVars(Module *M, Inits.push_back(I->getOperand(i)); } else { assert(isa<ConstantAggregateZero>(G2->getInitializer())); - Constant *CV = Context.getNullValue(T2->getElementType()); + Constant *CV = Constant::getNullValue(T2->getElementType()); for (unsigned i = 0, e = T2->getNumElements(); i != e; ++i) Inits.push_back(CV); } diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index d110684c47..6e71d3bd60 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -1236,7 +1236,7 @@ void CWriter::printConstant(Constant *CPV, bool Static) { Out << '{'; if (AT->getNumElements()) { Out << ' '; - Constant *CZ = CPV->getContext().getNullValue(AT->getElementType()); + Constant *CZ = Constant::getNullValue(AT->getElementType()); printConstant(CZ, Static); for (unsigned i = 1, e = AT->getNumElements(); i != e; ++i) { Out << ", "; @@ -1261,7 +1261,7 @@ void CWriter::printConstant(Constant *CPV, bool Static) { assert(isa<ConstantAggregateZero>(CPV) || isa<UndefValue>(CPV)); const VectorType *VT = cast<VectorType>(CPV->getType()); Out << "{ "; - Constant *CZ = CPV->getContext().getNullValue(VT->getElementType()); + Constant *CZ = Constant::getNullValue(VT->getElementType()); printConstant(CZ, Static); for (unsigned i = 1, e = VT->getNumElements(); i != e; ++i) { Out << ", "; @@ -1283,12 +1283,10 @@ void CWriter::printConstant(Constant *CPV, bool Static) { Out << '{'; if (ST->getNumElements()) { Out << ' '; - printConstant( - CPV->getContext().getNullValue(ST->getElementType(0)), Static); + printConstant(Constant::getNullValue(ST->getElementType(0)), Static); for (unsigned i = 1, e = ST->getNumElements(); i != e; ++i) { Out << ", "; - printConstant( - CPV->getContext().getNullValue(ST->getElementType(i)), Static); + printConstant(Constant::getNullValue(ST->getElementType(i)), Static); } } Out << " }"; diff --git a/lib/Target/X86/X86FastISel.cpp b/lib/Target/X86/X86FastISel.cpp index a01f2d09e2..de519e4fec 100644 --- a/lib/Target/X86/X86FastISel.cpp +++ b/lib/Target/X86/X86FastISel.cpp @@ -272,7 +272,7 @@ bool X86FastISel::X86FastEmitStore(MVT VT, Value *Val, const X86AddressMode &AM) { // Handle 'null' like i32/i64 0. if (isa<ConstantPointerNull>(Val)) - Val = Val->getContext().getNullValue(TD.getIntPtrType()); + Val = Constant::getNullValue(TD.getIntPtrType()); // If this is a store of a simple constant, fold the constant into the store. if (ConstantInt *CI = dyn_cast<ConstantInt>(Val)) { @@ -672,7 +672,7 @@ bool X86FastISel::X86FastEmitCompare(Value *Op0, Value *Op1, MVT VT) { // Handle 'null' like i32/i64 0. if (isa<ConstantPointerNull>(Op1)) - Op1 = Op0->getContext().getNullValue(TD.getIntPtrType()); + Op1 = Constant::getNullValue(TD.getIntPtrType()); // We have two options: compare with register or immediate. If the RHS of // the compare is an immediate that we can fold into this compare, use diff --git a/lib/Target/X86/X86InstrInfo.cpp b/lib/Target/X86/X86InstrInfo.cpp index afdb0f0f77..8ecb766847 100644 --- a/lib/Target/X86/X86InstrInfo.cpp +++ b/lib/Target/X86/X86InstrInfo.cpp @@ -2297,8 +2297,8 @@ MachineInstr* X86InstrInfo::foldMemoryOperandImpl(MachineFunction &MF, MachineConstantPool &MCP = *MF.getConstantPool(); const VectorType *Ty = VectorType::get(Type::Int32Ty, 4); Constant *C = LoadMI->getOpcode() == X86::V_SET0 ? - MF.getFunction()->getContext().getNullValue(Ty) : - MF.getFunction()->getContext().getAllOnesValue(Ty); + Constant::getNullValue(Ty) : + Constant::getAllOnesValue(Ty); unsigned CPI = MCP.getConstantPoolIndex(C, 16); // Create operands to load from the constant pool entry. diff --git a/lib/Transforms/ |