aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/InlineCost.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2022-12-02 19:43:04 -0800
committerKazu Hirata <kazu@google.com>2022-12-02 19:43:04 -0800
commit19aff0f37dd68ee51e78b764c0ce629ae73d1eef (patch)
tree07403086631814ae1ff7742c8c6dac4fb67b5088 /llvm/lib/Analysis/InlineCost.cpp
parentfef3a16aeab660d0789c592985993bd68b51f517 (diff)
downloadllvm-19aff0f37dd68ee51e78b764c0ce629ae73d1eef.zip
llvm-19aff0f37dd68ee51e78b764c0ce629ae73d1eef.tar.gz
llvm-19aff0f37dd68ee51e78b764c0ce629ae73d1eef.tar.bz2
[Analysis] Use std::nullopt instead of None (NFC)
This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of manual work required in migrating from Optional to std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
Diffstat (limited to 'llvm/lib/Analysis/InlineCost.cpp')
-rw-r--r--llvm/lib/Analysis/InlineCost.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index 96b733d..9a5f985 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -168,7 +168,7 @@ Optional<int> getStringFnAttrAsInt(const Attribute &Attr) {
if (!Attr.getValueAsString().getAsInteger(10, AttrValue))
return AttrValue;
}
- return None;
+ return std::nullopt;
}
Optional<int> getStringFnAttrAsInt(CallBase &CB, StringRef AttrKind) {
@@ -493,7 +493,7 @@ public:
std::optional<Constant *> getSimplifiedValue(Instruction *I) {
if (SimplifiedValues.find(I) != SimplifiedValues.end())
return SimplifiedValues[I];
- return None;
+ return std::nullopt;
}
// Keep a bunch of stats about the cost savings found so we can print them
@@ -584,7 +584,7 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
bool DecidedByCostBenefit = false;
// The cost-benefit pair computed by cost-benefit analysis.
- Optional<CostBenefitPair> CostBenefit = None;
+ Optional<CostBenefitPair> CostBenefit = std::nullopt;
bool SingleBB = true;
@@ -817,14 +817,14 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
// suficient profiling information to determine.
std::optional<bool> costBenefitAnalysis() {
if (!CostBenefitAnalysisEnabled)
- return None;
+ return std::nullopt;
// buildInlinerPipeline in the pass builder sets HotCallSiteThreshold to 0
// for the prelink phase of the AutoFDO + ThinLTO build. Honor the logic by
// falling back to the cost-based metric.
// TODO: Improve this hacky condition.
if (Threshold == 0)
- return None;
+ return std::nullopt;
assert(GetBFI);
BlockFrequencyInfo *CalleeBFI = &(GetBFI(F));
@@ -1056,7 +1056,7 @@ public:
Optional<InstructionCostDetail> getCostDetails(const Instruction *I) {
if (InstructionCostDetailMap.find(I) != InstructionCostDetailMap.end())
return InstructionCostDetailMap[I];
- return None;
+ return std::nullopt;
}
virtual ~InlineCostCallAnalyzer() = default;
@@ -1793,7 +1793,7 @@ InlineCostCallAnalyzer::getHotCallSiteThreshold(CallBase &Call,
// Otherwise we need BFI to be available and to have a locally hot callsite
// threshold.
if (!CallerBFI || !Params.LocallyHotCallSiteThreshold)
- return None;
+ return std::nullopt;
// Determine if the callsite is hot relative to caller's entry. We could
// potentially cache the computation of scaled entry frequency, but the added
@@ -1806,7 +1806,7 @@ InlineCostCallAnalyzer::getHotCallSiteThreshold(CallBase &Call,
return Params.LocallyHotCallSiteThreshold;
// Otherwise treat it normally.
- return None;
+ return std::nullopt;
}
void InlineCostCallAnalyzer::updateThreshold(CallBase &Call, Function &Callee) {
@@ -2850,7 +2850,7 @@ Optional<int> llvm::getInliningCostEstimate(
/*IgnoreThreshold*/ true);
auto R = CA.analyze();
if (!R.isSuccess())
- return None;
+ return std::nullopt;
return CA.getCost();
}
@@ -2863,7 +2863,7 @@ Optional<InlineCostFeatures> llvm::getInliningCostFeatures(
ORE, *Call.getCalledFunction(), Call);
auto R = CFA.analyze();
if (!R.isSuccess())
- return None;
+ return std::nullopt;
return CFA.features();
}
@@ -2935,7 +2935,7 @@ Optional<InlineResult> llvm::getAttributeBasedInliningDecision(
if (Call.isNoInline())
return InlineResult::failure("noinline call site attribute");
- return None;
+ return std::nullopt;
}
InlineCost llvm::getInlineCost(