missing-abstract-variable.ll 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. ; REQUIRES: object-emission
  2. ; RUN: %llc_dwarf -O0 -filetype=obj < %s | llvm-dwarfdump -v -debug-info - | FileCheck %s
  3. ; Build from the following source with clang -O2.
  4. ; The important details are that 'x's abstract definition is first built during
  5. ; the definition of 'b', where the parameter to 'x' is constant and so 'x's 's'
  6. ; variable is optimized away. No abstract definition DIE for 's' is constructed.
  7. ; Then, during 'a' emission, the abstract DbgVariable for 's' is created, but
  8. ; the abstract DIE isn't (since the abstract definition for 'b' is already
  9. ; built). This results in 's' inlined in 'a' being emitted with its name, line,
  10. ; file there, rather than referencing an abstract definition.
  11. ; extern int t;
  12. ;
  13. ; void f(int);
  14. ;
  15. ; inline void x(bool b) {
  16. ; if (b) {
  17. ; int s = t;
  18. ; f(s);
  19. ; }
  20. ; f(0);
  21. ; }
  22. ;
  23. ; void b() {
  24. ; x(false);
  25. ; }
  26. ;
  27. ; void a(bool u) {
  28. ; x(u);
  29. ; }
  30. ; CHECK: [[X_DECL:.*]]: DW_TAG_subprogram
  31. ; CHECK-NOT: DW_TAG
  32. ; CHECK: DW_AT_name {{.*}} "x"
  33. ; CHECK-NOT: {{DW_TAG|NULL}}
  34. ; CHECK: DW_TAG_formal_parameter
  35. ; CHECK-NOT: DW_TAG
  36. ; CHECK: DW_AT_name {{.*}} "b"
  37. ; CHECK-NOT: {{DW_TAG|NULL}}
  38. ; CHECK: DW_TAG_lexical_block
  39. ; CHECK-NOT: {{DW_TAG|NULL}}
  40. ; CHECK: DW_TAG_variable
  41. ; CHECK-NOT: DW_TAG
  42. ; CHECK: DW_AT_name {{.*}} "s"
  43. ; CHECK: DW_TAG_subprogram
  44. ; CHECK-NOT: DW_TAG
  45. ; CHECK: DW_AT_name {{.*}} "b"
  46. ; CHECK-NOT: {{DW_TAG|NULL}}
  47. ; CHECK: DW_TAG_inlined_subroutine
  48. ; CHECK-NOT: DW_TAG
  49. ; CHECK: DW_AT_abstract_origin {{.*}} {[[X_DECL]]}
  50. ; CHECK-NOT: {{DW_TAG|NULL}}
  51. ; CHECK: DW_TAG_formal_parameter
  52. ; CHECK-NOT: DW_TAG
  53. ; CHECK: DW_AT_abstract_origin {{.*}} "b"
  54. ; Notice 'x's local variable 's' is missing. Not necessarily a bug here,
  55. ; since it's been optimized entirely away and it should be described in
  56. ; abstract subprogram.
  57. ; CHECK-NOT: DW_TAG
  58. ; CHECK: NULL
  59. ; CHECK-NOT: DW_TAG
  60. ; CHECK: NULL
  61. ; CHECK: DW_TAG_subprogram
  62. ; CHECK-NOT: DW_TAG
  63. ; CHECK: DW_AT_name {{.*}} "a"
  64. ; CHECK-NOT: {{DW_TAG|NULL}}
  65. ; CHECK: DW_TAG_formal_parameter
  66. ; CHECK-NOT: {{DW_TAG|NULL}}
  67. ; CHECK: DW_TAG_inlined_subroutine
  68. ; CHECK-NOT: DW_TAG
  69. ; CHECK: DW_AT_abstract_origin {{.*}} {[[X_DECL]]}
  70. ; CHECK-NOT: {{DW_TAG|NULL}}
  71. ; FIXME: This formal parameter goes missing at least at -O2 (& on
  72. ; mips/powerpc), maybe before that. Perhaps SelectionDAG is to blame (and
  73. ; fastisel succeeds).
  74. ; CHECK: DW_TAG_formal_parameter
  75. ; CHECK-NOT: DW_TAG
  76. ; CHECK: DW_AT_abstract_origin {{.*}} "b"
  77. ; CHECK-NOT: {{DW_TAG|NULL}}
  78. ; CHECK: DW_TAG_lexical_block
  79. ; CHECK-NOT: {{DW_TAG|NULL}}
  80. ; CHECK: DW_TAG_variable
  81. ; CHECK-NOT: DW_TAG
  82. ; CHECK: DW_AT_abstract_origin {{.*}} "s"
  83. @t = external global i32
  84. ; Function Attrs: uwtable
  85. define void @_Z1bv() #0 !dbg !4 {
  86. entry:
  87. tail call void @llvm.dbg.value(metadata i1 false, metadata !25, metadata !DIExpression()), !dbg !27
  88. tail call void @_Z1fi(i32 0), !dbg !28
  89. ret void, !dbg !29
  90. }
  91. ; Function Attrs: uwtable
  92. define void @_Z1ab(i1 zeroext %u) #0 !dbg !8 {
  93. entry:
  94. tail call void @llvm.dbg.value(metadata i1 %u, metadata !13, metadata !DIExpression()), !dbg !30
  95. tail call void @llvm.dbg.value(metadata i1 %u, metadata !31, metadata !DIExpression()), !dbg !33
  96. br i1 %u, label %if.then.i, label %_Z1xb.exit, !dbg !34
  97. if.then.i: ; preds = %entry
  98. %0 = load i32, i32* @t, align 4, !dbg !35, !tbaa !36
  99. tail call void @llvm.dbg.value(metadata i32 %0, metadata !40, metadata !DIExpression()), !dbg !35
  100. tail call void @_Z1fi(i32 %0), !dbg !41
  101. br label %_Z1xb.exit, !dbg !42
  102. _Z1xb.exit: ; preds = %entry, %if.then.i
  103. tail call void @_Z1fi(i32 0), !dbg !43
  104. ret void, !dbg !44
  105. }
  106. declare void @_Z1fi(i32) #1
  107. ; Function Attrs: nounwind readnone
  108. declare void @llvm.dbg.value(metadata, metadata, metadata) #2
  109. 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" }
  110. 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" }
  111. attributes #2 = { nounwind readnone }
  112. !llvm.dbg.cu = !{!0}
  113. !llvm.module.flags = !{!21, !22}
  114. !llvm.ident = !{!23}
  115. !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 ", isOptimized: true, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
  116. !1 = !DIFile(filename: "missing-abstract-variables.cc", directory: "/tmp/dbginfo")
  117. !2 = !{}
  118. !4 = distinct !DISubprogram(name: "b", linkageName: "_Z1bv", line: 13, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 13, file: !1, scope: !5, type: !6, retainedNodes: !2)
  119. !5 = !DIFile(filename: "missing-abstract-variables.cc", directory: "/tmp/dbginfo")
  120. !6 = !DISubroutineType(types: !7)
  121. !7 = !{null}
  122. !8 = distinct !DISubprogram(name: "a", linkageName: "_Z1ab", line: 17, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 17, file: !1, scope: !5, type: !9, retainedNodes: !12)
  123. !9 = !DISubroutineType(types: !10)
  124. !10 = !{null, !11}
  125. !11 = !DIBasicType(tag: DW_TAG_base_type, name: "bool", size: 8, align: 8, encoding: DW_ATE_boolean)
  126. !12 = !{!13}
  127. !13 = !DILocalVariable(name: "u", line: 17, arg: 1, scope: !8, file: !5, type: !11)
  128. !14 = distinct !DISubprogram(name: "x", linkageName: "_Z1xb", line: 5, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 5, file: !1, scope: !5, type: !9, retainedNodes: !15)
  129. !15 = !{!16, !17}
  130. !16 = !DILocalVariable(name: "b", line: 5, arg: 1, scope: !14, file: !5, type: !11)
  131. !17 = !DILocalVariable(name: "s", line: 7, scope: !18, file: !5, type: !20)
  132. !18 = distinct !DILexicalBlock(line: 6, column: 0, file: !1, scope: !19)
  133. !19 = distinct !DILexicalBlock(line: 6, column: 0, file: !1, scope: !14)
  134. !20 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
  135. !21 = !{i32 2, !"Dwarf Version", i32 4}
  136. !22 = !{i32 2, !"Debug Info Version", i32 3}
  137. !23 = !{!"clang version 3.5.0 "}
  138. !24 = !{i1 false}
  139. !25 = !DILocalVariable(name: "b", line: 5, arg: 1, scope: !14, file: !5, type: !11)
  140. !26 = !DILocation(line: 14, scope: !4)
  141. !27 = !DILocation(line: 5, scope: !14, inlinedAt: !26)
  142. !28 = !DILocation(line: 10, scope: !14, inlinedAt: !26)
  143. !29 = !DILocation(line: 15, scope: !4)
  144. !30 = !DILocation(line: 17, scope: !8)
  145. !31 = !DILocalVariable(name: "b", line: 5, arg: 1, scope: !14, file: !5, type: !11)
  146. !32 = !DILocation(line: 18, scope: !8)
  147. !33 = !DILocation(line: 5, scope: !14, inlinedAt: !32)
  148. !34 = !DILocation(line: 6, scope: !19, inlinedAt: !32)
  149. !35 = !DILocation(line: 7, scope: !18, inlinedAt: !32)
  150. !36 = !{!37, !37, i64 0}
  151. !37 = !{!"int", !38, i64 0}
  152. !38 = !{!"omnipotent char", !39, i64 0}
  153. !39 = !{!"Simple C/C++ TBAA"}
  154. !40 = !DILocalVariable(name: "s", line: 7, scope: !18, file: !5, type: !20)
  155. !41 = !DILocation(line: 8, scope: !18, inlinedAt: !32)
  156. !42 = !DILocation(line: 9, scope: !18, inlinedAt: !32)
  157. !43 = !DILocation(line: 10, scope: !14, inlinedAt: !32)
  158. !44 = !DILocation(line: 19, scope: !8)