1*9880d681SAndroid Build Coastguard Worker; RUN: llc -mtriple x86_64-apple-darwin -filetype=obj -o %t.o < %s 2*9880d681SAndroid Build Coastguard Worker; RUN: llvm-dwarfdump %t.o | FileCheck %s 3*9880d681SAndroid Build Coastguard Worker; 4*9880d681SAndroid Build Coastguard Worker; Test that DW_AT_location is generated for a captured "self" inside a 5*9880d681SAndroid Build Coastguard Worker; block. 6*9880d681SAndroid Build Coastguard Worker; 7*9880d681SAndroid Build Coastguard Worker; This test is split into two parts, the frontend part can be found at 8*9880d681SAndroid Build Coastguard Worker; llvm/tools/clang/test/CodeGenObjC/debug-info-block-captured-self.m 9*9880d681SAndroid Build Coastguard Worker; 10*9880d681SAndroid Build Coastguard Worker; CHECK: {{.*}}DW_AT_name{{.*}}_block_invoke{{.*}} 11*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_variable 12*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: DW_TAG 13*9880d681SAndroid Build Coastguard Worker; CHECK: DW_AT_location 14*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: DW_TAG 15*9880d681SAndroid Build Coastguard Worker; CHECK: DW_AT_name{{.*}}"self"{{.*}} 16*9880d681SAndroid Build Coastguard Worker; 17*9880d681SAndroid Build Coastguard Worker; CHECK: {{.*}}DW_AT_name{{.*}}_block_invoke{{.*}} 18*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_variable 19*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: DW_TAG 20*9880d681SAndroid Build Coastguard Worker; CHECK: DW_AT_location 21*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: DW_TAG 22*9880d681SAndroid Build Coastguard Worker; CHECK: DW_AT_name{{.*}}"self"{{.*}} 23*9880d681SAndroid Build Coastguard Worker; 24*9880d681SAndroid Build Coastguard Worker; Generated (and then reduced) from 25*9880d681SAndroid Build Coastguard Worker; ---------------------------------------------------------------------- 26*9880d681SAndroid Build Coastguard Worker; 27*9880d681SAndroid Build Coastguard Worker; @class T; 28*9880d681SAndroid Build Coastguard Worker; @interface S 29*9880d681SAndroid Build Coastguard Worker; @end 30*9880d681SAndroid Build Coastguard Worker; @interface Mode 31*9880d681SAndroid Build Coastguard Worker; -(int) count; 32*9880d681SAndroid Build Coastguard Worker; @end 33*9880d681SAndroid Build Coastguard Worker; @interface Context 34*9880d681SAndroid Build Coastguard Worker; @end 35*9880d681SAndroid Build Coastguard Worker; @interface ViewController 36*9880d681SAndroid Build Coastguard Worker; @property (nonatomic, readwrite, strong) Context *context; 37*9880d681SAndroid Build Coastguard Worker; @end 38*9880d681SAndroid Build Coastguard Worker; typedef enum { 39*9880d681SAndroid Build Coastguard Worker; Unknown = 0, 40*9880d681SAndroid Build Coastguard Worker; } State; 41*9880d681SAndroid Build Coastguard Worker; @interface Main : ViewController 42*9880d681SAndroid Build Coastguard Worker; { 43*9880d681SAndroid Build Coastguard Worker; T * t1; 44*9880d681SAndroid Build Coastguard Worker; T * t2; 45*9880d681SAndroid Build Coastguard Worker; } 46*9880d681SAndroid Build Coastguard Worker; @property(readwrite, nonatomic) State state; 47*9880d681SAndroid Build Coastguard Worker; @end 48*9880d681SAndroid Build Coastguard Worker; @implementation Main 49*9880d681SAndroid Build Coastguard Worker; - (id) initWithContext:(Context *) context 50*9880d681SAndroid Build Coastguard Worker; { 51*9880d681SAndroid Build Coastguard Worker; t1 = [self.context withBlock:^(id obj){ 52*9880d681SAndroid Build Coastguard Worker; id *mode1; 53*9880d681SAndroid Build Coastguard Worker; t2 = [mode1 withBlock:^(id object){ 54*9880d681SAndroid Build Coastguard Worker; Mode *mode2 = object; 55*9880d681SAndroid Build Coastguard Worker; if ([mode2 count] != 0) { 56*9880d681SAndroid Build Coastguard Worker; self.state = 0; 57*9880d681SAndroid Build Coastguard Worker; } 58*9880d681SAndroid Build Coastguard Worker; }]; 59*9880d681SAndroid Build Coastguard Worker; }]; 60*9880d681SAndroid Build Coastguard Worker; } 61*9880d681SAndroid Build Coastguard Worker; @end 62*9880d681SAndroid Build Coastguard Worker; ---------------------------------------------------------------------- 63*9880d681SAndroid Build Coastguard Worker; ModuleID = 'llvm/tools/clang/test/CodeGenObjC/debug-info-block-captured-self.m' 64*9880d681SAndroid Build Coastguard Worker%0 = type opaque 65*9880d681SAndroid Build Coastguard Worker%struct.__block_descriptor = type { i64, i64 } 66*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.dbg.declare(metadata, metadata, metadata) #1 67*9880d681SAndroid Build Coastguard Workerdefine internal void @"__24-[Main initWithContext:]_block_invoke"(i8* %.block_descriptor, i8* %obj) #0 !dbg !38 { 68*9880d681SAndroid Build Coastguard Worker %block = bitcast i8* %.block_descriptor to <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>*, !dbg !84 69*9880d681SAndroid Build Coastguard Worker %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 70*9880d681SAndroid Build Coastguard Worker call void @llvm.dbg.declare(metadata <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>* %block, metadata !86, metadata !110), !dbg !87 71*9880d681SAndroid Build Coastguard Worker ret void, !dbg !87 72*9880d681SAndroid Build Coastguard Worker} 73*9880d681SAndroid Build Coastguard Worker 74*9880d681SAndroid Build Coastguard Workerdefine internal void @"__24-[Main initWithContext:]_block_invoke_2"(i8* %.block_descriptor, i8* %object) #0 !dbg !42 { 75*9880d681SAndroid Build Coastguard Worker %block = bitcast i8* %.block_descriptor to <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>*, !dbg !103 76*9880d681SAndroid Build Coastguard Worker %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 77*9880d681SAndroid Build Coastguard Worker call void @llvm.dbg.declare(metadata <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>* %block, metadata !105, metadata !109), !dbg !106 78*9880d681SAndroid Build Coastguard Worker ret void, !dbg !106 79*9880d681SAndroid Build Coastguard Worker} 80*9880d681SAndroid Build Coastguard Worker 81*9880d681SAndroid Build Coastguard Worker!llvm.dbg.cu = !{!0} 82*9880d681SAndroid Build Coastguard Worker!llvm.module.flags = !{!108} 83*9880d681SAndroid Build Coastguard Worker!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) 84*9880d681SAndroid Build Coastguard Worker!1 = !DIFile(filename: "llvm/tools/clang/test/CodeGenObjC/debug-info-block-captured-self.m", directory: "") 85*9880d681SAndroid Build Coastguard Worker!2 = !{!3} 86*9880d681SAndroid Build Coastguard Worker!3 = !DICompositeType(tag: DW_TAG_enumeration_type, line: 20, size: 32, align: 32, file: !107, elements: !4) 87*9880d681SAndroid Build Coastguard Worker!4 = !{} 88*9880d681SAndroid Build Coastguard Worker!15 = !{} 89*9880d681SAndroid Build Coastguard Worker!27 = !DIDerivedType(tag: DW_TAG_typedef, name: "id", line: 31, file: !107, baseType: !28) 90*9880d681SAndroid Build Coastguard Worker!28 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !29) 91*9880d681SAndroid Build Coastguard Worker!29 = !DICompositeType(tag: DW_TAG_structure_type, name: "objc_object", file: !107, elements: !30) 92*9880d681SAndroid Build Coastguard Worker!30 = !{!31} 93*9880d681SAndroid Build Coastguard Worker!31 = !DIDerivedType(tag: DW_TAG_member, name: "isa", size: 64, file: !107, scope: !29, baseType: !32) 94*9880d681SAndroid Build Coastguard Worker!32 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, baseType: !33) 95*9880d681SAndroid Build Coastguard Worker!33 = !DICompositeType(tag: DW_TAG_structure_type, name: "objc_class", flags: DIFlagFwdDecl, file: !107) 96*9880d681SAndroid Build Coastguard Worker!34 = !DICompositeType(tag: DW_TAG_structure_type, name: "Main", line: 23, flags: DIFlagArtificial | DIFlagObjectPointer, runtimeLang: DW_LANG_ObjC, file: !107) 97*9880d681SAndroid Build Coastguard Worker!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) 98*9880d681SAndroid Build Coastguard Worker!39 = !DISubroutineType(types: !40) 99*9880d681SAndroid Build Coastguard Worker!40 = !{null, !41, !27} 100*9880d681SAndroid Build Coastguard Worker!41 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: null) 101*9880d681SAndroid Build Coastguard Worker!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) 102*9880d681SAndroid Build Coastguard Worker!84 = !DILocation(line: 33, scope: !38) 103*9880d681SAndroid Build Coastguard Worker!86 = !DILocalVariable(name: "self", line: 41, scope: !38, file: !1, type: !34) 104*9880d681SAndroid Build Coastguard Worker!87 = !DILocation(line: 41, scope: !38) 105*9880d681SAndroid Build Coastguard Worker!103 = !DILocation(line: 35, scope: !42) 106*9880d681SAndroid Build Coastguard Worker!105 = !DILocalVariable(name: "self", line: 40, scope: !42, file: !1, type: !34) 107*9880d681SAndroid Build Coastguard Worker!106 = !DILocation(line: 40, scope: !42) 108*9880d681SAndroid Build Coastguard Worker!107 = !DIFile(filename: "llvm/tools/clang/test/CodeGenObjC/debug-info-block-captured-self.m", directory: "") 109*9880d681SAndroid Build Coastguard Worker!108 = !{i32 1, !"Debug Info Version", i32 3} 110*9880d681SAndroid Build Coastguard Worker!109 = !DIExpression(DW_OP_deref, DW_OP_plus, 32) 111*9880d681SAndroid Build Coastguard Worker!110 = !DIExpression(DW_OP_deref, DW_OP_plus, 32) 112