diff options
author | John McCall <rjmccall@apple.com> | 2015-11-19 02:27:55 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2015-11-19 02:27:55 +0000 |
commit | d80218fa4221c76fa1b822a406253921d4c7f8fc (patch) | |
tree | 175bcce0f7357453b5f5fe2994370e9e3a058135 /clang/lib | |
parent | 61fcb521fa1dd3426b653818fd315f9e542fc12b (diff) | |
download | bcm5719-llvm-d80218fa4221c76fa1b822a406253921d4c7f8fc.tar.gz bcm5719-llvm-d80218fa4221c76fa1b822a406253921d4c7f8fc.zip |
Fix the emission of ARC-style ivar layouts in the fragile runtime
to start at the offset of the first ivar instead of the rounded-up
end of the superclass. The latter could include a large amount of
tail padding because of a highly-aligned ivar, and subclass ivars
can be laid out within that.
llvm-svn: 253533
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/CodeGen/CGObjCMac.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp index a5f504e141c..dad172b5651 100644 --- a/clang/lib/CodeGen/CGObjCMac.cpp +++ b/clang/lib/CodeGen/CGObjCMac.cpp @@ -4927,7 +4927,7 @@ CGObjCCommonMac::BuildIvarLayout(const ObjCImplementationDecl *OMD, // ARC layout strings only include the class's ivars. In non-fragile // runtimes, that means starting at InstanceStart, rounded up to word // alignment. In fragile runtimes, there's no InstanceStart, so it means - // starting at the end of the superclass, rounded up to word alignment. + // starting at the offset of the first ivar, rounded up to word alignment. // // MRC weak layout strings follow the ARC style. CharUnits baseOffset; @@ -4938,10 +4938,9 @@ CGObjCCommonMac::BuildIvarLayout(const ObjCImplementationDecl *OMD, if (isNonFragileABI()) { baseOffset = beginOffset; // InstanceStart - } else if (auto superClass = OI->getSuperClass()) { - auto startOffset = - CGM.getContext().getASTObjCInterfaceLayout(superClass).getSize(); - baseOffset = startOffset; + } else if (!ivars.empty()) { + baseOffset = + CharUnits::fromQuantity(ComputeIvarBaseOffset(CGM, OMD, ivars[0])); } else { baseOffset = CharUnits::Zero(); } |