[PATCH] D124898: [BOLT][NFC] Minor cleanup in ICP getCallTargets and canPromoteCallsite
Amir Ayupov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 4 14:07:05 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2ad1c7540eb0: [BOLT][NFC] Minor cleanup in ICP getCallTargets and canPromoteCallsite (authored by Amir).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D124898/new/
https://reviews.llvm.org/D124898
Files:
bolt/lib/Passes/IndirectCallPromotion.cpp
Index: bolt/lib/Passes/IndirectCallPromotion.cpp
===================================================================
--- bolt/lib/Passes/IndirectCallPromotion.cpp
+++ bolt/lib/Passes/IndirectCallPromotion.cpp
@@ -206,7 +206,7 @@
IndirectCallPromotion::getCallTargets(BinaryBasicBlock &BB,
const MCInst &Inst) const {
BinaryFunction &BF = *BB.getFunction();
- BinaryContext &BC = BF.getBinaryContext();
+ const BinaryContext &BC = BF.getBinaryContext();
std::vector<Callsite> Targets;
if (const JumpTable *JT = BF.getJumpTable(Inst)) {
@@ -512,6 +512,7 @@
return SymTargets;
}
+ // Use memory profile to select hot targets.
JumpTableInfoType HotTargets =
maybeGetHotJumpTableTargets(BB, CallInst, TargetFetchInst, JT);
@@ -917,25 +918,28 @@
size_t IndirectCallPromotion::canPromoteCallsite(
const BinaryBasicBlock &BB, const MCInst &Inst,
const std::vector<Callsite> &Targets, uint64_t NumCalls) {
+ BinaryFunction *BF = BB.getFunction();
+ const BinaryContext &BC = BF->getBinaryContext();
+
if (BB.getKnownExecutionCount() < opts::ExecutionCountThreshold)
return 0;
- const bool IsJumpTable = BB.getFunction()->getJumpTable(Inst);
+ const bool IsJumpTable = BF->getJumpTable(Inst);
auto computeStats = [&](size_t N) {
for (size_t I = 0; I < N; ++I)
- if (!IsJumpTable)
- TotalNumFrequentCalls += Targets[I].Branches;
- else
+ if (IsJumpTable)
TotalNumFrequentJmps += Targets[I].Branches;
+ else
+ TotalNumFrequentCalls += Targets[I].Branches;
};
// If we have no targets (or no calls), skip this callsite.
if (Targets.empty() || !NumCalls) {
if (opts::Verbosity >= 1) {
const ptrdiff_t InstIdx = &Inst - &(*BB.begin());
- outs() << "BOLT-INFO: ICP failed in " << *BB.getFunction() << " @ "
- << InstIdx << " in " << BB.getName() << ", calls = " << NumCalls
+ outs() << "BOLT-INFO: ICP failed in " << *BF << " @ " << InstIdx << " in "
+ << BB.getName() << ", calls = " << NumCalls
<< ", targets empty or NumCalls == 0.\n";
}
return 0;
@@ -950,7 +954,6 @@
const size_t TrialN = TopN ? std::min(TopN, Targets.size()) : Targets.size();
if (opts::ICPTopCallsites > 0) {
- BinaryContext &BC = BB.getFunction()->getBinaryContext();
if (!BC.MIB->hasAnnotation(Inst, "DoICP"))
return 0;
}
@@ -978,8 +981,8 @@
if (TopNFrequency == 0 || TopNFrequency < opts::ICPMispredictThreshold) {
if (opts::Verbosity >= 1) {
const ptrdiff_t InstIdx = &Inst - &(*BB.begin());
- outs() << "BOLT-INFO: ICP failed in " << *BB.getFunction() << " @ "
- << InstIdx << " in " << BB.getName() << ", calls = " << NumCalls
+ outs() << "BOLT-INFO: ICP failed in " << *BF << " @ " << InstIdx
+ << " in " << BB.getName() << ", calls = " << NumCalls
<< ", top N mis. frequency " << format("%.1f", TopNFrequency)
<< "% < " << opts::ICPMispredictThreshold << "%\n";
}
@@ -1024,9 +1027,9 @@
if (TopNMispredictFrequency < opts::ICPMispredictThreshold) {
if (opts::Verbosity >= 1) {
const ptrdiff_t InstIdx = &Inst - &(*BB.begin());
- outs() << "BOLT-INFO: ICP failed in " << *BB.getFunction() << " @ "
- << InstIdx << " in " << BB.getName()
- << ", calls = " << NumCalls << ", top N mispredict frequency "
+ outs() << "BOLT-INFO: ICP failed in " << *BF << " @ " << InstIdx
+ << " in " << BB.getName() << ", calls = " << NumCalls
+ << ", top N mispredict frequency "
<< format("%.1f", TopNMispredictFrequency) << "% < "
<< opts::ICPMispredictThreshold << "%\n";
}
@@ -1038,7 +1041,7 @@
// Filter functions that can have ICP applied (for debugging)
if (!opts::ICPFuncsList.empty()) {
for (std::string &Name : opts::ICPFuncsList)
- if (BB.getFunction()->hasName(Name))
+ if (BF->hasName(Name))
return N;
return 0;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124898.427134.patch
Type: text/x-patch
Size: 4127 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220504/5b8a6501/attachment.bin>
More information about the llvm-commits
mailing list