inline-scopes.ll 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. ; REQUIRES: object-emission
  2. ; RUN: %llc_dwarf -O0 -filetype=obj < %s | llvm-dwarfdump -debug-info - | FileCheck %s
  3. ; bool f();
  4. ; inline __attribute__((always_inline)) int f1() {
  5. ; if (bool b = f())
  6. ; return 1;
  7. ; return 2;
  8. ; }
  9. ;
  10. ; inline __attribute__((always_inline)) int f2() {
  11. ; # 2 "y.cc"
  12. ; if (bool b = f())
  13. ; return 3;
  14. ; return 4;
  15. ; }
  16. ;
  17. ; int main() {
  18. ; f1();
  19. ; f2();
  20. ; }
  21. ; Ensure that lexical_blocks within inlined_subroutines are preserved/emitted.
  22. ; CHECK: DW_TAG_inlined_subroutine
  23. ; CHECK-NOT: DW_TAG
  24. ; CHECK-NOT: NULL
  25. ; CHECK: DW_TAG_lexical_block
  26. ; CHECK-NOT: DW_TAG
  27. ; CHECK-NOT: NULL
  28. ; CHECK: DW_TAG_variable
  29. ; Ensure that file changes don't interfere with creating inlined subroutines.
  30. ; (see the line directive inside 'f2' in thesource)
  31. ; CHECK: DW_TAG_inlined_subroutine
  32. ; CHECK: DW_TAG_variable
  33. ; CHECK-NOT: DW_TAG
  34. ; CHECK: DW_AT_abstract_origin
  35. ; Function Attrs: uwtable
  36. define i32 @main() #0 !dbg !4 {
  37. entry:
  38. %retval.i2 = alloca i32, align 4
  39. %b.i3 = alloca i8, align 1
  40. %retval.i = alloca i32, align 4
  41. %b.i = alloca i8, align 1
  42. call void @llvm.dbg.declare(metadata i8* %b.i, metadata !16, metadata !DIExpression()), !dbg !19
  43. %call.i = call zeroext i1 @_Z1fv(), !dbg !19
  44. %frombool.i = zext i1 %call.i to i8, !dbg !19
  45. store i8 %frombool.i, i8* %b.i, align 1, !dbg !19
  46. %0 = load i8, i8* %b.i, align 1, !dbg !19
  47. %tobool.i = trunc i8 %0 to i1, !dbg !19
  48. br i1 %tobool.i, label %if.then.i, label %if.end.i, !dbg !19
  49. if.then.i: ; preds = %entry
  50. store i32 1, i32* %retval.i, !dbg !21
  51. br label %_Z2f1v.exit, !dbg !21
  52. if.end.i: ; preds = %entry
  53. store i32 2, i32* %retval.i, !dbg !22
  54. br label %_Z2f1v.exit, !dbg !22
  55. _Z2f1v.exit: ; preds = %if.then.i, %if.end.i
  56. %1 = load i32, i32* %retval.i, !dbg !23
  57. call void @llvm.dbg.declare(metadata i8* %b.i3, metadata !24, metadata !DIExpression()), !dbg !27
  58. %call.i4 = call zeroext i1 @_Z1fv(), !dbg !27
  59. %frombool.i5 = zext i1 %call.i4 to i8, !dbg !27
  60. store i8 %frombool.i5, i8* %b.i3, align 1, !dbg !27
  61. %2 = load i8, i8* %b.i3, align 1, !dbg !27
  62. %tobool.i6 = trunc i8 %2 to i1, !dbg !27
  63. br i1 %tobool.i6, label %if.then.i7, label %if.end.i8, !dbg !27
  64. if.then.i7: ; preds = %_Z2f1v.exit
  65. store i32 3, i32* %retval.i2, !dbg !29
  66. br label %_Z2f2v.exit, !dbg !29
  67. if.end.i8: ; preds = %_Z2f1v.exit
  68. store i32 4, i32* %retval.i2, !dbg !30
  69. br label %_Z2f2v.exit, !dbg !30
  70. _Z2f2v.exit: ; preds = %if.then.i7, %if.end.i8
  71. %3 = load i32, i32* %retval.i2, !dbg !31
  72. ret i32 0, !dbg !32
  73. }
  74. ; Function Attrs: nounwind readnone
  75. declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
  76. declare zeroext i1 @_Z1fv() #2
  77. attributes #0 = { 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" }
  78. attributes #1 = { nounwind readnone }
  79. attributes #2 = { "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" }
  80. !llvm.dbg.cu = !{!0}
  81. !llvm.module.flags = !{!13, !14}
  82. !llvm.ident = !{!15}
  83. !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 ", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
  84. !1 = !DIFile(filename: "inline-scopes.cpp", directory: "/tmp/dbginfo")
  85. !2 = !{}
  86. !4 = distinct !DISubprogram(name: "main", line: 7, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 7, file: !5, scope: !6, type: !7, retainedNodes: !2)
  87. !5 = !DIFile(filename: "y.cc", directory: "/tmp/dbginfo")
  88. !6 = !DIFile(filename: "y.cc", directory: "/tmp/dbginfo")
  89. !7 = !DISubroutineType(types: !8)
  90. !8 = !{!9}
  91. !9 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
  92. !10 = distinct !DISubprogram(name: "f2", linkageName: "_Z2f2v", line: 8, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 8, file: !1, scope: !11, type: !7, retainedNodes: !2)
  93. !11 = !DIFile(filename: "inline-scopes.cpp", directory: "/tmp/dbginfo")
  94. !12 = distinct !DISubprogram(name: "f1", linkageName: "_Z2f1v", line: 2, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 2, file: !1, scope: !11, type: !7, retainedNodes: !2)
  95. !13 = !{i32 2, !"Dwarf Version", i32 4}
  96. !14 = !{i32 1, !"Debug Info Version", i32 3}
  97. !15 = !{!"clang version 3.5.0 "}
  98. !16 = !DILocalVariable(name: "b", line: 3, scope: !17, file: !11, type: !18)
  99. !17 = distinct !DILexicalBlock(line: 3, column: 0, file: !1, scope: !12)
  100. !18 = !DIBasicType(tag: DW_TAG_base_type, name: "bool", size: 8, align: 8, encoding: DW_ATE_boolean)
  101. !19 = !DILocation(line: 3, scope: !17, inlinedAt: !20)
  102. !20 = !DILocation(line: 8, scope: !4)
  103. !21 = !DILocation(line: 4, scope: !17, inlinedAt: !20)
  104. !22 = !DILocation(line: 5, scope: !12, inlinedAt: !20)
  105. !23 = !DILocation(line: 6, scope: !12, inlinedAt: !20)
  106. !24 = !DILocalVariable(name: "b", line: 2, scope: !25, file: !6, type: !18)
  107. !25 = distinct !DILexicalBlock(line: 2, column: 0, file: !5, scope: !26)
  108. !26 = !DILexicalBlockFile(discriminator: 0, file: !5, scope: !10)
  109. !27 = !DILocation(line: 2, scope: !25, inlinedAt: !28)
  110. !28 = !DILocation(line: 9, scope: !4)
  111. !29 = !DILocation(line: 3, scope: !25, inlinedAt: !28)
  112. !30 = !DILocation(line: 4, scope: !26, inlinedAt: !28)
  113. !31 = !DILocation(line: 5, scope: !26, inlinedAt: !28)
  114. !32 = !DILocation(line: 10, scope: !4)