diff --git a/bolt/include/bolt/Passes/IndirectCallPromotion.h b/bolt/include/bolt/Passes/IndirectCallPromotion.h --- a/bolt/include/bolt/Passes/IndirectCallPromotion.h +++ b/bolt/include/bolt/Passes/IndirectCallPromotion.h @@ -217,6 +217,10 @@ bool shouldPrint(const BinaryFunction &BF) const override { return BinaryFunctionPass::shouldPrint(BF) && Modified.count(&BF) > 0; } + bool shouldOptimize(const BinaryFunction &BF) const override { + return BF.isSimple() && !BF.isIgnored() && BF.hasProfile() && + !BF.hasUnknownControlFlow(); + } void runOnFunctions(BinaryContext &BC) override; }; 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 @@ -1158,8 +1158,7 @@ for (auto &BFIt : BFs) { BinaryFunction &Function = BFIt.second; - if (!Function.isSimple() || Function.isIgnored() || - !Function.hasProfile()) + if (!shouldOptimize(Function)) continue; const bool HasLayout = !Function.getLayout().block_empty(); @@ -1219,7 +1218,7 @@ for (BinaryFunction *FuncPtr : Functions) { BinaryFunction &Function = *FuncPtr; - if (!Function.isSimple() || Function.isIgnored() || !Function.hasProfile()) + if (!shouldOptimize(Function)) continue; const bool HasLayout = !Function.getLayout().block_empty();