]> granicus.if.org Git - clang/commitdiff
Don't try to expand struct arguments containing holes on x86-32. From gcc struct...
authorEli Friedman <eli.friedman@gmail.com>
Fri, 18 Nov 2011 01:32:26 +0000 (01:32 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Fri, 18 Nov 2011 01:32:26 +0000 (01:32 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144961 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/TargetInfo.cpp
test/CodeGen/x86_32-arguments-darwin.c

index 7ad351050dd03228fda4d89acd10d6912c596216..5be38978f26a5cbbe78b8d3c0f1715175d07b4e7 100644 (file)
@@ -292,6 +292,8 @@ static bool canExpandIndirectArgument(QualType Ty, ASTContext &Context) {
   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 @@ static bool canExpandIndirectArgument(QualType Ty, ASTContext &Context) {
     // 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;
 }
 
index 856a6d72eae02990d298b2ab5675e364db70943d..cc203d2add878970e72013ce0801ddc1972b93e3 100644 (file)
@@ -288,3 +288,7 @@ void f58(union u58 x) {}
 // 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) {}