[PATCH] D128404: [BOLT] Restrict icp-inline to callsites

Amir Ayupov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 22 18:16:39 PDT 2022


Amir created this revision.
Herald added a reviewer: rafauler.
Herald added a subscriber: ayermolo.
Herald added a reviewer: maksfb.
Herald added a project: All.
Amir requested review of this revision.
Herald added subscribers: llvm-commits, yota9.
Herald added a project: LLVM.

ICP peel for inline mode only makes sense for calls, not jump tables.
Plus, add a check that the Target BinaryFunction is found.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128404

Files:
  bolt/lib/Passes/IndirectCallPromotion.cpp


Index: bolt/lib/Passes/IndirectCallPromotion.cpp
===================================================================
--- bolt/lib/Passes/IndirectCallPromotion.cpp
+++ bolt/lib/Passes/IndirectCallPromotion.cpp
@@ -987,10 +987,8 @@
 
   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;
@@ -1074,11 +1072,11 @@
 
   // 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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128404.439230.patch
Type: text/x-patch
Size: 1194 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220623/3e25eda5/attachment.bin>


More information about the llvm-commits mailing list