blob: fd12d3f99f6c7e165b7668ffab11a06f71e60762 [file] [log] [blame]
Piotr Padlewskid9830eb2016-09-26 20:37:32 +00001; 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: opt -module-summary %p/Inputs/thinlto-function-summary-callgraph-profile-summary.ll -o %t2.o
5; RUN: llvm-lto -thinlto -o %t3 %t.o %t2.o
6; RUN: llvm-bcanalyzer -dump %t3.thinlto.bc | FileCheck %s --check-prefix=COMBINED
7
8
9; CHECK-LABEL: <GLOBALVAL_SUMMARY_BLOCK
10; CHECK-NEXT: <VERSION
11; See if the call to func is registered, using the expected callsite count
12; and profile count, with value id matching the subsequent value symbol table.
13; CHECK-NEXT: <PERMODULE_PROFILE {{.*}} op4=[[HOT1:.*]] op5=3 op6=[[HOT2:.*]] op7=3 op8=[[HOT3:.*]] op9=3 op10=[[COLD:.*]] op11=1 op12=[[NONE1:.*]] op13=2 op14=[[NONE2:.*]] op15=2 op16=[[NONE3:.*]] op17=2/>
14; CHECK-NEXT: </GLOBALVAL_SUMMARY_BLOCK>
15; CHECK-LABEL: <VALUE_SYMTAB
16; CHECK-NEXT: <FNENTRY {{.*}} record string = 'hot_function
17; CHECK-DAG: <ENTRY abbrevid=6 op0=[[NONE1]] {{.*}} record string = 'none1'
18; CHECK-DAG: <ENTRY abbrevid=6 op0=[[COLD]] {{.*}} record string = 'cold'
19; CHECK-DAG: <ENTRY abbrevid=6 op0=[[NONE2]] {{.*}} record string = 'none2'
20; CHECK-DAG: <ENTRY abbrevid=6 op0=[[NONE3]] {{.*}} record string = 'none3'
21; CHECK-DAG: <ENTRY abbrevid=6 op0=[[HOT1]] {{.*}} record string = 'hot1'
22; CHECK-DAG: <ENTRY abbrevid=6 op0=[[HOT2]] {{.*}} record string = 'hot2'
23; CHECK-DAG: <ENTRY abbrevid=6 op0=[[HOT3]] {{.*}} record string = 'hot3'
24; CHECK-LABEL: </VALUE_SYMTAB>
25
26; COMBINED: <GLOBALVAL_SUMMARY_BLOCK
27; COMBINED-NEXT: <VERSION
28; COMBINED-NEXT: <COMBINED abbrevid=
29; COMBINED-NEXT: <COMBINED abbrevid=
30; COMBINED-NEXT: <COMBINED abbrevid=
31; COMBINED-NEXT: <COMBINED abbrevid=
32; COMBINED-NEXT: <COMBINED abbrevid=
33; COMBINED-NEXT: <COMBINED abbrevid=
34; COMBINED-NEXT: <COMBINED_PROFILE {{.*}} op5=[[HOT1:.*]] op6=3 op7=[[HOT2:.*]] op8=3 op9=[[HOT3:.*]] op10=3 op11=[[COLD:.*]] op12=1 op13=[[NONE1:.*]] op14=2 op15=[[NONE2:.*]] op16=2 op17=[[NONE3:.*]] op18=2/>
35; COMBINED_NEXT: <COMBINED abbrevid=
36; COMBINED_NEXT: </GLOBALVAL_SUMMARY_BLOCK>
37
38
39; ModuleID = 'thinlto-function-summary-callgraph.ll'
40target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
41target triple = "x86_64-unknown-linux-gnu"
42
43; This function have high profile count, so entry block is hot.
44define void @hot_function(i1 %a, i1 %a2) !prof !20 {
45entry:
46 call void @hot1()
47 br i1 %a, label %Cold, label %Hot, !prof !41
48Cold: ; 1/1000 goes here
49 call void @cold()
50 call void @hot2()
51 call void @none1()
52 br label %exit
53Hot: ; 999/1000 goes here
54 call void @hot2()
55 call void @hot3()
56 br i1 %a2, label %None1, label %None2, !prof !42
57None1: ; half goes here
58 call void @none1()
59 call void @none2()
60 br label %exit
61None2: ; half goes here
62 call void @none3()
63 br label %exit
64exit:
65 ret void
66}
67
68declare void @hot1() #1
69declare void @hot2() #1
70declare void @hot3() #1
71declare void @cold() #1
72declare void @none1() #1
73declare void @none2() #1
74declare void @none3() #1
75
76
77!41 = !{!"branch_weights", i32 1, i32 1000}
78!42 = !{!"branch_weights", i32 1, i32 1}
79
80
81
82!llvm.module.flags = !{!1}
83!20 = !{!"function_entry_count", i64 110}
84
85!1 = !{i32 1, !"ProfileSummary", !2}
86!2 = !{!3, !4, !5, !6, !7, !8, !9, !10}
87!3 = !{!"ProfileFormat", !"InstrProf"}
88!4 = !{!"TotalCount", i64 10000}
89!5 = !{!"MaxCount", i64 10}
90!6 = !{!"MaxInternalCount", i64 1}
91!7 = !{!"MaxFunctionCount", i64 1000}
92!8 = !{!"NumCounts", i64 3}
93!9 = !{!"NumFunctions", i64 3}
94!10 = !{!"DetailedSummary", !11}
95!11 = !{!12, !13, !14}
96!12 = !{i32 10000, i64 100, i32 1}
97!13 = !{i32 999000, i64 100, i32 1}
98!14 = !{i32 999999, i64 1, i32 2}