From 8a7cbea525ceb4bd67e8fe097bf071c449a8e525 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Thu, 8 Dec 2022 23:21:59 -0800 Subject: [PATCH] [llvm] Use std::nullopt instead of None in comments (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 --- llvm/include/llvm/Analysis/InlineCost.h | 2 +- llvm/include/llvm/Analysis/LoopCacheAnalysis.h | 2 +- llvm/include/llvm/Analysis/LoopInfo.h | 2 +- llvm/include/llvm/Analysis/ScalarEvolution.h | 2 +- llvm/include/llvm/BinaryFormat/Dwarf.h | 2 +- llvm/include/llvm/IR/GlobalValue.h | 2 +- llvm/include/llvm/IR/Instructions.h | 2 +- llvm/include/llvm/Support/CheckedArithmetic.h | 14 +++++++------- llvm/include/llvm/Support/Threading.h | 4 ++-- llvm/include/llvm/Transforms/IPO/Attributor.h | 3 ++- llvm/include/llvm/Transforms/Utils/LoopUtils.h | 4 ++-- llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp | 4 ++-- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 2 +- llvm/lib/Target/AArch64/AArch64ISelLowering.cpp | 2 +- llvm/lib/Target/AMDGPU/AMDGPUMachineModuleInfo.h | 2 +- llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp | 9 +++++---- llvm/lib/Target/SPIRV/SPIRVBuiltins.h | 2 +- llvm/lib/Transforms/Scalar/GVNSink.cpp | 2 +- llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp | 2 +- 19 files changed, 33 insertions(+), 31 deletions(-) diff --git a/llvm/include/llvm/Analysis/InlineCost.h b/llvm/include/llvm/Analysis/InlineCost.h index cef704b..bac159f 100644 --- a/llvm/include/llvm/Analysis/InlineCost.h +++ b/llvm/include/llvm/Analysis/InlineCost.h @@ -312,7 +312,7 @@ Optional getAttributeBasedInliningDecision( /// Contrary to getInlineCost, which makes a threshold-based final evaluation of /// should/shouldn't inline, captured in InlineResult, getInliningCostEstimate /// returns: -/// - None, if the inlining cannot happen (is illegal) +/// - std::nullopt, if the inlining cannot happen (is illegal) /// - an integer, representing the cost. Optional getInliningCostEstimate( CallBase &Call, TargetTransformInfo &CalleeTTI, diff --git a/llvm/include/llvm/Analysis/LoopCacheAnalysis.h b/llvm/include/llvm/Analysis/LoopCacheAnalysis.h index 6c5a3ad..2e4f0c4 100644 --- a/llvm/include/llvm/Analysis/LoopCacheAnalysis.h +++ b/llvm/include/llvm/Analysis/LoopCacheAnalysis.h @@ -79,7 +79,7 @@ public: /// Return true if the current object and the indexed reference \p Other /// have distance smaller than \p MaxDistance in the dimension associated with /// the given loop \p L. Return false if the distance is not smaller than \p - /// MaxDistance and None if unsure. + /// MaxDistance and std::nullopt if unsure. Optional hasTemporalReuse(const IndexedReference &Other, unsigned MaxDistance, const Loop &L, DependenceInfo &DI, AAResults &AA) const; diff --git a/llvm/include/llvm/Analysis/LoopInfo.h b/llvm/include/llvm/Analysis/LoopInfo.h index 865b17b6..278ad92 100644 --- a/llvm/include/llvm/Analysis/LoopInfo.h +++ b/llvm/include/llvm/Analysis/LoopInfo.h @@ -750,7 +750,7 @@ public: }; /// Return the struct LoopBounds collected if all struct members are found, - /// else None. + /// else std::nullopt. Optional getBounds(ScalarEvolution &SE) const; /// Return the loop induction variable if found, else return nullptr. diff --git a/llvm/include/llvm/Analysis/ScalarEvolution.h b/llvm/include/llvm/Analysis/ScalarEvolution.h index dde0dcc..48fd94b 100644 --- a/llvm/include/llvm/Analysis/ScalarEvolution.h +++ b/llvm/include/llvm/Analysis/ScalarEvolution.h @@ -1190,7 +1190,7 @@ public: SmallPtrSetImpl &Preds); /// Compute \p LHS - \p RHS and returns the result as an APInt if it is a - /// constant, and None if it isn't. + /// constant, and std::nullopt if it isn't. /// /// This is intended to be a cheaper version of getMinusSCEV. We can be /// frugal here since we just bail out of actually constructing and diff --git a/llvm/include/llvm/BinaryFormat/Dwarf.h b/llvm/include/llvm/BinaryFormat/Dwarf.h index 89b239c..fedf98a 100644 --- a/llvm/include/llvm/BinaryFormat/Dwarf.h +++ b/llvm/include/llvm/BinaryFormat/Dwarf.h @@ -708,7 +708,7 @@ inline uint8_t getUnitLengthFieldByteSize(DwarfFormat Format) { /// /// If the form has a fixed byte size, then an Optional with a value will be /// returned. If the form is always encoded using a variable length storage -/// format (ULEB or SLEB numbers or blocks) then None will be returned. +/// format (ULEB or SLEB numbers or blocks) then std::nullopt will be returned. /// /// \param Form DWARF form to get the fixed byte size for. /// \param Params DWARF parameters to help interpret forms. diff --git a/llvm/include/llvm/IR/GlobalValue.h b/llvm/include/llvm/IR/GlobalValue.h index b0e17d9..d1891c1 100644 --- a/llvm/include/llvm/IR/GlobalValue.h +++ b/llvm/include/llvm/IR/GlobalValue.h @@ -638,7 +638,7 @@ public: bool isAbsoluteSymbolRef() const; /// If this is an absolute symbol reference, returns the range of the symbol, - /// otherwise returns None. + /// otherwise returns std::nullopt. std::optional getAbsoluteSymbolRange() const; /// This method unlinks 'this' from the containing module, but does not delete diff --git a/llvm/include/llvm/IR/Instructions.h b/llvm/include/llvm/IR/Instructions.h index 55486e5..0af65c9 100644 --- a/llvm/include/llvm/IR/Instructions.h +++ b/llvm/include/llvm/IR/Instructions.h @@ -5409,7 +5409,7 @@ inline Type *getLoadStoreType(Value *I) { } /// A helper function that returns an atomic operation's sync scope; returns -/// None if it is not an atomic operation. +/// std::nullopt if it is not an atomic operation. inline std::optional getAtomicSyncScopeID(const Instruction *I) { if (!I->isAtomic()) return std::nullopt; diff --git a/llvm/include/llvm/Support/CheckedArithmetic.h b/llvm/include/llvm/Support/CheckedArithmetic.h index 5bfc551..81b703a 100644 --- a/llvm/include/llvm/Support/CheckedArithmetic.h +++ b/llvm/include/llvm/Support/CheckedArithmetic.h @@ -42,7 +42,7 @@ namespace llvm { /// Add two signed integers \p LHS and \p RHS. /// \return Optional of sum if no signed overflow occurred, -/// \c None otherwise. +/// \c std::nullopt otherwise. template std::enable_if_t::value, std::optional> checkedAdd(T LHS, T RHS) { @@ -51,7 +51,7 @@ checkedAdd(T LHS, T RHS) { /// Subtract two signed integers \p LHS and \p RHS. /// \return Optional of sum if no signed overflow occurred, -/// \c None otherwise. +/// \c std::nullopt otherwise. template std::enable_if_t::value, std::optional> checkedSub(T LHS, T RHS) { @@ -60,7 +60,7 @@ checkedSub(T LHS, T RHS) { /// Multiply two signed integers \p LHS and \p RHS. /// \return Optional of product if no signed overflow occurred, -/// \c None otherwise. +/// \c std::nullopt otherwise. template std::enable_if_t::value, std::optional> checkedMul(T LHS, T RHS) { @@ -69,7 +69,7 @@ checkedMul(T LHS, T RHS) { /// Multiply A and B, and add C to the resulting product. /// \return Optional of result if no signed overflow occurred, -/// \c None otherwise. +/// \c std::nullopt otherwise. template std::enable_if_t::value, std::optional> checkedMulAdd(T A, T B, T C) { @@ -80,7 +80,7 @@ checkedMulAdd(T A, T B, T C) { /// Add two unsigned integers \p LHS and \p RHS. /// \return Optional of sum if no unsigned overflow occurred, -/// \c None otherwise. +/// \c std::nullopt otherwise. template std::enable_if_t::value, std::optional> checkedAddUnsigned(T LHS, T RHS) { @@ -89,7 +89,7 @@ checkedAddUnsigned(T LHS, T RHS) { /// Multiply two unsigned integers \p LHS and \p RHS. /// \return Optional of product if no unsigned overflow occurred, -/// \c None otherwise. +/// \c std::nullopt otherwise. template std::enable_if_t::value, std::optional> checkedMulUnsigned(T LHS, T RHS) { @@ -98,7 +98,7 @@ checkedMulUnsigned(T LHS, T RHS) { /// Multiply unsigned integers A and B, and add C to the resulting product. /// \return Optional of result if no unsigned overflow occurred, -/// \c None otherwise. +/// \c std::nullopt otherwise. template std::enable_if_t::value, std::optional> checkedMulAddUnsigned(T A, T B, T C) { diff --git a/llvm/include/llvm/Support/Threading.h b/llvm/include/llvm/Support/Threading.h index ce8dbff..ba6c531 100644 --- a/llvm/include/llvm/Support/Threading.h +++ b/llvm/include/llvm/Support/Threading.h @@ -139,8 +139,8 @@ constexpr bool llvm_is_multithreaded() { return LLVM_ENABLE_THREADS; } /// compute_thread_count()). void apply_thread_strategy(unsigned ThreadPoolNum) const; - /// Finds the CPU socket where a thread should go. Returns 'None' if the - /// thread shall remain on the actual CPU socket. + /// Finds the CPU socket where a thread should go. Returns 'std::nullopt' if + /// the thread shall remain on the actual CPU socket. std::optional compute_cpu_socket(unsigned ThreadPoolNum) const; }; diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h index c78404e..28cb568 100644 --- a/llvm/include/llvm/Transforms/IPO/Attributor.h +++ b/llvm/include/llvm/Transforms/IPO/Attributor.h @@ -4100,7 +4100,8 @@ struct AAPrivatizablePtr bool isKnownPrivatizablePtr() const { return getKnown(); } /// Return the type we can choose for a private copy of the underlying - /// value. None means it is not clear yet, nullptr means there is none. + /// value. std::nullopt means it is not clear yet, nullptr means there is + /// none. virtual std::optional getPrivatizableType() const = 0; /// Create an abstract attribute view for the position \p IRP. diff --git a/llvm/include/llvm/Transforms/Utils/LoopUtils.h b/llvm/include/llvm/Transforms/Utils/LoopUtils.h index 5f7b839..4f9c977 100644 --- a/llvm/include/llvm/Transforms/Utils/LoopUtils.h +++ b/llvm/include/llvm/Transforms/Utils/LoopUtils.h @@ -244,11 +244,11 @@ getOptionalElementCountLoopAttribute(const Loop *TheLoop); /// ; commonly used to remove metadata for the /// applied transformation. /// @param AlwaysNew If true, do not try to reuse OrigLoopID and never return -/// None. +/// std::nullopt. /// /// @return The loop ID for the after-transformation loop. The following values /// can be returned: -/// None : No followup attribute was found; it is up to the +/// std::nullopt : No followup attribute was found; it is up to the /// transformation to choose attributes that make sense. /// @p OrigLoopID: The original identifier can be reused. /// nullptr : The new loop has no attributes. diff --git a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp index 932b3bd..255e9a2 100644 --- a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp @@ -97,8 +97,8 @@ static unsigned bigEndianByteAt(const unsigned ByteWidth, const unsigned I) { /// \param MemOffset2Idx maps memory offsets to address offsets. /// \param LowestIdx is the lowest index in \p MemOffset2Idx. /// -/// \returns true if the map corresponds to a big endian byte pattern, false -/// if it corresponds to a little endian byte pattern, and None otherwise. +/// \returns true if the map corresponds to a big endian byte pattern, false if +/// it corresponds to a little endian byte pattern, and std::nullopt otherwise. /// /// E.g. given a 32-bit type x, and x[AddrOffset], the in-memory byte patterns /// are as follows: diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index b63dc05..4aaae27 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -8074,7 +8074,7 @@ static unsigned bigEndianByteAt(unsigned BW, unsigned i) { // Check if the bytes offsets we are looking at match with either big or // little endian value loaded. Return true for big endian, false for little -// endian, and None if match failed. +// endian, and std::nullopt if match failed. static Optional isBigEndian(const ArrayRef ByteOffsets, int64_t FirstOffset) { // The endian can be decided only when it is 2 bytes at least. diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp index 2ad7d8e..6592d51 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -4360,7 +4360,7 @@ static SDValue addRequiredExtensionForVectorMULL(SDValue N, SelectionDAG &DAG, } // Returns lane if Op extracts from a two-element vector and lane is constant -// (i.e., extractelt(<2 x Ty> %v, ConstantLane)), and None otherwise. +// (i.e., extractelt(<2 x Ty> %v, ConstantLane)), and std::nullopt otherwise. static std::optional getConstantLaneNumOfExtractHalfOperand(SDValue &Op) { SDNode *OpNode = Op.getNode(); diff --git a/llvm/lib/Target/AMDGPU/AMDGPUMachineModuleInfo.h b/llvm/lib/Target/AMDGPU/AMDGPUMachineModuleInfo.h index 3a23b71..b6d37cf 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUMachineModuleInfo.h +++ b/llvm/lib/Target/AMDGPU/AMDGPUMachineModuleInfo.h @@ -46,7 +46,7 @@ private: /// larger synchronization scope is inclusive of a smaller synchronization /// scope. /// - /// \returns \p SSID's inclusion ordering, or "None" if \p SSID is not + /// \returns \p SSID's inclusion ordering, or "std::nullopt" if \p SSID is not /// supported by the AMDGPU target. Optional getSyncScopeInclusionOrdering(SyncScope::ID SSID) const { if (SSID == SyncScope::SingleThread || diff --git a/llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp b/llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp index 65d95e5..2cbfcca 100644 --- a/llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp +++ b/llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp @@ -237,21 +237,22 @@ public: /// of instructions in the machine function \p MF. SIMemOpAccess(MachineFunction &MF); - /// \returns Load info if \p MI is a load operation, "None" otherwise. + /// \returns Load info if \p MI is a load operation, "std::nullopt" otherwise. Optional getLoadInfo( const MachineBasicBlock::iterator &MI) const; - /// \returns Store info if \p MI is a store operation, "None" otherwise. + /// \returns Store info if \p MI is a store operation, "std::nullopt" + /// otherwise. Optional getStoreInfo( const MachineBasicBlock::iterator &MI) const; /// \returns Atomic fence info if \p MI is an atomic fence operation, - /// "None" otherwise. + /// "std::nullopt" otherwise. Optional getAtomicFenceInfo( const MachineBasicBlock::iterator &MI) const; /// \returns Atomic cmpxchg/rmw info if \p MI is an atomic cmpxchg or - /// rmw operation, "None" otherwise. + /// rmw operation, "std::nullopt" otherwise. Optional getAtomicCmpxchgOrRmwInfo( const MachineBasicBlock::iterator &MI) const; }; diff --git a/llvm/lib/Target/SPIRV/SPIRVBuiltins.h b/llvm/lib/Target/SPIRV/SPIRVBuiltins.h index 26ffe69..26d2e8a 100644 --- a/llvm/lib/Target/SPIRV/SPIRVBuiltins.h +++ b/llvm/lib/Target/SPIRV/SPIRVBuiltins.h @@ -23,7 +23,7 @@ namespace SPIRV { /// and external instruction \p Set. /// /// \return the lowering success status if the called function is a recognized -/// builtin, None otherwise. +/// builtin, std::nullopt otherwise. /// /// \p DemangledCall is the skeleton of the lowered builtin function call. /// \p Set is the external instruction set containing the given builtin. diff --git a/llvm/lib/Transforms/Scalar/GVNSink.cpp b/llvm/lib/Transforms/Scalar/GVNSink.cpp index 4fba9f81..b44f20a 100644 --- a/llvm/lib/Transforms/Scalar/GVNSink.cpp +++ b/llvm/lib/Transforms/Scalar/GVNSink.cpp @@ -599,7 +599,7 @@ private: /// The main heuristic function. Analyze the set of instructions pointed to by /// LRI and return a candidate solution if these instructions can be sunk, or - /// None otherwise. + /// std::nullopt otherwise. Optional analyzeInstructionForSinking( LockstepReverseIterator &LRI, unsigned &InstNum, unsigned &MemoryInstNum, ModelledPHISet &NeededPHIs, SmallPtrSetImpl &PHIContents); diff --git a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp index 148af5a9..1b7b9d9 100644 --- a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp +++ b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp @@ -343,7 +343,7 @@ struct PragmaInfo { /// cost of the 'false'-block). /// \returns Optional value, holding the RolledDynamicCost and UnrolledCost. If /// the analysis failed (no benefits expected from the unrolling, or the loop is -/// too big to analyze), the returned value is None. +/// too big to analyze), the returned value is std::nullopt. static Optional analyzeLoopUnrollCost( const Loop *L, unsigned TripCount, DominatorTree &DT, ScalarEvolution &SE, const SmallPtrSetImpl &EphValues, -- 2.7.4