[cfe-commits] r131374 - in /cfe/trunk/lib/CodeGen: CGCall.cpp CodeGenTypes.h

John McCall rjmccall at apple.com
Sat May 14 19:19:43 PDT 2011


Author: rjmccall
Date: Sat May 14 21:19:42 2011
New Revision: 131374

URL: http://llvm.org/viewvc/llvm-project?rev=131374&view=rev
Log:
More killing of std::vector.


Modified:
    cfe/trunk/lib/CodeGen/CGCall.cpp
    cfe/trunk/lib/CodeGen/CodeGenTypes.h

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=131374&r1=131373&r2=131374&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Sat May 14 21:19:42 2011
@@ -309,10 +309,10 @@
 
 /***/
 
-void CodeGenTypes::GetExpandedTypes(QualType Ty,
-                                    std::vector<const llvm::Type*> &ArgTys,
-                                    bool IsRecursive) {
-  const RecordType *RT = Ty->getAsStructureType();
+void CodeGenTypes::GetExpandedTypes(QualType type,
+                     llvm::SmallVectorImpl<const llvm::Type*> &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 @@
     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(const CGFunctionInfo &FI, bool IsVariadic,
-                              bool IsRecursive) {
-  std::vector<const llvm::Type*> ArgTys;
-
-  const llvm::Type *ResultType = 0;
+CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI, bool isVariadic,
+                              bool isRecursive) {
+  llvm::SmallVector<const llvm::Type*, 8> argTypes;
+  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 @@
       // 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<llvm::StructType>(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<llvm::StructType>(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 @@
       continue;
 
     case ABIArgInfo::Expand: {
-      std::vector<const llvm::Type*> Tys;
+      llvm::SmallVector<const llvm::Type*, 8> 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;
     }
     }

Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.h?rev=131374&r1=131373&r2=131374&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.h Sat May 14 21:19:42 2011
@@ -220,8 +220,9 @@
   /// 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<const llvm::Type*> &ArgTys,
-                        bool IsRecursive);
+  void GetExpandedTypes(QualType type,
+                        llvm::SmallVectorImpl<const llvm::Type*> &expanded,
+                        bool isRecursive);
 
   /// IsZeroInitializable - Return whether a type can be
   /// zero-initialized (in the C++ sense) with an LLVM zeroinitializer.





More information about the cfe-commits mailing list