summaryrefslogtreecommitdiffstats
path: root/llvm/tools/opt/opt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/opt/opt.cpp')
-rw-r--r--llvm/tools/opt/opt.cpp28
1 files changed, 28 insertions, 0 deletions
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);
}
OpenPOWER on IntegriCloud