[llvm] b70f23f - [PGO][PGSO] Tune flags for profile guided size optimization.
Hiroshi Yamauchi via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 5 09:37:55 PST 2020
Author: Hiroshi Yamauchi
Date: 2020-02-05T09:37:32-08:00
New Revision: b70f23f5996d916f8ed4b870631a3b9075c12810
URL: https://github.com/llvm/llvm-project/commit/b70f23f5996d916f8ed4b870631a3b9075c12810
DIFF: https://github.com/llvm/llvm-project/commit/b70f23f5996d916f8ed4b870631a3b9075c12810.diff
LOG: [PGO][PGSO] Tune flags for profile guided size optimization.
Summary:
Tune the profile threshold flag value for instrumentation PGO based on internal
benchmarks.
Also, add flags to allow profile guided size optimizations for non-cold code
to be enabled separately for instrumentation and sample PGSO.
Neither changes the default behavior (yet) as it's disabled for non-cold code.
Reviewers: davidxl
Subscribers: hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D72937
Added:
Modified:
llvm/include/llvm/Transforms/Utils/SizeOpts.h
llvm/lib/Transforms/Utils/SizeOpts.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Transforms/Utils/SizeOpts.h b/llvm/include/llvm/Transforms/Utils/SizeOpts.h
index daead1443353..6e6ec6e109cc 100644
--- a/llvm/include/llvm/Transforms/Utils/SizeOpts.h
+++ b/llvm/include/llvm/Transforms/Utils/SizeOpts.h
@@ -21,6 +21,8 @@ extern llvm::cl::opt<bool> EnablePGSO;
extern llvm::cl::opt<bool> PGSOLargeWorkingSetSizeOnly;
extern llvm::cl::opt<bool> PGSOIRPassOrTestOnly;
extern llvm::cl::opt<bool> PGSOColdCodeOnly;
+extern llvm::cl::opt<bool> PGSOColdCodeOnlyForInstrPGO;
+extern llvm::cl::opt<bool> PGSOColdCodeOnlyForSamplePGO;
extern llvm::cl::opt<bool> ForcePGSO;
extern llvm::cl::opt<int> PgsoCutoffInstrProf;
extern llvm::cl::opt<int> PgsoCutoffSampleProf;
@@ -54,6 +56,8 @@ bool shouldFuncOptimizeForSizeImpl(const FuncT *F, ProfileSummaryInfo *PSI,
QueryType == PGSOQueryType::Test))
return false;
if (PGSOColdCodeOnly ||
+ (PSI->hasInstrumentationProfile() && PGSOColdCodeOnlyForInstrPGO) ||
+ (PSI->hasSampleProfile() && PGSOColdCodeOnlyForSamplePGO) ||
(PGSOLargeWorkingSetSizeOnly && !PSI->hasLargeWorkingSetSize())) {
// Even if the working set size isn't large, size-optimize cold code.
return AdapterT::isFunctionColdInCallGraph(F, PSI, *BFI);
@@ -78,6 +82,8 @@ bool shouldOptimizeForSizeImpl(BlockTOrBlockFreq BBOrBlockFreq, ProfileSummaryIn
QueryType == PGSOQueryType::Test))
return false;
if (PGSOColdCodeOnly ||
+ (PSI->hasInstrumentationProfile() && PGSOColdCodeOnlyForInstrPGO) ||
+ (PSI->hasSampleProfile() && PGSOColdCodeOnlyForSamplePGO) ||
(PGSOLargeWorkingSetSizeOnly && !PSI->hasLargeWorkingSetSize())) {
// Even if the working set size isn't large, size-optimize cold code.
return AdapterT::isColdBlock(BBOrBlockFreq, PSI, BFI);
diff --git a/llvm/lib/Transforms/Utils/SizeOpts.cpp b/llvm/lib/Transforms/Utils/SizeOpts.cpp
index a959cc6ce1a4..c25b6774b3fa 100644
--- a/llvm/lib/Transforms/Utils/SizeOpts.cpp
+++ b/llvm/lib/Transforms/Utils/SizeOpts.cpp
@@ -28,6 +28,16 @@ cl::opt<bool> PGSOColdCodeOnly(
cl::desc("Apply the profile guided size optimizations only "
"to cold code."));
+cl::opt<bool> PGSOColdCodeOnlyForInstrPGO(
+ "pgso-cold-code-only-for-instr-pgo", cl::Hidden, cl::init(true),
+ cl::desc("Apply the profile guided size optimizations only "
+ "to cold code under instrumentation PGO."));
+
+cl::opt<bool> PGSOColdCodeOnlyForSamplePGO(
+ "pgso-cold-code-only-for-sample-pgo", cl::Hidden, cl::init(true),
+ cl::desc("Apply the profile guided size optimizations only "
+ "to cold code under sample PGO."));
+
cl::opt<bool> PGSOIRPassOrTestOnly(
"pgso-ir-pass-or-test-only", cl::Hidden, cl::init(false),
cl::desc("Apply the profile guided size optimizations only"
@@ -38,7 +48,7 @@ cl::opt<bool> ForcePGSO(
cl::desc("Force the (profiled-guided) size optimizations. "));
cl::opt<int> PgsoCutoffInstrProf(
- "pgso-cutoff-instr-prof", cl::Hidden, cl::init(250000), cl::ZeroOrMore,
+ "pgso-cutoff-instr-prof", cl::Hidden, cl::init(950000), cl::ZeroOrMore,
cl::desc("The profile guided size optimization profile summary cutoff "
"for instrumentation profile."));
More information about the llvm-commits
mailing list