Author: Kazu Hirata Date: 2021-10-30T19:00:21-07:00 New Revision: c8b1ed5fb2da8f030cb3c9d8a361ea7420e42da1
URL: https://github.com/llvm/llvm-project/commit/c8b1ed5fb2da8f030cb3c9d8a361ea7420e42da1 DIFF: https://github.com/llvm/llvm-project/commit/c8b1ed5fb2da8f030cb3c9d8a361ea7420e42da1.diff LOG: [clang, llvm] Use Optional::getValueOr (NFC) Added: Modified: clang/include/clang/Analysis/PathDiagnostic.h llvm/include/llvm/Analysis/ProfileSummaryInfo.h llvm/lib/Analysis/ProfileSummaryInfo.cpp llvm/lib/Transforms/IPO/PartialInlining.cpp llvm/lib/Transforms/IPO/SampleProfileProbe.cpp llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp Removed: ################################################################################ diff --git a/clang/include/clang/Analysis/PathDiagnostic.h b/clang/include/clang/Analysis/PathDiagnostic.h index 14860c1168e21..235d26083191d 100644 --- a/clang/include/clang/Analysis/PathDiagnostic.h +++ b/clang/include/clang/Analysis/PathDiagnostic.h @@ -553,7 +553,7 @@ class PathDiagnosticEventPiece : public PathDiagnosticSpotPiece { /// Return true if the diagnostic piece is prunable. bool isPrunable() const { - return IsPrunable.hasValue() ? IsPrunable.getValue() : false; + return IsPrunable.getValueOr(false); } void dump() const override; diff --git a/llvm/include/llvm/Analysis/ProfileSummaryInfo.h b/llvm/include/llvm/Analysis/ProfileSummaryInfo.h index 8a5ab1ba6303d..886800d8a0f59 100644 --- a/llvm/include/llvm/Analysis/ProfileSummaryInfo.h +++ b/llvm/include/llvm/Analysis/ProfileSummaryInfo.h @@ -170,11 +170,11 @@ class ProfileSummaryInfo { uint64_t getOrCompColdCountThreshold() const; /// Returns HotCountThreshold if set. uint64_t getHotCountThreshold() const { - return HotCountThreshold ? HotCountThreshold.getValue() : 0; + return HotCountThreshold.getValueOr(0); } /// Returns ColdCountThreshold if set. uint64_t getColdCountThreshold() const { - return ColdCountThreshold ? ColdCountThreshold.getValue() : 0; + return ColdCountThreshold.getValueOr(0); } private: diff --git a/llvm/lib/Analysis/ProfileSummaryInfo.cpp b/llvm/lib/Analysis/ProfileSummaryInfo.cpp index 6dda0bf0a1b4a..69ca5502e5753 100644 --- a/llvm/lib/Analysis/ProfileSummaryInfo.cpp +++ b/llvm/lib/Analysis/ProfileSummaryInfo.cpp @@ -316,11 +316,11 @@ bool ProfileSummaryInfo::isColdCountNthPercentile(int PercentileCutoff, } uint64_t ProfileSummaryInfo::getOrCompHotCountThreshold() const { - return HotCountThreshold ? HotCountThreshold.getValue() : UINT64_MAX; + return HotCountThreshold.getValueOr(UINT64_MAX); } uint64_t ProfileSummaryInfo::getOrCompColdCountThreshold() const { - return ColdCountThreshold ? ColdCountThreshold.getValue() : 0; + return ColdCountThreshold.getValueOr(0); } bool ProfileSummaryInfo::isHotBlock(const BasicBlock *BB, diff --git a/llvm/lib/Transforms/IPO/PartialInlining.cpp b/llvm/lib/Transforms/IPO/PartialInlining.cpp index d517de38ace3e..6921c46be7a8e 100644 --- a/llvm/lib/Transforms/IPO/PartialInlining.cpp +++ b/llvm/lib/Transforms/IPO/PartialInlining.cpp @@ -441,9 +441,7 @@ PartialInlinerImpl::computeOutliningColdRegionsInfo( }; auto BBProfileCount = [BFI](BasicBlock *BB) { - return BFI->getBlockProfileCount(BB) - ? BFI->getBlockProfileCount(BB).getValue() - : 0; + return BFI->getBlockProfileCount(BB).getValueOr(0); }; // Use the same computeBBInlineCost function to compute the cost savings of diff --git a/llvm/lib/Transforms/IPO/SampleProfileProbe.cpp b/llvm/lib/Transforms/IPO/SampleProfileProbe.cpp index 08d316337ef55..21395460bccba 100644 --- a/llvm/lib/Transforms/IPO/SampleProfileProbe.cpp +++ b/llvm/lib/Transforms/IPO/SampleProfileProbe.cpp @@ -415,9 +415,7 @@ void PseudoProbeUpdatePass::runOnFunction(Function &F, FunctionAnalysisManager &FAM) { BlockFrequencyInfo &BFI = FAM.getResult<BlockFrequencyAnalysis>(F); auto BBProfileCount = [&BFI](BasicBlock *BB) { - return BFI.getBlockProfileCount(BB) - ? BFI.getBlockProfileCount(BB).getValue() - : 0; + return BFI.getBlockProfileCount(BB).getValueOr(0); }; // Collect the sum of execution weight for each probe. diff --git a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp index 3b4d80dc80232..440fc8e805975 100644 --- a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp +++ b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp @@ -1752,7 +1752,7 @@ void CHR::transformScopes(CHRScope *Scope, DenseSet<PHINode *> &TrivialPHIs) { // Create the combined branch condition and constant-fold the branches/selects // in the hot path. fixupBranchesAndSelects(Scope, PreEntryBlock, MergedBr, - ProfileCount ? ProfileCount.getValue() : 0); + ProfileCount.getValueOr(0)); } // A helper for transformScopes. Clone the blocks in the scope (excluding the _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits