llvm.org GIT mirror llvm / 22cdd42
[PGO] Make pgo related options in opt more consistent. Currently we have pgo options defined in PassManagerBuilder.cpp only for instrument pgo, but not for sample pgo. We also have pgo options defined in NewPMDriver.cpp in opt only for new pass manager and for all kinds of pgo. They have some inconsistency. To make the options more consistent and make tests writing easier, the patch let old pass manager to share the same pgo options with new pass manager in opt, and removes the options in PassManagerBuilder.cpp. Differential Revision: https://reviews.llvm.org/D56749 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351392 91177308-0d34-0410-b5e6-96231b3b80d8 Wei Mi 7 months ago
7 changed file(s) with 49 addition(s) and 39 deletion(s). Raw diff Collapse all Expand all
106106 cl::opt EnableHotColdSplit("hot-cold-split", cl::init(false), cl::Hidden,
107107 cl::desc("Enable hot-cold splitting pass"));
108108
109
110 static cl::opt RunPGOInstrGen(
111 "profile-generate", cl::init(false), cl::Hidden,
112 cl::desc("Enable PGO instrumentation."));
113
114 static cl::opt
115 PGOOutputFile("profile-generate-file", cl::init(""), cl::Hidden,
116 cl::desc("Specify the path of profile data file."));
117
118 static cl::opt RunPGOInstrUse(
119 "profile-use", cl::init(""), cl::Hidden, cl::value_desc("filename"),
120 cl::desc("Enable use phase of PGO instrumentation and specify the path "
121 "of profile data file"));
122
123109 static cl::opt UseLoopVersioningLICM(
124110 "enable-loop-versioning-licm", cl::init(false), cl::Hidden,
125111 cl::desc("Enable the experimental Loop Versioning LICM pass"));
174160 VerifyOutput = false;
175161 MergeFunctions = false;
176162 PrepareForLTO = false;
177 EnablePGOInstrGen = RunPGOInstrGen;
178 PGOInstrGen = PGOOutputFile;
179 PGOInstrUse = RunPGOInstrUse;
163 EnablePGOInstrGen = false;
164 PGOInstrGen = false;
165 PGOInstrUse = "";
166 PGOSampleUse = "";
180167 PrepareForThinLTO = EnablePrepareForThinLTO;
181168 PerformThinLTO = false;
182169 DivergentTarget = false;
None ; 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
0 ; RUN: opt -debug-pass-manager -passes='default' -pgo-kind=pgo-instr-gen-pipeline -profile-file='temp' %s 2>&1 |FileCheck %s --check-prefixes=GEN
11 ; 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 \
2 ; RUN: opt -debug-pass-manager -passes='default' -pgo-kind=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=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-pgo.prof' %s 2>&1 \
44 ; RUN: |FileCheck %s --check-prefixes=SAMPLE_USE,SAMPLE_USE_O
5 ; RUN: opt -debug-pass-manager -passes='thinlto-pre-link' -pgo-kind=new-pm-pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-pgo.prof' %s 2>&1 \
5 ; RUN: opt -debug-pass-manager -passes='thinlto-pre-link' -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-pgo.prof' %s 2>&1 \
66 ; RUN: |FileCheck %s --check-prefixes=SAMPLE_USE,SAMPLE_USE_PRE_LINK
7 ; RUN: opt -debug-pass-manager -passes='thinlto' -pgo-kind=new-pm-pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-pgo.prof' %s 2>&1 \
7 ; RUN: opt -debug-pass-manager -passes='thinlto' -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-pgo.prof' %s 2>&1 \
88 ; RUN: |FileCheck %s --check-prefixes=SAMPLE_USE,SAMPLE_USE_POST_LINK
99 ; RUN: opt -debug-pass-manager -passes='default' -new-pm-debug-info-for-profiling %s 2>&1 |FileCheck %s --check-prefixes=SAMPLE_GEN
1010 ;
None ; RUN: opt < %s -O2 -profile-generate -S | FileCheck %s --check-prefix=GEN
1 ; RUN: opt < %s -O2 -profile-generate -profile-generate-file=default.profraw -S | FileCheck %s --check-prefix=GEN
0 ; RUN: opt < %s -O2 -pgo-kind=pgo-instr-gen-pipeline -S | FileCheck %s --check-prefix=GEN
1 ; RUN: opt < %s -O2 -pgo-kind=pgo-instr-gen-pipeline -profile-file=default.profraw -S | FileCheck %s --check-prefix=GEN
22 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
33 target triple = "x86_64-unknown-linux-gnu"
44
None ; RUN: opt < %s -passes='thinlto-pre-link' -pgo-kind=new-pm-pgo-sample-use-pipeline -profile-file=%S/Inputs/function_metadata.prof -S | FileCheck %s
1 ; RUN: opt < %s -passes='thinlto-pre-link' -pgo-kind=new-pm-pgo-sample-use-pipeline -profile-file=%S/Inputs/function_metadata.compact.afdo -S | FileCheck %s
0 ; RUN: opt < %s -passes='thinlto-pre-link' -pgo-kind=pgo-sample-use-pipeline -profile-file=%S/Inputs/function_metadata.prof -S | FileCheck %s
1 ; RUN: opt < %s -passes='thinlto-pre-link' -pgo-kind=pgo-sample-use-pipeline -profile-file=%S/Inputs/function_metadata.compact.afdo -S | FileCheck %s
22
33 ; Tests whether the functions in the inline stack are added to the
44 ; function_entry_count metadata.
100100 "the OptimizerLast extension point into default pipelines"),
101101 cl::Hidden);
102102
103 enum PGOKind { NoPGO, InstrGen, InstrUse, SampleUse };
104 static cl::opt PGOKindFlag(
105 "pgo-kind", cl::init(NoPGO), cl::Hidden,
106 cl::desc("The kind of profile guided optimization"),
107 cl::values(clEnumValN(NoPGO, "nopgo", "Do not use PGO."),
108 clEnumValN(InstrGen, "new-pm-pgo-instr-gen-pipeline",
109 "Instrument the IR to generate profile."),
110 clEnumValN(InstrUse, "new-pm-pgo-instr-use-pipeline",
111 "Use instrumented profile to guide PGO."),
112 clEnumValN(SampleUse, "new-pm-pgo-sample-use-pipeline",
113 "Use sampled profile to guide PGO.")));
114 static cl::opt ProfileFile(
115 "profile-file", cl::desc("Path to the profile."), cl::Hidden);
103 extern cl::opt PGOKindFlag;
104 extern cl::opt ProfileFile;
116105 static cl::opt
117106 ProfileRemappingFile("profile-remapping-file",
118107 cl::desc("Path to the profile remapping file."),
3939 VK_VerifyInAndOut,
4040 VK_VerifyEachPass
4141 };
42 enum PGOKind {
43 NoPGO,
44 InstrGen,
45 InstrUse,
46 SampleUse
47 };
4248 }
4349
4450 /// Driver function to run the new pass manager over a module.
274274 cl::desc("YAML output filename for pass remarks"),
275275 cl::value_desc("filename"));
276276
277 cl::opt
278 PGOKindFlag("pgo-kind", cl::init(NoPGO), cl::Hidden,
279 cl::desc("The kind of profile guided optimization"),
280 cl::values(clEnumValN(NoPGO, "nopgo", "Do not use PGO."),
281 clEnumValN(InstrGen, "pgo-instr-gen-pipeline",
282 "Instrument the IR to generate profile."),
283 clEnumValN(InstrUse, "pgo-instr-use-pipeline",
284 "Use instrumented profile to guide PGO."),
285 clEnumValN(SampleUse, "pgo-sample-use-pipeline",
286 "Use sampled profile to guide PGO.")));
287 cl::opt ProfileFile("profile-file",
288 cl::desc("Path to the profile."), cl::Hidden);
289
277290 class OptCustomPassManager : public legacy::PassManager {
278291 DebugifyStatsMap DIStatsMap;
279292
367380
368381 if (Coroutines)
369382 addCoroutinePassesToExtensionPoints(Builder);
383
384 switch (PGOKindFlag) {
385 case InstrGen:
386 Builder.EnablePGOInstrGen = true;
387 Builder.PGOInstrGen = ProfileFile;
388 break;
389 case InstrUse:
390 Builder.PGOInstrUse = ProfileFile;
391 break;
392 case SampleUse:
393 Builder.PGOSampleUse = ProfileFile;
394 break;
395 default:
396 break;
397 }
370398
371399 Builder.populateFunctionPassManager(FPM);
372400 Builder.populateModulePassManager(MPM);