David Blaikie | 19a8b90 | 2014-06-04 01:30:59 +0000 | [diff] [blame] | 1 | ; REQUIRES: object-emission |
| 2 | |
| 3 | ; RUN: %llc_dwarf -O0 -filetype=obj < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s |
| 4 | |
David Blaikie | 484610c | 2014-06-04 17:05:23 +0000 | [diff] [blame] | 5 | ; The formal parameter 'b' for Function 'x' when inlined within 'a' is lost on |
| 6 | ; mips and powerpc64 (and on x86_64 at at least -O2). Presumably this is a |
| 7 | ; SelectionDAG issue (do mips/powerpc64 use FastISel?). |
James Y Knight | 0cab80c | 2015-08-07 23:01:16 +0000 | [diff] [blame] | 8 | ; XFAIL: mips, powerpc64, s390x, sparc |
David Blaikie | 484610c | 2014-06-04 17:05:23 +0000 | [diff] [blame] | 9 | |
David Blaikie | 19a8b90 | 2014-06-04 01:30:59 +0000 | [diff] [blame] | 10 | ; Build from the following source with clang -O2. |
| 11 | |
| 12 | ; The important details are that 'x's abstract definition is first built during |
| 13 | ; the definition of 'b', where the parameter to 'x' is constant and so 'x's 's' |
| 14 | ; variable is optimized away. No abstract definition DIE for 's' is constructed. |
| 15 | ; Then, during 'a' emission, the abstract DbgVariable for 's' is created, but |
| 16 | ; the abstract DIE isn't (since the abstract definition for 'b' is already |
| 17 | ; built). This results in 's' inlined in 'a' being emitted with its name, line, |
| 18 | ; file there, rather than referencing an abstract definition. |
| 19 | |
| 20 | ; extern int t; |
| 21 | ; |
| 22 | ; void f(int); |
| 23 | ; |
| 24 | ; inline void x(bool b) { |
| 25 | ; if (b) { |
| 26 | ; int s = t; |
| 27 | ; f(s); |
| 28 | ; } |
| 29 | ; f(0); |
| 30 | ; } |
| 31 | ; |
| 32 | ; void b() { |
| 33 | ; x(false); |
| 34 | ; } |
| 35 | ; |
| 36 | ; void a(bool u) { |
| 37 | ; x(u); |
| 38 | ; } |
| 39 | |
Paul Robinson | 78046b4 | 2015-08-11 21:36:45 +0000 | [diff] [blame^] | 40 | ; CHECK: [[X_DECL:.*]]: DW_TAG_subprogram |
David Blaikie | 19a8b90 | 2014-06-04 01:30:59 +0000 | [diff] [blame] | 41 | ; CHECK-NOT: DW_TAG |
| 42 | ; CHECK: DW_AT_name {{.*}} "x" |
| 43 | ; CHECK-NOT: {{DW_TAG|NULL}} |
Frederic Riss | d4de180 | 2014-10-10 15:51:02 +0000 | [diff] [blame] | 44 | ; CHECK: DW_TAG_formal_parameter |
David Blaikie | 19a8b90 | 2014-06-04 01:30:59 +0000 | [diff] [blame] | 45 | ; CHECK-NOT: DW_TAG |
| 46 | ; CHECK: DW_AT_name {{.*}} "b" |
David Blaikie | 36408e7 | 2014-06-04 23:50:52 +0000 | [diff] [blame] | 47 | ; CHECK-NOT: {{DW_TAG|NULL}} |
David Blaikie | 36408e7 | 2014-06-04 23:50:52 +0000 | [diff] [blame] | 48 | ; CHECK: DW_TAG_lexical_block |
| 49 | ; CHECK-NOT: {{DW_TAG|NULL}} |
Frederic Riss | d4de180 | 2014-10-10 15:51:02 +0000 | [diff] [blame] | 50 | ; CHECK: DW_TAG_variable |
David Blaikie | 36408e7 | 2014-06-04 23:50:52 +0000 | [diff] [blame] | 51 | ; CHECK-NOT: DW_TAG |
| 52 | ; CHECK: DW_AT_name {{.*}} "s" |
David Blaikie | 19a8b90 | 2014-06-04 01:30:59 +0000 | [diff] [blame] | 53 | |
| 54 | ; CHECK: DW_TAG_subprogram |
| 55 | ; CHECK-NOT: DW_TAG |
| 56 | ; CHECK: DW_AT_name {{.*}} "b" |
| 57 | ; CHECK-NOT: {{DW_TAG|NULL}} |
| 58 | ; CHECK: DW_TAG_inlined_subroutine |
| 59 | ; CHECK-NOT: DW_TAG |
Paul Robinson | 78046b4 | 2015-08-11 21:36:45 +0000 | [diff] [blame^] | 60 | ; CHECK: DW_AT_abstract_origin {{.*}} {[[X_DECL]]} |
David Blaikie | 19a8b90 | 2014-06-04 01:30:59 +0000 | [diff] [blame] | 61 | ; CHECK-NOT: {{DW_TAG|NULL}} |
| 62 | ; CHECK: DW_TAG_formal_parameter |
| 63 | ; CHECK-NOT: DW_TAG |
Frederic Riss | d4de180 | 2014-10-10 15:51:02 +0000 | [diff] [blame] | 64 | ; CHECK: DW_AT_abstract_origin {{.*}} "b" |
David Blaikie | 19a8b90 | 2014-06-04 01:30:59 +0000 | [diff] [blame] | 65 | ; Notice 'x's local variable 's' is missing. Not necessarily a bug here, |
| 66 | ; since it's been optimized entirely away and it should be described in |
| 67 | ; abstract subprogram. |
| 68 | ; CHECK-NOT: DW_TAG |
| 69 | ; CHECK: NULL |
| 70 | ; CHECK-NOT: DW_TAG |
| 71 | ; CHECK: NULL |
| 72 | |
| 73 | ; CHECK: DW_TAG_subprogram |
| 74 | ; CHECK-NOT: DW_TAG |
| 75 | ; CHECK: DW_AT_name {{.*}} "a" |
| 76 | ; CHECK-NOT: {{DW_TAG|NULL}} |
| 77 | ; CHECK: DW_TAG_formal_parameter |
| 78 | ; CHECK-NOT: {{DW_TAG|NULL}} |
| 79 | ; CHECK: DW_TAG_inlined_subroutine |
| 80 | ; CHECK-NOT: DW_TAG |
Paul Robinson | 78046b4 | 2015-08-11 21:36:45 +0000 | [diff] [blame^] | 81 | ; CHECK: DW_AT_abstract_origin {{.*}} {[[X_DECL]]} |
David Blaikie | 19a8b90 | 2014-06-04 01:30:59 +0000 | [diff] [blame] | 82 | ; CHECK-NOT: {{DW_TAG|NULL}} |
David Blaikie | 36408e7 | 2014-06-04 23:50:52 +0000 | [diff] [blame] | 83 | ; FIXME: This formal parameter goes missing at least at -O2 (& on |
| 84 | ; mips/powerpc), maybe before that. Perhaps SelectionDAG is to blame (and |
| 85 | ; fastisel succeeds). |
David Blaikie | 19a8b90 | 2014-06-04 01:30:59 +0000 | [diff] [blame] | 86 | ; CHECK: DW_TAG_formal_parameter |
| 87 | ; CHECK-NOT: DW_TAG |
Frederic Riss | d4de180 | 2014-10-10 15:51:02 +0000 | [diff] [blame] | 88 | ; CHECK: DW_AT_abstract_origin {{.*}} "b" |
David Blaikie | 19a8b90 | 2014-06-04 01:30:59 +0000 | [diff] [blame] | 89 | |
David Blaikie | 19a8b90 | 2014-06-04 01:30:59 +0000 | [diff] [blame] | 90 | ; CHECK-NOT: {{DW_TAG|NULL}} |
| 91 | ; CHECK: DW_TAG_lexical_block |
| 92 | ; CHECK-NOT: {{DW_TAG|NULL}} |
David Blaikie | 6a150a8 | 2014-08-31 21:26:22 +0000 | [diff] [blame] | 93 | ; CHECK: DW_TAG_variable |
David Blaikie | 19a8b90 | 2014-06-04 01:30:59 +0000 | [diff] [blame] | 94 | ; CHECK-NOT: DW_TAG |
Frederic Riss | d4de180 | 2014-10-10 15:51:02 +0000 | [diff] [blame] | 95 | ; CHECK: DW_AT_abstract_origin {{.*}} "s" |
David Blaikie | 19a8b90 | 2014-06-04 01:30:59 +0000 | [diff] [blame] | 96 | |
| 97 | @t = external global i32 |
| 98 | |
| 99 | ; Function Attrs: uwtable |
| 100 | define void @_Z1bv() #0 { |
| 101 | entry: |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 102 | tail call void @llvm.dbg.value(metadata i1 false, i64 0, metadata !25, metadata !DIExpression()), !dbg !27 |
David Blaikie | 19a8b90 | 2014-06-04 01:30:59 +0000 | [diff] [blame] | 103 | tail call void @_Z1fi(i32 0), !dbg !28 |
| 104 | ret void, !dbg !29 |
| 105 | } |
| 106 | |
| 107 | ; Function Attrs: uwtable |
| 108 | define void @_Z1ab(i1 zeroext %u) #0 { |
| 109 | entry: |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 110 | tail call void @llvm.dbg.value(metadata i1 %u, i64 0, metadata !13, metadata !DIExpression()), !dbg !30 |
| 111 | tail call void @llvm.dbg.value(metadata i1 %u, i64 0, metadata !31, metadata !DIExpression()), !dbg !33 |
David Blaikie | 19a8b90 | 2014-06-04 01:30:59 +0000 | [diff] [blame] | 112 | br i1 %u, label %if.then.i, label %_Z1xb.exit, !dbg !34 |
| 113 | |
| 114 | if.then.i: ; preds = %entry |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 115 | %0 = load i32, i32* @t, align 4, !dbg !35, !tbaa !36 |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 116 | tail call void @llvm.dbg.value(metadata i32 %0, i64 0, metadata !40, metadata !DIExpression()), !dbg !35 |
David Blaikie | 19a8b90 | 2014-06-04 01:30:59 +0000 | [diff] [blame] | 117 | tail call void @_Z1fi(i32 %0), !dbg !41 |
| 118 | br label %_Z1xb.exit, !dbg !42 |
| 119 | |
| 120 | _Z1xb.exit: ; preds = %entry, %if.then.i |
| 121 | tail call void @_Z1fi(i32 0), !dbg !43 |
| 122 | ret void, !dbg !44 |
| 123 | } |
| 124 | |
| 125 | declare void @_Z1fi(i32) #1 |
| 126 | |
| 127 | ; Function Attrs: nounwind readnone |
Adrian Prantl | 87b7eb9 | 2014-10-01 18:55:02 +0000 | [diff] [blame] | 128 | declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #2 |
David Blaikie | 19a8b90 | 2014-06-04 01:30:59 +0000 | [diff] [blame] | 129 | |
| 130 | attributes #0 = { uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } |
| 131 | attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } |
| 132 | attributes #2 = { nounwind readnone } |
| 133 | |
| 134 | !llvm.dbg.cu = !{!0} |
| 135 | !llvm.module.flags = !{!21, !22} |
| 136 | !llvm.ident = !{!23} |
| 137 | |
Duncan P. N. Exon Smith | 55ca964 | 2015-08-03 17:26:41 +0000 | [diff] [blame] | 138 | !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 ", isOptimized: true, emissionKind: 1, file: !1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2) |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 139 | !1 = !DIFile(filename: "missing-abstract-variables.cc", directory: "/tmp/dbginfo") |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 140 | !2 = !{} |
| 141 | !3 = !{!4, !8, !14} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 142 | !4 = !DISubprogram(name: "b", linkageName: "_Z1bv", line: 13, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, scopeLine: 13, file: !1, scope: !5, type: !6, function: void ()* @_Z1bv, variables: !2) |
| 143 | !5 = !DIFile(filename: "missing-abstract-variables.cc", directory: "/tmp/dbginfo") |
| 144 | !6 = !DISubroutineType(types: !7) |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 145 | !7 = !{null} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 146 | !8 = !DISubprogram(name: "a", linkageName: "_Z1ab", line: 17, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, scopeLine: 17, file: !1, scope: !5, type: !9, function: void (i1)* @_Z1ab, variables: !12) |
| 147 | !9 = !DISubroutineType(types: !10) |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 148 | !10 = !{null, !11} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 149 | !11 = !DIBasicType(tag: DW_TAG_base_type, name: "bool", size: 8, align: 8, encoding: DW_ATE_boolean) |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 150 | !12 = !{!13} |
Duncan P. N. Exon Smith | ed013cd | 2015-07-31 18:58:39 +0000 | [diff] [blame] | 151 | !13 = !DILocalVariable(name: "u", line: 17, arg: 1, scope: !8, file: !5, type: !11) |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 152 | !14 = !DISubprogram(name: "x", linkageName: "_Z1xb", line: 5, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, scopeLine: 5, file: !1, scope: !5, type: !9, variables: !15) |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 153 | !15 = !{!16, !17} |
Duncan P. N. Exon Smith | ed013cd | 2015-07-31 18:58:39 +0000 | [diff] [blame] | 154 | !16 = !DILocalVariable(name: "b", line: 5, arg: 1, scope: !14, file: !5, type: !11) |
| 155 | !17 = !DILocalVariable(name: "s", line: 7, scope: !18, file: !5, type: !20) |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 156 | !18 = distinct !DILexicalBlock(line: 6, column: 0, file: !1, scope: !19) |
| 157 | !19 = distinct !DILexicalBlock(line: 6, column: 0, file: !1, scope: !14) |
| 158 | !20 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 159 | !21 = !{i32 2, !"Dwarf Version", i32 4} |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 160 | !22 = !{i32 2, !"Debug Info Version", i32 3} |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 161 | !23 = !{!"clang version 3.5.0 "} |
| 162 | !24 = !{i1 false} |
Duncan P. N. Exon Smith | ed013cd | 2015-07-31 18:58:39 +0000 | [diff] [blame] | 163 | !25 = !DILocalVariable(name: "b", line: 5, arg: 1, scope: !14, file: !5, type: !11) |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 164 | !26 = !DILocation(line: 14, scope: !4) |
| 165 | !27 = !DILocation(line: 5, scope: !14, inlinedAt: !26) |
| 166 | !28 = !DILocation(line: 10, scope: !14, inlinedAt: !26) |
| 167 | !29 = !DILocation(line: 15, scope: !4) |
| 168 | !30 = !DILocation(line: 17, scope: !8) |
Duncan P. N. Exon Smith | ed013cd | 2015-07-31 18:58:39 +0000 | [diff] [blame] | 169 | !31 = !DILocalVariable(name: "b", line: 5, arg: 1, scope: !14, file: !5, type: !11) |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 170 | !32 = !DILocation(line: 18, scope: !8) |
| 171 | !33 = !DILocation(line: 5, scope: !14, inlinedAt: !32) |
| 172 | !34 = !DILocation(line: 6, scope: !19, inlinedAt: !32) |
| 173 | !35 = !DILocation(line: 7, scope: !18, inlinedAt: !32) |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 174 | !36 = !{!37, !37, i64 0} |
| 175 | !37 = !{!"int", !38, i64 0} |
| 176 | !38 = !{!"omnipotent char", !39, i64 0} |
| 177 | !39 = !{!"Simple C/C++ TBAA"} |
Duncan P. N. Exon Smith | ed013cd | 2015-07-31 18:58:39 +0000 | [diff] [blame] | 178 | !40 = !DILocalVariable(name: "s", line: 7, scope: !18, file: !5, type: !20) |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 179 | !41 = !DILocation(line: 8, scope: !18, inlinedAt: !32) |
| 180 | !42 = !DILocation(line: 9, scope: !18, inlinedAt: !32) |
| 181 | !43 = !DILocation(line: 10, scope: !14, inlinedAt: !32) |
| 182 | !44 = !DILocation(line: 19, scope: !8) |