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

Eli Friedman eli.friedman at gmail.com
Thu Nov 17 17:32:26 PST 2011


Author: efriedma
Date: Thu Nov 17 19:32:26 2011
New Revision: 144961

URL: http://llvm.org/viewvc/llvm-project?rev=144961&view=rev
Log:
Don't try to expand struct arguments containing holes on x86-32.  From gcc struct layout tests.


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=144961&r1=144960&r2=144961&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Thu Nov 17 19:32:26 2011
@@ -292,6 +292,8 @@
   if (!RD->isStruct() || isa<CXXRecordDecl>(RD))
     return false;
 
+  uint64_t Size = 0;
+
   for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
          i != e; ++i) {
     const FieldDecl *FD = *i;
@@ -304,8 +306,14 @@
     // counts as "basic" is more complicated than what we were doing previously.
     if (FD->isBitField())
       return false;
+
+    Size += Context.getTypeSize(FD->getType());
   }
 
+  // Make sure there are not any holes in the struct.
+  if (Size != Context.getTypeSize(Ty))
+    return false;
+
   return true;
 }
 

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=144961&r1=144960&r2=144961&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/x86_32-arguments-darwin.c (original)
+++ cfe/trunk/test/CodeGen/x86_32-arguments-darwin.c Thu Nov 17 19:32:26 2011
@@ -288,3 +288,7 @@
 // CHECK: define i64 @f59()
 struct s59 { float x __attribute((aligned(8))); };
 struct s59 f59() { while (1) {} }
+
+// CHECK: define void @f60(%struct.s60* byval align 4, i32 %y)
+struct s60 { int x __attribute((aligned(8))); };
+void f60(struct s60 x, int y) {}





More information about the cfe-commits mailing list