From debcb01b0f0a15f568ca69e8f288fade4bfc7297 Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Wed, 29 Jul 2009 22:17:13 +0000 Subject: [PATCH] Move types back to the 2.5 API. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77516 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/tutorial/LangImpl3.html | 4 +- docs/tutorial/LangImpl4.html | 2 +- docs/tutorial/LangImpl5.html | 2 +- docs/tutorial/LangImpl6.html | 2 +- docs/tutorial/LangImpl7.html | 2 +- examples/BrainF/BrainF.cpp | 6 +- examples/Kaleidoscope/toy.cpp | 3 +- examples/ModuleMaker/ModuleMaker.cpp | 2 +- include/llvm/CodeGen/ValueTypes.h | 2 +- include/llvm/InstrTypes.h | 8 ++ include/llvm/Instructions.h | 13 ++- include/llvm/LLVMContext.h | 34 -------- include/llvm/Support/TypeBuilder.h | 35 ++++---- lib/Analysis/ConstantFolding.cpp | 8 +- lib/Analysis/DebugInfo.cpp | 8 +- lib/Analysis/LoopVR.cpp | 4 +- lib/Analysis/ScalarEvolution.cpp | 2 +- lib/AsmParser/LLLexer.cpp | 2 +- lib/AsmParser/LLParser.cpp | 36 ++++---- lib/Bitcode/Reader/BitcodeReader.cpp | 22 ++--- lib/CodeGen/DwarfEHPrepare.cpp | 3 +- lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 15 ++-- lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 36 ++++---- lib/CodeGen/SelectionDAG/LegalizeTypes.cpp | 4 +- .../SelectionDAG/LegalizeTypesGeneric.cpp | 3 +- .../SelectionDAG/LegalizeVectorTypes.cpp | 3 +- lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 11 ++- .../SelectionDAG/SelectionDAGBuild.cpp | 4 +- lib/CodeGen/ShadowStackGC.cpp | 4 +- lib/ExecutionEngine/JIT/JIT.cpp | 3 +- lib/Linker/LinkModules.cpp | 2 +- lib/Target/CellSPU/SPUISelLowering.cpp | 5 +- lib/Target/PIC16/PIC16ISelLowering.cpp | 4 +- lib/Target/PowerPC/PPCISelLowering.cpp | 2 +- lib/Target/XCore/XCoreISelLowering.cpp | 6 +- lib/Transforms/IPO/ArgumentPromotion.cpp | 2 +- .../IPO/DeadArgumentElimination.cpp | 7 +- lib/Transforms/IPO/ExtractGV.cpp | 4 +- lib/Transforms/IPO/GlobalOpt.cpp | 10 +-- lib/Transforms/IPO/LowerSetJmp.cpp | 11 ++- lib/Transforms/IPO/RaiseAllocations.cpp | 18 ++-- lib/Transforms/IPO/StructRetPromotion.cpp | 3 +- .../Instrumentation/BlockProfiling.cpp | 4 +- .../Instrumentation/EdgeProfiling.cpp | 2 +- .../Instrumentation/ProfilingUtils.cpp | 4 +- .../Scalar/InstructionCombining.cpp | 35 ++++---- lib/Transforms/Scalar/LoopStrengthReduce.cpp | 2 +- lib/Transforms/Scalar/MemCpyOptimizer.cpp | 3 +- .../Scalar/ScalarReplAggregates.cpp | 27 +++--- lib/Transforms/Scalar/SimplifyLibCalls.cpp | 40 ++++----- lib/Transforms/Utils/CloneFunction.cpp | 3 +- lib/Transforms/Utils/CodeExtractor.cpp | 9 +- lib/Transforms/Utils/InlineFunction.cpp | 2 +- lib/Transforms/Utils/LowerAllocations.cpp | 6 +- lib/Transforms/Utils/LowerInvoke.cpp | 12 +-- lib/VMCore/AutoUpgrade.cpp | 6 +- lib/VMCore/ConstantFold.cpp | 6 +- lib/VMCore/Constants.cpp | 2 +- lib/VMCore/Core.cpp | 21 ++--- lib/VMCore/Function.cpp | 2 +- lib/VMCore/Globals.cpp | 4 +- lib/VMCore/Instructions.cpp | 11 ++- lib/VMCore/LLVMContext.cpp | 83 ------------------- lib/VMCore/Module.cpp | 12 +-- lib/VMCore/ValueTypes.cpp | 50 ++++++----- lib/VMCore/Verifier.cpp | 3 +- tools/bugpoint/ExtractFunction.cpp | 3 +- tools/bugpoint/Miscompilation.cpp | 6 +- unittests/ExecutionEngine/JIT/JITTest.cpp | 3 +- unittests/Support/TypeBuilderTest.cpp | 4 +- utils/TableGen/CallingConvEmitter.cpp | 4 +- 71 files changed, 287 insertions(+), 439 deletions(-) diff --git a/docs/tutorial/LangImpl3.html b/docs/tutorial/LangImpl3.html index c56b1edac65..5f1072f6329 100644 --- a/docs/tutorial/LangImpl3.html +++ b/docs/tutorial/LangImpl3.html @@ -308,7 +308,7 @@ bodies and external function declarations. The code starts with:

