[llvm-commits] [dragonegg] r88786 - /dragonegg/trunk/llvm-abi.h

Duncan Sands baldrick at free.fr
Sat Nov 14 04:36:07 PST 2009


Author: baldrick
Date: Sat Nov 14 06:36:07 2009
New Revision: 88786

URL: http://llvm.org/viewvc/llvm-project?rev=88786&view=rev
Log:
Port commit 86892 (bwilson) from llvm-gcc:
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:
    dragonegg/trunk/llvm-abi.h

Modified: dragonegg/trunk/llvm-abi.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-abi.h?rev=88786&r1=88785&r2=88786&view=diff

==============================================================================
--- dragonegg/trunk/llvm-abi.h (original)
+++ dragonegg/trunk/llvm-abi.h Sat Nov 14 06:36:07 2009
@@ -630,19 +630,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;
@@ -1077,19 +1076,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