summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/TargetInfo.cpp
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2011-11-18 01:32:26 +0000
committerEli Friedman <eli.friedman@gmail.com>2011-11-18 01:32:26 +0000
commite5c85622c915dc2ff8a3b4012882a1ec3a3d521c (patch)
treefff3ef0538ea4103eff7515faaf0167377f2a991 /clang/lib/CodeGen/TargetInfo.cpp
parentee94534662f9a5e52b59c9324b6e280842eb8795 (diff)
downloadbcm5719-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/CodeGen/TargetInfo.cpp')
-rw-r--r--clang/lib/CodeGen/TargetInfo.cpp8
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;
}
OpenPOWER on IntegriCloud