[PATCH] D22607: [Profile] Don't use the override API in all cases.

Jake VanAdrighem via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 20 20:31:50 PDT 2016


jakev created this revision.
jakev added reviewers: xur, davidxl, silvas.
jakev added a subscriber: llvm-commits.
jakev set the repository for this revision to rL LLVM.
Herald added a subscriber: mehdi_amini.

We shouldn't be using `__llvm_profile_override_default_filename` even when a profile output filename isn't specified. This patch uses a flag to enable IRPGO instead.

Repository:
  rL LLVM

https://reviews.llvm.org/D22607

Files:
  include/llvm/Transforms/IPO/PassManagerBuilder.h
  lib/Transforms/IPO/PassManagerBuilder.cpp
  test/Transforms/PGOProfile/preinline.ll

Index: test/Transforms/PGOProfile/preinline.ll
===================================================================
--- test/Transforms/PGOProfile/preinline.ll
+++ test/Transforms/PGOProfile/preinline.ll
@@ -1,4 +1,5 @@
-; RUN: opt < %s -O2 -profile-generate=default.profraw -S | FileCheck %s --check-prefix=GEN
+; RUN: opt < %s -O2 -profile-generate -S | FileCheck %s --check-prefix=GEN
+; RUN: opt < %s -O2 -profile-generate -profile-generate-file=default.profraw -S | FileCheck %s --check-prefix=GEN
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 
Index: lib/Transforms/IPO/PassManagerBuilder.cpp
===================================================================
--- lib/Transforms/IPO/PassManagerBuilder.cpp
+++ lib/Transforms/IPO/PassManagerBuilder.cpp
@@ -111,10 +111,13 @@
     "enable-loop-load-elim", cl::init(true), cl::Hidden,
     cl::desc("Enable the LoopLoadElimination Pass"));
 
-static cl::opt<std::string> 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<bool> RunPGOInstrGen(
+    "profile-generate", cl::init(false), cl::Hidden,
+    cl::desc("Enable PGO instrumentation."));
+
+static cl::opt<std::string>
+    PGOOutputFile("profile-generate-file", cl::init(""), cl::Hidden,
+                      cl::desc("Specify the path of profile data file."));
 
 static cl::opt<std::string> RunPGOInstrUse(
     "profile-use", cl::init(""), cl::Hidden, cl::value_desc("filename"),
@@ -152,7 +155,8 @@
     VerifyOutput = false;
     MergeFunctions = false;
     PrepareForLTO = false;
-    PGOInstrGen = RunPGOInstrGen;
+    EnablePGOInstrGen = RunPGOInstrGen;
+    PGOInstrGen = PGOOutputFile;
     PGOInstrUse = RunPGOInstrUse;
     PrepareForThinLTO = false;
     PerformThinLTO = false;
@@ -238,7 +242,7 @@
 
 // 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.
@@ -251,11 +255,12 @@
     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())
Index: include/llvm/Transforms/IPO/PassManagerBuilder.h
===================================================================
--- include/llvm/Transforms/IPO/PassManagerBuilder.h
+++ include/llvm/Transforms/IPO/PassManagerBuilder.h
@@ -138,6 +138,8 @@
   bool PrepareForThinLTO;
   bool PerformThinLTO;
 
+  /// Enable profile instrumentation pass.
+  bool EnablePGOInstrGen;
   /// Profile data file name that the instrumentation will be written to.
   std::string PGOInstrGen;
   /// Path of the profile data file.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22607.64805.patch
Type: text/x-patch
Size: 3381 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160721/6f7e60b9/attachment.bin>


More information about the llvm-commits mailing list