[cfe-commits] r130176 - /cfe/trunk/lib/CodeGen/TargetInfo.cpp

Stuart Hastings stuart at apple.com
Mon Apr 25 16:48:12 PDT 2011


Author: stuart
Date: Mon Apr 25 18:48:12 2011
New Revision: 130176

URL: http://llvm.org/viewvc/llvm-project?rev=130176&view=rev
Log:
Turn on byval parameters in Clang for ARM APCS.  rdar://problem/7662569

Modified:
    cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=130176&r1=130175&r2=130176&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Mon Apr 25 18:48:12 2011
@@ -2341,23 +2341,34 @@
 
   // Otherwise, pass by coercing to a structure of the appropriate size.
   //
-  // FIXME: This is kind of nasty... but there isn't much choice because the ARM
-  // backend doesn't support byval.
   // FIXME: This doesn't handle alignment > 64 bits.
   const llvm::Type* ElemTy;
   unsigned SizeRegs;
-  if (getContext().getTypeAlign(Ty) > 32) {
-    ElemTy = llvm::Type::getInt64Ty(getVMContext());
-    SizeRegs = (getContext().getTypeSize(Ty) + 63) / 64;
-  } else {
+  if (getContext().getTypeSize(Ty) <= 32) {
     ElemTy = llvm::Type::getInt32Ty(getVMContext());
     SizeRegs = (getContext().getTypeSize(Ty) + 31) / 32;
+    llvm::SmallVector<const llvm::Type*, 8> LLVMFields;
+    LLVMFields.push_back(llvm::ArrayType::get(ElemTy, SizeRegs));
+    const llvm::Type* STy = llvm::StructType::get(getVMContext(), LLVMFields,
+                                                  true);
+    return ABIArgInfo::getDirect(STy);
+  }
+
+  if (getABIKind() == ARMABIInfo::APCS) {
+    // Initial ARM ByVal support is APCS-only.
+    return ABIArgInfo::getIndirect(0, /*ByVal=*/true);
+  } else {
+    // FIXME: This is kind of nasty... but there isn't much choice
+    // because most of the ARM calling conventions don't yet support
+    // byval.
+    ElemTy = llvm::Type::getInt64Ty(getVMContext());
+    SizeRegs = (getContext().getTypeSize(Ty) + 63) / 64;
+    llvm::SmallVector<const llvm::Type*, 8> LLVMFields;
+    LLVMFields.push_back(llvm::ArrayType::get(ElemTy, SizeRegs));
+    const llvm::Type* STy = llvm::StructType::get(getVMContext(), LLVMFields,
+                                                  true);
+    return ABIArgInfo::getDirect(STy);
   }
-  std::vector<const llvm::Type*> LLVMFields;
-  LLVMFields.push_back(llvm::ArrayType::get(ElemTy, SizeRegs));
-  const llvm::Type* STy = llvm::StructType::get(getVMContext(), LLVMFields,
-                                                true);
-  return ABIArgInfo::getDirect(STy);
 }
 
 static bool isIntegerLikeType(QualType Ty, ASTContext &Context,





More information about the cfe-commits mailing list