[PATCH] D35807: Add test coverage for new PM PGOOpt handling.
Dehao Chen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 25 15:27:49 PDT 2017
danielcdh updated this revision to Diff 108167.
danielcdh marked an inline comment as done.
danielcdh added a comment.
update
https://reviews.llvm.org/D35807
Files:
include/llvm/Passes/PassBuilder.h
test/Other/Inputs/new-pm-pgo.prof
test/Other/Inputs/new-pm-pgo.proftext
test/Other/new-pm-pgo.ll
tools/opt/NewPMDriver.cpp
Index: tools/opt/NewPMDriver.cpp
===================================================================
--- tools/opt/NewPMDriver.cpp
+++ tools/opt/NewPMDriver.cpp
@@ -81,6 +81,18 @@
cl::desc("A textual description of the function pass pipeline inserted at "
"the VectorizerStart extension point into default pipelines"),
cl::Hidden);
+static cl::opt<std::string> PGOInstrGen(
+ "pgo-gen", cl::desc("Path to the instrumented profile. If set, "
+ "enable PGO instrumentation."),
+ cl::Hidden);
+static cl::opt<std::string> PGOInstrUse(
+ "pgo-use", cl::desc("Path to the instrumented profile. If set, "
+ "enable PGO optimization."),
+ cl::Hidden);
+static cl::opt<std::string> PGOSampleUse(
+ "pgo-sample-use", cl::desc("Path to the sample profile. If set, enable "
+ "SamplePGO optimization."),
+ cl::Hidden);
/// @}}
template <typename PassManagerT>
@@ -153,7 +165,17 @@
bool ShouldPreserveBitcodeUseListOrder,
bool EmitSummaryIndex, bool EmitModuleHash) {
bool VerifyEachPass = VK == VK_VerifyEachPass;
- PassBuilder PB(TM);
+ int NumPGOOptions = (PGOInstrGen.empty() ? 0 : 1) +
+ (PGOInstrUse.empty() ? 0 : 1) +
+ (PGOSampleUse.empty() ? 0 : 1);
+ assert(NumPGOOptions <2 &&
+ "Only one of -pgo-gen,-pgo-use,-pgo-sample-use can be "
+ "specified");
+ Optional<PGOOptions> P;
+ if (NumPGOOptions)
+ P = PGOOptions(PGOInstrGen, PGOInstrUse, PGOSampleUse,
+ !PGOInstrGen.empty());
+ PassBuilder PB(TM, P);
registerEPCallbacks(PB, VerifyEachPass, DebugPM);
// Specially handle the alias analysis manager so that we can register
Index: test/Other/new-pm-pgo.ll
===================================================================
--- /dev/null
+++ test/Other/new-pm-pgo.ll
@@ -0,0 +1,12 @@
+; RUN: opt -debug-pass-manager -passes='default<O2>' -pgo-gen='temp' %s 2>&1 |FileCheck %s --check-prefixes=GEN
+; RUN: llvm-profdata merge %S/Inputs/new-pm-pgo.proftext -o %t.profdata
+; RUN: opt -debug-pass-manager -passes='default<O2>' -pgo-use='%t.profdata' %s 2>&1 |FileCheck %s --check-prefixes=USE
+; RUN: opt -debug-pass-manager -passes='default<O2>' -pgo-sample-use='%S/Inputs/new-pm-pgo.prof' %s 2>&1 |FileCheck %s --check-prefixes=SAMPLE_USE
+;
+; GEN: Running pass: PGOInstrumentationGen
+; USE: Running pass: PGOInstrumentationUse
+; SAMPLE_USE: Running pass: SampleProfileLoaderPass
+
+define void @foo() {
+ ret void
+}
Index: test/Other/Inputs/new-pm-pgo.proftext
===================================================================
--- /dev/null
+++ test/Other/Inputs/new-pm-pgo.proftext
@@ -0,0 +1 @@
+:ir
Index: test/Other/Inputs/new-pm-pgo.prof
===================================================================
--- /dev/null
+++ test/Other/Inputs/new-pm-pgo.prof
@@ -0,0 +1 @@
+foo:0:0
Index: include/llvm/Passes/PassBuilder.h
===================================================================
--- include/llvm/Passes/PassBuilder.h
+++ include/llvm/Passes/PassBuilder.h
@@ -29,10 +29,14 @@
/// A struct capturing PGO tunables.
struct PGOOptions {
- std::string ProfileGenFile = "";
- std::string ProfileUseFile = "";
- std::string SampleProfileFile = "";
- bool RunProfileGen = false;
+ PGOOptions(std::string ProfileGenFile = "", std::string ProfileUseFile = "",
+ std::string SampleProfileFile = "", bool RunProfileGen = false)
+ : ProfileGenFile(ProfileGenFile), ProfileUseFile(ProfileUseFile),
+ SampleProfileFile(SampleProfileFile), RunProfileGen(RunProfileGen) {}
+ std::string ProfileGenFile;
+ std::string ProfileUseFile;
+ std::string SampleProfileFile;
+ bool RunProfileGen;
};
/// \brief This class provides access to building LLVM's passes.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35807.108167.patch
Type: text/x-patch
Size: 3877 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170725/d4a6e298/attachment.bin>
More information about the llvm-commits
mailing list