diff options
author | Anders Carlsson <andersca@mac.com> | 2010-06-13 17:49:16 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2010-06-13 17:49:16 +0000 |
commit | 5ccfdd8d215c7bf324a14523c71ed328325c2bc8 (patch) | |
tree | 07b3e64a29ea3ba976e822ee89ffb69711f9e9d5 | |
parent | 71d74bc0d6e522ce7c21a599db8e19d3883b518f (diff) |
Implement part of the EmptySubobjectMap optimization described in PR6998. We still need to do this for bases.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105919 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AST/RecordLayoutBuilder.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/AST/RecordLayoutBuilder.cpp b/lib/AST/RecordLayoutBuilder.cpp index 7c0c8088e8..6b8d7cf22d 100644 --- a/lib/AST/RecordLayoutBuilder.cpp +++ b/lib/AST/RecordLayoutBuilder.cpp @@ -415,7 +415,14 @@ EmptySubobjectMap::CanPlaceFieldAtOffset(const FieldDecl *FD, uint64_t Offset) { void EmptySubobjectMap::UpdateEmptyFieldSubobjects(const CXXRecordDecl *RD, const CXXRecordDecl *Class, uint64_t Offset) { - + // We know that the only empty subobjects that can conflict with empty + // field subobjects are subobjects empty bases that can be placed at offset + // zero. Because of this, we only need to keep track of empty field + // subobjects with offsets less than the size of the largest empty + // subobject for our class. + if (Offset >= SizeOfLargestEmptySubobject) + return; + AddSubobjectAtOffset(RD, Offset); const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD); @@ -480,6 +487,14 @@ void EmptySubobjectMap::UpdateEmptyFieldSubobjects(const FieldDecl *FD, uint64_t ElementOffset = Offset; for (uint64_t I = 0; I != NumElements; ++I) { + // We know that the only empty subobjects that can conflict with empty + // field subobjects are subobjects empty bases that can be placed at + // offset zero. Because of this, we only need to keep track of empty field + // subobjects with offsets less than the size of the largest empty + // subobject for our class. + if (ElementOffset >= SizeOfLargestEmptySubobject) + return; + UpdateEmptyFieldSubobjects(RD, RD, ElementOffset); ElementOffset += Layout.getSize(); } |