[cfe-commits] r144971 - in /cfe/trunk: lib/CodeGen/TargetInfo.cpp test/CodeGen/x86_32-arguments-darwin.c

Eli Friedman eli.friedman at gmail.com
Thu Nov 17 19:47:21 PST 2011


Author: efriedma
Date: Thu Nov 17 21:47:20 2011
New Revision: 144971

URL: http://llvm.org/viewvc/llvm-project?rev=144971&view=rev
Log:
Fix the meaning of an "empty" record for the case of a zero-length array.  Use isEmptyRecord for arguments on x86-32; there are structs of size 0 which don't count as empty.


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

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=144971&r1=144970&r2=144971&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Thu Nov 17 21:47:20 2011
@@ -117,10 +117,14 @@
 
   QualType FT = FD->getType();
 
-    // Constant arrays of empty records count as empty, strip them off.
+  // Constant arrays of empty records count as empty, strip them off.
+  // Constant arrays of zero length always count as empty.
   if (AllowArrays)
-    while (const ConstantArrayType *AT = Context.getAsConstantArrayType(FT))
+    while (const ConstantArrayType *AT = Context.getAsConstantArrayType(FT)) {
+      if (AT->getSize() == 0)
+        return true;
       FT = AT->getElementType();
+    }
 
   const RecordType *RT = FT->getAs<RecordType>();
   if (!RT)
@@ -684,7 +688,7 @@
     }
 
     // Ignore empty structs/unions.
-    if (Ty->isRecordType() && getContext().getTypeSize(Ty) == 0)
+    if (isEmptyRecord(Context, Ty, true))
       return ABIArgInfo::getIgnore();
 
     // Expand small (<= 128-bit) record types when we know that the stack layout

Modified: cfe/trunk/test/CodeGen/x86_32-arguments-darwin.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86_32-arguments-darwin.c?rev=144971&r1=144970&r2=144971&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/x86_32-arguments-darwin.c (original)
+++ cfe/trunk/test/CodeGen/x86_32-arguments-darwin.c Thu Nov 17 21:47:20 2011
@@ -316,3 +316,11 @@
   __builtin_va_end(ap);
   return s.y;
 }
+
+// CHECK: define i32 @f64(%struct.s64* nocapture byval align 4 %x)
+struct s64 { signed char a[0]; signed char b[]; };
+void f64(struct s64 x) {}
+
+// CHECK: define float @f65()
+struct s65 { signed char a[0]; float b; };
+struct s65 f65() { return (struct s65){{},2}; }





More information about the cfe-commits mailing list