Skip to content

Commit 3c775d9

Browse files
[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.
1 parent ec46e03 commit 3c775d9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

llvm/lib/Analysis/InlineCost.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,9 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
696696
if (!PSI->isHotCallSite(CandidateCall, CallerBFI))
697697
return false;
698698

699-
if (!F.getEntryCount())
699+
// Make sure we have a nonzero entry count.
700+
auto EntryCount = F.getEntryCount();
701+
if (!EntryCount || !EntryCount.getCount())
700702
return false;
701703

702704
BlockFrequencyInfo *CalleeBFI = &(GetBFI(F));
@@ -765,7 +767,7 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
765767

766768
// Compute the cycle savings per call.
767769
auto EntryProfileCount = F.getEntryCount();
768-
assert(EntryProfileCount.hasValue());
770+
assert(EntryProfileCount.hasValue() && EntryProfileCount.getCount());
769771
auto EntryCount = EntryProfileCount.getCount();
770772
CycleSavings += EntryCount / 2;
771773
CycleSavings = CycleSavings.udiv(EntryCount);

0 commit comments

Comments
 (0)