From df1fb13a5cc47f589444dddf568c2912d0deaeb9 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sat, 28 May 2011 14:26:31 +0000 Subject: [PATCH] Eliminate temporary argument vectors. llvm-svn: 132260 --- clang/lib/CodeGen/CGBuiltin.cpp | 5 ++--- clang/lib/CodeGen/CGDeclCXX.cpp | 10 ++-------- clang/lib/CodeGen/CGExprScalar.cpp | 4 +--- clang/lib/CodeGen/CGObjCGNU.cpp | 23 ++++++++--------------- clang/lib/CodeGen/CodeGenFunction.cpp | 14 +++++--------- clang/lib/CodeGen/ItaniumCXXABI.cpp | 14 +++----------- 6 files changed, 21 insertions(+), 49 deletions(-) diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 2f4104da9374..14bebaf3c1cb 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -164,9 +164,8 @@ static Value *EmitFAbs(CodeGenFunction &CGF, Value *V, QualType ValTy) { } // The prototype is something that takes and returns whatever V's type is. - std::vector Args; - Args.push_back(V->getType()); - llvm::FunctionType *FT = llvm::FunctionType::get(V->getType(), Args, false); + llvm::FunctionType *FT = llvm::FunctionType::get(V->getType(), V->getType(), + false); llvm::Value *Fn = CGF.CGM.CreateRuntimeFunction(FT, FnName); return CGF.Builder.CreateCall(Fn, V, "abs"); diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index a24203c44982..178badd44d81 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -117,19 +117,13 @@ CodeGenFunction::EmitCXXGlobalDtorRegistration(llvm::Constant *DtorFn, return; } - std::vector Params; - Params.push_back(Int8PtrTy); - // Get the destructor function type const llvm::Type *DtorFnTy = llvm::FunctionType::get(llvm::Type::getVoidTy(getLLVMContext()), - Params, false); + Int8PtrTy, false); DtorFnTy = llvm::PointerType::getUnqual(DtorFnTy); - Params.clear(); - Params.push_back(DtorFnTy); - Params.push_back(Int8PtrTy); - Params.push_back(Int8PtrTy); + const llvm::Type *Params[] = { DtorFnTy, Int8PtrTy, Int8PtrTy }; // Get the __cxa_atexit function type // extern "C" int __cxa_atexit ( void (*f)(void *), void *p, void *d ); diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index be9089a9c525..b1d457589d82 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -1788,9 +1788,7 @@ Value *ScalarExprEmitter::EmitOverflowCheckedBinOp(const BinOpInfo &Ops) { // Get the overflow handler. const llvm::Type *Int8Ty = llvm::Type::getInt8Ty(VMContext); - std::vector argTypes; - argTypes.push_back(CGF.Int64Ty); argTypes.push_back(CGF.Int64Ty); - argTypes.push_back(Int8Ty); argTypes.push_back(Int8Ty); + const llvm::Type *argTypes[] = { CGF.Int64Ty, CGF.Int64Ty, Int8Ty, Int8Ty }; llvm::FunctionType *handlerTy = llvm::FunctionType::get(CGF.Int64Ty, argTypes, true); llvm::Value *handler = CGF.CGM.CreateRuntimeFunction(handlerTy, *handlerName); diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp index 9c0ecc751dc5..58bcf6f40ad6 100644 --- a/clang/lib/CodeGen/CGObjCGNU.cpp +++ b/clang/lib/CodeGen/CGObjCGNU.cpp @@ -736,9 +736,7 @@ CGObjCGNU::CGObjCGNU(CodeGenModule &cgm, unsigned runtimeABIVersion, PtrDiffTy, BoolTy, BoolTy, NULL); // IMP type - std::vector IMPArgs; - IMPArgs.push_back(IdTy); - IMPArgs.push_back(SelectorTy); + const llvm::Type *IMPArgs[] = { IdTy, SelectorTy }; IMPTy = llvm::PointerType::getUnqual(llvm::FunctionType::get(IdTy, IMPArgs, true)); @@ -786,11 +784,8 @@ llvm::Value *CGObjCGNU::GetClass(CGBuilderTy &Builder, EmitClassRef(OID->getNameAsString()); ClassName = Builder.CreateStructGEP(ClassName, 0); - std::vector Params(1, PtrToInt8Ty); llvm::Constant *ClassLookupFn = - CGM.CreateRuntimeFunction(llvm::FunctionType::get(IdTy, - Params, - true), + CGM.CreateRuntimeFunction(llvm::FunctionType::get(IdTy, PtrToInt8Ty, true), "objc_lookup_class"); return Builder.CreateCall(ClassLookupFn, ClassName); } @@ -983,14 +978,12 @@ CGObjCGNU::GenerateMessageSendSuper(CodeGenFunction &CGF, llvm::Value *ReceiverClass = 0; if (isCategoryImpl) { llvm::Constant *classLookupFunction = 0; - std::vector Params; - Params.push_back(PtrTy); if (IsClassMessage) { classLookupFunction = CGM.CreateRuntimeFunction(llvm::FunctionType::get( - IdTy, Params, true), "objc_get_meta_class"); + IdTy, PtrTy, true), "objc_get_meta_class"); } else { classLookupFunction = CGM.CreateRuntimeFunction(llvm::FunctionType::get( - IdTy, Params, true), "objc_get_class"); + IdTy, PtrTy, true), "objc_get_class"); } ReceiverClass = Builder.CreateCall(classLookupFunction, MakeConstantString(Class->getNameAsString())); @@ -2183,10 +2176,10 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() { CGBuilderTy Builder(VMContext); Builder.SetInsertPoint(EntryBB); - std::vector Params(1, - llvm::PointerType::getUnqual(ModuleTy)); - llvm::Value *Register = CGM.CreateRuntimeFunction(llvm::FunctionType::get( - llvm::Type::getVoidTy(VMContext), Params, true), "__objc_exec_class"); + llvm::FunctionType *FT = + llvm::FunctionType::get(Builder.getVoidTy(), + llvm::PointerType::getUnqual(ModuleTy), true); + llvm::Value *Register = CGM.CreateRuntimeFunction(FT, "__objc_exec_class"); Builder.CreateCall(Register, Module); Builder.CreateRetVoid(); diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 28a4fa4baecd..d42057aba033 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -205,16 +205,12 @@ bool CodeGenFunction::ShouldInstrumentFunction() { /// instrumentation function with the current function and the call site, if /// function instrumentation is enabled. void CodeGenFunction::EmitFunctionInstrumentation(const char *Fn) { - const llvm::PointerType *PointerTy; - const llvm::FunctionType *FunctionTy; - std::vector ProfileFuncArgs; - // void __cyg_profile_func_{enter,exit} (void *this_fn, void *call_site); - PointerTy = Int8PtrTy; - ProfileFuncArgs.push_back(PointerTy); - ProfileFuncArgs.push_back(PointerTy); - FunctionTy = llvm::FunctionType::get(llvm::Type::getVoidTy(getLLVMContext()), - ProfileFuncArgs, false); + const llvm::PointerType *PointerTy = Int8PtrTy; + const llvm::Type *ProfileFuncArgs[] = { PointerTy, PointerTy }; + const llvm::FunctionType *FunctionTy = + llvm::FunctionType::get(llvm::Type::getVoidTy(getLLVMContext()), + ProfileFuncArgs, false); llvm::Constant *F = CGM.CreateRuntimeFunction(FunctionTy, Fn); llvm::CallInst *CallSite = Builder.CreateCall( diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index 33abf3a4aaf7..12ef9bd030bd 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -1007,11 +1007,9 @@ void ARMCXXABI::ReadArrayCookie(CodeGenFunction &CGF, static llvm::Constant *getGuardAcquireFn(CodeGenModule &CGM, const llvm::PointerType *GuardPtrTy) { // int __cxa_guard_acquire(__guard *guard_object); - - std::vector Args(1, GuardPtrTy); const llvm::FunctionType *FTy = llvm::FunctionType::get(CGM.getTypes().ConvertType(CGM.getContext().IntTy), - Args, /*isVarArg=*/false); + GuardPtrTy, /*isVarArg=*/false); return CGM.CreateRuntimeFunction(FTy, "__cxa_guard_acquire"); } @@ -1019,12 +1017,9 @@ static llvm::Constant *getGuardAcquireFn(CodeGenModule &CGM, static llvm::Constant *getGuardReleaseFn(CodeGenModule &CGM, const llvm::PointerType *GuardPtrTy) { // void __cxa_guard_release(__guard *guard_object); - - std::vector Args(1, GuardPtrTy); - const llvm::FunctionType *FTy = llvm::FunctionType::get(llvm::Type::getVoidTy(CGM.getLLVMContext()), - Args, /*isVarArg=*/false); + GuardPtrTy, /*isVarArg=*/false); return CGM.CreateRuntimeFunction(FTy, "__cxa_guard_release"); } @@ -1032,12 +1027,9 @@ static llvm::Constant *getGuardReleaseFn(CodeGenModule &CGM, static llvm::Constant *getGuardAbortFn(CodeGenModule &CGM, const llvm::PointerType *GuardPtrTy) { // void __cxa_guard_abort(__guard *guard_object); - - std::vector Args(1, GuardPtrTy); - const llvm::FunctionType *FTy = llvm::FunctionType::get(llvm::Type::getVoidTy(CGM.getLLVMContext()), - Args, /*isVarArg=*/false); + GuardPtrTy, /*isVarArg=*/false); return CGM.CreateRuntimeFunction(FTy, "__cxa_guard_abort"); }