summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-11-22 23:01:23 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-11-22 23:01:23 +0000
commite1cd0152a9d53d50698ef6d7ddc24cd4ee1dbe37 (patch)
treeed95271188418a228d38adf44b1a30f029aab0f3 /clang/lib/CodeGen
parentfd29d886056e7477c565bad8ffae460e3b14625c (diff)
downloadbcm5719-llvm-e1cd0152a9d53d50698ef6d7ddc24cd4ee1dbe37.tar.gz
bcm5719-llvm-e1cd0152a9d53d50698ef6d7ddc24cd4ee1dbe37.zip
x86_64, PR5582: Layout bases for C++ records.
- Ideally we would have an single iteration interface for this, but this works for now. llvm-svn: 89632
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/TargetABIInfo.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/TargetABIInfo.cpp b/clang/lib/CodeGen/TargetABIInfo.cpp
index ba0bc6668e2..2bc61753a03 100644
--- a/clang/lib/CodeGen/TargetABIInfo.cpp
+++ b/clang/lib/CodeGen/TargetABIInfo.cpp
@@ -771,7 +771,7 @@ void X86_64ABIInfo::classify(QualType Ty,
// reference.
if (hasNonTrivialDestructorOrCopyConstructor(RT))
return;
-
+
const RecordDecl *RD = RT->getDecl();
// Assume variable sized types are passed in memory.
@@ -782,6 +782,32 @@ void X86_64ABIInfo::classify(QualType Ty,
// Reset Lo class, this will be recomputed.
Current = NoClass;
+
+ // If this is a C++ record, classify the bases first.
+ if (const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
+ for (CXXRecordDecl::base_class_const_iterator i = CXXRD->bases_begin(),
+ e = CXXRD->bases_end(); i != e; ++i) {
+ assert(!i->isVirtual() && !i->getType()->isDependentType() &&
+ "Unexpected base class!");
+ const CXXRecordDecl *Base =
+ cast<CXXRecordDecl>(i->getType()->getAs<RecordType>()->getDecl());
+
+ // Classify this field.
+ //
+ // AMD64-ABI 3.2.3p2: Rule 3. If the size of the aggregate exceeds a
+ // single eightbyte, each is classified separately. Each eightbyte gets
+ // initialized to class NO_CLASS.
+ Class FieldLo, FieldHi;
+ uint64_t Offset = OffsetBase + Layout.getBaseClassOffset(Base);
+ classify(i->getType(), Context, Offset, FieldLo, FieldHi);
+ Lo = merge(Lo, FieldLo);
+ Hi = merge(Hi, FieldHi);
+ if (Lo == Memory || Hi == Memory)
+ break;
+ }
+ }
+
+ // Classify the fields one at a time, merging the results.
unsigned idx = 0;
for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
i != e; ++i, ++idx) {
OpenPOWER on IntegriCloud