[llvm-commits] [llvm-gcc-4.2] r86892 - /llvm-gcc-4.2/trunk/gcc/llvm-abi.h

Bob Wilson bob.wilson at apple.com
Wed Nov 11 15:05:45 PST 2009


Author: bwilson
Date: Wed Nov 11 17:05:45 2009
New Revision: 86892

URL: http://llvm.org/viewvc/llvm-project?rev=86892&view=rev
Log:
Fix pr5406: When passing an aggregate in integer registers, the data cannot
be split up into integer types smaller than the target registers.  Most of
the data is put into an array of i32 or i64 values, and that part is OK.  But,
if the size is not a multiple of 32 or 64, there may be some leftover bytes
to be passed separately.  Change to pass those leftover bytes in a single
integer.  The x86_64 target already does this in target-specific code.
This also fixes radars 7226380 and 7226213.

Modified:
    llvm-gcc-4.2/trunk/gcc/llvm-abi.h

Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi.h?rev=86892&r1=86891&r2=86892&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-abi.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-abi.h Wed Nov 11 17:05:45 2009
@@ -629,19 +629,18 @@
       Elts.push_back(ATy);
     }
 
-    if (Size >= 4) {
+    // Put any left over bytes into one last register.  This target-independent
+    // code does not know the size of the argument registers, so use the
+    // smallest size that will work.
+    if (Size > 4) {
+      Elts.push_back(Type::getInt64Ty(getGlobalContext()));
+    } else if (Size > 2) {
       Elts.push_back(Type::getInt32Ty(getGlobalContext()));
-      Size -= 4;
-    }
-    if (Size >= 2) {
+    } else if (Size > 1) {
       Elts.push_back(Type::getInt16Ty(getGlobalContext()));
-      Size -= 2;
-    }
-    if (Size >= 1) {
+    } else {
       Elts.push_back(Type::getInt8Ty(getGlobalContext()));
-      Size -= 1;
     }
-    assert(Size == 0 && "Didn't cover value?");
     const StructType *STy = StructType::get(getGlobalContext(), Elts, false);
 
     unsigned i = 0;
@@ -1073,19 +1072,18 @@
       Elts.push_back(ATy);
     }
 
-    if (Size >= 4) {
+    // Put any left over bytes into one last register.  This target-independent
+    // code does not know the size of the argument registers, so use the
+    // smallest size that will work.
+    if (Size > 4) {
+      Elts.push_back(Type::getInt64Ty(getGlobalContext()));
+    } else if (Size > 2) {
       Elts.push_back(Type::getInt32Ty(getGlobalContext()));
-      Size -= 4;
-    }
-    if (Size >= 2) {
+    } else if (Size > 1) {
       Elts.push_back(Type::getInt16Ty(getGlobalContext()));
-      Size -= 2;
-    }
-    if (Size >= 1) {
+    } else {
       Elts.push_back(Type::getInt8Ty(getGlobalContext()));
-      Size -= 1;
     }
-    assert(Size == 0 && "Didn't cover value?");
     const StructType *STy = StructType::get(getGlobalContext(), Elts, false);
 
     unsigned i = 0;





More information about the llvm-commits mailing list