llvm.org GIT mirror llvm / 52e0b0d
[Profile] Use explicit flag to enable IR PGO Patch by Jake VanAdrighem Differential Revision: http://reviews.llvm.org/D22607 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276516 91177308-0d34-0410-b5e6-96231b3b80d8 Xinliang David Li 3 years ago
3 changed file(s) with 17 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
137137 bool PrepareForThinLTO;
138138 bool PerformThinLTO;
139139
140 /// Enable profile instrumentation pass.
141 bool EnablePGOInstrGen;
140142 /// Profile data file name that the instrumentation will be written to.
141143 std::string PGOInstrGen;
142144 /// Path of the profile data file.
110110 "enable-loop-load-elim", cl::init(true), cl::Hidden,
111111 cl::desc("Enable the LoopLoadElimination Pass"));
112112
113 static cl::opt RunPGOInstrGen(
114 "profile-generate", cl::init(""), cl::Hidden,
115 cl::desc("Enable generation phase of PGO instrumentation and specify the "
116 "path of profile data file"));
113 static cl::opt RunPGOInstrGen(
114 "profile-generate", cl::init(false), cl::Hidden,
115 cl::desc("Enable PGO instrumentation."));
116
117 static cl::opt
118 PGOOutputFile("profile-generate-file", cl::init(""), cl::Hidden,
119 cl::desc("Specify the path of profile data file."));
117120
118121 static cl::opt RunPGOInstrUse(
119122 "profile-use", cl::init(""), cl::Hidden, cl::value_desc("filename"),
155158 VerifyOutput = false;
156159 MergeFunctions = false;
157160 PrepareForLTO = false;
158 PGOInstrGen = RunPGOInstrGen;
161 EnablePGOInstrGen = RunPGOInstrGen;
162 PGOInstrGen = PGOOutputFile;
159163 PGOInstrUse = RunPGOInstrUse;
160164 PrepareForThinLTO = false;
161165 PerformThinLTO = false;
242246
243247 // Do PGO instrumentation generation or use pass as the option specified.
244248 void PassManagerBuilder::addPGOInstrPasses(legacy::PassManagerBase &MPM) {
245 if (PGOInstrGen.empty() && PGOInstrUse.empty())
249 if (!EnablePGOInstrGen && PGOInstrUse.empty())
246250 return;
247251 // Perform the preinline and cleanup passes for O1 and above.
248252 // And avoid doing them if optimizing for size.
255259 MPM.add(createInstructionCombiningPass()); // Combine silly seq's
256260 addExtensionsToPM(EP_Peephole, MPM);
257261 }
258 if (!PGOInstrGen.empty()) {
262 if (EnablePGOInstrGen) {
259263 MPM.add(createPGOInstrumentationGenLegacyPass());
260264 // Add the profile lowering pass.
261265 InstrProfOptions Options;
262 Options.InstrProfileOutput = PGOInstrGen;
266 if (!PGOInstrGen.empty())
267 Options.InstrProfileOutput = PGOInstrGen;
263268 MPM.add(createInstrProfilingLegacyPass(Options));
264269 }
265270 if (!PGOInstrUse.empty())
None ; RUN: opt < %s -O2 -profile-generate=default.profraw -S | FileCheck %s --check-prefix=GEN
0 ; 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
12 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
23 target triple = "x86_64-unknown-linux-gnu"
34