diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2011-11-18 01:32:26 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2011-11-18 01:32:26 +0000 |
commit | e5c85622c915dc2ff8a3b4012882a1ec3a3d521c (patch) | |
tree | fff3ef0538ea4103eff7515faaf0167377f2a991 /clang/lib | |
parent | ee94534662f9a5e52b59c9324b6e280842eb8795 (diff) | |
download | bcm5719-llvm-e5c85622c915dc2ff8a3b4012882a1ec3a3d521c.tar.gz bcm5719-llvm-e5c85622c915dc2ff8a3b4012882a1ec3a3d521c.zip |
Don't try to expand struct arguments containing holes on x86-32. From gcc struct layout tests.
llvm-svn: 144961
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/CodeGen/TargetInfo.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index 7ad351050dd..5be38978f26 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/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; } |