Remove some unnecessary single element array temporaries.

llvm-svn: 136461
This commit is contained in:
Jay Foad 2011-07-29 13:56:53 +00:00
parent be64bbf979
commit 5709f7c5f7
6 changed files with 20 additions and 38 deletions

View File

@ -164,8 +164,7 @@ static Value *EmitFAbs(CodeGenFunction &CGF, Value *V, QualType ValTy) {
} }
// The prototype is something that takes and returns whatever V's type is. // The prototype is something that takes and returns whatever V's type is.
llvm::Type *ArgTys[] = { V->getType() }; llvm::FunctionType *FT = llvm::FunctionType::get(V->getType(), V->getType(),
llvm::FunctionType *FT = llvm::FunctionType::get(V->getType(), ArgTys,
false); false);
llvm::Value *Fn = CGF.CGM.CreateRuntimeFunction(FT, FnName); llvm::Value *Fn = CGF.CGM.CreateRuntimeFunction(FT, FnName);

View File

@ -126,10 +126,9 @@ CodeGenFunction::EmitCXXGlobalDtorRegistration(llvm::Constant *DtorFn,
} }
// Get the destructor function type // Get the destructor function type
llvm::Type *ArgTys[] = { Int8PtrTy };
llvm::Type *DtorFnTy = llvm::Type *DtorFnTy =
llvm::FunctionType::get(llvm::Type::getVoidTy(getLLVMContext()), llvm::FunctionType::get(llvm::Type::getVoidTy(getLLVMContext()),
ArgTys, false); Int8PtrTy, false);
DtorFnTy = llvm::PointerType::getUnqual(DtorFnTy); DtorFnTy = llvm::PointerType::getUnqual(DtorFnTy);
llvm::Type *Params[] = { DtorFnTy, Int8PtrTy, Int8PtrTy }; llvm::Type *Params[] = { DtorFnTy, Int8PtrTy, Int8PtrTy };

View File

