[llvm] r281927 - Handle early inline for hot callsites that reside in the same basic block.
Dehao Chen via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 19 11:38:14 PDT 2016
Author: dehao
Date: Mon Sep 19 13:38:14 2016
New Revision: 281927
URL: http://llvm.org/viewvc/llvm-project?rev=281927&view=rev
Log:
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
Modified:
llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp
llvm/trunk/test/Transforms/SampleProfile/Inputs/einline.prof
llvm/trunk/test/Transforms/SampleProfile/early-inline.ll
Modified: llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp?rev=281927&r1=281926&r2=281927&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp Mon Sep 19 13:38:14 2016
@@ -638,15 +638,20 @@ bool SampleProfileLoader::inlineHotFunct
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);
Modified: llvm/trunk/test/Transforms/SampleProfile/Inputs/einline.prof
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SampleProfile/Inputs/einline.prof?rev=281927&r1=281926&r2=281927&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/SampleProfile/Inputs/einline.prof (original)
+++ llvm/trunk/test/Transforms/SampleProfile/Inputs/einline.prof Mon Sep 19 13:38:14 2016
@@ -1,3 +1,3 @@
_Z3foov:200:100
- 1: _Z3barv:100
+ 1: _Z3barv:0
3: _Z3barv:100
Modified: llvm/trunk/test/Transforms/SampleProfile/early-inline.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SampleProfile/early-inline.ll?rev=281927&r1=281926&r2=281927&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/SampleProfile/early-inline.ll (original)
+++ llvm/trunk/test/Transforms/SampleProfile/early-inline.ll Mon Sep 19 13:38:14 2016
@@ -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.
More information about the llvm-commits
mailing list