blob: 3a5adea202e2a0da2b963f851d7ae4dedf168ad4 [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.
Dehao Chen190f17c2017-03-21 17:22:35 +000013; CHECK-NEXT: <PERMODULE_PROFILE {{.*}} op4=[[HOT1:.*]] op5=3 op6=[[COLD:.*]] op7=1 op8=[[HOT2:.*]] op9=3 op10=[[HOT4:.*]] op11=3 op12=[[NONE1:.*]] op13=2 op14=[[HOT3:.*]] op15=3 op16=[[NONE2:.*]] op17=2 op18=[[NONE3:.*]] op19=2 op20=[[LEGACY:.*]] op21=3/>
Piotr Padlewskid9830eb2016-09-26 20:37:32 +000014; 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'
Dehao Chen190f17c2017-03-21 17:22:35 +000024; CHECK-DAG: <ENTRY abbrevid=6 op0=[[HOT4]] {{.*}} record string = 'hot4'
Dehao Chena60cdd32017-02-28 18:09:44 +000025; CHECK-DAG: <COMBINED_ENTRY abbrevid=11 op0=[[LEGACY]] op1=123/>
Piotr Padlewskid9830eb2016-09-26 20:37:32 +000026; CHECK-LABEL: </VALUE_SYMTAB>
27
28; COMBINED: <GLOBALVAL_SUMMARY_BLOCK
29; COMBINED-NEXT: <VERSION
30; COMBINED-NEXT: <COMBINED abbrevid=
31; COMBINED-NEXT: <COMBINED abbrevid=
32; COMBINED-NEXT: <COMBINED abbrevid=
33; COMBINED-NEXT: <COMBINED abbrevid=
34; COMBINED-NEXT: <COMBINED abbrevid=
35; COMBINED-NEXT: <COMBINED abbrevid=
Peter Collingbourne0c30f082016-12-20 21:12:28 +000036; COMBINED-NEXT: <COMBINED_PROFILE {{.*}} op5=[[HOT1:.*]] op6=3 op7=[[COLD:.*]] op8=1 op9=[[HOT2:.*]] op10=3 op11=[[NONE1:.*]] op12=2 op13=[[HOT3:.*]] op14=3 op15=[[NONE2:.*]] op16=2 op17=[[NONE3:.*]] op18=2/>
Piotr Padlewskid9830eb2016-09-26 20:37:32 +000037; COMBINED_NEXT: <COMBINED abbrevid=
38; COMBINED_NEXT: </GLOBALVAL_SUMMARY_BLOCK>
39
40
41; ModuleID = 'thinlto-function-summary-callgraph.ll'
42target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
43target triple = "x86_64-unknown-linux-gnu"
44
45; This function have high profile count, so entry block is hot.
46define void @hot_function(i1 %a, i1 %a2) !prof !20 {
47entry:
48 call void @hot1()
49 br i1 %a, label %Cold, label %Hot, !prof !41
50Cold: ; 1/1000 goes here
51 call void @cold()
52 call void @hot2()
Dehao Chen190f17c2017-03-21 17:22:35 +000053 call void @hot4(), !prof !15
Piotr Padlewskid9830eb2016-09-26 20:37:32 +000054 call void @none1()
55 br label %exit
56Hot: ; 999/1000 goes here
57 call void @hot2()
58 call void @hot3()
59 br i1 %a2, label %None1, label %None2, !prof !42
60None1: ; half goes here
61 call void @none1()
62 call void @none2()
63 br label %exit
64None2: ; half goes here
65 call void @none3()
66 br label %exit
67exit:
68 ret void
69}
70
71declare void @hot1() #1
72declare void @hot2() #1
73declare void @hot3() #1
Dehao Chen190f17c2017-03-21 17:22:35 +000074declare void @hot4() #1
Piotr Padlewskid9830eb2016-09-26 20:37:32 +000075declare void @cold() #1
76declare void @none1() #1
77declare void @none2() #1
78declare void @none3() #1
79
80
81!41 = !{!"branch_weights", i32 1, i32 1000}
82!42 = !{!"branch_weights", i32 1, i32 1}
83
84
85
86!llvm.module.flags = !{!1}
Dehao Chena60cdd32017-02-28 18:09:44 +000087!20 = !{!"function_entry_count", i64 110, i64 123}
Piotr Padlewskid9830eb2016-09-26 20:37:32 +000088
89!1 = !{i32 1, !"ProfileSummary", !2}
90!2 = !{!3, !4, !5, !6, !7, !8, !9, !10}
91!3 = !{!"ProfileFormat", !"InstrProf"}
92!4 = !{!"TotalCount", i64 10000}
93!5 = !{!"MaxCount", i64 10}
94!6 = !{!"MaxInternalCount", i64 1}
95!7 = !{!"MaxFunctionCount", i64 1000}
96!8 = !{!"NumCounts", i64 3}
97!9 = !{!"NumFunctions", i64 3}
98!10 = !{!"DetailedSummary", !11}
99!11 = !{!12, !13, !14}
100!12 = !{i32 10000, i64 100, i32 1}
101!13 = !{i32 999000, i64 100, i32 1}
102!14 = !{i32 999999, i64 1, i32 2}
Dehao Chen190f17c2017-03-21 17:22:35 +0000103!15 = !{!"branch_weights", i32 100}