[llvm] 3c775d9 - [InlineCost] Reject a zero entry count
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 25 21:52:02 PDT 2021
Author: Kazu Hirata
Date: 2021-03-25T21:51:36-07:00
New Revision: 3c775d93a1dda3cec3bb6c7617c4b4ab770f4af0
URL: https://github.com/llvm/llvm-project/commit/3c775d93a1dda3cec3bb6c7617c4b4ab770f4af0
DIFF: https://github.com/llvm/llvm-project/commit/3c775d93a1dda3cec3bb6c7617c4b4ab770f4af0.diff
LOG: [InlineCost] Reject a zero entry count
This patch teaches the cost-benefit-analysis-based inliner to reject a
zero entry count so that we don't trigger a divide-by-zero.
Added:
Modified:
llvm/lib/Analysis/InlineCost.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index c02b56797be3..538dfacdaa5b 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -696,7 +696,9 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
if (!PSI->isHotCallSite(CandidateCall, CallerBFI))
return false;
- if (!F.getEntryCount())
+ // Make sure we have a nonzero entry count.
+ auto EntryCount = F.getEntryCount();
+ if (!EntryCount || !EntryCount.getCount())
return false;
BlockFrequencyInfo *CalleeBFI = &(GetBFI(F));
@@ -765,7 +767,7 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
// Compute the cycle savings per call.
auto EntryProfileCount = F.getEntryCount();
- assert(EntryProfileCount.hasValue());
+ assert(EntryProfileCount.hasValue() && EntryProfileCount.getCount());
auto EntryCount = EntryProfileCount.getCount();
CycleSavings += EntryCount / 2;
CycleSavings = CycleSavings.udiv(EntryCount);
More information about the llvm-commits
mailing list