Skip to content

Commit

Permalink
Revert D84057 "[PGO][PGSO] Remove a temporary flag used for gradual r…
Browse files Browse the repository at this point in the history
…ollout."

This reverts commit e64afef. It caused
a PGO bootstrapped clang to crash on many source files.

`__llvm_profile_instrument_range` seems to trigger a null pointer dereference.

Call stack:
__llvm_profile_instrument_range
llvm::APInt::udiv(llvm::APInt const&) const
getRangeForAffineARHelper
  • Loading branch information
MaskRay committed Jul 22, 2020
1 parent ae35c09 commit dbdda82
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions llvm/include/llvm/Transforms/Utils/SizeOpts.h
Expand Up @@ -19,6 +19,7 @@

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;
Expand Down Expand Up @@ -59,6 +60,11 @@ bool shouldFuncOptimizeForSizeImpl(const FuncT *F, ProfileSummaryInfo *PSI,
return true;
if (!EnablePGSO)
return false;
// Temporarily enable size optimizations only for the IR pass or test query
// sites for gradual commit/rollout. This is to be removed later.
if (PGSOIRPassOrTestOnly && !(QueryType == PGSOQueryType::IRPass ||
QueryType == PGSOQueryType::Test))
return false;
if (isPGSOColdCodeOnly(PSI))
return AdapterT::isFunctionColdInCallGraph(F, PSI, *BFI);
if (PSI->hasSampleProfile())
Expand All @@ -79,6 +85,11 @@ bool shouldOptimizeForSizeImpl(BlockTOrBlockFreq BBOrBlockFreq, ProfileSummaryIn
return true;
if (!EnablePGSO)
return false;
// Temporarily enable size optimizations only for the IR pass or test query
// sites for gradual commit/rollout. This is to be removed later.
if (PGSOIRPassOrTestOnly && !(QueryType == PGSOQueryType::IRPass ||
QueryType == PGSOQueryType::Test))
return false;
if (isPGSOColdCodeOnly(PSI))
return AdapterT::isColdBlock(BBOrBlockFreq, PSI, BFI);
if (PSI->hasSampleProfile())
Expand Down
5 changes: 5 additions & 0 deletions llvm/lib/Transforms/Utils/SizeOpts.cpp
Expand Up @@ -43,6 +43,11 @@ cl::opt<bool> PGSOColdCodeOnlyForPartialSamplePGO(
cl::desc("Apply the profile guided size optimizations only "
"to cold code under partial-profile 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"
"to the IR passes or tests."));

cl::opt<bool> ForcePGSO(
"force-pgso", cl::Hidden, cl::init(false),
cl::desc("Force the (profiled-guided) size optimizations. "));
Expand Down

0 comments on commit dbdda82

Please sign in to comment.