diff --git a/clang/include/clang/Basic/CodeGenOptions.h b/clang/include/clang/Basic/CodeGenOptions.h index 101e4761992f..24cc56c8e05d 100644 --- a/clang/include/clang/Basic/CodeGenOptions.h +++ b/clang/include/clang/Basic/CodeGenOptions.h @@ -430,7 +430,7 @@ public: /// The maximum percentage profiling weights can deviate from the expected /// values in order to be included in misexpect diagnostics. - Optional DiagnosticsMisExpectTolerance = 0; + std::optional DiagnosticsMisExpectTolerance = 0; /// The name of a file to use with \c .secure_log_unique directives. std::string AsSecureLogFile; diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index e9ad41262c3f..5a8e92139854 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -115,7 +115,7 @@ using namespace llvm::opt; // Parse misexpect tolerance argument value. // Valid option values are integers in the range [0, 100) -inline Expected> parseToleranceOption(StringRef Arg) { +static Expected> parseToleranceOption(StringRef Arg) { uint32_t Val; if (Arg.getAsInteger(10, Val)) return llvm::createStringError(llvm::inconvertibleErrorCode(), diff --git a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h index 9138248d08aa..0e9cac076902 100644 --- a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h +++ b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h @@ -1270,7 +1270,7 @@ bool BlockFrequencyInfoImpl::computeMassInLoop(LoopData &Loop) { auto &HeaderNode = Loop.Nodes[H]; const BlockT *Block = getBlock(HeaderNode); IsIrrLoopHeader.set(Loop.Nodes[H].Index); - Optional HeaderWeight = Block->getIrrLoopHeaderWeight(); + std::optional HeaderWeight = Block->getIrrLoopHeaderWeight(); if (!HeaderWeight) { LLVM_DEBUG(dbgs() << "Missing irr loop header metadata on " << getBlockName(HeaderNode) << "\n"); @@ -1734,8 +1734,8 @@ raw_ostream &BlockFrequencyInfoImpl::print(raw_ostream &OS) const { BlockFrequencyInfoImplBase::getBlockProfileCount( F->getFunction(), getNode(&BB))) OS << ", count = " << ProfileCount.value(); - if (Optional IrrLoopHeaderWeight = - BB.getIrrLoopHeaderWeight()) + if (std::optional IrrLoopHeaderWeight = + BB.getIrrLoopHeaderWeight()) OS << ", irr_loop_header_weight = " << IrrLoopHeaderWeight.value(); OS << "\n"; } diff --git a/llvm/include/llvm/AsmParser/LLParser.h b/llvm/include/llvm/AsmParser/LLParser.h index f2fba49ab705..862b9ed29394 100644 --- a/llvm/include/llvm/AsmParser/LLParser.h +++ b/llvm/include/llvm/AsmParser/LLParser.h @@ -539,7 +539,7 @@ namespace llvm { bool parseGlobalValue(Type *Ty, Constant *&C); bool parseGlobalTypeAndValue(Constant *&V); bool parseGlobalValueVector(SmallVectorImpl &Elts, - Optional *InRangeOp = nullptr); + std::optional *InRangeOp = nullptr); bool parseOptionalComdat(StringRef GlobalName, Comdat *&C); bool parseSanitizer(GlobalVariable *GV); bool parseMetadataAsValue(Value *&V, PerFunctionState &PFS); diff --git a/llvm/include/llvm/CodeGen/MachineBasicBlock.h b/llvm/include/llvm/CodeGen/MachineBasicBlock.h index fe4ad270f2a3..a1c1d0395da4 100644 --- a/llvm/include/llvm/CodeGen/MachineBasicBlock.h +++ b/llvm/include/llvm/CodeGen/MachineBasicBlock.h @@ -126,7 +126,7 @@ private: using const_probability_iterator = std::vector::const_iterator; - Optional IrrLoopHeaderWeight; + std::optional IrrLoopHeaderWeight; /// Keep track of the physical registers that are livein of the basicblock. using LiveInVector = std::vector; @@ -1121,7 +1121,7 @@ public: /// Return the EHCatchret Symbol for this basic block. MCSymbol *getEHCatchretSymbol() const; - Optional getIrrLoopHeaderWeight() const { + std::optional getIrrLoopHeaderWeight() const { return IrrLoopHeaderWeight; } diff --git a/llvm/include/llvm/IR/BasicBlock.h b/llvm/include/llvm/IR/BasicBlock.h index 57a2ace099ad..9a6def27bc7f 100644 --- a/llvm/include/llvm/IR/BasicBlock.h +++ b/llvm/include/llvm/IR/BasicBlock.h @@ -520,7 +520,7 @@ public: /// This method can only be used on blocks that have a parent function. bool isEntryBlock() const; - Optional getIrrLoopHeaderWeight() const; + std::optional getIrrLoopHeaderWeight() const; /// Returns true if the Order field of child Instructions is valid. bool isInstrOrderValid() const { diff --git a/llvm/include/llvm/IR/ConstantFold.h b/llvm/include/llvm/IR/ConstantFold.h index d637a180b0ba..77f5f0eb174a 100644 --- a/llvm/include/llvm/IR/ConstantFold.h +++ b/llvm/include/llvm/IR/ConstantFold.h @@ -21,8 +21,8 @@ #ifndef LLVM_IR_CONSTANTFOLD_H #define LLVM_IR_CONSTANTFOLD_H -#include "llvm/ADT/Optional.h" #include "llvm/IR/InstrTypes.h" +#include namespace llvm { template class ArrayRef; @@ -53,7 +53,7 @@ namespace llvm { Constant *ConstantFoldCompareInstruction(CmpInst::Predicate Predicate, Constant *C1, Constant *C2); Constant *ConstantFoldGetElementPtr(Type *Ty, Constant *C, bool InBounds, - Optional InRangeIndex, + std::optional InRangeIndex, ArrayRef Idxs); } // End llvm namespace diff --git a/llvm/include/llvm/IR/ConstantRange.h b/llvm/include/llvm/IR/ConstantRange.h index 4bbc8407b524..0b9ac18d0a92 100644 --- a/llvm/include/llvm/IR/ConstantRange.h +++ b/llvm/include/llvm/IR/ConstantRange.h @@ -334,11 +334,12 @@ public: /// Intersect the two ranges and return the result if it can be represented /// exactly, otherwise return std::nullopt. - Optional exactIntersectWith(const ConstantRange &CR) const; + std::optional + exactIntersectWith(const ConstantRange &CR) const; /// Union the two ranges and return the result if it can be represented /// exactly, otherwise return std::nullopt. - Optional exactUnionWith(const ConstantRange &CR) const; + std::optional exactUnionWith(const ConstantRange &CR) const; /// Return a new range representing the possible values resulting /// from an application of the specified cast operator to this range. \p diff --git a/llvm/include/llvm/IR/Constants.h b/llvm/include/llvm/IR/Constants.h index d39445832f79..f6c1986f3823 100644 --- a/llvm/include/llvm/IR/Constants.h +++ b/llvm/include/llvm/IR/Constants.h @@ -24,7 +24,6 @@ #include "llvm/ADT/APInt.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/None.h" -#include "llvm/ADT/Optional.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/IR/Constant.h" @@ -38,6 +37,7 @@ #include #include #include +#include namespace llvm { @@ -1218,7 +1218,7 @@ public: static Constant * getGetElementPtr(Type *Ty, Constant *C, ArrayRef IdxList, bool InBounds = false, - Optional InRangeIndex = std::nullopt, + std::optional InRangeIndex = std::nullopt, Type *OnlyIfReducedTy = nullptr) { return getGetElementPtr( Ty, C, makeArrayRef((Value *const *)IdxList.data(), IdxList.size()), @@ -1226,7 +1226,7 @@ public: } static Constant * getGetElementPtr(Type *Ty, Constant *C, Constant *Idx, bool InBounds = false, - Optional InRangeIndex = std::nullopt, + std::optional InRangeIndex = std::nullopt, Type *OnlyIfReducedTy = nullptr) { // This form of the function only exists to avoid ambiguous overload // warnings about whether to convert Idx to ArrayRef or @@ -1237,7 +1237,7 @@ public: static Constant * getGetElementPtr(Type *Ty, Constant *C, ArrayRef IdxList, bool InBounds = false, - Optional InRangeIndex = std::nullopt, + std::optional InRangeIndex = std::nullopt, Type *OnlyIfReducedTy = nullptr); /// Create an "inbounds" getelementptr. See the documentation for the diff --git a/llvm/include/llvm/IR/DataLayout.h b/llvm/include/llvm/IR/DataLayout.h index d607c2a76679..f4174ede22fb 100644 --- a/llvm/include/llvm/IR/DataLayout.h +++ b/llvm/include/llvm/IR/DataLayout.h @@ -595,7 +595,7 @@ public: /// if index cannot be computed, e.g. because the type is not an aggregate. /// ElemTy is updated to be the result element type and Offset to be the /// residual offset. - Optional getGEPIndexForOffset(Type *&ElemTy, APInt &Offset) const; + std::optional getGEPIndexForOffset(Type *&ElemTy, APInt &Offset) const; /// Returns a StructLayout object, indicating the alignment of the /// struct, its size, and the offsets of its fields. diff --git a/llvm/include/llvm/IR/DiagnosticInfo.h b/llvm/include/llvm/IR/DiagnosticInfo.h index 0a1c4abdd56a..f3abce37b167 100644 --- a/llvm/include/llvm/IR/DiagnosticInfo.h +++ b/llvm/include/llvm/IR/DiagnosticInfo.h @@ -16,7 +16,6 @@ #include "llvm-c/Types.h" #include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Twine.h" @@ -29,6 +28,7 @@ #include #include #include +#include #include namespace llvm { diff --git a/llvm/include/llvm/IR/Function.h b/llvm/include/llvm/IR/Function.h index 22e98e91d458..2ad19e6eafc0 100644 --- a/llvm/include/llvm/IR/Function.h +++ b/llvm/include/llvm/IR/Function.h @@ -280,7 +280,7 @@ public: /// /// Entry count is the number of times the function was executed. /// When AllowSynthetic is false, only pgo_data will be returned. - Optional getEntryCount(bool AllowSynthetic = false) const; + std::optional getEntryCount(bool AllowSynthetic = false) const; /// Return true if the function is annotated with profile data. /// @@ -299,7 +299,7 @@ public: void setSectionPrefix(StringRef Prefix); /// Get the section prefix for this function. - Optional getSectionPrefix() const; + std::optional getSectionPrefix() const; /// hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm /// to use during code generation. diff --git a/llvm/include/llvm/IR/GCStrategy.h b/llvm/include/llvm/IR/GCStrategy.h index b83a4bf72608..660ac3d47993 100644 --- a/llvm/include/llvm/IR/GCStrategy.h +++ b/llvm/include/llvm/IR/GCStrategy.h @@ -48,8 +48,8 @@ #define LLVM_IR_GCSTRATEGY_H #include "llvm/ADT/None.h" -#include "llvm/ADT/Optional.h" #include "llvm/Support/Registry.h" +#include #include namespace llvm { @@ -94,7 +94,7 @@ public: /// pointers to GC managed locations and false for pointers to non-GC /// managed locations. Note a GCStrategy can always return 'None' (i.e. an /// empty optional indicating it can't reliably distinguish. - virtual Optional isGCManagedPointer(const Type *Ty) const { + virtual std::optional isGCManagedPointer(const Type *Ty) const { return std::nullopt; } ///@} diff --git a/llvm/include/llvm/IR/GlobalValue.h b/llvm/include/llvm/IR/GlobalValue.h index f92e1a324dad..b0e17d9553f7 100644 --- a/llvm/include/llvm/IR/GlobalValue.h +++ b/llvm/include/llvm/IR/GlobalValue.h @@ -638,8 +638,8 @@ public: bool isAbsoluteSymbolRef() const; /// If this is an absolute symbol reference, returns the range of the symbol, - /// otherwise returns std::nullopt. - Optional getAbsoluteSymbolRange() const; + /// otherwise returns None. + std::optional getAbsoluteSymbolRange() const; /// This method unlinks 'this' from the containing module, but does not delete /// it. diff --git a/llvm/include/llvm/IR/GlobalVariable.h b/llvm/include/llvm/IR/GlobalVariable.h index 9db5b04c1492..03c680e4f955 100644 --- a/llvm/include/llvm/IR/GlobalVariable.h +++ b/llvm/include/llvm/IR/GlobalVariable.h @@ -59,7 +59,7 @@ public: Constant *Initializer, const Twine &Name = "", GlobalVariable *InsertBefore = nullptr, ThreadLocalMode = NotThreadLocal, - Optional AddressSpace = std::nullopt, + std::optional AddressSpace = std::nullopt, bool isExternallyInitialized = false); GlobalVariable(const GlobalVariable &) = delete; GlobalVariable &operator=(const GlobalVariable &) = delete; diff --git a/llvm/include/llvm/IR/Intrinsics.h b/llvm/include/llvm/IR/Intrinsics.h index 559e5eef5259..7459ea9e689d 100644 --- a/llvm/include/llvm/IR/Intrinsics.h +++ b/llvm/include/llvm/IR/Intrinsics.h @@ -17,8 +17,8 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/None.h" -#include "llvm/ADT/Optional.h" #include "llvm/Support/TypeSize.h" +#include #include namespace llvm { @@ -250,7 +250,7 @@ namespace Intrinsic { // returns the declaration with the same signature and remangled name. // An existing GlobalValue with the wanted name but with a wrong prototype // or of the wrong kind will be renamed by adding ".renamed" to the name. - llvm::Optional remangleIntrinsicFunction(Function *F); + std::optional remangleIntrinsicFunction(Function *F); } // End Intrinsic namespace diff --git a/llvm/include/llvm/IR/LLVMContext.h b/llvm/include/llvm/IR/LLVMContext.h index 55c68691730f..c380ed215b6c 100644 --- a/llvm/include/llvm/IR/LLVMContext.h +++ b/llvm/include/llvm/IR/LLVMContext.h @@ -15,11 +15,11 @@ #define LLVM_IR_LLVMCONTEXT_H #include "llvm-c/Types.h" -#include "llvm/ADT/Optional.h" #include "llvm/IR/DiagnosticHandler.h" #include "llvm/Support/CBindingWrapping.h" #include #include +#include #include namespace llvm { @@ -205,7 +205,7 @@ public: bool getMisExpectWarningRequested() const; void setMisExpectWarningRequested(bool Requested); - void setDiagnosticsMisExpectTolerance(Optional Tolerance); + void setDiagnosticsMisExpectTolerance(std::optional Tolerance); uint32_t getDiagnosticsMisExpectTolerance() const; /// Return the minimum hotness value a diagnostic would need in order diff --git a/llvm/include/llvm/IR/Module.h b/llvm/include/llvm/IR/Module.h index 0dd1b81326a3..cd71a848addb 100644 --- a/llvm/include/llvm/IR/Module.h +++ b/llvm/include/llvm/IR/Module.h @@ -15,7 +15,6 @@ #define LLVM_IR_MODULE_H #include "llvm-c/Types.h" -#include "llvm/ADT/Optional.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" diff --git a/llvm/include/llvm/IR/Operator.h b/llvm/include/llvm/IR/Operator.h index ed52535c0b6e..215b1d36837e 100644 --- a/llvm/include/llvm/IR/Operator.h +++ b/llvm/include/llvm/IR/Operator.h @@ -16,7 +16,6 @@ #include "llvm/ADT/MapVector.h" #include "llvm/ADT/None.h" -#include "llvm/ADT/Optional.h" #include "llvm/IR/Constants.h" #include "llvm/IR/FMF.h" #include "llvm/IR/Instruction.h" @@ -24,6 +23,7 @@ #include "llvm/IR/Value.h" #include "llvm/Support/Casting.h" #include +#include namespace llvm { @@ -395,7 +395,7 @@ public: /// Returns the offset of the index with an inrange attachment, or /// std::nullopt if none. - Optional getInRangeIndex() const { + std::optional getInRangeIndex() const { if (SubclassOptionalData >> 1 == 0) return std::nullopt; return (SubclassOptionalData >> 1) - 1; diff --git a/llvm/include/llvm/IR/PseudoProbe.h b/llvm/include/llvm/IR/PseudoProbe.h index 1c109eafde57..79726c0eee8b 100644 --- a/llvm/include/llvm/IR/PseudoProbe.h +++ b/llvm/include/llvm/IR/PseudoProbe.h @@ -13,10 +13,10 @@ #ifndef LLVM_IR_PSEUDOPROBE_H #define LLVM_IR_PSEUDOPROBE_H -#include "llvm/ADT/Optional.h" #include #include #include +#include namespace llvm { @@ -91,7 +91,7 @@ static inline bool isSentinelProbe(uint32_t Flags) { return Flags & (uint32_t)PseudoProbeAttributes::Sentinel; } -Optional extractProbe(const Instruction &Inst); +std::optional extractProbe(const Instruction &Inst); void setProbeDistributionFactor(Instruction &Inst, float Factor); } // end namespace llvm diff --git a/llvm/include/llvm/IR/Statepoint.h b/llvm/include/llvm/IR/Statepoint.h index 8b6ffd2e0897..21c4a3eaa5ac 100644 --- a/llvm/include/llvm/IR/Statepoint.h +++ b/llvm/include/llvm/IR/Statepoint.h @@ -16,7 +16,6 @@ #ifndef LLVM_IR_STATEPOINT_H #define LLVM_IR_STATEPOINT_H -#include "llvm/ADT/Optional.h" #include "llvm/ADT/iterator_range.h" #include "llvm/IR/Attributes.h" #include "llvm/IR/Constants.h" diff --git a/llvm/include/llvm/IR/ValueMap.h b/llvm/include/llvm/IR/ValueMap.h index a8c905631055..5e26f68efdc8 100644 --- a/llvm/include/llvm/IR/ValueMap.h +++ b/llvm/include/llvm/IR/ValueMap.h @@ -28,7 +28,6 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseMapInfo.h" #include "llvm/ADT/None.h" -#include "llvm/ADT/Optional.h" #include "llvm/IR/TrackingMDRef.h" #include "llvm/IR/ValueHandle.h" #include "llvm/Support/Casting.h" @@ -38,6 +37,7 @@ #include #include #include +#include #include #include @@ -91,7 +91,7 @@ class ValueMap { using ExtraData = typename Config::ExtraData; MapT Map; - Optional MDMap; + std::optional MDMap; ExtraData Data; public: @@ -117,10 +117,10 @@ public: MDMap.emplace(); return *MDMap; } - Optional &getMDMap() { return MDMap; } + std::optional &getMDMap() { return MDMap; } /// Get the mapped metadata, if it's in the map. - Optional getMappedMD(const Metadata *MD) const { + std::optional getMappedMD(const Metadata *MD) const { if (!MDMap) return std::nullopt; auto Where = MDMap->find(MD); diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index f2a56d6249a5..f07113af8404 100644 --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/lib/Analysis/ConstantFolding.cpp @@ -825,7 +825,7 @@ Constant *SymbolicallyEvaluateBinop(unsigned Opc, Constant *Op0, Constant *Op1, /// If array indices are not pointer-sized integers, explicitly cast them so /// that they aren't implicitly casted by the getelementptr. Constant *CastGEPIndices(Type *SrcElemTy, ArrayRef Ops, - Type *ResultTy, Optional InRangeIndex, + Type *ResultTy, std::optional InRangeIndex, const DataLayout &DL, const TargetLibraryInfo *TLI) { Type *IntIdxTy = DL.getIndexType(ResultTy); Type *IntIdxScalarTy = IntIdxTy->getScalarType(); @@ -992,8 +992,8 @@ Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP, // Preserve the inrange index from the innermost GEP if possible. We must // have calculated the same indices up to and including the inrange index. - Optional InRangeIndex; - if (Optional LastIRIndex = InnermostGEP->getInRangeIndex()) + std::optional InRangeIndex; + if (std::optional LastIRIndex = InnermostGEP->getInRangeIndex()) if (SrcElemTy == InnermostGEP->getSourceElementType() && NewIdxs.size() > *LastIRIndex) { InRangeIndex = LastIRIndex; diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index 2c1a94b12b31..76cb5ee6944f 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -3855,7 +3855,7 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) { return true; } - Optional InRangeOp; + std::optional InRangeOp; if (parseGlobalValueVector( Elts, Opc == Instruction::GetElementPtr ? &InRangeOp : nullptr) || parseToken(lltok::rparen, "expected ')' in constantexpr")) @@ -3998,7 +3998,7 @@ bool LLParser::parseOptionalComdat(StringRef GlobalName, Comdat *&C) { /// ::= /*empty*/ /// ::= [inrange] TypeAndValue (',' [inrange] TypeAndValue)* bool LLParser::parseGlobalValueVector(SmallVectorImpl &Elts, - Optional *InRangeOp) { + std::optional *InRangeOp) { // Empty list. if (Lex.getKind() == lltok::rbrace || Lex.getKind() == lltok::rsquare || diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 1d5d10a22728..b5f185171ba1 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -551,7 +551,7 @@ public: return makeArrayRef(getTrailingObjects(), NumOperands); } - Optional getInRangeIndex() const { + std::optional getInRangeIndex() const { assert(Opcode == Instruction::GetElementPtr); if (Extra == (unsigned)-1) return std::nullopt; diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index ff64435e7588..12358bbf8d0d 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -2657,7 +2657,7 @@ void ModuleBitcodeWriter::writeConstants(unsigned FirstVal, unsigned LastVal, Code = bitc::CST_CODE_CE_GEP; const auto *GO = cast(C); Record.push_back(VE.getTypeID(GO->getSourceElementType())); - if (Optional Idx = GO->getInRangeIndex()) { + if (std::optional Idx = GO->getInRangeIndex()) { Code = bitc::CST_CODE_CE_GEP_WITH_INRANGE_INDEX; Record.push_back((*Idx << 1) | GO->isInBounds()); } else if (GO->isInBounds()) diff --git a/llvm/lib/CodeGen/MachineFunctionSplitter.cpp b/llvm/lib/CodeGen/MachineFunctionSplitter.cpp index e8d233385161..29caf7204c42 100644 --- a/llvm/lib/CodeGen/MachineFunctionSplitter.cpp +++ b/llvm/lib/CodeGen/MachineFunctionSplitter.cpp @@ -185,7 +185,7 @@ bool MachineFunctionSplitter::runOnMachineFunction(MachineFunction &MF) { // We don't want to proceed further for cold functions // or functions of unknown hotness. Lukewarm functions have no prefix. - Optional SectionPrefix = MF.getFunction().getSectionPrefix(); + std::optional SectionPrefix = MF.getFunction().getSectionPrefix(); if (SectionPrefix && (SectionPrefix.value().equals("unlikely") || SectionPrefix.value().equals("unknown"))) { return false; diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index b9ee79031425..b2d56adfbeab 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -670,7 +670,7 @@ getELFSectionNameForGlobal(const GlobalObject *GO, SectionKind Kind, bool HasPrefix = false; if (const auto *F = dyn_cast(GO)) { - if (Optional Prefix = F->getSectionPrefix()) { + if (std::optional Prefix = F->getSectionPrefix()) { raw_svector_ostream(Name) << '.' << *Prefix; HasPrefix = true; } @@ -1720,7 +1720,7 @@ MCSection *TargetLoweringObjectFileCOFF::SelectSectionForGlobal( StringRef COMDATSymName = Sym->getName(); if (const auto *F = dyn_cast(GO)) - if (Optional Prefix = F->getSectionPrefix()) + if (std::optional Prefix = F->getSectionPrefix()) raw_svector_ostream(Name) << '$' << *Prefix; // Append "$symbol" to the section name *before* IR-level mangling is diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp index af80b47449e4..3ca17648a703 100644 --- a/llvm/lib/IR/AsmWriter.cpp +++ b/llvm/lib/IR/AsmWriter.cpp @@ -20,7 +20,6 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/None.h" -#include "llvm/ADT/Optional.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SetVector.h" #include "llvm/ADT/SmallPtrSet.h" @@ -1580,7 +1579,7 @@ static void WriteConstantInternal(raw_ostream &Out, const Constant *CV, static_cast(CE->getPredicate())); Out << " ("; - Optional InRangeOp; + std::optional InRangeOp; if (const GEPOperator *GEP = dyn_cast(CE)) { WriterCtx.TypePrinter->print(GEP->getSourceElementType(), Out); Out << ", "; @@ -1676,7 +1675,7 @@ struct MDFieldPrinter { void printAPInt(StringRef Name, const APInt &Int, bool IsUnsigned, bool ShouldSkipZero); void printBool(StringRef Name, bool Value, - Optional Default = std::nullopt); + std::optional Default = std::nullopt); void printDIFlags(StringRef Name, DINode::DIFlags Flags); void printDISPFlags(StringRef Name, DISubprogram::DISPFlags Flags); template @@ -1760,7 +1759,7 @@ void MDFieldPrinter::printAPInt(StringRef Name, const APInt &Int, } void MDFieldPrinter::printBool(StringRef Name, bool Value, - Optional Default) { + std::optional Default) { if (Default && Value == *Default) return; Out << FS << Name << ": " << (Value ? "true" : "false"); diff --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp index 7a30005eb981..f2ecd6ea3c85 100644 --- a/llvm/lib/IR/BasicBlock.cpp +++ b/llvm/lib/IR/BasicBlock.cpp @@ -519,14 +519,14 @@ const LandingPadInst *BasicBlock::getLandingPadInst() const { return dyn_cast(getFirstNonPHI()); } -Optional BasicBlock::getIrrLoopHeaderWeight() const { +std::optional BasicBlock::getIrrLoopHeaderWeight() const { const Instruction *TI = getTerminator(); if (MDNode *MDIrrLoopHeader = TI->getMetadata(LLVMContext::MD_irr_loop)) { MDString *MDName = cast(MDIrrLoopHeader->getOperand(0)); if (MDName->getString().equals("loop_header_weight")) { auto *CI = mdconst::extract(MDIrrLoopHeader->getOperand(1)); - return Optional(CI->getValue().getZExtValue()); + return std::optional(CI->getValue().getZExtValue()); } } return std::nullopt; diff --git a/llvm/lib/IR/BuiltinGCs.cpp b/llvm/lib/IR/BuiltinGCs.cpp index dc7cb815f7d4..1a7100a0d7a9 100644 --- a/llvm/lib/IR/BuiltinGCs.cpp +++ b/llvm/lib/IR/BuiltinGCs.cpp @@ -72,7 +72,7 @@ public: UsesMetadata = false; } - Optional isGCManagedPointer(const Type *Ty) const override { + std::optional isGCManagedPointer(const Type *Ty) const override { // Method is only valid on pointer typed values. const PointerType *PT = cast(Ty); // For the sake of this example GC, we arbitrarily pick addrspace(1) as our @@ -104,7 +104,7 @@ public: UsesMetadata = false; } - Optional isGCManagedPointer(const Type *Ty) const override { + std::optional isGCManagedPointer(const Type *Ty) const override { // Method is only valid on pointer typed values. const PointerType *PT = cast(Ty); // We pick addrspace(1) as our GC managed heap. diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp index 1815bba02138..a487aa4145a1 100644 --- a/llvm/lib/IR/ConstantFold.cpp +++ b/llvm/lib/IR/ConstantFold.cpp @@ -2022,7 +2022,7 @@ static Constant *foldGEPOfGEP(GEPOperator *GEP, Type *PointeeTy, bool InBounds, // The combined GEP normally inherits its index inrange attribute from // the inner GEP, but if the inner GEP's last index was adjusted by the // outer GEP, any inbounds attribute on that index is invalidated. - Optional IRIndex = GEP->getInRangeIndex(); + std::optional IRIndex = GEP->getInRangeIndex(); if (IRIndex && *IRIndex == GEP->getNumIndices() - 1) IRIndex = std::nullopt; @@ -2033,7 +2033,7 @@ static Constant *foldGEPOfGEP(GEPOperator *GEP, Type *PointeeTy, bool InBounds, Constant *llvm::ConstantFoldGetElementPtr(Type *PointeeTy, Constant *C, bool InBounds, - Optional InRangeIndex, + std::optional InRangeIndex, ArrayRef Idxs) { if (Idxs.empty()) return C; diff --git a/llvm/lib/IR/ConstantRange.cpp b/llvm/lib/IR/ConstantRange.cpp index d443f2cb847e..553e56597094 100644 --- a/llvm/lib/IR/ConstantRange.cpp +++ b/llvm/lib/IR/ConstantRange.cpp @@ -699,7 +699,7 @@ ConstantRange ConstantRange::unionWith(const ConstantRange &CR, return ConstantRange(std::move(L), std::move(U)); } -Optional +std::optional ConstantRange::exactIntersectWith(const ConstantRange &CR) const { // TODO: This can be implemented more efficiently. ConstantRange Result = intersectWith(CR); @@ -708,7 +708,7 @@ ConstantRange::exactIntersectWith(const ConstantRange &CR) const { return std::nullopt; } -Optional +std::optional ConstantRange::exactUnionWith(const ConstantRange &CR) const { // TODO: This can be implemented more efficiently. ConstantRange Result = unionWith(CR); diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index adbc158c8c1e..b7126adb9f4c 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -2430,7 +2430,7 @@ Constant *ConstantExpr::getSelect(Constant *C, Constant *V1, Constant *V2, Constant *ConstantExpr::getGetElementPtr(Type *Ty, Constant *C, ArrayRef Idxs, bool InBounds, - Optional InRangeIndex, + std::optional InRangeIndex, Type *OnlyIfReducedTy) { PointerType *OrigPtrTy = cast(C->getType()->getScalarType()); assert(Ty && "Must specify element type"); diff --git a/llvm/lib/IR/DataLayout.cpp b/llvm/lib/IR/DataLayout.cpp index e451234eaa4d..4bd088714d4b 100644 --- a/llvm/lib/IR/DataLayout.cpp +++ b/llvm/lib/IR/DataLayout.cpp @@ -925,8 +925,8 @@ static APInt getElementIndex(TypeSize ElemSize, APInt &Offset) { return Index; } -Optional DataLayout::getGEPIndexForOffset(Type *&ElemTy, - APInt &Offset) const { +std::optional DataLayout::getGEPIndexForOffset(Type *&ElemTy, + APInt &Offset) const { if (auto *ArrTy = dyn_cast(ElemTy)) { ElemTy = ArrTy->getElementType(); return getElementIndex(getTypeAllocSize(ElemTy), Offset); @@ -964,7 +964,7 @@ SmallVector DataLayout::getGEPIndicesForOffset(Type *&ElemTy, SmallVector Indices; Indices.push_back(getElementIndex(getTypeAllocSize(ElemTy), Offset)); while (Offset != 0) { - Optional Index = getGEPIndexForOffset(ElemTy, Offset); + std::optional Index = getGEPIndexForOffset(ElemTy, Offset); if (!Index) break; Indices.push_back(*Index); diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp index 51ef4d0972f2..9912e1a9b7ea 100644 --- a/llvm/lib/IR/Function.cpp +++ b/llvm/lib/IR/Function.cpp @@ -1843,7 +1843,7 @@ bool Intrinsic::getIntrinsicSignature(Function *F, return true; } -Optional Intrinsic::remangleIntrinsicFunction(Function *F) { +std::optional Intrinsic::remangleIntrinsicFunction(Function *F) { SmallVector ArgTys; if (!getIntrinsicSignature(F, ArgTys)) return std::nullopt; @@ -2051,7 +2051,7 @@ void Function::setEntryCount(uint64_t Count, Function::ProfileCountType Type, setEntryCount(ProfileCount(Count, Type), Imports); } -Optional Function::getEntryCount(bool AllowSynthetic) const { +std::optional Function::getEntryCount(bool AllowSynthetic) const { MDNode *MD = getMetadata(LLVMContext::MD_prof); if (MD && MD->getOperand(0)) if (MDString *MDS = dyn_cast(MD->getOperand(0))) { @@ -2091,7 +2091,7 @@ void Function::setSectionPrefix(StringRef Prefix) { MDB.createFunctionSectionPrefix(Prefix)); } -Optional Function::getSectionPrefix() const { +std::optional Function::getSectionPrefix() const { if (MDNode *MD = getMetadata(LLVMContext::MD_section_prefix)) { assert(cast(MD->getOperand(0)) ->getString() diff --git a/llvm/lib/IR/Globals.cpp b/llvm/lib/IR/Globals.cpp index 7169ca2c3401..ac9b830f9952 100644 --- a/llvm/lib/IR/Globals.cpp +++ b/llvm/lib/IR/Globals.cpp @@ -370,7 +370,7 @@ bool GlobalValue::isAbsoluteSymbolRef() const { return GO->getMetadata(LLVMContext::MD_absolute_symbol); } -Optional GlobalValue::getAbsoluteSymbolRange() const { +std::optional GlobalValue::getAbsoluteSymbolRange() const { auto *GO = dyn_cast(this); if (!GO) return std::nullopt; @@ -427,7 +427,7 @@ GlobalVariable::GlobalVariable(Module &M, Type *Ty, bool constant, LinkageTypes Link, Constant *InitVal, const Twine &Name, GlobalVariable *Before, ThreadLocalMode TLMode, - Optional AddressSpace, + std::optional AddressSpace, bool isExternallyInitialized) : GlobalObject(Ty, Value::GlobalVariableVal, OperandTraits::op_begin(this), diff --git a/llvm/lib/IR/LLVMContext.cpp b/llvm/lib/IR/LLVMContext.cpp index dc8671480a68..2b5577595ee3 100644 --- a/llvm/lib/IR/LLVMContext.cpp +++ b/llvm/lib/IR/LLVMContext.cpp @@ -153,7 +153,7 @@ uint64_t LLVMContext::getDiagnosticsHotnessThreshold() const { return pImpl->DiagnosticsHotnessThreshold.value_or(UINT64_MAX); } void LLVMContext::setDiagnosticsMisExpectTolerance( - Optional Tolerance) { + std::optional Tolerance) { pImpl->DiagnosticsMisExpectTolerance = Tolerance; } uint32_t LLVMContext::getDiagnosticsMisExpectTolerance() const { diff --git a/llvm/lib/IR/LLVMContextImpl.h b/llvm/lib/IR/LLVMContextImpl.h index 469705166b43..99270daf1974 100644 --- a/llvm/lib/IR/LLVMContextImpl.h +++ b/llvm/lib/IR/LLVMContextImpl.h @@ -24,7 +24,6 @@ #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/Hashing.h" -#include "llvm/ADT/Optional.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" @@ -1389,7 +1388,7 @@ public: /// The percentage of difference between profiling branch weights and /// llvm.expect branch weights to tolerate when emiting MisExpect diagnostics - Optional DiagnosticsMisExpectTolerance = 0; + std::optional DiagnosticsMisExpectTolerance = 0; bool MisExpectWarningRequested = false; /// The specialized remark streamer used by LLVM's OptimizationRemarkEmitter. @@ -1421,7 +1420,7 @@ public: #include "llvm/IR/Metadata.def" // Optional map for looking up composite types by identifier. - Optional> DITypeMap; + std::optional> DITypeMap; // MDNodes may be uniqued or not uniqued. When they're not uniqued, they // aren't in the MDNodeSet, but they're still shared between objects, so no @@ -1580,7 +1579,7 @@ public: void setOpaquePointers(bool OP); private: - Optional OpaquePointers; + std::optional OpaquePointers; }; } // end namespace llvm diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp index 1f2f86fc1e0c..49fadc9ed7e6 100644 --- a/llvm/lib/IR/Module.cpp +++ b/llvm/lib/IR/Module.cpp @@ -12,7 +12,6 @@ #include "llvm/IR/Module.h" #include "SymbolTableListTraitsImpl.h" -#include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" diff --git a/llvm/lib/IR/PassManager.cpp b/llvm/lib/IR/PassManager.cpp index a2e9a7c62589..ef850b8235b9 100644 --- a/llvm/lib/IR/PassManager.cpp +++ b/llvm/lib/IR/PassManager.cpp @@ -8,7 +8,6 @@ #include "llvm/IR/PassManager.h" #include "llvm/ADT/DenseMapInfo.h" -#include "llvm/ADT/Optional.h" #include "llvm/IR/PassManagerImpl.h" #include diff --git a/llvm/lib/IR/PseudoProbe.cpp b/llvm/lib/IR/PseudoProbe.cpp index ae307d871f59..f3802af26a61 100644 --- a/llvm/lib/IR/PseudoProbe.cpp +++ b/llvm/lib/IR/PseudoProbe.cpp @@ -21,7 +21,8 @@ using namespace llvm; namespace llvm { -Optional extractProbeFromDiscriminator(const Instruction &Inst) { +std::optional +extractProbeFromDiscriminator(const Instruction &Inst) { assert(isa(&Inst) && !isa(&Inst) && "Only call instructions should have pseudo probe encodes as their " "Dwarf discriminators"); @@ -45,7 +46,7 @@ Optional extractProbeFromDiscriminator(const Instruction &Inst) { return std::nullopt; } -Optional extractProbe(const Instruction &Inst) { +std::optional extractProbe(const Instruction &Inst) { if (const auto *II = dyn_cast(&Inst)) { PseudoProbe Probe; Probe.Id = II->getIndex()->getZExtValue(); diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 836990030aee..b487d24ab8da 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -48,7 +48,6 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/MapVector.h" -#include "llvm/ADT/Optional.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallSet.h" diff --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp index e4d381509b21..548dd06559c5 100644 --- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp +++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp @@ -2690,7 +2690,7 @@ bool X86DAGToDAGISel::selectMOV64Imm32(SDValue N, SDValue &Imm) { if (N->getOpcode() != ISD::TargetGlobalAddress) return TM.getCodeModel() == CodeModel::Small; - Optional CR = + std::optional CR = cast(N)->getGlobal()->getAbsoluteSymbolRange(); if (!CR) return TM.getCodeModel() == CodeModel::Small; @@ -2872,7 +2872,7 @@ bool X86DAGToDAGISel::selectRelocImm(SDValue N, SDValue &Op) { // Check that the global's range fits into VT. auto *GA = cast(N.getOperand(0)); - Optional CR = GA->getGlobal()->getAbsoluteSymbolRange(); + std::optional CR = GA->getGlobal()->getAbsoluteSymbolRange(); if (!CR || CR->getUnsignedMax().uge(1ull << VT.getSizeInBits())) return false; @@ -2929,7 +2929,7 @@ bool X86DAGToDAGISel::isSExtAbsoluteSymbolRef(unsigned Width, SDNode *N) const { if (!GA) return false; - Optional CR = GA->getGlobal()->getAbsoluteSymbolRange(); + std::optional CR = GA->getGlobal()->getAbsoluteSymbolRange(); if (!CR) return Width == 32 && TM.getCodeModel() == CodeModel::Small; diff --git a/llvm/lib/Target/X86/X86Subtarget.cpp b/llvm/lib/Target/X86/X86Subtarget.cpp index 0d091adc8e77..e991cde5ffbf 100644 --- a/llvm/lib/Target/X86/X86Subtarget.cpp +++ b/llvm/lib/Target/X86/X86Subtarget.cpp @@ -137,7 +137,7 @@ unsigned char X86Subtarget::classifyGlobalReference(const GlobalValue *GV, // Absolute symbols can be referenced directly. if (GV) { - if (Optional CR = GV->getAbsoluteSymbolRange()) { + if (std::optional CR = GV->getAbsoluteSymbolRange()) { // See if we can use the 8-bit immediate form. Note that some instructions // will sign extend the immediate operand, so to be conservative we only // accept the range [0,128). diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp index deca83d4d62d..f3e8cda6642c 100644 --- a/llvm/lib/Transforms/IPO/SampleProfile.cpp +++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp @@ -620,7 +620,7 @@ ErrorOr SampleProfileLoader::getInstWeight(const Instruction &Inst) { ErrorOr SampleProfileLoader::getProbeWeight(const Instruction &Inst) { assert(FunctionSamples::ProfileIsProbeBased && "Profile is not pseudo probe based"); - Optional Probe = extractProbe(Inst); + std::optional Probe = extractProbe(Inst); // Ignore the non-probe instruction. If none of the instruction in the BB is // probe, we choose to infer the BB's weight. if (!Probe) @@ -773,7 +773,7 @@ SampleProfileLoader::findIndirectCallFunctionSamples( const FunctionSamples * SampleProfileLoader::findFunctionSamples(const Instruction &Inst) const { if (FunctionSamples::ProfileIsProbeBased) { - Optional Probe = extractProbe(Inst); + std::optional Probe = extractProbe(Inst); if (!Probe) return nullptr; } @@ -1286,7 +1286,7 @@ bool SampleProfileLoader::tryInlineCandidate( // aggregation of duplication. if (Candidate.CallsiteDistribution < 1) { for (auto &I : IFI.InlinedCallSites) { - if (Optional Probe = extractProbe(*I)) + if (std::optional Probe = extractProbe(*I)) setProbeDistributionFactor(*I, Probe->Factor * Candidate.CallsiteDistribution); } @@ -1311,7 +1311,7 @@ bool SampleProfileLoader::getInlineCandidate(InlineCandidate *NewCandidate, return false; float Factor = 1.0; - if (Optional Probe = extractProbe(*CB)) + if (std::optional Probe = extractProbe(*CB)) Factor = Probe->Factor; uint64_t CallsiteCount = @@ -1636,7 +1636,7 @@ void SampleProfileLoader::generateMDProfMetadata(Function &F) { // Prorate the callsite counts based on the pre-ICP distribution // factor to reflect what is already done to the callsite before // ICP, such as calliste cloning. - if (Optional Probe = extractProbe(I)) { + if (std::optional Probe = extractProbe(I)) { if (Probe->Factor < 1) T = SampleRecord::adjustCallTargets(T.get(), Probe->Factor); } diff --git a/llvm/lib/Transforms/IPO/SampleProfileProbe.cpp b/llvm/lib/Transforms/IPO/SampleProfileProbe.cpp index d1ab2649ee2e..d1edea9cba77 100644 --- a/llvm/lib/Transforms/IPO/SampleProfileProbe.cpp +++ b/llvm/lib/Transforms/IPO/SampleProfileProbe.cpp @@ -137,7 +137,7 @@ void PseudoProbeVerifier::runAfterPass(const Loop *L) { void PseudoProbeVerifier::collectProbeFactors(const BasicBlock *Block, ProbeFactorMap &ProbeFactors) { for (const auto &I : *Block) { - if (Optional Probe = extractProbe(I)) { + if (std::optional Probe = extractProbe(I)) { uint64_t Hash = computeCallStackHash(I); ProbeFactors[{Probe->Id, Hash}] += Probe->Factor; } @@ -421,7 +421,7 @@ void PseudoProbeUpdatePass::runOnFunction(Function &F, ProbeFactorMap ProbeFactors; for (auto &Block : F) { for (auto &I : Block) { - if (Optional Probe = extractProbe(I)) { + if (std::optional Probe = extractProbe(I)) { uint64_t Hash = computeCallStackHash(I); ProbeFactors[{Probe->Id, Hash}] += BBProfileCount(&Block); } @@ -431,7 +431,7 @@ void PseudoProbeUpdatePass::runOnFunction(Function &F, // Fix up over-counted probes. for (auto &Block : F) { for (auto &I : Block) { - if (Optional Probe = extractProbe(I)) { + if (std::optional Probe = extractProbe(I)) { uint64_t Hash = computeCallStackHash(I); float Sum = ProbeFactors[{Probe->Id, Hash}]; if (Sum != 0) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp index 39b4af5e9739..032021b5806b 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp @@ -1174,7 +1174,7 @@ Value *InstCombinerImpl::foldAndOrOfICmpsUsingRanges(ICmpInst *ICmp1, Type *Ty = V1->getType(); Value *NewV = V1; - Optional CR = CR1.exactUnionWith(CR2); + std::optional CR = CR1.exactUnionWith(CR2); if (!CR) { if (!(ICmp1->hasOneUse() && ICmp2->hasOneUse()) || CR1.isWrappedSet() || CR2.isWrappedSet()) diff --git a/llvm/lib/Transforms/Scalar/GuardWidening.cpp b/llvm/lib/Transforms/Scalar/GuardWidening.cpp index 6f0349fc7bf4..abe0babc3f12 100644 --- a/llvm/lib/Transforms/Scalar/GuardWidening.cpp +++ b/llvm/lib/Transforms/Scalar/GuardWidening.cpp @@ -524,7 +524,8 @@ bool GuardWideningImpl::widenCondCommon(Value *Cond0, Value *Cond1, // Given what we're doing here and the semantics of guards, it would // be correct to use a subset intersection, but that may be too // aggressive in cases we care about. - if (Optional Intersect = CR0.exactIntersectWith(CR1)) { + if (std::optional Intersect = + CR0.exactIntersectWith(CR1)) { APInt NewRHSAP; CmpInst::Predicate Pred; if (Intersect->getEquivalentICmp(Pred, NewRHSAP)) { diff --git a/llvm/lib/Transforms/Utils/Evaluator.cpp b/llvm/lib/Transforms/Utils/Evaluator.cpp index 65d065af99b6..dc58bebd724b 100644 --- a/llvm/lib/Transforms/Utils/Evaluator.cpp +++ b/llvm/lib/Transforms/Utils/Evaluator.cpp @@ -132,7 +132,7 @@ Constant *Evaluator::MutableValue::read(Type *Ty, APInt Offset, const MutableValue *V = this; while (const auto *Agg = V->Val.dyn_cast()) { Type *AggTy = Agg->Ty; - Optional Index = DL.getGEPIndexForOffset(AggTy, Offset); + std::optional Index = DL.getGEPIndexForOffset(AggTy, Offset); if (!Index || Index->uge(Agg->Elements.size()) || !TypeSize::isKnownLE(TySize, DL.getTypeStoreSize(AggTy))) return nullptr; @@ -176,7 +176,7 @@ bool Evaluator::MutableValue::write(Constant *V, APInt Offset, MutableAggregate *Agg = MV->Val.get(); Type *AggTy = Agg->Ty; - Optional Index = DL.getGEPIndexForOffset(AggTy, Offset); + std::optional Index = DL.getGEPIndexForOffset(AggTy, Offset); if (!Index || Index->uge(Agg->Elements.size()) || !TypeSize::isKnownLE(TySize, DL.getTypeStoreSize(AggTy))) return false; diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp index 8b3ffb1d8ceb..f20f2810f3fd 100644 --- a/llvm/lib/Transforms/Utils/ValueMapper.cpp +++ b/llvm/lib/Transforms/Utils/ValueMapper.cpp @@ -611,7 +611,7 @@ Optional MDNodeMapper::getMappedOp(const Metadata *Op) const { if (!Op) return nullptr; - if (Optional MappedOp = M.getVM().getMappedMD(Op)) + if (std::optional MappedOp = M.getVM().getMappedMD(Op)) return *MappedOp; if (isa(Op)) @@ -828,7 +828,7 @@ Metadata *MDNodeMapper::mapTopLevelUniquedNode(const MDNode &FirstN) { Optional Mapper::mapSimpleMetadata(const Metadata *MD) { // If the value already exists in the map, use it. - if (Optional NewMD = getVM().getMappedMD(MD)) + if (std::optional NewMD = getVM().getMappedMD(MD)) return *NewMD; if (isa(MD)) diff --git a/llvm/tools/llvm-reduce/ReducerWorkItem.cpp b/llvm/tools/llvm-reduce/ReducerWorkItem.cpp index ea5284a67cef..b536c98bea93 100644 --- a/llvm/tools/llvm-reduce/ReducerWorkItem.cpp +++ b/llvm/tools/llvm-reduce/ReducerWorkItem.cpp @@ -238,7 +238,7 @@ static std::unique_ptr cloneMF(MachineFunction *SrcMF, SrcMBB.isInlineAsmBrIndirectTarget()); // FIXME: This is not serialized - if (Optional Weight = SrcMBB.getIrrLoopHeaderWeight()) + if (std::optional Weight = SrcMBB.getIrrLoopHeaderWeight()) DstMBB->setIrrLoopHeaderWeight(*Weight); } diff --git a/llvm/unittests/IR/ConstantRangeTest.cpp b/llvm/unittests/IR/ConstantRangeTest.cpp index ab55b7f0545d..1427a6c3aa9d 100644 --- a/llvm/unittests/IR/ConstantRangeTest.cpp +++ b/llvm/unittests/IR/ConstantRangeTest.cpp @@ -554,7 +554,7 @@ void testBinarySetOperationExhaustive(Fn1 OpFn, Fn2 ExactOpFn, Fn3 InResultFn) { ConstantRange SignedCR = OpFn(CR1, CR2, ConstantRange::Signed); TestRange(SignedCR, Elems, PreferSmallestNonFullSigned, {CR1, CR2}); - Optional ExactCR = ExactOpFn(CR1, CR2); + std::optional ExactCR = ExactOpFn(CR1, CR2); if (SmallestCR.isSizeLargerThan(Elems.count())) { EXPECT_TRUE(!ExactCR); } else {