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
35 ; CHECK-NOT: {{DW_TAG|NULL}}
36 ; CHECK: DW_TAG_imported_module
38 ;; Abstract "bar" function
39 ; CHECK: [[Offset_bar]]: DW_TAG_subprogram
40 ; CHECK-NOT: {{DW_TAG|NULL}}
41 ; CHECK: DW_AT_name {{.*}} "bar"
42 ; CHECK-NOT: {{DW_TAG|NULL}}
44 ; CHECK-NOT: {{DW_TAG|NULL}}
45 ; CHECK: DW_TAG_lexical_block
46 ; CHECK-NOT: {{DW_TAG|NULL}}
47 ; CHECK: DW_TAG_variable
48 ; CHECK-NOT: {{DW_TAG|NULL}}
49 ; CHECK: DW_TAG_imported_module
51 ; CHECK: DW_TAG_subprogram
52 ; CHECK-NOT: {{DW_TAG|NULL}}
53 ; CHECK: DW_AT_name {{.*}} "foo"
56 ;; Inlined "bar" function
57 ; CHECK: DW_TAG_inlined_subroutine
58 ; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[Offset_bar]]}
59 ; CHECK-NOT: {{DW_TAG|NULL}}
60 ; CHECK: DW_TAG_lexical_block
61 ; CHECK-NOT: {{DW_TAG|NULL}}
62 ; CHECK: DW_TAG_variable
63 ; CHECK-NOT: {{DW_TAG|NULL}}
64 ; CHECK: DW_TAG_imported_module
67 ; Function Attrs: alwaysinline nounwind
68 define i32 @_Z3barv() #0 !dbg !4 {
70 %retval = alloca i32, align 4
71 %y = alloca i32, align 4
72 call void @llvm.dbg.declare(metadata i32* %y, metadata !18, metadata !19), !dbg !20
73 br label %while.cond, !dbg !21
75 while.cond: ; preds = %entry
76 %0 = load i32, i32* %y, align 4, !dbg !22
77 %cmp = icmp slt i32 %0, 0, !dbg !22
78 br i1 %cmp, label %while.body, label %while.end, !dbg !22
80 while.body: ; preds = %while.cond
81 store i32 2, i32* %retval, align 4, !dbg !24
82 br label %return, !dbg !24
84 while.end: ; preds = %while.cond
85 store i32 0, i32* %retval, align 4, !dbg !26
86 br label %return, !dbg !26
88 return: ; preds = %while.end, %while.body
89 %1 = load i32, i32* %retval, align 4, !dbg !27
93 ; Function Attrs: nounwind readnone
94 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
96 ; Function Attrs: nounwind
97 define i32 @_Z3foov() #2 !dbg !8 {
99 %retval.i = alloca i32, align 4
100 %y.i = alloca i32, align 4
101 call void @llvm.dbg.declare(metadata i32* %y.i, metadata !18, metadata !19), !dbg !29
102 %0 = load i32, i32* %y.i, align 4, !dbg !31
103 %cmp.i = icmp slt i32 %0, 0, !dbg !31
104 br i1 %cmp.i, label %while.body.i, label %while.end.i, !dbg !31
106 while.body.i: ; preds = %entry
107 store i32 2, i32* %retval.i, align 4, !dbg !32
108 br label %_Z3barv.exit, !dbg !32
110 while.end.i: ; preds = %entry
111 store i32 0, i32* %retval.i, align 4, !dbg !33
112 br label %_Z3barv.exit, !dbg !33
114 _Z3barv.exit: ; preds = %while.end.i, %while.body.i
115 %1 = load i32, i32* %retval.i, align 4, !dbg !34
119 attributes #0 = { alwaysinline nounwind }
120 attributes #1 = { nounwind readnone }
121 attributes #2 = { nounwind }
124 !llvm.module.flags = !{!15, !16}
127 !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, imports: !10)
128 !1 = !DIFile(filename: "test.cpp", directory: "/")
130 !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: !2)
131 !5 = !DISubroutineType(types: !6)
133 !7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
134 !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)
135 !9 = !DIFile(filename: "test.h", directory: "/")
137 !11 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !12, entity: !14, file: !1, line: 1)
138 !12 = !DILexicalBlockFile(scope: !13, file: !9, discriminator: 0)
139 !13 = distinct !DILexicalBlock(scope: !4, file: !1, line: 3)
140 !14 = !DINamespace(name: "N", scope: null)
141 !15 = !{i32 2, !"Dwarf Version", i32 4}
142 !16 = !{i32 2, !"Debug Info Version", i32 3}
143 !17 = !{!"clang version 3.9.0 (trunk 264349)"}
144 !18 = !DILocalVariable(name: "y", scope: !13, file: !1, line: 4, type: !7)
145 !19 = !DIExpression()
146 !20 = !DILocation(line: 4, scope: !13)
147 !21 = !DILocation(line: 2, scope: !12)
148 !22 = !DILocation(line: 2, scope: !23)
149 !23 = !DILexicalBlockFile(scope: !12, file: !9, discriminator: 1)
150 !24 = !DILocation(line: 2, scope: !25)
151 !25 = !DILexicalBlockFile(scope: !12, file: !9, discriminator: 2)
152 !26 = !DILocation(line: 3, scope: !12)
153 !27 = !DILocation(line: 5, scope: !28)
154 !28 = !DILexicalBlockFile(scope: !4, file: !9, discriminator: 0)
155 !29 = !DILocation(line: 4, scope: !13, inlinedAt: !30)
156 !30 = distinct !DILocation(line: 7, scope: !8)
157 !31 = !DILocation(line: 2, scope: !23, inlinedAt: !30)
158 !32 = !DILocation(line: 2, scope: !25, inlinedAt: !30)
159 !33 = !DILocation(line: 3, scope: !12, inlinedAt: !30)
160 !34 = !DILocation(line: 5, scope: !28, inlinedAt: !30)
161 !35 = !DILocation(line: 7, scope: !8)