diff options
Diffstat (limited to 'llvm/tools/opt')
| -rw-r--r-- | llvm/tools/opt/NewPMDriver.cpp | 15 | ||||
| -rw-r--r-- | llvm/tools/opt/NewPMDriver.h | 6 | ||||
| -rw-r--r-- | llvm/tools/opt/opt.cpp | 28 |
3 files changed, 36 insertions, 13 deletions
diff --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp index 211a3b151fe..f16981296d0 100644 --- a/llvm/tools/opt/NewPMDriver.cpp +++ b/llvm/tools/opt/NewPMDriver.cpp @@ -101,19 +101,8 @@ static cl::opt<std::string> OptimizerLastEPPipeline( "the OptimizerLast extension point into default pipelines"), cl::Hidden); -enum PGOKind { NoPGO, InstrGen, InstrUse, SampleUse }; -static cl::opt<PGOKind> PGOKindFlag( - "pgo-kind", cl::init(NoPGO), cl::Hidden, - cl::desc("The kind of profile guided optimization"), - cl::values(clEnumValN(NoPGO, "nopgo", "Do not use PGO."), - clEnumValN(InstrGen, "new-pm-pgo-instr-gen-pipeline", - "Instrument the IR to generate profile."), - clEnumValN(InstrUse, "new-pm-pgo-instr-use-pipeline", - "Use instrumented profile to guide PGO."), - clEnumValN(SampleUse, "new-pm-pgo-sample-use-pipeline", - "Use sampled profile to guide PGO."))); -static cl::opt<std::string> ProfileFile( - "profile-file", cl::desc("Path to the profile."), cl::Hidden); +extern cl::opt<PGOKind> PGOKindFlag; +extern cl::opt<std::string> ProfileFile; static cl::opt<std::string> ProfileRemappingFile("profile-remapping-file", cl::desc("Path to the profile remapping file."), diff --git a/llvm/tools/opt/NewPMDriver.h b/llvm/tools/opt/NewPMDriver.h index 7d74a5777d1..5f294fec6f8 100644 --- a/llvm/tools/opt/NewPMDriver.h +++ b/llvm/tools/opt/NewPMDriver.h @@ -40,6 +40,12 @@ enum VerifierKind { VK_VerifyInAndOut, VK_VerifyEachPass }; +enum PGOKind { + NoPGO, + InstrGen, + InstrUse, + SampleUse +}; } /// Driver function to run the new pass manager over a module. diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp index a4967a234d9..21f28c7a621 100644 --- a/llvm/tools/opt/opt.cpp +++ b/llvm/tools/opt/opt.cpp @@ -275,6 +275,19 @@ static cl::opt<std::string> cl::desc("YAML output filename for pass remarks"), cl::value_desc("filename")); +cl::opt<PGOKind> + PGOKindFlag("pgo-kind", cl::init(NoPGO), cl::Hidden, + cl::desc("The kind of profile guided optimization"), + cl::values(clEnumValN(NoPGO, "nopgo", "Do not use PGO."), + clEnumValN(InstrGen, "pgo-instr-gen-pipeline", + "Instrument the IR to generate profile."), + clEnumValN(InstrUse, "pgo-instr-use-pipeline", + "Use instrumented profile to guide PGO."), + clEnumValN(SampleUse, "pgo-sample-use-pipeline", + "Use sampled profile to guide PGO."))); +cl::opt<std::string> ProfileFile("profile-file", + cl::desc("Path to the profile."), cl::Hidden); + class OptCustomPassManager : public legacy::PassManager { DebugifyStatsMap DIStatsMap; @@ -369,6 +382,21 @@ static void AddOptimizationPasses(legacy::PassManagerBase &MPM, if (Coroutines) addCoroutinePassesToExtensionPoints(Builder); + switch (PGOKindFlag) { + case InstrGen: + Builder.EnablePGOInstrGen = true; + Builder.PGOInstrGen = ProfileFile; + break; + case InstrUse: + Builder.PGOInstrUse = ProfileFile; + break; + case SampleUse: + Builder.PGOSampleUse = ProfileFile; + break; + default: + break; + } + Builder.populateFunctionPassManager(FPM); Builder.populateModulePassManager(MPM); } |

