aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ValueTracking.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2022-11-25 11:30:34 -0800
committerKazu Hirata <kazu@google.com>2022-11-25 11:30:34 -0800
commit5ea708375f507a783a44fe9864067ba4b425f777 (patch)
tree77952887a8ddaeff680c5b75fcf50e5b215dda02 /llvm/lib/Analysis/ValueTracking.cpp
parentee8959d09894f2494c4c6928a6904ac0f45b9fe7 (diff)
downloadllvm-5ea708375f507a783a44fe9864067ba4b425f777.zip
llvm-5ea708375f507a783a44fe9864067ba4b425f777.tar.gz
llvm-5ea708375f507a783a44fe9864067ba4b425f777.tar.bz2
[Analysis] Use std::optional in ValueTracking.cpp (NFC)
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/ValueTracking.cpp')
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 09b8131..28463bb 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -74,6 +74,7 @@
#include <algorithm>
#include <cassert>
#include <cstdint>
+#include <optional>
#include <utility>
using namespace llvm;
@@ -1016,7 +1017,7 @@ static void computeKnownBitsFromShiftOperator(
// If we know the shifter operand is nonzero, we can sometimes infer more
// known bits. However this is expensive to compute, so be lazy about it and
// only compute it when absolutely necessary.
- Optional<bool> ShifterOperandIsNonZero;
+ std::optional<bool> ShifterOperandIsNonZero;
// Early exit if we can't constrain any well-defined shift amount.
if (!(ShiftAmtKZ & (PowerOf2Ceil(BitWidth) - 1)) &&
@@ -2745,7 +2746,7 @@ bool isKnownNonZero(const Value* V, unsigned Depth, const Query& Q) {
/// every input value to exactly one output value. This is equivalent to
/// saying that Op1 and Op2 are equal exactly when the specified pair of
/// operands are equal, (except that Op1 and Op2 may be poison more often.)
-static Optional<std::pair<Value*, Value*>>
+static std::optional<std::pair<Value*, Value*>>
getInvertibleOperands(const Operator *Op1,
const Operator *Op2) {
if (Op1->getOpcode() != Op2->getOpcode())
@@ -7322,7 +7323,7 @@ ConstantRange llvm::computeConstantRange(const Value *V, bool ForSigned,
return CR;
}
-static Optional<int64_t>
+static std::optional<int64_t>
getOffsetFromIndex(const GEPOperator *GEP, unsigned Idx, const DataLayout &DL) {
// Skip over the first indices.
gep_type_iterator GTI = gep_type_begin(GEP);