diff --git a/llvm/include/llvm/Transforms/Utils/SizeOpts.h b/llvm/include/llvm/Transforms/Utils/SizeOpts.h --- a/llvm/include/llvm/Transforms/Utils/SizeOpts.h +++ b/llvm/include/llvm/Transforms/Utils/SizeOpts.h @@ -21,6 +21,8 @@ extern llvm::cl::opt PGSOLargeWorkingSetSizeOnly; extern llvm::cl::opt PGSOIRPassOrTestOnly; extern llvm::cl::opt PGSOColdCodeOnly; +extern llvm::cl::opt PGSOColdCodeOnlyForInstrPGO; +extern llvm::cl::opt PGSOColdCodeOnlyForSamplePGO; extern llvm::cl::opt ForcePGSO; extern llvm::cl::opt PgsoCutoffInstrProf; extern llvm::cl::opt PgsoCutoffSampleProf; @@ -54,6 +56,8 @@ 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); @@ -79,6 +83,8 @@ 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(BB, PSI, BFI); diff --git a/llvm/lib/Transforms/Utils/SizeOpts.cpp b/llvm/lib/Transforms/Utils/SizeOpts.cpp --- a/llvm/lib/Transforms/Utils/SizeOpts.cpp +++ b/llvm/lib/Transforms/Utils/SizeOpts.cpp @@ -28,6 +28,16 @@ cl::desc("Apply the profile guided size optimizations only " "to cold code.")); +cl::opt 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 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 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::desc("Force the (profiled-guided) size optimizations. ")); cl::opt PgsoCutoffInstrProf( - "pgso-cutoff-instr-prof", cl::Hidden, cl::init(250000), cl::ZeroOrMore, + "pgso-cutoff-instr-prof", cl::Hidden, cl::init(990000), cl::ZeroOrMore, cl::desc("The profile guided size optimization profile summary cutoff " "for instrumentation profile."));