summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDehao Chen <dehao@google.com>2016-09-19 18:38:14 +0000
committerDehao Chen <dehao@google.com>2016-09-19 18:38:14 +0000
commit20866ed57e7e6b8e93290a1baee36839f06c4222 (patch)
tree9bd82924575f5179759be543b7ca0f1bb90c945a
parent552d012b7e2de4b1163f449b406e8beb691577e1 (diff)
downloadbcm5719-llvm-20866ed57e7e6b8e93290a1baee36839f06c4222.tar.gz
bcm5719-llvm-20866ed57e7e6b8e93290a1baee36839f06c4222.zip
Handle early inline for hot callsites that reside in the same basic block.
Summary: Callsites in the same basic block should share the same hotness. This patch checks for the hottest callsite in the same basic block, and use the hotness for all callsites in that basic block for early inline decisions. It also fixes the test to add "-S" so theat the "CHECK-NOT" is actually checking the content. Reviewers: dnovillo Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D24734 llvm-svn: 281927
-rw-r--r--llvm/lib/Transforms/IPO/SampleProfile.cpp9
-rw-r--r--llvm/test/Transforms/SampleProfile/Inputs/einline.prof2
-rw-r--r--llvm/test/Transforms/SampleProfile/early-inline.ll2
3 files changed, 9 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp
index ad806addf6c..0594063f0c7 100644
--- a/llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -638,15 +638,20 @@ bool SampleProfileLoader::inlineHotFunctions(Function &F) {
bool LocalChanged = false;
SmallVector<Instruction *, 10> CIS;
for (auto &BB : F) {
+ bool Hot = false;
+ SmallVector<Instruction *, 10> Candidates;
for (auto &I : BB.getInstList()) {
const FunctionSamples *FS = nullptr;
if ((isa<CallInst>(I) || isa<InvokeInst>(I)) &&
(FS = findCalleeFunctionSamples(I))) {
-
+ Candidates.push_back(&I);
if (callsiteIsHot(Samples, FS))
- CIS.push_back(&I);
+ Hot = true;
}
}
+ if (Hot) {
+ CIS.insert(CIS.begin(), Candidates.begin(), Candidates.end());
+ }
}
for (auto I : CIS) {
InlineFunctionInfo IFI(nullptr, ACT ? &GetAssumptionCache : nullptr);
diff --git a/llvm/test/Transforms/SampleProfile/Inputs/einline.prof b/llvm/test/Transforms/SampleProfile/Inputs/einline.prof
index 425d6ce22c1..90f41d21ca3 100644
--- a/llvm/test/Transforms/SampleProfile/Inputs/einline.prof
+++ b/llvm/test/Transforms/SampleProfile/Inputs/einline.prof
@@ -1,3 +1,3 @@
_Z3foov:200:100
- 1: _Z3barv:100
+ 1: _Z3barv:0
3: _Z3barv:100
diff --git a/llvm/test/Transforms/SampleProfile/early-inline.ll b/llvm/test/Transforms/SampleProfile/early-inline.ll
index 1ec16119e52..6e55ab1eec7 100644
--- a/llvm/test/Transforms/SampleProfile/early-inline.ll
+++ b/llvm/test/Transforms/SampleProfile/early-inline.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -instcombine -sample-profile -sample-profile-file=%S/Inputs/einline.prof | FileCheck %s
+; RUN: opt < %s -instcombine -sample-profile -sample-profile-file=%S/Inputs/einline.prof -S | FileCheck %s
; Checks if both call and invoke can be inlined early if their inlined
; instances are hot in profile.
OpenPOWER on IntegriCloud