diff options
author | Kazu Hirata <kazu@google.com> | 2022-12-02 19:43:04 -0800 |
---|---|---|
committer | Kazu Hirata <kazu@google.com> | 2022-12-02 19:43:04 -0800 |
commit | 19aff0f37dd68ee51e78b764c0ce629ae73d1eef (patch) | |
tree | 07403086631814ae1ff7742c8c6dac4fb67b5088 /llvm/lib/Analysis/LoopAccessAnalysis.cpp | |
parent | fef3a16aeab660d0789c592985993bd68b51f517 (diff) | |
download | llvm-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/LoopAccessAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/LoopAccessAnalysis.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp index eb06fb6..b65db6e 100644 --- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp +++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp @@ -1376,7 +1376,7 @@ llvm::getPtrStride(PredicatedScalarEvolution &PSE, Type *AccessTy, if (isa<ScalableVectorType>(AccessTy)) { LLVM_DEBUG(dbgs() << "LAA: Bad stride - Scalable object: " << *AccessTy << "\n"); - return None; + return std::nullopt; } const SCEV *PtrScev = replaceSymbolicStrideSCEV(PSE, StridesMap, Ptr); @@ -1388,14 +1388,14 @@ llvm::getPtrStride(PredicatedScalarEvolution &PSE, Type *AccessTy, if (!AR) { LLVM_DEBUG(dbgs() << "LAA: Bad stride - Not an AddRecExpr pointer " << *Ptr << " SCEV: " << *PtrScev << "\n"); - return None; + return std::nullopt; } // The access function must stride over the innermost loop. if (Lp != AR->getLoop()) { LLVM_DEBUG(dbgs() << "LAA: Bad stride - Not striding over innermost loop " << *Ptr << " SCEV: " << *AR << "\n"); - return None; + return std::nullopt; } // The address calculation must not wrap. Otherwise, a dependence could be @@ -1423,7 +1423,7 @@ llvm::getPtrStride(PredicatedScalarEvolution &PSE, Type *AccessTy, LLVM_DEBUG( dbgs() << "LAA: Bad stride - Pointer may wrap in the address space " << *Ptr << " SCEV: " << *AR << "\n"); - return None; + return std::nullopt; } } @@ -1435,7 +1435,7 @@ llvm::getPtrStride(PredicatedScalarEvolution &PSE, Type *AccessTy, if (!C) { LLVM_DEBUG(dbgs() << "LAA: Bad stride - Not a constant strided " << *Ptr << " SCEV: " << *AR << "\n"); - return None; + return std::nullopt; } auto &DL = Lp->getHeader()->getModule()->getDataLayout(); @@ -1445,7 +1445,7 @@ llvm::getPtrStride(PredicatedScalarEvolution &PSE, Type *AccessTy, // Huge step value - give up. if (APStepVal.getBitWidth() > 64) - return None; + return std::nullopt; int64_t StepVal = APStepVal.getSExtValue(); @@ -1453,7 +1453,7 @@ llvm::getPtrStride(PredicatedScalarEvolution &PSE, Type *AccessTy, int64_t Stride = StepVal / Size; int64_t Rem = StepVal % Size; if (Rem) - return None; + return std::nullopt; // If the SCEV could wrap but we have an inbounds gep with a unit stride we // know we can't "wrap around the address space". In case of address space @@ -1470,7 +1470,7 @@ llvm::getPtrStride(PredicatedScalarEvolution &PSE, Type *AccessTy, << "LAA: Added an overflow assumption\n"); PSE.setNoOverflow(Ptr, SCEVWrapPredicate::IncrementNUSW); } else - return None; + return std::nullopt; } return Stride; @@ -1492,14 +1492,14 @@ Optional<int> llvm::getPointersDiff(Type *ElemTyA, Value *PtrA, Type *ElemTyB, // Make sure that the element types are the same if required. if (CheckType && ElemTyA != ElemTyB) - return None; + return std::nullopt; unsigned ASA = PtrA->getType()->getPointerAddressSpace(); unsigned ASB = PtrB->getType()->getPointerAddressSpace(); // Check that the address spaces match. if (ASA != ASB) - return None; + return std::nullopt; unsigned IdxWidth = DL.getIndexSizeInBits(ASA); APInt OffsetA(IdxWidth, 0), OffsetB(IdxWidth, 0); @@ -1514,7 +1514,7 @@ Optional<int> llvm::getPointersDiff(Type *ElemTyA, Value *PtrA, Type *ElemTyB, ASB = cast<PointerType>(PtrB1->getType())->getAddressSpace(); // Check that the address spaces match and that the pointers are valid. if (ASA != ASB) - return None; + return std::nullopt; IdxWidth = DL.getIndexSizeInBits(ASA); OffsetA = OffsetA.sextOrTrunc(IdxWidth); @@ -1529,7 +1529,7 @@ Optional<int> llvm::getPointersDiff(Type *ElemTyA, Value *PtrA, Type *ElemTyB, const auto *Diff = dyn_cast<SCEVConstant>(SE.getMinusSCEV(PtrSCEVB, PtrSCEVA)); if (!Diff) - return None; + return std::nullopt; Val = Diff->getAPInt().getSExtValue(); } int Size = DL.getTypeStoreSize(ElemTyA); @@ -1539,7 +1539,7 @@ Optional<int> llvm::getPointersDiff(Type *ElemTyA, Value *PtrA, Type *ElemTyB, // the bitcasts removal in the provided pointers. if (!StrictCheck || Dist * Size == Val) return Dist; - return None; + return std::nullopt; } bool llvm::sortPtrAccesses(ArrayRef<Value *> VL, Type *ElemTy, |