return-block.ll 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. ; Inject metadata to set the .gcno file location
  2. ; RUN: echo '!19 = !{!"%/T/return-block.ll", !0}' > %t1
  3. ; RUN: cat %s %t1 > %t2
  4. ; By default, the return block is last.
  5. ; RUN: opt -insert-gcov-profiling -disable-output %t2
  6. ; RUN: llvm-cov gcov -n -dump %T/return-block.gcno 2>&1 | FileCheck -check-prefix=CHECK -check-prefix=RETURN-LAST %s
  7. ; But we can optionally emit it second, to match newer gcc versions.
  8. ; RUN: opt -insert-gcov-profiling -gcov-exit-block-before-body -disable-output %t2
  9. ; RUN: llvm-cov gcov -n -dump %T/return-block.gcno 2>&1 | FileCheck -check-prefix=CHECK -check-prefix=RETURN-SECOND %s
  10. target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
  11. target triple = "x86_64-unknown-linux-gnu"
  12. @A = common global i32 0, align 4
  13. ; Function Attrs: nounwind uwtable
  14. define void @test() #0 {
  15. entry:
  16. tail call void (...) @f() #2, !dbg !14
  17. %0 = load i32, i32* @A, align 4, !dbg !15
  18. %tobool = icmp eq i32 %0, 0, !dbg !15
  19. br i1 %tobool, label %if.end, label %if.then, !dbg !15
  20. if.then: ; preds = %entry
  21. tail call void (...) @g() #2, !dbg !16
  22. br label %if.end, !dbg !16
  23. if.end: ; preds = %entry, %if.then
  24. ret void, !dbg !18
  25. }
  26. declare void @f(...) #1
  27. declare void @g(...) #1
  28. attributes #0 = { nounwind 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" }
  29. 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" }
  30. attributes #2 = { nounwind }
  31. !llvm.gcov = !{!19}
  32. !llvm.dbg.cu = !{!0}
  33. !llvm.module.flags = !{!11, !12}
  34. !llvm.ident = !{!13}
  35. !0 = !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.6.0 (trunk 223182)", isOptimized: true, emissionKind: 1, file: !1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !8, imports: !2)
  36. !1 = !DIFile(filename: ".../llvm/test/Transforms/GCOVProfiling/return-block.ll", directory: "")
  37. !2 = !{}
  38. !3 = !{!4}
  39. !4 = !DISubprogram(name: "test", line: 5, isLocal: false, isDefinition: true, isOptimized: true, scopeLine: 5, file: !1, scope: !5, type: !6, function: void ()* @test, variables: !2)
  40. !5 = !DIFile(filename: ".../llvm/test/Transforms/GCOVProfiling/return-block.ll", directory: "")
  41. !6 = !DISubroutineType(types: !7)
  42. !7 = !{null}
  43. !8 = !{!9}
  44. !9 = !DIGlobalVariable(name: "A", line: 3, isLocal: false, isDefinition: true, scope: null, file: !5, type: !10, variable: i32* @A)
  45. !10 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
  46. !11 = !{i32 2, !"Dwarf Version", i32 4}
  47. !12 = !{i32 2, !"Debug Info Version", i32 3}
  48. !13 = !{!"clang version 3.6.0 (trunk 223182)"}
  49. !14 = !DILocation(line: 6, column: 3, scope: !4)
  50. !15 = !DILocation(line: 7, column: 7, scope: !4)
  51. !16 = !DILocation(line: 8, column: 5, scope: !17)
  52. !17 = distinct !DILexicalBlock(line: 7, column: 7, file: !1, scope: !4)
  53. !18 = !DILocation(line: 9, column: 1, scope: !4)
  54. ; There should be no destination edges for the exit block.
  55. ; CHECK: Block : 1 Counter : 0
  56. ; RETURN-LAST: Destination Edges
  57. ; RETURN-SECOND-NOT: Destination Edges
  58. ; CHECK: Block : 2 Counter : 0
  59. ; CHECK: Block : 4 Counter : 0
  60. ; RETURN-LAST-NOT: Destination Edges
  61. ; RETURN-SECOND: Destination Edges
  62. ; CHECK-NOT: Block :