diff options
Diffstat (limited to 'include/llvm/Support')
-rw-r--r-- | include/llvm/Support/BranchProbability.h | 18 | ||||
-rw-r--r-- | include/llvm/Support/CFG.h | 14 | ||||
-rw-r--r-- | include/llvm/Support/ConstantFolder.h | 10 | ||||
-rw-r--r-- | include/llvm/Support/DebugLoc.h | 7 | ||||
-rw-r--r-- | include/llvm/Support/IRBuilder.h | 100 | ||||
-rw-r--r-- | include/llvm/Support/NoFolder.h | 12 | ||||
-rw-r--r-- | include/llvm/Support/PassManagerBuilder.h | 15 | ||||
-rw-r--r-- | include/llvm/Support/TargetFolder.h | 11 | ||||
-rw-r--r-- | include/llvm/Support/TypeBuilder.h | 75 |
9 files changed, 123 insertions, 139 deletions
diff --git a/include/llvm/Support/BranchProbability.h b/include/llvm/Support/BranchProbability.h index c66d224..2e81490 100644 --- a/include/llvm/Support/BranchProbability.h +++ b/include/llvm/Support/BranchProbability.h @@ -18,20 +18,10 @@ namespace llvm { -template<class BlockT, class FunctionT, class BranchProbInfoT> -class BlockFrequencyImpl; -class BranchProbabilityInfo; -class MachineBranchProbabilityInfo; -class MachineBasicBlock; class raw_ostream; // This class represents Branch Probability as a non-negative fraction. class BranchProbability { - template<class BlockT, class FunctionT, class BranchProbInfoT> - friend class BlockFrequencyImpl; - friend class BranchProbabilityInfo; - friend class MachineBranchProbabilityInfo; - friend class MachineBasicBlock; // Numerator uint32_t N; @@ -39,12 +29,16 @@ class BranchProbability { // Denominator uint32_t D; - BranchProbability(uint32_t n, uint32_t d); - public: + BranchProbability(uint32_t n, uint32_t d); uint32_t getNumerator() const { return N; } uint32_t getDenominator() const { return D; } + + // Return (1 - Probability). + BranchProbability getCompl() { + return BranchProbability(D - N, D); + } raw_ostream &print(raw_ostream &OS) const; diff --git a/include/llvm/Support/CFG.h b/include/llvm/Support/CFG.h index 7e193ff..29313ef 100644 --- a/include/llvm/Support/CFG.h +++ b/include/llvm/Support/CFG.h @@ -109,11 +109,18 @@ public: // TODO: This can be random access iterator, only operator[] missing. explicit inline SuccIterator(Term_ T) : Term(T), idx(0) {// begin iterator - assert(T && "getTerminator returned null!"); } inline SuccIterator(Term_ T, bool) // end iterator - : Term(T), idx(Term->getNumSuccessors()) { - assert(T && "getTerminator returned null!"); + : Term(T) { + if (Term) + idx = Term->getNumSuccessors(); + else + // Term == NULL happens, if a basic block is not fully constructed and + // consequently getTerminator() returns NULL. In this case we construct a + // SuccIterator which describes a basic block that has zero successors. + // Defining SuccIterator for incomplete and malformed CFGs is especially + // useful for debugging. + idx = 0; } inline const Self &operator=(const Self &I) { @@ -201,6 +208,7 @@ public: /// Get the source BB of this iterator. inline BB_ *getSource() { + assert(Term && "Source not available, if basic block was malformed"); return Term->getParent(); } }; diff --git a/include/llvm/Support/ConstantFolder.h b/include/llvm/Support/ConstantFolder.h index d0eaa3e..7330235 100644 --- a/include/llvm/Support/ConstantFolder.h +++ b/include/llvm/Support/ConstantFolder.h @@ -210,14 +210,14 @@ public: return ConstantExpr::getShuffleVector(V1, V2, Mask); } - Constant *CreateExtractValue(Constant *Agg, const unsigned *IdxList, - unsigned NumIdx) const { - return ConstantExpr::getExtractValue(Agg, IdxList, NumIdx); + Constant *CreateExtractValue(Constant *Agg, + ArrayRef<unsigned> IdxList) const { + return ConstantExpr::getExtractValue(Agg, IdxList); } Constant *CreateInsertValue(Constant *Agg, Constant *Val, - const unsigned *IdxList, unsigned NumIdx) const { - return ConstantExpr::getInsertValue(Agg, Val, IdxList, NumIdx); + ArrayRef<unsigned> IdxList) const { + return ConstantExpr::getInsertValue(Agg, Val, IdxList); } }; diff --git a/include/llvm/Support/DebugLoc.h b/include/llvm/Support/DebugLoc.h index 98a05a4..2ee9f87 100644 --- a/include/llvm/Support/DebugLoc.h +++ b/include/llvm/Support/DebugLoc.h @@ -61,7 +61,10 @@ namespace llvm { /// getFromDILocation - Translate the DILocation quad into a DebugLoc. static DebugLoc getFromDILocation(MDNode *N); - + + /// getFromDILexicalBlock - Translate the DILexicalBlock into a DebugLoc. + static DebugLoc getFromDILexicalBlock(MDNode *N); + /// isUnknown - Return true if this is an unknown location. bool isUnknown() const { return ScopeIdx == 0; } @@ -94,6 +97,8 @@ namespace llvm { return LineCol == DL.LineCol && ScopeIdx == DL.ScopeIdx; } bool operator!=(const DebugLoc &DL) const { return !(*this == DL); } + + void dump(const LLVMContext &Ctx) const; }; template <> diff --git a/include/llvm/Support/IRBuilder.h b/include/llvm/Support/IRBuilder.h index 9459280..91cd78e 100644 --- a/include/llvm/Support/IRBuilder.h +++ b/include/llvm/Support/IRBuilder.h @@ -111,7 +111,7 @@ public: /// getCurrentDebugLocation - Get location information used by debugging /// information. - const DebugLoc &getCurrentDebugLocation() const { return CurDbgLocation; } + DebugLoc getCurrentDebugLocation() const { return CurDbgLocation; } /// SetInstDebugLocation - If this builder has a current debug location, set /// it on the specified instruction. @@ -122,7 +122,7 @@ public: /// getCurrentFunctionReturnType - Get the return type of the current function /// that we're emitting into. - const Type *getCurrentFunctionReturnType() const; + Type *getCurrentFunctionReturnType() const; /// InsertPoint - A saved insertion point. class InsertPoint { @@ -222,46 +222,46 @@ public: //===--------------------------------------------------------------------===// /// getInt1Ty - Fetch the type representing a single bit - const IntegerType *getInt1Ty() { + IntegerType *getInt1Ty() { return Type::getInt1Ty(Context); } /// getInt8Ty - Fetch the type representing an 8-bit integer. - const IntegerType *getInt8Ty() { + IntegerType *getInt8Ty() { return Type::getInt8Ty(Context); } /// getInt16Ty - Fetch the type representing a 16-bit integer. - const IntegerType *getInt16Ty() { + IntegerType *getInt16Ty() { return Type::getInt16Ty(Context); } /// getInt32Ty - Fetch the type resepresenting a 32-bit integer. - const IntegerType *getInt32Ty() { + IntegerType *getInt32Ty() { return Type::getInt32Ty(Context); } /// getInt64Ty - Fetch the type representing a 64-bit integer. - const IntegerType *getInt64Ty() { + IntegerType *getInt64Ty() { return Type::getInt64Ty(Context); } /// getFloatTy - Fetch the type representing a 32-bit floating point value. - const Type *getFloatTy() { + Type *getFloatTy() { return Type::getFloatTy(Context); } /// getDoubleTy - Fetch the type representing a 64-bit floating point value. - const Type *getDoubleTy() { + Type *getDoubleTy() { return Type::getDoubleTy(Context); } /// getVoidTy - Fetch the type representing void. - const Type *getVoidTy() { + Type *getVoidTy() { return Type::getVoidTy(Context); } - const PointerType *getInt8PtrTy(unsigned AddrSpace = 0) { + PointerType *getInt8PtrTy(unsigned AddrSpace = 0) { return Type::getInt8PtrTy(Context, AddrSpace); } @@ -449,34 +449,30 @@ public: InvokeInst *CreateInvoke(Value *Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, const Twine &Name = "") { - Value *Args[] = { 0 }; - return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, Args, - Args), Name); + return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, + ArrayRef<Value *>()), + Name); } InvokeInst *CreateInvoke(Value *Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, Value *Arg1, const Twine &Name = "") { - Value *Args[] = { Arg1 }; - return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, Args, - Args+1), Name); + return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, Arg1), + Name); } InvokeInst *CreateInvoke3(Value *Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, Value *Arg1, Value *Arg2, Value *Arg3, const Twine &Name = "") { Value *Args[] = { Arg1, Arg2, Arg3 }; - return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, Args, - Args+3), Name); + return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, Args), + Name); } /// CreateInvoke - Create an invoke instruction. - template<typename RandomAccessIterator> InvokeInst *CreateInvoke(Value *Callee, BasicBlock *NormalDest, - BasicBlock *UnwindDest, - RandomAccessIterator ArgBegin, - RandomAccessIterator ArgEnd, + BasicBlock *UnwindDest, ArrayRef<Value *> Args, const Twine &Name = "") { - return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, - ArgBegin, ArgEnd), Name); + return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, Args), + Name); } UnwindInst *CreateUnwind() { @@ -1126,33 +1122,27 @@ public: CallInst *CreateCall2(Value *Callee, Value *Arg1, Value *Arg2, const Twine &Name = "") { Value *Args[] = { Arg1, Arg2 }; - return Insert(CallInst::Create(Callee, Args, Args+2), Name); + return Insert(CallInst::Create(Callee, Args), Name); } CallInst *CreateCall3(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3, const Twine &Name = "") { Value *Args[] = { Arg1, Arg2, Arg3 }; - return Insert(CallInst::Create(Callee, Args, Args+3), Name); + return Insert(CallInst::Create(Callee, Args), Name); } CallInst *CreateCall4(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3, Value *Arg4, const Twine &Name = "") { Value *Args[] = { Arg1, Arg2, Arg3, Arg4 }; - return Insert(CallInst::Create(Callee, Args, Args+4), Name); + return Insert(CallInst::Create(Callee, Args), Name); } CallInst *CreateCall5(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3, Value *Arg4, Value *Arg5, const Twine &Name = "") { Value *Args[] = { Arg1, Arg2, Arg3, Arg4, Arg5 }; - return Insert(CallInst::Create(Callee, Args, Args+5), Name); + return Insert(CallInst::Create(Callee, Args), Name); } - CallInst *CreateCall(Value *Callee, ArrayRef<Value *> Arg, + CallInst *CreateCall(Value *Callee, ArrayRef<Value *> Args, const Twine &Name = "") { - return Insert(CallInst::Create(Callee, Arg.begin(), Arg.end(), Name)); - } - - template<typename RandomAccessIterator> - CallInst *CreateCall(Value *Callee, RandomAccessIterator ArgBegin, - RandomAccessIterator ArgEnd, const Twine &Name = "") { - return Insert(CallInst::Create(Callee, ArgBegin, ArgEnd), Name); + return Insert(CallInst::Create(Callee, Args, Name)); } Value *CreateSelect(Value *C, Value *True, Value *False, @@ -1194,43 +1184,21 @@ public: return Insert(new ShuffleVectorInst(V1, V2, Mask), Name); } - Value *CreateExtractValue(Value *Agg, unsigned Idx, - const Twine &Name = "") { - if (Constant *AggC = dyn_cast<Constant>(Agg)) - return Insert(Folder.CreateExtractValue(AggC, &Idx, 1), Name); - return Insert(ExtractValueInst::Create(Agg, Idx), Name); - } - - template<typename RandomAccessIterator> Value *CreateExtractValue(Value *Agg, - RandomAccessIterator IdxBegin, - RandomAccessIterator IdxEnd, + ArrayRef<unsigned> Idxs, const Twine &Name = "") { if (Constant *AggC = dyn_cast<Constant>(Agg)) - return Insert(Folder.CreateExtractValue(AggC, IdxBegin, IdxEnd-IdxBegin), - Name); - return Insert(ExtractValueInst::Create(Agg, IdxBegin, IdxEnd), Name); + return Insert(Folder.CreateExtractValue(AggC, Idxs), Name); + return Insert(ExtractValueInst::Create(Agg, Idxs), Name); } - Value *CreateInsertValue(Value *Agg, Value *Val, unsigned Idx, - const Twine &Name = "") { - if (Constant *AggC = dyn_cast<Constant>(Agg)) - if (Constant *ValC = dyn_cast<Constant>(Val)) - return Insert(Folder.CreateInsertValue(AggC, ValC, &Idx, 1), Name); - return Insert(InsertValueInst::Create(Agg, Val, Idx), Name); - } - - template<typename RandomAccessIterator> Value *CreateInsertValue(Value *Agg, Value *Val, - RandomAccessIterator IdxBegin, - RandomAccessIterator IdxEnd, + ArrayRef<unsigned> Idxs, const Twine &Name = "") { if (Constant *AggC = dyn_cast<Constant>(Agg)) if (Constant *ValC = dyn_cast<Constant>(Val)) - return Insert(Folder.CreateInsertValue(AggC, ValC, IdxBegin, - IdxEnd - IdxBegin), - Name); - return Insert(InsertValueInst::Create(Agg, Val, IdxBegin, IdxEnd), Name); + return Insert(Folder.CreateInsertValue(AggC, ValC, Idxs), Name); + return Insert(InsertValueInst::Create(Agg, Val, Idxs), Name); } //===--------------------------------------------------------------------===// @@ -1257,7 +1225,7 @@ public: Value *CreatePtrDiff(Value *LHS, Value *RHS, const Twine &Name = "") { assert(LHS->getType() == RHS->getType() && "Pointer subtraction operand types must match!"); - const PointerType *ArgType = cast<PointerType>(LHS->getType()); + PointerType *ArgType = cast<PointerType>(LHS->getType()); Value *LHS_int = CreatePtrToInt(LHS, Type::getInt64Ty(Context)); Value *RHS_int = CreatePtrToInt(RHS, Type::getInt64Ty(Context)); Value *Difference = CreateSub(LHS_int, RHS_int); diff --git a/include/llvm/Support/NoFolder.h b/include/llvm/Support/NoFolder.h index 5ead26e..94359a5 100644 --- a/include/llvm/Support/NoFolder.h +++ b/include/llvm/Support/NoFolder.h @@ -22,6 +22,7 @@ #ifndef LLVM_SUPPORT_NOFOLDER_H #define LLVM_SUPPORT_NOFOLDER_H +#include "llvm/ADT/ArrayRef.h" #include "llvm/Constants.h" #include "llvm/Instructions.h" @@ -269,15 +270,14 @@ public: return new ShuffleVectorInst(V1, V2, Mask); } - Instruction *CreateExtractValue(Constant *Agg, const unsigned *IdxList, - unsigned NumIdx) const { - return ExtractValueInst::Create(Agg, IdxList, IdxList+NumIdx); + Instruction *CreateExtractValue(Constant *Agg, + ArrayRef<unsigned> IdxList) const { + return ExtractValueInst::Create(Agg, IdxList); } Instruction *CreateInsertValue(Constant *Agg, Constant *Val, - const unsigned *IdxList, - unsigned NumIdx) const { - return InsertValueInst::Create(Agg, Val, IdxList, IdxList+NumIdx); + ArrayRef<unsigned> IdxList) const { + return InsertValueInst::Create(Agg, Val, IdxList); } }; diff --git a/include/llvm/Support/PassManagerBuilder.h b/include/llvm/Support/PassManagerBuilder.h index 31624db..b0cec6e 100644 --- a/include/llvm/Support/PassManagerBuilder.h +++ b/include/llvm/Support/PassManagerBuilder.h @@ -67,7 +67,12 @@ public: /// EP_LoopOptimizerEnd - This extension point allows adding loop passes to /// the end of the loop optimizer. - EP_LoopOptimizerEnd + EP_LoopOptimizerEnd, + + /// EP_ScalarOptimizerLate - This extension point allows adding optimization + /// passes after most of the main optimizations, but before the last + /// cleanup-ish optimizations. + EP_ScalarOptimizerLate }; /// The Optimization Level - Specify the basic optimization level. @@ -147,6 +152,7 @@ public: FPM.add(createCFGSimplificationPass()); FPM.add(createScalarReplAggregatesPass()); FPM.add(createEarlyCSEPass()); + FPM.add(createLowerExpectIntrinsicPass()); } /// populateModulePassManager - This sets up the primary pass manager. @@ -188,7 +194,6 @@ public: MPM.add(createArgumentPromotionPass()); // Scalarize uninlined fn args // Start of function pass. - MPM.add(createObjCARCExpandPass()); // Canonicalize ObjC ARC code. // Break up aggregate allocas, using SSAUpdater. MPM.add(createScalarReplAggregatesPass(-1, false)); MPM.add(createEarlyCSEPass()); // Catch trivial redundancies @@ -224,14 +229,16 @@ public: MPM.add(createJumpThreadingPass()); // Thread jumps MPM.add(createCorrelatedValuePropagationPass()); MPM.add(createDeadStoreEliminationPass()); // Delete dead stores - MPM.add(createObjCARCOptPass()); // Objective-C ARC optimizations. + + addExtensionsToPM(EP_ScalarOptimizerLate, MPM); + MPM.add(createAggressiveDCEPass()); // Delete dead instructions MPM.add(createCFGSimplificationPass()); // Merge & remove BBs MPM.add(createInstructionCombiningPass()); // Clean up after everything. if (!DisableUnitAtATime) { + // FIXME: We shouldn't bother with this anymore. MPM.add(createStripDeadPrototypesPass()); // Get rid of dead prototypes - MPM.add(createDeadTypeEliminationPass()); // Eliminate dead types // GlobalOpt already deletes dead functions and globals, at -O3 try a // late pass of GlobalDCE. It is capable of deleting dead cycles. diff --git a/include/llvm/Support/TargetFolder.h b/include/llvm/Support/TargetFolder.h index 20ca557..3233a98 100644 --- a/include/llvm/Support/TargetFolder.h +++ b/include/llvm/Support/TargetFolder.h @@ -21,6 +21,7 @@ #include "llvm/Constants.h" #include "llvm/InstrTypes.h" +#include "llvm/ADT/ArrayRef.h" #include "llvm/Analysis/ConstantFolding.h" namespace llvm { @@ -226,14 +227,14 @@ public: return Fold(ConstantExpr::getShuffleVector(V1, V2, Mask)); } - Constant *CreateExtractValue(Constant *Agg, const unsigned *IdxList, - unsigned NumIdx) const { - return Fold(ConstantExpr::getExtractValue(Agg, IdxList, NumIdx)); + Constant *CreateExtractValue(Constant *Agg, + ArrayRef<unsigned> IdxList) const { + return Fold(ConstantExpr::getExtractValue(Agg, IdxList)); } Constant *CreateInsertValue(Constant *Agg, Constant *Val, - const unsigned *IdxList, unsigned NumIdx) const { - return Fold(ConstantExpr::getInsertValue(Agg, Val, IdxList, NumIdx)); + ArrayRef<unsigned> IdxList) const { + return Fold(ConstantExpr::getInsertValue(Agg, Val, IdxList)); } }; diff --git a/include/llvm/Support/TypeBuilder.h b/include/llvm/Support/TypeBuilder.h index ea63da0..1800778 100644 --- a/include/llvm/Support/TypeBuilder.h +++ b/include/llvm/Support/TypeBuilder.h @@ -18,6 +18,7 @@ #include "llvm/DerivedTypes.h" #include "llvm/LLVMContext.h" #include <limits.h> +#include <vector> namespace llvm { @@ -50,7 +51,7 @@ namespace llvm { /// namespace llvm { /// template<bool xcompile> class TypeBuilder<MyType, xcompile> { /// public: -/// static const StructType *get(LLVMContext &Context) { +/// static StructType *get(LLVMContext &Context) { /// // If you cache this result, be sure to cache it separately /// // for each LLVMContext. /// return StructType::get( @@ -103,7 +104,7 @@ template<typename T, bool cross> class TypeBuilder<const volatile T, cross> // Pointers template<typename T, bool cross> class TypeBuilder<T*, cross> { public: - static const PointerType *get(LLVMContext &Context) { + static PointerType *get(LLVMContext &Context) { return PointerType::getUnqual(TypeBuilder<T,cross>::get(Context)); } }; @@ -114,14 +115,14 @@ template<typename T, bool cross> class TypeBuilder<T&, cross> {}; // Arrays template<typename T, size_t N, bool cross> class TypeBuilder<T[N], cross> { public: - static const ArrayType *get(LLVMContext &Context) { + static ArrayType *get(LLVMContext &Context) { return ArrayType::get(TypeBuilder<T, cross>::get(Context), N); } }; /// LLVM uses an array of length 0 to represent an unknown-length array. template<typename T, bool cross> class TypeBuilder<T[], cross> { public: - static const ArrayType *get(LLVMContext &Context) { + static ArrayType *get(LLVMContext &Context) { return ArrayType::get(TypeBuilder<T, cross>::get(Context), 0); } }; @@ -151,7 +152,7 @@ public: #define DEFINE_INTEGRAL_TYPEBUILDER(T) \ template<> class TypeBuilder<T, false> { \ public: \ - static const IntegerType *get(LLVMContext &Context) { \ + static IntegerType *get(LLVMContext &Context) { \ return IntegerType::get(Context, sizeof(T) * CHAR_BIT); \ } \ }; \ @@ -180,14 +181,14 @@ DEFINE_INTEGRAL_TYPEBUILDER(unsigned long long); template<uint32_t num_bits, bool cross> class TypeBuilder<types::i<num_bits>, cross> { public: - static const IntegerType *get(LLVMContext &C) { + static IntegerType *get(LLVMContext &C) { return IntegerType::get(C, num_bits); } }; template<> class TypeBuilder<float, false> { public: - static const Type *get(LLVMContext& C) { + static Type *get(LLVMContext& C) { return Type::getFloatTy(C); } }; @@ -195,7 +196,7 @@ template<> class TypeBuilder<float, true> {}; template<> class TypeBuilder<double, false> { public: - static const Type *get(LLVMContext& C) { + static Type *get(LLVMContext& C) { return Type::getDoubleTy(C); } }; @@ -203,32 +204,32 @@ template<> class TypeBuilder<double, true> {}; template<bool cross> class TypeBuilder<types::ieee_float, cross> { public: - static const Type *get(LLVMContext& C) { return Type::getFloatTy(C); } + static Type *get(LLVMContext& C) { return Type::getFloatTy(C); } }; template<bool cross> class TypeBuilder<types::ieee_double, cross> { public: - static const Type *get(LLVMContext& C) { return Type::getDoubleTy(C); } + static Type *get(LLVMContext& C) { return Type::getDoubleTy(C); } }; template<bool cross> class TypeBuilder<types::x86_fp80, cross> { public: - static const Type *get(LLVMContext& C) { return Type::getX86_FP80Ty(C); } + static Type *get(LLVMContext& C) { return Type::getX86_FP80Ty(C); } }; template<bool cross> class TypeBuilder<types::fp128, cross> { public: - static const Type *get(LLVMContext& C) { return Type::getFP128Ty(C); } + static Type *get(LLVMContext& C) { return Type::getFP128Ty(C); } }; template<bool cross> class TypeBuilder<types::ppc_fp128, cross> { public: - static const Type *get(LLVMContext& C) { return Type::getPPC_FP128Ty(C); } + static Type *get(LLVMContext& C) { return Type::getPPC_FP128Ty(C); } }; template<bool cross> class TypeBuilder<types::x86_mmx, cross> { public: - static const Type *get(LLVMContext& C) { return Type::getX86_MMXTy(C); } + static Type *get(LLVMContext& C) { return Type::getX86_MMXTy(C); } }; template<bool cross> class TypeBuilder<void, cross> { public: - static const Type *get(LLVMContext &C) { + static Type *get(LLVMContext &C) { return Type::getVoidTy(C); } }; @@ -246,14 +247,14 @@ template<> class TypeBuilder<const volatile void*, false> template<typename R, bool cross> class TypeBuilder<R(), cross> { public: - static const FunctionType *get(LLVMContext &Context) { + static FunctionType *get(LLVMContext &Context) { return FunctionType::get(TypeBuilder<R, cross>::get(Context), false); } }; template<typename R, typename A1, bool cross> class TypeBuilder<R(A1), cross> { public: - static const FunctionType *get(LLVMContext &Context) { - std::vector<const Type*> params; + static FunctionType *get(LLVMContext &Context) { + std::vector<Type*> params; params.reserve(1); params.push_back(TypeBuilder<A1, cross>::get(Context)); return FunctionType::get(TypeBuilder<R, cross>::get(Context), @@ -263,8 +264,8 @@ public: template<typename R, typename A1, typename A2, bool cross> class TypeBuilder<R(A1, A2), cross> { public: - static const FunctionType *get(LLVMContext &Context) { - std::vector<const Type*> params; + static FunctionType *get(LLVMContext &Context) { + std::vector<Type*> params; params.reserve(2); params.push_back(TypeBuilder<A1, cross>::get(Context)); params.push_back(TypeBuilder<A2, cross>::get(Context)); @@ -275,8 +276,8 @@ public: template<typename R, typename A1, typename A2, typename A3, bool cross> class TypeBuilder<R(A1, A2, A3), cross> { public: - static const FunctionType *get(LLVMContext &Context) { - std::vector<const Type*> params; + static FunctionType *get(LLVMContext &Context) { + std::vector<Type*> params; params.reserve(3); params.push_back(TypeBuilder<A1, cross>::get(Context)); params.push_back(TypeBuilder<A2, cross>::get(Context)); @@ -290,8 +291,8 @@ template<typename R, typename A1, typename A2, typename A3, typename A4, bool cross> class TypeBuilder<R(A1, A2, A3, A4), cross> { public: - static const FunctionType *get(LLVMContext &Context) { - std::vector<const Type*> params; + static FunctionType *get(LLVMContext &Context) { + std::vector<Type*> params; params.reserve(4); params.push_back(TypeBuilder<A1, cross>::get(Context)); params.push_back(TypeBuilder<A2, cross>::get(Context)); @@ -306,8 +307,8 @@ template<typename R, typename A1, typename A2, typename A3, typename A4, typename A5, bool cross> class TypeBuilder<R(A1, A2, A3, A4, A5), cross> { public: - static const FunctionType *get(LLVMContext &Context) { - std::vector<const Type*> params; + static FunctionType *get(LLVMContext &Context) { + std::vector<Type*> params; params.reserve(5); params.push_back(TypeBuilder<A1, cross>::get(Context)); params.push_back(TypeBuilder<A2, cross>::get(Context)); @@ -321,15 +322,15 @@ public: template<typename R, bool cross> class TypeBuilder<R(...), cross> { public: - static const FunctionType *get(LLVMContext &Context) { + static FunctionType *get(LLVMContext &Context) { return FunctionType::get(TypeBuilder<R, cross>::get(Context), true); } }; template<typename R, typename A1, bool cross> class TypeBuilder<R(A1, ...), cross> { public: - static const FunctionType *get(LLVMContext &Context) { - std::vector<const Type*> params; + static FunctionType *get(LLVMContext &Context) { + std::vector<Type*> params; params.reserve(1); params.push_back(TypeBuilder<A1, cross>::get(Context)); return FunctionType::get(TypeBuilder<R, cross>::get(Context), params, true); @@ -338,8 +339,8 @@ public: template<typename R, typename A1, typename A2, bool cross> class TypeBuilder<R(A1, A2, ...), cross> { public: - static const FunctionType *get(LLVMContext &Context) { - std::vector<const Type*> params; + static FunctionType *get(LLVMContext &Context) { + std::vector<Type*> params; params.reserve(2); params.push_back(TypeBuilder<A1, cross>::get(Context)); params.push_back(TypeBuilder<A2, cross>::get(Context)); @@ -350,8 +351,8 @@ public: template<typename R, typename A1, typename A2, typename A3, bool cross> class TypeBuilder<R(A1, A2, A3, ...), cross> { public: - static const FunctionType *get(LLVMContext &Context) { - std::vector<const Type*> params; + static FunctionType *get(LLVMContext &Context) { + std::vector<Type*> params; params.reserve(3); params.push_back(TypeBuilder<A1, cross>::get(Context)); params.push_back(TypeBuilder<A2, cross>::get(Context)); @@ -365,8 +366,8 @@ template<typename R, typename A1, typename A2, typename A3, typename A4, bool cross> class TypeBuilder<R(A1, A2, A3, A4, ...), cross> { public: - static const FunctionType *get(LLVMContext &Context) { - std::vector<const Type*> params; + static FunctionType *get(LLVMContext &Context) { + std::vector<Type*> params; params.reserve(4); params.push_back(TypeBuilder<A1, cross>::get(Context)); params.push_back(TypeBuilder<A2, cross>::get(Context)); @@ -381,8 +382,8 @@ template<typename R, typename A1, typename A2, typename A3, typename A4, typename A5, bool cross> class TypeBuilder<R(A1, A2, A3, A4, A5, ...), cross> { public: - static const FunctionType *get(LLVMContext &Context) { - std::vector<const Type*> params; + static FunctionType *get(LLVMContext &Context) { + std::vector<Type*> params; params.reserve(5); params.push_back(TypeBuilder<A1, cross>::get(Context)); params.push_back(TypeBuilder<A2, cross>::get(Context)); |