diff options
Diffstat (limited to 'llvm/test')
-rw-r--r-- | llvm/test/DebugInfo/Generic/2010-04-06-NestedFnDbgInfo.ll | 3 | ||||
-rw-r--r-- | llvm/test/DebugInfo/Generic/2010-06-29-InlinedFnLocalVar.ll | 3 | ||||
-rw-r--r-- | llvm/test/DebugInfo/Generic/cross-cu-linkonce-distinct.ll | 6 | ||||
-rw-r--r-- | llvm/test/DebugInfo/Generic/namespace.ll | 30 | ||||
-rw-r--r-- | llvm/test/DebugInfo/Generic/nodebug.ll | 6 | ||||
-rw-r--r-- | llvm/test/DebugInfo/Mips/InlinedFnLocalVar.ll | 3 | ||||
-rw-r--r-- | llvm/test/DebugInfo/X86/InlinedFnLocalVar.ll | 3 | ||||
-rw-r--r-- | llvm/test/DebugInfo/X86/PR24008.ll | 67 | ||||
-rw-r--r-- | llvm/test/DebugInfo/X86/dbg-file-name.ll | 3 | ||||
-rw-r--r-- | llvm/test/DebugInfo/X86/debug-dead-local-var.ll | 9 | ||||
-rw-r--r-- | llvm/test/DebugInfo/X86/gnu-public-names.ll | 25 | ||||
-rw-r--r-- | llvm/test/DebugInfo/X86/lexical-block-file.ll | 89 | ||||
-rw-r--r-- | llvm/test/DebugInfo/X86/lexical-block-inline.ll | 198 | ||||
-rw-r--r-- | llvm/test/DebugInfo/X86/lexical-block.ll | 131 | ||||
-rw-r--r-- | llvm/test/DebugInfo/X86/subprogram-inline.ll | 169 |
15 files changed, 705 insertions, 40 deletions
diff --git a/llvm/test/DebugInfo/Generic/2010-04-06-NestedFnDbgInfo.ll b/llvm/test/DebugInfo/Generic/2010-04-06-NestedFnDbgInfo.ll index 610b55c903e..3eaedd816a8 100644 --- a/llvm/test/DebugInfo/Generic/2010-04-06-NestedFnDbgInfo.ll +++ b/llvm/test/DebugInfo/Generic/2010-04-06-NestedFnDbgInfo.ll @@ -74,7 +74,7 @@ entry: !1 = distinct !DILexicalBlock(line: 15, column: 12, file: !38, scope: !2) !2 = distinct !DISubprogram(name: "main", linkageName: "main", line: 15, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, scopeLine: 15, file: !38, scope: !3, type: !5) !3 = !DIFile(filename: "one.cc", directory: "/tmp") -!4 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang 1.5", isOptimized: false, emissionKind: 0, file: !38, enums: !39, retainedTypes: !39, subprograms: !37, imports: null) +!4 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang 1.5", isOptimized: false, emissionKind: 0, file: !38, enums: !39, retainedTypes: !41, subprograms: !37, imports: null) !5 = !DISubroutineType(types: !6) !6 = !{!7} !7 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) @@ -112,3 +112,4 @@ entry: !38 = !DIFile(filename: "one.cc", directory: "/tmp") !39 = !{} !40 = !{i32 1, !"Debug Info Version", i32 3} +!41 = !{!21}
\ No newline at end of file diff --git a/llvm/test/DebugInfo/Generic/2010-06-29-InlinedFnLocalVar.ll b/llvm/test/DebugInfo/Generic/2010-06-29-InlinedFnLocalVar.ll index f01cf6db905..10bc50cc85e 100644 --- a/llvm/test/DebugInfo/Generic/2010-06-29-InlinedFnLocalVar.ll +++ b/llvm/test/DebugInfo/Generic/2010-06-29-InlinedFnLocalVar.ll @@ -27,7 +27,7 @@ entry: !0 = distinct !DISubprogram(name: "foo", line: 9, isLocal: true, isDefinition: true, virtualIndex: 6, isOptimized: true, scopeLine: 9, file: !27, scope: !1, type: !3, variables: !24) !1 = !DIFile(filename: "bar.c", directory: "/tmp/") -!2 = distinct !DICompileUnit(language: DW_LANG_C89, producer: "4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", isOptimized: true, emissionKind: 0, file: !27, enums: !20, retainedTypes: !20, subprograms: !25, globals: !26, imports: !20) +!2 = distinct !DICompileUnit(language: DW_LANG_C89, producer: "4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", isOptimized: true, emissionKind: 0, file: !27, enums: !20, retainedTypes: !61, subprograms: !25, globals: !26, imports: !20) !3 = !DISubroutineType(types: !4) !4 = !{!5, !5} !5 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) @@ -39,6 +39,7 @@ entry: !59 = !DILocalVariable(name: "j", line: 9, arg: 1, scope: !0, file: !1, type: !5) !60 = !DILocalVariable(name: "xyz", line: 10, scope: !11, file: !1, type: !12) +!61 = !{!12} !11 = distinct !DILexicalBlock(line: 9, column: 0, file: !1, scope: !0) !12 = !DICompositeType(tag: DW_TAG_structure_type, name: "X", line: 10, size: 64, align: 32, file: !27, scope: !0, elements: !13) diff --git a/llvm/test/DebugInfo/Generic/cross-cu-linkonce-distinct.ll b/llvm/test/DebugInfo/Generic/cross-cu-linkonce-distinct.ll index 1713ea112d4..cbe192075ad 100644 --- a/llvm/test/DebugInfo/Generic/cross-cu-linkonce-distinct.ll +++ b/llvm/test/DebugInfo/Generic/cross-cu-linkonce-distinct.ll @@ -32,7 +32,7 @@ ; CHECK: DW_AT_name {{.*}} "func" ; CHECK: DW_TAG_compile_unit -; FIXME: Maybe we should drop the subprogram here - since the function was +; Check that the subprogram is dropped in this CU - since the function was ; emitted in one CU, due to linkonce_odr uniquing. We certainly don't emit the ; subprogram here if the source location for this definition is the same (see ; test/DebugInfo/cross-cu-linkonce.ll), though it's very easy to tickle that @@ -43,7 +43,7 @@ ; directory of the source file even though the file name is absolute, not ; relative) -; CHECK: DW_TAG_subprogram +; CHECK-NOT: DW_TAG_subprogram @x = global i32 (i32)* @_Z4funci, align 8 @y = global i32 (i32)* @_Z4funci, align 8 @@ -64,7 +64,7 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 attributes #0 = { inlinehint nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } attributes #1 = { nounwind readnone } -!llvm.dbg.cu = !{!12, !0} +!llvm.dbg.cu = !{!0, !12} !llvm.module.flags = !{!19, !20} !llvm.ident = !{!21, !21} diff --git a/llvm/test/DebugInfo/Generic/namespace.ll b/llvm/test/DebugInfo/Generic/namespace.ll index e446806249f..e1769758551 100644 --- a/llvm/test/DebugInfo/Generic/namespace.ll +++ b/llvm/test/DebugInfo/Generic/namespace.ll @@ -23,6 +23,11 @@ ; CHECK-NOT: NULL ; CHECK: [[BAR:0x[0-9a-f]*]]:{{ *}}DW_TAG_structure_type ; CHECK-NEXT: DW_AT_name{{.*}}= "bar" +; CHECK: DW_TAG_subprogram +; CHECK-NOT: DW_TAG +; CHECK: DW_AT_MIPS_linkage_name +; CHECK-NOT: DW_TAG +; CHECK: DW_AT_name{{.*}}= "f1" ; CHECK: [[FUNC1:.*]]: DW_TAG_subprogram ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_MIPS_linkage_name @@ -45,11 +50,6 @@ ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_name{{.*}}= "func_fwd" ; CHECK-NOT: DW_AT_declaration -; CHECK: DW_TAG_subprogram -; CHECK-NOT: DW_TAG -; CHECK: DW_AT_MIPS_linkage_name -; CHECK-NOT: DW_TAG -; CHECK: DW_AT_name{{.*}}= "f1" ; CHECK: NULL ; CHECK-NOT: NULL @@ -71,10 +71,23 @@ ; CHECK: DW_TAG_subprogram ; CHECK-NOT: DW_TAG +; CHECK: DW_AT_name{{.*}}= "__cxx_global_var_init" +; CHECK-NOT: DW_TAG + +; CHECK: DW_TAG_subprogram +; CHECK-NOT: DW_TAG ; CHECK: DW_AT_MIPS_linkage_name ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_name{{.*}}= "func" ; CHECK-NOT: NULL +; CHECK: DW_TAG_lexical_block +; CHECK-NOT: NULL +; CHECK: DW_TAG_imported_module +; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F2]]) +; CHECK-NEXT: DW_AT_decl_line{{.*}}(23) +; CHECK-NEXT: DW_AT_import{{.*}}=> +; CHECK: NULL +; CHECK-NOT: NULL ; CHECK: DW_TAG_imported_module ; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F2]]) ; CHECK-NEXT: DW_AT_decl_line{{.*}}(26) @@ -134,13 +147,6 @@ ; CHECK-NEXT: DW_AT_decl_line{{.*}}(37) ; CHECK-NEXT: DW_AT_import{{.*}}=> {[[FUNC_FWD]]}) -; CHECK: DW_TAG_lexical_block -; CHECK-NOT: NULL -; CHECK: DW_TAG_imported_module -; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F2]]) -; CHECK-NEXT: DW_AT_decl_line{{.*}}(23) -; CHECK-NEXT: DW_AT_import{{.*}}=> -; CHECK: NULL ; CHECK: NULL ; CHECK: NULL diff --git a/llvm/test/DebugInfo/Generic/nodebug.ll b/llvm/test/DebugInfo/Generic/nodebug.ll index 6f20aecaaf5..7aafc8d5fa1 100644 --- a/llvm/test/DebugInfo/Generic/nodebug.ll +++ b/llvm/test/DebugInfo/Generic/nodebug.ll @@ -16,10 +16,8 @@ ; f1(); ; } -; Check that there's only one DW_TAG_subprogram, nothing for the 'f2' function. -; CHECK: DW_TAG_subprogram -; CHECK-NOT: DW_TAG -; CHECK: DW_AT_name {{.*}} "f1" +; Check that there is no DW_TAG_subprogram, nothing for the 'f2' function. +; Note: No debug info was emitted for 'f1' function because it has no code. ; CHECK-NOT: DW_TAG_subprogram @i = external global i32 diff --git a/llvm/test/DebugInfo/Mips/InlinedFnLocalVar.ll b/llvm/test/DebugInfo/Mips/InlinedFnLocalVar.ll index fe661522da7..4b57e7c4c30 100644 --- a/llvm/test/DebugInfo/Mips/InlinedFnLocalVar.ll +++ b/llvm/test/DebugInfo/Mips/InlinedFnLocalVar.ll @@ -27,7 +27,7 @@ entry: !0 = distinct !DISubprogram(name: "foo", line: 9, isLocal: true, isDefinition: true, virtualIndex: 6, isOptimized: true, scopeLine: 9, file: !27, scope: !1, type: !3, variables: !24) !1 = !DIFile(filename: "bar.c", directory: "/tmp/") -!2 = distinct !DICompileUnit(language: DW_LANG_C89, producer: "4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", isOptimized: true, emissionKind: 0, file: !27, enums: !20, retainedTypes: !20, subprograms: !25, globals: !26, imports: !20) +!2 = distinct !DICompileUnit(language: DW_LANG_C89, producer: "4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", isOptimized: true, emissionKind: 0, file: !27, enums: !20, retainedTypes: !61, subprograms: !25, globals: !26, imports: !20) !3 = !DISubroutineType(types: !4) !4 = !{!5, !5} !5 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) @@ -39,6 +39,7 @@ entry: !59 = !DILocalVariable(name: "j", line: 9, arg: 1, scope: !0, file: !1, type: !5) !60 = !DILocalVariable(name: "xyz", line: 10, scope: !11, file: !1, type: !12) +!61 = !{!12} !11 = distinct !DILexicalBlock(line: 9, column: 0, file: !1, scope: !0) !12 = !DICompositeType(tag: DW_TAG_structure_type, name: "X", line: 10, size: 64, align: 32, file: !27, scope: !0, elements: !13) diff --git a/llvm/test/DebugInfo/X86/InlinedFnLocalVar.ll b/llvm/test/DebugInfo/X86/InlinedFnLocalVar.ll index a262fc8e88c..0b1490adbc6 100644 --- a/llvm/test/DebugInfo/X86/InlinedFnLocalVar.ll +++ b/llvm/test/DebugInfo/X86/InlinedFnLocalVar.ll @@ -27,7 +27,7 @@ entry: !0 = distinct !DISubprogram(name: "foo", line: 9, isLocal: true, isDefinition: true, virtualIndex: 6, isOptimized: true, scopeLine: 9, file: !27, scope: !1, type: !3, variables: !24) !1 = !DIFile(filename: "bar.c", directory: "/tmp/") -!2 = distinct !DICompileUnit(language: DW_LANG_C89, producer: "4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", isOptimized: true, emissionKind: 0, file: !27, enums: !20, retainedTypes: !20, subprograms: !25, globals: !26, imports: !20) +!2 = distinct !DICompileUnit(language: DW_LANG_C89, producer: "4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", isOptimized: true, emissionKind: 0, file: !27, enums: !20, retainedTypes: !111, subprograms: !25, globals: !26, imports: !20) !3 = !DISubroutineType(types: !4) !4 = !{!5, !5} !5 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) @@ -39,6 +39,7 @@ entry: !109 = !DILocalVariable(name: "j", line: 9, arg: 1, scope: !0, file: !1, type: !5) !110 = !DILocalVariable(name: "xyz", line: 10, scope: !11, file: !1, type: !12) +!111 = !{!12} !11 = distinct !DILexicalBlock(line: 9, column: 0, file: !1, scope: !0) !12 = !DICompositeType(tag: DW_TAG_structure_type, name: "X", line: 10, size: 64, align: 32, file: !27, scope: !0, elements: !13) diff --git a/llvm/test/DebugInfo/X86/PR24008.ll b/llvm/test/DebugInfo/X86/PR24008.ll new file mode 100644 index 00000000000..ec7c978775e --- /dev/null +++ b/llvm/test/DebugInfo/X86/PR24008.ll @@ -0,0 +1,67 @@ +; RUN: llc -mtriple=x86_64-unknown-linux-gnu -filetype=obj -O0 < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s + +;; This test checks the following: +;; 1. Compilation does not crash +;; 2. "f1" function is defined. +;; 3. "nested::f2" function is not defined. +;; +;; This test was generated by running following command: +;; clang -cc1 -O0 -g -emit-llvm foo.cpp -o - | opt -S -inline -sroa +;; Where test.cpp +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;void f1() { +;; while (true) { +;; struct nested { +;; static void f2() {} +;; }; +;; nested::f2(); +;; } +;;} +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +; CHECK: DW_TAG_compile_unit +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_TAG_subprogram +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_name {{.*}} "f1" +; CHECK: NULL + +; CHECK-NOT: DW_TAG_subprogram + + +; Function Attrs: nounwind +define void @_Z2f1v() #0 !dbg !6 { +entry: + br label %while.body, !dbg !16 + +while.body: ; preds = %while.body, %entry + br label %while.body, !dbg !16 + +return: ; No predecessors! + ret void, !dbg !17 +} + +attributes #0 = { nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "target-features"="+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!13, !14} +!llvm.ident = !{!15} + +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 242994) (llvm/trunk 242995)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !3, subprograms: !11) +!1 = !DIFile(filename: "foo.cpp", directory: "/") +!2 = !{} +!3 = !{!4} +!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "nested", scope: !5, file: !1, line: 3, size: 8, align: 8, elements: !9) +!5 = distinct !DILexicalBlock(scope: !6, file: !1, line: 2) +!6 = distinct !DISubprogram(name: "f1", linkageName: "_Z2f1v", scope: !1, file: !1, line: 1, type: !7, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, variables: !2) +!7 = !DISubroutineType(types: !8) +!8 = !{null} +!9 = !{!10} +!10 = distinct !DISubprogram(name: "f2", scope: !4, file: !1, line: 4, type: !7, isLocal: false, isDefinition: false, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: false) +!11 = !{!6, !12} +!12 = distinct !DISubprogram(name: "f2", linkageName: "_ZZ2f1vEN6nested2f2Ev", scope: !4, file: !1, line: 4, type: !7, isLocal: true, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: false, declaration: !10, variables: !2) +!13 = !{i32 2, !"Dwarf Version", i32 4} +!14 = !{i32 2, !"Debug Info Version", i32 3} +!15 = !{!"clang version 3.8.0 (trunk 242994) (llvm/trunk 242995)"} +!16 = !DILocation(line: 2, scope: !6) +!17 = !DILocation(line: 8, scope: !6) diff --git a/llvm/test/DebugInfo/X86/dbg-file-name.ll b/llvm/test/DebugInfo/X86/dbg-file-name.ll index 60954b9746b..0716d8619c7 100644 --- a/llvm/test/DebugInfo/X86/dbg-file-name.ll +++ b/llvm/test/DebugInfo/X86/dbg-file-name.ll @@ -6,7 +6,7 @@ declare i32 @printf(i8*, ...) nounwind define i32 @main() nounwind !dbg !6 { - ret i32 0 + ret i32 0, !dbg !13 } !llvm.dbg.cu = !{!2} @@ -22,3 +22,4 @@ define i32 @main() nounwind !dbg !6 { !10 = !DIFile(filename: "simple.c", directory: "/Users/manav/one/two") !11 = !{} !12 = !{i32 1, !"Debug Info Version", i32 3} +!13 = !DILocation(line: 10, scope: !6) diff --git a/llvm/test/DebugInfo/X86/debug-dead-local-var.ll b/llvm/test/DebugInfo/X86/debug-dead-local-var.ll index 9a2872aeb0a..ef6453647ad 100644 --- a/llvm/test/DebugInfo/X86/debug-dead-local-var.ll +++ b/llvm/test/DebugInfo/X86/debug-dead-local-var.ll @@ -11,9 +11,9 @@ ; return 1; ; } -; Check that we still have the structure type for X even though we're not -; going to emit a low/high_pc for foo. -; CHECK: DW_TAG_structure_type +; Check that we will not have the structure type for X as we are going to omit +; the function foo. +; CHECK-NOT: DW_TAG_structure_type ; Function Attrs: nounwind readnone uwtable define i32 @bar() #0 !dbg !4 { @@ -27,7 +27,7 @@ attributes #0 = { nounwind readnone uwtable "less-precise-fpmad"="false" "no-fra !llvm.module.flags = !{!18, !19} !llvm.ident = !{!20} -!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.5.0 (trunk 209255) (llvm/trunk 209253)", isOptimized: true, emissionKind: 1, file: !1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2) +!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.5.0 (trunk 209255) (llvm/trunk 209253)", isOptimized: true, emissionKind: 1, file: !1, enums: !2, retainedTypes: !22, subprograms: !3, globals: !2, imports: !2) !1 = !DIFile(filename: "debug-dead-local-var.c", directory: "/usr/local/google/home/echristo") !2 = !{} !3 = !{!4, !9} @@ -49,3 +49,4 @@ attributes #0 = { nounwind readnone uwtable "less-precise-fpmad"="false" "no-fra !19 = !{i32 2, !"Debug Info Version", i32 3} !20 = !{!"clang version 3.5.0 (trunk 209255) (llvm/trunk 209253)"} !21 = !DILocation(line: 13, scope: !4) +!22 = !{!14} diff --git a/llvm/test/DebugInfo/X86/gnu-public-names.ll b/llvm/test/DebugInfo/X86/gnu-public-names.ll index 584c879c064..45b6b272236 100644 --- a/llvm/test/DebugInfo/X86/gnu-public-names.ll +++ b/llvm/test/DebugInfo/X86/gnu-public-names.ll @@ -123,17 +123,6 @@ ; CHECK: DW_AT_linkage_name ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_name {{.*}} "global_namespace_function" - -; CHECK: DW_TAG_subprogram -; CHECK-NOT: DW_TAG -; CHECK: DW_AT_name {{.*}} "f3" -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: [[F3_Z:.*]]: DW_TAG_variable -; CHECK-NOT: DW_TAG -; CHECK: DW_AT_name {{.*}} "z" -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_location -; CHECK-NOT: {{DW_TAG|NULL}} ; CHECK: NULL ; CHECK-NOT: {{DW_TAG|NULL}} @@ -194,6 +183,18 @@ ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_name {{.*}} "global_function" +; CHECK: DW_TAG_subprogram +; CHECK-NOT: DW_TAG +; CHECK: DW_AT_name {{.*}} "f3" +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: [[F3_Z:.*]]: DW_TAG_variable +; CHECK-NOT: DW_TAG +; CHECK: DW_AT_name {{.*}} "z" +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_location +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: NULL + ; CHECK-LABEL: .debug_gnu_pubnames contents: ; CHECK-NEXT: length = {{.*}} version = 0x0002 unit_offset = 0x00000000 unit_size = {{.*}} ; CHECK-NEXT: Offset Linkage Kind Name @@ -201,12 +202,12 @@ ; CHECK-NEXT: [[NS]] EXTERNAL TYPE "ns" ; CHECK-NEXT: [[OUTER_ANON_C]] STATIC VARIABLE "outer::(anonymous namespace)::c" ; CHECK-NEXT: [[ANON_I]] STATIC VARIABLE "(anonymous namespace)::i" +; CHECK-NEXT: [[ANON]] EXTERNAL TYPE "(anonymous namespace)" ; GCC Doesn't put local statics in pubnames, but it seems not unreasonable and ; comes out naturally from LLVM's implementation, so I'm OK with it for now. If ; it's demonstrated that this is a major size concern or degrades debug info ; consumer behavior, feel free to change it. ; CHECK-NEXT: [[F3_Z]] STATIC VARIABLE "f3::z" -; CHECK-NEXT: [[ANON]] EXTERNAL TYPE "(anonymous namespace)" ; CHECK-NEXT: [[OUTER_ANON]] EXTERNAL TYPE "outer::(anonymous namespace)" ; CHECK-NEXT: [[ANON_INNER_B]] STATIC VARIABLE "(anonymous namespace)::inner::b" ; CHECK-NEXT: [[OUTER]] EXTERNAL TYPE "outer" diff --git a/llvm/test/DebugInfo/X86/lexical-block-file.ll b/llvm/test/DebugInfo/X86/lexical-block-file.ll new file mode 100644 index 00000000000..a03a01e9902 --- /dev/null +++ b/llvm/test/DebugInfo/X86/lexical-block-file.ll @@ -0,0 +1,89 @@ +; RUN: llc -mtriple=x86_64-unknown-linux-gnu -filetype=obj -O0 < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s + +;; This test checks that Inlined DILexicalBlockFile with local decl entry is +;; skipped and only one DW_TAG_lexical_block is generated. +;; +;; This test was generated by running following command: +;; clang -cc1 -O0 -debug-info-kind=limited -emit-llvm test.cpp +;; Where test.cpp +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;static __attribute__((always_inline)) int bar() { +;; { +;;#line 2 "test.h" +;; static int x = 0; +;; return x; +;; } +;;} +;;int foo() { +;; { +;; return bar(); +;; } +;;} +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; Abstract "bar" function +; CHECK: [[Offset_bar:0x[0-9abcdef]+]]: DW_TAG_subprogram +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_name {{.*}} "bar" +; CHECK: DW_AT_inline + +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: [[Offset_LB:0x[0-9abcdef]+]]: DW_TAG_lexical_block + +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: [[Offset_x:0x[0-9abcdef]+]]: DW_TAG_variable +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_name {{.*}} "x" + + +; CHECK: DW_TAG_subprogram +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_name {{.*}} "foo" +; CHECK-NOT: {{NULL}} + +;; Inlined "bar" function +; CHECK: DW_TAG_inlined_subroutine +; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[Offset_bar]]} + +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_TAG_lexical_block +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_abstract_origin {{.*}} {[[Offset_LB]]} + + +@bar.x = internal global i32 0, align 4 + +; Function Attrs: nounwind +define i32 @foo() #0 !dbg !4 { +entry: + %0 = load i32, i32* @bar.x, align 4, !dbg !16 + ret i32 %0, !dbg !19 +} + +attributes #0 = { nounwind } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!14} +!llvm.ident = !{!15} + +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.9.0 (trunk 263423)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, subprograms: !3, globals: !10) +!1 = !DIFile(filename: "test.c", directory: "/") +!2 = !{} +!3 = !{!4, !9} +!4 = distinct !DISubprogram(name: "foo", scope: !5, file: !5, line: 6, type: !6, isLocal: false, isDefinition: true, scopeLine: 6, isOptimized: false, variables: !2) +!5 = !DIFile(filename: "test.h", directory: "/") +!6 = !DISubroutineType(types: !7) +!7 = !{!8} +!8 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) +!9 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 2, type: !6, isLocal: true, isDefinition: true, scopeLine: 2, isOptimized: false, variables: !2) +!10 = !{!11} +!11 = !DIGlobalVariable(name: "x", scope: !12, file: !5, line: 2, type: !8, isLocal: true, isDefinition: true, variable: i32* @bar.x) +!12 = !DILexicalBlockFile(scope: !13, file: !5, discriminator: 0) +!13 = distinct !DILexicalBlock(scope: !9, file: !1, line: 3) +!14 = !{i32 2, !"Debug Info Version", i32 3} +!15 = !{!"clang version 3.9.0 (trunk 263423)"} +!16 = !DILocation(line: 3, scope: !12, inlinedAt: !17) +!17 = distinct !DILocation(line: 8, scope: !18) +!18 = distinct !DILexicalBlock(scope: !4, file: !5, line: 7) +!19 = !DILocation(line: 8, scope: !18) diff --git a/llvm/test/DebugInfo/X86/lexical-block-inline.ll b/llvm/test/DebugInfo/X86/lexical-block-inline.ll new file mode 100644 index 00000000000..caf51bc3a50 --- /dev/null +++ b/llvm/test/DebugInfo/X86/lexical-block-inline.ll @@ -0,0 +1,198 @@ +; RUN: llc -mtriple=x86_64-unknown-linux-gnu -filetype=obj -O0 < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s +; RUN: llc -mtriple=x86_64-unknown-linux-gnu -split-dwarf=Enable -filetype=obj -O0 < %s | llvm-dwarfdump -debug-dump=info.dwo - | FileCheck %s + +;; This test checks the following: +;; 1. Useless lexical block entry is not emitted. +;; 2. Function static variable, typedef, records (structure, class and union) +;; that are defined in lexical basic block are emitted as children to +;; these lexical blocks. +;; * For typedef and record check that both are emitted in lexical block +;; where they are declared and not in the one where they are used. +;; 3. "bar" function, which was inlined into "foo" function, is created as +;; abstract (with DW_AT_inline attribute). +;; All variables and types are defined in this abstract entry. +;; 4. "bar" function is created in "foo" function as inlined function +;; (with DW_TAG_inlined_subroutine attribute), and all its local variables +;; are created as concrete variables pointing to the abstract suitable entry +;; defined under abstract "bar" function. +;; 5. Lexical block entries created in the inline "bar" function entry have +;; "DW_AT_abstract_origin" attribute pointing to the equivalent abstract +;; lexical block entry. +;; +;; This test was generated by running following command: +;; clang -cc1 -O0 -g -emit-llvm foo.cpp -o - | opt -S -inline -sroa +;; Where foo.cpp +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;__inline int bar(int s) { +;; { +;; { +;; struct X { +;; int x; +;; }; +;; typedef int Y; +;; { +;; X a = { s }; +;; Y b(s); +;; static int c = 0; +;; return a.x + b + c++; +;; } +;; } +;; } +;;} +;; +;; +;;int foo(int i) { +;; return +;; bar(i); +;;} +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +; CHECK: [[Offset_bar:0x[0-9abcdef]+]]: DW_TAG_subprogram +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_name {{.*}} "bar" +; CHECK: DW_AT_inline +; CHECK-NOT: NULL +; CHECK: DW_TAG_lexical_block + +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: [[Offset_LB2:0x[0-9abcdef]+]]: DW_TAG_lexical_block + +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: [[Offset_a:0x[0-9abcdef]+]]: DW_TAG_variable +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_name {{.*}} "a" + +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: [[Offset_b:0x[0-9abcdef]+]]: DW_TAG_variable +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_name {{.*}} "b" + +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: [[Offset_c:0x[0-9abcdef]+]]: DW_TAG_variable +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_name {{.*}} "c" +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_location + +; CHECK-NOT: {{DW_TAG}} +; CHECK: NULL + +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: [[Offset_X:0x[0-9abcdef]+]]: DW_TAG_structure_type +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_name {{.*}} "X" +; CHECK: NULL + +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: [[Offset_Y:0x[0-9abcdef]+]]: DW_TAG_typedef +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_name {{.*}} "Y" + +; CHECK-NOT: {{DW_TAG}} +; CHECK: NULL + + +; CHECK: DW_TAG_subprogram +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_name {{.*}} "foo" +; CHECK-NOT: {{NULL}} +; CHECK: DW_TAG_inlined_subroutine +; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[Offset_bar]]} + +; CHECK-NOT: {{NULL}} +; CHECK: DW_TAG_lexical_block + +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_TAG_lexical_block +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_abstract_origin {{.*}} {[[Offset_LB2]]} + +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_TAG_variable +; CHECK-NEXT: DW_AT_location +; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[Offset_a]]} + +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_TAG_variable +; CHECK-NEXT: DW_AT_location +; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[Offset_b]]} + +; CHECK-NOT: {{DW_TAG}} +; CHECK: NULL + +; CHECK-NOT: {{DW_TAG}} +; CHECK: NULL + +%struct.X = type { i32 } + +$_ZZ3bariE1c = comdat any + +@_ZZ3bariE1c = linkonce_odr global i32 0, comdat, align 4 + +; Function Attrs: nounwind +define i32 @_Z3fooi(i32 %i) #0 !dbg !15 { +entry: + call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !22, metadata !23), !dbg !24 + call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !25, metadata !23), !dbg !26 + call void @llvm.dbg.declare(metadata %struct.X* undef, metadata !28, metadata !23), !dbg !29 + call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !28, metadata !23), !dbg !29 + call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !30, metadata !23), !dbg !31 + %add.i = add nsw i32 %i, %i, !dbg !32 + %0 = load i32, i32* @_ZZ3bariE1c, align 4, !dbg !32 + %inc.i = add nsw i32 %0, 1, !dbg !32 + store i32 %inc.i, i32* @_ZZ3bariE1c, align 4, !dbg !32 + %add2.i = add nsw i32 %add.i, %0, !dbg !32 + ret i32 %add2.i, !dbg !33 +} + +; Function Attrs: nounwind readnone +declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 + +; Function Attrs: nounwind readnone +declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1 + +attributes #0 = { nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "target-features"="+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { nounwind readnone } + +!llvm.dbg.cu = !{!0, !34} +!llvm.module.flags = !{!19, !20} +!llvm.ident = !{!21} + +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 242994) (llvm/trunk 242995)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !3, subprograms: !14, globals: !16) +!1 = !DIFile(filename: "foo.cpp", directory: "/") +!2 = !{} +!3 = !{!4, !13} +!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "X", scope: !5, file: !1, line: 4, size: 32, align: 32, elements: !11, identifier: "_ZTSZ3bariE1X") +!5 = distinct !DILexicalBlock(scope: !6, file: !1, line: 3) +!6 = distinct !DILexicalBlock(scope: !7, file: !1, line: 2) +!7 = distinct !DISubprogram(name: "bar", linkageName: "_Z3bari", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, variables: !2) +!8 = !DISubroutineType(types: !9) +!9 = !{!10, !10} +!10 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) +!11 = !{!12} +!12 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !"_ZTSZ3bariE1X", file: !1, line: 5, baseType: !10, size: 32, align: 32) +!13 = !DIDerivedType(tag: DW_TAG_typedef, name: "Y", scope: !5, file: !1, line: 7, baseType: !10) +!14 = !{!15, !7} +!15 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooi", scope: !1, file: !1, line: 19, type: !8, isLocal: false, isDefinition: true, scopeLine: 19, flags: DIFlagPrototyped, isOptimized: false, variables: !2) +!16 = !{!17} +!17 = !DIGlobalVariable(name: "c", scope: !18, file: !1, line: 11, type: !10, isLocal: false, isDefinition: true, variable: i32* @_ZZ3bariE1c) +!18 = distinct !DILexicalBlock(scope: !5, file: !1, line: 8) +!19 = !{i32 2, !"Dwarf Version", i32 4} +!20 = !{i32 2, !"Debug Info Version", i32 3} +!21 = !{!"clang version 3.8.0 (trunk 242994) (llvm/trunk 242995)"} +!22 = !DILocalVariable(name: "i", arg: 1, scope: !15, file: !1, line: 19, type: !10) +!23 = !DIExpression() +!24 = !DILocation(line: 19, scope: !15) +!25 = !DILocalVariable(name: "s", arg: 1, scope: !7, file: !1, line: 1, type: !10) +!26 = !DILocation(line: 1, scope: !7, inlinedAt: !27) +!27 = distinct !DILocation(line: 21, scope: !15) +!28 = !DILocalVariable(name: "a", scope: !18, file: !1, line: 9, type: !"_ZTSZ3bariE1X") +!29 = !DILocation(line: 9, scope: !18, inlinedAt: !27) +!30 = !DILocalVariable(name: "b", scope: !18, file: !1, line: 10, type: !13) +!31 = !DILocation(line: 10, scope: !18, inlinedAt: !27) +!32 = !DILocation(line: 12, scope: !18, inlinedAt: !27) +!33 = !DILocation(line: 20, scope: !15) + +; This line is manually added to check that the test does not crash when having +; more than one compile unit! +!34 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 242994) (llvm/trunk 242995)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !2, subprograms: !2, globals: !2) diff --git a/llvm/test/DebugInfo/X86/lexical-block.ll b/llvm/test/DebugInfo/X86/lexical-block.ll new file mode 100644 index 00000000000..5f8ed349e13 --- /dev/null +++ b/llvm/test/DebugInfo/X86/lexical-block.ll @@ -0,0 +1,131 @@ +; RUN: llc -mtriple=x86_64-unknown-linux-gnu -filetype=obj -O0 < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s + +;; This test checks the following: +;; 1. Useless lexical block entry is not emitted. +;; 2. Function static variable, typedef, records (structure, class and union) +;; that are defined in lexical basic block are emitted as children to +;; these lexical blocks. +;; * For typedef and record check that both are emitted in lexical block +;; where they are declared and not in the one where they are used. +;; +;; This test was generated by running following command: +;; clang -cc1 -O0 -g -emit-llvm foo.cpp +;; Where foo.cpp +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;int foo(void) { +;; { +;; { +;; struct X { +;; int x; +;; }; +;; typedef int Y; +;; { +;; X a; +;; Y b; +;; static int c; +;; return a.x + b + c; +;; } +;; } +;; } +;;} +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +; CHECK: DW_TAG_subprogram +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_name {{.*}} "foo" +; CHECK-NOT: NULL +; CHECK: DW_TAG_lexical_block + +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_TAG_lexical_block + +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_TAG_variable +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_name {{.*}} "a" + +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_TAG_variable +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_name {{.*}} "b" + +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_TAG_variable +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_name {{.*}} "c" + +; CHECK-NOT: {{DW_TAG}} +; CHECK: NULL + +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_TAG_structure_type +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_name {{.*}} "X" +; CHECK: NULL + +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_TAG_typedef +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_name {{.*}} "Y" + +; CHECK-NOT: {{DW_TAG}} +; CHECK: NULL + +%struct.X = type { i32 } + +@_ZZ3foovE1c = internal global i32 0, align 4 + +; Function Attrs: nounwind +define i32 @_Z3foov() #0 !dbg !7 { +entry: + %a = alloca %struct.X, align 4 + %b = alloca i32, align 4 + call void @llvm.dbg.declare(metadata %struct.X* %a, metadata !21, metadata !22), !dbg !23 + call void @llvm.dbg.declare(metadata i32* %b, metadata !24, metadata !22), !dbg !25 + %x = getelementptr inbounds %struct.X, %struct.X* %a, i32 0, i32 0, !dbg !26 + %0 = load i32, i32* %x, align 4, !dbg !26 + %1 = load i32, i32* %b, align 4, !dbg !26 + %add = add nsw i32 %0, %1, !dbg !26 + %2 = load i32, i32* @_ZZ3foovE1c, align 4, !dbg !26 + %add1 = add nsw i32 %add, %2, !dbg !26 + ret i32 %add1, !dbg !26 +} + +; Function Attrs: nounwind readnone +declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 + +attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "target-features"="+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { nounwind readnone } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!18, !19} +!llvm.ident = !{!20} + +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.7.0 (trunk 237245)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !3, subprograms: !14, globals: !15, imports: !2) +!1 = !DIFile(filename: "foo.cpp", directory: "/") +!2 = !{} +!3 = !{!4, !13} +!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "X", scope: !5, file: !1, line: 4, size: 32, align: 32, elements: !11) +!5 = distinct !DILexicalBlock(scope: !6, file: !1, line: 3) +!6 = distinct !DILexicalBlock(scope: !7, file: !1, line: 2) +!7 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, variables: !2) +!8 = !DISubroutineType(types: !9) +!9 = !{!10} +!10 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) +!11 = !{!12} +!12 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !4, file: !1, line: 5, baseType: !10, size: 32, align: 32) +!13 = !DIDerivedType(tag: DW_TAG_typedef, name: "Y", scope: !5, file: !1, line: 7, baseType: !10) +!14 = !{!7} +!15 = !{!16} +!16 = !DIGlobalVariable(name: "c", scope: !17, file: !1, line: 11, type: !10, isLocal: true, isDefinition: true, variable: i32* @_ZZ3foovE1c) +!17 = distinct !DILexicalBlock(scope: !5, file: !1, line: 8) +!18 = !{i32 2, !"Dwarf Version", i32 4} +!19 = !{i32 2, !"Debug Info Version", i32 3} +!20 = !{!"clang version 3.7.0 (trunk 237245)"} +!21 = !DILocalVariable(name: "a", scope: !17, file: !1, line: 9, type: !4) +!22 = !DIExpression() +!23 = !DILocation(line: 9, scope: !17) +!24 = !DILocalVariable(name: "b", scope: !17, file: !1, line: 10, type: !13) +!25 = !DILocation(line: 10, scope: !17) +!26 = !DILocation(line: 12, scope: !17) diff --git a/llvm/test/DebugInfo/X86/subprogram-inline.ll b/llvm/test/DebugInfo/X86/subprogram-inline.ll new file mode 100644 index 00000000000..1442a98f489 --- /dev/null +++ b/llvm/test/DebugInfo/X86/subprogram-inline.ll @@ -0,0 +1,169 @@ +; RUN: llc -mtriple=x86_64-unknown-linux-gnu -filetype=obj -O0 < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s +; RUN: llc -mtriple=x86_64-unknown-linux-gnu -split-dwarf=Enable -filetype=obj -O0 < %s | llvm-dwarfdump -debug-dump=info.dwo - | FileCheck %s + +;; This test checks the following: +;; 2. Function static variable, typedef, records (structure, class and union) +;; that are defined in lexical function scope are emitted as children to +;; the function scope, directly. +;; 3. "bar" function, which was inlined into "foo" function, is created as +;; abstract (with DW_AT_inline attribute). +;; All variables and types are defined in this abstract entry. +;; 4. "bar" function is created in "foo" function as inlined function +;; (with DW_TAG_inlined_subroutine attribute), and all its local variables +;; are created as concrete variables pointing to the abstract suitable entry +;; defined under abstract "bar" function. +;; +;; This test was generated by running following command: +;; clang -cc1 -O0 -g -emit-llvm foo.cpp -o - | opt -S -inline -sroa +;; Where foo.cpp +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;__inline int bar(int s) { +;; +;; +;; struct X { +;; int x; +;; }; +;; typedef int Y; +;; +;; X a = { s }; +;; Y b(s); +;; static int c = 0; +;; return a.x + b + c++; +;; +;; +;; +;;} +;; +;; +;;int foo(int i) { +;; return +;; bar(i); +;;} +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +; CHECK: [[Offset_bar:0x[0-9abcdef]+]]: DW_TAG_subprogram +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_name {{.*}} "bar" +; CHECK: DW_AT_inline +; CHECK-NOT: NULL + +; CHECK: [[Offset_a:0x[0-9abcdef]+]]: DW_TAG_variable +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_name {{.*}} "a" + +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: [[Offset_b:0x[0-9abcdef]+]]: DW_TAG_variable +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_name {{.*}} "b" + +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: [[Offset_c:0x[0-9abcdef]+]]: DW_TAG_variable +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_name {{.*}} "c" +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_location + +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: [[Offset_X:0x[0-9abcdef]+]]: DW_TAG_structure_type +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_name {{.*}} "X" +; CHECK: NULL + +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: [[Offset_Y:0x[0-9abcdef]+]]: DW_TAG_typedef +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_name {{.*}} "Y" + +; CHECK-NOT: {{DW_TAG}} +; CHECK: NULL + + +; CHECK: DW_TAG_subprogram +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_name {{.*}} "foo" +; CHECK-NOT: {{NULL}} +; CHECK: DW_TAG_inlined_subroutine +; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[Offset_bar]]} + +; CHECK-NOT: {{NULL}} +; CHECK: DW_TAG_variable +; CHECK-NEXT: DW_AT_location +; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[Offset_a]]} + +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_TAG_variable +; CHECK-NEXT: DW_AT_location +; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[Offset_b]]} + +; CHECK-NOT: {{DW_TAG}} +; CHECK: NULL + +%struct.X = type { i32 } + +$_ZZ3bariE1c = comdat any + +@_ZZ3bariE1c = linkonce_odr global i32 0, comdat, align 4 + +; Function Attrs: nounwind +define i32 @_Z3fooi(i32 %i) #0 !dbg !13 { +entry: + call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !18, metadata !19), !dbg !20 + call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !21, metadata !19), !dbg !22 + call void @llvm.dbg.declare(metadata %struct.X* undef, metadata !24, metadata !19), !dbg !25 + call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !24, metadata !19), !dbg !25 + call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !26, metadata !19), !dbg !27 + %add.i = add nsw i32 %i, %i, !dbg !28 + %0 = load i32, i32* @_ZZ3bariE1c, align 4, !dbg !28 + %inc.i = add nsw i32 %0, 1, !dbg !28 + store i32 %inc.i, i32* @_ZZ3bariE1c, align 4, !dbg !28 + %add2.i = add nsw i32 %add.i, %0, !dbg !28 + ret i32 %add2.i, !dbg !29 +} + +; Function Attrs: nounwind readnone +declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 + +; Function Attrs: nounwind readnone +declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1 + +attributes #0 = { nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-features"="+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { nounwind readnone } + +!llvm.dbg.cu = !{!0, !30} +!llvm.module.flags = !{!16} +!llvm.ident = !{!17} + +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 256818)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !3, subprograms: !12, globals: !14) +!1 = !DIFile(filename: "foo.cpp", directory: "/") +!2 = !{} +!3 = !{!4, !11} +!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "X", scope: !5, file: !1, line: 4, size: 32, align: 32, elements: !9, identifier: "_ZTSZ3bariE1X") +!5 = distinct !DISubprogram(name: "bar", linkageName: "_Z3bari", scope: !1, file: !1, line: 1, type: !6, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, variables: !2) +!6 = !DISubroutineType(types: !7) +!7 = !{!8, !8} +!8 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) +!9 = !{!10} +!10 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !"_ZTSZ3bariE1X", file: !1, line: 5, baseType: !8, size: 32, align: 32) +!11 = !DIDerivedType(tag: DW_TAG_typedef, name: "Y", scope: !5, file: !1, line: 7, baseType: !8) +!12 = !{!13, !5} +!13 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooi", scope: !1, file: !1, line: 19, type: !6, isLocal: false, isDefinition: true, scopeLine: 19, flags: DIFlagPrototyped, isOptimized: false, variables: !2) +!14 = !{!15} +!15 = !DIGlobalVariable(name: "c", scope: !5, file: !1, line: 11, type: !8, isLocal: false, isDefinition: true, variable: i32* @_ZZ3bariE1c) +!16 = !{i32 2, !"Debug Info Version", i32 3} +!17 = !{!"clang version 3.8.0 (trunk 256818)"} +!18 = !DILocalVariable(name: "i", arg: 1, scope: !13, file: !1, line: 19, type: !8) +!19 = !DIExpression() +!20 = !DILocation(line: 19, scope: !13) +!21 = !DILocalVariable(name: "s", arg: 1, scope: !5, file: !1, line: 1, type: !8) +!22 = !DILocation(line: 1, scope: !5, inlinedAt: !23) +!23 = distinct !DILocation(line: 21, scope: !13) +!24 = !DILocalVariable(name: "a", scope: !5, file: !1, line: 9, type: !"_ZTSZ3bariE1X") +!25 = !DILocation(line: 9, scope: !5, inlinedAt: !23) +!26 = !DILocalVariable(name: "b", scope: !5, file: !1, line: 10, type: !11) +!27 = !DILocation(line: 10, scope: !5, inlinedAt: !23) +!28 = !DILocation(line: 12, scope: !5, inlinedAt: !23) +!29 = !DILocation(line: 20, scope: !13) + +; This line is manually added to check that the test does not crash when having +; more than one compile unit! +!30 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 242994) (llvm/trunk 242995)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !2, subprograms: !2, globals: !2) |