From 92392454010a6d7ad090fbba785c288dfd81c416 Mon Sep 17 00:00:00 2001 From: Xinliang David Li Date: Sat, 23 Jul 2016 04:28:52 +0000 Subject: [Profile] Use explicit flag to enable IR PGO Patch by Jake VanAdrighem Differential Revision: http://reviews.llvm.org/D22607 llvm-svn: 276516 --- llvm/lib/Transforms/IPO/PassManagerBuilder.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'llvm/lib/Transforms') diff --git a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp index 5e93bb65609..ec3973ea66e 100644 --- a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp +++ b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp @@ -111,10 +111,13 @@ static cl::opt EnableLoopLoadElim( "enable-loop-load-elim", cl::init(true), cl::Hidden, cl::desc("Enable the LoopLoadElimination Pass")); -static cl::opt RunPGOInstrGen( - "profile-generate", cl::init(""), cl::Hidden, - cl::desc("Enable generation phase of PGO instrumentation and specify the " - "path of profile data file")); +static cl::opt RunPGOInstrGen( + "profile-generate", cl::init(false), cl::Hidden, + cl::desc("Enable PGO instrumentation.")); + +static cl::opt + PGOOutputFile("profile-generate-file", cl::init(""), cl::Hidden, + cl::desc("Specify the path of profile data file.")); static cl::opt RunPGOInstrUse( "profile-use", cl::init(""), cl::Hidden, cl::value_desc("filename"), @@ -156,7 +159,8 @@ PassManagerBuilder::PassManagerBuilder() { VerifyOutput = false; MergeFunctions = false; PrepareForLTO = false; - PGOInstrGen = RunPGOInstrGen; + EnablePGOInstrGen = RunPGOInstrGen; + PGOInstrGen = PGOOutputFile; PGOInstrUse = RunPGOInstrUse; PrepareForThinLTO = false; PerformThinLTO = false; @@ -243,7 +247,7 @@ void PassManagerBuilder::populateFunctionPassManager( // Do PGO instrumentation generation or use pass as the option specified. void PassManagerBuilder::addPGOInstrPasses(legacy::PassManagerBase &MPM) { - if (PGOInstrGen.empty() && PGOInstrUse.empty()) + if (!EnablePGOInstrGen && PGOInstrUse.empty()) return; // Perform the preinline and cleanup passes for O1 and above. // And avoid doing them if optimizing for size. @@ -256,11 +260,12 @@ void PassManagerBuilder::addPGOInstrPasses(legacy::PassManagerBase &MPM) { MPM.add(createInstructionCombiningPass()); // Combine silly seq's addExtensionsToPM(EP_Peephole, MPM); } - if (!PGOInstrGen.empty()) { + if (EnablePGOInstrGen) { MPM.add(createPGOInstrumentationGenLegacyPass()); // Add the profile lowering pass. InstrProfOptions Options; - Options.InstrProfileOutput = PGOInstrGen; + if (!PGOInstrGen.empty()) + Options.InstrProfileOutput = PGOInstrGen; MPM.add(createInstrProfilingLegacyPass(Options)); } if (!PGOInstrUse.empty()) -- cgit v1.2.3