[cfe-commits] r161554 - in /cfe/trunk: lib/CodeGen/TargetInfo.cpp test/CodeGen/arm-arguments.c

Eli Friedman eli.friedman at gmail.com
Wed Aug 8 17:31:40 PDT 2012


Author: efriedma
Date: Wed Aug  8 19:31:40 2012
New Revision: 161554

URL: http://llvm.org/viewvc/llvm-project?rev=161554&view=rev
Log:
Fix AAPCS ABI.  I can't actually test this, but it restores the behavior from before r159168.  PR13562.


Modified:
    cfe/trunk/lib/CodeGen/TargetInfo.cpp
    cfe/trunk/test/CodeGen/arm-arguments.c

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=161554&r1=161553&r2=161554&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Wed Aug  8 19:31:40 2012
@@ -2757,21 +2757,24 @@
     }
   }
 
+  // FIXME: byval for AAPCS is not yet supported; we need it for performance
+  // and to support large alignment.
+  if (getABIKind() == ARMABIInfo::APCS) {
+    if (getContext().getTypeSizeInChars(Ty) > CharUnits::fromQuantity(64) ||
+        getContext().getTypeAlign(Ty) > 64) {
+      return ABIArgInfo::getIndirect(0, /*ByVal=*/true);
+    }
+  }
+
   // Otherwise, pass by coercing to a structure of the appropriate size.
-  //
-  // FIXME: This doesn't handle alignment > 64 bits.
   llvm::Type* ElemTy;
   unsigned SizeRegs;
-  if (getContext().getTypeSizeInChars(Ty) <= CharUnits::fromQuantity(64)) {
+  // FIXME: Try to match the types of the arguments more accurately where
+  // we can.
+  if (getContext().getTypeAlign(Ty) <= 32) {
     ElemTy = llvm::Type::getInt32Ty(getVMContext());
     SizeRegs = (getContext().getTypeSize(Ty) + 31) / 32;
-  } else 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;
   }

Modified: cfe/trunk/test/CodeGen/arm-arguments.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-arguments.c?rev=161554&r1=161553&r2=161554&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/arm-arguments.c (original)
+++ cfe/trunk/test/CodeGen/arm-arguments.c Wed Aug  8 19:31:40 2012
@@ -166,3 +166,9 @@
 // APCS-GNU: %s = alloca %struct.s31, align 4
 // APCS-GNU: alloca [1 x i32]
 // APCS-GNU: store [1 x i32] %s.coerce, [1 x i32]*
+
+// PR13562
+struct s32 { double x; };
+void f32(struct s32 s) { }
+// AAPCS: @f32([1 x i64] %s.coerce)
+// APCS-GNU: @f32([2 x i32] %s.coerce)





More information about the cfe-commits mailing list