diff options
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r-- | llvm/lib/CodeGen/CodeGenPrepare.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index 359618d..eceee30 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -177,6 +177,17 @@ static cl::opt<bool> ProfileGuidedSectionPrefix( "profile-guided-section-prefix", cl::Hidden, cl::init(true), cl::ZeroOrMore, cl::desc("Use profile info to add section prefix for hot/cold functions")); +static cl::opt<bool> ProfileUnknownInSpecialSection( + "profile-unknown-in-special-section", cl::Hidden, cl::init(false), + cl::ZeroOrMore, + cl::desc("In profiling mode like sampleFDO, if a function doesn't have " + "profile, we cannot tell the function is cold for sure because " + "it may be a function newly added without ever being sampled. " + "With the flag enabled, compiler can put such profile unknown " + "functions into a special section, so runtime system can choose " + "to handle it in a different way than .text section, to save " + "RAM for example. ")); + static cl::opt<unsigned> FreqRatioToSkipMerge( "cgp-freq-ratio-to-skip-merge", cl::Hidden, cl::init(2), cl::desc("Skip merging empty blocks if (frequency of empty block) / " @@ -452,6 +463,9 @@ bool CodeGenPrepare::runOnFunction(Function &F) { F.setSectionPrefix(".hot"); else if (PSI->isFunctionColdInCallGraph(&F, *BFI)) F.setSectionPrefix(".unlikely"); + else if (ProfileUnknownInSpecialSection && PSI->hasPartialSampleProfile() && + PSI->isFunctionHotnessUnknown(F)) + F.setSectionPrefix(".unknown"); } /// This optimization identifies DIV instructions that can be |