diff --git a/bolt/include/bolt/Core/MCPlusBuilder.h b/bolt/include/bolt/Core/MCPlusBuilder.h --- a/bolt/include/bolt/Core/MCPlusBuilder.h +++ b/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"); diff --git a/bolt/lib/Passes/IndirectCallPromotion.cpp b/bolt/lib/Passes/IndirectCallPromotion.cpp --- a/bolt/lib/Passes/IndirectCallPromotion.cpp +++ b/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);