r215449 - Objective-C. Fixes an assert where because of captured
Fariborz Jahanian
fjahanian at apple.com
Tue Aug 12 08:51:49 PDT 2014
Author: fjahanian
Date: Tue Aug 12 10:51:49 2014
New Revision: 215449
URL: http://llvm.org/viewvc/llvm-project?rev=215449&view=rev
Log:
Objective-C. Fixes an assert where because of captured
variable in block is over-aligned with an align
attribute causing block metadata size not be multiple
of alignment. rdar://17878679
Added:
cfe/trunk/test/CodeGenObjC/block-over-align.m
Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=215449&r1=215448&r2=215449&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Tue Aug 12 10:51:49 2014
@@ -539,6 +539,16 @@ static void computeBlockInfo(CodeGenModu
// multiple of alignment.
for (SmallVectorImpl<BlockLayoutChunk>::iterator
li = layout.begin(), le = layout.end(); li != le; ++li) {
+ if (endAlign < li->Alignment) {
+ // size may not be multiple of alignment. This can only happen with
+ // an over-aligned variable. We will be adding a padding field to
+ // make the size be multiple of alignment.
+ CharUnits padding = li->Alignment - endAlign;
+ elementTypes.push_back(llvm::ArrayType::get(CGM.Int8Ty,
+ padding.getQuantity()));
+ blockSize += padding;
+ endAlign = getLowBit(blockSize);
+ }
assert(endAlign >= li->Alignment);
li->setIndex(info, elementTypes.size());
elementTypes.push_back(li->Type);
Added: cfe/trunk/test/CodeGenObjC/block-over-align.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/block-over-align.m?rev=215449&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/block-over-align.m (added)
+++ cfe/trunk/test/CodeGenObjC/block-over-align.m Tue Aug 12 10:51:49 2014
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin -emit-llvm -o /dev/null %s
+// rdar://17878679
+
+typedef struct
+{
+ int i;
+} GAXBackboardState __attribute__ ((aligned(32))); // minimum alignment is 32-byte boundary
+
+ at interface GAXSpringboard @end
+
+ at implementation GAXSpringboard
+{
+ GAXBackboardState _reflectedBackboardState;
+}
+
+- (void) MyMethod
+{
+ GAXBackboardState newBackboardState;
+ ^{
+ _reflectedBackboardState = newBackboardState;
+ return newBackboardState.i;
+ }();
+}
+ at end
+
More information about the cfe-commits
mailing list