blob: f7ee79a73a92aae74ecfd6e5720878fe03c6ae72 [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
Teresa Johnson08d5b4e2018-05-26 02:34:13 +00004; RUN: llvm-dis %t.o
5; RUN: cat %t.o.ll | FileCheck %s --check-prefix=DIS
6
7; Make sure the assembler doesn't error when parsing the summary
8; RUN: llvm-as %t.o.ll
9; RUN: ls %t.o.bc
10
Piotr Padlewskid9830eb2016-09-26 20:37:32 +000011; RUN: opt -module-summary %p/Inputs/thinlto-function-summary-callgraph-profile-summary.ll -o %t2.o
12; RUN: llvm-lto -thinlto -o %t3 %t.o %t2.o
13; RUN: llvm-bcanalyzer -dump %t3.thinlto.bc | FileCheck %s --check-prefix=COMBINED
Teresa Johnson08d5b4e2018-05-26 02:34:13 +000014; RUN: llvm-dis %t3.thinlto.bc
15; RUN: cat %t3.thinlto.ll | FileCheck %s --check-prefix=COMBINED-DIS
16
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; RUN: ls %t3.thinlto.o
Piotr Padlewskid9830eb2016-09-26 20:37:32 +000020
21
Peter Collingbournea0f371a2017-04-17 17:51:36 +000022; CHECK: <SOURCE_FILENAME
23; "hot_function"
24; CHECK-NEXT: <FUNCTION op0=0 op1=12
25; "hot1"
26; CHECK-NEXT: <FUNCTION op0=12 op1=4
27; "hot2"
28; CHECK-NEXT: <FUNCTION op0=16 op1=4
29; "hot3"
30; CHECK-NEXT: <FUNCTION op0=20 op1=4
31; "hot4"
32; CHECK-NEXT: <FUNCTION op0=24 op1=4
33; "cold"
34; CHECK-NEXT: <FUNCTION op0=28 op1=4
35; "none1"
36; CHECK-NEXT: <FUNCTION op0=32 op1=5
37; "none2"
38; CHECK-NEXT: <FUNCTION op0=37 op1=5
39; "none3"
40; CHECK-NEXT: <FUNCTION op0=42 op1=5
Piotr Padlewskid9830eb2016-09-26 20:37:32 +000041; CHECK-LABEL: <GLOBALVAL_SUMMARY_BLOCK
42; CHECK-NEXT: <VERSION
Peter Collingbournea0f371a2017-04-17 17:51:36 +000043; 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
Charles Saternos75da10d2017-08-04 16:00:58 +000045; CHECK-NEXT: <PERMODULE_PROFILE {{.*}} op5=1 op6=3 op7=5 op8=1 op9=2 op10=3 op11=4 op12=1 op13=6 op14=2 op15=3 op16=3 op17=7 op18=2 op19=8 op20=2 op21=25 op22=4/>
Piotr Padlewskid9830eb2016-09-26 20:37:32 +000046; CHECK-NEXT: </GLOBALVAL_SUMMARY_BLOCK>
Peter Collingbournea0f371a2017-04-17 17:51:36 +000047
48; CHECK: <STRTAB_BLOCK
Peter Collingbourne92648c22017-06-27 23:50:11 +000049; CHECK-NEXT: blob data = 'hot_functionhot1hot2hot3hot4coldnone1none2none3{{.*}}'
Piotr Padlewskid9830eb2016-09-26 20:37:32 +000050
51; COMBINED: <GLOBALVAL_SUMMARY_BLOCK
52; COMBINED-NEXT: <VERSION
Teresa Johnsonf3681012018-02-07 04:05:59 +000053; COMBINED-NEXT: <FLAGS
Peter Collingbournea0f371a2017-04-17 17:51:36 +000054; 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: <VALUE_GUID
61; COMBINED-NEXT: <VALUE_GUID
Piotr Padlewskid9830eb2016-09-26 20:37:32 +000062; COMBINED-NEXT: <COMBINED abbrevid=
63; COMBINED-NEXT: <COMBINED abbrevid=
64; COMBINED-NEXT: <COMBINED abbrevid=
65; COMBINED-NEXT: <COMBINED abbrevid=
66; COMBINED-NEXT: <COMBINED abbrevid=
67; COMBINED-NEXT: <COMBINED abbrevid=
Charles Saternos75da10d2017-08-04 16:00:58 +000068; COMBINED-NEXT: <COMBINED_PROFILE {{.*}} op6=[[HOT1:.*]] op7=3 op8=[[COLD:.*]] op9=1 op10=[[HOT2:.*]] op11=3 op12=[[NONE1:.*]] op13=2 op14=[[HOT3:.*]] op15=3 op16=[[NONE2:.*]] op17=2 op18=[[NONE3:.*]] op19=2/>
Piotr Padlewskid9830eb2016-09-26 20:37:32 +000069; COMBINED_NEXT: <COMBINED abbrevid=
70; COMBINED_NEXT: </GLOBALVAL_SUMMARY_BLOCK>
71
72
73; ModuleID = 'thinlto-function-summary-callgraph.ll'
74target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
75target triple = "x86_64-unknown-linux-gnu"
76
77; This function have high profile count, so entry block is hot.
78define void @hot_function(i1 %a, i1 %a2) !prof !20 {
79entry:
80 call void @hot1()
81 br i1 %a, label %Cold, label %Hot, !prof !41
82Cold: ; 1/1000 goes here
83 call void @cold()
84 call void @hot2()
Dehao Chen190f17c2017-03-21 17:22:35 +000085 call void @hot4(), !prof !15
Piotr Padlewskid9830eb2016-09-26 20:37:32 +000086 call void @none1()
87 br label %exit
88Hot: ; 999/1000 goes here
89 call void @hot2()
90 call void @hot3()
91 br i1 %a2, label %None1, label %None2, !prof !42
92None1: ; half goes here
93 call void @none1()
94 call void @none2()
95 br label %exit
96None2: ; half goes here
97 call void @none3()
98 br label %exit
99exit:
100 ret void
101}
102
103declare void @hot1() #1
104declare void @hot2() #1
105declare void @hot3() #1
Dehao Chen190f17c2017-03-21 17:22:35 +0000106declare void @hot4() #1
Piotr Padlewskid9830eb2016-09-26 20:37:32 +0000107declare void @cold() #1
108declare void @none1() #1
109declare void @none2() #1
110declare void @none3() #1
111
112
113!41 = !{!"branch_weights", i32 1, i32 1000}
114!42 = !{!"branch_weights", i32 1, i32 1}
115
116
117
118!llvm.module.flags = !{!1}
Dehao Chena60cdd32017-02-28 18:09:44 +0000119!20 = !{!"function_entry_count", i64 110, i64 123}
Piotr Padlewskid9830eb2016-09-26 20:37:32 +0000120
121!1 = !{i32 1, !"ProfileSummary", !2}
122!2 = !{!3, !4, !5, !6, !7, !8, !9, !10}
123!3 = !{!"ProfileFormat", !"InstrProf"}
124!4 = !{!"TotalCount", i64 10000}
125!5 = !{!"MaxCount", i64 10}
126!6 = !{!"MaxInternalCount", i64 1}
127!7 = !{!"MaxFunctionCount", i64 1000}
128!8 = !{!"NumCounts", i64 3}
129!9 = !{!"NumFunctions", i64 3}
130!10 = !{!"DetailedSummary", !11}
131!11 = !{!12, !13, !14}
132!12 = !{i32 10000, i64 100, i32 1}
133!13 = !{i32 999000, i64 100, i32 1}
134!14 = !{i32 999999, i64 1, i32 2}
Dehao Chen190f17c2017-03-21 17:22:35 +0000135!15 = !{!"branch_weights", i32 100}
Teresa Johnson08d5b4e2018-05-26 02:34:13 +0000136
137; DIS: ^0 = module: (path: "{{.*}}/test/Bitcode/Output/thinlto-function-summary-callgraph-profile-summary.ll.tmp.o", hash: (0, 0, 0, 0, 0))
138; DIS: ^1 = gv: (guid: 123)
139; DIS: ^2 = gv: (name: "none2") ; guid = 3741006263754194003
140; DIS: ^3 = gv: (name: "hot3") ; guid = 5026609803865204483
141; DIS: ^4 = gv: (name: "hot2") ; guid = 8117347573235780485
142; DIS: ^5 = gv: (name: "hot1") ; guid = 9453975128311291976
143; DIS: ^6 = gv: (name: "cold") ; guid = 11668175513417606517
144; DIS: ^7 = gv: (name: "hot4") ; guid = 13161834114071272798
145; DIS: ^8 = gv: (name: "none3") ; guid = 16213681105727317812
146; DIS: ^9 = gv: (name: "hot_function", summaries: (function: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 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
147; DIS: ^10 = gv: (name: "none1") ; guid = 17712061229457633252
148
149; COMBINED-DIS: ^0 = module: (path: "{{.*}}/test/Bitcode/Output/thinlto-function-summary-callgraph-profile-summary.ll.tmp.o", hash: (0, 0, 0, 0, 0))
150; COMBINED-DIS: ^1 = module: (path: "{{.*}}/test/Bitcode/Output/thinlto-function-summary-callgraph-profile-summary.ll.tmp2.o", hash: (0, 0, 0, 0, 0))
151; COMBINED-DIS: ^2 = gv: (guid: 3741006263754194003, summaries: (function: (module: ^1, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), insts: 1)))
152; COMBINED-DIS: ^3 = gv: (guid: 5026609803865204483, summaries: (function: (module: ^1, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), insts: 1)))
153; COMBINED-DIS: ^4 = gv: (guid: 8117347573235780485, summaries: (function: (module: ^1, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), insts: 1)))
154; COMBINED-DIS: ^5 = gv: (guid: 9453975128311291976, summaries: (function: (module: ^1, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), insts: 1)))
155; COMBINED-DIS: ^6 = gv: (guid: 11668175513417606517, summaries: (function: (module: ^1, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), insts: 1)))
156; COMBINED-DIS: ^7 = gv: (guid: 16213681105727317812, summaries: (function: (module: ^1, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), insts: 1)))
157; COMBINED-DIS: ^8 = gv: (guid: 17381606045411660303, summaries: (function: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 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)))))
158; COMBINED-DIS: ^9 = gv: (guid: 17712061229457633252, summaries: (function: (module: ^1, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), insts: 1)))