aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/InlineCost.cpp
diff options
context:
space:
mode:
authorMircea Trofin <mtrofin@google.com>2021-11-13 22:03:10 -0800
committerMircea Trofin <mtrofin@google.com>2021-11-14 19:03:30 -0800
commita32c2c380863d02eb0fd5e8757a62d96114b9519 (patch)
treea8efd17605ad68ca7810556740703fb38c29f9c4 /llvm/lib/Analysis/InlineCost.cpp
parenteec9ca622c2df2bcf3ffa7fad5a2381b829758b7 (diff)
downloadllvm-a32c2c380863d02eb0fd5e8757a62d96114b9519.zip
llvm-a32c2c380863d02eb0fd5e8757a62d96114b9519.tar.gz
llvm-a32c2c380863d02eb0fd5e8757a62d96114b9519.tar.bz2
[NFC] Use Optional<ProfileCount> to model invalid counts
ProfileCount could model invalid values, but a user had no indication that the getCount method could return bogus data. Optional<ProfileCount> addresses that, because the user must dereference the optional. In addition, the patch removes concept duplication. Differential Revision: https://reviews.llvm.org/D113839
Diffstat (limited to 'llvm/lib/Analysis/InlineCost.cpp')
-rw-r--r--llvm/lib/Analysis/InlineCost.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index a77dd32..6d97898 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -771,7 +771,7 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
// Make sure we have a nonzero entry count.
auto EntryCount = F.getEntryCount();
- if (!EntryCount || !EntryCount.getCount())
+ if (!EntryCount || !EntryCount->getCount())
return false;
BlockFrequencyInfo *CalleeBFI = &(GetBFI(F));
@@ -837,8 +837,8 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
// Compute the cycle savings per call.
auto EntryProfileCount = F.getEntryCount();
- assert(EntryProfileCount.hasValue() && EntryProfileCount.getCount());
- auto EntryCount = EntryProfileCount.getCount();
+ assert(EntryProfileCount.hasValue() && EntryProfileCount->getCount());
+ auto EntryCount = EntryProfileCount->getCount();
CycleSavings += EntryCount / 2;
CycleSavings = CycleSavings.udiv(EntryCount);