@ -29,9 +29,8 @@ using namespace CodeGen;
static llvm::Constant *getAllocateExceptionFn(CodeGenFunction &CGF) { static llvm::Constant *getAllocateExceptionFn(CodeGenFunction &CGF) {
// void *__cxa_allocate_exception(size_t thrown_size); // void *__cxa_allocate_exception(size_t thrown_size);
llvm::Type *ArgTys[] = { CGF.SizeTy };
llvm::FunctionType *FTy = llvm::FunctionType *FTy =
llvm::FunctionType::get(CGF.Int8PtrTy, ArgTys, /*IsVarArgs=*/false); llvm::FunctionType::get(CGF.Int8PtrTy, CGF.SizeTy, /*IsVarArgs=*/false);
return CGF.CGM.CreateRuntimeFunction(FTy, "__cxa_allocate_exception"); return CGF.CGM.CreateRuntimeFunction(FTy, "__cxa_allocate_exception");
} }
@ -39,9 +38,8 @@ static llvm::Constant *getAllocateExceptionFn(CodeGenFunction &CGF) {
static llvm::Constant *getFreeExceptionFn(CodeGenFunction &CGF) { static llvm::Constant *getFreeExceptionFn(CodeGenFunction &CGF) {
// void __cxa_free_exception(void *thrown_exception); // void __cxa_free_exception(void *thrown_exception);
llvm::Type *ArgTys[] = { CGF.Int8PtrTy };
llvm::FunctionType *FTy = llvm::FunctionType *FTy =
llvm::FunctionType::get(CGF.VoidTy, ArgTys, /*IsVarArgs=*/false); llvm::FunctionType::get(CGF.VoidTy, CGF.Int8PtrTy, /*IsVarArgs=*/false);
return CGF.CGM.CreateRuntimeFunction(FTy, "__cxa_free_exception"); return CGF.CGM.CreateRuntimeFunction(FTy, "__cxa_free_exception");
} }
@ -69,9 +67,8 @@ static llvm::Constant *getReThrowFn(CodeGenFunction &CGF) {
static llvm::Constant *getGetExceptionPtrFn(CodeGenFunction &CGF) { static llvm::Constant *getGetExceptionPtrFn(CodeGenFunction &CGF) {
// void *__cxa_get_exception_ptr(void*); // void *__cxa_get_exception_ptr(void*);
llvm::Type *ArgTys[] = { CGF.Int8PtrTy };
llvm::FunctionType *FTy = llvm::FunctionType *FTy =
llvm::FunctionType::get(CGF.Int8PtrTy, ArgTys, /*IsVarArgs=*/false); llvm::FunctionType::get(CGF.Int8PtrTy, CGF.Int8PtrTy, /*IsVarArgs=*/false);
return CGF.CGM.CreateRuntimeFunction(FTy, "__cxa_get_exception_ptr"); return CGF.CGM.CreateRuntimeFunction(FTy, "__cxa_get_exception_ptr");
} }
@ -79,9 +76,8 @@ static llvm::Constant *getGetExceptionPtrFn(CodeGenFunction &CGF) {
static llvm::Constant *getBeginCatchFn(CodeGenFunction &CGF) { static llvm::Constant *getBeginCatchFn(CodeGenFunction &CGF) {
// void *__cxa_begin_catch(void*); // void *__cxa_begin_catch(void*);
llvm::Type *ArgTys[] = { CGF.Int8PtrTy };
llvm::FunctionType *FTy = llvm::FunctionType *FTy =
llvm::FunctionType::get(CGF.Int8PtrTy, ArgTys, /*IsVarArgs=*/false); llvm::FunctionType::get(CGF.Int8PtrTy, CGF.Int8PtrTy, /*IsVarArgs=*/false);
return CGF.CGM.CreateRuntimeFunction(FTy, "__cxa_begin_catch"); return CGF.CGM.CreateRuntimeFunction(FTy, "__cxa_begin_catch");
} }
@ -98,17 +94,15 @@ static llvm::Constant *getEndCatchFn(CodeGenFunction &CGF) {
static llvm::Constant *getUnexpectedFn(CodeGenFunction &CGF) { static llvm::Constant *getUnexpectedFn(CodeGenFunction &CGF) {
// void __cxa_call_unexepcted(void *thrown_exception); // void __cxa_call_unexepcted(void *thrown_exception);
llvm::Type *ArgTys[] = { CGF.Int8PtrTy };
llvm::FunctionType *FTy = llvm::FunctionType *FTy =
llvm::FunctionType::get(CGF.VoidTy, ArgTys, /*IsVarArgs=*/false); llvm::FunctionType::get(CGF.VoidTy, CGF.Int8PtrTy, /*IsVarArgs=*/false);
return CGF.CGM.CreateRuntimeFunction(FTy, "__cxa_call_unexpected"); return CGF.CGM.CreateRuntimeFunction(FTy, "__cxa_call_unexpected");
} }
llvm::Constant *CodeGenFunction::getUnwindResumeFn() { llvm::Constant *CodeGenFunction::getUnwindResumeFn() {
llvm::Type *ArgTys[] = { Int8PtrTy };
llvm::FunctionType *FTy = llvm::FunctionType *FTy =
llvm::FunctionType::get(VoidTy, ArgTys, /*IsVarArgs=*/false); llvm::FunctionType::get(VoidTy, Int8PtrTy, /*IsVarArgs=*/false);
if (CGM.getLangOptions().SjLjExceptions) if (CGM.getLangOptions().SjLjExceptions)
return CGM.CreateRuntimeFunction(FTy, "_Unwind_SjLj_Resume"); return CGM.CreateRuntimeFunction(FTy, "_Unwind_SjLj_Resume");
@ -116,9 +110,8 @@ llvm::Constant *CodeGenFunction::getUnwindResumeFn() {
} }
llvm::Constant *CodeGenFunction::getUnwindResumeOrRethrowFn() { llvm::Constant *CodeGenFunction::getUnwindResumeOrRethrowFn() {
llvm::Type *ArgTys[] = { Int8PtrTy };
llvm::FunctionType *FTy = llvm::FunctionType *FTy =
llvm::FunctionType::get(VoidTy, ArgTys, /*IsVarArgs=*/false); llvm::FunctionType::get(VoidTy, Int8PtrTy, /*IsVarArgs=*/false);
if (CGM.getLangOptions().SjLjExceptions) if (CGM.getLangOptions().SjLjExceptions)
return CGM.CreateRuntimeFunction(FTy, "_Unwind_SjLj_Resume_or_Rethrow"); return CGM.CreateRuntimeFunction(FTy, "_Unwind_SjLj_Resume_or_Rethrow");
@ -146,9 +139,8 @@ static llvm::Constant *getTerminateFn(CodeGenFunction &CGF) {
static llvm::Constant *getCatchallRethrowFn(CodeGenFunction &CGF, static llvm::Constant *getCatchallRethrowFn(CodeGenFunction &CGF,
StringRef Name) { StringRef Name) {
llvm::Type *ArgTys[] = { CGF.Int8PtrTy };
llvm::FunctionType *FTy = llvm::FunctionType *FTy =
llvm::FunctionType::get(CGF.VoidTy, ArgTys, /*IsVarArgs=*/false); llvm::FunctionType::get(CGF.VoidTy, CGF.Int8PtrTy, /*IsVarArgs=*/false);
return CGF.CGM.CreateRuntimeFunction(FTy, Name); return CGF.CGM.CreateRuntimeFunction(FTy, Name);
} }

View File

@ -1532,8 +1532,7 @@ CodeGenFunction::EmitARCRetainAutoreleasedReturnValue(llvm::Value *value) {
assert(metadata->getNumOperands() <= 1); assert(metadata->getNumOperands() <= 1);
if (metadata->getNumOperands() == 0) { if (metadata->getNumOperands() == 0) {
llvm::Value *string = llvm::MDString::get(getLLVMContext(), assembly); llvm::Value *string = llvm::MDString::get(getLLVMContext(), assembly);
llvm::Value *args[] = { string }; metadata->addOperand(llvm::MDNode::get(getLLVMContext(), string));
metadata->addOperand(llvm::MDNode::get(getLLVMContext(), args));
} }
} }
} }
@ -2220,9 +2219,8 @@ void CodeGenFunction::EmitObjCAutoreleasePoolStmt(
/// make sure it survives garbage collection until this point. /// make sure it survives garbage collection until this point.
void CodeGenFunction::EmitExtendGCLifetime(llvm::Value *object) { void CodeGenFunction::EmitExtendGCLifetime(llvm::Value *object) {
// We just use an inline assembly. // We just use an inline assembly.
llvm::Type *paramTypes[] = { VoidPtrTy };
llvm::FunctionType *extenderType llvm::FunctionType *extenderType
= llvm::FunctionType::get(VoidTy, paramTypes, /*variadic*/ false); = llvm::FunctionType::get(VoidTy, VoidPtrTy, /*variadic*/ false);
llvm::Value *extender llvm::Value *extender
= llvm::InlineAsm::get(extenderType, = llvm::InlineAsm::get(extenderType,
/* assembly */ "", /* assembly */ "",

View File

@ -792,9 +792,8 @@ llvm::Value *CGObjCGNU::GetClassNamed(CGBuilderTy &Builder,
EmitClassRef(Name); EmitClassRef(Name);
ClassName = Builder.CreateStructGEP(ClassName, 0); ClassName = Builder.CreateStructGEP(ClassName, 0);
llvm::Type *ArgTys[] = { PtrToInt8Ty };
llvm::Constant *ClassLookupFn = llvm::Constant *ClassLookupFn =
CGM.CreateRuntimeFunction(llvm::FunctionType::get(IdTy, ArgTys, true), CGM.CreateRuntimeFunction(llvm::FunctionType::get(IdTy, PtrToInt8Ty, true),
"objc_lookup_class"); "objc_lookup_class");
return Builder.CreateCall(ClassLookupFn, ClassName); return Builder.CreateCall(ClassLookupFn, ClassName);
} }
@ -998,13 +997,11 @@ CGObjCGNU::GenerateMessageSendSuper(CodeGenFunction &CGF,
if (isCategoryImpl) { if (isCategoryImpl) {
llvm::Constant *classLookupFunction = 0; llvm::Constant *classLookupFunction = 0;
if (IsClassMessage) { if (IsClassMessage) {
llvm::Type *ArgTys[] = { PtrTy };
classLookupFunction = CGM.CreateRuntimeFunction(llvm::FunctionType::get( classLookupFunction = CGM.CreateRuntimeFunction(llvm::FunctionType::get(
IdTy, ArgTys, true), "objc_get_meta_class"); IdTy, PtrTy, true), "objc_get_meta_class");
} else { } else {
llvm::Type *ArgTys[] = { PtrTy };
classLookupFunction = CGM.CreateRuntimeFunction(llvm::FunctionType::get( classLookupFunction = CGM.CreateRuntimeFunction(llvm::FunctionType::get(
IdTy, ArgTys, true), "objc_get_class"); IdTy, PtrTy, true), "objc_get_class");
} }
ReceiverClass = Builder.CreateCall(classLookupFunction, ReceiverClass = Builder.CreateCall(classLookupFunction,
MakeConstantString(Class->getNameAsString())); MakeConstantString(Class->getNameAsString()));
@ -2201,9 +2198,9 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() {
CGBuilderTy Builder(VMContext); CGBuilderTy Builder(VMContext);
Builder.SetInsertPoint(EntryBB); Builder.SetInsertPoint(EntryBB);
llvm::Type *ArgTys[] = { llvm::PointerType::getUnqual(ModuleTy) };
llvm::FunctionType *FT = llvm::FunctionType *FT =
llvm::FunctionType::get(Builder.getVoidTy(), ArgTys, true); llvm::FunctionType::get(Builder.getVoidTy(),
llvm::PointerType::getUnqual(ModuleTy), true);
llvm::Value *Register = CGM.CreateRuntimeFunction(FT, "__objc_exec_class"); llvm::Value *Register = CGM.CreateRuntimeFunction(FT, "__objc_exec_class");
Builder.CreateCall(Register, Module); Builder.CreateCall(Register, Module);
Builder.CreateRetVoid(); Builder.CreateRetVoid();

View File

@ -1016,10 +1016,9 @@ void ARMCXXABI::ReadArrayCookie(CodeGenFunction &CGF,
static llvm::Constant *getGuardAcquireFn(CodeGenModule &CGM, static llvm::Constant *getGuardAcquireFn(CodeGenModule &CGM,
llvm::PointerType *GuardPtrTy) { llvm::PointerType *GuardPtrTy) {
// int __cxa_guard_acquire(__guard *guard_object); // int __cxa_guard_acquire(__guard *guard_object);
llvm::Type *ArgTys[] = { GuardPtrTy };
llvm::FunctionType *FTy = llvm::FunctionType *FTy =
llvm::FunctionType::get(CGM.getTypes().ConvertType(CGM.getContext().IntTy), llvm::FunctionType::get(CGM.getTypes().ConvertType(CGM.getContext().IntTy),
ArgTys, /*isVarArg=*/false); GuardPtrTy, /*isVarArg=*/false);
return CGM.CreateRuntimeFunction(FTy, "__cxa_guard_acquire"); return CGM.CreateRuntimeFunction(FTy, "__cxa_guard_acquire");
} }
@ -1027,10 +1026,9 @@ static llvm::Constant *getGuardAcquireFn(CodeGenModule &CGM,
static llvm::Constant *getGuardReleaseFn(CodeGenModule &CGM, static llvm::Constant *getGuardReleaseFn(CodeGenModule &CGM,
llvm::PointerType *GuardPtrTy) { llvm::PointerType *GuardPtrTy) {
// void __cxa_guard_release(__guard *guard_object); // void __cxa_guard_release(__guard *guard_object);
llvm::Type *ArgTys[] = { GuardPtrTy };
llvm::FunctionType *FTy = llvm::FunctionType *FTy =
llvm::FunctionType::get(llvm::Type::getVoidTy(CGM.getLLVMContext()), llvm::FunctionType::get(llvm::Type::getVoidTy(CGM.getLLVMContext()),
ArgTys, /*isVarArg=*/false); GuardPtrTy, /*isVarArg=*/false);
return CGM.CreateRuntimeFunction(FTy, "__cxa_guard_release"); return CGM.CreateRuntimeFunction(FTy, "__cxa_guard_release");
} }
@ -1038,10 +1036,9 @@ static llvm::Constant *getGuardReleaseFn(CodeGenModule &CGM,
static llvm::Constant *getGuardAbortFn(CodeGenModule &CGM, static llvm::Constant *getGuardAbortFn(CodeGenModule &CGM,
llvm::PointerType *GuardPtrTy) { llvm::PointerType *GuardPtrTy) {
// void __cxa_guard_abort(__guard *guard_object); // void __cxa_guard_abort(__guard *guard_object);
llvm::Type *ArgTys[] = { GuardPtrTy };
llvm::FunctionType *FTy = llvm::FunctionType *FTy =
llvm::FunctionType::get(llvm::Type::getVoidTy(CGM.getLLVMContext()), llvm::FunctionType::get(llvm::Type::getVoidTy(CGM.getLLVMContext()),
ArgTys, /*isVarArg=*/false); GuardPtrTy, /*isVarArg=*/false);
return CGM.CreateRuntimeFunction(FTy, "__cxa_guard_abort"); return CGM.CreateRuntimeFunction(FTy, "__cxa_guard_abort");
} }