diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp --- a/llvm/lib/Analysis/InlineCost.cpp +++ b/llvm/lib/Analysis/InlineCost.cpp @@ -844,6 +844,9 @@ APInt CycleSavings(128, 0); for (auto &BB : F) { + // Skip dead blocks since they are going to be simplified away. + if (DeadBlocks.count(&BB)) + continue; APInt CurrentSavings(128, 0); for (auto &I : BB) { if (BranchInst *BI = dyn_cast(&I)) {