r186894 - Debug Info: Acknowledge the alignment when locating byref block variables.

David Blaikie dblaikie at gmail.com
Mon Jul 22 17:03:42 PDT 2013


On Mon, Jul 22, 2013 at 4:44 PM, Adrian Prantl <aprantl at apple.com> wrote:
>
> Author: adrian
> Date: Mon Jul 22 18:44:26 2013
> New Revision: 186894
>
> URL: http://llvm.org/viewvc/llvm-project?rev=186894&view=rev
> Log:
> Debug Info: Acknowledge the alignment when locating byref block variables.
> Fixes rdar://problem/14386148
>
> Added:
>     cfe/trunk/test/CodeGenObjC/block-byref-debuginfo.m
> Modified:
>     cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=186894&r1=186893&r2=186894&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Jul 22 18:44:26 2013
> @@ -2626,6 +2626,7 @@ llvm::DIType CGDebugInfo::EmitTypeForVar
>    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,
>
> Added: cfe/trunk/test/CodeGenObjC/block-byref-debuginfo.m
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/block-byref-debuginfo.m?rev=186894&view=auto
> ==============================================================================
> --- cfe/trunk/test/CodeGenObjC/block-byref-debuginfo.m (added)
> +++ cfe/trunk/test/CodeGenObjC/block-byref-debuginfo.m Mon Jul 22 18:44:26 2013

This seems like a lot of source code for such a simple issue - could
it be simplified further? (I don't know enough ObjC to be sure)

> @@ -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;
> + at protocol NSObject
> + at end
> + at interface NSObject <NSObject> {
> +}
> + at 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;
> + at protocol DelegateProtocol <NSObject>
> + at end
> + at interface FileReader : NSObject <DelegateProtocol>
> +{
> + dispatch_once_t offset;
> +}
> + at end
> + at implementation FileReader
> +- (BufferRef) bar:(int *)index
> +{
> +  __attribute__((__blocks__(byref))) Foo foo;
> +  _dispatch_once(&offset, ^{});
> +  return 0;
> +}
> + at end
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits



More information about the cfe-commits mailing list