diff options
-rw-r--r-- | lib/CodeGen/TargetInfo.cpp | 8 | ||||
-rw-r--r-- | test/CodeGen/x86_32-arguments-darwin.c | 4 |
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp index 7ad351050d..5be38978f2 100644 --- a/lib/CodeGen/TargetInfo.cpp +++ b/lib/CodeGen/TargetInfo.cpp @@ -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; } diff --git a/test/CodeGen/x86_32-arguments-darwin.c b/test/CodeGen/x86_32-arguments-darwin.c index 856a6d72ea..cc203d2add 100644 --- a/test/CodeGen/x86_32-arguments-darwin.c +++ b/test/CodeGen/x86_32-arguments-darwin.c @@ -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) {} |