r186993 - [PowerPC64] Fix passing of single-vector-member structs to match ABI.

Bill Schmidt wschmidt at linux.vnet.ibm.com
Tue Jul 23 15:15:57 PDT 2013


Author: wschmidt
Date: Tue Jul 23 17:15:57 2013
New Revision: 186993

URL: http://llvm.org/viewvc/llvm-project?rev=186993&view=rev
Log:
[PowerPC64] Fix passing of single-vector-member structs to match ABI.

The 64-bit PowerPC ELF ABI requires a struct that contains a single
vector member to be passed in a vector register as though the wrapping
struct were not present.  Instead we were passing this as a byval
struct.

The same logic was already present for floating-point arguments, so
this patch just extends the logic to handle vector types.  The new
test case verifies that clang coerces the parameter and annotates it
as inreg.

Thanks,
Bill


Added:
    cfe/trunk/test/CodeGen/ppc64-struct-onevect.c
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=186993&r1=186992&r2=186993&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Tue Jul 23 17:15:57 2013
@@ -2801,11 +2801,11 @@ public:
          it != ie; ++it) {
       // We rely on the default argument classification for the most part.
       // One exception:  An aggregate containing a single floating-point
-      // item must be passed in a register if one is available.
+      // or vector item must be passed in a register if one is available.
       const Type *T = isSingleElementStruct(it->type, getContext());
       if (T) {
         const BuiltinType *BT = T->getAs<BuiltinType>();
-        if (BT && BT->isFloatingPoint()) {
+        if (T->isVectorType() || (BT && BT->isFloatingPoint())) {
           QualType QT(T, 0);
           it->info = ABIArgInfo::getDirectInReg(CGT.ConvertType(QT));
           continue;

Added: cfe/trunk/test/CodeGen/ppc64-struct-onevect.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ppc64-struct-onevect.c?rev=186993&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/ppc64-struct-onevect.c (added)
+++ cfe/trunk/test/CodeGen/ppc64-struct-onevect.c Tue Jul 23 17:15:57 2013
@@ -0,0 +1,13 @@
+// REQUIRES: ppc64-registered-target
+// RUN: %clang_cc1 -O2 -triple powerpc64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
+
+typedef float v4sf __attribute__ ((vector_size (16)));
+
+struct s { v4sf v; };
+
+v4sf foo (struct s a) {
+  return a.v;
+}
+
+// CHECK: define <4 x float> @foo(<4 x float> inreg %a.coerce)
+// CHECK: ret <4 x float> %a.coerce





More information about the cfe-commits mailing list