blob: e1620af5025514da450605165f2888981fbd27d1 [file] [log] [blame]
Adrian Prantled6d9552013-03-14 17:54:13 +00001; RUN: llc -mtriple x86_64-apple-darwin -filetype=obj -o %t.o < %s
2; RUN: llvm-dwarfdump %t.o | FileCheck %s
3;
4; Test that DW_AT_location is generated for a captured "self" inside a
5; block.
6;
7; This test is split into two parts, the frontend part can be found at
8; llvm/tools/clang/test/CodeGenObjC/debug-info-block-captured-self.m
9;
David Blaikieeb1a2722014-06-13 22:18:23 +000010; CHECK: {{.*}}DW_AT_name{{.*}}_block_invoke{{.*}}
11; CHECK: DW_TAG_variable
Adrian Prantled6d9552013-03-14 17:54:13 +000012; CHECK-NOT: DW_TAG
David Blaikieeb1a2722014-06-13 22:18:23 +000013; CHECK: DW_AT_location
14; CHECK-NOT: DW_TAG
15; CHECK: DW_AT_name{{.*}}"self"{{.*}}
Adrian Prantled6d9552013-03-14 17:54:13 +000016;
David Blaikieeb1a2722014-06-13 22:18:23 +000017; CHECK: {{.*}}DW_AT_name{{.*}}_block_invoke{{.*}}
18; CHECK: DW_TAG_variable
Adrian Prantled6d9552013-03-14 17:54:13 +000019; CHECK-NOT: DW_TAG
David Blaikieeb1a2722014-06-13 22:18:23 +000020; CHECK: DW_AT_location
21; CHECK-NOT: DW_TAG
22; CHECK: DW_AT_name{{.*}}"self"{{.*}}
Adrian Prantled6d9552013-03-14 17:54:13 +000023;
24; Generated (and then reduced) from
25; ----------------------------------------------------------------------
26;
27; @class T;
28; @interface S
29; @end
30; @interface Mode
31; -(int) count;
32; @end
33; @interface Context
34; @end
35; @interface ViewController
36; @property (nonatomic, readwrite, strong) Context *context;
37; @end
38; typedef enum {
39; Unknown = 0,
40; } State;
41; @interface Main : ViewController
42; {
43; T * t1;
44; T * t2;
45; }
46; @property(readwrite, nonatomic) State state;
47; @end
48; @implementation Main
49; - (id) initWithContext:(Context *) context
50; {
51; t1 = [self.context withBlock:^(id obj){
52; id *mode1;
53; t2 = [mode1 withBlock:^(id object){
54; Mode *mode2 = object;
55; if ([mode2 count] != 0) {
56; self.state = 0;
57; }
58; }];
59; }];
60; }
61; @end
62; ----------------------------------------------------------------------
63; ModuleID = 'llvm/tools/clang/test/CodeGenObjC/debug-info-block-captured-self.m'
64%0 = type opaque
65%struct.__block_descriptor = type { i64, i64 }
Adrian Prantl87b7eb92014-10-01 18:55:02 +000066declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
Peter Collingbourned4bff302015-11-05 22:03:56 +000067define internal void @"__24-[Main initWithContext:]_block_invoke"(i8* %.block_descriptor, i8* %obj) #0 !dbg !38 {
Adrian Prantled6d9552013-03-14 17:54:13 +000068 %block = bitcast i8* %.block_descriptor to <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>*, !dbg !84
David Blaikie79e6c742015-02-27 19:29:02 +000069 %block.captured-self = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>, <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>* %block, i32 0, i32 5, !dbg !84
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000070 call void @llvm.dbg.declare(metadata <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>* %block, metadata !86, metadata !110), !dbg !87
Adrian Prantled6d9552013-03-14 17:54:13 +000071 ret void, !dbg !87
72}
73
Peter Collingbourned4bff302015-11-05 22:03:56 +000074define internal void @"__24-[Main initWithContext:]_block_invoke_2"(i8* %.block_descriptor, i8* %object) #0 !dbg !42 {
Adrian Prantled6d9552013-03-14 17:54:13 +000075 %block = bitcast i8* %.block_descriptor to <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>*, !dbg !103
David Blaikie79e6c742015-02-27 19:29:02 +000076 %block.captured-self = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>, <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>* %block, i32 0, i32 5, !dbg !103
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000077 call void @llvm.dbg.declare(metadata <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>* %block, metadata !105, metadata !109), !dbg !106
Adrian Prantled6d9552013-03-14 17:54:13 +000078 ret void, !dbg !106
79}
80
81!llvm.dbg.cu = !{!0}
Manman Ren409558f2013-11-22 21:49:45 +000082!llvm.module.flags = !{!108}
Adrian Prantl75819ae2016-04-15 15:57:41 +000083!0 = distinct !DICompileUnit(language: DW_LANG_ObjC, producer: "clang version 3.3 ", isOptimized: false, runtimeVersion: 2, emissionKind: FullDebug, file: !107, enums: !2, retainedTypes: !4, globals: !15, imports: !15)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000084!1 = !DIFile(filename: "llvm/tools/clang/test/CodeGenObjC/debug-info-block-captured-self.m", directory: "")
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000085!2 = !{!3}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000086!3 = !DICompositeType(tag: DW_TAG_enumeration_type, line: 20, size: 32, align: 32, file: !107, elements: !4)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000087!4 = !{}
88!15 = !{}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000089!27 = !DIDerivedType(tag: DW_TAG_typedef, name: "id", line: 31, file: !107, baseType: !28)
90!28 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !29)
91!29 = !DICompositeType(tag: DW_TAG_structure_type, name: "objc_object", file: !107, elements: !30)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000092!30 = !{!31}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000093!31 = !DIDerivedType(tag: DW_TAG_member, name: "isa", size: 64, file: !107, scope: !29, baseType: !32)
94!32 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, baseType: !33)
95!33 = !DICompositeType(tag: DW_TAG_structure_type, name: "objc_class", flags: DIFlagFwdDecl, file: !107)
96!34 = !DICompositeType(tag: DW_TAG_structure_type, name: "Main", line: 23, flags: DIFlagArtificial | DIFlagObjectPointer, runtimeLang: DW_LANG_ObjC, file: !107)
Adrian Prantl75819ae2016-04-15 15:57:41 +000097!38 = distinct !DISubprogram(name: "__24-[Main initWithContext:]_block_invoke", line: 33, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 33, file: !1, scope: !1, type: !39, variables: !15)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000098!39 = !DISubroutineType(types: !40)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000099!40 = !{null, !41, !27}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000100!41 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: null)
Adrian Prantl75819ae2016-04-15 15:57:41 +0000101!42 = distinct !DISubprogram(name: "__24-[Main initWithContext:]_block_invoke_2", line: 35, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 35, file: !1, scope: !1, type: !39, variables: !15)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000102!84 = !DILocation(line: 33, scope: !38)
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +0000103!86 = !DILocalVariable(name: "self", line: 41, scope: !38, file: !1, type: !34)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000104!87 = !DILocation(line: 41, scope: !38)
105!103 = !DILocation(line: 35, scope: !42)
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +0000106!105 = !DILocalVariable(name: "self", line: 40, scope: !42, file: !1, type: !34)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000107!106 = !DILocation(line: 40, scope: !42)
108!107 = !DIFile(filename: "llvm/tools/clang/test/CodeGenObjC/debug-info-block-captured-self.m", directory: "")
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000109!108 = !{i32 1, !"Debug Info Version", i32 3}
Florian Hahnffc498d2017-06-14 13:14:38 +0000110!109 = !DIExpression(DW_OP_plus_uconst, 32, DW_OP_deref)
111!110 = !DIExpression(DW_OP_plus_uconst, 32, DW_OP_deref)