1 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -filetype=obj -O0 < %s | llvm-dwarfdump -v -debug-info - | FileCheck %s
3 ;; This test checks that Inlined DILexicalBlockFile with local decl entry
4 ;; is skipped and only one DW_TAG_lexical_block is generated.
5 ;; This test is special because it contains DILexicalBlockFile that has a
6 ;; DILexicalBlockFile as a parent scope.
8 ;; This test was generated by running following command:
9 ;; clang -cc1 -O0 -debug-info-kind=limited -dwarf-version=4 -emit-llvm test.cpp
11 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13 ;; __attribute__((always_inline)) int bar() {
18 ;; while (y < 0) return 2;
25 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
27 ;; Concrete "bar" function
28 ; CHECK: DW_TAG_subprogram
29 ; CHECK-NOT: {{DW_TAG|NULL}}
30 ; CHECK: DW_AT_abstract_origin {{.*}} {[[Offset_bar:0x[0-9abcdef]+]]}
31 ; CHECK-NOT: {{DW_TAG|NULL}}
32 ; CHECK: DW_TAG_lexical_block
33 ; CHECK-NOT: {{DW_TAG|NULL}}
34 ; CHECK: DW_TAG_variable
36 ;; Abstract "bar" function
37 ; CHECK: [[Offset_bar]]: DW_TAG_subprogram
38 ; CHECK-NOT: {{DW_TAG|NULL}}
39 ; CHECK: DW_AT_name {{.*}} "bar"
40 ; CHECK-NOT: {{DW_TAG|NULL}}
42 ; CHECK-NOT: {{DW_TAG|NULL}}
43 ; CHECK: DW_TAG_lexical_block
44 ; CHECK-NOT: {{DW_TAG|NULL}}
45 ; CHECK: DW_TAG_variable
46 ; CHECK-NOT: {{DW_TAG|NULL}}
47 ; CHECK: DW_TAG_imported_module
49 ; CHECK: DW_TAG_subprogram
50 ; CHECK-NOT: {{DW_TAG|NULL}}
51 ; CHECK: DW_AT_name {{.*}} "foo"
54 ;; Inlined "bar" function
55 ; CHECK: DW_TAG_inlined_subroutine
56 ; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[Offset_bar]]}
57 ; CHECK-NOT: {{DW_TAG|NULL}}
58 ; CHECK: DW_TAG_lexical_block
59 ; CHECK-NOT: {{DW_TAG|NULL}}
60 ; CHECK: DW_TAG_variable
62 ; Function Attrs: alwaysinline nounwind
63 define i32 @_Z3barv() #0 !dbg !4 {
65 %retval = alloca i32, align 4
66 %y = alloca i32, align 4
67 call void @llvm.dbg.declare(metadata ptr %y, metadata !18, metadata !19), !dbg !20
68 br label %while.cond, !dbg !21
70 while.cond: ; preds = %entry
71 %0 = load i32, ptr %y, align 4, !dbg !22
72 %cmp = icmp slt i32 %0, 0, !dbg !22
73 br i1 %cmp, label %while.body, label %while.end, !dbg !22
75 while.body: ; preds = %while.cond
76 store i32 2, ptr %retval, align 4, !dbg !24
77 br label %return, !dbg !24
79 while.end: ; preds = %while.cond
80 store i32 0, ptr %retval, align 4, !dbg !26
81 br label %return, !dbg !26
83 return: ; preds = %while.end, %while.body
84 %1 = load i32, ptr %retval, align 4, !dbg !27
88 ; Function Attrs: nounwind readnone
89 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
91 ; Function Attrs: nounwind
92 define i32 @_Z3foov() #2 !dbg !8 {
94 %retval.i = alloca i32, align 4
95 %y.i = alloca i32, align 4
96 call void @llvm.dbg.declare(metadata ptr %y.i, metadata !18, metadata !19), !dbg !29
97 %0 = load i32, ptr %y.i, align 4, !dbg !31
98 %cmp.i = icmp slt i32 %0, 0, !dbg !31
99 br i1 %cmp.i, label %while.body.i, label %while.end.i, !dbg !31
101 while.body.i: ; preds = %entry
102 store i32 2, ptr %retval.i, align 4, !dbg !32
103 br label %_Z3barv.exit, !dbg !32
105 while.end.i: ; preds = %entry
106 store i32 0, ptr %retval.i, align 4, !dbg !33
107 br label %_Z3barv.exit, !dbg !33
109 _Z3barv.exit: ; preds = %while.end.i, %while.body.i
110 %1 = load i32, ptr %retval.i, align 4, !dbg !34
114 attributes #0 = { alwaysinline nounwind }
115 attributes #1 = { nounwind readnone }
116 attributes #2 = { nounwind }
119 !llvm.module.flags = !{!15, !16}
122 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.9.0 (trunk 264349)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2)
123 !1 = !DIFile(filename: "test.cpp", directory: "/")
125 !4 = distinct !DISubprogram(name: "bar", linkageName: "_Z3barv", scope: !1, file: !1, line: 2, type: !5, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !10)
126 !5 = !DISubroutineType(types: !6)
128 !7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
129 !8 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !9, file: !9, line: 6, type: !5, isLocal: false, isDefinition: true, scopeLine: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
130 !9 = !DIFile(filename: "test.h", directory: "/")
132 !11 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !12, entity: !14, file: !1, line: 1)
133 !12 = !DILexicalBlockFile(scope: !13, file: !9, discriminator: 0)
134 !13 = distinct !DILexicalBlock(scope: !4, file: !1, line: 3)
135 !14 = !DINamespace(name: "N", scope: null)
136 !15 = !{i32 2, !"Dwarf Version", i32 4}
137 !16 = !{i32 2, !"Debug Info Version", i32 3}
138 !17 = !{!"clang version 3.9.0 (trunk 264349)"}
139 !18 = !DILocalVariable(name: "y", scope: !13, file: !1, line: 4, type: !7)
140 !19 = !DIExpression()
141 !20 = !DILocation(line: 4, scope: !13)
142 !21 = !DILocation(line: 2, scope: !12)
143 !22 = !DILocation(line: 2, scope: !23)
144 !23 = !DILexicalBlockFile(scope: !12, file: !9, discriminator: 1)
145 !24 = !DILocation(line: 2, scope: !25)
146 !25 = !DILexicalBlockFile(scope: !12, file: !9, discriminator: 2)
147 !26 = !DILocation(line: 3, scope: !12)
148 !27 = !DILocation(line: 5, scope: !28)
149 !28 = !DILexicalBlockFile(scope: !4, file: !9, discriminator: 0)
150 !29 = !DILocation(line: 4, scope: !13, inlinedAt: !30)
151 !30 = distinct !DILocation(line: 7, scope: !8)
152 !31 = !DILocation(line: 2, scope: !23, inlinedAt: !30)
153 !32 = !DILocation(line: 2, scope: !25, inlinedAt: !30)
154 !33 = !DILocation(line: 3, scope: !12, inlinedAt: !30)
155 !34 = !DILocation(line: 5, scope: !28, inlinedAt: !30)
156 !35 = !DILocation(line: 7, scope: !8)