• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc %s -o %t -filetype=obj
2; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck %s
3
4; Checks that we emit debug info for the block variable declare.
5; CHECK: DW_TAG_subprogram
6; CHECK: DW_TAG_variable
7; CHECK-NEXT: DW_AT_location [DW_FORM_block1] (DW_OP_fbreg +8, DW_OP_deref, DW_OP_plus_uconst 0x20)
8; CHECK-NEXT: DW_AT_name {{.*}} "block"
9
10; Extracted from the clang output for:
11; void foo() {
12;  void (^block)() = ^{ block(); };
13; }
14
15; ModuleID = 'foo.m'
16target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
17target triple = "x86_64-apple-darwin"
18
19%struct.__block_descriptor = type { i64, i64 }
20%struct.__block_literal_generic = type { i8*, i32, i32, i8*, %struct.__block_descriptor* }
21
22@_NSConcreteStackBlock = external global i8*
23@.str = private unnamed_addr constant [6 x i8] c"v8@?0\00", align 1
24
25; Function Attrs: nounwind readnone
26declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
27
28; Function Attrs: ssp uwtable
29define internal void @__foo_block_invoke(i8* %.block_descriptor) #2 !dbg !8 {
30entry:
31  %.block_descriptor.addr = alloca i8*, align 8
32  %block.addr = alloca <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, void (...)* }>*, align 8
33  store i8* %.block_descriptor, i8** %.block_descriptor.addr, align 8
34  %0 = load i8*, i8** %.block_descriptor.addr
35  call void @llvm.dbg.value(metadata i8* %0, metadata !47, metadata !43), !dbg !66
36  call void @llvm.dbg.declare(metadata i8* %.block_descriptor, metadata !47, metadata !43), !dbg !66
37  %block = bitcast i8* %.block_descriptor to <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, void (...)* }>*, !dbg !67
38  store <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, void (...)* }>* %block, <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, void (...)* }>** %block.addr, align 8
39  call void @llvm.dbg.declare(metadata <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, void (...)* }>** %block.addr, metadata !68, metadata !69), !dbg !70
40  %block.capture.addr = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, void (...)* }>, <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, void (...)* }>* %block, i32 0, i32 5, !dbg !71
41  %1 = load void (...)*, void (...)** %block.capture.addr, align 8, !dbg !71
42  %block.literal = bitcast void (...)* %1 to %struct.__block_literal_generic*, !dbg !71
43  %2 = getelementptr inbounds %struct.__block_literal_generic, %struct.__block_literal_generic* %block.literal, i32 0, i32 3, !dbg !71
44  %3 = bitcast %struct.__block_literal_generic* %block.literal to i8*, !dbg !71
45  %4 = load i8*, i8** %2, !dbg !71
46  %5 = bitcast i8* %4 to void (i8*, ...)*, !dbg !71
47  call void (i8*, ...) %5(i8* %3), !dbg !71
48  ret void, !dbg !73
49}
50
51; Function Attrs: nounwind readnone
52declare void @llvm.dbg.value(metadata, metadata, metadata) #1
53
54
55attributes #0 = { nounwind ssp uwtable }
56attributes #1 = { nounwind readnone }
57attributes #2 = { ssp uwtable }
58attributes #3 = { nounwind }
59
60!llvm.dbg.cu = !{!0}
61!llvm.module.flags = !{!16, !17, !18, !19, !20, !21, !22}
62!llvm.ident = !{!23}
63
64!0 = distinct !DICompileUnit(language: DW_LANG_ObjC, producer: "clang version 3.6.0 (trunk 223471)", isOptimized: false, runtimeVersion: 2, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
65!1 = !DIFile(filename: "foo.m", directory: "")
66!2 = !{}
67!5 = !DIFile(filename: "foo.m", directory: "")
68!6 = !DISubroutineType(types: !7)
69!7 = !{null}
70!8 = distinct !DISubprogram(name: "__foo_block_invoke", line: 2, isLocal: true, isDefinition: true, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 2, file: !1, scope: !5, type: !9, retainedNodes: !2)
71!9 = !DISubroutineType(types: !10)
72!10 = !{null, !11}
73!11 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: null)
74!13 = !DISubroutineType(types: !14)
75!14 = !{null, !11, !11}
76!16 = !{i32 1, !"Objective-C Version", i32 2}
77!17 = !{i32 1, !"Objective-C Image Info Version", i32 0}
78!18 = !{i32 1, !"Objective-C Image Info Section", !"__DATA, __objc_imageinfo, regular, no_dead_strip"}
79!19 = !{i32 4, !"Objective-C Garbage Collection", i32 0}
80!20 = !{i32 2, !"Dwarf Version", i32 2}
81!21 = !{i32 2, !"Debug Info Version", i32 3}
82!22 = !{i32 1, !"PIC Level", i32 2}
83!23 = !{!"clang version 3.6.0 (trunk 223471)"}
84!25 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, baseType: !26)
85!26 = !DICompositeType(tag: DW_TAG_structure_type, name: "__block_literal_generic", line: 2, size: 256, flags: DIFlagAppleBlock, file: !1, scope: !5, elements: !27)
86!27 = !{!28, !29, !31, !32, !36}
87!28 = !DIDerivedType(tag: DW_TAG_member, name: "__isa", size: 64, align: 64, file: !1, scope: !5, baseType: !11)
88!29 = !DIDerivedType(tag: DW_TAG_member, name: "__flags", size: 32, align: 32, offset: 64, file: !1, scope: !5, baseType: !30)
89!30 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
90!31 = !DIDerivedType(tag: DW_TAG_member, name: "__reserved", size: 32, align: 32, offset: 96, file: !1, scope: !5, baseType: !30)
91!32 = !DIDerivedType(tag: DW_TAG_member, name: "__FuncPtr", size: 64, align: 64, offset: 128, file: !1, scope: !5, baseType: !33)
92!33 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !34)
93!34 = !DISubroutineType(types: !35)
94!35 = !{null, null}
95!36 = !DIDerivedType(tag: DW_TAG_member, name: "__descriptor", line: 2, size: 64, align: 64, offset: 192, file: !1, scope: !5, baseType: !37)
96!37 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, baseType: !38)
97!38 = !DICompositeType(tag: DW_TAG_structure_type, name: "__block_descriptor", line: 2, size: 128, flags: DIFlagAppleBlock, file: !1, scope: !5, elements: !39)
98!39 = !{!40, !42}
99!40 = !DIDerivedType(tag: DW_TAG_member, name: "reserved", size: 64, align: 64, file: !1, scope: !5, baseType: !41)
100!41 = !DIBasicType(tag: DW_TAG_base_type, name: "long unsigned int", size: 64, align: 64, encoding: DW_ATE_unsigned)
101!42 = !DIDerivedType(tag: DW_TAG_member, name: "Size", size: 64, align: 64, offset: 64, file: !1, scope: !5, baseType: !41)
102!43 = !DIExpression()
103!47 = !DILocalVariable(name: ".block_descriptor", line: 2, arg: 1, flags: DIFlagArtificial, scope: !8, file: !5, type: !48)
104!48 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, baseType: !49)
105!49 = !DICompositeType(tag: DW_TAG_structure_type, name: "__block_literal_1", line: 2, size: 320, align: 64, file: !1, scope: !5, elements: !50)
106!50 = !{!51, !52, !53, !54, !56, !65}
107!51 = !DIDerivedType(tag: DW_TAG_member, name: "__isa", line: 2, size: 64, align: 64, flags: DIFlagPublic, file: !1, scope: !5, baseType: !11)
108!52 = !DIDerivedType(tag: DW_TAG_member, name: "__flags", line: 2, size: 32, align: 32, offset: 64, flags: DIFlagPublic, file: !1, scope: !5, baseType: !30)
109!53 = !DIDerivedType(tag: DW_TAG_member, name: "__reserved", line: 2, size: 32, align: 32, offset: 96, flags: DIFlagPublic, file: !1, scope: !5, baseType: !30)
110!54 = !DIDerivedType(tag: DW_TAG_member, name: "__FuncPtr", line: 2, size: 64, align: 64, offset: 128, flags: DIFlagPublic, file: !1, scope: !5, baseType: !55)
111!55 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !6)
112!56 = !DIDerivedType(tag: DW_TAG_member, name: "__descriptor", line: 2, size: 64, align: 64, offset: 192, flags: DIFlagPublic, file: !1, scope: !5, baseType: !57)
113!57 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !58)
114!58 = !DICompositeType(tag: DW_TAG_structure_type, name: "__block_descriptor_withcopydispose", line: 2, size: 256, align: 64, file: !1, elements: !59)
115!59 = !{!60, !61, !62, !64}
116!60 = !DIDerivedType(tag: DW_TAG_member, name: "reserved", line: 2, size: 64, align: 64, file: !1, scope: !58, baseType: !41)
117!61 = !DIDerivedType(tag: DW_TAG_member, name: "Size", line: 2, size: 64, align: 64, offset: 64, file: !1, scope: !58, baseType: !41)
118!62 = !DIDerivedType(tag: DW_TAG_member, name: "CopyFuncPtr", line: 2, size: 64, align: 64, offset: 128, file: !1, scope: !58, baseType: !63)
119!63 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !11)
120!64 = !DIDerivedType(tag: DW_TAG_member, name: "DestroyFuncPtr", line: 2, size: 64, align: 64, offset: 192, file: !1, scope: !58, baseType: !63)
121!65 = !DIDerivedType(tag: DW_TAG_member, name: "block", line: 2, size: 64, align: 64, offset: 256, flags: DIFlagPublic, file: !1, scope: !5, baseType: !25)
122!66 = !DILocation(line: 2, column: 20, scope: !8)
123!67 = !DILocation(line: 2, column: 21, scope: !8)
124!68 = !DILocalVariable(name: "block", line: 2, scope: !8, file: !5, type: !25)
125!69 = !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 32)
126!70 = !DILocation(line: 2, column: 9, scope: !8)
127!71 = !DILocation(line: 2, column: 23, scope: !72)
128!72 = distinct !DILexicalBlock(line: 2, column: 21, file: !1, scope: !8)
129!73 = !DILocation(line: 2, column: 32, scope: !8)
130