From 2280ebd61416b73d0b6137f275b25af82e268d1f Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Tue, 12 Jul 2011 01:15:52 +0000 Subject: [PATCH] Revert r134893 and r134888 (and related patches in other trees). It was causing an assert on Darwin llvm-gcc builds. Assertion failed: (castIsValid(op, S, Ty) && "Invalid cast!"), function Create, file /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.llvm-gcc-i386-darwin9-RA/llvm.src/lib/VMCore/Instructions.cpp, li\ ne 2067. etc. http://smooshlab.apple.com:8013/builders/llvm-gcc-i386-darwin9-RA/builds/2354 --- Reverse-merging r134893 into '.': U include/llvm/Target/TargetData.h U include/llvm/DerivedTypes.h U tools/bugpoint/ExtractFunction.cpp U unittests/Support/TypeBuilderTest.cpp U lib/Target/ARM/ARMGlobalMerge.cpp U lib/Target/TargetData.cpp U lib/VMCore/Constants.cpp U lib/VMCore/Type.cpp U lib/VMCore/Core.cpp U lib/Transforms/Utils/CodeExtractor.cpp U lib/Transforms/Instrumentation/ProfilingUtils.cpp U lib/Transforms/IPO/DeadArgumentElimination.cpp U lib/CodeGen/SjLjEHPrepare.cpp --- Reverse-merging r134888 into '.': G include/llvm/DerivedTypes.h U include/llvm/Support/TypeBuilder.h U include/llvm/Intrinsics.h U unittests/Analysis/ScalarEvolutionTest.cpp U unittests/ExecutionEngine/JIT/JITTest.cpp U unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp U unittests/VMCore/PassManagerTest.cpp G unittests/Support/TypeBuilderTest.cpp U lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp U lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp U lib/VMCore/IRBuilder.cpp G lib/VMCore/Type.cpp U lib/VMCore/Function.cpp G lib/VMCore/Core.cpp U lib/VMCore/Module.cpp U lib/AsmParser/LLParser.cpp U lib/Transforms/Utils/CloneFunction.cpp G lib/Transforms/Utils/CodeExtractor.cpp U lib/Transforms/Utils/InlineFunction.cpp U lib/Transforms/Instrumentation/GCOVProfiling.cpp U lib/Transforms/Scalar/ObjCARC.cpp U lib/Transforms/Scalar/SimplifyLibCalls.cpp U lib/Transforms/Scalar/MemCpyOptimizer.cpp G lib/Transforms/IPO/DeadArgumentElimination.cpp U lib/Transforms/IPO/ArgumentPromotion.cpp U lib/Transforms/InstCombine/InstCombineCompares.cpp U lib/Transforms/InstCombine/InstCombineAndOrXor.cpp U lib/Transforms/InstCombine/InstCombineCalls.cpp U lib/CodeGen/DwarfEHPrepare.cpp U lib/CodeGen/IntrinsicLowering.cpp U lib/Bitcode/Reader/BitcodeReader.cpp git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134949 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DerivedTypes.h | 9 ++- include/llvm/Intrinsics.h | 6 +- include/llvm/Support/TypeBuilder.h | 74 +++++++++---------- include/llvm/Target/TargetData.h | 2 +- lib/AsmParser/LLParser.cpp | 8 +- lib/Bitcode/Reader/BitcodeReader.cpp | 4 +- lib/CodeGen/DwarfEHPrepare.cpp | 4 +- lib/CodeGen/IntrinsicLowering.cpp | 8 +- lib/CodeGen/SjLjEHPrepare.cpp | 5 +- lib/Target/ARM/ARMGlobalMerge.cpp | 4 +- lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp | 2 +- lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp | 2 +- lib/Target/TargetData.cpp | 2 +- lib/Transforms/IPO/ArgumentPromotion.cpp | 2 +- .../IPO/DeadArgumentElimination.cpp | 8 +- .../InstCombine/InstCombineAndOrXor.cpp | 4 +- .../InstCombine/InstCombineCalls.cpp | 10 +-- .../InstCombine/InstCombineCompares.cpp | 4 +- .../Instrumentation/GCOVProfiling.cpp | 9 ++- .../Instrumentation/ProfilingUtils.cpp | 2 +- lib/Transforms/Scalar/MemCpyOptimizer.cpp | 6 +- lib/Transforms/Scalar/ObjCARC.cpp | 28 +++---- lib/Transforms/Scalar/SimplifyLibCalls.cpp | 2 +- lib/Transforms/Utils/CloneFunction.cpp | 2 +- lib/Transforms/Utils/CodeExtractor.cpp | 6 +- lib/Transforms/Utils/InlineFunction.cpp | 4 +- lib/VMCore/Constants.cpp | 2 +- lib/VMCore/Core.cpp | 4 +- lib/VMCore/Function.cpp | 8 +- lib/VMCore/IRBuilder.cpp | 6 +- lib/VMCore/Module.cpp | 8 +- lib/VMCore/Type.cpp | 22 +++++- tools/bugpoint/ExtractFunction.cpp | 2 +- unittests/Analysis/ScalarEvolutionTest.cpp | 2 +- .../JIT/JITMemoryManagerTest.cpp | 2 +- unittests/ExecutionEngine/JIT/JITTest.cpp | 4 +- unittests/Support/TypeBuilderTest.cpp | 6 +- unittests/VMCore/PassManagerTest.cpp | 4 +- 38 files changed, 156 insertions(+), 131 deletions(-) diff --git a/include/llvm/DerivedTypes.h b/include/llvm/DerivedTypes.h index 0f1e99f1349..0fc2c3a0c3a 100644 --- a/include/llvm/DerivedTypes.h +++ b/include/llvm/DerivedTypes.h @@ -102,6 +102,8 @@ public: /// FunctionType::get - This static method is the primary way of constructing /// a FunctionType. /// + static FunctionType *get(const Type *Result, + ArrayRef Params, bool isVarArg); static FunctionType *get(const Type *Result, ArrayRef Params, bool isVarArg); @@ -204,6 +206,11 @@ public: /// StructType::get - This static method is the primary way to create a /// StructType. + /// + /// FIXME: Remove the 'const Type*' version of this when types are pervasively + /// de-constified. + static StructType *get(LLVMContext &Context, ArrayRef Elements, + bool isPacked = false); static StructType *get(LLVMContext &Context, ArrayRef Elements, bool isPacked = false); @@ -215,7 +222,7 @@ public: /// structure types by specifying the elements as arguments. Note that this /// method always returns a non-packed struct, and requires at least one /// element type. - static StructType *get(Type *elt1, ...) END_WITH_NULL; + static StructType *get(const Type *elt1, ...) END_WITH_NULL; bool isPacked() const { return (getSubclassData() & SCDB_Packed) != 0; } diff --git a/include/llvm/Intrinsics.h b/include/llvm/Intrinsics.h index 4885e28611f..5cfe55181f5 100644 --- a/include/llvm/Intrinsics.h +++ b/include/llvm/Intrinsics.h @@ -44,12 +44,12 @@ namespace Intrinsic { /// Intrinsic::getName(ID) - Return the LLVM name for an intrinsic, such as /// "llvm.ppc.altivec.lvx". - std::string getName(ID id, Type **Tys = 0, unsigned numTys = 0); + std::string getName(ID id, const Type **Tys = 0, unsigned numTys = 0); /// Intrinsic::getType(ID) - Return the function type for an intrinsic. /// const FunctionType *getType(LLVMContext &Context, ID id, - Type **Tys = 0, unsigned numTys = 0); + const Type **Tys = 0, unsigned numTys = 0); /// Intrinsic::isOverloaded(ID) - Returns true if the intrinsic can be /// overloaded. @@ -67,7 +67,7 @@ namespace Intrinsic { /// overloaded intrinsic, Tys should point to an array of numTys pointers to /// Type, and must provide exactly one type for each overloaded type in the /// intrinsic. - Function *getDeclaration(Module *M, ID id, Type **Tys = 0, + Function *getDeclaration(Module *M, ID id, const Type **Tys = 0, unsigned numTys = 0); /// Map a GCC builtin name to an intrinsic ID. diff --git a/include/llvm/Support/TypeBuilder.h b/include/llvm/Support/TypeBuilder.h index 18007789736..dbe7cfdf6e1 100644 --- a/include/llvm/Support/TypeBuilder.h +++ b/include/llvm/Support/TypeBuilder.h @@ -51,7 +51,7 @@ namespace llvm { /// namespace llvm { /// template class TypeBuilder { /// public: -/// static StructType *get(LLVMContext &Context) { +/// static const StructType *get(LLVMContext &Context) { /// // If you cache this result, be sure to cache it separately /// // for each LLVMContext. /// return StructType::get( @@ -104,7 +104,7 @@ template class TypeBuilder // Pointers template class TypeBuilder { public: - static PointerType *get(LLVMContext &Context) { + static const PointerType *get(LLVMContext &Context) { return PointerType::getUnqual(TypeBuilder::get(Context)); } }; @@ -115,14 +115,14 @@ template class TypeBuilder {}; // Arrays template class TypeBuilder { public: - static ArrayType *get(LLVMContext &Context) { + static const ArrayType *get(LLVMContext &Context) { return ArrayType::get(TypeBuilder::get(Context), N); } }; /// LLVM uses an array of length 0 to represent an unknown-length array. template class TypeBuilder { public: - static ArrayType *get(LLVMContext &Context) { + static const ArrayType *get(LLVMContext &Context) { return ArrayType::get(TypeBuilder::get(Context), 0); } }; @@ -152,7 +152,7 @@ public: #define DEFINE_INTEGRAL_TYPEBUILDER(T) \ template<> class TypeBuilder { \ public: \ - static IntegerType *get(LLVMContext &Context) { \ + static const IntegerType *get(LLVMContext &Context) { \ return IntegerType::get(Context, sizeof(T) * CHAR_BIT); \ } \ }; \ @@ -181,14 +181,14 @@ DEFINE_INTEGRAL_TYPEBUILDER(unsigned long long); template class TypeBuilder, cross> { public: - static IntegerType *get(LLVMContext &C) { + static const IntegerType *get(LLVMContext &C) { return IntegerType::get(C, num_bits); } }; template<> class TypeBuilder { public: - static Type *get(LLVMContext& C) { + static const Type *get(LLVMContext& C) { return Type::getFloatTy(C); } }; @@ -196,7 +196,7 @@ template<> class TypeBuilder {}; template<> class TypeBuilder { public: - static Type *get(LLVMContext& C) { + static const Type *get(LLVMContext& C) { return Type::getDoubleTy(C); } }; @@ -204,32 +204,32 @@ template<> class TypeBuilder {}; template class TypeBuilder { public: - static Type *get(LLVMContext& C) { return Type::getFloatTy(C); } + static const Type *get(LLVMContext& C) { return Type::getFloatTy(C); } }; template class TypeBuilder { public: - static Type *get(LLVMContext& C) { return Type::getDoubleTy(C); } + static const Type *get(LLVMContext& C) { return Type::getDoubleTy(C); } }; template class TypeBuilder { public: - static Type *get(LLVMContext& C) { return Type::getX86_FP80Ty(C); } + static const Type *get(LLVMContext& C) { return Type::getX86_FP80Ty(C); } }; template class TypeBuilder { public: - static Type *get(LLVMContext& C) { return Type::getFP128Ty(C); } + static const Type *get(LLVMContext& C) { return Type::getFP128Ty(C); } }; template class TypeBuilder { public: - static Type *get(LLVMContext& C) { return Type::getPPC_FP128Ty(C); } + static const Type *get(LLVMContext& C) { return Type::getPPC_FP128Ty(C); } }; template class TypeBuilder { public: - static Type *get(LLVMContext& C) { return Type::getX86_MMXTy(C); } + static const Type *get(LLVMContext& C) { return Type::getX86_MMXTy(C); } }; template class TypeBuilder { public: - static Type *get(LLVMContext &C) { + static const Type *get(LLVMContext &C) { return Type::getVoidTy(C); } }; @@ -247,14 +247,14 @@ template<> class TypeBuilder template class TypeBuilder { public: - static FunctionType *get(LLVMContext &Context) { + static const FunctionType *get(LLVMContext &Context) { return FunctionType::get(TypeBuilder::get(Context), false); } }; template class TypeBuilder { public: - static FunctionType *get(LLVMContext &Context) { - std::vector params; + static const FunctionType *get(LLVMContext &Context) { + std::vector params; params.reserve(1); params.push_back(TypeBuilder::get(Context)); return FunctionType::get(TypeBuilder::get(Context), @@ -264,8 +264,8 @@ public: template class TypeBuilder { public: - static FunctionType *get(LLVMContext &Context) { - std::vector params; + static const FunctionType *get(LLVMContext &Context) { + std::vector params; params.reserve(2); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); @@ -276,8 +276,8 @@ public: template class TypeBuilder { public: - static FunctionType *get(LLVMContext &Context) { - std::vector params; + static const FunctionType *get(LLVMContext &Context) { + std::vector params; params.reserve(3); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); @@ -291,8 +291,8 @@ template class TypeBuilder { public: - static FunctionType *get(LLVMContext &Context) { - std::vector params; + static const FunctionType *get(LLVMContext &Context) { + std::vector params; params.reserve(4); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); @@ -307,8 +307,8 @@ template class TypeBuilder { public: - static FunctionType *get(LLVMContext &Context) { - std::vector params; + static const FunctionType *get(LLVMContext &Context) { + std::vector params; params.reserve(5); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); @@ -322,15 +322,15 @@ public: template class TypeBuilder { public: - static FunctionType *get(LLVMContext &Context) { + static const FunctionType *get(LLVMContext &Context) { return FunctionType::get(TypeBuilder::get(Context), true); } }; template class TypeBuilder { public: - static FunctionType *get(LLVMContext &Context) { - std::vector params; + static const FunctionType *get(LLVMContext &Context) { + std::vector params; params.reserve(1); params.push_back(TypeBuilder::get(Context)); return FunctionType::get(TypeBuilder::get(Context), params, true); @@ -339,8 +339,8 @@ public: template class TypeBuilder { public: - static FunctionType *get(LLVMContext &Context) { - std::vector params; + static const FunctionType *get(LLVMContext &Context) { + std::vector params; params.reserve(2); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); @@ -351,8 +351,8 @@ public: template class TypeBuilder { public: - static FunctionType *get(LLVMContext &Context) { - std::vector params; + static const FunctionType *get(LLVMContext &Context) { + std::vector params; params.reserve(3); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); @@ -366,8 +366,8 @@ template class TypeBuilder { public: - static FunctionType *get(LLVMContext &Context) { - std::vector params; + static const FunctionType *get(LLVMContext &Context) { + std::vector params; params.reserve(4); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); @@ -382,8 +382,8 @@ template class TypeBuilder { public: - static FunctionType *get(LLVMContext &Context) { - std::vector params; + static const FunctionType *get(LLVMContext &Context) { + std::vector params; params.reserve(5); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); diff --git a/include/llvm/Target/TargetData.h b/include/llvm/Target/TargetData.h index 10252865c96..32e3e2b0b61 100644 --- a/include/llvm/Target/TargetData.h +++ b/include/llvm/Target/TargetData.h @@ -259,7 +259,7 @@ public: /// getIntPtrType - Return an unsigned integer type that is the same size or /// greater to the host pointer size. /// - IntegerType *getIntPtrType(LLVMContext &C) const; + const IntegerType *getIntPtrType(LLVMContext &C) const; /// getIndexedOffset - return the offset from the beginning of the type for /// the specified indices. This is used to implement getelementptr. diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index 4b066fef727..881b3e943b8 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -1442,7 +1442,7 @@ bool LLParser::ParseFunctionType(Type *&Result) { "argument attributes invalid in function type"); } - SmallVector ArgListTy; + SmallVector ArgListTy; for (unsigned i = 0, e = ArgList.size(); i != e; ++i) ArgListTy.push_back(ArgList[i].Ty); @@ -2655,7 +2655,7 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) { // Okay, if we got here, the function is syntactically valid. Convert types // and do semantic checks. - std::vector ParamTypeList; + std::vector ParamTypeList; SmallVector Attrs; if (RetAttrs != Attribute::None) @@ -3171,7 +3171,7 @@ bool LLParser::ParseInvoke(Instruction *&Inst, PerFunctionState &PFS) { if (!(PFTy = dyn_cast(RetType)) || !(Ty = dyn_cast(PFTy->getElementType()))) { // Pull out the types of all of the arguments... - std::vector ParamTypes; + std::vector ParamTypes; for (unsigned i = 0, e = ArgList.size(); i != e; ++i) ParamTypes.push_back(ArgList[i].V->getType()); @@ -3508,7 +3508,7 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS, if (!(PFTy = dyn_cast(RetType)) || !(Ty = dyn_cast(PFTy->getElementType()))) { // Pull out the types of all of the arguments... - std::vector ParamTypes; + std::vector ParamTypes; for (unsigned i = 0, e = ArgList.size(); i != e; ++i) ParamTypes.push_back(ArgList[i].V->getType()); diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 0a5ba45fc12..1bdcfe98d40 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -582,7 +582,7 @@ bool BitcodeReader::ParseTypeTableBody() { // FUNCTION: [vararg, attrid, retty, paramty x N] if (Record.size() < 3) return Error("Invalid FUNCTION type record"); - std::vector ArgTys; + std::vector ArgTys; for (unsigned i = 3, e = Record.size(); i != e; ++i) { if (Type *T = getTypeByID(Record[i])) ArgTys.push_back(T); @@ -838,7 +838,7 @@ RestartScan: // FUNCTION: [vararg, attrid, retty, paramty x N] if (Record.size() < 3) return Error("Invalid FUNCTION type record"); - std::vector ArgTys; + std::vector ArgTys; for (unsigned i = 3, e = Record.size(); i != e; ++i) { if (Type *Elt = getTypeByIDOrNull(Record[i])) ArgTys.push_back(Elt); diff --git a/lib/CodeGen/DwarfEHPrepare.cpp b/lib/CodeGen/DwarfEHPrepare.cpp index 46a88842983..22c5465bf9f 100644 --- a/lib/CodeGen/DwarfEHPrepare.cpp +++ b/lib/CodeGen/DwarfEHPrepare.cpp @@ -497,8 +497,10 @@ bool DwarfEHPrepare::LowerUnwindsAndResumes() { // Find the rewind function if we didn't already. if (!RewindFunction) { LLVMContext &Ctx = ResumeInsts[0]->getContext(); + std::vector + Params(1, Type::getInt8PtrTy(Ctx)); FunctionType *FTy = FunctionType::get(Type::getVoidTy(Ctx), - Type::getInt8PtrTy(Ctx), false); + Params, false); const char *RewindName = TLI->getLibcallName(RTLIB::UNWIND_RESUME); RewindFunction = F->getParent()->getOrInsertFunction(RewindName, FTy); } diff --git a/lib/CodeGen/IntrinsicLowering.cpp b/lib/CodeGen/IntrinsicLowering.cpp index a1166d026a5..b0a823042d4 100644 --- a/lib/CodeGen/IntrinsicLowering.cpp +++ b/lib/CodeGen/IntrinsicLowering.cpp @@ -29,7 +29,7 @@ static void EnsureFunctionExists(Module &M, const char *Name, ArgIt ArgBegin, ArgIt ArgEnd, const Type *RetTy) { // Insert a correctly-typed definition now. - std::vector ParamTys; + std::vector ParamTys; for (ArgIt I = ArgBegin; I != ArgEnd; ++I) ParamTys.push_back(I->getType()); M.getOrInsertFunction(Name, FunctionType::get(RetTy, ParamTys, false)); @@ -69,7 +69,7 @@ static CallInst *ReplaceCallWith(const char *NewFn, CallInst *CI, // program already contains a function with this name. Module *M = CI->getParent()->getParent()->getParent(); // Get or insert the definition now. - std::vector ParamTys; + std::vector ParamTys; for (ArgIt I = ArgBegin; I != ArgEnd; ++I) ParamTys.push_back((*I)->getType()); Constant* FCache = M->getOrInsertFunction(NewFn, @@ -553,12 +553,12 @@ bool IntrinsicLowering::LowerToByteSwap(CallInst *CI) { !CI->getType()->isIntegerTy()) return false; - IntegerType *Ty = dyn_cast(CI->getType()); + const IntegerType *Ty = dyn_cast(CI->getType()); if (!Ty) return false; // Okay, we can do this xform, do so now. - Type *Tys[] = { Ty }; + const Type *Tys[] = { Ty }; Module *M = CI->getParent()->getParent()->getParent(); Constant *Int = Intrinsic::getDeclaration(M, Intrinsic::bswap, Tys, 1); diff --git a/lib/CodeGen/SjLjEHPrepare.cpp b/lib/CodeGen/SjLjEHPrepare.cpp index 65a33da93af..c2565afe016 100644 --- a/lib/CodeGen/SjLjEHPrepare.cpp +++ b/lib/CodeGen/SjLjEHPrepare.cpp @@ -87,8 +87,9 @@ FunctionPass *llvm::createSjLjEHPass(const TargetLowering *TLI) { bool SjLjEHPass::doInitialization(Module &M) { // Build the function context structure. // builtin_setjmp uses a five word jbuf - Type *VoidPtrTy = Type::getInt8PtrTy(M.getContext()); - Type *Int32Ty = Type::getInt32Ty(M.getContext()); + const Type *VoidPtrTy = + Type::getInt8PtrTy(M.getContext()); + const Type *Int32Ty = Type::getInt32Ty(M.getContext()); FunctionContextTy = StructType::get(VoidPtrTy, // __prev Int32Ty, // call_site diff --git a/lib/Target/ARM/ARMGlobalMerge.cpp b/lib/Target/ARM/ARMGlobalMerge.cpp index 8d77b2d8383..f8993792bc6 100644 --- a/lib/Target/ARM/ARMGlobalMerge.cpp +++ b/lib/Target/ARM/ARMGlobalMerge.cpp @@ -128,10 +128,10 @@ bool ARMGlobalMerge::doMerge(SmallVectorImpl &Globals, for (size_t i = 0, e = Globals.size(); i != e; ) { size_t j = 0; uint64_t MergedSize = 0; - std::vector Tys; + std::vector Tys; std::vector Inits; for (j = i; j != e; ++j) { - Type *Ty = Globals[j]->getType()->getElementType(); + const Type *Ty = Globals[j]->getType()->getElementType(); MergedSize += TD->getTypeAllocSize(Ty); if (MergedSize > MaxOffset) { break; diff --git a/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp b/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp index ae8ee9e2a1a..34a8d3809ea 100644 --- a/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp +++ b/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp @@ -83,7 +83,7 @@ bool BlackfinIntrinsicInfo::isOverloaded(unsigned IntrID) const { static const FunctionType *getType(LLVMContext &Context, unsigned id) { const Type *ResultTy = NULL; - std::vector ArgTys; + std::vector ArgTys; bool IsVarArg = false; #define GET_INTRINSIC_GENERATOR diff --git a/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp b/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp index 32d67b264a2..7e4a2f5c945 100644 --- a/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp +++ b/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp @@ -92,7 +92,7 @@ bool MBlazeIntrinsicInfo::isOverloaded(unsigned IntrID) const { static const FunctionType *getType(LLVMContext &Context, unsigned id) { const Type *ResultTy = NULL; - std::vector ArgTys; + std::vector ArgTys; bool IsVarArg = false; #define GET_INTRINSIC_GENERATOR diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp index b2c4b21f680..6309a1572c5 100644 --- a/lib/Target/TargetData.cpp +++ b/lib/Target/TargetData.cpp @@ -535,7 +535,7 @@ unsigned TargetData::getPreferredTypeAlignmentShift(const Type *Ty) const { /// getIntPtrType - Return an unsigned integer type that is the same size or /// greater to the host pointer size. -IntegerType *TargetData::getIntPtrType(LLVMContext &C) const { +const IntegerType *TargetData::getIntPtrType(LLVMContext &C) const { return IntegerType::get(C, getPointerSizeInBits()); } diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp index 3288ee57c38..54a7f679e01 100644 --- a/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -493,7 +493,7 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F, // Start by computing a new prototype for the function, which is the same as // the old function, but has modified arguments. const FunctionType *FTy = F->getFunctionType(); - std::vector Params; + std::vector Params; typedef std::set ScalarizeTable; diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp index bbb386c0125..d4eaf0c4a3e 100644 --- a/lib/Transforms/IPO/DeadArgumentElimination.cpp +++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp @@ -208,7 +208,7 @@ bool DAE::DeleteDeadVarargs(Function &Fn) { // the old function, but doesn't have isVarArg set. const FunctionType *FTy = Fn.getFunctionType(); - std::vector Params(FTy->param_begin(), FTy->param_end()); + std::vector Params(FTy->param_begin(), FTy->param_end()); FunctionType *NFTy = FunctionType::get(FTy->getReturnType(), Params, false); unsigned NumArgs = Params.size(); @@ -647,7 +647,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) { // Start by computing a new prototype for the function, which is the same as // the old function, but has fewer arguments and a different return type. const FunctionType *FTy = F->getFunctionType(); - std::vector Params; + std::vector Params; // Set up to build a new list of parameter attributes. SmallVector AttributesVec; @@ -659,13 +659,13 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) { // Find out the new return value. - Type *RetTy = FTy->getReturnType(); + const Type *RetTy = FTy->getReturnType(); const Type *NRetTy = NULL; unsigned RetCount = NumRetVals(F); // -1 means unused, other numbers are the new index SmallVector NewRetIdxs(RetCount, -1); - std::vector RetTypes; + std::vector RetTypes; if (RetTy->isVoidTy()) { NRetTy = RetTy; } else { diff --git a/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp index 1dfbd3e548c..a08446e5d51 100644 --- a/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp +++ b/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp @@ -1400,7 +1400,7 @@ static bool CollectBSwapParts(Value *V, int OverallLeftShift, uint32_t ByteMask, /// MatchBSwap - Given an OR instruction, check to see if this is a bswap idiom. /// If so, insert the new bswap intrinsic and return it. Instruction *InstCombiner::MatchBSwap(BinaryOperator &I) { - IntegerType *ITy = dyn_cast(I.getType()); + const IntegerType *ITy = dyn_cast(I.getType()); if (!ITy || ITy->getBitWidth() % 16 || // ByteMask only allows up to 32-byte values. ITy->getBitWidth() > 32*8) @@ -1424,7 +1424,7 @@ Instruction *InstCombiner::MatchBSwap(BinaryOperator &I) { for (unsigned i = 1, e = ByteValues.size(); i != e; ++i) if (ByteValues[i] != V) return 0; - Type *Tys[] = { ITy }; + const Type *Tys[] = { ITy }; Module *M = I.getParent()->getParent()->getParent(); Function *F = Intrinsic::getDeclaration(M, Intrinsic::bswap, Tys, 1); return CallInst::Create(F, V); diff --git a/lib/Transforms/InstCombine/InstCombineCalls.cpp b/lib/Transforms/InstCombine/InstCombineCalls.cpp index b4843658f56..27e15c30589 100644 --- a/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -217,9 +217,9 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) { if (GVSrc->isConstant()) { Module *M = CI.getParent()->getParent()->getParent(); Intrinsic::ID MemCpyID = Intrinsic::memcpy; - Type *Tys[3] = { CI.getArgOperand(0)->getType(), - CI.getArgOperand(1)->getType(), - CI.getArgOperand(2)->getType() }; + const Type *Tys[3] = { CI.getArgOperand(0)->getType(), + CI.getArgOperand(1)->getType(), + CI.getArgOperand(2)->getType() }; CI.setCalledFunction(Intrinsic::getDeclaration(M, MemCpyID, Tys, 3)); Changed = true; } @@ -1187,7 +1187,7 @@ Instruction *InstCombiner::transformCallThroughTrampoline(CallSite CS) { const AttrListPtr &NestAttrs = NestF->getAttributes(); if (!NestAttrs.isEmpty()) { unsigned NestIdx = 1; - Type *NestTy = 0; + const Type *NestTy = 0; Attributes NestAttr = Attribute::None; // Look for a parameter marked with the 'nest' attribute. @@ -1249,7 +1249,7 @@ Instruction *InstCombiner::transformCallThroughTrampoline(CallSite CS) { // Handle this by synthesizing a new function type, equal to FTy // with the chain parameter inserted. - std::vector NewTypes; + std::vector NewTypes; NewTypes.reserve(FTy->getNumParams()+1); // Insert the chain's type into the list of parameter types, which may diff --git a/lib/Transforms/InstCombine/InstCombineCompares.cpp b/lib/Transforms/InstCombine/InstCombineCompares.cpp index 3cdb705c160..5a1e2b08853 100644 --- a/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -1683,7 +1683,7 @@ static Instruction *ProcessUGT_ADDCST_ADD(ICmpInst &I, Value *A, Value *B, // result and the overflow bit. Module *M = I.getParent()->getParent()->getParent(); - Type *NewType = IntegerType::get(OrigAdd->getContext(), NewWidth); + const Type *NewType = IntegerType::get(OrigAdd->getContext(), NewWidth); Value *F = Intrinsic::getDeclaration(M, Intrinsic::sadd_with_overflow, &NewType, 1); @@ -1725,7 +1725,7 @@ static Instruction *ProcessUAddIdiom(Instruction &I, Value *OrigAddV, Builder->SetInsertPoint(OrigAdd); Module *M = I.getParent()->getParent()->getParent(); - Type *Ty = LHS->getType(); + const Type *Ty = LHS->getType(); Value *F = Intrinsic::getDeclaration(M, Intrinsic::uadd_with_overflow, &Ty,1); CallInst *Call = Builder->CreateCall2(F, LHS, RHS, "uadd"); Value *Add = Builder->CreateExtractValue(Call, 0); diff --git a/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/lib/Transforms/Instrumentation/GCOVProfiling.cpp index 3f2c4123882..07d69e8f36a 100644 --- a/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -572,13 +572,14 @@ GlobalVariable *GCOVProfiler::buildEdgeLookupTable( } Constant *GCOVProfiler::getStartFileFunc() { + const Type *Args[] = { Type::getInt8PtrTy(*Ctx) }; const FunctionType *FTy = FunctionType::get(Type::getVoidTy(*Ctx), - Type::getInt8PtrTy(*Ctx), false); + Args, false); return M->getOrInsertFunction("llvm_gcda_start_file", FTy); } Constant *GCOVProfiler::getIncrementIndirectCounterFunc() { - Type *Args[] = { + const Type *Args[] = { Type::getInt32PtrTy(*Ctx), // uint32_t *predecessor Type::getInt64PtrTy(*Ctx)->getPointerTo(), // uint64_t **state_table_row }; @@ -588,7 +589,7 @@ Constant *GCOVProfiler::getIncrementIndirectCounterFunc() { } Constant *GCOVProfiler::getEmitFunctionFunc() { - Type *Args[2] = { + const Type *Args[2] = { Type::getInt32Ty(*Ctx), // uint32_t ident Type::getInt8PtrTy(*Ctx), // const char *function_name }; @@ -598,7 +599,7 @@ Constant *GCOVProfiler::getEmitFunctionFunc() { } Constant *GCOVProfiler::getEmitArcsFunc() { - Type *Args[] = { + const Type *Args[] = { Type::getInt32Ty(*Ctx), // uint32_t num_counters Type::getInt64PtrTy(*Ctx), // uint64_t *counters }; diff --git a/lib/Transforms/Instrumentation/ProfilingUtils.cpp b/lib/Transforms/Instrumentation/ProfilingUtils.cpp index 327e423839f..4224ee303f0 100644 --- a/lib/Transforms/Instrumentation/ProfilingUtils.cpp +++ b/lib/Transforms/Instrumentation/ProfilingUtils.cpp @@ -134,7 +134,7 @@ void llvm::IncrementCounterInBlock(BasicBlock *BB, unsigned CounterNum, void llvm::InsertProfilingShutdownCall(Function *Callee, Module *Mod) { // llvm.global_dtors is an array of type { i32, void ()* }. Prepare those // types. - Type *GlobalDtorElems[2] = { + const Type *GlobalDtorElems[2] = { Type::getInt32Ty(Mod->getContext()), FunctionType::get(Type::getVoidTy(Mod->getContext()), false)->getPointerTo() }; diff --git a/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/lib/Transforms/Scalar/MemCpyOptimizer.cpp index a3a3063cdeb..bd4c2d6d8e0 100644 --- a/lib/Transforms/Scalar/MemCpyOptimizer.cpp +++ b/lib/Transforms/Scalar/MemCpyOptimizer.cpp @@ -840,9 +840,9 @@ bool MemCpyOpt::processMemMove(MemMoveInst *M) { // If not, then we know we can transform this. Module *Mod = M->getParent()->getParent()->getParent(); - Type *ArgTys[3] = { M->getRawDest()->getType(), - M->getRawSource()->getType(), - M->getLength()->getType() }; + const Type *ArgTys[3] = { M->getRawDest()->getType(), + M->getRawSource()->getType(), + M->getLength()->getType() }; M->setCalledFunction(Intrinsic::getDeclaration(Mod, Intrinsic::memcpy, ArgTys, 3)); diff --git a/lib/Transforms/Scalar/ObjCARC.cpp b/lib/Transforms/Scalar/ObjCARC.cpp index 6e3e0f86b63..89a451ef7ad 100644 --- a/lib/Transforms/Scalar/ObjCARC.cpp +++ b/lib/Transforms/Scalar/ObjCARC.cpp @@ -1498,8 +1498,8 @@ void ObjCARCOpt::getAnalysisUsage(AnalysisUsage &AU) const { Constant *ObjCARCOpt::getRetainRVCallee(Module *M) { if (!RetainRVCallee) { LLVMContext &C = M->getContext(); - Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); - std::vector Params; + const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); + std::vector Params; Params.push_back(I8X); const FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false); @@ -1515,8 +1515,8 @@ Constant *ObjCARCOpt::getRetainRVCallee(Module *M) { Constant *ObjCARCOpt::getAutoreleaseRVCallee(Module *M) { if (!AutoreleaseRVCallee) { LLVMContext &C = M->getContext(); - Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); - std::vector Params; + const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); + std::vector Params; Params.push_back(I8X); const FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false); @@ -1532,7 +1532,7 @@ Constant *ObjCARCOpt::getAutoreleaseRVCallee(Module *M) { Constant *ObjCARCOpt::getReleaseCallee(Module *M) { if (!ReleaseCallee) { LLVMContext &C = M->getContext(); - std::vector Params; + std::vector Params; Params.push_back(PointerType::getUnqual(Type::getInt8Ty(C))); AttrListPtr Attributes; Attributes.addAttr(~0u, Attribute::NoUnwind); @@ -1548,7 +1548,7 @@ Constant *ObjCARCOpt::getReleaseCallee(Module *M) { Constant *ObjCARCOpt::getRetainCallee(Module *M) { if (!RetainCallee) { LLVMContext &C = M->getContext(); - std::vector Params; + std::vector Params; Params.push_back(PointerType::getUnqual(Type::getInt8Ty(C))); AttrListPtr Attributes; Attributes.addAttr(~0u, Attribute::NoUnwind); @@ -1564,7 +1564,7 @@ Constant *ObjCARCOpt::getRetainCallee(Module *M) { Constant *ObjCARCOpt::getAutoreleaseCallee(Module *M) { if (!AutoreleaseCallee) { LLVMContext &C = M->getContext(); - std::vector Params; + std::vector Params; Params.push_back(PointerType::getUnqual(Type::getInt8Ty(C))); AttrListPtr Attributes; Attributes.addAttr(~0u, Attribute::NoUnwind); @@ -3269,9 +3269,9 @@ void ObjCARCContract::getAnalysisUsage(AnalysisUsage &AU) const { Constant *ObjCARCContract::getStoreStrongCallee(Module *M) { if (!StoreStrongCallee) { LLVMContext &C = M->getContext(); - Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); - Type *I8XX = PointerType::getUnqual(I8X); - std::vector Params; + const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); + const Type *I8XX = PointerType::getUnqual(I8X); + std::vector Params; Params.push_back(I8XX); Params.push_back(I8X); @@ -3291,8 +3291,8 @@ Constant *ObjCARCContract::getStoreStrongCallee(Module *M) { Constant *ObjCARCContract::getRetainAutoreleaseCallee(Module *M) { if (!RetainAutoreleaseCallee) { LLVMContext &C = M->getContext(); - Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); - std::vector Params; + const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); + std::vector Params; Params.push_back(I8X); const FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false); @@ -3307,8 +3307,8 @@ Constant *ObjCARCContract::getRetainAutoreleaseCallee(Module *M) { Constant *ObjCARCContract::getRetainAutoreleaseRVCallee(Module *M) { if (!RetainAutoreleaseRVCallee) { LLVMContext &C = M->getContext(); - Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); - std::vector Params; + const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); + std::vector Params; Params.push_back(I8X); const FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false); diff --git a/lib/Transforms/Scalar/SimplifyLibCalls.cpp b/lib/Transforms/Scalar/SimplifyLibCalls.cpp index 66c30284414..6247b0348f1 100644 --- a/lib/Transforms/Scalar/SimplifyLibCalls.cpp +++ b/lib/Transforms/Scalar/SimplifyLibCalls.cpp @@ -992,7 +992,7 @@ struct FFSOpt : public LibCallOptimization { } // ffs(x) -> x != 0 ? (i32)llvm.cttz(x)+1 : 0 - Type *ArgType = Op->getType(); + const Type *ArgType = Op->getType(); Value *F = Intrinsic::getDeclaration(Callee->getParent(), Intrinsic::cttz, &ArgType, 1); Value *V = B.CreateCall(F, Op, "cttz"); diff --git a/lib/Transforms/Utils/CloneFunction.cpp b/lib/Transforms/Utils/CloneFunction.cpp index 6ea831f5345..98c9f68f3ec 100644 --- a/lib/Transforms/Utils/CloneFunction.cpp +++ b/lib/Transforms/Utils/CloneFunction.cpp @@ -140,7 +140,7 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc, Function *llvm::CloneFunction(const Function *F, ValueToValueMapTy &VMap, bool ModuleLevelChanges, ClonedCodeInfo *CodeInfo) { - std::vector ArgTypes; + std::vector ArgTypes; // The user might be deleting arguments to the function by specifying them in // the VMap. If so, we need to not add the arguments to the arg ty vector diff --git a/lib/Transforms/Utils/CodeExtractor.cpp b/lib/Transforms/Utils/CodeExtractor.cpp index 9a2e53fd518..8c133ea7f56 100644 --- a/lib/Transforms/Utils/CodeExtractor.cpp +++ b/lib/Transforms/Utils/CodeExtractor.cpp @@ -258,7 +258,7 @@ Function *CodeExtractor::constructFunction(const Values &inputs, default: RetTy = Type::getInt16Ty(header->getContext()); break; } - std::vector paramTy; + std::vector paramTy; // Add the types of the input values to the function's argument list for (Values::const_iterator i = inputs.begin(), @@ -279,7 +279,7 @@ Function *CodeExtractor::constructFunction(const Values &inputs, } DEBUG(dbgs() << "Function type: " << *RetTy << " f("); - for (std::vector::iterator i = paramTy.begin(), + for (std::vector::iterator i = paramTy.begin(), e = paramTy.end(); i != e; ++i) DEBUG(dbgs() << **i << ", "); DEBUG(dbgs() << ")\n"); @@ -403,7 +403,7 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer, AllocaInst *Struct = 0; if (AggregateArgs && (inputs.size() + outputs.size() > 0)) { - std::vector ArgTypes; + std::vector ArgTypes; for (Values::iterator v = StructValues.begin(), ve = StructValues.end(); v != ve; ++v) ArgTypes.push_back((*v)->getType()); diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp index 791d30cb179..348c3e49ab6 100644 --- a/lib/Transforms/Utils/InlineFunction.cpp +++ b/lib/Transforms/Utils/InlineFunction.cpp @@ -663,7 +663,7 @@ static Value *HandleByValArgument(Value *Arg, Instruction *TheCall, LLVMContext &Context = Arg->getContext(); - Type *VoidPtrTy = Type::getInt8PtrTy(Context); + const Type *VoidPtrTy = Type::getInt8PtrTy(Context); // Create the alloca. If we have TargetData, use nice alignment. unsigned Align = 1; @@ -680,7 +680,7 @@ static Value *HandleByValArgument(Value *Arg, Instruction *TheCall, Value *NewAlloca = new AllocaInst(AggTy, 0, Align, Arg->getName(), &*Caller->begin()->begin()); // Emit a memcpy. - Type *Tys[3] = {VoidPtrTy, VoidPtrTy, Type::getInt64Ty(Context)}; + const Type *Tys[3] = {VoidPtrTy, VoidPtrTy, Type::getInt64Ty(Context)}; Function *MemCpyFn = Intrinsic::getDeclaration(Caller->getParent(), Intrinsic::memcpy, Tys, 3); diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 1529c4ad481..57498b48592 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -619,7 +619,7 @@ Constant *ConstantArray::get(LLVMContext &Context, StringRef Str, StructType *ConstantStruct::getTypeForElements(LLVMContext &Context, ArrayRef V, bool Packed) { - SmallVector EltTypes; + SmallVector EltTypes; for (unsigned i = 0, e = V.size(); i != e; ++i) EltTypes.push_back(V[i]->getType()); diff --git a/lib/VMCore/Core.cpp b/lib/VMCore/Core.cpp index 15d27233f22..d9ced94134a 100644 --- a/lib/VMCore/Core.cpp +++ b/lib/VMCore/Core.cpp @@ -260,7 +260,7 @@ LLVMTypeRef LLVMX86MMXType(void) { LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType, LLVMTypeRef *ParamTypes, unsigned ParamCount, LLVMBool IsVarArg) { - std::vector Tys; + std::vector Tys; for (LLVMTypeRef *I = ParamTypes, *E = ParamTypes + ParamCount; I != E; ++I) Tys.push_back(unwrap(*I)); @@ -290,7 +290,7 @@ void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest) { LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes, unsigned ElementCount, LLVMBool Packed) { - std::vector Tys; + std::vector Tys; for (LLVMTypeRef *I = ElementTypes, *E = ElementTypes + ElementCount; I != E; ++I) Tys.push_back(unwrap(*I)); diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index bde6a6d6918..972319e7402 100644 --- a/lib/VMCore/Function.cpp +++ b/lib/VMCore/Function.cpp @@ -333,7 +333,7 @@ unsigned Function::getIntrinsicID() const { return 0; } -std::string Intrinsic::getName(ID id, Type **Tys, unsigned numTys) { +std::string Intrinsic::getName(ID id, const Type **Tys, unsigned numTys) { assert(id < num_intrinsics && "Invalid intrinsic ID!"); static const char * const Table[] = { "not_intrinsic", @@ -356,10 +356,10 @@ std::string Intrinsic::getName(ID id, Type **Tys, unsigned numTys) { } const FunctionType *Intrinsic::getType(LLVMContext &Context, - ID id, Type **Tys, + ID id, const Type **Tys, unsigned numTys) { const Type *ResultTy = NULL; - std::vector ArgTys; + std::vector ArgTys; bool IsVarArg = false; #define GET_INTRINSIC_GENERATOR @@ -384,7 +384,7 @@ bool Intrinsic::isOverloaded(ID id) { #include "llvm/Intrinsics.gen" #undef GET_INTRINSIC_ATTRIBUTES -Function *Intrinsic::getDeclaration(Module *M, ID id, Type **Tys, +Function *Intrinsic::getDeclaration(Module *M, ID id, const Type **Tys, unsigned numTys) { // There can never be multiple globals with the same name of different types, // because intrinsics must be a specific type. diff --git a/lib/VMCore/IRBuilder.cpp b/lib/VMCore/IRBuilder.cpp index 0908470216f..f2d469a2d84 100644 --- a/lib/VMCore/IRBuilder.cpp +++ b/lib/VMCore/IRBuilder.cpp @@ -65,7 +65,7 @@ CreateMemSet(Value *Ptr, Value *Val, Value *Size, unsigned Align, bool isVolatile, MDNode *TBAATag) { Ptr = getCastedInt8PtrValue(Ptr); Value *Ops[] = { Ptr, Val, Size, getInt32(Align), getInt1(isVolatile) }; - Type *Tys[] = { Ptr->getType(), Size->getType() }; + const Type *Tys[] = { Ptr->getType(), Size->getType() }; Module *M = BB->getParent()->getParent(); Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys, 2); @@ -85,7 +85,7 @@ CreateMemCpy(Value *Dst, Value *Src, Value *Size, unsigned Align, Src = getCastedInt8PtrValue(Src); Value *Ops[] = { Dst, Src, Size, getInt32(Align), getInt1(isVolatile) }; - Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; + const Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; Module *M = BB->getParent()->getParent(); Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memcpy, Tys, 3); @@ -105,7 +105,7 @@ CreateMemMove(Value *Dst, Value *Src, Value *Size, unsigned Align, Src = getCastedInt8PtrValue(Src); Value *Ops[] = { Dst, Src, Size, getInt32(Align), getInt1(isVolatile) }; - Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; + const Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; Module *M = BB->getParent()->getParent(); Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memmove, Tys, 3); diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp index 8a738cbac5c..1ca70161d6d 100644 --- a/lib/VMCore/Module.cpp +++ b/lib/VMCore/Module.cpp @@ -216,8 +216,8 @@ Constant *Module::getOrInsertFunction(StringRef Name, va_start(Args, RetTy); // Build the list of argument types... - std::vector ArgTys; - while (Type *ArgTy = va_arg(Args, Type*)) + std::vector ArgTys; + while (const Type *ArgTy = va_arg(Args, const Type*)) ArgTys.push_back(ArgTy); va_end(Args); @@ -234,8 +234,8 @@ Constant *Module::getOrInsertFunction(StringRef Name, va_start(Args, RetTy); // Build the list of argument types... - std::vector ArgTys; - while (Type *ArgTy = va_arg(Args, Type*)) + std::vector ArgTys; + while (const Type *ArgTy = va_arg(Args, const Type*)) ArgTys.push_back(ArgTy); va_end(Args); diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index 10467a8d900..ac8b76ff1eb 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -325,6 +325,13 @@ FunctionType::FunctionType(const Type *Result, ArrayRef Params, NumContainedTys = Params.size() + 1; // + 1 for result type } +// FIXME: Remove this version. +FunctionType *FunctionType::get(const Type *ReturnType, + ArrayRef Params, bool isVarArg) { + return get(ReturnType, ArrayRef(const_cast(Params.data()), + Params.size()), isVarArg); +} + // FunctionType::get - The factory function for the FunctionType class. FunctionType *FunctionType::get(const Type *ReturnType, ArrayRef Params, bool isVarArg) { @@ -350,7 +357,7 @@ FunctionType *FunctionType::get(const Type *ReturnType, FunctionType *FunctionType::get(const Type *Result, bool isVarArg) { - return get(Result, ArrayRef(), isVarArg); + return get(Result, ArrayRef(), isVarArg); } @@ -458,15 +465,22 @@ void StructType::setName(StringRef Name) { //===----------------------------------------------------------------------===// // StructType Helper functions. +// FIXME: Remove this version. +StructType *StructType::get(LLVMContext &Context, ArrayRefElements, + bool isPacked) { + return get(Context, ArrayRef(const_cast(Elements.data()), + Elements.size()), isPacked); +} + StructType *StructType::get(LLVMContext &Context, bool isPacked) { - return get(Context, llvm::ArrayRef(), isPacked); + return get(Context, llvm::ArrayRef(), isPacked); } -StructType *StructType::get(Type *type, ...) { +StructType *StructType::get(const Type *type, ...) { assert(type != 0 && "Cannot create a struct type with no elements with this"); LLVMContext &Ctx = type->getContext(); va_list ap; - SmallVector StructFields; + SmallVector StructFields; va_start(ap, type); while (type) { StructFields.push_back(type); diff --git a/tools/bugpoint/ExtractFunction.cpp b/tools/bugpoint/ExtractFunction.cpp index 9941add52e2..7ed15245c19 100644 --- a/tools/bugpoint/ExtractFunction.cpp +++ b/tools/bugpoint/ExtractFunction.cpp @@ -173,7 +173,7 @@ void llvm::DeleteFunctionBody(Function *F) { static Constant *GetTorInit(std::vector > &TorList) { assert(!TorList.empty() && "Don't create empty tor list!"); std::vector ArrayElts; - Type *Int32Ty = Type::getInt32Ty(TorList[0].first->getContext()); + const Type *Int32Ty = Type::getInt32Ty(TorList[0].first->getContext()); const StructType *STy = StructType::get(Int32Ty, TorList[0].first->getType(), NULL); diff --git a/unittests/Analysis/ScalarEvolutionTest.cpp b/unittests/Analysis/ScalarEvolutionTest.cpp index 39ced2a16e6..b7341603cf6 100644 --- a/unittests/Analysis/ScalarEvolutionTest.cpp +++ b/unittests/Analysis/ScalarEvolutionTest.cpp @@ -23,7 +23,7 @@ TEST(ScalarEvolutionsTest, SCEVUnknownRAUW) { Module M("world", Context); const FunctionType *FTy = FunctionType::get(Type::getVoidTy(Context), - std::vector(), false); + std::vector(), false); Function *F = cast(M.getOrInsertFunction("f", FTy)); BasicBlock *BB = BasicBlock::Create(Context, "entry", F); ReturnInst::Create(Context, 0, BB); diff --git a/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp b/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp index 039b5e00f2e..0bc1966781d 100644 --- a/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp +++ b/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp @@ -21,7 +21,7 @@ using namespace llvm; namespace { Function *makeFakeFunction() { - std::vector params; + std::vector params; const FunctionType *FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), params, false); return Function::Create(FTy, GlobalValue::ExternalLinkage); diff --git a/unittests/ExecutionEngine/JIT/JITTest.cpp b/unittests/ExecutionEngine/JIT/JITTest.cpp index 9c001c423f9..ceacbbe62a4 100644 --- a/unittests/ExecutionEngine/JIT/JITTest.cpp +++ b/unittests/ExecutionEngine/JIT/JITTest.cpp @@ -37,7 +37,7 @@ using namespace llvm; namespace { Function *makeReturnGlobal(std::string Name, GlobalVariable *G, Module *M) { - std::vector params; + std::vector params; const FunctionType *FTy = FunctionType::get(G->getType()->getElementType(), params, false); Function *F = Function::Create(FTy, GlobalValue::ExternalLinkage, Name, M); @@ -322,7 +322,7 @@ TEST_F(JITTest, NonLazyCompilationStillNeedsStubs) { const FunctionType *Func1Ty = cast(TypeBuilder::get(Context)); - std::vector arg_types; + std::vector arg_types; arg_types.push_back(Type::getInt1Ty(Context)); const FunctionType *FuncTy = FunctionType::get( Type::getVoidTy(Context), arg_types, false); diff --git a/unittests/Support/TypeBuilderTest.cpp b/unittests/Support/TypeBuilderTest.cpp index 06091784cf0..bd19c651ec5 100644 --- a/unittests/Support/TypeBuilderTest.cpp +++ b/unittests/Support/TypeBuilderTest.cpp @@ -120,7 +120,7 @@ TEST(TypeBuilderTest, Derived) { } TEST(TypeBuilderTest, Functions) { - std::vector params; + std::vector params; EXPECT_EQ(FunctionType::get(Type::getVoidTy(getGlobalContext()), params, false), (TypeBuilder::get(getGlobalContext()))); EXPECT_EQ(FunctionType::get(Type::getInt8Ty(getGlobalContext()), params, true), @@ -187,7 +187,7 @@ public: static const StructType *get(LLVMContext &Context) { // Using the static result variable ensures that the type is // only looked up once. - std::vector st; + std::vector st; st.push_back(TypeBuilder::get(Context)); st.push_back(TypeBuilder::get(Context)); st.push_back(TypeBuilder::get(Context)); @@ -210,7 +210,7 @@ public: static const StructType *get(LLVMContext &Context) { // Using the static result variable ensures that the type is // only looked up once. - std::vector st; + std::vector st; st.push_back(TypeBuilder, cross>::get(Context)); st.push_back(TypeBuilder*, cross>::get(Context)); st.push_back(TypeBuilder*[], cross>::get(Context)); diff --git a/unittests/VMCore/PassManagerTest.cpp b/unittests/VMCore/PassManagerTest.cpp index af845b0ca42..2f2a200e1d0 100644 --- a/unittests/VMCore/PassManagerTest.cpp +++ b/unittests/VMCore/PassManagerTest.cpp @@ -405,13 +405,13 @@ namespace llvm { mod->setTargetTriple("x86_64-unknown-linux-gnu"); // Type Definitions - std::vectorFuncTy_0_args; + std::vectorFuncTy_0_args; FunctionType* FuncTy_0 = FunctionType::get( /*Result=*/IntegerType::get(getGlobalContext(), 32), /*Params=*/FuncTy_0_args, /*isVarArg=*/false); - std::vectorFuncTy_2_args; + std::vectorFuncTy_2_args; FuncTy_2_args.push_back(IntegerType::get(getGlobalContext(), 1)); FunctionType* FuncTy_2 = FunctionType::get( /*Result=*/Type::getVoidTy(getGlobalContext()), -- 2.34.1