aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/InlineCost.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2022-12-16 22:44:08 +0000
committerFangrui Song <i@maskray.me>2022-12-16 22:44:08 +0000
commit2fa744e631cbabe583da010ec56560edbc7a5384 (patch)
treedb931423c9394a852b65bdf5072ba997463114d5 /llvm/lib/Analysis/InlineCost.cpp
parent27249c06b775c73b7fa9f2d8e48cac1a85169481 (diff)
downloadllvm-2fa744e631cbabe583da010ec56560edbc7a5384.zip
llvm-2fa744e631cbabe583da010ec56560edbc7a5384.tar.gz
llvm-2fa744e631cbabe583da010ec56560edbc7a5384.tar.bz2
std::optional::value => operator*/operator->
value() has undesired exception checking semantics and calls __throw_bad_optional_access in libc++. Moreover, the API is unavailable without _LIBCPP_NO_EXCEPTIONS on older Mach-O platforms (see _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS). This commit fixes LLVMAnalysis and its dependencies.
Diffstat (limited to 'llvm/lib/Analysis/InlineCost.cpp')
-rw-r--r--llvm/lib/Analysis/InlineCost.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index b6f50b8d..e39940e 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -736,8 +736,7 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
BlockFrequencyInfo *BFI = &(GetBFI(F));
assert(BFI && "BFI must be available");
auto ProfileCount = BFI->getBlockProfileCount(BB);
- assert(ProfileCount);
- if (ProfileCount.value() == 0)
+ if (*ProfileCount == 0)
ColdSize += Cost - CostAtBBStart;
}
@@ -861,8 +860,7 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
}
auto ProfileCount = CalleeBFI->getBlockProfileCount(&BB);
- assert(ProfileCount);
- CurrentSavings *= ProfileCount.value();
+ CurrentSavings *= *ProfileCount;
CycleSavings += CurrentSavings;
}
@@ -1820,12 +1818,12 @@ void InlineCostCallAnalyzer::updateThreshold(CallBase &Call, Function &Callee) {
// return min(A, B) if B is valid.
auto MinIfValid = [](int A, std::optional<int> B) {
- return B ? std::min(A, B.value()) : A;
+ return B ? std::min(A, *B) : A;
};
// return max(A, B) if B is valid.
auto MaxIfValid = [](int A, std::optional<int> B) {
- return B ? std::max(A, B.value()) : A;
+ return B ? std::max(A, *B) : A;
};
// Various bonus percentages. These are multiplied by Threshold to get the