thinlto-function-summary-callgraph-profile-summary.ll 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. ; Test to check the callgraph in summary when there is PGO
  2. ; RUN: opt -module-summary %s -o %t.o
  3. ; RUN: llvm-bcanalyzer -dump %t.o | FileCheck %s
  4. ; RUN: llvm-dis %t.o
  5. ; RUN: cat %t.o.ll | FileCheck %s --check-prefix=DIS
  6. ; Make sure the assembler doesn't error when parsing the summary
  7. ; RUN: llvm-as %t.o.ll
  8. ; Check assembled summary.
  9. ; RUN: llvm-dis %t.o.bc -o - | FileCheck %s --check-prefix=DIS
  10. ; RUN: opt -module-summary %p/Inputs/thinlto-function-summary-callgraph-profile-summary.ll -o %t2.o
  11. ; RUN: llvm-lto -thinlto -o %t3 %t.o %t2.o
  12. ; RUN: llvm-bcanalyzer -dump %t3.thinlto.bc | FileCheck %s --check-prefix=COMBINED
  13. ; RUN: llvm-dis %t3.thinlto.bc
  14. ; RUN: cat %t3.thinlto.ll | FileCheck %s --check-prefix=COMBINED-DIS
  15. ; Round trip it through llvm-as
  16. ; RUN: cat %t3.thinlto.ll | llvm-as -o - | llvm-dis -o - | FileCheck %s --check-prefix=COMBINED-DIS
  17. ; Make sure the assembler doesn't error when parsing the combined summary
  18. ; RUN: llvm-as %t3.thinlto.ll -o %t3.thinlto.o
  19. ; Check assembled combined summary.
  20. ; RUN: llvm-dis %t3.thinlto.o -o - | FileCheck %s --check-prefix=COMBINED-DIS
  21. ; CHECK: <SOURCE_FILENAME
  22. ; "hot_function"
  23. ; CHECK-NEXT: <FUNCTION op0=0 op1=12
  24. ; "hot1"
  25. ; CHECK-NEXT: <FUNCTION op0=12 op1=4
  26. ; "hot2"
  27. ; CHECK-NEXT: <FUNCTION op0=16 op1=4
  28. ; "hot3"
  29. ; CHECK-NEXT: <FUNCTION op0=20 op1=4
  30. ; "hot4"
  31. ; CHECK-NEXT: <FUNCTION op0=24 op1=4
  32. ; "cold"
  33. ; CHECK-NEXT: <FUNCTION op0=28 op1=4
  34. ; "none1"
  35. ; CHECK-NEXT: <FUNCTION op0=32 op1=5
  36. ; "none2"
  37. ; CHECK-NEXT: <FUNCTION op0=37 op1=5
  38. ; "none3"
  39. ; CHECK-NEXT: <FUNCTION op0=42 op1=5
  40. ; CHECK-LABEL: <GLOBALVAL_SUMMARY_BLOCK
  41. ; CHECK-NEXT: <VERSION
  42. ; CHECK-NEXT: <FLAGS
  43. ; CHECK-NEXT: <VALUE_GUID op0=25 op1=123/>
  44. ; op4=hot1 op6=cold op8=hot2 op10=hot4 op12=none1 op14=hot3 op16=none2 op18=none3 op20=123
  45. ; CHECK-NEXT: <PERMODULE_PROFILE {{.*}} op6=1 op7=3 op8=5 op9=1 op10=2 op11=3 op12=4 op13=1 op14=6 op15=2 op16=3 op17=3 op18=7 op19=2 op20=8 op21=2 op22=25 op23=4/>
  46. ; CHECK-NEXT: </GLOBALVAL_SUMMARY_BLOCK>
  47. ; CHECK: <STRTAB_BLOCK
  48. ; CHECK-NEXT: blob data = 'hot_functionhot1hot2hot3hot4coldnone1none2none3{{.*}}'
  49. ; COMBINED: <GLOBALVAL_SUMMARY_BLOCK
  50. ; COMBINED-NEXT: <VERSION
  51. ; COMBINED-NEXT: <FLAGS
  52. ; COMBINED-NEXT: <VALUE_GUID
  53. ; COMBINED-NEXT: <VALUE_GUID
  54. ; COMBINED-NEXT: <VALUE_GUID
  55. ; COMBINED-NEXT: <VALUE_GUID
  56. ; COMBINED-NEXT: <VALUE_GUID
  57. ; COMBINED-NEXT: <VALUE_GUID
  58. ; COMBINED-NEXT: <VALUE_GUID
  59. ; COMBINED-NEXT: <VALUE_GUID
  60. ; COMBINED-NEXT: <COMBINED abbrevid=
  61. ; COMBINED-NEXT: <COMBINED abbrevid=
  62. ; COMBINED-NEXT: <COMBINED abbrevid=
  63. ; COMBINED-NEXT: <COMBINED abbrevid=
  64. ; COMBINED-NEXT: <COMBINED abbrevid=
  65. ; COMBINED-NEXT: <COMBINED abbrevid=
  66. ; COMBINED-NEXT: <COMBINED_PROFILE {{.*}} op8=[[HOT1:.*]] op9=3 op10=[[COLD:.*]] op11=1 op12=[[HOT2:.*]] op13=3 op14=[[NONE1:.*]] op15=2 op16=[[HOT3:.*]] op17=3 op18=[[NONE2:.*]] op19=2 op20=[[NONE3:.*]] op21=2/>
  67. ; COMBINED_NEXT: <COMBINED abbrevid=
  68. ; COMBINED_NEXT: </GLOBALVAL_SUMMARY_BLOCK>
  69. ; ModuleID = 'thinlto-function-summary-callgraph.ll'
  70. target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
  71. target triple = "x86_64-unknown-linux-gnu"
  72. ; This function have high profile count, so entry block is hot.
  73. define void @hot_function(i1 %a, i1 %a2) !prof !20 {
  74. entry:
  75. call void @hot1()
  76. br i1 %a, label %Cold, label %Hot, !prof !41
  77. Cold: ; 1/1000 goes here
  78. call void @cold()
  79. call void @hot2()
  80. call void @hot4(), !prof !15
  81. call void @none1()
  82. br label %exit
  83. Hot: ; 999/1000 goes here
  84. call void @hot2()
  85. call void @hot3()
  86. br i1 %a2, label %None1, label %None2, !prof !42
  87. None1: ; half goes here
  88. call void @none1()
  89. call void @none2()
  90. br label %exit
  91. None2: ; half goes here
  92. call void @none3()
  93. br label %exit
  94. exit:
  95. ret void
  96. }
  97. declare void @hot1() #1
  98. declare void @hot2() #1
  99. declare void @hot3() #1
  100. declare void @hot4() #1
  101. declare void @cold() #1
  102. declare void @none1() #1
  103. declare void @none2() #1
  104. declare void @none3() #1
  105. !41 = !{!"branch_weights", i32 1, i32 1000}
  106. !42 = !{!"branch_weights", i32 1, i32 1}
  107. !llvm.module.flags = !{!1}
  108. !20 = !{!"function_entry_count", i64 110, i64 123}
  109. !1 = !{i32 1, !"ProfileSummary", !2}
  110. !2 = !{!3, !4, !5, !6, !7, !8, !9, !10}
  111. !3 = !{!"ProfileFormat", !"InstrProf"}
  112. !4 = !{!"TotalCount", i64 10000}
  113. !5 = !{!"MaxCount", i64 10}
  114. !6 = !{!"MaxInternalCount", i64 1}
  115. !7 = !{!"MaxFunctionCount", i64 1000}
  116. !8 = !{!"NumCounts", i64 3}
  117. !9 = !{!"NumFunctions", i64 3}
  118. !10 = !{!"DetailedSummary", !11}
  119. !11 = !{!12, !13, !14}
  120. !12 = !{i32 10000, i64 100, i32 1}
  121. !13 = !{i32 999000, i64 100, i32 1}
  122. !14 = !{i32 999999, i64 1, i32 2}
  123. !15 = !{!"branch_weights", i32 100}
  124. ; DIS: ^0 = module: (path: "{{.*}}thinlto-function-summary-callgraph-profile-summary.ll.tmp.o{{.*}}", hash: (0, 0, 0, 0, 0))
  125. ; DIS: ^1 = gv: (guid: 123)
  126. ; DIS: ^2 = gv: (name: "none2") ; guid = 3741006263754194003
  127. ; DIS: ^3 = gv: (name: "hot3") ; guid = 5026609803865204483
  128. ; DIS: ^4 = gv: (name: "hot2") ; guid = 8117347573235780485
  129. ; DIS: ^5 = gv: (name: "hot1") ; guid = 9453975128311291976
  130. ; DIS: ^6 = gv: (name: "cold") ; guid = 11668175513417606517
  131. ; DIS: ^7 = gv: (name: "hot4") ; guid = 13161834114071272798
  132. ; DIS: ^8 = gv: (name: "none3") ; guid = 16213681105727317812
  133. ; DIS: ^9 = gv: (name: "hot_function", summaries: (function: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 16, calls: ((callee: ^5, hotness: hot), (callee: ^6, hotness: cold), (callee: ^4, hotness: hot), (callee: ^7, hotness: cold), (callee: ^10, hotness: none), (callee: ^3, hotness: hot), (callee: ^2, hotness: none), (callee: ^8, hotness: none), (callee: ^1, hotness: critical))))) ; guid = 17381606045411660303
  134. ; DIS: ^10 = gv: (name: "none1") ; guid = 17712061229457633252
  135. ; COMBINED-DIS: ^0 = module: (path: "{{.*}}thinlto-function-summary-callgraph-profile-summary.ll.tmp.o", hash: (0, 0, 0, 0, 0))
  136. ; COMBINED-DIS: ^1 = module: (path: "{{.*}}thinlto-function-summary-callgraph-profile-summary.ll.tmp2.o", hash: (0, 0, 0, 0, 0))
  137. ; COMBINED-DIS: ^2 = gv: (guid: 3741006263754194003, summaries: (function: (module: ^1, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 1)))
  138. ; COMBINED-DIS: ^3 = gv: (guid: 5026609803865204483, summaries: (function: (module: ^1, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 1)))
  139. ; COMBINED-DIS: ^4 = gv: (guid: 8117347573235780485, summaries: (function: (module: ^1, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 1)))
  140. ; COMBINED-DIS: ^5 = gv: (guid: 9453975128311291976, summaries: (function: (module: ^1, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 1)))
  141. ; COMBINED-DIS: ^6 = gv: (guid: 11668175513417606517, summaries: (function: (module: ^1, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 1)))
  142. ; COMBINED-DIS: ^7 = gv: (guid: 16213681105727317812, summaries: (function: (module: ^1, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 1)))
  143. ; COMBINED-DIS: ^8 = gv: (guid: 17381606045411660303, summaries: (function: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 16, calls: ((callee: ^5, hotness: hot), (callee: ^6, hotness: cold), (callee: ^4, hotness: hot), (callee: ^9, hotness: none), (callee: ^3, hotness: hot), (callee: ^2, hotness: none), (callee: ^7, hotness: none)))))
  144. ; COMBINED-DIS: ^9 = gv: (guid: 17712061229457633252, summaries: (function: (module: ^1, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0), insts: 1)))