[llvm] c74026d - [HotColdSplit] Mark entire function cold when entry block is cold
Vedant Kumar via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 17 16:00:15 PST 2020
Author: Vedant Kumar
Date: 2020-02-17T15:57:50-08:00
New Revision: c74026daf36a2b8a21ccae8736772269c6467a6f
URL: https://github.com/llvm/llvm-project/commit/c74026daf36a2b8a21ccae8736772269c6467a6f
DIFF: https://github.com/llvm/llvm-project/commit/c74026daf36a2b8a21ccae8736772269c6467a6f.diff
LOG: [HotColdSplit] Mark entire function cold when entry block is cold
rdar://58855712
Added:
Modified:
llvm/lib/Transforms/IPO/HotColdSplitting.cpp
llvm/test/Transforms/HotColdSplit/X86/do-not-split.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp
index 5e690714bfdf..5fa89e2bfce3 100644
--- a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp
+++ b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp
@@ -458,6 +458,10 @@ class OutliningRegion {
// first have predecessors within the extraction region.
if (mayExtractBlock(SinkBB)) {
addBlockToRegion(&SinkBB, SinkScore);
+ if (pred_empty(&SinkBB)) {
+ ColdRegion->EntireFunctionCold = true;
+ return Regions;
+ }
} else {
Regions.emplace_back();
ColdRegion = &Regions.back();
diff --git a/llvm/test/Transforms/HotColdSplit/X86/do-not-split.ll b/llvm/test/Transforms/HotColdSplit/X86/do-not-split.ll
index 076174d0a05e..21cd099ac703 100644
--- a/llvm/test/Transforms/HotColdSplit/X86/do-not-split.ll
+++ b/llvm/test/Transforms/HotColdSplit/X86/do-not-split.ll
@@ -50,6 +50,16 @@ if.end: ; preds = %entry
ret void
}
+; Make sure we don't try to outline the entire function, especially when the
+; entry block is cold.
+; CHECK: define void @cold_entry_block() [[COLD_ATTR:#[0-9]+]]
+; CHECK-NOT: cold_entry_block.cold.1
+define void @cold_entry_block() {
+entry:
+ call void @sink()
+ ret void
+}
+
; Do not split `noinline` functions.
; CHECK-LABEL: @noinline_func
; CHECK-NOT: noinline_func.cold.1
@@ -182,6 +192,8 @@ if.end: ; preds = %entry
ret void
}
+; CHECK: attributes [[COLD_ATTR]] = { {{.*}}cold
+
declare void @llvm.dbg.value(metadata, metadata, metadata)
declare void @sink() cold
More information about the llvm-commits
mailing list