blob: 31c99c189ac014ae85e6bd850b9421b2d4ddef36 [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
Teresa Johnson63ee0e72018-06-26 13:56:49 +00009
10; Check assembled summary.
11; RUN: llvm-dis %t.o.bc -o - | FileCheck %s --check-prefix=DIS
Teresa Johnson08d5b4e2018-05-26 02:34:13 +000012
Piotr Padlewskid9830eb2016-09-26 20:37:32 +000013; RUN: opt -module-summary %p/Inputs/thinlto-function-summary-callgraph-profile-summary.ll -o %t2.o
14; RUN: llvm-lto -thinlto -o %t3 %t.o %t2.o
15; RUN: llvm-bcanalyzer -dump %t3.thinlto.bc | FileCheck %s --check-prefix=COMBINED
Teresa Johnson08d5b4e2018-05-26 02:34:13 +000016; RUN: llvm-dis %t3.thinlto.bc
17; RUN: cat %t3.thinlto.ll | FileCheck %s --check-prefix=COMBINED-DIS
Teresa Johnson63ee0e72018-06-26 13:56:49 +000018; Round trip it through llvm-as
19; RUN: cat %t3.thinlto.ll | llvm-as -o - | llvm-dis -o - | FileCheck %s --check-prefix=COMBINED-DIS
Teresa Johnson08d5b4e2018-05-26 02:34:13 +000020
21; Make sure the assembler doesn't error when parsing the combined summary
22; RUN: llvm-as %t3.thinlto.ll -o %t3.thinlto.o
Teresa Johnson63ee0e72018-06-26 13:56:49 +000023
24; Check assembled combined summary.
25; RUN: llvm-dis %t3.thinlto.o -o - | FileCheck %s --check-prefix=COMBINED-DIS
Piotr Padlewskid9830eb2016-09-26 20:37:32 +000026
27
Peter Collingbournea0f371a2017-04-17 17:51:36 +000028; CHECK: <SOURCE_FILENAME
29; "hot_function"
30; CHECK-NEXT: <FUNCTION op0=0 op1=12
31; "hot1"
32; CHECK-NEXT: <FUNCTION op0=12 op1=4
33; "hot2"
34; CHECK-NEXT: <FUNCTION op0=16 op1=4
35; "hot3"
36; CHECK-NEXT: <FUNCTION op0=20 op1=4
37; "hot4"
38; CHECK-NEXT: <FUNCTION op0=24 op1=4
39; "cold"
40; CHECK-NEXT: <FUNCTION op0=28 op1=4
41; "none1"
42; CHECK-NEXT: <FUNCTION op0=32 op1=5
43; "none2"
44; CHECK-NEXT: <FUNCTION op0=37 op1=5
45; "none3"
46; CHECK-NEXT: <FUNCTION op0=42 op1=5
Piotr Padlewskid9830eb2016-09-26 20:37:32 +000047; CHECK-LABEL: <GLOBALVAL_SUMMARY_BLOCK
48; CHECK-NEXT: <VERSION
Peter Collingbournea0f371a2017-04-17 17:51:36 +000049; CHECK-NEXT: <VALUE_GUID op0=25 op1=123/>
50; op4=hot1 op6=cold op8=hot2 op10=hot4 op12=none1 op14=hot3 op16=none2 op18=none3 op20=123
Eugene Leviantbf46e742018-11-16 07:08:00 +000051; 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/>
Piotr Padlewskid9830eb2016-09-26 20:37:32 +000052; CHECK-NEXT: </GLOBALVAL_SUMMARY_BLOCK>
Peter Collingbournea0f371a2017-04-17 17:51:36 +000053
54; CHECK: <STRTAB_BLOCK
Peter Collingbourne92648c22017-06-27 23:50:11 +000055; CHECK-NEXT: blob data = 'hot_functionhot1hot2hot3hot4coldnone1none2none3{{.*}}'
Piotr Padlewskid9830eb2016-09-26 20:37:32 +000056
57; COMBINED: <GLOBALVAL_SUMMARY_BLOCK
58; COMBINED-NEXT: <VERSION
Teresa Johnsonf3681012018-02-07 04:05:59 +000059; COMBINED-NEXT: <FLAGS
Peter Collingbournea0f371a2017-04-17 17:51:36 +000060; COMBINED-NEXT: <VALUE_GUID
61; COMBINED-NEXT: <VALUE_GUID
62; COMBINED-NEXT: <VALUE_GUID
63; COMBINED-NEXT: <VALUE_GUID
64; COMBINED-NEXT: <VALUE_GUID
65; COMBINED-NEXT: <VALUE_GUID
66; COMBINED-NEXT: <VALUE_GUID
67; COMBINED-NEXT: <VALUE_GUID
Piotr Padlewskid9830eb2016-09-26 20:37:32 +000068; COMBINED-NEXT: <COMBINED abbrevid=
69; COMBINED-NEXT: <COMBINED abbrevid=
70; COMBINED-NEXT: <COMBINED abbrevid=
71; COMBINED-NEXT: <COMBINED abbrevid=
72; COMBINED-NEXT: <COMBINED abbrevid=
73; COMBINED-NEXT: <COMBINED abbrevid=
Easwaran Raman5a7056f2018-12-13 19:54:27 +000074; 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/>
Piotr Padlewskid9830eb2016-09-26 20:37:32 +000075; COMBINED_NEXT: <COMBINED abbrevid=
76; COMBINED_NEXT: </GLOBALVAL_SUMMARY_BLOCK>
77
78
79; ModuleID = 'thinlto-function-summary-callgraph.ll'
80target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
81target triple = "x86_64-unknown-linux-gnu"
82
83; This function have high profile count, so entry block is hot.
84define void @hot_function(i1 %a, i1 %a2) !prof !20 {
85entry:
86 call void @hot1()
87 br i1 %a, label %Cold, label %Hot, !prof !41
88Cold: ; 1/1000 goes here
89 call void @cold()
90 call void @hot2()
Dehao Chen190f17c2017-03-21 17:22:35 +000091 call void @hot4(), !prof !15
Piotr Padlewskid9830eb2016-09-26 20:37:32 +000092 call void @none1()
93 br label %exit
94Hot: ; 999/1000 goes here
95 call void @hot2()
96 call void @hot3()
97 br i1 %a2, label %None1, label %None2, !prof !42
98None1: ; half goes here
99 call void @none1()
100 call void @none2()
101 br label %exit
102None2: ; half goes here
103 call void @none3()
104 br label %exit
105exit:
106 ret void
107}
108
109declare void @hot1() #1
110declare void @hot2() #1
111declare void @hot3() #1
Dehao Chen190f17c2017-03-21 17:22:35 +0000112declare void @hot4() #1
Piotr Padlewskid9830eb2016-09-26 20:37:32 +0000113declare void @cold() #1
114declare void @none1() #1
115declare void @none2() #1
116declare void @none3() #1
117
118
119!41 = !{!"branch_weights", i32 1, i32 1000}
120!42 = !{!"branch_weights", i32 1, i32 1}
121
122
123
124!llvm.module.flags = !{!1}
Dehao Chena60cdd32017-02-28 18:09:44 +0000125!20 = !{!"function_entry_count", i64 110, i64 123}
Piotr Padlewskid9830eb2016-09-26 20:37:32 +0000126
127!1 = !{i32 1, !"ProfileSummary", !2}
128!2 = !{!3, !4, !5, !6, !7, !8, !9, !10}
129!3 = !{!"ProfileFormat", !"InstrProf"}
130!4 = !{!"TotalCount", i64 10000}
131!5 = !{!"MaxCount", i64 10}
132!6 = !{!"MaxInternalCount", i64 1}
133!7 = !{!"MaxFunctionCount", i64 1000}
134!8 = !{!"NumCounts", i64 3}
135!9 = !{!"NumFunctions", i64 3}
136!10 = !{!"DetailedSummary", !11}
137!11 = !{!12, !13, !14}
138!12 = !{i32 10000, i64 100, i32 1}
139!13 = !{i32 999000, i64 100, i32 1}
140!14 = !{i32 999999, i64 1, i32 2}
Dehao Chen190f17c2017-03-21 17:22:35 +0000141!15 = !{!"branch_weights", i32 100}
Teresa Johnson08d5b4e2018-05-26 02:34:13 +0000142
Teresa Johnson63ee0e72018-06-26 13:56:49 +0000143; DIS: ^0 = module: (path: "{{.*}}thinlto-function-summary-callgraph-profile-summary.ll.tmp.o{{.*}}", hash: (0, 0, 0, 0, 0))
Teresa Johnson08d5b4e2018-05-26 02:34:13 +0000144; DIS: ^1 = gv: (guid: 123)
145; DIS: ^2 = gv: (name: "none2") ; guid = 3741006263754194003
146; DIS: ^3 = gv: (name: "hot3") ; guid = 5026609803865204483
147; DIS: ^4 = gv: (name: "hot2") ; guid = 8117347573235780485
148; DIS: ^5 = gv: (name: "hot1") ; guid = 9453975128311291976
149; DIS: ^6 = gv: (name: "cold") ; guid = 11668175513417606517
150; DIS: ^7 = gv: (name: "hot4") ; guid = 13161834114071272798
151; DIS: ^8 = gv: (name: "none3") ; guid = 16213681105727317812
152; 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
153; DIS: ^10 = gv: (name: "none1") ; guid = 17712061229457633252
154
Teresa Johnsonfb89e7a2018-05-26 03:50:29 +0000155; COMBINED-DIS: ^0 = module: (path: "{{.*}}thinlto-function-summary-callgraph-profile-summary.ll.tmp.o", hash: (0, 0, 0, 0, 0))
156; COMBINED-DIS: ^1 = module: (path: "{{.*}}thinlto-function-summary-callgraph-profile-summary.ll.tmp2.o", hash: (0, 0, 0, 0, 0))
Teresa Johnson08d5b4e2018-05-26 02:34:13 +0000157; COMBINED-DIS: ^2 = gv: (guid: 3741006263754194003, summaries: (function: (module: ^1, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), insts: 1)))
158; COMBINED-DIS: ^3 = gv: (guid: 5026609803865204483, summaries: (function: (module: ^1, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), insts: 1)))
159; COMBINED-DIS: ^4 = gv: (guid: 8117347573235780485, summaries: (function: (module: ^1, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), insts: 1)))
160; COMBINED-DIS: ^5 = gv: (guid: 9453975128311291976, summaries: (function: (module: ^1, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), insts: 1)))
161; COMBINED-DIS: ^6 = gv: (guid: 11668175513417606517, summaries: (function: (module: ^1, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), insts: 1)))
162; COMBINED-DIS: ^7 = gv: (guid: 16213681105727317812, summaries: (function: (module: ^1, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), insts: 1)))
163; 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)))))
164; COMBINED-DIS: ^9 = gv: (guid: 17712061229457633252, summaries: (function: (module: ^1, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), insts: 1)))