summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2019-02-07 17:50:35 +0000
committerTeresa Johnson <tejohnson@google.com>2019-02-07 17:50:35 +0000
commitc36c10ddfb3dc07129b9f3973029d17940f6a45f (patch)
treebe5d43bf0cd4a839694ceafe7abfe6e58418edbd /llvm/lib/Transforms/IPO
parent2d4b186844ab56768165240f2cc32b7cec53bf02 (diff)
downloadbcm5719-llvm-c36c10ddfb3dc07129b9f3973029d17940f6a45f.tar.gz
bcm5719-llvm-c36c10ddfb3dc07129b9f3973029d17940f6a45f.zip
[HotColdSplit] With PGO add profile entry metadata to split cold function
Summary: When compiling with profile data, ensure the split cold function gets cold function_entry_count metadata (just use 0 since it should be cold). Otherwise with function sections it will not be placed in the unlikely text section with other cold code. Reviewers: vsk Subscribers: sebpop, hiraditya, davidxl, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D57900 llvm-svn: 353434
Diffstat (limited to 'llvm/lib/Transforms/IPO')
-rw-r--r--llvm/lib/Transforms/IPO/HotColdSplitting.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp
index 65e7938720d..648e2aed758 100644
--- a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp
+++ b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp
@@ -144,8 +144,10 @@ static bool mayExtractBlock(const BasicBlock &BB) {
}
/// Mark \p F cold. Based on this assumption, also optimize it for minimum size.
+/// If \p UpdateEntryCount is true (set when this is a new split function and
+/// module has profile data), set entry count to 0 to ensure treated as cold.
/// Return true if the function is changed.
-static bool markFunctionCold(Function &F) {
+static bool markFunctionCold(Function &F, bool UpdateEntryCount = false) {
assert(!F.hasFnAttribute(Attribute::OptimizeNone) && "Can't mark this cold");
bool Changed = false;
if (!F.hasFnAttribute(Attribute::Cold)) {
@@ -156,6 +158,13 @@ static bool markFunctionCold(Function &F) {
F.addFnAttr(Attribute::MinSize);
Changed = true;
}
+ if (UpdateEntryCount) {
+ // Set the entry count to 0 to ensure it is placed in the unlikely text
+ // section when function sections are enabled.
+ F.setEntryCount(0);
+ Changed = true;
+ }
+
return Changed;
}
@@ -340,7 +349,7 @@ Function *HotColdSplitting::extractColdRegion(const BlockSequence &Region,
}
CI->setIsNoInline();
- markFunctionCold(*OutF);
+ markFunctionCold(*OutF, BFI != nullptr);
LLVM_DEBUG(llvm::dbgs() << "Outlined Region: " << *OutF);
ORE.emit([&]() {
OpenPOWER on IntegriCloud