From 42e06119496e84e74cfc60230b18fcb53b35eb1c Mon Sep 17 00:00:00 2001 From: John McCall Date: Sun, 15 May 2011 02:19:42 +0000 Subject: [PATCH] More killing of std::vector. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131374 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGCall.cpp | 76 +++++++++++++++++++------------------- lib/CodeGen/CodeGenTypes.h | 5 ++- 2 files changed, 41 insertions(+), 40 deletions(-) diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp index a765f0f343..6b6f3176b0 100644 --- a/lib/CodeGen/CGCall.cpp +++ b/lib/CodeGen/CGCall.cpp @@ -309,10 +309,10 @@ CGFunctionInfo::CGFunctionInfo(unsigned _CallingConvention, /***/ -void CodeGenTypes::GetExpandedTypes(QualType Ty, - std::vector &ArgTys, - bool IsRecursive) { - const RecordType *RT = Ty->getAsStructureType(); +void CodeGenTypes::GetExpandedTypes(QualType type, + llvm::SmallVectorImpl &expandedTypes, + bool isRecursive) { + const RecordType *RT = type->getAsStructureType(); assert(RT && "Can only expand structure types."); const RecordDecl *RD = RT->getDecl(); assert(!RD->hasFlexibleArrayMember() && @@ -324,11 +324,11 @@ void CodeGenTypes::GetExpandedTypes(QualType Ty, assert(!FD->isBitField() && "Cannot expand structure with bit-field members."); - QualType FT = FD->getType(); - if (CodeGenFunction::hasAggregateLLVMType(FT)) - GetExpandedTypes(FT, ArgTys, IsRecursive); + QualType fieldType = FD->getType(); + if (fieldType->isRecordType()) + GetExpandedTypes(fieldType, expandedTypes, isRecursive); else - ArgTys.push_back(ConvertType(FT, IsRecursive)); + expandedTypes.push_back(ConvertType(fieldType, isRecursive)); } } @@ -612,49 +612,49 @@ const llvm::FunctionType *CodeGenTypes::GetFunctionType(GlobalDecl GD) { } const llvm::FunctionType * -CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI, bool IsVariadic, - bool IsRecursive) { - std::vector ArgTys; +CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI, bool isVariadic, + bool isRecursive) { + llvm::SmallVector argTypes; + const llvm::Type *resultType = 0; - const llvm::Type *ResultType = 0; - - QualType RetTy = FI.getReturnType(); - const ABIArgInfo &RetAI = FI.getReturnInfo(); - switch (RetAI.getKind()) { + const ABIArgInfo &retAI = FI.getReturnInfo(); + switch (retAI.getKind()) { case ABIArgInfo::Expand: - assert(0 && "Invalid ABI kind for return argument"); + llvm_unreachable("Invalid ABI kind for return argument"); case ABIArgInfo::Extend: case ABIArgInfo::Direct: - ResultType = RetAI.getCoerceToType(); + resultType = retAI.getCoerceToType(); break; case ABIArgInfo::Indirect: { - assert(!RetAI.getIndirectAlign() && "Align unused on indirect return."); - ResultType = llvm::Type::getVoidTy(getLLVMContext()); - const llvm::Type *STy = ConvertType(RetTy, IsRecursive); - unsigned AS = Context.getTargetAddressSpace(RetTy); - ArgTys.push_back(llvm::PointerType::get(STy, AS)); + assert(!retAI.getIndirectAlign() && "Align unused on indirect return."); + resultType = llvm::Type::getVoidTy(getLLVMContext()); + + QualType ret = FI.getReturnType(); + const llvm::Type *ty = ConvertType(ret, isRecursive); + unsigned addressSpace = Context.getTargetAddressSpace(ret); + argTypes.push_back(llvm::PointerType::get(ty, addressSpace)); break; } case ABIArgInfo::Ignore: - ResultType = llvm::Type::getVoidTy(getLLVMContext()); + resultType = llvm::Type::getVoidTy(getLLVMContext()); break; } for (CGFunctionInfo::const_arg_iterator it = FI.arg_begin(), ie = FI.arg_end(); it != ie; ++it) { - const ABIArgInfo &AI = it->info; + const ABIArgInfo &argAI = it->info; - switch (AI.getKind()) { + switch (argAI.getKind()) { case ABIArgInfo::Ignore: break; case ABIArgInfo::Indirect: { // indirect arguments are always on the stack, which is addr space #0. - const llvm::Type *LTy = ConvertTypeForMem(it->type, IsRecursive); - ArgTys.push_back(llvm::PointerType::getUnqual(LTy)); + const llvm::Type *LTy = ConvertTypeForMem(it->type, isRecursive); + argTypes.push_back(LTy->getPointerTo()); break; } @@ -663,23 +663,23 @@ CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI, bool IsVariadic, // If the coerce-to type is a first class aggregate, flatten it. Either // way is semantically identical, but fast-isel and the optimizer // generally likes scalar values better than FCAs. - const llvm::Type *ArgTy = AI.getCoerceToType(); - if (const llvm::StructType *STy = dyn_cast(ArgTy)) { - for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) - ArgTys.push_back(STy->getElementType(i)); + const llvm::Type *argType = argAI.getCoerceToType(); + if (const llvm::StructType *st = dyn_cast(argType)) { + for (unsigned i = 0, e = st->getNumElements(); i != e; ++i) + argTypes.push_back(st->getElementType(i)); } else { - ArgTys.push_back(ArgTy); + argTypes.push_back(argType); } break; } case ABIArgInfo::Expand: - GetExpandedTypes(it->type, ArgTys, IsRecursive); + GetExpandedTypes(it->type, argTypes, isRecursive); break; } } - return llvm::FunctionType::get(ResultType, ArgTys, IsVariadic); + return llvm::FunctionType::get(resultType, argTypes, isVariadic); } const llvm::Type *CodeGenTypes::GetFunctionTypeForVTable(GlobalDecl GD) { @@ -822,12 +822,12 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI, continue; case ABIArgInfo::Expand: { - std::vector Tys; + llvm::SmallVector types; // FIXME: This is rather inefficient. Do we ever actually need to do // anything here? The result should be just reconstructed on the other // side, so extension should be a non-issue. - getTypes().GetExpandedTypes(ParamType, Tys, false); - Index += Tys.size(); + getTypes().GetExpandedTypes(ParamType, types, false); + Index += types.size(); continue; } } diff --git a/lib/CodeGen/CodeGenTypes.h b/lib/CodeGen/CodeGenTypes.h index dc383cb4db..ff1eb4c45b 100644 --- a/lib/CodeGen/CodeGenTypes.h +++ b/lib/CodeGen/CodeGenTypes.h @@ -220,8 +220,9 @@ public: // These are internal details of CGT that shouldn't be used externally. /// GetExpandedTypes - Expand the type \arg Ty into the LLVM /// argument types it would be passed as on the provided vector \arg /// ArgTys. See ABIArgInfo::Expand. - void GetExpandedTypes(QualType Ty, std::vector &ArgTys, - bool IsRecursive); + void GetExpandedTypes(QualType type, + llvm::SmallVectorImpl &expanded, + bool isRecursive); /// IsZeroInitializable - Return whether a type can be /// zero-initialized (in the C++ sense) with an LLVM zeroinitializer. -- 2.40.0