Function *PrototypeAST::Codegen() { // Make the function type: double(double,double) etc. std::vector<const Type*> Doubles(Args.size(), Type::DoubleTy); - FunctionType *FT = getGlobalContext().getFunctionType(Type::DoubleTy, Doubles, false); + FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false); Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule); @@ -1082,7 +1082,7 @@ Value *CallExprAST::Codegen() { Function *PrototypeAST::Codegen() { // Make the function type: double(double,double) etc. std::vector<const Type*> Doubles(Args.size(), Type::DoubleTy); - FunctionType *FT = getGlobalContext().getFunctionType(Type::DoubleTy, Doubles, false); + FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false); Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule); diff --git a/docs/tutorial/LangImpl4.html b/docs/tutorial/LangImpl4.html index 45002d29ea1..5eb69d33572 100644 --- a/docs/tutorial/LangImpl4.html +++ b/docs/tutorial/LangImpl4.html @@ -917,7 +917,7 @@ Value *CallExprAST::Codegen() { Function *PrototypeAST::Codegen() { // Make the function type: double(double,double) etc. std::vector<const Type*> Doubles(Args.size(), Type::DoubleTy); - FunctionType *FT = getGlobalContext().getFunctionType(Type::DoubleTy, Doubles, false); + FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false); Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule); diff --git a/docs/tutorial/LangImpl5.html b/docs/tutorial/LangImpl5.html index 62a0dd97398..8d77d5ec892 100644 --- a/docs/tutorial/LangImpl5.html +++ b/docs/tutorial/LangImpl5.html @@ -1551,7 +1551,7 @@ Value *ForExprAST::Codegen() { Function *PrototypeAST::Codegen() { // Make the function type: double(double,double) etc. std::vector<const Type*> Doubles(Args.size(), Type::DoubleTy); - FunctionType *FT = getGlobalContext().getFunctionType(Type::DoubleTy, Doubles, false); + FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false); Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule); diff --git a/docs/tutorial/LangImpl6.html b/docs/tutorial/LangImpl6.html index 5a553b7b8a1..0f714b385ad 100644 --- a/docs/tutorial/LangImpl6.html +++ b/docs/tutorial/LangImpl6.html @@ -1576,7 +1576,7 @@ Value *ForExprAST::Codegen() { Function *PrototypeAST::Codegen() { // Make the function type: double(double,double) etc. std::vector<const Type*> Doubles(Args.size(), Type::DoubleTy); - FunctionType *FT = getGlobalContext().getFunctionType(Type::DoubleTy, Doubles, false); + FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false); Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule); diff --git a/docs/tutorial/LangImpl7.html b/docs/tutorial/LangImpl7.html index d3ebd962c5c..844c48fff23 100644 --- a/docs/tutorial/LangImpl7.html +++ b/docs/tutorial/LangImpl7.html @@ -1911,7 +1911,7 @@ Value *VarExprAST::Codegen() { Function *PrototypeAST::Codegen() { // Make the function type: double(double,double) etc. std::vector<const Type*> Doubles(Args.size(), Type::DoubleTy); - FunctionType *FT = getGlobalContext().getFunctionType(Type::DoubleTy, Doubles, false); + FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false); Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule); diff --git a/examples/BrainF/BrainF.cpp b/examples/BrainF/BrainF.cpp index e47365bfa16..e1615569d2b 100644 --- a/examples/BrainF/BrainF.cpp +++ b/examples/BrainF/BrainF.cpp @@ -138,7 +138,7 @@ void BrainF::header(LLVMContext& C) { //declare i32 @puts(i8 *) Function *puts_func = cast(module-> getOrInsertFunction("puts", IntegerType::Int32Ty, - C.getPointerTypeUnqual(IntegerType::Int8Ty), NULL)); + PointerType::getUnqual(IntegerType::Int8Ty), NULL)); //brainf.aberror: aberrorbb = BasicBlock::Create(label, brainf_func); @@ -284,7 +284,7 @@ void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb, // Make part of PHI instruction now, wait until end of loop to finish PHINode *phi_0 = - PHINode::Create(C.getPointerTypeUnqual(IntegerType::Int8Ty), + PHINode::Create(PointerType::getUnqual(IntegerType::Int8Ty), headreg, testbb); phi_0->reserveOperandSpace(2); phi_0->addIncoming(curhead, bb_0); @@ -440,7 +440,7 @@ void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb, //%head.%d = phi i8 *[%head.%d, %main.%d] PHINode *phi_1 = builder-> - CreatePHI(C.getPointerTypeUnqual(IntegerType::Int8Ty), headreg); + CreatePHI(PointerType::getUnqual(IntegerType::Int8Ty), headreg); phi_1->reserveOperandSpace(1); phi_1->addIncoming(head_0, testbb); curhead = phi_1; diff --git a/examples/Kaleidoscope/toy.cpp b/examples/Kaleidoscope/toy.cpp index 6f7f0ee206f..004c7b7c061 100644 --- a/examples/Kaleidoscope/toy.cpp +++ b/examples/Kaleidoscope/toy.cpp @@ -909,8 +909,7 @@ Value *VarExprAST::Codegen() { Function *PrototypeAST::Codegen() { // Make the function type: double(double,double) etc. std::vector Doubles(Args.size(), Type::DoubleTy); - FunctionType *FT = - getGlobalContext().getFunctionType(Type::DoubleTy, Doubles, false); + FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false); Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule); diff --git a/examples/ModuleMaker/ModuleMaker.cpp b/examples/ModuleMaker/ModuleMaker.cpp index 1baa8c98efc..fc487af056d 100644 --- a/examples/ModuleMaker/ModuleMaker.cpp +++ b/examples/ModuleMaker/ModuleMaker.cpp @@ -31,7 +31,7 @@ int main() { // Create the main function: first create the type 'int ()' FunctionType *FT = - Context.getFunctionType(Type::Int32Ty, /*not vararg*/false); + FunctionType::get(Type::Int32Ty, /*not vararg*/false); // By passing a module as the last parameter to the Function constructor, // it automatically gets appended to the Module. diff --git a/include/llvm/CodeGen/ValueTypes.h b/include/llvm/CodeGen/ValueTypes.h index 57ca285fac4..5069f9e00a6 100644 --- a/include/llvm/CodeGen/ValueTypes.h +++ b/include/llvm/CodeGen/ValueTypes.h @@ -477,7 +477,7 @@ namespace llvm { /// getTypeForMVT - This method returns an LLVM type corresponding to the /// specified MVT. For integer types, this returns an unsigned type. Note /// that this will abort for types that cannot be represented. - const Type *getTypeForMVT(LLVMContext &Context) const; + const Type *getTypeForMVT() const; /// getMVT - Return the value type corresponding to the specified type. /// This returns all pointers as iPTR. If HandleUnknown is true, unknown diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h index 43fe664003d..ddb6ad377d8 100644 --- a/include/llvm/InstrTypes.h +++ b/include/llvm/InstrTypes.h @@ -667,6 +667,14 @@ public: static inline bool classof(const Value *V) { return isa(V) && classof(cast(V)); } + + /// @brief Create a result type for fcmp/icmp + static const Type* makeCmpResultType(const Type* opnd_type) { + if (const VectorType* vt = dyn_cast(opnd_type)) { + return VectorType::get(Type::Int1Ty, vt->getNumElements()); + } + return Type::Int1Ty; + } }; diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index 2b53fac4656..ad5a4a9d3e4 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -645,7 +645,7 @@ public: Value *LHS, ///< The left-hand-side of the expression Value *RHS, ///< The right-hand-side of the expression const Twine &NameStr = "" ///< Name of the instruction - ) : CmpInst(InsertBefore->getContext().makeCmpResultType(LHS->getType()), + ) : CmpInst(makeCmpResultType(LHS->getType()), Instruction::ICmp, pred, LHS, RHS, NameStr, InsertBefore) { assert(pred >= CmpInst::FIRST_ICMP_PREDICATE && @@ -666,7 +666,7 @@ public: Value *LHS, ///< The left-hand-side of the expression Value *RHS, ///< The right-hand-side of the expression const Twine &NameStr = "" ///< Name of the instruction - ) : CmpInst(InsertAtEnd.getContext().makeCmpResultType(LHS->getType()), + ) : CmpInst(makeCmpResultType(LHS->getType()), Instruction::ICmp, pred, LHS, RHS, NameStr, &InsertAtEnd) { assert(pred >= CmpInst::FIRST_ICMP_PREDICATE && @@ -687,7 +687,7 @@ public: Value *LHS, ///< The left-hand-side of the expression Value *RHS, ///< The right-hand-side of the expression const Twine &NameStr = "" ///< Name of the instruction - ) : CmpInst(Context.makeCmpResultType(LHS->getType()), + ) : CmpInst(makeCmpResultType(LHS->getType()), Instruction::ICmp, pred, LHS, RHS, NameStr) { assert(pred >= CmpInst::FIRST_ICMP_PREDICATE && pred <= CmpInst::LAST_ICMP_PREDICATE && @@ -820,7 +820,7 @@ public: Value *LHS, ///< The left-hand-side of the expression Value *RHS, ///< The right-hand-side of the expression const Twine &NameStr = "" ///< Name of the instruction - ) : CmpInst(InsertBefore->getContext().makeCmpResultType(LHS->getType()), + ) : CmpInst(makeCmpResultType(LHS->getType()), Instruction::FCmp, pred, LHS, RHS, NameStr, InsertBefore) { assert(pred <= FCmpInst::LAST_FCMP_PREDICATE && @@ -839,7 +839,7 @@ public: Value *LHS, ///< The left-hand-side of the expression Value *RHS, ///< The right-hand-side of the expression const Twine &NameStr = "" ///< Name of the instruction - ) : CmpInst(InsertAtEnd.getContext().makeCmpResultType(LHS->getType()), + ) : CmpInst(makeCmpResultType(LHS->getType()), Instruction::FCmp, pred, LHS, RHS, NameStr, &InsertAtEnd) { assert(pred <= FCmpInst::LAST_FCMP_PREDICATE && @@ -858,7 +858,7 @@ public: Value *LHS, ///< The left-hand-side of the expression Value *RHS, ///< The right-hand-side of the expression const Twine &NameStr = "" ///< Name of the instruction - ) : CmpInst(Context.makeCmpResultType(LHS->getType()), + ) : CmpInst(makeCmpResultType(LHS->getType()), Instruction::FCmp, pred, LHS, RHS, NameStr) { assert(pred <= FCmpInst::LAST_FCMP_PREDICATE && "Invalid FCmp predicate value"); @@ -910,7 +910,6 @@ public: static inline bool classof(const Value *V) { return isa(V) && classof(cast(V)); } - }; //===----------------------------------------------------------------------===// diff --git a/include/llvm/LLVMContext.h b/include/llvm/LLVMContext.h index 8c3e2eff963..00a6581dab0 100644 --- a/include/llvm/LLVMContext.h +++ b/include/llvm/LLVMContext.h @@ -91,40 +91,6 @@ public: // MDString accessors MDString* getMDString(const StringRef &Str); - // FunctionType accessors - FunctionType* getFunctionType(const Type* Result, bool isVarArg); - FunctionType* getFunctionType(const Type* Result, - const std::vector& Params, - bool isVarArg); - - // IntegerType accessors - const IntegerType* getIntegerType(unsigned NumBits); - - // OpaqueType accessors - OpaqueType* getOpaqueType(); - - // StructType accessors - StructType* getStructType(bool isPacked=false); - StructType* getStructType(const std::vector& Params, - bool isPacked = false); - StructType* getStructType(const Type* type, ...); - - // ArrayType accessors - ArrayType* getArrayType(const Type* ElementType, uint64_t NumElements); - - // PointerType accessors - PointerType* getPointerType(const Type* ElementType, unsigned AddressSpace); - PointerType* getPointerTypeUnqual(const Type* ElementType); - - // VectorType accessors - VectorType* getVectorType(const Type* ElementType, unsigned NumElements); - VectorType* getVectorTypeInteger(const VectorType* VTy); - VectorType* getVectorTypeExtendedElement(const VectorType* VTy); - VectorType* getVectorTypeTruncatedElement(const VectorType* VTy); - - // Other helpers - /// @brief Create a result type for fcmp/icmp - const Type* makeCmpResultType(const Type* opnd_type); // Methods for erasing constants void erase(MDString *M); diff --git a/include/llvm/Support/TypeBuilder.h b/include/llvm/Support/TypeBuilder.h index 5ea7f9ebcf3..1f85f1d1258 100644 --- a/include/llvm/Support/TypeBuilder.h +++ b/include/llvm/Support/TypeBuilder.h @@ -107,7 +107,7 @@ template class TypeBuilder { public: static const PointerType *get(LLVMContext &Context) { static const PointerType *const result = - Context.getPointerTypeUnqual(TypeBuilder::get(Context)); + PointerType::getUnqual(TypeBuilder::get(Context)); return result; } }; @@ -120,7 +120,7 @@ template class TypeBuilder { public: static const ArrayType *get(LLVMContext &Context) { static const ArrayType *const result = - Context.getArrayType(TypeBuilder::get(Context), N); + ArrayType::get(TypeBuilder::get(Context), N); return result; } }; @@ -129,7 +129,7 @@ template class TypeBuilder { public: static const ArrayType *get(LLVMContext &Context) { static const ArrayType *const result = - Context.getArrayType(TypeBuilder::get(Context), 0); + ArrayType::get(TypeBuilder::get(Context), 0); return result; } }; @@ -161,7 +161,7 @@ template<> class TypeBuilder { \ public: \ static const IntegerType *get(LLVMContext &Context) { \ static const IntegerType *const result = \ - Context.getIntegerType(sizeof(T) * CHAR_BIT); \ + IntegerType::get(sizeof(T) * CHAR_BIT); \ return result; \ } \ }; \ @@ -191,7 +191,7 @@ template class TypeBuilder, cross> { public: static const IntegerType *get(LLVMContext &Context) { - static const IntegerType *const result = Context.getIntegerType(num_bits); + static const IntegerType *const result = IntegerType::get(num_bits); return result; } }; @@ -254,7 +254,7 @@ public: private: static const FunctionType *create(LLVMContext &Context) { - return Context.getFunctionType(TypeBuilder::get(Context), false); + return FunctionType::get(TypeBuilder::get(Context), false); } }; template class TypeBuilder { @@ -269,7 +269,7 @@ private: std::vector params; params.reserve(1); params.push_back(TypeBuilder::get(Context)); - return Context.getFunctionType(TypeBuilder::get(Context), + return FunctionType::get(TypeBuilder::get(Context), params, false); } }; @@ -287,7 +287,7 @@ private: params.reserve(2); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); - return Context.getFunctionType(TypeBuilder::get(Context), + return FunctionType::get(TypeBuilder::get(Context), params, false); } }; @@ -306,7 +306,7 @@ private: params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); - return Context.getFunctionType(TypeBuilder::get(Context), + return FunctionType::get(TypeBuilder::get(Context), params, false); } }; @@ -328,7 +328,7 @@ private: params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); - return Context.getFunctionType(TypeBuilder::get(Context), + return FunctionType::get(TypeBuilder::get(Context), params, false); } }; @@ -351,7 +351,7 @@ private: params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); - return Context.getFunctionType(TypeBuilder::get(Context), + return FunctionType::get(TypeBuilder::get(Context), params, false); } }; @@ -365,7 +365,7 @@ public: private: static const FunctionType *create(LLVMContext &Context) { - return Context.getFunctionType(TypeBuilder::get(Context), true); + return FunctionType::get(TypeBuilder::get(Context), true); } }; template @@ -381,8 +381,7 @@ private: std::vector params; params.reserve(1); params.push_back(TypeBuilder::get(Context)); - return Context.getFunctionType(TypeBuilder::get(Context), - params, true); + return FunctionType::get(TypeBuilder::get(Context), params, true); } }; template @@ -399,7 +398,7 @@ private: params.reserve(2); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); - return Context.getFunctionType(TypeBuilder::get(Context), + return FunctionType::get(TypeBuilder::get(Context), params, true); } }; @@ -418,7 +417,7 @@ private: params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); - return Context.getFunctionType(TypeBuilder::get(Context), + return FunctionType::get(TypeBuilder::get(Context), params, true); } }; @@ -440,7 +439,7 @@ private: params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); - return Context.getFunctionType(TypeBuilder::get(Context), + return FunctionType::get(TypeBuilder::get(Context), params, true); } }; @@ -463,7 +462,7 @@ private: params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); - return Context.getFunctionType(TypeBuilder::get(Context), + return FunctionType::get(TypeBuilder::get(Context), params, true); } }; diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp index 1f034e9862d..126f8503310 100644 --- a/lib/Analysis/ConstantFolding.cpp +++ b/lib/Analysis/ConstantFolding.cpp @@ -184,8 +184,8 @@ static Constant *FoldBitCast(Constant *C, const Type *DestTy, if (DstEltTy->isFloatingPoint()) { // Fold to an vector of integers with same size as our FP type. unsigned FPWidth = DstEltTy->getPrimitiveSizeInBits(); - const Type *DestIVTy = Context.getVectorType( - Context.getIntegerType(FPWidth), NumDstElt); + const Type *DestIVTy = VectorType::get( + IntegerType::get(FPWidth), NumDstElt); // Recursively handle this integer conversion, if possible. C = FoldBitCast(C, DestIVTy, TD, Context); if (!C) return 0; @@ -198,8 +198,8 @@ static Constant *FoldBitCast(Constant *C, const Type *DestTy, // it to integer first. if (SrcEltTy->isFloatingPoint()) { unsigned FPWidth = SrcEltTy->getPrimitiveSizeInBits(); - const Type *SrcIVTy = Context.getVectorType( - Context.getIntegerType(FPWidth), NumSrcElt); + const Type *SrcIVTy = VectorType::get( + IntegerType::get(FPWidth), NumSrcElt); // Ask VMCore to do the conversion now that #elts line up. C = ConstantExpr::getBitCast(C, SrcIVTy); CV = dyn_cast(C); diff --git a/lib/Analysis/DebugInfo.cpp b/lib/Analysis/DebugInfo.cpp index 3db7ff964c2..7ff1de6351b 100644 --- a/lib/Analysis/DebugInfo.cpp +++ b/lib/Analysis/DebugInfo.cpp @@ -470,7 +470,7 @@ DIFactory::DIFactory(Module &m) : M(m), VMContext(M.getContext()), StopPointFn(0), FuncStartFn(0), RegionStartFn(0), RegionEndFn(0), DeclareFn(0) { - EmptyStructPtr = VMContext.getPointerTypeUnqual(VMContext.getStructType()); + EmptyStructPtr = PointerType::getUnqual(StructType::get()); } /// getCastToEmpty - Return this descriptor as a Constant* with type '{}*'. @@ -493,7 +493,7 @@ Constant *DIFactory::GetStringConstant(const std::string &String) { // Return Constant if previously defined. if (Slot) return Slot; - const PointerType *DestTy = VMContext.getPointerTypeUnqual(Type::Int8Ty); + const PointerType *DestTy = PointerType::getUnqual(Type::Int8Ty); // If empty string then use a i8* null instead. if (String.empty()) @@ -522,7 +522,7 @@ DIArray DIFactory::GetOrCreateArray(DIDescriptor *Tys, unsigned NumTys) { for (unsigned i = 0; i != NumTys; ++i) Elts.push_back(getCastToEmpty(Tys[i])); - Constant *Init = ConstantArray::get(VMContext.getArrayType(EmptyStructPtr, + Constant *Init = ConstantArray::get(ArrayType::get(EmptyStructPtr, Elts.size()), Elts.data(), Elts.size()); // If we already have this array, just return the uniqued version. @@ -1075,7 +1075,7 @@ namespace llvm { const Type *Ty = M->getTypeByName("llvm.dbg.global_variable.type"); if (!Ty) return 0; - Ty = Context.getPointerType(Ty, 0); + Ty = PointerType::get(Ty, 0); Value *Val = V->stripPointerCasts(); for (Value::use_iterator I = Val->use_begin(), E = Val->use_end(); diff --git a/lib/Analysis/LoopVR.cpp b/lib/Analysis/LoopVR.cpp index ccd5400df8d..8ffac633d03 100644 --- a/lib/Analysis/LoopVR.cpp +++ b/lib/Analysis/LoopVR.cpp @@ -75,8 +75,8 @@ ConstantRange LoopVR::getRange(const SCEV *S, const SCEV *T, ScalarEvolution &SE ConstantRange X = getRange(Mul->getOperand(0), T, SE); if (X.isFullSet()) return FullSet; - const IntegerType *Ty = Context.getIntegerType(X.getBitWidth()); - const IntegerType *ExTy = Context.getIntegerType(X.getBitWidth() * + const IntegerType *Ty = IntegerType::get(X.getBitWidth()); + const IntegerType *ExTy = IntegerType::get(X.getBitWidth() * Mul->getNumOperands()); ConstantRange XExt = X.zeroExtend(ExTy->getBitWidth()); diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 3bf5e70cc1b..8c4d191efbc 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -4670,7 +4670,7 @@ const SCEV *ScalarEvolution::getBECount(const SCEV *Start, // Check Add for unsigned overflow. // TODO: More sophisticated things could be done here. - const Type *WideTy = getContext().getIntegerType(getTypeSizeInBits(Ty) + 1); + const Type *WideTy = IntegerType::get(getTypeSizeInBits(Ty) + 1); const SCEV *EDiff = getZeroExtendExpr(Diff, WideTy); const SCEV *ERoundUp = getZeroExtendExpr(RoundUp, WideTy); const SCEV *OperandExtendedAdd = getAddExpr(EDiff, ERoundUp); diff --git a/lib/AsmParser/LLLexer.cpp b/lib/AsmParser/LLLexer.cpp index 4a7e1230938..a6e63448b2e 100644 --- a/lib/AsmParser/LLLexer.cpp +++ b/lib/AsmParser/LLLexer.cpp @@ -471,7 +471,7 @@ lltok::Kind LLLexer::LexIdentifier() { Error("bitwidth for integer type out of range!"); return lltok::Error; } - TyVal = Context.getIntegerType(NumBits); + TyVal = IntegerType::get(NumBits); return lltok::Type; } diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index 8b3b832cb69..359a733cd91 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -1104,7 +1104,7 @@ bool LLParser::ParseTypeRec(PATypeHolder &Result) { break; case lltok::kw_opaque: // TypeRec ::= 'opaque' - Result = Context.getOpaqueType(); + Result = OpaqueType::get(); Lex.Lex(); break; case lltok::lbrace: @@ -1134,7 +1134,7 @@ bool LLParser::ParseTypeRec(PATypeHolder &Result) { if (const Type *T = M->getTypeByName(Lex.getStrVal())) { Result = T; } else { - Result = Context.getOpaqueType(); + Result = OpaqueType::get(); ForwardRefTypes.insert(std::make_pair(Lex.getStrVal(), std::make_pair(Result, Lex.getLoc()))); @@ -1153,7 +1153,7 @@ bool LLParser::ParseTypeRec(PATypeHolder &Result) { if (I != ForwardRefTypeIDs.end()) Result = I->second.first; else { - Result = Context.getOpaqueType(); + Result = OpaqueType::get(); ForwardRefTypeIDs.insert(std::make_pair(Lex.getUIntVal(), std::make_pair(Result, Lex.getLoc()))); @@ -1166,7 +1166,7 @@ bool LLParser::ParseTypeRec(PATypeHolder &Result) { Lex.Lex(); unsigned Val; if (ParseUInt32(Val)) return true; - OpaqueType *OT = Context.getOpaqueType(); //Use temporary placeholder. + OpaqueType *OT = OpaqueType::get(); //Use temporary placeholder. UpRefs.push_back(UpRefRecord(Lex.getLoc(), Val, OT)); Result = OT; break; @@ -1187,7 +1187,7 @@ bool LLParser::ParseTypeRec(PATypeHolder &Result) { return TokError("pointers to void are invalid; use i8* instead"); if (!PointerType::isValidElementType(Result.get())) return TokError("pointer to this type is invalid"); - Result = HandleUpRefs(Context.getPointerTypeUnqual(Result.get())); + Result = HandleUpRefs(PointerType::getUnqual(Result.get())); Lex.Lex(); break; @@ -1204,7 +1204,7 @@ bool LLParser::ParseTypeRec(PATypeHolder &Result) { ParseToken(lltok::star, "expected '*' in address space")) return true; - Result = HandleUpRefs(Context.getPointerType(Result.get(), AddrSpace)); + Result = HandleUpRefs(PointerType::get(Result.get(), AddrSpace)); break; } @@ -1365,7 +1365,7 @@ bool LLParser::ParseFunctionType(PATypeHolder &Result) { for (unsigned i = 0, e = ArgList.size(); i != e; ++i) ArgListTy.push_back(ArgList[i].Type); - Result = HandleUpRefs(Context.getFunctionType(Result.get(), + Result = HandleUpRefs(FunctionType::get(Result.get(), ArgListTy, isVarArg)); return false; } @@ -1381,7 +1381,7 @@ bool LLParser::ParseStructType(PATypeHolder &Result, bool Packed) { Lex.Lex(); // Consume the '{' if (EatIfPresent(lltok::rbrace)) { - Result = Context.getStructType(Packed); + Result = StructType::get(Packed); return false; } @@ -1413,7 +1413,7 @@ bool LLParser::ParseStructType(PATypeHolder &Result, bool Packed) { std::vector ParamsListTy; for (unsigned i = 0, e = ParamsList.size(); i != e; ++i) ParamsListTy.push_back(ParamsList[i].get()); - Result = HandleUpRefs(Context.getStructType(ParamsListTy, Packed)); + Result = HandleUpRefs(StructType::get(ParamsListTy, Packed)); return false; } @@ -1452,11 +1452,11 @@ bool LLParser::ParseArrayVectorType(PATypeHolder &Result, bool isVector) { return Error(SizeLoc, "size too large for vector"); if (!VectorType::isValidElementType(EltTy)) return Error(TypeLoc, "vector element type must be fp or integer"); - Result = Context.getVectorType(EltTy, unsigned(Size)); + Result = VectorType::get(EltTy, unsigned(Size)); } else { if (!ArrayType::isValidElementType(EltTy)) return Error(TypeLoc, "invalid array element type"); - Result = HandleUpRefs(Context.getArrayType(EltTy, Size)); + Result = HandleUpRefs(ArrayType::get(EltTy, Size)); } return false; } @@ -1836,7 +1836,7 @@ bool LLParser::ParseValID(ValID &ID) { return Error(FirstEltLoc, "invalid array element type: " + Elts[0]->getType()->getDescription()); - ArrayType *ATy = Context.getArrayType(Elts[0]->getType(), Elts.size()); + ArrayType *ATy = ArrayType::get(Elts[0]->getType(), Elts.size()); // Verify all elements are correct type! for (unsigned i = 0, e = Elts.size(); i != e; ++i) { @@ -2417,8 +2417,8 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) { return Error(RetTypeLoc, "functions with 'sret' argument must return void"); const FunctionType *FT = - Context.getFunctionType(RetType, ParamTypeList, isVarArg); - const PointerType *PFT = Context.getPointerTypeUnqual(FT); + FunctionType::get(RetType, ParamTypeList, isVarArg); + const PointerType *PFT = PointerType::getUnqual(FT); Fn = 0; if (!FunctionName.empty()) { @@ -2902,8 +2902,8 @@ bool LLParser::ParseInvoke(Instruction *&Inst, PerFunctionState &PFS) { if (!FunctionType::isValidReturnType(RetType)) return Error(RetTypeLoc, "Invalid result type for LLVM function"); - Ty = Context.getFunctionType(RetType, ParamTypes, false); - PFTy = Context.getPointerTypeUnqual(Ty); + Ty = FunctionType::get(RetType, ParamTypes, false); + PFTy = PointerType::getUnqual(Ty); } // Look up the callee. @@ -3242,8 +3242,8 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS, if (!FunctionType::isValidReturnType(RetType)) return Error(RetTypeLoc, "Invalid result type for LLVM function"); - Ty = Context.getFunctionType(RetType, ParamTypes, false); - PFTy = Context.getPointerTypeUnqual(Ty); + Ty = FunctionType::get(RetType, ParamTypes, false); + PFTy = PointerType::getUnqual(Ty); } // Look up the callee. diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 2b224040865..1e6f5b6dd43 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -322,7 +322,7 @@ const Type *BitcodeReader::getTypeByID(unsigned ID, bool isTypeTable) { // The type table allows forward references. Push as many Opaque types as // needed to get up to ID. while (TypeList.size() <= ID) - TypeList.push_back(Context.getOpaqueType()); + TypeList.push_back(OpaqueType::get()); return TypeList.back().get(); } @@ -512,7 +512,7 @@ bool BitcodeReader::ParseTypeTable() { if (Record.size() < 1) return Error("Invalid Integer type record"); - ResultTy = Context.getIntegerType(Record[0]); + ResultTy = IntegerType::get(Record[0]); break; case bitc::TYPE_CODE_POINTER: { // POINTER: [pointee type] or // [pointee type, address space] @@ -521,7 +521,7 @@ bool BitcodeReader::ParseTypeTable() { unsigned AddressSpace = 0; if (Record.size() == 2) AddressSpace = Record[1]; - ResultTy = Context.getPointerType(getTypeByID(Record[0], true), + ResultTy = PointerType::get(getTypeByID(Record[0], true), AddressSpace); break; } @@ -534,7 +534,7 @@ bool BitcodeReader::ParseTypeTable() { for (unsigned i = 3, e = Record.size(); i != e; ++i) ArgTys.push_back(getTypeByID(Record[i], true)); - ResultTy = Context.getFunctionType(getTypeByID(Record[2], true), ArgTys, + ResultTy = FunctionType::get(getTypeByID(Record[2], true), ArgTys, Record[0]); break; } @@ -544,24 +544,24 @@ bool BitcodeReader::ParseTypeTable() { std::vector EltTys; for (unsigned i = 1, e = Record.size(); i != e; ++i) EltTys.push_back(getTypeByID(Record[i], true)); - ResultTy = Context.getStructType(EltTys, Record[0]); + ResultTy = StructType::get(EltTys, Record[0]); break; } case bitc::TYPE_CODE_ARRAY: // ARRAY: [numelts, eltty] if (Record.size() < 2) return Error("Invalid ARRAY type record"); - ResultTy = Context.getArrayType(getTypeByID(Record[1], true), Record[0]); + ResultTy = ArrayType::get(getTypeByID(Record[1], true), Record[0]); break; case bitc::TYPE_CODE_VECTOR: // VECTOR: [numelts, eltty] if (Record.size() < 2) return Error("Invalid VECTOR type record"); - ResultTy = Context.getVectorType(getTypeByID(Record[1], true), Record[0]); + ResultTy = VectorType::get(getTypeByID(Record[1], true), Record[0]); break; } if (NumRecords == TypeList.size()) { // If this is a new type slot, just append it. - TypeList.push_back(ResultTy ? ResultTy : Context.getOpaqueType()); + TypeList.push_back(ResultTy ? ResultTy : OpaqueType::get()); ++NumRecords; } else if (ResultTy == 0) { // Otherwise, this was forward referenced, so an opaque type was created, @@ -1046,7 +1046,7 @@ bool BitcodeReader::ParseConstants() { return Error("Invalid CE_SHUFFLEVEC record"); Constant *Op0 = ValueList.getConstantFwdRef(Record[0], OpTy); Constant *Op1 = ValueList.getConstantFwdRef(Record[1], OpTy); - const Type *ShufTy = Context.getVectorType(Type::Int32Ty, + const Type *ShufTy = VectorType::get(Type::Int32Ty, OpTy->getNumElements()); Constant *Op2 = ValueList.getConstantFwdRef(Record[2], ShufTy); V = ConstantExpr::getShuffleVector(Op0, Op1, Op2); @@ -1059,7 +1059,7 @@ bool BitcodeReader::ParseConstants() { return Error("Invalid CE_SHUFVEC_EX record"); Constant *Op0 = ValueList.getConstantFwdRef(Record[1], OpTy); Constant *Op1 = ValueList.getConstantFwdRef(Record[2], OpTy); - const Type *ShufTy = Context.getVectorType(Type::Int32Ty, + const Type *ShufTy = VectorType::get(Type::Int32Ty, RTy->getNumElements()); Constant *Op2 = ValueList.getConstantFwdRef(Record[3], ShufTy); V = ConstantExpr::getShuffleVector(Op0, Op1, Op2); @@ -1940,7 +1940,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { Value *Val, *Ptr; if (getValueTypePair(Record, OpNum, NextValueNo, Val) || getValue(Record, OpNum, - Context.getPointerTypeUnqual(Val->getType()), Ptr)|| + PointerType::getUnqual(Val->getType()), Ptr)|| OpNum+2 != Record.size()) return Error("Invalid STORE record"); diff --git a/lib/CodeGen/DwarfEHPrepare.cpp b/lib/CodeGen/DwarfEHPrepare.cpp index 43760afad84..5bfb32870c9 100644 --- a/lib/CodeGen/DwarfEHPrepare.cpp +++ b/lib/CodeGen/DwarfEHPrepare.cpp @@ -354,8 +354,7 @@ Instruction *DwarfEHPrepare::CreateValueLoad(BasicBlock *BB) { // Create the temporary if we didn't already. if (!ExceptionValueVar) { - ExceptionValueVar = new AllocaInst( - BB->getContext().getPointerTypeUnqual(Type::Int8Ty), + ExceptionValueVar = new AllocaInst(PointerType::getUnqual(Type::Int8Ty), "eh.value", F->begin()->begin()); ++NumStackTempsIntroduced; } diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index aacd9e847aa..0796f2251d2 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -3664,7 +3664,7 @@ SDValue DAGCombiner::CombineConsecutiveLoads(SDNode *N, MVT VT) { TLI.isConsecutiveLoad(LD2, LD1, LD1VT.getSizeInBits()/8, 1, MFI)) { unsigned Align = LD1->getAlignment(); unsigned NewAlign = TLI.getTargetData()-> - getABITypeAlignment(VT.getTypeForMVT(*DAG.getContext())); + getABITypeAlignment(VT.getTypeForMVT()); if (NewAlign <= Align && (!LegalOperations || TLI.isOperationLegal(ISD::LOAD, VT))) @@ -3722,7 +3722,7 @@ SDValue DAGCombiner::visitBIT_CONVERT(SDNode *N) { (!LegalOperations || TLI.isOperationLegal(ISD::LOAD, VT))) { LoadSDNode *LN0 = cast(N0); unsigned Align = TLI.getTargetData()-> - getABITypeAlignment(VT.getTypeForMVT(*DAG.getContext())); + getABITypeAlignment(VT.getTypeForMVT()); unsigned OrigAlign = LN0->getAlignment(); if (Align <= OrigAlign) { @@ -4993,8 +4993,7 @@ SDValue DAGCombiner::ReduceLoadOpStoreWidth(SDNode *N) { unsigned NewAlign = MinAlign(LD->getAlignment(), PtrOff); if (NewAlign < - TLI.getTargetData()->getABITypeAlignment(NewVT.getTypeForMVT( - *DAG.getContext()))) + TLI.getTargetData()->getABITypeAlignment(NewVT.getTypeForMVT())) return SDValue(); SDValue NewPtr = DAG.getNode(ISD::ADD, LD->getDebugLoc(), @@ -5049,7 +5048,7 @@ SDValue DAGCombiner::visitSTORE(SDNode *N) { unsigned OrigAlign = ST->getAlignment(); MVT SVT = Value.getOperand(0).getValueType(); unsigned Align = TLI.getTargetData()-> - getABITypeAlignment(SVT.getTypeForMVT(*DAG.getContext())); + getABITypeAlignment(SVT.getTypeForMVT()); if (Align <= OrigAlign && ((!LegalOperations && !ST->isVolatile()) || TLI.isOperationLegalOrCustom(ISD::STORE, SVT))) @@ -5329,8 +5328,7 @@ SDValue DAGCombiner::visitEXTRACT_VECTOR_ELT(SDNode *N) { // Check the resultant load doesn't need a higher alignment than the // original load. unsigned NewAlign = - TLI.getTargetData()->getABITypeAlignment(LVT.getTypeForMVT( - *DAG.getContext())); + TLI.getTargetData()->getABITypeAlignment(LVT.getTypeForMVT()); if (NewAlign > Align || !TLI.isOperationLegalOrCustom(ISD::LOAD, LVT)) return SDValue(); @@ -5812,8 +5810,7 @@ SDValue DAGCombiner::SimplifySelectCC(DebugLoc DL, SDValue N0, SDValue N1, const TargetData &TD = *TLI.getTargetData(); // Create a ConstantArray of the two constants. - Constant *CA = ConstantArray::get( - DAG.getContext()->getArrayType(FPTy, 2), Elts, 2); + Constant *CA = ConstantArray::get(ArrayType::get(FPTy, 2), Elts, 2); SDValue CPIdx = DAG.getConstantPool(CA, TLI.getPointerTy(), TD.getPrefTypeAlignment(FPTy)); unsigned Alignment = cast(CPIdx)->getAlignment(); diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index e4b71b1a404..7293144b4e7 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -361,7 +361,7 @@ static SDValue ExpandConstantFP(ConstantFPSDNode *CFP, bool UseCP, // smaller type. TLI.isLoadExtLegal(ISD::EXTLOAD, SVT) && TLI.ShouldShrinkFPConstant(OrigVT)) { - const Type *SType = SVT.getTypeForMVT(*DAG.getContext()); + const Type *SType = SVT.getTypeForMVT(); LLVMC = cast(ConstantExpr::getFPTrunc(LLVMC, SType)); VT = SVT; Extend = true; @@ -1107,11 +1107,10 @@ SDValue SelectionDAGLegalize::LegalizeOp(SDValue Op) { // expand it. if (!TLI.allowsUnalignedMemoryAccesses()) { unsigned ABIAlignment = TLI.getTargetData()-> - getABITypeAlignment(LD->getMemoryVT().getTypeForMVT( - *DAG.getContext())); + getABITypeAlignment(LD->getMemoryVT().getTypeForMVT()); if (LD->getAlignment() < ABIAlignment){ - Result = ExpandUnalignedLoad(cast(Result.getNode()), DAG, - TLI); + Result = ExpandUnalignedLoad(cast(Result.getNode()), + DAG, TLI); Tmp3 = Result.getOperand(0); Tmp4 = Result.getOperand(1); Tmp3 = LegalizeOp(Tmp3); @@ -1291,11 +1290,10 @@ SDValue SelectionDAGLegalize::LegalizeOp(SDValue Op) { // expand it. if (!TLI.allowsUnalignedMemoryAccesses()) { unsigned ABIAlignment = TLI.getTargetData()-> - getABITypeAlignment(LD->getMemoryVT().getTypeForMVT( - *DAG.getContext())); + getABITypeAlignment(LD->getMemoryVT().getTypeForMVT()); if (LD->getAlignment() < ABIAlignment){ - Result = ExpandUnalignedLoad(cast(Result.getNode()), DAG, - TLI); + Result = ExpandUnalignedLoad(cast(Result.getNode()), + DAG, TLI); Tmp1 = Result.getOperand(0); Tmp2 = Result.getOperand(1); Tmp1 = LegalizeOp(Tmp1); @@ -1370,8 +1368,7 @@ SDValue SelectionDAGLegalize::LegalizeOp(SDValue Op) { // expand it. if (!TLI.allowsUnalignedMemoryAccesses()) { unsigned ABIAlignment = TLI.getTargetData()-> - getABITypeAlignment(ST->getMemoryVT().getTypeForMVT( - *DAG.getContext())); + getABITypeAlignment(ST->getMemoryVT().getTypeForMVT()); if (ST->getAlignment() < ABIAlignment) Result = ExpandUnalignedStore(cast(Result.getNode()), DAG, TLI); @@ -1470,8 +1467,7 @@ SDValue SelectionDAGLegalize::LegalizeOp(SDValue Op) { // expand it. if (!TLI.allowsUnalignedMemoryAccesses()) { unsigned ABIAlignment = TLI.getTargetData()-> - getABITypeAlignment(ST->getMemoryVT().getTypeForMVT( - *DAG.getContext())); + getABITypeAlignment(ST->getMemoryVT().getTypeForMVT()); if (ST->getAlignment() < ABIAlignment) Result = ExpandUnalignedStore(cast(Result.getNode()), DAG, TLI); @@ -1737,7 +1733,7 @@ SDValue SelectionDAGLegalize::EmitStackConvert(SDValue SrcOp, // Create the stack frame object. unsigned SrcAlign = TLI.getTargetData()->getPrefTypeAlignment(SrcOp.getValueType(). - getTypeForMVT(*DAG.getContext())); + getTypeForMVT()); SDValue FIPtr = DAG.CreateStackTemporary(SlotVT, SrcAlign); FrameIndexSDNode *StackPtrFI = cast(FIPtr); @@ -1748,8 +1744,7 @@ SDValue SelectionDAGLegalize::EmitStackConvert(SDValue SrcOp, unsigned SlotSize = SlotVT.getSizeInBits(); unsigned DestSize = DestVT.getSizeInBits(); unsigned DestAlign = - TLI.getTargetData()->getPrefTypeAlignment(DestVT.getTypeForMVT( - *DAG.getContext())); + TLI.getTargetData()->getPrefTypeAlignment(DestVT.getTypeForMVT()); // Emit a store to the stack slot. Use a truncstore if the input value is // later than DestVT. @@ -1844,7 +1839,7 @@ SDValue SelectionDAGLegalize::ExpandBUILD_VECTOR(SDNode *Node) { CV.push_back(const_cast(V->getConstantIntValue())); } else { assert(Node->getOperand(i).getOpcode() == ISD::UNDEF); - const Type *OpNTy = OpVT.getTypeForMVT(*DAG.getContext()); + const Type *OpNTy = OpVT.getTypeForMVT(); CV.push_back(Context->getUndef(OpNTy)); } } @@ -1898,7 +1893,7 @@ SDValue SelectionDAGLegalize::ExpandLibCall(RTLIB::Libcall LC, SDNode *Node, TargetLowering::ArgListEntry Entry; for (unsigned i = 0, e = Node->getNumOperands(); i != e; ++i) { MVT ArgVT = Node->getOperand(i).getValueType(); - const Type *ArgTy = ArgVT.getTypeForMVT(*DAG.getContext()); + const Type *ArgTy = ArgVT.getTypeForMVT(); Entry.Node = Node->getOperand(i); Entry.Ty = ArgTy; Entry.isSExt = isSigned; Entry.isZExt = !isSigned; @@ -1908,7 +1903,7 @@ SDValue SelectionDAGLegalize::ExpandLibCall(RTLIB::Libcall LC, SDNode *Node, TLI.getPointerTy()); // Splice the libcall in wherever FindInputOutputChains tells us to. - const Type *RetTy = Node->getValueType(0).getTypeForMVT(*DAG.getContext()); + const Type *RetTy = Node->getValueType(0).getTypeForMVT(); std::pair CallInfo = TLI.LowerCallTo(InChain, RetTy, isSigned, !isSigned, false, false, 0, CallingConv::C, false, Callee, Args, DAG, @@ -2397,8 +2392,7 @@ void SelectionDAGLegalize::ExpandNode(SDNode *Node, // Increment the pointer, VAList, to the next vaarg Tmp3 = DAG.getNode(ISD::ADD, dl, TLI.getPointerTy(), VAList, DAG.getConstant(TLI.getTargetData()-> - getTypeAllocSize(VT.getTypeForMVT( - *DAG.getContext())), + getTypeAllocSize(VT.getTypeForMVT()), TLI.getPointerTy())); // Store the incremented VAList to the legalized pointer Tmp3 = DAG.getStore(VAList.getValue(1), dl, Tmp3, Tmp2, V, 0); diff --git a/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp b/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp index 1f05e8dc6c2..c80b34db990 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp @@ -1009,7 +1009,7 @@ SDValue DAGTypeLegalizer::MakeLibCall(RTLIB::Libcall LC, MVT RetVT, TargetLowering::ArgListEntry Entry; for (unsigned i = 0; i != NumOps; ++i) { Entry.Node = Ops[i]; - Entry.Ty = Entry.Node.getValueType().getTypeForMVT(*DAG.getContext()); + Entry.Ty = Entry.Node.getValueType().getTypeForMVT(); Entry.isSExt = isSigned; Entry.isZExt = !isSigned; Args.push_back(Entry); @@ -1017,7 +1017,7 @@ SDValue DAGTypeLegalizer::MakeLibCall(RTLIB::Libcall LC, MVT RetVT, SDValue Callee = DAG.getExternalSymbol(TLI.getLibcallName(LC), TLI.getPointerTy()); - const Type *RetTy = RetVT.getTypeForMVT(*DAG.getContext()); + const Type *RetTy = RetVT.getTypeForMVT(); std::pair CallInfo = TLI.LowerCallTo(DAG.getEntryNode(), RetTy, isSigned, !isSigned, false, false, 0, CallingConv::C, false, Callee, Args, DAG, dl); diff --git a/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp b/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp index 49ea022404d..080342687a6 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp @@ -115,8 +115,7 @@ void DAGTypeLegalizer::ExpandRes_BIT_CONVERT(SDNode *N, SDValue &Lo, // Create the stack frame object. Make sure it is aligned for both // the source and expanded destination types. unsigned Alignment = - TLI.getTargetData()->getPrefTypeAlignment(NOutVT.getTypeForMVT( - *DAG.getContext())); + TLI.getTargetData()->getPrefTypeAlignment(NOutVT.getTypeForMVT()); SDValue StackPtr = DAG.CreateStackTemporary(InVT, Alignment); int SPFI = cast(StackPtr.getNode())->getIndex(); const Value *SV = PseudoSourceValue::getFixedStack(SPFI); diff --git a/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp b/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp index fe2660963d3..9ec084663fd 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp @@ -667,8 +667,7 @@ void DAGTypeLegalizer::SplitVecRes_INSERT_VECTOR_ELT(SDNode *N, SDValue &Lo, // so use a truncating store. SDValue EltPtr = GetVectorElementPointer(StackPtr, EltVT, Idx); unsigned Alignment = - TLI.getTargetData()->getPrefTypeAlignment(VecVT.getTypeForMVT( - *DAG.getContext())); + TLI.getTargetData()->getPrefTypeAlignment(VecVT.getTypeForMVT()); Store = DAG.getTruncStore(Store, dl, Elt, EltPtr, NULL, 0, EltVT); // Load the Lo part from the stack slot. diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index a8398243c73..eca726a1df9 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -798,7 +798,7 @@ void SelectionDAG::VerifyNode(SDNode *N) { unsigned SelectionDAG::getMVTAlignment(MVT VT) const { const Type *Ty = VT == MVT::iPTR ? PointerType::get(Type::Int8Ty, 0) : - VT.getTypeForMVT(*Context); + VT.getTypeForMVT(); return TLI.getTargetData()->getABITypeAlignment(Ty); } @@ -1389,7 +1389,7 @@ SDValue SelectionDAG::getShiftAmountOperand(SDValue Op) { SDValue SelectionDAG::CreateStackTemporary(MVT VT, unsigned minAlign) { MachineFrameInfo *FrameInfo = getMachineFunction().getFrameInfo(); unsigned ByteSize = VT.getStoreSizeInBits()/8; - const Type *Ty = VT.getTypeForMVT(*Context); + const Type *Ty = VT.getTypeForMVT(); unsigned StackAlign = std::max((unsigned)TLI.getTargetData()->getPrefTypeAlignment(Ty), minAlign); @@ -1402,8 +1402,8 @@ SDValue SelectionDAG::CreateStackTemporary(MVT VT, unsigned minAlign) { SDValue SelectionDAG::CreateStackTemporary(MVT VT1, MVT VT2) { unsigned Bytes = std::max(VT1.getStoreSizeInBits(), VT2.getStoreSizeInBits())/8; - const Type *Ty1 = VT1.getTypeForMVT(*Context); - const Type *Ty2 = VT2.getTypeForMVT(*Context); + const Type *Ty1 = VT1.getTypeForMVT(); + const Type *Ty2 = VT2.getTypeForMVT(); const TargetData *TD = TLI.getTargetData(); unsigned Align = std::max(TD->getPrefTypeAlignment(Ty1), TD->getPrefTypeAlignment(Ty2)); @@ -3104,8 +3104,7 @@ bool MeetsMaxMemopRequirement(std::vector &MemOps, MVT VT = TLI.getOptimalMemOpType(Size, Align, isSrcConst, isSrcStr, DAG); if (VT != MVT::iAny) { unsigned NewAlign = (unsigned) - TLI.getTargetData()->getABITypeAlignment(VT.getTypeForMVT( - *DAG.getContext())); + TLI.getTargetData()->getABITypeAlignment(VT.getTypeForMVT()); // If source is a string constant, this will require an unaligned load. if (NewAlign > Align && (isSrcConst || AllowUnalign)) { if (Dst.getOpcode() != ISD::FrameIndex) { diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp index 7134938060e..0eda58ade4b 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp @@ -5516,7 +5516,7 @@ void TargetLowering::LowerArguments(Function &F, SelectionDAG &DAG, for (unsigned Value = 0, NumValues = ValueVTs.size(); Value != NumValues; ++Value) { MVT VT = ValueVTs[Value]; - const Type *ArgTy = VT.getTypeForMVT(*DAG.getContext()); + const Type *ArgTy = VT.getTypeForMVT(); ISD::ArgFlagsTy Flags; unsigned OriginalAlignment = getTargetData()->getABITypeAlignment(ArgTy); @@ -5647,7 +5647,7 @@ TargetLowering::LowerCallTo(SDValue Chain, const Type *RetTy, for (unsigned Value = 0, NumValues = ValueVTs.size(); Value != NumValues; ++Value) { MVT VT = ValueVTs[Value]; - const Type *ArgTy = VT.getTypeForMVT(*DAG.getContext()); + const Type *ArgTy = VT.getTypeForMVT(); SDValue Op = SDValue(Args[i].Node.getNode(), Args[i].Node.getResNo() + Value); ISD::ArgFlagsTy Flags; diff --git a/lib/CodeGen/ShadowStackGC.cpp b/lib/CodeGen/ShadowStackGC.cpp index 08d6720701a..b412532e331 100644 --- a/lib/CodeGen/ShadowStackGC.cpp +++ b/lib/CodeGen/ShadowStackGC.cpp @@ -188,8 +188,6 @@ ShadowStackGC::ShadowStackGC() : Head(0), StackEntryTy(0) { Constant *ShadowStackGC::GetFrameMap(Function &F) { // doInitialization creates the abstract type of this value. - LLVMContext &Context = F.getContext(); - Type *VoidPtr = PointerType::getUnqual(Type::Int8Ty); // Truncate the ShadowStackDescriptor if some metadata is null. @@ -209,7 +207,7 @@ Constant *ShadowStackGC::GetFrameMap(Function &F) { Constant *DescriptorElts[] = { ConstantStruct::get(BaseElts, 2), - ConstantArray::get(Context.getArrayType(VoidPtr, NumMeta), + ConstantArray::get(ArrayType::get(VoidPtr, NumMeta), Metadata.begin(), NumMeta) }; diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp index 9f60954ba83..b932c8cef19 100644 --- a/lib/ExecutionEngine/JIT/JIT.cpp +++ b/lib/ExecutionEngine/JIT/JIT.cpp @@ -368,7 +368,6 @@ void JIT::deleteModuleProvider(ModuleProvider *MP, std::string *E) { GenericValue JIT::runFunction(Function *F, const std::vector &ArgValues) { assert(F && "Function *F was null at entry to run()"); - LLVMContext &Context = F->getContext(); void *FPtr = getPointerToFunction(F); assert(FPtr && "Pointer to fn's code was null after getPointerToFunction"); @@ -470,7 +469,7 @@ GenericValue JIT::runFunction(Function *F, // arguments. Make this function and return. // First, create the function. - FunctionType *STy=Context.getFunctionType(RetTy, false); + FunctionType *STy=FunctionType::get(RetTy, false); Function *Stub = Function::Create(STy, Function::InternalLinkage, "", F->getParent()); diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index 75da6bf3305..4d9b061c08f 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -1148,7 +1148,7 @@ static bool LinkAppendingVars(Module *M, "Appending variables with different section name need to be linked!"); unsigned NewSize = T1->getNumElements() + T2->getNumElements(); - ArrayType *NewType = Context.getArrayType(T1->getElementType(), + ArrayType *NewType = ArrayType::get(T1->getElementType(), NewSize); G1->setName(""); // Clear G1's name in case of a conflict! diff --git a/lib/Target/CellSPU/SPUISelLowering.cpp b/lib/Target/CellSPU/SPUISelLowering.cpp index 50ba00f6367..ce7ba72e77d 100644 --- a/lib/Target/CellSPU/SPUISelLowering.cpp +++ b/lib/Target/CellSPU/SPUISelLowering.cpp @@ -101,7 +101,7 @@ namespace { TargetLowering::ArgListEntry Entry; for (unsigned i = 0, e = Op.getNumOperands(); i != e; ++i) { MVT ArgVT = Op.getOperand(i).getValueType(); - const Type *ArgTy = ArgVT.getTypeForMVT(*DAG.getContext()); + const Type *ArgTy = ArgVT.getTypeForMVT(); Entry.Node = Op.getOperand(i); Entry.Ty = ArgTy; Entry.isSExt = isSigned; @@ -112,8 +112,7 @@ namespace { TLI.getPointerTy()); // Splice the libcall in wherever FindInputOutputChains tells us to. - const Type *RetTy = - Op.getNode()->getValueType(0).getTypeForMVT(*DAG.getContext()); + const Type *RetTy = Op.getNode()->getValueType(0).getTypeForMVT(); std::pair CallInfo = TLI.LowerCallTo(InChain, RetTy, isSigned, !isSigned, false, false, 0, CallingConv::C, false, Callee, Args, DAG, diff --git a/lib/Target/PIC16/PIC16ISelLowering.cpp b/lib/Target/PIC16/PIC16ISelLowering.cpp index f194dc85f24..7dc96d1e1fa 100644 --- a/lib/Target/PIC16/PIC16ISelLowering.cpp +++ b/lib/Target/PIC16/PIC16ISelLowering.cpp @@ -372,14 +372,14 @@ PIC16TargetLowering::MakePIC16Libcall(PIC16ISD::PIC16Libcall Call, TargetLowering::ArgListEntry Entry; for (unsigned i = 0; i != NumOps; ++i) { Entry.Node = Ops[i]; - Entry.Ty = Entry.Node.getValueType().getTypeForMVT(*DAG.getContext()); + Entry.Ty = Entry.Node.getValueType().getTypeForMVT(); Entry.isSExt = isSigned; Entry.isZExt = !isSigned; Args.push_back(Entry); } SDValue Callee = DAG.getExternalSymbol(getPIC16LibcallName(Call), MVT::i8); - const Type *RetTy = RetVT.getTypeForMVT(*DAG.getContext()); + const Type *RetTy = RetVT.getTypeForMVT(); std::pair CallInfo = LowerCallTo(DAG.getEntryNode(), RetTy, isSigned, !isSigned, false, false, 0, CallingConv::C, false, Callee, Args, DAG, dl); diff --git a/lib/Target/PowerPC/PPCISelLowering.cpp b/lib/Target/PowerPC/PPCISelLowering.cpp index df71838b1e6..bfe0f6f2b01 100644 --- a/lib/Target/PowerPC/PPCISelLowering.cpp +++ b/lib/Target/PowerPC/PPCISelLowering.cpp @@ -1291,7 +1291,7 @@ SDValue PPCTargetLowering::LowerTRAMPOLINE(SDValue Op, SelectionDAG &DAG) { // Lower to a call to __trampoline_setup(Trmp, TrampSize, FPtr, ctx_reg) std::pair CallResult = - LowerCallTo(Chain, Op.getValueType().getTypeForMVT(*DAG.getContext()), + LowerCallTo(Chain, Op.getValueType().getTypeForMVT(), false, false, false, false, 0, CallingConv::C, false, DAG.getExternalSymbol("__trampoline_setup", PtrVT), Args, DAG, dl); diff --git a/lib/Target/XCore/XCoreISelLowering.cpp b/lib/Target/XCore/XCoreISelLowering.cpp index eaab8493750..78734630ad7 100644 --- a/lib/Target/XCore/XCoreISelLowering.cpp +++ b/lib/Target/XCore/XCoreISelLowering.cpp @@ -380,7 +380,7 @@ LowerLOAD(SDValue Op, SelectionDAG &DAG) return SDValue(); } unsigned ABIAlignment = getTargetData()-> - getABITypeAlignment(LD->getMemoryVT().getTypeForMVT(*DAG.getContext())); + getABITypeAlignment(LD->getMemoryVT().getTypeForMVT()); // Leave aligned load alone. if (LD->getAlignment() >= ABIAlignment) { return SDValue(); @@ -475,7 +475,7 @@ LowerSTORE(SDValue Op, SelectionDAG &DAG) return SDValue(); } unsigned ABIAlignment = getTargetData()-> - getABITypeAlignment(ST->getMemoryVT().getTypeForMVT(*DAG.getContext())); + getABITypeAlignment(ST->getMemoryVT().getTypeForMVT()); // Leave aligned store alone. if (ST->getAlignment() >= ABIAlignment) { return SDValue(); @@ -1077,7 +1077,7 @@ SDValue XCoreTargetLowering::PerformDAGCombine(SDNode *N, break; } unsigned ABIAlignment = getTargetData()-> - getABITypeAlignment(ST->getMemoryVT().getTypeForMVT(*DAG.getContext())); + getABITypeAlignment(ST->getMemoryVT().getTypeForMVT()); unsigned Alignment = ST->getAlignment(); if (Alignment >= ABIAlignment) { break; diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp index cb5787b6bd4..5cf3a9b6fd4 100644 --- a/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -588,7 +588,7 @@ Function *ArgPromotion::DoPromotion(Function *F, } // Construct the new function type using the new arguments. - FunctionType *NFTy = Context.getFunctionType(RetTy, Params, FTy->isVarArg()); + FunctionType *NFTy = FunctionType::get(RetTy, Params, FTy->isVarArg()); // Create the new function body and insert it into the module... Function *NF = Function::Create(NFTy, F->getLinkage(), F->getName()); diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp index 63210487c8e..0b7e9d98743 100644 --- a/lib/Transforms/IPO/DeadArgumentElimination.cpp +++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp @@ -197,10 +197,9 @@ bool DAE::DeleteDeadVarargs(Function &Fn) { // Start by computing a new prototype for the function, which is the same as // the old function, but doesn't have isVarArg set. const FunctionType *FTy = Fn.getFunctionType(); - LLVMContext &Context = FTy->getContext(); std::vector Params(FTy->param_begin(), FTy->param_end()); - FunctionType *NFTy = Context.getFunctionType(FTy->getReturnType(), + FunctionType *NFTy = FunctionType::get(FTy->getReturnType(), Params, false); unsigned NumArgs = Params.size(); @@ -641,7 +640,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) { // something and {} into void. // Make the new struct packed if we used to return a packed struct // already. - NRetTy = Context.getStructType(RetTypes, STy->isPacked()); + NRetTy = StructType::get(RetTypes, STy->isPacked()); else if (RetTypes.size() == 1) // One return type? Just a simple value then, but only if we didn't use to // return a struct with that simple value before. @@ -709,7 +708,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) { } // Create the new function type based on the recomputed parameters. - FunctionType *NFTy = Context.getFunctionType(NRetTy, Params, + FunctionType *NFTy = FunctionType::get(NRetTy, Params, FTy->isVarArg()); // No change? diff --git a/lib/Transforms/IPO/ExtractGV.cpp b/lib/Transforms/IPO/ExtractGV.cpp index 9c28fdbe646..dfbad61cf5d 100644 --- a/lib/Transforms/IPO/ExtractGV.cpp +++ b/lib/Transforms/IPO/ExtractGV.cpp @@ -103,13 +103,13 @@ namespace { // by putting them in the used array { std::vector AUGs; - const Type *SBP= Context.getPointerTypeUnqual(Type::Int8Ty); + const Type *SBP= PointerType::getUnqual(Type::Int8Ty); for (std::vector::iterator GI = Named.begin(), GE = Named.end(); GI != GE; ++GI) { (*GI)->setLinkage(GlobalValue::ExternalLinkage); AUGs.push_back(ConstantExpr::getBitCast(*GI, SBP)); } - ArrayType *AT = Context.getArrayType(SBP, AUGs.size()); + ArrayType *AT = ArrayType::get(SBP, AUGs.size()); Constant *Init = ConstantArray::get(AT, AUGs); GlobalValue *gv = new GlobalVariable(M, AT, false, GlobalValue::AppendingLinkage, diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index 5be3239a639..61e4316a614 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -826,7 +826,7 @@ static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV, if (NElements->getZExtValue() != 1) { // If we have an array allocation, transform it to a single element // allocation to make the code below simpler. - Type *NewTy = Context.getArrayType(MI->getAllocatedType(), + Type *NewTy = ArrayType::get(MI->getAllocatedType(), NElements->getZExtValue()); MallocInst *NewMI = new MallocInst(NewTy, Context.getNullValue(Type::Int32Ty), @@ -1161,7 +1161,7 @@ static Value *GetHeapSROAValue(Value *V, unsigned FieldNo, cast(cast(PN->getType())->getElementType()); Result = - PHINode::Create(Context.getPointerTypeUnqual(ST->getElementType(FieldNo)), + PHINode::Create(PointerType::getUnqual(ST->getElementType(FieldNo)), PN->getName()+".f"+utostr(FieldNo), PN); PHIsToRewrite.push_back(std::make_pair(PN, FieldNo)); } else { @@ -1282,7 +1282,7 @@ static GlobalVariable *PerformHeapAllocSRoA(GlobalVariable *GV, MallocInst *MI, for (unsigned FieldNo = 0, e = STy->getNumElements(); FieldNo != e;++FieldNo){ const Type *FieldTy = STy->getElementType(FieldNo); - const Type *PFieldTy = Context.getPointerTypeUnqual(FieldTy); + const Type *PFieldTy = PointerType::getUnqual(FieldTy); GlobalVariable *NGV = new GlobalVariable(*GV->getParent(), @@ -1957,8 +1957,8 @@ static GlobalVariable *InstallGlobalCtors(GlobalVariable *GCL, if (Ctors[i]) { CSVals[1] = Ctors[i]; } else { - const Type *FTy = Context.getFunctionType(Type::VoidTy, false); - const PointerType *PFTy = Context.getPointerTypeUnqual(FTy); + const Type *FTy = FunctionType::get(Type::VoidTy, false); + const PointerType *PFTy = PointerType::getUnqual(FTy); CSVals[1] = Context.getNullValue(PFTy); CSVals[0] = ConstantInt::get(Type::Int32Ty, 2147483647); } diff --git a/lib/Transforms/IPO/LowerSetJmp.cpp b/lib/Transforms/IPO/LowerSetJmp.cpp index 980123af57e..d2837a30ed3 100644 --- a/lib/Transforms/IPO/LowerSetJmp.cpp +++ b/lib/Transforms/IPO/LowerSetJmp.cpp @@ -201,9 +201,8 @@ bool LowerSetJmp::runOnModule(Module& M) { // This function is always successful, unless it isn't. bool LowerSetJmp::doInitialization(Module& M) { - LLVMContext &Context = M.getContext(); - const Type *SBPTy = Context.getPointerTypeUnqual(Type::Int8Ty); - const Type *SBPPTy = Context.getPointerTypeUnqual(SBPTy); + const Type *SBPTy = PointerType::getUnqual(Type::Int8Ty); + const Type *SBPPTy = PointerType::getUnqual(SBPTy); // N.B. See llvm/runtime/GCCLibraries/libexception/SJLJ-Exception.h for // a description of the following library functions. @@ -259,7 +258,7 @@ bool LowerSetJmp::IsTransformableFunction(const std::string& Name) { // throwing the exception for us. void LowerSetJmp::TransformLongJmpCall(CallInst* Inst) { - const Type* SBPTy = Inst->getContext().getPointerTypeUnqual(Type::Int8Ty); + const Type* SBPTy = PointerType::getUnqual(Type::Int8Ty); // Create the call to "__llvm_sjljeh_throw_longjmp". This takes the // same parameters as "longjmp", except that the buffer is cast to a @@ -312,7 +311,7 @@ AllocaInst* LowerSetJmp::GetSetJmpMap(Function* Func) assert(Inst && "Couldn't find even ONE instruction in entry block!"); // Fill in the alloca and call to initialize the SJ map. - const Type *SBPTy = Func->getContext().getPointerTypeUnqual(Type::Int8Ty); + const Type *SBPTy = PointerType::getUnqual(Type::Int8Ty); AllocaInst* Map = new AllocaInst(SBPTy, 0, "SJMap", Inst); CallInst::Create(InitSJMap, Map, "", Inst); return SJMap[Func] = Map; @@ -378,7 +377,7 @@ void LowerSetJmp::TransformSetJmpCall(CallInst* Inst) Function* Func = ABlock->getParent(); // Add this setjmp to the setjmp map. - const Type* SBPTy = Inst->getContext().getPointerTypeUnqual(Type::Int8Ty); + const Type* SBPTy = PointerType::getUnqual(Type::Int8Ty); CastInst* BufPtr = new BitCastInst(Inst->getOperand(1), SBPTy, "SBJmpBuf", Inst); std::vector Args = diff --git a/lib/Transforms/IPO/RaiseAllocations.cpp b/lib/Transforms/IPO/RaiseAllocations.cpp index 3c9178ed0ad..943d3cf1605 100644 --- a/lib/Transforms/IPO/RaiseAllocations.cpp +++ b/lib/Transforms/IPO/RaiseAllocations.cpp @@ -70,8 +70,6 @@ ModulePass *llvm::createRaiseAllocationsPass() { // function into the appropriate instruction. // void RaiseAllocations::doInitialization(Module &M) { - LLVMContext &Context = M.getContext(); - // Get Malloc and free prototypes if they exist! MallocFunc = M.getFunction("malloc"); if (MallocFunc) { @@ -79,7 +77,7 @@ void RaiseAllocations::doInitialization(Module &M) { // Get the expected prototype for malloc const FunctionType *Malloc1Type = - Context.getFunctionType(Context.getPointerTypeUnqual(Type::Int8Ty), + FunctionType::get(PointerType::getUnqual(Type::Int8Ty), std::vector(1, Type::Int64Ty), false); // Chck to see if we got the expected malloc @@ -87,14 +85,14 @@ void RaiseAllocations::doInitialization(Module &M) { // Check to see if the prototype is wrong, giving us i8*(i32) * malloc // This handles the common declaration of: 'void *malloc(unsigned);' const FunctionType *Malloc2Type = - Context.getFunctionType(Context.getPointerTypeUnqual(Type::Int8Ty), + FunctionType::get(PointerType::getUnqual(Type::Int8Ty), std::vector(1, Type::Int32Ty), false); if (TyWeHave != Malloc2Type) { // Check to see if the prototype is missing, giving us // i8*(...) * malloc // This handles the common declaration of: 'void *malloc();' const FunctionType *Malloc3Type = - Context.getFunctionType(Context.getPointerTypeUnqual(Type::Int8Ty), + FunctionType::get(PointerType::getUnqual(Type::Int8Ty), true); if (TyWeHave != Malloc3Type) // Give up @@ -108,21 +106,21 @@ void RaiseAllocations::doInitialization(Module &M) { const FunctionType* TyWeHave = FreeFunc->getFunctionType(); // Get the expected prototype for void free(i8*) - const FunctionType *Free1Type = Context.getFunctionType(Type::VoidTy, - std::vector(1, Context.getPointerTypeUnqual(Type::Int8Ty)), + const FunctionType *Free1Type = FunctionType::get(Type::VoidTy, + std::vector(1, PointerType::getUnqual(Type::Int8Ty)), false); if (TyWeHave != Free1Type) { // Check to see if the prototype was forgotten, giving us // void (...) * free // This handles the common forward declaration of: 'void free();' - const FunctionType* Free2Type = Context.getFunctionType(Type::VoidTy, + const FunctionType* Free2Type = FunctionType::get(Type::VoidTy, true); if (TyWeHave != Free2Type) { // One last try, check to see if we can find free as // int (...)* free. This handles the case where NOTHING was declared. - const FunctionType* Free3Type = Context.getFunctionType(Type::Int32Ty, + const FunctionType* Free3Type = FunctionType::get(Type::Int32Ty, true); if (TyWeHave != Free3Type) { @@ -224,7 +222,7 @@ bool RaiseAllocations::runOnModule(Module &M) { Value *Source = *CS.arg_begin(); if (!isa(Source->getType())) Source = new IntToPtrInst(Source, - Context.getPointerTypeUnqual(Type::Int8Ty), + PointerType::getUnqual(Type::Int8Ty), "FreePtrCast", I); new FreeInst(Source, I); diff --git a/lib/Transforms/IPO/StructRetPromotion.cpp b/lib/Transforms/IPO/StructRetPromotion.cpp index 8d6671dbb78..a2413597a3e 100644 --- a/lib/Transforms/IPO/StructRetPromotion.cpp +++ b/lib/Transforms/IPO/StructRetPromotion.cpp @@ -232,8 +232,7 @@ Function *SRETPromotion::cloneFunctionBody(Function *F, AttributesVec.push_back(AttributeWithIndex::get(~0, attrs)); - FunctionType *NFTy = - F->getContext().getFunctionType(STy, Params, FTy->isVarArg()); + FunctionType *NFTy = FunctionType::get(STy, Params, FTy->isVarArg()); Function *NF = Function::Create(NFTy, F->getLinkage()); NF->takeName(F); NF->copyAttributesFrom(F); diff --git a/lib/Transforms/Instrumentation/BlockProfiling.cpp b/lib/Transforms/Instrumentation/BlockProfiling.cpp index 065bd1125d2..700260db46d 100644 --- a/lib/Transforms/Instrumentation/BlockProfiling.cpp +++ b/lib/Transforms/Instrumentation/BlockProfiling.cpp @@ -63,7 +63,7 @@ bool FunctionProfiler::runOnModule(Module &M) { if (!I->isDeclaration()) ++NumFunctions; - const Type *ATy = M.getContext().getArrayType(Type::Int32Ty, NumFunctions); + const Type *ATy = ArrayType::get(Type::Int32Ty, NumFunctions); GlobalVariable *Counters = new GlobalVariable(M, ATy, false, GlobalValue::InternalLinkage, M.getContext().getNullValue(ATy), "FuncProfCounters"); @@ -108,7 +108,7 @@ bool BlockProfiler::runOnModule(Module &M) { for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) NumBlocks += I->size(); - const Type *ATy = M.getContext().getArrayType(Type::Int32Ty, NumBlocks); + const Type *ATy = ArrayType::get(Type::Int32Ty, NumBlocks); GlobalVariable *Counters = new GlobalVariable(M, ATy, false, GlobalValue::InternalLinkage, M.getContext().getNullValue(ATy), "BlockProfCounters"); diff --git a/lib/Transforms/Instrumentation/EdgeProfiling.cpp b/lib/Transforms/Instrumentation/EdgeProfiling.cpp index d1aa3701870..b900945dace 100644 --- a/lib/Transforms/Instrumentation/EdgeProfiling.cpp +++ b/lib/Transforms/Instrumentation/EdgeProfiling.cpp @@ -64,7 +64,7 @@ bool EdgeProfiler::runOnModule(Module &M) { NumEdges += BB->getTerminator()->getNumSuccessors(); } - const Type *ATy = M.getContext().getArrayType(Type::Int32Ty, NumEdges); + const Type *ATy = ArrayType::get(Type::Int32Ty, NumEdges); GlobalVariable *Counters = new GlobalVariable(M, ATy, false, GlobalValue::InternalLinkage, M.getContext().getNullValue(ATy), "EdgeProfCounters"); diff --git a/lib/Transforms/Instrumentation/ProfilingUtils.cpp b/lib/Transforms/Instrumentation/ProfilingUtils.cpp index 70ce86a2c37..d5752b72d2d 100644 --- a/lib/Transforms/Instrumentation/ProfilingUtils.cpp +++ b/lib/Transforms/Instrumentation/ProfilingUtils.cpp @@ -25,8 +25,8 @@ void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName, GlobalValue *Array) { LLVMContext &Context = MainFn->getContext(); const Type *ArgVTy = - Context.getPointerTypeUnqual(Context.getPointerTypeUnqual(Type::Int8Ty)); - const PointerType *UIntPtr = Context.getPointerTypeUnqual(Type::Int32Ty); + PointerType::getUnqual(PointerType::getUnqual(Type::Int8Ty)); + const PointerType *UIntPtr = PointerType::getUnqual(Type::Int32Ty); Module &M = *MainFn->getParent(); Constant *InitFn = M.getOrInsertFunction(FnName, Type::Int32Ty, Type::Int32Ty, ArgVTy, UIntPtr, Type::Int32Ty, diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 63dddaeee1a..554591ac252 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -7681,7 +7681,7 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1, case 32 : case 64 : case 128: - SExtType = Context->getIntegerType(Ty->getBitWidth() - ShiftAmt1); + SExtType = IntegerType::get(Ty->getBitWidth() - ShiftAmt1); break; default: break; } @@ -9697,7 +9697,7 @@ Instruction *InstCombiner::SimplifyMemTransfer(MemIntrinsic *MI) { // Use an integer load+store unless we can find something better. Type *NewPtrTy = - Context->getPointerTypeUnqual(Context->getIntegerType(Size<<3)); + PointerType::getUnqual(IntegerType::get(Size<<3)); // Memcpy forces the use of i8* for the source and destination. That means // that if you're using memcpy to move one double around, you'll get a cast @@ -9726,7 +9726,7 @@ Instruction *InstCombiner::SimplifyMemTransfer(MemIntrinsic *MI) { } if (SrcETy->isSingleValueType()) - NewPtrTy = Context->getPointerTypeUnqual(SrcETy); + NewPtrTy = PointerType::getUnqual(SrcETy); } } @@ -9768,10 +9768,10 @@ Instruction *InstCombiner::SimplifyMemSet(MemSetInst *MI) { // memset(s,c,n) -> store s, c (for n=1,2,4,8) if (Len <= 8 && isPowerOf2_32((uint32_t)Len)) { - const Type *ITy = Context->getIntegerType(Len*8); // n=1 -> i8. + const Type *ITy = IntegerType::get(Len*8); // n=1 -> i8. Value *Dest = MI->getDest(); - Dest = InsertBitCastBefore(Dest, Context->getPointerTypeUnqual(ITy), *MI); + Dest = InsertBitCastBefore(Dest, PointerType::getUnqual(ITy), *MI); // Alignment 0 is identity for alignment 1 for memset, but not store. if (Alignment == 0) Alignment = 1; @@ -9875,7 +9875,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) { // Turn X86 loadups -> load if the pointer is known aligned. if (GetOrEnforceKnownAlignment(II->getOperand(1), 16) >= 16) { Value *Ptr = InsertBitCastBefore(II->getOperand(1), - Context->getPointerTypeUnqual(II->getType()), + PointerType::getUnqual(II->getType()), CI); return new LoadInst(Ptr); } @@ -9885,7 +9885,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) { // Turn stvx -> store if the pointer is known aligned. if (GetOrEnforceKnownAlignment(II->getOperand(2), 16) >= 16) { const Type *OpPtrTy = - Context->getPointerTypeUnqual(II->getOperand(1)->getType()); + PointerType::getUnqual(II->getOperand(1)->getType()); Value *Ptr = InsertBitCastBefore(II->getOperand(2), OpPtrTy, CI); return new StoreInst(II->getOperand(1), Ptr); } @@ -9896,7 +9896,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) { // Turn X86 storeu -> store if the pointer is known aligned. if (GetOrEnforceKnownAlignment(II->getOperand(1), 16) >= 16) { const Type *OpPtrTy = - Context->getPointerTypeUnqual(II->getOperand(2)->getType()); + PointerType::getUnqual(II->getOperand(2)->getType()); Value *Ptr = InsertBitCastBefore(II->getOperand(1), OpPtrTy, CI); return new StoreInst(II->getOperand(2), Ptr); } @@ -10062,7 +10062,7 @@ 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(Context->getPointerTypeUnqual(Type::Int1Ty)), + Context->getUndef(PointerType::getUnqual(Type::Int1Ty)), OldCall); if (!OldCall->use_empty()) OldCall->replaceAllUsesWith(Context->getUndef(OldCall->getType())); @@ -10076,7 +10076,7 @@ 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(Context->getPointerTypeUnqual(Type::Int1Ty)), + Context->getUndef(PointerType::getUnqual(Type::Int1Ty)), CS.getInstruction()); if (!CS.getInstruction()->use_empty()) @@ -10457,13 +10457,12 @@ Instruction *InstCombiner::transformCallThroughTrampoline(CallSite CS) { // Replace the trampoline call with a direct call. Let the generic // code sort out any function type mismatches. - FunctionType *NewFTy = - Context->getFunctionType(FTy->getReturnType(), NewTypes, + FunctionType *NewFTy = FunctionType::get(FTy->getReturnType(), NewTypes, FTy->isVarArg()); Constant *NewCallee = - NestF->getType() == Context->getPointerTypeUnqual(NewFTy) ? + NestF->getType() == PointerType::getUnqual(NewFTy) ? NestF : ConstantExpr::getBitCast(NestF, - Context->getPointerTypeUnqual(NewFTy)); + PointerType::getUnqual(NewFTy)); const AttrListPtr &NewPAL = AttrListPtr::get(NewAttrs.begin(), NewAttrs.end()); @@ -11367,7 +11366,7 @@ Instruction *InstCombiner::visitAllocationInst(AllocationInst &AI) { if (AI.isArrayAllocation()) { // Check C != 1 if (const ConstantInt *C = dyn_cast(AI.getArraySize())) { const Type *NewTy = - Context->getArrayType(AI.getAllocatedType(), C->getZExtValue()); + ArrayType::get(AI.getAllocatedType(), C->getZExtValue()); AllocationInst *New = 0; // Create and insert the replacement instruction... @@ -11427,7 +11426,7 @@ Instruction *InstCombiner::visitFreeInst(FreeInst &FI) { if (isa(Op)) { // Insert a new store to null because we cannot modify the CFG here. new StoreInst(Context->getTrue(), - Context->getUndef(Context->getPointerTypeUnqual(Type::Int1Ty)), &FI); + Context->getUndef(PointerType::getUnqual(Type::Int1Ty)), &FI); return EraseInstFromFunction(FI); } @@ -11734,7 +11733,7 @@ static Instruction *InstCombineStoreToCast(InstCombiner &IC, StoreInst &SI) { } } - SrcTy = Context->getPointerType(SrcPTy, SrcTy->getAddressSpace()); + SrcTy = PointerType::get(SrcPTy, SrcTy->getAddressSpace()); } if (!SrcPTy->isInteger() && !isa(SrcPTy)) @@ -12456,7 +12455,7 @@ Instruction *InstCombiner::visitExtractElementInst(ExtractElementInst &EI) { unsigned AS = cast(I->getOperand(0)->getType())->getAddressSpace(); Value *Ptr = InsertBitCastBefore(I->getOperand(0), - Context->getPointerType(EI.getType(), AS),EI); + PointerType::get(EI.getType(), AS),EI); GetElementPtrInst *GEP = GetElementPtrInst::Create(Ptr, EI.getOperand(1), I->getName()+".gep"); cast(GEP)->setIsInBounds(true); diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 9fd0fdf0b0d..619e1f10935 100644 --- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -1947,7 +1947,7 @@ ICmpInst *LoopStrengthReduce::ChangeCompareStride(Loop *L, ICmpInst *Cond, NewCmpTy = NewCmpLHS->getType(); NewTyBits = SE->getTypeSizeInBits(NewCmpTy); - const Type *NewCmpIntTy = Context.getIntegerType(NewTyBits); + const Type *NewCmpIntTy = IntegerType::get(NewTyBits); if (RequiresTypeConversion(NewCmpTy, CmpTy)) { // Check if it is possible to rewrite it using // an iv / stride of a smaller integer type. diff --git a/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/lib/Transforms/Scalar/MemCpyOptimizer.cpp index afbed3741f4..224a1366483 100644 --- a/lib/Transforms/Scalar/MemCpyOptimizer.cpp +++ b/lib/Transforms/Scalar/MemCpyOptimizer.cpp @@ -352,7 +352,6 @@ bool MemCpyOpt::processStore(StoreInst *SI, BasicBlock::iterator& BBI) { TargetData &TD = getAnalysis(); AliasAnalysis &AA = getAnalysis(); - LLVMContext &Context = SI->getContext(); Module *M = SI->getParent()->getParent()->getParent(); // Okay, so we now have a single store that can be splatable. Scan to find @@ -441,7 +440,7 @@ bool MemCpyOpt::processStore(StoreInst *SI, BasicBlock::iterator& BBI) { StartPtr = Range.StartPtr; // Cast the start ptr to be i8* as memset requires. - const Type *i8Ptr = Context.getPointerTypeUnqual(Type::Int8Ty); + const Type *i8Ptr = PointerType::getUnqual(Type::Int8Ty); if (StartPtr->getType() != i8Ptr) StartPtr = new BitCastInst(StartPtr, i8Ptr, StartPtr->getName(), InsertPt); diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp index 7ca2c5e7f37..73dd23cf682 100644 --- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -307,7 +307,7 @@ bool SROA::performScalarRepl(Function &F) { DOUT << "CONVERT TO SCALAR INTEGER: " << *AI << "\n"; // Create and insert the integer alloca. - const Type *NewTy = F.getContext().getIntegerType(AllocaSize*8); + const Type *NewTy = IntegerType::get(AllocaSize*8); NewAI = new AllocaInst(NewTy, 0, "", AI->getParent()->begin()); ConvertUsesToScalar(AI, NewAI, 0); } @@ -900,7 +900,6 @@ void SROA::RewriteStoreUserOfWholeAlloca(StoreInst *SI, SmallVector &NewElts){ // Extract each element out of the integer according to its structure offset // and store the element value to the individual alloca. - LLVMContext &Context = SI->getContext(); Value *SrcVal = SI->getOperand(0); const Type *AllocaEltTy = AI->getType()->getElementType(); uint64_t AllocaSizeBits = TD->getTypeAllocSizeInBits(AllocaEltTy); @@ -914,7 +913,7 @@ void SROA::RewriteStoreUserOfWholeAlloca(StoreInst *SI, // Handle tail padding by extending the operand if (TD->getTypeSizeInBits(SrcVal->getType()) != AllocaSizeBits) SrcVal = new ZExtInst(SrcVal, - Context.getIntegerType(AllocaSizeBits), "", SI); + IntegerType::get(AllocaSizeBits), "", SI); DOUT << "PROMOTING STORE TO WHOLE ALLOCA: " << *AI << *SI; @@ -946,7 +945,7 @@ void SROA::RewriteStoreUserOfWholeAlloca(StoreInst *SI, if (FieldSizeBits != AllocaSizeBits) EltVal = new TruncInst(EltVal, - Context.getIntegerType(FieldSizeBits), "", SI); + IntegerType::get(FieldSizeBits), "", SI); Value *DestField = NewElts[i]; if (EltVal->getType() == FieldTy) { // Storing to an integer field of this size, just do it. @@ -956,7 +955,7 @@ void SROA::RewriteStoreUserOfWholeAlloca(StoreInst *SI, } else { // Otherwise, bitcast the dest pointer (for aggregates). DestField = new BitCastInst(DestField, - Context.getPointerTypeUnqual(EltVal->getType()), + PointerType::getUnqual(EltVal->getType()), "", SI); } new StoreInst(EltVal, DestField, SI); @@ -989,7 +988,7 @@ void SROA::RewriteStoreUserOfWholeAlloca(StoreInst *SI, // Truncate down to an integer of the right size. if (ElementSizeBits != AllocaSizeBits) EltVal = new TruncInst(EltVal, - Context.getIntegerType(ElementSizeBits),"",SI); + IntegerType::get(ElementSizeBits),"",SI); Value *DestField = NewElts[i]; if (EltVal->getType() == ArrayEltTy) { // Storing to an integer field of this size, just do it. @@ -999,7 +998,7 @@ void SROA::RewriteStoreUserOfWholeAlloca(StoreInst *SI, } else { // Otherwise, bitcast the dest pointer (for aggregates). DestField = new BitCastInst(DestField, - Context.getPointerTypeUnqual(EltVal->getType()), + PointerType::getUnqual(EltVal->getType()), "", SI); } new StoreInst(EltVal, DestField, SI); @@ -1046,7 +1045,7 @@ void SROA::RewriteLoadUserOfWholeAlloca(LoadInst *LI, AllocationInst *AI, LLVMContext &Context = LI->getContext(); Value *ResultVal = - Context.getNullValue(Context.getIntegerType(AllocaSizeBits)); + Context.getNullValue(IntegerType::get(AllocaSizeBits)); for (unsigned i = 0, e = NewElts.size(); i != e; ++i) { // Load the value from the alloca. If the NewElt is an aggregate, cast @@ -1059,11 +1058,11 @@ void SROA::RewriteLoadUserOfWholeAlloca(LoadInst *LI, AllocationInst *AI, // Ignore zero sized fields like {}, they obviously contain no data. if (FieldSizeBits == 0) continue; - const IntegerType *FieldIntTy = Context.getIntegerType(FieldSizeBits); + const IntegerType *FieldIntTy = IntegerType::get(FieldSizeBits); if (!isa(FieldTy) && !FieldTy->isFloatingPoint() && !isa(FieldTy)) SrcField = new BitCastInst(SrcField, - Context.getPointerTypeUnqual(FieldIntTy), + PointerType::getUnqual(FieldIntTy), "", LI); SrcField = new LoadInst(SrcField, "sroa.load.elt", LI); @@ -1297,7 +1296,7 @@ static void MergeInType(const Type *In, uint64_t Offset, const Type *&VecTy, cast(VecTy)->getElementType() ->getPrimitiveSizeInBits()/8 == EltSize)) { if (VecTy == 0) - VecTy = In->getContext().getVectorType(In, AllocaSize/EltSize); + VecTy = VectorType::get(In, AllocaSize/EltSize); return; } } @@ -1623,10 +1622,10 @@ Value *SROA::ConvertScalar_ExtractValue(Value *FromVal, const Type *ToType, unsigned LIBitWidth = TD->getTypeSizeInBits(ToType); if (LIBitWidth < NTy->getBitWidth()) FromVal = - Builder.CreateTrunc(FromVal, Context.getIntegerType(LIBitWidth), "tmp"); + Builder.CreateTrunc(FromVal, IntegerType::get(LIBitWidth), "tmp"); else if (LIBitWidth > NTy->getBitWidth()) FromVal = - Builder.CreateZExt(FromVal, Context.getIntegerType(LIBitWidth), "tmp"); + Builder.CreateZExt(FromVal, IntegerType::get(LIBitWidth), "tmp"); // If the result is an integer, this is a trunc or bitcast. if (isa(ToType)) { @@ -1711,7 +1710,7 @@ Value *SROA::ConvertScalar_InsertValue(Value *SV, Value *Old, unsigned SrcStoreWidth = TD->getTypeStoreSizeInBits(SV->getType()); unsigned DestStoreWidth = TD->getTypeStoreSizeInBits(AllocaType); if (SV->getType()->isFloatingPoint() || isa(SV->getType())) - SV = Builder.CreateBitCast(SV, Context.getIntegerType(SrcWidth), "tmp"); + SV = Builder.CreateBitCast(SV, IntegerType::get(SrcWidth), "tmp"); else if (isa(SV->getType())) SV = Builder.CreatePtrToInt(SV, TD->getIntPtrType(), "tmp"); diff --git a/lib/Transforms/Scalar/SimplifyLibCalls.cpp b/lib/Transforms/Scalar/SimplifyLibCalls.cpp index c421ee24068..04bc39b4e0a 100644 --- a/lib/Transforms/Scalar/SimplifyLibCalls.cpp +++ b/lib/Transforms/Scalar/SimplifyLibCalls.cpp @@ -126,7 +126,7 @@ public: /// CastToCStr - Return V if it is an i8*, otherwise cast it to i8*. Value *LibCallOptimization::CastToCStr(Value *V, IRBuilder<> &B) { return - B.CreateBitCast(V, Context->getPointerTypeUnqual(Type::Int8Ty), "cstr"); + B.CreateBitCast(V, PointerType::getUnqual(Type::Int8Ty), "cstr"); } /// EmitStrLen - Emit a call to the strlen function to the builder, for the @@ -140,7 +140,7 @@ Value *LibCallOptimization::EmitStrLen(Value *Ptr, IRBuilder<> &B) { Constant *StrLen =M->getOrInsertFunction("strlen", AttrListPtr::get(AWI, 2), TD->getIntPtrType(), - Context->getPointerTypeUnqual(Type::Int8Ty), + PointerType::getUnqual(Type::Int8Ty), NULL); CallInst *CI = B.CreateCall(StrLen, CastToCStr(Ptr, B), "strlen"); if (const Function *F = dyn_cast(StrLen->stripPointerCasts())) @@ -171,8 +171,8 @@ Value *LibCallOptimization::EmitMemChr(Value *Ptr, Value *Val, AWI = AttributeWithIndex::get(~0u, Attribute::ReadOnly | Attribute::NoUnwind); Value *MemChr = M->getOrInsertFunction("memchr", AttrListPtr::get(&AWI, 1), - Context->getPointerTypeUnqual(Type::Int8Ty), - Context->getPointerTypeUnqual(Type::Int8Ty), + PointerType::getUnqual(Type::Int8Ty), + PointerType::getUnqual(Type::Int8Ty), Type::Int32Ty, TD->getIntPtrType(), NULL); CallInst *CI = B.CreateCall3(MemChr, CastToCStr(Ptr, B), Val, Len, "memchr"); @@ -195,8 +195,8 @@ Value *LibCallOptimization::EmitMemCmp(Value *Ptr1, Value *Ptr2, Value *MemCmp = M->getOrInsertFunction("memcmp", AttrListPtr::get(AWI, 3), Type::Int32Ty, - Context->getPointerTypeUnqual(Type::Int8Ty), - Context->getPointerTypeUnqual(Type::Int8Ty), + PointerType::getUnqual(Type::Int8Ty), + PointerType::getUnqual(Type::Int8Ty), TD->getIntPtrType(), NULL); CallInst *CI = B.CreateCall3(MemCmp, CastToCStr(Ptr1, B), CastToCStr(Ptr2, B), Len, "memcmp"); @@ -274,7 +274,7 @@ void LibCallOptimization::EmitPutS(Value *Str, IRBuilder<> &B) { Value *PutS = M->getOrInsertFunction("puts", AttrListPtr::get(AWI, 2), Type::Int32Ty, - Context->getPointerTypeUnqual(Type::Int8Ty), + PointerType::getUnqual(Type::Int8Ty), NULL); CallInst *CI = B.CreateCall(PutS, CastToCStr(Str, B), "puts"); if (const Function *F = dyn_cast(PutS->stripPointerCasts())) @@ -314,11 +314,11 @@ void LibCallOptimization::EmitFPutS(Value *Str, Value *File, IRBuilder<> &B) { Constant *F; if (isa(File->getType())) F = M->getOrInsertFunction("fputs", AttrListPtr::get(AWI, 3), Type::Int32Ty, - Context->getPointerTypeUnqual(Type::Int8Ty), + PointerType::getUnqual(Type::Int8Ty), File->getType(), NULL); else F = M->getOrInsertFunction("fputs", Type::Int32Ty, - Context->getPointerTypeUnqual(Type::Int8Ty), + PointerType::getUnqual(Type::Int8Ty), File->getType(), NULL); CallInst *CI = B.CreateCall2(F, CastToCStr(Str, B), File, "fputs"); @@ -339,12 +339,12 @@ void LibCallOptimization::EmitFWrite(Value *Ptr, Value *Size, Value *File, if (isa(File->getType())) F = M->getOrInsertFunction("fwrite", AttrListPtr::get(AWI, 3), TD->getIntPtrType(), - Context->getPointerTypeUnqual(Type::Int8Ty), + PointerType::getUnqual(Type::Int8Ty), TD->getIntPtrType(), TD->getIntPtrType(), File->getType(), NULL); else F = M->getOrInsertFunction("fwrite", TD->getIntPtrType(), - Context->getPointerTypeUnqual(Type::Int8Ty), + PointerType::getUnqual(Type::Int8Ty), TD->getIntPtrType(), TD->getIntPtrType(), File->getType(), NULL); CallInst *CI = B.CreateCall4(F, CastToCStr(Ptr, B), Size, @@ -555,7 +555,7 @@ struct VISIBILITY_HIDDEN StrCatOpt : public LibCallOptimization { // Verify the "strcat" function prototype. const FunctionType *FT = Callee->getFunctionType(); if (FT->getNumParams() != 2 || - FT->getReturnType() != Context->getPointerTypeUnqual(Type::Int8Ty) || + FT->getReturnType() != PointerType::getUnqual(Type::Int8Ty) || FT->getParamType(0) != FT->getReturnType() || FT->getParamType(1) != FT->getReturnType()) return 0; @@ -602,7 +602,7 @@ struct VISIBILITY_HIDDEN StrNCatOpt : public StrCatOpt { // Verify the "strncat" function prototype. const FunctionType *FT = Callee->getFunctionType(); if (FT->getNumParams() != 3 || - FT->getReturnType() != Context->getPointerTypeUnqual(Type::Int8Ty) || + FT->getReturnType() != PointerType::getUnqual(Type::Int8Ty) || FT->getParamType(0) != FT->getReturnType() || FT->getParamType(1) != FT->getReturnType() || !isa(FT->getParamType(2))) @@ -647,7 +647,7 @@ struct VISIBILITY_HIDDEN StrChrOpt : public LibCallOptimization { // Verify the "strchr" function prototype. const FunctionType *FT = Callee->getFunctionType(); if (FT->getNumParams() != 2 || - FT->getReturnType() != Context->getPointerTypeUnqual(Type::Int8Ty) || + FT->getReturnType() != PointerType::getUnqual(Type::Int8Ty) || FT->getParamType(0) != FT->getReturnType()) return 0; @@ -701,7 +701,7 @@ struct VISIBILITY_HIDDEN StrCmpOpt : public LibCallOptimization { const FunctionType *FT = Callee->getFunctionType(); if (FT->getNumParams() != 2 || FT->getReturnType() != Type::Int32Ty || FT->getParamType(0) != FT->getParamType(1) || - FT->getParamType(0) != Context->getPointerTypeUnqual(Type::Int8Ty)) + FT->getParamType(0) != PointerType::getUnqual(Type::Int8Ty)) return 0; Value *Str1P = CI->getOperand(1), *Str2P = CI->getOperand(2); @@ -745,7 +745,7 @@ struct VISIBILITY_HIDDEN StrNCmpOpt : public LibCallOptimization { const FunctionType *FT = Callee->getFunctionType(); if (FT->getNumParams() != 3 || FT->getReturnType() != Type::Int32Ty || FT->getParamType(0) != FT->getParamType(1) || - FT->getParamType(0) != Context->getPointerTypeUnqual(Type::Int8Ty) || + FT->getParamType(0) != PointerType::getUnqual(Type::Int8Ty) || !isa(FT->getParamType(2))) return 0; @@ -791,7 +791,7 @@ struct VISIBILITY_HIDDEN StrCpyOpt : public LibCallOptimization { const FunctionType *FT = Callee->getFunctionType(); if (FT->getNumParams() != 2 || FT->getReturnType() != FT->getParamType(0) || FT->getParamType(0) != FT->getParamType(1) || - FT->getParamType(0) != Context->getPointerTypeUnqual(Type::Int8Ty)) + FT->getParamType(0) != PointerType::getUnqual(Type::Int8Ty)) return 0; Value *Dst = CI->getOperand(1), *Src = CI->getOperand(2); @@ -818,7 +818,7 @@ struct VISIBILITY_HIDDEN StrNCpyOpt : public LibCallOptimization { const FunctionType *FT = Callee->getFunctionType(); if (FT->getNumParams() != 3 || FT->getReturnType() != FT->getParamType(0) || FT->getParamType(0) != FT->getParamType(1) || - FT->getParamType(0) != Context->getPointerTypeUnqual(Type::Int8Ty) || + FT->getParamType(0) != PointerType::getUnqual(Type::Int8Ty) || !isa(FT->getParamType(2))) return 0; @@ -863,7 +863,7 @@ struct VISIBILITY_HIDDEN StrLenOpt : public LibCallOptimization { virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) { const FunctionType *FT = Callee->getFunctionType(); if (FT->getNumParams() != 1 || - FT->getParamType(0) != Context->getPointerTypeUnqual(Type::Int8Ty) || + FT->getParamType(0) != PointerType::getUnqual(Type::Int8Ty) || !isa(FT->getReturnType())) return 0; @@ -937,7 +937,7 @@ struct VISIBILITY_HIDDEN MemCmpOpt : public LibCallOptimization { // memcmp(S1,S2,2) != 0 -> (*(short*)LHS ^ *(short*)RHS) != 0 // memcmp(S1,S2,4) != 0 -> (*(int*)LHS ^ *(int*)RHS) != 0 if ((Len == 2 || Len == 4) && IsOnlyUsedInZeroEqualityComparison(CI)) { - const Type *PTy = Context->getPointerTypeUnqual(Len == 2 ? + const Type *PTy = PointerType::getUnqual(Len == 2 ? Type::Int16Ty : Type::Int32Ty); LHS = B.CreateBitCast(LHS, PTy, "tmp"); RHS = B.CreateBitCast(RHS, PTy, "tmp"); diff --git a/lib/Transforms/Utils/CloneFunction.cpp b/lib/Transforms/Utils/CloneFunction.cpp index dae39b7a790..7b8a8a498bc 100644 --- a/lib/Transforms/Utils/CloneFunction.cpp +++ b/lib/Transforms/Utils/CloneFunction.cpp @@ -151,8 +151,7 @@ Function *llvm::CloneFunction(const Function *F, ArgTypes.push_back(I->getType()); // Create a new function type... - FunctionType *FTy = - F->getContext().getFunctionType(F->getFunctionType()->getReturnType(), + FunctionType *FTy = FunctionType::get(F->getFunctionType()->getReturnType(), ArgTypes, F->getFunctionType()->isVarArg()); // Create the new function... diff --git a/lib/Transforms/Utils/CodeExtractor.cpp b/lib/Transforms/Utils/CodeExtractor.cpp index ab10baa7721..d897c2acd14 100644 --- a/lib/Transforms/Utils/CodeExtractor.cpp +++ b/lib/Transforms/Utils/CodeExtractor.cpp @@ -266,8 +266,7 @@ Function *CodeExtractor::constructFunction(const Values &inputs, if (AggregateArgs) paramTy.push_back((*I)->getType()); else - paramTy.push_back( - header->getContext().getPointerTypeUnqual((*I)->getType())); + paramTy.push_back(PointerType::getUnqual((*I)->getType())); } DOUT << "Function type: " << *RetTy << " f("; @@ -278,12 +277,12 @@ Function *CodeExtractor::constructFunction(const Values &inputs, if (AggregateArgs && (inputs.size() + outputs.size() > 0)) { PointerType *StructPtr = - Context.getPointerTypeUnqual(Context.getStructType(paramTy)); + PointerType::getUnqual(StructType::get(paramTy)); paramTy.clear(); paramTy.push_back(StructPtr); } const FunctionType *funcType = - Context.getFunctionType(RetTy, paramTy, false); + FunctionType::get(RetTy, paramTy, false); // Create the new function Function *newFunction = Function::Create(funcType, @@ -387,7 +386,7 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer, ArgTypes.push_back((*v)->getType()); // Allocate a struct at the beginning of this function - Type *StructArgTy = Context.getStructType(ArgTypes); + Type *StructArgTy = StructType::get(ArgTypes); Struct = new AllocaInst(StructArgTy, 0, "structArg", codeReplacer->getParent()->begin()->begin()); diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp index cdde678d75c..43b996af3f5 100644 --- a/lib/Transforms/Utils/InlineFunction.cpp +++ b/lib/Transforms/Utils/InlineFunction.cpp @@ -304,7 +304,7 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) { if (CalledFunc->paramHasAttr(ArgNo+1, Attribute::ByVal) && !CalledFunc->onlyReadsMemory()) { const Type *AggTy = cast(I->getType())->getElementType(); - const Type *VoidPtrTy = Context.getPointerTypeUnqual(Type::Int8Ty); + const Type *VoidPtrTy = PointerType::getUnqual(Type::Int8Ty); // Create the alloca. If we have TargetData, use nice alignment. unsigned Align = 1; diff --git a/lib/Transforms/Utils/LowerAllocations.cpp b/lib/Transforms/Utils/LowerAllocations.cpp index 522166d6f2d..305897c8ffb 100644 --- a/lib/Transforms/Utils/LowerAllocations.cpp +++ b/lib/Transforms/Utils/LowerAllocations.cpp @@ -87,10 +87,10 @@ Pass *llvm::createLowerAllocationsPass(bool LowerMallocArgToInteger) { // This function is always successful. // bool LowerAllocations::doInitialization(Module &M) { - const Type *BPTy = M.getContext().getPointerTypeUnqual(Type::Int8Ty); + const Type *BPTy = PointerType::getUnqual(Type::Int8Ty); // Prototype malloc as "char* malloc(...)", because we don't know in // doInitialization whether size_t is int or long. - FunctionType *FT = M.getContext().getFunctionType(BPTy, true); + FunctionType *FT = FunctionType::get(BPTy, true); MallocFunc = M.getOrInsertFunction("malloc", FT); FreeFunc = M.getOrInsertFunction("free" , Type::VoidTy, BPTy, (Type *)0); return true; @@ -166,7 +166,7 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) { } else if (FreeInst *FI = dyn_cast(I)) { Value *PtrCast = new BitCastInst(FI->getOperand(0), - Context.getPointerTypeUnqual(Type::Int8Ty), "", I); + PointerType::getUnqual(Type::Int8Ty), "", I); // Insert a call to the free function... CallInst::Create(FreeFunc, PtrCast, "", I)->setTailCall(); diff --git a/lib/Transforms/Utils/LowerInvoke.cpp b/lib/Transforms/Utils/LowerInvoke.cpp index b880734c14b..a9d218c5fd7 100644 --- a/lib/Transforms/Utils/LowerInvoke.cpp +++ b/lib/Transforms/Utils/LowerInvoke.cpp @@ -117,26 +117,26 @@ FunctionPass *llvm::createLowerInvokePass(const TargetLowering *TLI) { bool LowerInvoke::doInitialization(Module &M) { LLVMContext &Context = M.getContext(); - const Type *VoidPtrTy = Context.getPointerTypeUnqual(Type::Int8Ty); + const Type *VoidPtrTy = PointerType::getUnqual(Type::Int8Ty); AbortMessage = 0; if (ExpensiveEHSupport) { // Insert a type for the linked list of jump buffers. unsigned JBSize = TLI ? TLI->getJumpBufSize() : 0; JBSize = JBSize ? JBSize : 200; - const Type *JmpBufTy = Context.getArrayType(VoidPtrTy, JBSize); + const Type *JmpBufTy = ArrayType::get(VoidPtrTy, JBSize); { // The type is recursive, so use a type holder. std::vector Elements; Elements.push_back(JmpBufTy); - OpaqueType *OT = Context.getOpaqueType(); - Elements.push_back(Context.getPointerTypeUnqual(OT)); - PATypeHolder JBLType(Context.getStructType(Elements)); + OpaqueType *OT = OpaqueType::get(); + Elements.push_back(PointerType::getUnqual(OT)); + PATypeHolder JBLType(StructType::get(Elements)); OT->refineAbstractTypeTo(JBLType.get()); // Complete the cycle. JBLinkTy = JBLType.get(); M.addTypeName("llvm.sjljeh.jmpbufty", JBLinkTy); } - const Type *PtrJBList = Context.getPointerTypeUnqual(JBLinkTy); + const Type *PtrJBList = PointerType::getUnqual(JBLinkTy); // Now that we've done that, insert the jmpbuf list head global, unless it // already exists. diff --git a/lib/VMCore/AutoUpgrade.cpp b/lib/VMCore/AutoUpgrade.cpp index fc86e54682d..81d143a58a3 100644 --- a/lib/VMCore/AutoUpgrade.cpp +++ b/lib/VMCore/AutoUpgrade.cpp @@ -27,8 +27,6 @@ using namespace llvm; static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) { assert(F && "Illegal to upgrade a non-existent Function."); - LLVMContext &Context = F->getContext(); - // Get the Function's name. const std::string& Name = F->getName(); @@ -167,7 +165,7 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) { Name.compare(13,4,"psrl", 4) == 0) && Name[17] != 'i') { const llvm::Type *VT = - Context.getVectorType(Context.getIntegerType(64), 1); + VectorType::get(IntegerType::get(64), 1); // We don't have to do anything if the parameter already has // the correct type. @@ -268,7 +266,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { if (isLoadH || isLoadL) { Value *Op1 = Context.getUndef(Op0->getType()); Value *Addr = new BitCastInst(CI->getOperand(2), - Context.getPointerTypeUnqual(Type::DoubleTy), + PointerType::getUnqual(Type::DoubleTy), "upgraded.", CI); Value *Load = new LoadInst(Addr, "upgraded.", false, 8, CI); Value *Idx = ConstantInt::get(Type::Int32Ty, 0); diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index 440fb888568..ab0016059ed 100644 --- a/lib/VMCore/ConstantFold.cpp +++ b/lib/VMCore/ConstantFold.cpp @@ -1373,7 +1373,7 @@ Constant *llvm::ConstantFoldCompareInstruction(LLVMContext &Context, const Constant *C2) { const Type *ResultTy; if (const VectorType *VT = dyn_cast(C1->getType())) - ResultTy = Context.getVectorType(Type::Int1Ty, VT->getNumElements()); + ResultTy = VectorType::get(Type::Int1Ty, VT->getNumElements()); else ResultTy = Type::Int1Ty; @@ -1677,7 +1677,7 @@ Constant *llvm::ConstantFoldGetElementPtr(LLVMContext &Context, (Value **)Idxs, (Value **)Idxs+NumIdx); assert(Ty != 0 && "Invalid indices for GEP!"); - return Context.getUndef(Context.getPointerType(Ty, Ptr->getAddressSpace())); + return Context.getUndef(PointerType::get(Ty, Ptr->getAddressSpace())); } Constant *Idx0 = Idxs[0]; @@ -1695,7 +1695,7 @@ Constant *llvm::ConstantFoldGetElementPtr(LLVMContext &Context, (Value**)Idxs+NumIdx); assert(Ty != 0 && "Invalid indices for GEP!"); return Context.getConstantPointerNull( - Context.getPointerType(Ty,Ptr->getAddressSpace())); + PointerType::get(Ty,Ptr->getAddressSpace())); } } diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 6746882ed8d..1ff596fb710 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -178,7 +178,7 @@ ConstantInt::ConstantInt(const IntegerType *Ty, const APInt& V) // invariant which generates an assertion. ConstantInt *ConstantInt::get(LLVMContext &Context, const APInt& V) { // Get the corresponding integer type for the bit width of the value. - const IntegerType *ITy = Context.getIntegerType(V.getBitWidth()); + const IntegerType *ITy = IntegerType::get(V.getBitWidth()); // get an existing value or the insertion position DenseMapAPIntKeyInfo::KeyTy Key(V, ITy); diff --git a/lib/VMCore/Core.cpp b/lib/VMCore/Core.cpp index bf5a6a1b75d..59aeb878007 100644 --- a/lib/VMCore/Core.cpp +++ b/lib/VMCore/Core.cpp @@ -162,7 +162,7 @@ LLVMTypeRef LLVMInt32Type(void) { return (LLVMTypeRef) Type::Int32Ty; } LLVMTypeRef LLVMInt64Type(void) { return (LLVMTypeRef) Type::Int64Ty; } LLVMTypeRef LLVMIntType(unsigned NumBits) { - return wrap(getGlobalContext().getIntegerType(NumBits)); + return wrap(IntegerType::get(NumBits)); } unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy) { @@ -186,8 +186,7 @@ LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType, for (LLVMTypeRef *I = ParamTypes, *E = ParamTypes + ParamCount; I != E; ++I) Tys.push_back(unwrap(*I)); - return wrap(getGlobalContext().getFunctionType(unwrap(ReturnType), Tys, - IsVarArg != 0)); + return wrap(FunctionType::get(unwrap(ReturnType), Tys, IsVarArg != 0)); } int LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy) { @@ -218,7 +217,7 @@ LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, *E = ElementTypes + ElementCount; I != E; ++I) Tys.push_back(unwrap(*I)); - return wrap(getGlobalContext().getStructType(Tys, Packed != 0)); + return wrap(StructType::get(Tys, Packed != 0)); } unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy) { @@ -239,18 +238,15 @@ int LLVMIsPackedStruct(LLVMTypeRef StructTy) { /*--.. Operations on array, pointer, and vector types (sequence types) .....--*/ LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount) { - return wrap(getGlobalContext().getArrayType(unwrap(ElementType), - ElementCount)); + return wrap(ArrayType::get(unwrap(ElementType), ElementCount)); } LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace) { - return wrap(getGlobalContext().getPointerType(unwrap(ElementType), - AddressSpace)); + return wrap(PointerType::get(unwrap(ElementType), AddressSpace)); } LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount) { - return wrap(getGlobalContext().getVectorType(unwrap(ElementType), - ElementCount)); + return wrap(VectorType::get(unwrap(ElementType), ElementCount)); } LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty) { @@ -275,7 +271,7 @@ LLVMTypeRef LLVMVoidType(void) { return (LLVMTypeRef) Type::VoidTy; } LLVMTypeRef LLVMLabelType(void) { return (LLVMTypeRef) Type::LabelTy; } LLVMTypeRef LLVMOpaqueType(void) { - return wrap(getGlobalContext().getOpaqueType()); + return wrap(OpaqueType::get()); } /*--.. Operations on type handles ..........................................--*/ @@ -408,8 +404,7 @@ LLVMValueRef LLVMConstString(const char *Str, unsigned Length, LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy, LLVMValueRef *ConstantVals, unsigned Length) { - return wrap(ConstantArray::get( - getGlobalContext().getArrayType(unwrap(ElementTy), Length), + return wrap(ConstantArray::get(ArrayType::get(unwrap(ElementTy), Length), unwrap(ConstantVals, Length), Length)); } diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index cdf2dd07fa6..9fc300043de 100644 --- a/lib/VMCore/Function.cpp +++ b/lib/VMCore/Function.cpp @@ -346,7 +346,7 @@ const FunctionType *Intrinsic::getType(LLVMContext &Context, #include "llvm/Intrinsics.gen" #undef GET_INTRINSIC_GENERATOR - return Context.getFunctionType(ResultTy, ArgTys, IsVarArg); + return FunctionType::get(ResultTy, ArgTys, IsVarArg); } bool Intrinsic::isOverloaded(ID id) { diff --git a/lib/VMCore/Globals.cpp b/lib/VMCore/Globals.cpp index e01dedd597b..d18a20162dd 100644 --- a/lib/VMCore/Globals.cpp +++ b/lib/VMCore/Globals.cpp @@ -98,7 +98,7 @@ GlobalVariable::GlobalVariable(LLVMContext &Context, const Type *Ty, bool constant, LinkageTypes Link, Constant *InitVal, const Twine &Name, bool ThreadLocal, unsigned AddressSpace) - : GlobalValue(Context.getPointerType(Ty, AddressSpace), + : GlobalValue(PointerType::get(Ty, AddressSpace), Value::GlobalVariableVal, OperandTraits::op_begin(this), InitVal != 0, Link, Name), @@ -117,7 +117,7 @@ GlobalVariable::GlobalVariable(Module &M, const Type *Ty, bool constant, const Twine &Name, GlobalVariable *Before, bool ThreadLocal, unsigned AddressSpace) - : GlobalValue(M.getContext().getPointerType(Ty, AddressSpace), + : GlobalValue(PointerType::get(Ty, AddressSpace), Value::GlobalVariableVal, OperandTraits::op_begin(this), InitVal != 0, Link, Name), diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index 0b242415054..08b43963074 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -716,7 +716,7 @@ static Value *getAISize(LLVMContext &Context, Value *Amt) { AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, unsigned Align, const Twine &Name, Instruction *InsertBefore) - : UnaryInstruction(Ty->getContext().getPointerTypeUnqual(Ty), iTy, + : UnaryInstruction(PointerType::getUnqual(Ty), iTy, getAISize(Ty->getContext(), ArraySize), InsertBefore) { setAlignment(Align); assert(Ty != Type::VoidTy && "Cannot allocate void!"); @@ -726,7 +726,7 @@ AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, unsigned Align, const Twine &Name, BasicBlock *InsertAtEnd) - : UnaryInstruction(Ty->getContext().getPointerTypeUnqual(Ty), iTy, + : UnaryInstruction(PointerType::getUnqual(Ty), iTy, getAISize(Ty->getContext(), ArraySize), InsertAtEnd) { setAlignment(Align); assert(Ty != Type::VoidTy && "Cannot allocate void!"); @@ -1046,7 +1046,7 @@ GetElementPtrInst::GetElementPtrInst(const GetElementPtrInst &GEPI) GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx, const Twine &Name, Instruction *InBe) - : Instruction(Ptr->getType()->getContext().getPointerType( + : Instruction(PointerType::get( checkType(getIndexedType(Ptr->getType(),Idx)), retrieveAddrSpace(Ptr)), GetElementPtr, OperandTraits::op_end(this) - 2, @@ -1056,7 +1056,7 @@ GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx, GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx, const Twine &Name, BasicBlock *IAE) - : Instruction(Ptr->getType()->getContext().getPointerType( + : Instruction(PointerType::get( checkType(getIndexedType(Ptr->getType(),Idx)), retrieveAddrSpace(Ptr)), GetElementPtr, @@ -1270,8 +1270,7 @@ ShuffleVectorInst::ShuffleVectorInst(const ShuffleVectorInst &SV) ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask, const Twine &Name, Instruction *InsertBefore) -: Instruction(V1->getType()->getContext().getVectorType( - cast(V1->getType())->getElementType(), +: Instruction(VectorType::get(cast(V1->getType())->getElementType(), cast(Mask->getType())->getNumElements()), ShuffleVector, OperandTraits::op_begin(this), diff --git a/lib/VMCore/LLVMContext.cpp b/lib/VMCore/LLVMContext.cpp index e38986eb3df..8bd45b2954d 100644 --- a/lib/VMCore/LLVMContext.cpp +++ b/lib/VMCore/LLVMContext.cpp @@ -113,89 +113,6 @@ MDString* LLVMContext::getMDString(const StringRef &Str) { return pImpl->getMDString(Str.data(), Str.size()); } -// FunctionType accessors -FunctionType* LLVMContext::getFunctionType(const Type* Result, bool isVarArg) { - return FunctionType::get(Result, isVarArg); -} - -FunctionType* LLVMContext::getFunctionType(const Type* Result, - const std::vector& Params, - bool isVarArg) { - return FunctionType::get(Result, Params, isVarArg); -} - -// IntegerType accessors -const IntegerType* LLVMContext::getIntegerType(unsigned NumBits) { - return IntegerType::get(NumBits); -} - -// OpaqueType accessors -OpaqueType* LLVMContext::getOpaqueType() { - return OpaqueType::get(); -} - -// StructType accessors -StructType* LLVMContext::getStructType(bool isPacked) { - return StructType::get(isPacked); -} - -StructType* LLVMContext::getStructType(const std::vector& Params, - bool isPacked) { - return StructType::get(Params, isPacked); -} - -StructType *LLVMContext::getStructType(const Type *type, ...) { - va_list ap; - std::vector StructFields; - va_start(ap, type); - while (type) { - StructFields.push_back(type); - type = va_arg(ap, llvm::Type*); - } - return StructType::get(StructFields); -} - -// ArrayType accessors -ArrayType* LLVMContext::getArrayType(const Type* ElementType, - uint64_t NumElements) { - return ArrayType::get(ElementType, NumElements); -} - -// PointerType accessors -PointerType* LLVMContext::getPointerType(const Type* ElementType, - unsigned AddressSpace) { - return PointerType::get(ElementType, AddressSpace); -} - -PointerType* LLVMContext::getPointerTypeUnqual(const Type* ElementType) { - return PointerType::getUnqual(ElementType); -} - -// VectorType accessors -VectorType* LLVMContext::getVectorType(const Type* ElementType, - unsigned NumElements) { - return VectorType::get(ElementType, NumElements); -} - -VectorType* LLVMContext::getVectorTypeInteger(const VectorType* VTy) { - return VectorType::getInteger(VTy); -} - -VectorType* LLVMContext::getVectorTypeExtendedElement(const VectorType* VTy) { - return VectorType::getExtendedElementVectorType(VTy); -} - -VectorType* LLVMContext::getVectorTypeTruncatedElement(const VectorType* VTy) { - return VectorType::getTruncatedElementVectorType(VTy); -} - -const Type* LLVMContext::makeCmpResultType(const Type* opnd_type) { - if (const VectorType* vt = dyn_cast(opnd_type)) { - return getVectorType(Type::Int1Ty, vt->getNumElements()); - } - return Type::Int1Ty; -} - void LLVMContext::erase(MDString *M) { pImpl->erase(M); } diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp index 2ef16d01f68..87d4b05cf14 100644 --- a/lib/VMCore/Module.cpp +++ b/lib/VMCore/Module.cpp @@ -153,8 +153,8 @@ Constant *Module::getOrInsertFunction(const StringRef &Name, // If the function exists but has the wrong type, return a bitcast to the // right type. - if (F->getType() != Context.getPointerTypeUnqual(Ty)) - return ConstantExpr::getBitCast(F, Context.getPointerTypeUnqual(Ty)); + if (F->getType() != PointerType::getUnqual(Ty)) + return ConstantExpr::getBitCast(F, PointerType::getUnqual(Ty)); // Otherwise, we just found the existing function or a prototype. return F; @@ -203,7 +203,7 @@ Constant *Module::getOrInsertFunction(const StringRef &Name, // Build the function type and chain to the other getOrInsertFunction... return getOrInsertFunction(Name, - Context.getFunctionType(RetTy, ArgTys, false), + FunctionType::get(RetTy, ArgTys, false), AttributeList); } @@ -221,7 +221,7 @@ Constant *Module::getOrInsertFunction(const StringRef &Name, // Build the function type and chain to the other getOrInsertFunction... return getOrInsertFunction(Name, - Context.getFunctionType(RetTy, ArgTys, false), + FunctionType::get(RetTy, ArgTys, false), AttrListPtr::get((AttributeWithIndex *)0, 0)); } @@ -271,8 +271,8 @@ Constant *Module::getOrInsertGlobal(const StringRef &Name, const Type *Ty) { // If the variable exists but has the wrong type, return a bitcast to the // right type. - if (GV->getType() != Context.getPointerTypeUnqual(Ty)) - return ConstantExpr::getBitCast(GV, Context.getPointerTypeUnqual(Ty)); + if (GV->getType() != PointerType::getUnqual(Ty)) + return ConstantExpr::getBitCast(GV, PointerType::getUnqual(Ty)); // Otherwise, we just found the existing function or a prototype. return GV; diff --git a/lib/VMCore/ValueTypes.cpp b/lib/VMCore/ValueTypes.cpp index 5badffc82c3..244659607f5 100644 --- a/lib/VMCore/ValueTypes.cpp +++ b/lib/VMCore/ValueTypes.cpp @@ -21,16 +21,14 @@ using namespace llvm; MVT MVT::getExtendedIntegerVT(unsigned BitWidth) { MVT VT; - VT.LLVMTy = getGlobalContext().getIntegerType(BitWidth); + VT.LLVMTy = IntegerType::get(BitWidth); assert(VT.isExtended() && "Type is not extended!"); return VT; } MVT MVT::getExtendedVectorVT(MVT VT, unsigned NumElements) { MVT ResultVT; - ResultVT.LLVMTy = getGlobalContext().getVectorType( - VT.getTypeForMVT(getGlobalContext()), - NumElements); + ResultVT.LLVMTy = VectorType::get(VT.getTypeForMVT(), NumElements); assert(ResultVT.isExtended() && "Type is not extended!"); return ResultVT; } @@ -133,7 +131,7 @@ std::string MVT::getMVTString() const { /// getTypeForMVT - This method returns an LLVM type corresponding to the /// specified MVT. For integer types, this returns an unsigned type. Note /// that this will abort for types that cannot be represented. -const Type *MVT::getTypeForMVT(LLVMContext &Context) const { +const Type *MVT::getTypeForMVT() const { switch (V) { default: assert(isExtended() && "Type is not extended!"); @@ -144,32 +142,32 @@ const Type *MVT::getTypeForMVT(LLVMContext &Context) const { case MVT::i16: return Type::Int16Ty; case MVT::i32: return Type::Int32Ty; case MVT::i64: return Type::Int64Ty; - case MVT::i128: return Context.getIntegerType(128); + case MVT::i128: return IntegerType::get(128); case MVT::f32: return Type::FloatTy; case MVT::f64: return Type::DoubleTy; case MVT::f80: return Type::X86_FP80Ty; case MVT::f128: return Type::FP128Ty; case MVT::ppcf128: return Type::PPC_FP128Ty; - case MVT::v2i8: return Context.getVectorType(Type::Int8Ty, 2); - case MVT::v4i8: return Context.getVectorType(Type::Int8Ty, 4); - case MVT::v8i8: return Context.getVectorType(Type::Int8Ty, 8); - case MVT::v16i8: return Context.getVectorType(Type::Int8Ty, 16); - case MVT::v32i8: return Context.getVectorType(Type::Int8Ty, 32); - case MVT::v2i16: return Context.getVectorType(Type::Int16Ty, 2); - case MVT::v4i16: return Context.getVectorType(Type::Int16Ty, 4); - case MVT::v8i16: return Context.getVectorType(Type::Int16Ty, 8); - case MVT::v16i16: return Context.getVectorType(Type::Int16Ty, 16); - case MVT::v2i32: return Context.getVectorType(Type::Int32Ty, 2); - case MVT::v4i32: return Context.getVectorType(Type::Int32Ty, 4); - case MVT::v8i32: return Context.getVectorType(Type::Int32Ty, 8); - case MVT::v1i64: return Context.getVectorType(Type::Int64Ty, 1); - case MVT::v2i64: return Context.getVectorType(Type::Int64Ty, 2); - case MVT::v4i64: return Context.getVectorType(Type::Int64Ty, 4); - case MVT::v2f32: return Context.getVectorType(Type::FloatTy, 2); - case MVT::v4f32: return Context.getVectorType(Type::FloatTy, 4); - case MVT::v8f32: return Context.getVectorType(Type::FloatTy, 8); - case MVT::v2f64: return Context.getVectorType(Type::DoubleTy, 2); - case MVT::v4f64: return Context.getVectorType(Type::DoubleTy, 4); + case MVT::v2i8: return VectorType::get(Type::Int8Ty, 2); + case MVT::v4i8: return VectorType::get(Type::Int8Ty, 4); + case MVT::v8i8: return VectorType::get(Type::Int8Ty, 8); + case MVT::v16i8: return VectorType::get(Type::Int8Ty, 16); + case MVT::v32i8: return VectorType::get(Type::Int8Ty, 32); + case MVT::v2i16: return VectorType::get(Type::Int16Ty, 2); + case MVT::v4i16: return VectorType::get(Type::Int16Ty, 4); + case MVT::v8i16: return VectorType::get(Type::Int16Ty, 8); + case MVT::v16i16: return VectorType::get(Type::Int16Ty, 16); + case MVT::v2i32: return VectorType::get(Type::Int32Ty, 2); + case MVT::v4i32: return VectorType::get(Type::Int32Ty, 4); + case MVT::v8i32: return VectorType::get(Type::Int32Ty, 8); + case MVT::v1i64: return VectorType::get(Type::Int64Ty, 1); + case MVT::v2i64: return VectorType::get(Type::Int64Ty, 2); + case MVT::v4i64: return VectorType::get(Type::Int64Ty, 4); + case MVT::v2f32: return VectorType::get(Type::FloatTy, 2); + case MVT::v4f32: return VectorType::get(Type::FloatTy, 4); + case MVT::v8f32: return VectorType::get(Type::FloatTy, 8); + case MVT::v2f64: return VectorType::get(Type::DoubleTy, 2); + case MVT::v4f64: return VectorType::get(Type::DoubleTy, 4); } } diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 6d179d01a6b..407a80b2378 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -1490,7 +1490,6 @@ static std::string IntrinsicParam(unsigned ArgNo, unsigned NumRets) { bool Verifier::PerformTypeCheck(Intrinsic::ID ID, Function *F, const Type *Ty, int VT, unsigned ArgNo, std::string &Suffix) { const FunctionType *FTy = F->getFunctionType(); - LLVMContext &Context = FTy->getContext(); unsigned NumElts = 0; const Type *EltTy = Ty; @@ -1620,7 +1619,7 @@ bool Verifier::PerformTypeCheck(Intrinsic::ID ID, Function *F, const Type *Ty, "vector elements!", F); return false; } - } else if (MVT((MVT::SimpleValueType)VT).getTypeForMVT(Context) != EltTy) { + } else if (MVT((MVT::SimpleValueType)VT).getTypeForMVT() != EltTy) { CheckFailed(IntrinsicParam(ArgNo, NumRets) + " is wrong!", F); return false; } else if (EltTy != Ty) { diff --git a/tools/bugpoint/ExtractFunction.cpp b/tools/bugpoint/ExtractFunction.cpp index c2159dea4b0..ea40caaf3d9 100644 --- a/tools/bugpoint/ExtractFunction.cpp +++ b/tools/bugpoint/ExtractFunction.cpp @@ -181,7 +181,6 @@ void llvm::DeleteFunctionBody(Function *F) { /// as a constant array. static Constant *GetTorInit(std::vector > &TorList) { assert(!TorList.empty() && "Don't create empty tor list!"); - LLVMContext &Context = TorList[0].first->getContext(); std::vector ArrayElts; for (unsigned i = 0, e = TorList.size(); i != e; ++i) { std::vector Elts; @@ -189,7 +188,7 @@ static Constant *GetTorInit(std::vector > &TorList) { Elts.push_back(TorList[i].first); ArrayElts.push_back(ConstantStruct::get(Elts)); } - return ConstantArray::get(Context.getArrayType(ArrayElts[0]->getType(), + return ConstantArray::get(ArrayType::get(ArrayElts[0]->getType(), ArrayElts.size()), ArrayElts); } diff --git a/tools/bugpoint/Miscompilation.cpp b/tools/bugpoint/Miscompilation.cpp index 74eaaa8584e..c021418905a 100644 --- a/tools/bugpoint/Miscompilation.cpp +++ b/tools/bugpoint/Miscompilation.cpp @@ -701,8 +701,8 @@ static void CleanupAndPrepareModules(BugDriver &BD, Module *&Test, // Prototype: void *getPointerToNamedFunction(const char* Name) Constant *resolverFunc = Safe->getOrInsertFunction("getPointerToNamedFunction", - Context.getPointerTypeUnqual(Type::Int8Ty), - Context.getPointerTypeUnqual(Type::Int8Ty), (Type *)0); + PointerType::getUnqual(Type::Int8Ty), + PointerType::getUnqual(Type::Int8Ty), (Type *)0); // Use the function we just added to get addresses of functions we need. for (Module::iterator F = Safe->begin(), E = Safe->end(); F != E; ++F) { @@ -765,7 +765,7 @@ static void CleanupAndPrepareModules(BugDriver &BD, Module *&Test, // Cast the result from the resolver to correctly-typed function. CastInst *CastedResolver = new BitCastInst(Resolver, - Context.getPointerTypeUnqual(F->getFunctionType()), + PointerType::getUnqual(F->getFunctionType()), "resolverCast", LookupBB); // Save the value in our cache. diff --git a/unittests/ExecutionEngine/JIT/JITTest.cpp b/unittests/ExecutionEngine/JIT/JITTest.cpp index 129f21f84fb..abfe9313470 100644 --- a/unittests/ExecutionEngine/JIT/JITTest.cpp +++ b/unittests/ExecutionEngine/JIT/JITTest.cpp @@ -31,8 +31,7 @@ namespace { Function *makeReturnGlobal(std::string Name, GlobalVariable *G, Module *M) { std::vector params; - const FunctionType *FTy = - getGlobalContext().getFunctionType(G->getType()->getElementType(), + const FunctionType *FTy = FunctionType::get(G->getType()->getElementType(), params, false); Function *F = Function::Create(FTy, GlobalValue::ExternalLinkage, Name, M); BasicBlock *Entry = BasicBlock::Create("entry", F); diff --git a/unittests/Support/TypeBuilderTest.cpp b/unittests/Support/TypeBuilderTest.cpp index 8c5369b7b3b..e6c7c95f1d7 100644 --- a/unittests/Support/TypeBuilderTest.cpp +++ b/unittests/Support/TypeBuilderTest.cpp @@ -171,7 +171,7 @@ public: st.push_back(TypeBuilder::get(Context)); st.push_back(TypeBuilder::get(Context)); st.push_back(TypeBuilder::get(Context)); - static const StructType *const result = Context.getStructType(st); + static const StructType *const result = StructType::get(st); return result; } @@ -194,7 +194,7 @@ public: st.push_back(TypeBuilder, cross>::get(Context)); st.push_back(TypeBuilder*, cross>::get(Context)); st.push_back(TypeBuilder*[], cross>::get(Context)); - static const StructType *const result = Context.getStructType(st); + static const StructType *const result = StructType::get(st); return result; } diff --git a/utils/TableGen/CallingConvEmitter.cpp b/utils/TableGen/CallingConvEmitter.cpp index 82e13dd4eee..a14be0b76fd 100644 --- a/utils/TableGen/CallingConvEmitter.cpp +++ b/utils/TableGen/CallingConvEmitter.cpp @@ -163,12 +163,12 @@ void CallingConvEmitter::EmitAction(Record *Action, O << Size << ", "; else O << "\n" << IndentStr << " State.getTarget().getTargetData()" - "->getTypeAllocSize(LocVT.getTypeForMVT(State.getContext())), "; + "->getTypeAllocSize(LocVT.getTypeForMVT()), "; if (Align) O << Align; else O << "\n" << IndentStr << " State.getTarget().getTargetData()" - "->getABITypeAlignment(LocVT.getTypeForMVT(State.getContext()))"; + "->getABITypeAlignment(LocVT.getTypeForMVT())"; O << ");\n" << IndentStr << "State.addLoc(CCValAssign::getMem(ValNo, ValVT, Offset" << Counter << ", LocVT, LocInfo));\n";