aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/MemoryLocation.cpp
diff options
context:
space:
mode:
authorKrzysztof Parzyszek <kparzysz@quicinc.com>2022-12-01 15:23:53 -0800
committerKrzysztof Parzyszek <kparzysz@quicinc.com>2022-12-01 15:36:20 -0800
commit467432899bc2f71842ed1b24d24c094da02af7d4 (patch)
tree39b97b6744ba1c40bb4a82912135c0033b274374 /llvm/lib/Analysis/MemoryLocation.cpp
parent1b722f04306afe1023952d1b59bd7d9d4d5ffc7a (diff)
downloadllvm-467432899bc2f71842ed1b24d24c094da02af7d4.zip
llvm-467432899bc2f71842ed1b24d24c094da02af7d4.tar.gz
llvm-467432899bc2f71842ed1b24d24c094da02af7d4.tar.bz2
MemoryLocation: convert Optional to std::optional
Diffstat (limited to 'llvm/lib/Analysis/MemoryLocation.cpp')
-rw-r--r--llvm/lib/Analysis/MemoryLocation.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/llvm/lib/Analysis/MemoryLocation.cpp b/llvm/lib/Analysis/MemoryLocation.cpp
index fb23f0b..e839f9e 100644
--- a/llvm/lib/Analysis/MemoryLocation.cpp
+++ b/llvm/lib/Analysis/MemoryLocation.cpp
@@ -74,7 +74,8 @@ MemoryLocation MemoryLocation::get(const AtomicRMWInst *RMWI) {
RMWI->getAAMetadata());
}
-Optional<MemoryLocation> MemoryLocation::getOrNone(const Instruction *Inst) {
+std::optional<MemoryLocation>
+MemoryLocation::getOrNone(const Instruction *Inst) {
switch (Inst->getOpcode()) {
case Instruction::Load:
return get(cast<LoadInst>(Inst));
@@ -87,7 +88,7 @@ Optional<MemoryLocation> MemoryLocation::getOrNone(const Instruction *Inst) {
case Instruction::AtomicRMW:
return get(cast<AtomicRMWInst>(Inst));
default:
- return None;
+ return std::nullopt;
}
}
@@ -117,39 +118,39 @@ MemoryLocation MemoryLocation::getForDest(const AnyMemIntrinsic *MI) {
return getForArgument(MI, 0, nullptr);
}
-Optional<MemoryLocation>
+std::optional<MemoryLocation>
MemoryLocation::getForDest(const CallBase *CB, const TargetLibraryInfo &TLI) {
if (!CB->onlyAccessesArgMemory())
- return None;
+ return std::nullopt;
if (CB->hasOperandBundles())
// TODO: remove implementation restriction
- return None;
+ return std::nullopt;
Value *UsedV = nullptr;
std::optional<unsigned> UsedIdx;
for (unsigned i = 0; i < CB->arg_size(); i++) {
if (!CB->getArgOperand(i)->getType()->isPointerTy())
continue;
- if (CB->onlyReadsMemory(i))
- continue;
+ if (CB->onlyReadsMemory(i))
+ continue;
if (!UsedV) {
// First potentially writing parameter
UsedV = CB->getArgOperand(i);
UsedIdx = i;
continue;
}
- UsedIdx = None;
+ UsedIdx = std::nullopt;
if (UsedV != CB->getArgOperand(i))
// Can't describe writing to two distinct locations.
// TODO: This results in an inprecision when two values derived from the
// same object are passed as arguments to the same function.
- return None;
+ return std::nullopt;
}
if (!UsedV)
// We don't currently have a way to represent a "does not write" result
// and thus have to be conservative and return unknown.
- return None;
+ return std::nullopt;
if (UsedIdx)
return getForArgument(CB, *UsedIdx, &TLI);