summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2013-07-22 23:44:26 +0000
committerAdrian Prantl <aprantl@apple.com>2013-07-22 23:44:26 +0000
commit52f5b2502f2a7d85f9e56f987ac445b1e8dd73b9 (patch)
tree51a54ce074d9d9a924558af1670341636efb5d9c /clang
parent6ab9d936d5c20f417f4036a15ae00a14c299c0f5 (diff)
downloadbcm5719-llvm-52f5b2502f2a7d85f9e56f987ac445b1e8dd73b9.tar.gz
bcm5719-llvm-52f5b2502f2a7d85f9e56f987ac445b1e8dd73b9.zip
Debug Info: Acknowledge the alignment when locating byref block variables.
Fixes rdar://problem/14386148 llvm-svn: 186894
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp1
-rw-r--r--clang/test/CodeGenObjC/block-byref-debuginfo.m38
2 files changed, 39 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index feed2b48afc..64259b3e993 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2626,6 +2626,7 @@ llvm::DIType CGDebugInfo::EmitTypeForVarWithBlocksAttr(const VarDecl *VD,
llvm::DIType FieldTy = CGDebugInfo::getOrCreateType(FType, Unit);
FieldSize = CGM.getContext().getTypeSize(FType);
FieldAlign = CGM.getContext().toBits(Align);
+ FieldOffset += FieldOffset % FieldAlign;
*XOffset = FieldOffset;
FieldTy = DBuilder.createMemberType(Unit, VD->getName(), Unit,
diff --git a/clang/test/CodeGenObjC/block-byref-debuginfo.m b/clang/test/CodeGenObjC/block-byref-debuginfo.m
new file mode 100644
index 00000000000..f918d32a988
--- /dev/null
+++ b/clang/test/CodeGenObjC/block-byref-debuginfo.m
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -fblocks -fobjc-arc -fobjc-runtime-has-weak -g -triple x86_64-apple-darwin -O0 -emit-llvm %s -o - | FileCheck %s
+
+// Test that the foo is aligned at an 8 byte boundary in the DWARF
+// expression (256) that locates it inside of the byref descriptor:
+// CHECK: metadata !"foo", i32 0, i64 {{[0-9]+}}, i64 64, i64 256, i32 0, metadata
+
+typedef unsigned char uint8_t;
+@protocol NSObject
+@end
+@interface NSObject <NSObject> {
+}
+@end
+typedef void (^dispatch_block_t)(void);
+typedef long dispatch_once_t;
+static __inline__ __attribute__((__always_inline__)) __attribute__((__nonnull__)) __attribute__((__nothrow__))
+void
+_dispatch_once(dispatch_once_t *predicate, dispatch_block_t block)
+{
+};
+typedef struct Buffer *BufferRef;
+typedef struct Foo_s {
+ uint8_t *data;
+} Foo;
+@protocol DelegateProtocol <NSObject>
+@end
+@interface FileReader : NSObject <DelegateProtocol>
+{
+ dispatch_once_t offset;
+}
+@end
+@implementation FileReader
+- (BufferRef) bar:(int *)index
+{
+ __attribute__((__blocks__(byref))) Foo foo;
+ _dispatch_once(&offset, ^{});
+ return 0;
+}
+@end
OpenPOWER on IntegriCloud