llvm.org GIT mirror llvm / c87493d
Add test coverage for new PM PGOOpt handling. Summary: This patch adds flags and tests to cover the PGOOpt handling logic in new PM. Reviewers: chandlerc, davide Reviewed By: chandlerc Subscribers: sanjoy, llvm-commits Differential Revision: https://reviews.llvm.org/D35807 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309076 91177308-0d34-0410-b5e6-96231b3b80d8 Dehao Chen 2 years ago
5 changed file(s) with 51 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
2828
2929 /// A struct capturing PGO tunables.
3030 struct PGOOptions {
31 std::string ProfileGenFile = "";
32 std::string ProfileUseFile = "";
33 std::string SampleProfileFile = "";
34 bool RunProfileGen = false;
31 PGOOptions(std::string ProfileGenFile = "", std::string ProfileUseFile = "",
32 std::string SampleProfileFile = "", bool RunProfileGen = false)
33 : ProfileGenFile(ProfileGenFile), ProfileUseFile(ProfileUseFile),
34 SampleProfileFile(SampleProfileFile), RunProfileGen(RunProfileGen) {}
35 std::string ProfileGenFile;
36 std::string ProfileUseFile;
37 std::string SampleProfileFile;
38 bool RunProfileGen;
3539 };
3640
3741 /// \brief This class provides access to building LLVM's passes.
0 ; RUN: opt -debug-pass-manager -passes='default' -pgo-kind=new-pm-pgo-instr-gen-pipeline -profile-file='temp' %s 2>&1 |FileCheck %s --check-prefixes=GEN
1 ; RUN: llvm-profdata merge %S/Inputs/new-pm-pgo.proftext -o %t.profdata
2 ; RUN: opt -debug-pass-manager -passes='default' -pgo-kind=new-pm-pgo-instr-use-pipeline -profile-file='%t.profdata' %s 2>&1 |FileCheck %s --check-prefixes=USE
3 ; RUN: opt -debug-pass-manager -passes='default' -pgo-kind=new-pm-pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-pgo.prof' %s 2>&1 |FileCheck %s --check-prefixes=SAMPLE_USE
4 ;
5 ; GEN: Running pass: PGOInstrumentationGen
6 ; USE: Running pass: PGOInstrumentationUse
7 ; SAMPLE_USE: Running pass: SampleProfileLoaderPass
8
9 define void @foo() {
10 ret void
11 }
8080 cl::desc("A textual description of the function pass pipeline inserted at "
8181 "the VectorizerStart extension point into default pipelines"),
8282 cl::Hidden);
83 enum PGOKind { NoPGO, InstrGen, InstrUse, SampleUse };
84 static cl::opt PGOKindFlag(
85 "pgo-kind", cl::init(NoPGO), cl::Hidden,
86 cl::desc("The kind of profile guided optimization"),
87 cl::values(clEnumValN(NoPGO, "nopgo", "Do not use PGO."),
88 clEnumValN(InstrGen, "new-pm-pgo-instr-gen-pipeline",
89 "Instrument the IR to generate profile."),
90 clEnumValN(InstrUse, "new-pm-pgo-instr-use-pipeline",
91 "Use instrumented profile to guide PGO."),
92 clEnumValN(SampleUse, "new-pm-pgo-sample-use-pipeline",
93 "Use sampled profile to guide PGO.")));
94 static cl::opt ProfileFile(
95 "profile-file", cl::desc("Path to the profile."), cl::Hidden);
8396 /// @}}
8497
8598 template
152165 bool ShouldPreserveBitcodeUseListOrder,
153166 bool EmitSummaryIndex, bool EmitModuleHash) {
154167 bool VerifyEachPass = VK == VK_VerifyEachPass;
155 PassBuilder PB(TM);
168
169 Optional P;
170 switch (PGOKindFlag) {
171 case InstrGen:
172 P = PGOOptions(ProfileFile, "", "", true);
173 break;
174 case InstrUse:
175 P = PGOOptions("", ProfileFile, "", false);
176 break;
177 case SampleUse:
178 P = PGOOptions("", "", ProfileFile, false);
179 break;
180 case NoPGO:
181 P = None;
182 }
183 PassBuilder PB(TM, P);
156184 registerEPCallbacks(PB, VerifyEachPass, DebugPM);
157185
158186 // Specially handle the alias analysis manager so that we can register