Skip to content

Commit

Permalink
[clang, llvm] Use Optional::getValueOr (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazutakahirata committed Oct 31, 2021
1 parent 4db2e4c commit c8b1ed5
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion clang/include/clang/Analysis/PathDiagnostic.h
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions llvm/include/llvm/Analysis/ProfileSummaryInfo.h
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Analysis/ProfileSummaryInfo.cpp
Expand Up @@ -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,
Expand Down
4 changes: 1 addition & 3 deletions llvm/lib/Transforms/IPO/PartialInlining.cpp
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions llvm/lib/Transforms/IPO/SampleProfileProbe.cpp
Expand Up @@ -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.
Expand Down
Expand Up @@ -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
Expand Down

0 comments on commit c8b1ed5

Please sign in to comment.