diff options
author | John McCall <rjmccall@apple.com> | 2015-10-29 23:36:14 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2015-10-29 23:36:14 +0000 |
commit | f5ea072e019bd87689f9d00877d267c91ff2c8a1 (patch) | |
tree | ec284addb60aaeb3c5ef158eeddcba5271317aa3 /clang/lib | |
parent | 25cb32091cce2e6227e1f8812aea84b45000654e (diff) | |
download | bcm5719-llvm-f5ea072e019bd87689f9d00877d267c91ff2c8a1.tar.gz bcm5719-llvm-f5ea072e019bd87689f9d00877d267c91ff2c8a1.zip |
Fix the emission of ARC ivar layouts in the non-fragile Mac runtime.
My previous change in this area accidentally broke the rule when
InstanceBegin was not a multiple of the word size.
llvm-svn: 251666
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/CodeGen/CGObjCMac.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp index 44c9a90c76c..e3cba265efa 100644 --- a/clang/lib/CodeGen/CGObjCMac.cpp +++ b/clang/lib/CodeGen/CGObjCMac.cpp @@ -2081,7 +2081,7 @@ llvm::Constant *CGObjCCommonMac::BuildGCBlockLayout(CodeGenModule &CGM, llvm::SmallVector<unsigned char, 32> buffer; llvm::Constant *C = builder.buildBitmap(*this, buffer); - if (CGM.getLangOpts().ObjCGCBitmapPrint) { + if (CGM.getLangOpts().ObjCGCBitmapPrint && !buffer.empty()) { printf("\n block variable layout for block: "); builder.dump(buffer); } @@ -4861,6 +4861,9 @@ llvm::Constant *IvarLayoutBuilder::buildBitmap(CGObjCCommonMac &CGObjC, endOfLastScanInWords = endOfScanInWords; } + if (buffer.empty()) + return llvm::ConstantPointerNull::get(CGM.Int8PtrTy); + // For GC layouts, emit a skip to the end of the allocation so that we // have precise information about the entire thing. This isn't useful // or necessary for the ARC-style layout strings. @@ -4922,9 +4925,9 @@ CGObjCCommonMac::BuildIvarLayout(const ObjCImplementationDecl *OMD, // up. // // ARC layout strings only include the class's ivars. In non-fragile - // runtimes, that means starting at InstanceStart. In fragile runtimes, - // there's no InstanceStart, so it means starting at the end of the - // superclass, rounded up to word alignment. + // 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. // // MRC weak layout strings follow the ARC style. CharUnits baseOffset; @@ -4938,10 +4941,12 @@ CGObjCCommonMac::BuildIvarLayout(const ObjCImplementationDecl *OMD, } else if (auto superClass = OI->getSuperClass()) { auto startOffset = CGM.getContext().getASTObjCInterfaceLayout(superClass).getSize(); - baseOffset = startOffset.RoundUpToAlignment(CGM.getPointerAlign()); + baseOffset = startOffset; } else { baseOffset = CharUnits::Zero(); } + + baseOffset = baseOffset.RoundUpToAlignment(CGM.getPointerAlign()); } else { CGM.getContext().DeepCollectObjCIvars(OI, true, ivars); @@ -4965,7 +4970,7 @@ CGObjCCommonMac::BuildIvarLayout(const ObjCImplementationDecl *OMD, llvm::SmallVector<unsigned char, 4> buffer; llvm::Constant *C = builder.buildBitmap(*this, buffer); - if (CGM.getLangOpts().ObjCGCBitmapPrint) { + if (CGM.getLangOpts().ObjCGCBitmapPrint && !buffer.empty()) { printf("\n%s ivar layout for class '%s': ", ForStrongLayout ? "strong" : "weak", OMD->getClassInterface()->getName().str().c_str()); |