Amjad Aboud | ab0378b | 2016-03-14 12:03:20 +0000 | [diff] [blame] | 1 | ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -filetype=obj -O0 < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s |
| 2 | ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -split-dwarf=Enable -filetype=obj -O0 < %s | llvm-dwarfdump -debug-dump=info.dwo - | FileCheck %s |
| 3 | |
| 4 | ;; This test checks the following: |
| 5 | ;; 2. Function static variable, typedef, records (structure, class and union) |
| 6 | ;; that are defined in lexical function scope are emitted as children to |
| 7 | ;; the function scope, directly. |
| 8 | ;; 3. "bar" function, which was inlined into "foo" function, is created as |
| 9 | ;; abstract (with DW_AT_inline attribute). |
| 10 | ;; All variables and types are defined in this abstract entry. |
| 11 | ;; 4. "bar" function is created in "foo" function as inlined function |
| 12 | ;; (with DW_TAG_inlined_subroutine attribute), and all its local variables |
| 13 | ;; are created as concrete variables pointing to the abstract suitable entry |
| 14 | ;; defined under abstract "bar" function. |
| 15 | ;; |
| 16 | ;; This test was generated by running following command: |
| 17 | ;; clang -cc1 -O0 -g -emit-llvm foo.cpp -o - | opt -S -inline -sroa |
| 18 | ;; Where foo.cpp |
| 19 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 20 | ;;__inline int bar(int s) { |
| 21 | ;; |
| 22 | ;; |
| 23 | ;; struct X { |
| 24 | ;; int x; |
| 25 | ;; }; |
| 26 | ;; typedef int Y; |
| 27 | ;; |
| 28 | ;; X a = { s }; |
| 29 | ;; Y b(s); |
| 30 | ;; static int c = 0; |
| 31 | ;; return a.x + b + c++; |
| 32 | ;; |
| 33 | ;; |
| 34 | ;; |
| 35 | ;;} |
| 36 | ;; |
| 37 | ;; |
| 38 | ;;int foo(int i) { |
| 39 | ;; return |
| 40 | ;; bar(i); |
| 41 | ;;} |
| 42 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 43 | |
| 44 | ; CHECK: [[Offset_bar:0x[0-9abcdef]+]]: DW_TAG_subprogram |
| 45 | ; CHECK-NOT: {{DW_TAG|NULL}} |
| 46 | ; CHECK: DW_AT_name {{.*}} "bar" |
| 47 | ; CHECK: DW_AT_inline |
| 48 | ; CHECK-NOT: NULL |
| 49 | |
| 50 | ; CHECK: [[Offset_a:0x[0-9abcdef]+]]: DW_TAG_variable |
| 51 | ; CHECK-NOT: {{DW_TAG|NULL}} |
| 52 | ; CHECK: DW_AT_name {{.*}} "a" |
| 53 | |
| 54 | ; CHECK-NOT: {{DW_TAG|NULL}} |
| 55 | ; CHECK: [[Offset_b:0x[0-9abcdef]+]]: DW_TAG_variable |
| 56 | ; CHECK-NOT: {{DW_TAG|NULL}} |
| 57 | ; CHECK: DW_AT_name {{.*}} "b" |
| 58 | |
| 59 | ; CHECK-NOT: {{DW_TAG|NULL}} |
| 60 | ; CHECK: [[Offset_c:0x[0-9abcdef]+]]: DW_TAG_variable |
| 61 | ; CHECK-NOT: {{DW_TAG|NULL}} |
| 62 | ; CHECK: DW_AT_name {{.*}} "c" |
| 63 | ; CHECK-NOT: {{DW_TAG|NULL}} |
| 64 | ; CHECK: DW_AT_location |
| 65 | |
| 66 | ; CHECK-NOT: {{DW_TAG|NULL}} |
| 67 | ; CHECK: [[Offset_X:0x[0-9abcdef]+]]: DW_TAG_structure_type |
| 68 | ; CHECK-NOT: {{DW_TAG|NULL}} |
| 69 | ; CHECK: DW_AT_name {{.*}} "X" |
| 70 | ; CHECK: NULL |
| 71 | |
| 72 | ; CHECK-NOT: {{DW_TAG|NULL}} |
| 73 | ; CHECK: [[Offset_Y:0x[0-9abcdef]+]]: DW_TAG_typedef |
| 74 | ; CHECK-NOT: {{DW_TAG|NULL}} |
| 75 | ; CHECK: DW_AT_name {{.*}} "Y" |
| 76 | |
| 77 | ; CHECK-NOT: {{DW_TAG}} |
| 78 | ; CHECK: NULL |
| 79 | |
| 80 | |
| 81 | ; CHECK: DW_TAG_subprogram |
| 82 | ; CHECK-NOT: {{DW_TAG|NULL}} |
| 83 | ; CHECK: DW_AT_name {{.*}} "foo" |
| 84 | ; CHECK-NOT: {{NULL}} |
| 85 | ; CHECK: DW_TAG_inlined_subroutine |
| 86 | ; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[Offset_bar]]} |
| 87 | |
| 88 | ; CHECK-NOT: {{NULL}} |
| 89 | ; CHECK: DW_TAG_variable |
| 90 | ; CHECK-NEXT: DW_AT_location |
| 91 | ; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[Offset_a]]} |
| 92 | |
| 93 | ; CHECK-NOT: {{DW_TAG|NULL}} |
| 94 | ; CHECK: DW_TAG_variable |
| 95 | ; CHECK-NEXT: DW_AT_location |
| 96 | ; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[Offset_b]]} |
| 97 | |
| 98 | ; CHECK-NOT: {{DW_TAG}} |
| 99 | ; CHECK: NULL |
| 100 | |
| 101 | %struct.X = type { i32 } |
| 102 | |
| 103 | $_ZZ3bariE1c = comdat any |
| 104 | |
| 105 | @_ZZ3bariE1c = linkonce_odr global i32 0, comdat, align 4 |
| 106 | |
| 107 | ; Function Attrs: nounwind |
| 108 | define i32 @_Z3fooi(i32 %i) #0 !dbg !13 { |
| 109 | entry: |
| 110 | call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !18, metadata !19), !dbg !20 |
| 111 | call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !21, metadata !19), !dbg !22 |
| 112 | call void @llvm.dbg.declare(metadata %struct.X* undef, metadata !24, metadata !19), !dbg !25 |
| 113 | call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !24, metadata !19), !dbg !25 |
| 114 | call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !26, metadata !19), !dbg !27 |
| 115 | %add.i = add nsw i32 %i, %i, !dbg !28 |
| 116 | %0 = load i32, i32* @_ZZ3bariE1c, align 4, !dbg !28 |
| 117 | %inc.i = add nsw i32 %0, 1, !dbg !28 |
| 118 | store i32 %inc.i, i32* @_ZZ3bariE1c, align 4, !dbg !28 |
| 119 | %add2.i = add nsw i32 %add.i, %0, !dbg !28 |
| 120 | ret i32 %add2.i, !dbg !29 |
| 121 | } |
| 122 | |
| 123 | ; Function Attrs: nounwind readnone |
| 124 | declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 |
| 125 | |
| 126 | ; Function Attrs: nounwind readnone |
| 127 | declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1 |
| 128 | |
| 129 | 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" } |
| 130 | attributes #1 = { nounwind readnone } |
| 131 | |
| 132 | !llvm.dbg.cu = !{!0, !30} |
| 133 | !llvm.module.flags = !{!16} |
| 134 | !llvm.ident = !{!17} |
| 135 | |
| 136 | !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) |
| 137 | !1 = !DIFile(filename: "foo.cpp", directory: "/") |
| 138 | !2 = !{} |
| 139 | !3 = !{!4, !11} |
| 140 | !4 = !DICompositeType(tag: DW_TAG_structure_type, name: "X", scope: !5, file: !1, line: 4, size: 32, align: 32, elements: !9, identifier: "_ZTSZ3bariE1X") |
| 141 | !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) |
| 142 | !6 = !DISubroutineType(types: !7) |
| 143 | !7 = !{!8, !8} |
| 144 | !8 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) |
| 145 | !9 = !{!10} |
| 146 | !10 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !"_ZTSZ3bariE1X", file: !1, line: 5, baseType: !8, size: 32, align: 32) |
| 147 | !11 = !DIDerivedType(tag: DW_TAG_typedef, name: "Y", scope: !5, file: !1, line: 7, baseType: !8) |
| 148 | !12 = !{!13, !5} |
| 149 | !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) |
| 150 | !14 = !{!15} |
| 151 | !15 = !DIGlobalVariable(name: "c", scope: !5, file: !1, line: 11, type: !8, isLocal: false, isDefinition: true, variable: i32* @_ZZ3bariE1c) |
| 152 | !16 = !{i32 2, !"Debug Info Version", i32 3} |
| 153 | !17 = !{!"clang version 3.8.0 (trunk 256818)"} |
| 154 | !18 = !DILocalVariable(name: "i", arg: 1, scope: !13, file: !1, line: 19, type: !8) |
| 155 | !19 = !DIExpression() |
| 156 | !20 = !DILocation(line: 19, scope: !13) |
| 157 | !21 = !DILocalVariable(name: "s", arg: 1, scope: !5, file: !1, line: 1, type: !8) |
| 158 | !22 = !DILocation(line: 1, scope: !5, inlinedAt: !23) |
| 159 | !23 = distinct !DILocation(line: 21, scope: !13) |
| 160 | !24 = !DILocalVariable(name: "a", scope: !5, file: !1, line: 9, type: !"_ZTSZ3bariE1X") |
| 161 | !25 = !DILocation(line: 9, scope: !5, inlinedAt: !23) |
| 162 | !26 = !DILocalVariable(name: "b", scope: !5, file: !1, line: 10, type: !11) |
| 163 | !27 = !DILocation(line: 10, scope: !5, inlinedAt: !23) |
| 164 | !28 = !DILocation(line: 12, scope: !5, inlinedAt: !23) |
| 165 | !29 = !DILocation(line: 20, scope: !13) |
| 166 | |
| 167 | ; This line is manually added to check that the test does not crash when having |
| 168 | ; more than one compile unit! |
| 169 | !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) |