forked from OSchip/llvm-project
[BOLT] Add icp-inline option
Add an option to only peel ICP targets that can be subsequently inlined. Yet there's no guarantee that they will be inlined. The mode is independent from the heuristic used to choose ICP targets: by exec count, mispredictions, or memory profile. Reviewed By: rafauler Differential Revision: https://reviews.llvm.org/D124900
This commit is contained in:
parent
b4a5340be5
commit
c2d40f1dfb
|
@ -13,6 +13,7 @@
|
|||
#include "bolt/Passes/IndirectCallPromotion.h"
|
||||
#include "bolt/Passes/BinaryFunctionCallGraph.h"
|
||||
#include "bolt/Passes/DataflowInfoManager.h"
|
||||
#include "bolt/Passes/Inliner.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
|
||||
#define DEBUG_TYPE "ICP"
|
||||
|
@ -120,6 +121,10 @@ static cl::opt<bool> ICPJumpTablesByTarget(
|
|||
"for jump tables, optimize indirect jmp targets instead of indices"),
|
||||
cl::init(false), cl::ZeroOrMore, cl::Hidden, cl::cat(BoltOptCategory));
|
||||
|
||||
static cl::opt<bool> ICPPeelForInline(
|
||||
"icp-inline", cl::desc("only promote call targets eligible for inlining"),
|
||||
cl::init(false), cl::ZeroOrMore, cl::Hidden, cl::cat(BoltOptCategory));
|
||||
|
||||
} // namespace opts
|
||||
|
||||
namespace llvm {
|
||||
|
@ -1038,6 +1043,20 @@ size_t IndirectCallPromotion::canPromoteCallsite(
|
|||
}
|
||||
}
|
||||
|
||||
// Filter by inline-ability of target functions, stop at first target that
|
||||
// can't be inlined.
|
||||
if (opts::ICPPeelForInline) {
|
||||
for (size_t I = 0; I < N; ++I) {
|
||||
const MCSymbol *TargetSym = Targets[I].To.Sym;
|
||||
const BinaryFunction *TargetBF = BC.getFunctionForSymbol(TargetSym);
|
||||
if (!BinaryFunctionPass::shouldOptimize(*TargetBF) ||
|
||||
getInliningInfo(*TargetBF).Type == InliningType::INL_NONE) {
|
||||
N = I;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Filter functions that can have ICP applied (for debugging)
|
||||
if (!opts::ICPFuncsList.empty()) {
|
||||
for (std::string &Name : opts::ICPFuncsList)
|
||||
|
|
Loading…
Reference in New Issue