From d58b5a06147eb40aec807ff58c74c20ca9071f28 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Mon, 27 Jun 2022 10:30:30 -0700 Subject: [PATCH] [BOLT] Restrict icp-inline to callsites ICP peel for inline mode only makes sense for calls, not jump tables. Plus, add a check that the Target BinaryFunction is found. Reviewed By: rafauler Differential Revision: https://reviews.llvm.org/D128404 --- bolt/lib/Passes/IndirectCallPromotion.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/bolt/lib/Passes/IndirectCallPromotion.cpp b/bolt/lib/Passes/IndirectCallPromotion.cpp index 4886cfec3845..700216bbdc91 100644 --- a/bolt/lib/Passes/IndirectCallPromotion.cpp +++ b/bolt/lib/Passes/IndirectCallPromotion.cpp @@ -977,10 +977,8 @@ size_t IndirectCallPromotion::canPromoteCallsite( const size_t TrialN = TopN ? std::min(TopN, Targets.size()) : Targets.size(); - if (opts::ICPTopCallsites > 0) { - if (!BC.MIB->hasAnnotation(Inst, "DoICP")) - return 0; - } + if (opts::ICPTopCallsites && !BC.MIB->hasAnnotation(Inst, "DoICP")) + return 0; // Pick the top N targets. uint64_t TotalMispredictsTopN = 0; @@ -1064,11 +1062,11 @@ size_t IndirectCallPromotion::canPromoteCallsite( // Filter by inline-ability of target functions, stop at first target that // can't be inlined. - if (opts::ICPPeelForInline) { + if (!IsJumpTable && 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) || + if (!TargetBF || !BinaryFunctionPass::shouldOptimize(*TargetBF) || getInliningInfo(*TargetBF).Type == InliningType::INL_NONE) { N = I; break;