diff options
author | Mircea Trofin <mtrofin@google.com> | 2021-11-13 22:03:10 -0800 |
---|---|---|
committer | Mircea Trofin <mtrofin@google.com> | 2021-11-14 19:03:30 -0800 |
commit | a32c2c380863d02eb0fd5e8757a62d96114b9519 (patch) | |
tree | a8efd17605ad68ca7810556740703fb38c29f9c4 /llvm/lib/Transforms/Utils/InlineFunction.cpp | |
parent | eec9ca622c2df2bcf3ffa7fad5a2381b829758b7 (diff) | |
download | llvm-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/Transforms/Utils/InlineFunction.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/InlineFunction.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp index 6a3ac1e..f477658 100644 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -1600,8 +1600,7 @@ static void updateCallProfile(Function *Callee, const ValueToValueMapTy &VMap, const ProfileCount &CalleeEntryCount, const CallBase &TheCall, ProfileSummaryInfo *PSI, BlockFrequencyInfo *CallerBFI) { - if (!CalleeEntryCount.hasValue() || CalleeEntryCount.isSynthetic() || - CalleeEntryCount.getCount() < 1) + if (CalleeEntryCount.isSynthetic() || CalleeEntryCount.getCount() < 1) return; auto CallSiteCount = PSI ? PSI->getProfileCount(TheCall, CallerBFI) : None; int64_t CallCount = @@ -1616,7 +1615,7 @@ void llvm::updateProfileCallee( if (!CalleeCount.hasValue()) return; - const uint64_t PriorEntryCount = CalleeCount.getCount(); + const uint64_t PriorEntryCount = CalleeCount->getCount(); // Since CallSiteCount is an estimate, it could exceed the original callee // count and has to be set to 0 so guard against underflow. @@ -1969,8 +1968,9 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI, updateCallerBFI(OrigBB, VMap, IFI.CallerBFI, IFI.CalleeBFI, CalledFunc->front()); - updateCallProfile(CalledFunc, VMap, CalledFunc->getEntryCount(), CB, - IFI.PSI, IFI.CallerBFI); + if (auto Profile = CalledFunc->getEntryCount()) + updateCallProfile(CalledFunc, VMap, *Profile, CB, IFI.PSI, + IFI.CallerBFI); } // Inject byval arguments initialization. |