aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
diff options
context:
space:
mode:
authorDavid Green <david.green@arm.com>2025-04-23 07:46:27 +0100
committerGitHub <noreply@github.com>2025-04-23 07:46:27 +0100
commit98b6f8dc699d789d834e5b6d810ed217f560aad0 (patch)
tree2e6a97dca2bcd2f2376e2d127a819105200ee9e7 /llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
parent665914fea1433409015a87fef2837218bcd21460 (diff)
downloadllvm-98b6f8dc699d789d834e5b6d810ed217f560aad0.zip
llvm-98b6f8dc699d789d834e5b6d810ed217f560aad0.tar.gz
llvm-98b6f8dc699d789d834e5b6d810ed217f560aad0.tar.bz2
[CostModel] Remove optional from InstructionCost::getValue() (#135596)
InstructionCost is already an optional value, containing an Invalid state that can be checked with isValid(). There is little point in returning another optional from getValue(). Most uses do not make use of it being a std::optional, dereferencing the value directly (either isValid has been checked previously or the Cost is assumed to be valid). The one case that does in AMDGPU used value_or which has been replaced by a isValid() check.
Diffstat (limited to 'llvm/lib/Transforms/IPO/FunctionSpecialization.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/FunctionSpecialization.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp b/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
index c13305c..1034ce9 100644
--- a/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
@@ -662,7 +662,7 @@ FunctionSpecializer::~FunctionSpecializer() {
/// non-negative, which is true for both TCK_CodeSize and TCK_Latency, and
/// always Valid.
static unsigned getCostValue(const Cost &C) {
- int64_t Value = *C.getValue();
+ int64_t Value = C.getValue();
assert(Value >= 0 && "CodeSize and Latency cannot be negative");
// It is safe to down cast since we know the arguments cannot be negative and
@@ -713,7 +713,7 @@ bool FunctionSpecializer::run() {
if (!SpecializeLiteralConstant && !Inserted && !Metrics.isRecursive)
continue;
- int64_t Sz = *Metrics.NumInsts.getValue();
+ int64_t Sz = Metrics.NumInsts.getValue();
assert(Sz > 0 && "CodeSize should be positive");
// It is safe to down cast from int64_t, NumInsts is always positive.
unsigned FuncSize = static_cast<unsigned>(Sz);