diff --git a/llvm/lib/CodeGen/MachineFunctionSplitter.cpp b/llvm/lib/CodeGen/MachineFunctionSplitter.cpp --- a/llvm/lib/CodeGen/MachineFunctionSplitter.cpp +++ b/llvm/lib/CodeGen/MachineFunctionSplitter.cpp @@ -59,6 +59,12 @@ "Minimum number of times a block must be executed to be retained."), cl::init(1), cl::Hidden); +static cl::opt + ColdSizeThreshold("mfs-size-threshold", + cl::desc("Maximum number of instructions a cold block " + "may have and still be retained."), + cl::init(0), cl::Hidden); + static cl::opt SplitAllEHCode( "mfs-split-ehcode", cl::desc("Splits all EH code and it's descendants by default."), @@ -97,6 +103,9 @@ static bool isColdBlock(const MachineBasicBlock &MBB, const MachineBlockFrequencyInfo *MBFI, ProfileSummaryInfo *PSI) { + if (MBB.size() <= ColdSizeThreshold) + return false; + std::optional Count = MBFI->getBlockProfileCount(&MBB); if (!Count) return true;