[PATCH] D128870: [BOLT] Don't apply ICP to instructions with unknown control flow

Amir Ayupov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 30 01:24:16 PDT 2022


Amir updated this revision to Diff 441301.
Amir added a comment.

Narrow down to non-tailcall indirect jump with no jump table


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128870/new/

https://reviews.llvm.org/D128870

Files:
  bolt/include/bolt/Core/MCPlusBuilder.h
  bolt/lib/Passes/IndirectCallPromotion.cpp


Index: bolt/lib/Passes/IndirectCallPromotion.cpp
===================================================================
--- bolt/lib/Passes/IndirectCallPromotion.cpp
+++ bolt/lib/Passes/IndirectCallPromotion.cpp
@@ -947,6 +947,8 @@
 
   if (BB.getKnownExecutionCount() < opts::ExecutionCountThreshold)
     return 0;
+  if (BC.MIB->isUnknownControlFlow(Inst))
+    return 0;
 
   const bool IsJumpTable = BF->getJumpTable(Inst);
 
Index: bolt/include/bolt/Core/MCPlusBuilder.h
===================================================================
--- bolt/include/bolt/Core/MCPlusBuilder.h
+++ bolt/include/bolt/Core/MCPlusBuilder.h
@@ -370,6 +370,10 @@
     return Analysis->isIndirectBranch(Inst);
   }
 
+  virtual bool isUnknownControlFlow(const MCInst &Inst) const {
+    return !isCall(Inst) && isIndirectBranch(Inst) && !getJumpTable(Inst);
+  }
+
   /// Returns true if the instruction is memory indirect call or jump
   virtual bool isBranchOnMem(const MCInst &Inst) const {
     llvm_unreachable("not implemented");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128870.441301.patch
Type: text/x-patch
Size: 1021 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220630/5ae0d8a6/attachment.bin>


More information about the llvm-commits mailing list