diff --git a/llvm/tools/llvm-profgen/CSPreInliner.cpp b/llvm/tools/llvm-profgen/CSPreInliner.cpp --- a/llvm/tools/llvm-profgen/CSPreInliner.cpp +++ b/llvm/tools/llvm-profgen/CSPreInliner.cpp @@ -190,7 +190,11 @@ unsigned FuncSize = getFuncSize(ContextTracker.getContextNodeForProfile(FSamples)); unsigned FuncFinalSize = FuncSize; - unsigned SizeLimit = FuncSize * ProfileInlineGrowthLimit; + // Use one to avoid multiplication with a zero func size. This could happen + // when all of the original function's code is gone and only inlined code is + // left. + unsigned ModifiedFuncSize = FuncSize ? FuncSize : 1; + unsigned SizeLimit = ModifiedFuncSize * ProfileInlineGrowthLimit; SizeLimit = std::min(SizeLimit, (unsigned)ProfileInlineLimitMax); SizeLimit = std::max(SizeLimit, (unsigned)ProfileInlineLimitMin);