From 2fa744e631cbabe583da010ec56560edbc7a5384 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Fri, 16 Dec 2022 22:44:08 +0000 Subject: [PATCH] std::optional::value => operator*/operator-> value() has undesired exception checking semantics and calls __throw_bad_optional_access in libc++. Moreover, the API is unavailable without _LIBCPP_NO_EXCEPTIONS on older Mach-O platforms (see _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS). This commit fixes LLVMAnalysis and its dependencies. --- .../include/llvm/Analysis/BlockFrequencyInfoImpl.h | 10 +++--- llvm/include/llvm/Analysis/VectorUtils.h | 6 ++-- llvm/include/llvm/Bitstream/BitstreamWriter.h | 4 +-- llvm/include/llvm/IR/IRBuilder.h | 15 +++----- llvm/include/llvm/MC/MCSymbolWasm.h | 10 +++--- llvm/include/llvm/MC/MCSymbolXCOFF.h | 2 +- llvm/include/llvm/Support/Casting.h | 4 +-- llvm/lib/Analysis/BranchProbabilityInfo.cpp | 2 +- llvm/lib/Analysis/IRSimilarityIdentifier.cpp | 2 +- llvm/lib/Analysis/InlineCost.cpp | 10 +++--- llvm/lib/Analysis/InstructionSimplify.cpp | 20 +++++------ llvm/lib/Analysis/LazyValueInfo.cpp | 6 ++-- llvm/lib/Analysis/MemoryBuiltins.cpp | 4 +-- llvm/lib/Analysis/MustExecute.cpp | 2 +- llvm/lib/Analysis/ProfileSummaryInfo.cpp | 12 +++---- llvm/lib/Analysis/ScalarEvolution.cpp | 9 +++-- llvm/lib/Analysis/VectorUtils.cpp | 2 +- llvm/lib/DebugInfo/DWARF/DWARFContext.cpp | 5 ++- llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp | 10 +++--- llvm/lib/IR/DebugInfo.cpp | 2 +- llvm/lib/IR/Instructions.cpp | 12 +++---- llvm/lib/IR/IntrinsicInst.cpp | 10 +++--- llvm/lib/IR/LLVMContextImpl.cpp | 2 +- llvm/lib/InterfaceStub/IFSHandler.cpp | 19 +++++----- llvm/lib/MC/MCAsmStreamer.cpp | 4 +-- llvm/lib/MC/MCContext.cpp | 12 +++---- llvm/lib/MC/MCDisassembler/MCDisassembler.cpp | 4 +-- llvm/lib/MC/MCParser/MasmParser.cpp | 7 ++-- llvm/lib/MC/MCSchedule.cpp | 8 ++--- llvm/lib/MC/MCSectionXCOFF.cpp | 2 +- llvm/lib/Object/ELFObjectFile.cpp | 18 +++++----- llvm/lib/Support/Process.cpp | 2 +- llvm/lib/Support/VirtualFileSystem.cpp | 10 +++--- llvm/lib/Support/raw_ostream.cpp | 2 +- llvm/lib/TableGen/Record.cpp | 2 +- llvm/unittests/FileCheck/FileCheckTest.cpp | 4 +-- llvm/unittests/Support/AlignmentTest.cpp | 4 +-- llvm/unittests/Support/KnownBitsTest.cpp | 42 +++++++++++----------- llvm/utils/TableGen/GlobalISelEmitter.cpp | 4 +-- 39 files changed, 145 insertions(+), 160 deletions(-) diff --git a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h index 68d9d1b..2186ace 100644 --- a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h +++ b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h @@ -1277,10 +1277,10 @@ bool BlockFrequencyInfoImpl::computeMassInLoop(LoopData &Loop) { continue; } LLVM_DEBUG(dbgs() << getBlockName(HeaderNode) - << " has irr loop header weight " - << HeaderWeight.value() << "\n"); + << " has irr loop header weight " << *HeaderWeight + << "\n"); NumHeadersWithWeight++; - uint64_t HeaderWeightValue = HeaderWeight.value(); + uint64_t HeaderWeightValue = *HeaderWeight; if (!MinHeaderWeight || HeaderWeightValue < MinHeaderWeight) MinHeaderWeight = HeaderWeightValue; if (HeaderWeightValue) { @@ -1732,10 +1732,10 @@ raw_ostream &BlockFrequencyInfoImpl::print(raw_ostream &OS) const { if (std::optional ProfileCount = BlockFrequencyInfoImplBase::getBlockProfileCount( F->getFunction(), getNode(&BB))) - OS << ", count = " << ProfileCount.value(); + OS << ", count = " << *ProfileCount; if (std::optional IrrLoopHeaderWeight = BB.getIrrLoopHeaderWeight()) - OS << ", irr_loop_header_weight = " << IrrLoopHeaderWeight.value(); + OS << ", irr_loop_header_weight = " << *IrrLoopHeaderWeight; OS << "\n"; } diff --git a/llvm/include/llvm/Analysis/VectorUtils.h b/llvm/include/llvm/Analysis/VectorUtils.h index b04d087..cb09a1c 100644 --- a/llvm/include/llvm/Analysis/VectorUtils.h +++ b/llvm/include/llvm/Analysis/VectorUtils.h @@ -237,10 +237,10 @@ class VFDatabase { // ensuring that the variant described in the attribute has a // corresponding definition or declaration of the vector // function in the Module M. - if (Shape && (Shape.value().ScalarName == ScalarName)) { - assert(CI.getModule()->getFunction(Shape.value().VectorName) && + if (Shape && (Shape->ScalarName == ScalarName)) { + assert(CI.getModule()->getFunction(Shape->VectorName) && "Vector function is missing."); - Mappings.push_back(Shape.value()); + Mappings.push_back(*Shape); } } } diff --git a/llvm/include/llvm/Bitstream/BitstreamWriter.h b/llvm/include/llvm/Bitstream/BitstreamWriter.h index 0516d53..89b1d5c 100644 --- a/llvm/include/llvm/Bitstream/BitstreamWriter.h +++ b/llvm/include/llvm/Bitstream/BitstreamWriter.h @@ -385,12 +385,12 @@ private: const BitCodeAbbrevOp &Op = Abbv->getOperandInfo(i++); if (Op.isLiteral()) - EmitAbbreviatedLiteral(Op, Code.value()); + EmitAbbreviatedLiteral(Op, *Code); else { assert(Op.getEncoding() != BitCodeAbbrevOp::Array && Op.getEncoding() != BitCodeAbbrevOp::Blob && "Expected literal or scalar"); - EmitAbbreviatedField(Op, Code.value()); + EmitAbbreviatedField(Op, *Code); } } diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h index 52bd48b..4627957 100644 --- a/llvm/include/llvm/IR/IRBuilder.h +++ b/llvm/include/llvm/IR/IRBuilder.h @@ -1199,26 +1199,21 @@ private: RoundingMode UseRounding = DefaultConstrainedRounding; if (Rounding) - UseRounding = Rounding.value(); + UseRounding = *Rounding; std::optional RoundingStr = convertRoundingModeToStr(UseRounding); assert(RoundingStr && "Garbage strict rounding mode!"); - auto *RoundingMDS = MDString::get(Context, RoundingStr.value()); + auto *RoundingMDS = MDString::get(Context, *RoundingStr); return MetadataAsValue::get(Context, RoundingMDS); } Value *getConstrainedFPExcept(std::optional Except) { - fp::ExceptionBehavior UseExcept = DefaultConstrainedExcept; - - if (Except) - UseExcept = Except.value(); - - std::optional ExceptStr = - convertExceptionBehaviorToStr(UseExcept); + std::optional ExceptStr = convertExceptionBehaviorToStr( + Except.value_or(DefaultConstrainedExcept)); assert(ExceptStr && "Garbage strict exception behavior!"); - auto *ExceptMDS = MDString::get(Context, ExceptStr.value()); + auto *ExceptMDS = MDString::get(Context, *ExceptStr); return MetadataAsValue::get(Context, ExceptMDS); } diff --git a/llvm/include/llvm/MC/MCSymbolWasm.h b/llvm/include/llvm/MC/MCSymbolWasm.h index 66f0e3a..c67bd64 100644 --- a/llvm/include/llvm/MC/MCSymbolWasm.h +++ b/llvm/include/llvm/MC/MCSymbolWasm.h @@ -89,7 +89,7 @@ public: bool hasImportModule() const { return ImportModule.has_value(); } StringRef getImportModule() const { if (ImportModule) - return ImportModule.value(); + return *ImportModule; // Use a default module name of "env" for now, for compatibility with // existing tools. // TODO(sbc): Find a way to specify a default value in the object format @@ -101,13 +101,13 @@ public: bool hasImportName() const { return ImportName.has_value(); } StringRef getImportName() const { if (ImportName) - return ImportName.value(); + return *ImportName; return getName(); } void setImportName(StringRef Name) { ImportName = Name; } bool hasExportName() const { return ExportName.has_value(); } - StringRef getExportName() const { return ExportName.value(); } + StringRef getExportName() const { return *ExportName; } void setExportName(StringRef Name) { ExportName = Name; } bool isFunctionTable() const { @@ -130,14 +130,14 @@ public: const wasm::WasmGlobalType &getGlobalType() const { assert(GlobalType); - return GlobalType.value(); + return *GlobalType; } void setGlobalType(wasm::WasmGlobalType GT) { GlobalType = GT; } bool hasTableType() const { return TableType.has_value(); } const wasm::WasmTableType &getTableType() const { assert(hasTableType()); - return TableType.value(); + return *TableType; } void setTableType(wasm::WasmTableType TT) { TableType = TT; } void setTableType(wasm::ValType VT) { diff --git a/llvm/include/llvm/MC/MCSymbolXCOFF.h b/llvm/include/llvm/MC/MCSymbolXCOFF.h index e57f47d..af5759f 100644 --- a/llvm/include/llvm/MC/MCSymbolXCOFF.h +++ b/llvm/include/llvm/MC/MCSymbolXCOFF.h @@ -39,7 +39,7 @@ public: XCOFF::StorageClass getStorageClass() const { assert(StorageClass && "StorageClass not set on XCOFF MCSymbol."); - return StorageClass.value(); + return *StorageClass; } StringRef getUnqualifiedName() const { return getUnqualifiedName(getName()); } diff --git a/llvm/include/llvm/Support/Casting.h b/llvm/include/llvm/Support/Casting.h index 9d1228b..4ff5865 100644 --- a/llvm/include/llvm/Support/Casting.h +++ b/llvm/include/llvm/Support/Casting.h @@ -612,9 +612,7 @@ template struct ValueIsPresent> { static inline bool isPresent(const std::optional &t) { return t.has_value(); } - static inline decltype(auto) unwrapValue(std::optional &t) { - return t.value(); - } + static inline decltype(auto) unwrapValue(std::optional &t) { return *t; } }; // If something is "nullable" then we just compare it to nullptr to see if it diff --git a/llvm/lib/Analysis/BranchProbabilityInfo.cpp b/llvm/lib/Analysis/BranchProbabilityInfo.cpp index b99c361..fc908e1 100644 --- a/llvm/lib/Analysis/BranchProbabilityInfo.cpp +++ b/llvm/lib/Analysis/BranchProbabilityInfo.cpp @@ -823,7 +823,7 @@ void BranchProbabilityInfo::computeEestimateBlockWeight( if (auto BBWeight = getInitialEstimatedBlockWeight(BB)) // If we were able to find estimated weight for the block set it to this // block and propagate up the IR. - propagateEstimatedBlockWeight(getLoopBlock(BB), DT, PDT, BBWeight.value(), + propagateEstimatedBlockWeight(getLoopBlock(BB), DT, PDT, *BBWeight, BlockWorkList, LoopWorkList); // BlockWorklist/LoopWorkList contains blocks/loops with at least one diff --git a/llvm/lib/Analysis/IRSimilarityIdentifier.cpp b/llvm/lib/Analysis/IRSimilarityIdentifier.cpp index 8a11f66..f471e32 100644 --- a/llvm/lib/Analysis/IRSimilarityIdentifier.cpp +++ b/llvm/lib/Analysis/IRSimilarityIdentifier.cpp @@ -184,7 +184,7 @@ CmpInst::Predicate IRInstructionData::getPredicate() const { "Can only get a predicate from a compare instruction"); if (RevisedPredicate) - return RevisedPredicate.value(); + return *RevisedPredicate; return cast(Inst)->getPredicate(); } diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp index b6f50b8d..e39940e 100644 --- a/llvm/lib/Analysis/InlineCost.cpp +++ b/llvm/lib/Analysis/InlineCost.cpp @@ -736,8 +736,7 @@ class InlineCostCallAnalyzer final : public CallAnalyzer { BlockFrequencyInfo *BFI = &(GetBFI(F)); assert(BFI && "BFI must be available"); auto ProfileCount = BFI->getBlockProfileCount(BB); - assert(ProfileCount); - if (ProfileCount.value() == 0) + if (*ProfileCount == 0) ColdSize += Cost - CostAtBBStart; } @@ -861,8 +860,7 @@ class InlineCostCallAnalyzer final : public CallAnalyzer { } auto ProfileCount = CalleeBFI->getBlockProfileCount(&BB); - assert(ProfileCount); - CurrentSavings *= ProfileCount.value(); + CurrentSavings *= *ProfileCount; CycleSavings += CurrentSavings; } @@ -1820,12 +1818,12 @@ void InlineCostCallAnalyzer::updateThreshold(CallBase &Call, Function &Callee) { // return min(A, B) if B is valid. auto MinIfValid = [](int A, std::optional B) { - return B ? std::min(A, B.value()) : A; + return B ? std::min(A, *B) : A; }; // return max(A, B) if B is valid. auto MaxIfValid = [](int A, std::optional B) { - return B ? std::max(A, B.value()) : A; + return B ? std::max(A, *B) : A; }; // Various bonus percentages. These are multiplied by Threshold to get the diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index 63eee20..32b1aa5 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -2227,10 +2227,10 @@ static Value *simplifyAndInst(Value *Op0, Value *Op1, const SimplifyQuery &Q, } if (std::optional Implied = isImpliedCondition(Op1, Op0, Q.DL)) { // If Op1 is true implies Op0 is true, then Op1 is a subset of Op0. - if (Implied.value()) + if (*Implied) return Op1; // If Op1 is true implies Op0 is false, then they are not true together. - if (!Implied.value()) + if (!*Implied) return ConstantInt::getFalse(Op1->getType()); } } @@ -6324,9 +6324,9 @@ static Value *simplifyIntrinsic(CallBase *Call, const SimplifyQuery &Q) { Value *Op1 = Call->getArgOperand(1); Value *Op2 = Call->getArgOperand(2); auto *FPI = cast(Call); - if (Value *V = simplifyFPOp({Op0, Op1, Op2}, {}, Q, - FPI->getExceptionBehavior().value(), - FPI->getRoundingMode().value())) + if (Value *V = + simplifyFPOp({Op0, Op1, Op2}, {}, Q, *FPI->getExceptionBehavior(), + *FPI->getRoundingMode())) return V; return nullptr; } @@ -6392,31 +6392,31 @@ static Value *simplifyIntrinsic(CallBase *Call, const SimplifyQuery &Q) { auto *FPI = cast(Call); return simplifyFAddInst( FPI->getArgOperand(0), FPI->getArgOperand(1), FPI->getFastMathFlags(), - Q, FPI->getExceptionBehavior().value(), FPI->getRoundingMode().value()); + Q, *FPI->getExceptionBehavior(), *FPI->getRoundingMode()); } case Intrinsic::experimental_constrained_fsub: { auto *FPI = cast(Call); return simplifyFSubInst( FPI->getArgOperand(0), FPI->getArgOperand(1), FPI->getFastMathFlags(), - Q, FPI->getExceptionBehavior().value(), FPI->getRoundingMode().value()); + Q, *FPI->getExceptionBehavior(), *FPI->getRoundingMode()); } case Intrinsic::experimental_constrained_fmul: { auto *FPI = cast(Call); return simplifyFMulInst( FPI->getArgOperand(0), FPI->getArgOperand(1), FPI->getFastMathFlags(), - Q, FPI->getExceptionBehavior().value(), FPI->getRoundingMode().value()); + Q, *FPI->getExceptionBehavior(), *FPI->getRoundingMode()); } case Intrinsic::experimental_constrained_fdiv: { auto *FPI = cast(Call); return simplifyFDivInst( FPI->getArgOperand(0), FPI->getArgOperand(1), FPI->getFastMathFlags(), - Q, FPI->getExceptionBehavior().value(), FPI->getRoundingMode().value()); + Q, *FPI->getExceptionBehavior(), *FPI->getRoundingMode()); } case Intrinsic::experimental_constrained_frem: { auto *FPI = cast(Call); return simplifyFRemInst( FPI->getArgOperand(0), FPI->getArgOperand(1), FPI->getFastMathFlags(), - Q, FPI->getExceptionBehavior().value(), FPI->getRoundingMode().value()); + Q, *FPI->getExceptionBehavior(), *FPI->getRoundingMode()); } default: return nullptr; diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp index 502ac68..2a655af 100644 --- a/llvm/lib/Analysis/LazyValueInfo.cpp +++ b/llvm/lib/Analysis/LazyValueInfo.cpp @@ -924,7 +924,7 @@ LazyValueInfoImpl::solveBlockValueCast(CastInst *CI, BasicBlock *BB) { if (!LHSRes) // More work to do before applying this transfer rule. return std::nullopt; - const ConstantRange &LHSRange = LHSRes.value(); + const ConstantRange &LHSRange = *LHSRes; const unsigned ResultBitWidth = CI->getType()->getIntegerBitWidth(); @@ -950,8 +950,8 @@ LazyValueInfoImpl::solveBlockValueBinaryOpImpl( // More work to do before applying this transfer rule. return std::nullopt; - const ConstantRange &LHSRange = LHSRes.value(); - const ConstantRange &RHSRange = RHSRes.value(); + const ConstantRange &LHSRange = *LHSRes; + const ConstantRange &RHSRange = *RHSRes; return ValueLatticeElement::getRange(OpFn(LHSRange, RHSRange)); } diff --git a/llvm/lib/Analysis/MemoryBuiltins.cpp b/llvm/lib/Analysis/MemoryBuiltins.cpp index af5ef4e..27005e5 100644 --- a/llvm/lib/Analysis/MemoryBuiltins.cpp +++ b/llvm/lib/Analysis/MemoryBuiltins.cpp @@ -508,10 +508,10 @@ llvm::getAllocationFamily(const Value *I, const TargetLibraryInfo *TLI) { // Callee is some known library function. const auto AllocData = getAllocationDataForFunction(Callee, AnyAlloc, TLI); if (AllocData) - return mangledNameForMallocFamily(AllocData.value().Family); + return mangledNameForMallocFamily(AllocData->Family); const auto FreeData = getFreeFunctionDataForFunction(Callee, TLIFn); if (FreeData) - return mangledNameForMallocFamily(FreeData.value().Family); + return mangledNameForMallocFamily(FreeData->Family); } // Callee isn't a known library function, still check attributes. if (checkFnAllocKind(I, AllocFnKind::Free | AllocFnKind::Alloc | diff --git a/llvm/lib/Analysis/MustExecute.cpp b/llvm/lib/Analysis/MustExecute.cpp index 5598e33..2f68996 100644 --- a/llvm/lib/Analysis/MustExecute.cpp +++ b/llvm/lib/Analysis/MustExecute.cpp @@ -503,7 +503,7 @@ static V getOrCreateCachedOptional(K Key, DenseMap> &Map, std::optional &OptVal = Map[Key]; if (!OptVal) OptVal = Fn(std::forward(args)...); - return OptVal.value(); + return *OptVal; } const BasicBlock * diff --git a/llvm/lib/Analysis/ProfileSummaryInfo.cpp b/llvm/lib/Analysis/ProfileSummaryInfo.cpp index c8a2ddf..6b9f15b 100644 --- a/llvm/lib/Analysis/ProfileSummaryInfo.cpp +++ b/llvm/lib/Analysis/ProfileSummaryInfo.cpp @@ -282,19 +282,19 @@ ProfileSummaryInfo::computeThreshold(int PercentileCutoff) const { } bool ProfileSummaryInfo::hasHugeWorkingSetSize() const { - return HasHugeWorkingSetSize && HasHugeWorkingSetSize.value(); + return HasHugeWorkingSetSize && *HasHugeWorkingSetSize; } bool ProfileSummaryInfo::hasLargeWorkingSetSize() const { - return HasLargeWorkingSetSize && HasLargeWorkingSetSize.value(); + return HasLargeWorkingSetSize && *HasLargeWorkingSetSize; } bool ProfileSummaryInfo::isHotCount(uint64_t C) const { - return HotCountThreshold && C >= HotCountThreshold.value(); + return HotCountThreshold && C >= *HotCountThreshold; } bool ProfileSummaryInfo::isColdCount(uint64_t C) const { - return ColdCountThreshold && C <= ColdCountThreshold.value(); + return ColdCountThreshold && C <= *ColdCountThreshold; } template @@ -302,9 +302,9 @@ bool ProfileSummaryInfo::isHotOrColdCountNthPercentile(int PercentileCutoff, uint64_t C) const { auto CountThreshold = computeThreshold(PercentileCutoff); if (isHot) - return CountThreshold && C >= CountThreshold.value(); + return CountThreshold && C >= *CountThreshold; else - return CountThreshold && C <= CountThreshold.value(); + return CountThreshold && C <= *CountThreshold; } bool ProfileSummaryInfo::isHotCountNthPercentile(int PercentileCutoff, diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 2e46ae5..bcfb8a8 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -4943,7 +4943,7 @@ public: std::optional Res = compareWithBackedgeCondition(SI->getCondition()); if (Res) { - bool IsOne = cast(Res.value())->getValue()->isOne(); + bool IsOne = cast(*Res)->getValue()->isOne(); Result = SE.getSCEV(IsOne ? SI->getTrueValue() : SI->getFalseValue()); } break; @@ -4951,7 +4951,7 @@ public: default: { std::optional Res = compareWithBackedgeCondition(I); if (Res) - Result = Res.value(); + Result = *Res; break; } } @@ -6778,7 +6778,7 @@ const ConstantRange &ScalarEvolution::getRangeRef( std::optional MDRange = GetRangeFromMetadata(U->getValue()); if (MDRange) ConservativeResult = - ConservativeResult.intersectWith(MDRange.value(), RangeType); + ConservativeResult.intersectWith(*MDRange, RangeType); // Use facts about recurrences in the underlying IR. Note that add // recurrences are AddRecExprs and thus don't hit this path. This @@ -10903,8 +10903,7 @@ ScalarEvolution::getMonotonicPredicateType(const SCEVAddRecExpr *LHS, auto ResultSwapped = getMonotonicPredicateTypeImpl(LHS, ICmpInst::getSwappedPredicate(Pred)); - assert(ResultSwapped && "should be able to analyze both!"); - assert(ResultSwapped.value() != Result.value() && + assert(*ResultSwapped != *Result && "monotonicity should flip as we flip the predicate"); } #endif diff --git a/llvm/lib/Analysis/VectorUtils.cpp b/llvm/lib/Analysis/VectorUtils.cpp index ae76637..bcd748c 100644 --- a/llvm/lib/Analysis/VectorUtils.cpp +++ b/llvm/lib/Analysis/VectorUtils.cpp @@ -1546,7 +1546,7 @@ void VFABI::getVectorVariantNames( std::optional Info = VFABI::tryDemangleForVFABI(S, *(CI.getModule())); assert(Info && "Invalid name for a VFABI variant."); - assert(CI.getModule()->getFunction(Info.value().VectorName) && + assert(CI.getModule()->getFunction(Info->VectorName) && "Vector function is missing."); #endif VariantMappings.push_back(std::string(S)); diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp index 184eeff..c9be03a 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp @@ -1203,13 +1203,12 @@ void DWARFContext::addLocalsForDie(DWARFCompileUnit *CU, DWARFDie Subprogram, if (auto DeclFileAttr = Die.find(DW_AT_decl_file)) { if (const auto *LT = CU->getContext().getLineTableForUnit(CU)) LT->getFileNameByIndex( - DeclFileAttr->getAsUnsignedConstant().value(), - CU->getCompilationDir(), + *DeclFileAttr->getAsUnsignedConstant(), CU->getCompilationDir(), DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath, Local.DeclFile); } if (auto DeclLineAttr = Die.find(DW_AT_decl_line)) - Local.DeclLine = DeclLineAttr->getAsUnsignedConstant().value(); + Local.DeclLine = *DeclLineAttr->getAsUnsignedConstant(); Result.push_back(Local); return; diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp index e9d307c..0725bd7 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp @@ -323,20 +323,20 @@ parseV5DirFileTables(const DWARFDataExtractor &DebugLineData, FileEntry.Source = Value; break; case DW_LNCT_directory_index: - FileEntry.DirIdx = Value.getAsUnsignedConstant().value(); + FileEntry.DirIdx = *Value.getAsUnsignedConstant(); break; case DW_LNCT_timestamp: - FileEntry.ModTime = Value.getAsUnsignedConstant().value(); + FileEntry.ModTime = *Value.getAsUnsignedConstant(); break; case DW_LNCT_size: - FileEntry.Length = Value.getAsUnsignedConstant().value(); + FileEntry.Length = *Value.getAsUnsignedConstant(); break; case DW_LNCT_MD5: - if (!Value.getAsBlock() || Value.getAsBlock().value().size() != 16) + if (!Value.getAsBlock() || Value.getAsBlock()->size() != 16) return createStringError( errc::invalid_argument, "failed to parse file entry because the MD5 hash is invalid"); - std::uninitialized_copy_n(Value.getAsBlock().value().begin(), 16, + std::uninitialized_copy_n(Value.getAsBlock()->begin(), 16, FileEntry.Checksum.begin()); break; default: diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp index 5375edc..2a6f9b9 100644 --- a/llvm/lib/IR/DebugInfo.cpp +++ b/llvm/lib/IR/DebugInfo.cpp @@ -1800,7 +1800,7 @@ static CallInst *emitDbgAssign(AssignmentInfo Info, Value *Val, Value *Dest, auto R = DIExpression::createFragmentExpression(Expr, Info.OffsetInBits, Info.SizeInBits); assert(R.has_value() && "failed to create fragment expression"); - Expr = R.value(); + Expr = *R; } DIExpression *AddrExpr = DIExpression::get(StoreLikeInst.getContext(), std::nullopt); diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp index 46afae1..cdd2770 100644 --- a/llvm/lib/IR/Instructions.cpp +++ b/llvm/lib/IR/Instructions.cpp @@ -4582,9 +4582,9 @@ MDNode *SwitchInstProfUpdateWrapper::buildProfBranchWeightsMD() { assert(SI.getNumSuccessors() == Weights->size() && "num of prof branch_weights must accord with num of successors"); - bool AllZeroes = all_of(Weights.value(), [](uint32_t W) { return W == 0; }); + bool AllZeroes = all_of(*Weights, [](uint32_t W) { return W == 0; }); - if (AllZeroes || Weights.value().size() < 2) + if (AllZeroes || Weights->size() < 2) return nullptr; return MDBuilder(SI.getParent()->getContext()).createBranchWeights(*Weights); @@ -4618,8 +4618,8 @@ SwitchInstProfUpdateWrapper::removeCase(SwitchInst::CaseIt I) { // Copy the last case to the place of the removed one and shrink. // This is tightly coupled with the way SwitchInst::removeCase() removes // the cases in SwitchInst::removeCase(CaseIt). - Weights.value()[I->getCaseIndex() + 1] = Weights.value().back(); - Weights.value().pop_back(); + (*Weights)[I->getCaseIndex() + 1] = Weights->back(); + Weights->pop_back(); } return SI.removeCase(I); } @@ -4632,10 +4632,10 @@ void SwitchInstProfUpdateWrapper::addCase( if (!Weights && W && *W) { Changed = true; Weights = SmallVector(SI.getNumSuccessors(), 0); - Weights.value()[SI.getNumSuccessors() - 1] = *W; + (*Weights)[SI.getNumSuccessors() - 1] = *W; } else if (Weights) { Changed = true; - Weights.value().push_back(W.value_or(0)); + Weights->push_back(W.value_or(0)); } if (Weights) assert(SI.getNumSuccessors() == Weights->size() && diff --git a/llvm/lib/IR/IntrinsicInst.cpp b/llvm/lib/IR/IntrinsicInst.cpp index 6f9cd2d..6fd59d8 100644 --- a/llvm/lib/IR/IntrinsicInst.cpp +++ b/llvm/lib/IR/IntrinsicInst.cpp @@ -301,13 +301,13 @@ ConstrainedFPIntrinsic::getExceptionBehavior() const { bool ConstrainedFPIntrinsic::isDefaultFPEnvironment() const { std::optional Except = getExceptionBehavior(); if (Except) { - if (Except.value() != fp::ebIgnore) + if (*Except != fp::ebIgnore) return false; } std::optional Rounding = getRoundingMode(); if (Rounding) { - if (Rounding.value() != RoundingMode::NearestTiesToEven) + if (*Rounding != RoundingMode::NearestTiesToEven) return false; } @@ -444,13 +444,13 @@ MaybeAlign VPIntrinsic::getPointerAlignment() const { std::optional PtrParamOpt = getMemoryPointerParamPos(getIntrinsicID()); assert(PtrParamOpt && "no pointer argument!"); - return getParamAlign(PtrParamOpt.value()); + return getParamAlign(*PtrParamOpt); } /// \return The pointer operand of this load,store, gather or scatter. Value *VPIntrinsic::getMemoryPointerParam() const { if (auto PtrParamOpt = getMemoryPointerParamPos(getIntrinsicID())) - return getArgOperand(PtrParamOpt.value()); + return getArgOperand(*PtrParamOpt); return nullptr; } @@ -472,7 +472,7 @@ Value *VPIntrinsic::getMemoryDataParam() const { auto DataParamOpt = getMemoryDataParamPos(getIntrinsicID()); if (!DataParamOpt) return nullptr; - return getArgOperand(DataParamOpt.value()); + return getArgOperand(*DataParamOpt); } std::optional VPIntrinsic::getMemoryDataParamPos(Intrinsic::ID VPID) { diff --git a/llvm/lib/IR/LLVMContextImpl.cpp b/llvm/lib/IR/LLVMContextImpl.cpp index e0e25f2..e3917f1 100644 --- a/llvm/lib/IR/LLVMContextImpl.cpp +++ b/llvm/lib/IR/LLVMContextImpl.cpp @@ -259,7 +259,7 @@ bool LLVMContextImpl::getOpaquePointers() { } void LLVMContextImpl::setOpaquePointers(bool OP) { - assert((!OpaquePointers || OpaquePointers.value() == OP) && + assert((!OpaquePointers || *OpaquePointers == OP) && "Cannot change opaque pointers mode once set"); OpaquePointers = OP; } diff --git a/llvm/lib/InterfaceStub/IFSHandler.cpp b/llvm/lib/InterfaceStub/IFSHandler.cpp index c8e9c11..2204b49 100644 --- a/llvm/lib/InterfaceStub/IFSHandler.cpp +++ b/llvm/lib/InterfaceStub/IFSHandler.cpp @@ -204,7 +204,7 @@ Error ifs::writeIFSToOutputStream(raw_ostream &OS, const IFSStub &Stub) { std::unique_ptr CopyStub(new IFSStubTriple(Stub)); if (Stub.Target.Arch) { CopyStub->Target.ArchString = - std::string(ELF::convertEMachineToArchName(Stub.Target.Arch.value())); + std::string(ELF::convertEMachineToArchName(*Stub.Target.Arch)); } IFSTarget Target = Stub.Target; @@ -224,35 +224,34 @@ Error ifs::overrideIFSTarget( std::optional OverrideTriple) { std::error_code OverrideEC(1, std::generic_category()); if (OverrideArch) { - if (Stub.Target.Arch && Stub.Target.Arch.value() != OverrideArch.value()) { + if (Stub.Target.Arch && *Stub.Target.Arch != OverrideArch.value()) { return make_error( "Supplied Arch conflicts with the text stub", OverrideEC); } - Stub.Target.Arch = OverrideArch.value(); + Stub.Target.Arch = *OverrideArch; } if (OverrideEndianness) { if (Stub.Target.Endianness && - Stub.Target.Endianness.value() != OverrideEndianness.value()) { + *Stub.Target.Endianness != OverrideEndianness.value()) { return make_error( "Supplied Endianness conflicts with the text stub", OverrideEC); } - Stub.Target.Endianness = OverrideEndianness.value(); + Stub.Target.Endianness = *OverrideEndianness; } if (OverrideBitWidth) { if (Stub.Target.BitWidth && - Stub.Target.BitWidth.value() != OverrideBitWidth.value()) { + *Stub.Target.BitWidth != OverrideBitWidth.value()) { return make_error( "Supplied BitWidth conflicts with the text stub", OverrideEC); } - Stub.Target.BitWidth = OverrideBitWidth.value(); + Stub.Target.BitWidth = *OverrideBitWidth; } if (OverrideTriple) { - if (Stub.Target.Triple && - Stub.Target.Triple.value() != OverrideTriple.value()) { + if (Stub.Target.Triple && *Stub.Target.Triple != OverrideTriple.value()) { return make_error( "Supplied Triple conflicts with the text stub", OverrideEC); } - Stub.Target.Triple = OverrideTriple.value(); + Stub.Target.Triple = *OverrideTriple; } return Error::success(); } diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp index f562289..282bdb9 100644 --- a/llvm/lib/MC/MCAsmStreamer.cpp +++ b/llvm/lib/MC/MCAsmStreamer.cpp @@ -1449,7 +1449,7 @@ void MCAsmStreamer::emitAlignmentDirective(unsigned ByteAlignment, if (Value.has_value() || MaxBytesToEmit) { if (Value.has_value()) { OS << ", 0x"; - OS.write_hex(truncateToSize(Value.value(), ValueSize)); + OS.write_hex(truncateToSize(*Value, ValueSize)); } else { OS << ", "; } @@ -1473,7 +1473,7 @@ void MCAsmStreamer::emitAlignmentDirective(unsigned ByteAlignment, OS << ' ' << ByteAlignment; if (Value.has_value()) - OS << ", " << truncateToSize(Value.value(), ValueSize); + OS << ", " << truncateToSize(*Value, ValueSize); else if (MaxBytesToEmit) OS << ", "; if (MaxBytesToEmit) diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp index cde77be..29dd0e4 100644 --- a/llvm/lib/MC/MCContext.cpp +++ b/llvm/lib/MC/MCContext.cpp @@ -778,9 +778,8 @@ MCSectionXCOFF *MCContext::getXCOFFSection( // Do the lookup. If we have a hit, return it. auto IterBool = XCOFFUniquingMap.insert(std::make_pair( - IsDwarfSec - ? XCOFFSectionKey(Section.str(), DwarfSectionSubtypeFlags.value()) - : XCOFFSectionKey(Section.str(), CsectProp->MappingClass), + IsDwarfSec ? XCOFFSectionKey(Section.str(), *DwarfSectionSubtypeFlags) + : XCOFFSectionKey(Section.str(), CsectProp->MappingClass), nullptr)); auto &Entry = *IterBool.first; if (!IterBool.second) { @@ -810,10 +809,9 @@ MCSectionXCOFF *MCContext::getXCOFFSection( // CachedName contains invalid character(s) such as '$' for an XCOFF symbol. MCSectionXCOFF *Result = nullptr; if (IsDwarfSec) - Result = new (XCOFFAllocator.Allocate()) - MCSectionXCOFF(QualName->getUnqualifiedName(), Kind, QualName, - DwarfSectionSubtypeFlags.value(), Begin, CachedName, - MultiSymbolsAllowed); + Result = new (XCOFFAllocator.Allocate()) MCSectionXCOFF( + QualName->getUnqualifiedName(), Kind, QualName, + *DwarfSectionSubtypeFlags, Begin, CachedName, MultiSymbolsAllowed); else Result = new (XCOFFAllocator.Allocate()) MCSectionXCOFF(QualName->getUnqualifiedName(), CsectProp->MappingClass, diff --git a/llvm/lib/MC/MCDisassembler/MCDisassembler.cpp b/llvm/lib/MC/MCDisassembler/MCDisassembler.cpp index 6d7f6ed..80c32ac 100644 --- a/llvm/lib/MC/MCDisassembler/MCDisassembler.cpp +++ b/llvm/lib/MC/MCDisassembler/MCDisassembler.cpp @@ -93,8 +93,8 @@ bool XCOFFSymbolInfoTy::operator<(const XCOFFSymbolInfoTy &SymInfo) const { return SymInfo.StorageMappingClass.has_value(); if (StorageMappingClass) { - return getSMCPriority(StorageMappingClass.value()) < - getSMCPriority(SymInfo.StorageMappingClass.value()); + return getSMCPriority(*StorageMappingClass) < + getSMCPriority(*SymInfo.StorageMappingClass); } return false; diff --git a/llvm/lib/MC/MCParser/MasmParser.cpp b/llvm/lib/MC/MCParser/MasmParser.cpp index 309458e..a3882ad 100644 --- a/llvm/lib/MC/MCParser/MasmParser.cpp +++ b/llvm/lib/MC/MCParser/MasmParser.cpp @@ -4233,8 +4233,7 @@ bool MasmParser::parseStructInitializer(const StructInfo &Structure, size_t FieldIndex = 0; if (EndToken) { // Initialize all fields with given initializers. - while (getTok().isNot(EndToken.value()) && - FieldIndex < Structure.Fields.size()) { + while (getTok().isNot(*EndToken) && FieldIndex < Structure.Fields.size()) { const FieldInfo &Field = Structure.Fields[FieldIndex++]; if (parseOptionalToken(AsmToken::Comma)) { // Empty initializer; use the default and continue. (Also, allow line @@ -4262,10 +4261,10 @@ bool MasmParser::parseStructInitializer(const StructInfo &Structure, FieldInitializers.push_back(Field.Contents); if (EndToken) { - if (EndToken.value() == AsmToken::Greater) + if (*EndToken == AsmToken::Greater) return parseAngleBracketClose(); - return parseToken(EndToken.value()); + return parseToken(*EndToken); } return false; diff --git a/llvm/lib/MC/MCSchedule.cpp b/llvm/lib/MC/MCSchedule.cpp index 2641d52..209b24a 100644 --- a/llvm/lib/MC/MCSchedule.cpp +++ b/llvm/lib/MC/MCSchedule.cpp @@ -97,10 +97,10 @@ MCSchedModel::getReciprocalThroughput(const MCSubtargetInfo &STI, continue; unsigned NumUnits = SM.getProcResource(I->ProcResourceIdx)->NumUnits; double Temp = NumUnits * 1.0 / I->Cycles; - Throughput = Throughput ? std::min(Throughput.value(), Temp) : Temp; + Throughput = Throughput ? std::min(*Throughput, Temp) : Temp; } if (Throughput) - return 1.0 / Throughput.value(); + return 1.0 / *Throughput; // If no throughput value was calculated, assume that we can execute at the // maximum issue width scaled by number of micro-ops for the schedule class. @@ -141,10 +141,10 @@ MCSchedModel::getReciprocalThroughput(unsigned SchedClass, if (!I->getCycles()) continue; double Temp = countPopulation(I->getUnits()) * 1.0 / I->getCycles(); - Throughput = Throughput ? std::min(Throughput.value(), Temp) : Temp; + Throughput = Throughput ? std::min(*Throughput, Temp) : Temp; } if (Throughput) - return 1.0 / Throughput.value(); + return 1.0 / *Throughput; // If there are no execution resources specified for this class, then assume // that it can execute at the maximum default issue width. diff --git a/llvm/lib/MC/MCSectionXCOFF.cpp b/llvm/lib/MC/MCSectionXCOFF.cpp index a48a936..e13f30c 100644 --- a/llvm/lib/MC/MCSectionXCOFF.cpp +++ b/llvm/lib/MC/MCSectionXCOFF.cpp @@ -109,7 +109,7 @@ void MCSectionXCOFF::printSwitchToSection(const MCAsmInfo &MAI, const Triple &T, // XCOFF debug sections. if (getKind().isMetadata() && isDwarfSect()) { - OS << "\n\t.dwsect " << format("0x%" PRIx32, getDwarfSubtypeFlags().value()) + OS << "\n\t.dwsect " << format("0x%" PRIx32, *getDwarfSubtypeFlags()) << '\n'; OS << MAI.getPrivateLabelPrefix() << getName() << ':' << '\n'; return; diff --git a/llvm/lib/Object/ELFObjectFile.cpp b/llvm/lib/Object/ELFObjectFile.cpp index a3593ea..6b29703 100644 --- a/llvm/lib/Object/ELFObjectFile.cpp +++ b/llvm/lib/Object/ELFObjectFile.cpp @@ -169,11 +169,11 @@ SubtargetFeatures ELFObjectFileBase::getARMFeatures() const { std::optional Attr = Attributes.getAttributeValue(ARMBuildAttrs::CPU_arch); if (Attr) - isV7 = Attr.value() == ARMBuildAttrs::v7; + isV7 = *Attr == ARMBuildAttrs::v7; Attr = Attributes.getAttributeValue(ARMBuildAttrs::CPU_arch_profile); if (Attr) { - switch (Attr.value()) { + switch (*Attr) { case ARMBuildAttrs::ApplicationProfile: Features.AddFeature("aclass"); break; @@ -192,7 +192,7 @@ SubtargetFeatures ELFObjectFileBase::getARMFeatures() const { Attr = Attributes.getAttributeValue(ARMBuildAttrs::THUMB_ISA_use); if (Attr) { - switch (Attr.value()) { + switch (*Attr) { default: break; case ARMBuildAttrs::Not_Allowed: @@ -207,7 +207,7 @@ SubtargetFeatures ELFObjectFileBase::getARMFeatures() const { Attr = Attributes.getAttributeValue(ARMBuildAttrs::FP_arch); if (Attr) { - switch (Attr.value()) { + switch (*Attr) { default: break; case ARMBuildAttrs::Not_Allowed: @@ -231,7 +231,7 @@ SubtargetFeatures ELFObjectFileBase::getARMFeatures() const { Attr = Attributes.getAttributeValue(ARMBuildAttrs::Advanced_SIMD_arch); if (Attr) { - switch (Attr.value()) { + switch (*Attr) { default: break; case ARMBuildAttrs::Not_Allowed: @@ -250,7 +250,7 @@ SubtargetFeatures ELFObjectFileBase::getARMFeatures() const { Attr = Attributes.getAttributeValue(ARMBuildAttrs::MVE_arch); if (Attr) { - switch (Attr.value()) { + switch (*Attr) { default: break; case ARMBuildAttrs::Not_Allowed: @@ -269,7 +269,7 @@ SubtargetFeatures ELFObjectFileBase::getARMFeatures() const { Attr = Attributes.getAttributeValue(ARMBuildAttrs::DIV_use); if (Attr) { - switch (Attr.value()) { + switch (*Attr) { default: break; case ARMBuildAttrs::DisallowDIV: @@ -546,7 +546,7 @@ void ELFObjectFileBase::setARMSubArch(Triple &TheTriple) const { std::optional Attr = Attributes.getAttributeValue(ARMBuildAttrs::CPU_arch); if (Attr) { - switch (Attr.value()) { + switch (*Attr) { case ARMBuildAttrs::v4: Triple += "v4"; break; @@ -578,7 +578,7 @@ void ELFObjectFileBase::setARMSubArch(Triple &TheTriple) const { std::optional ArchProfileAttr = Attributes.getAttributeValue(ARMBuildAttrs::CPU_arch_profile); if (ArchProfileAttr && - ArchProfileAttr.value() == ARMBuildAttrs::MicroControllerProfile) + *ArchProfileAttr == ARMBuildAttrs::MicroControllerProfile) Triple += "v7m"; else Triple += "v7"; diff --git a/llvm/lib/Support/Process.cpp b/llvm/lib/Support/Process.cpp index a7fa5a4..30c64d3 100644 --- a/llvm/lib/Support/Process.cpp +++ b/llvm/lib/Support/Process.cpp @@ -47,7 +47,7 @@ Process::FindInEnvPath(StringRef EnvName, StringRef FileName, const char EnvPathSeparatorStr[] = {Separator, '\0'}; SmallVector Dirs; - SplitString(OptPath.value(), Dirs, EnvPathSeparatorStr); + SplitString(*OptPath, Dirs, EnvPathSeparatorStr); for (StringRef Dir : Dirs) { if (Dir.empty()) diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp index 1c0d2a0..fb6ce47 100644 --- a/llvm/lib/Support/VirtualFileSystem.cpp +++ b/llvm/lib/Support/VirtualFileSystem.cpp @@ -2724,14 +2724,14 @@ void JSONWriter::write(ArrayRef Entries, OS << "{\n" " 'version': 0,\n"; if (IsCaseSensitive) - OS << " 'case-sensitive': '" - << (IsCaseSensitive.value() ? "true" : "false") << "',\n"; + OS << " 'case-sensitive': '" << (*IsCaseSensitive ? "true" : "false") + << "',\n"; if (UseExternalNames) - OS << " 'use-external-names': '" - << (UseExternalNames.value() ? "true" : "false") << "',\n"; + OS << " 'use-external-names': '" << (*UseExternalNames ? "true" : "false") + << "',\n"; bool UseOverlayRelative = false; if (IsOverlayRelative) { - UseOverlayRelative = IsOverlayRelative.value(); + UseOverlayRelative = *IsOverlayRelative; OS << " 'overlay-relative': '" << (UseOverlayRelative ? "true" : "false") << "',\n"; } diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp index 2a05081..92b15f1 100644 --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp @@ -428,7 +428,7 @@ raw_ostream &raw_ostream::operator<<(const FormattedBytes &FB) { indent(FB.IndentLevel); if (FB.FirstByteOffset) { - uint64_t Offset = FB.FirstByteOffset.value(); + uint64_t Offset = *FB.FirstByteOffset; llvm::write_hex(*this, Offset + LineIndex, HPS, OffsetWidth); *this << ": "; } diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp index 112ae082..91bf3f1 100644 --- a/llvm/lib/TableGen/Record.cpp +++ b/llvm/lib/TableGen/Record.cpp @@ -2695,7 +2695,7 @@ StringRef Record::getValueAsString(StringRef FieldName) const { if (!S) PrintFatalError(getLoc(), "Record `" + getName() + "' does not have a field named `" + FieldName + "'!\n"); - return S.value(); + return *S; } std::optional diff --git a/llvm/unittests/FileCheck/FileCheckTest.cpp b/llvm/unittests/FileCheck/FileCheckTest.cpp index 8f75128..6f154b1 100644 --- a/llvm/unittests/FileCheck/FileCheckTest.cpp +++ b/llvm/unittests/FileCheck/FileCheckTest.cpp @@ -766,8 +766,8 @@ TEST_F(FileCheckTest, NumericVariable) { ASSERT_TRUE(Value); EXPECT_EQ(925, cantFail(Value->getSignedValue())); // getStringValue should return the same memory not just the same characters. - EXPECT_EQ(StringValue.begin(), FooVar.getStringValue().value().begin()); - EXPECT_EQ(StringValue.end(), FooVar.getStringValue().value().end()); + EXPECT_EQ(StringValue.begin(), FooVar.getStringValue()->begin()); + EXPECT_EQ(StringValue.end(), FooVar.getStringValue()->end()); EvalResult = FooVarUse.eval(); ASSERT_THAT_EXPECTED(EvalResult, Succeeded()); EXPECT_EQ(925, cantFail(EvalResult->getSignedValue())); diff --git a/llvm/unittests/Support/AlignmentTest.cpp b/llvm/unittests/Support/AlignmentTest.cpp index 01ac02f..7b77197 100644 --- a/llvm/unittests/Support/AlignmentTest.cpp +++ b/llvm/unittests/Support/AlignmentTest.cpp @@ -151,8 +151,8 @@ TEST(AlignmentTest, isAligned_isAddrAligned) { MaybeAlign A(T.alignment); // Test Align if (A) { - EXPECT_EQ(isAligned(A.value(), T.offset), T.isAligned); - EXPECT_EQ(isAddrAligned(A.value(), T.forgedAddr()), T.isAligned); + EXPECT_EQ(isAligned(*A, T.offset), T.isAligned); + EXPECT_EQ(isAddrAligned(*A, T.forgedAddr()), T.isAligned); } } } diff --git a/llvm/unittests/Support/KnownBitsTest.cpp b/llvm/unittests/Support/KnownBitsTest.cpp index 0c3d9df..2f5d2e8 100644 --- a/llvm/unittests/Support/KnownBitsTest.cpp +++ b/llvm/unittests/Support/KnownBitsTest.cpp @@ -369,27 +369,27 @@ TEST(KnownBitsTest, ICmpExhaustive) { EXPECT_EQ(AllSLT || NoneSLT, KnownSLT.has_value()); EXPECT_EQ(AllSLE || NoneSLE, KnownSLE.has_value()); - EXPECT_EQ(AllEQ, KnownEQ.has_value() && KnownEQ.value()); - EXPECT_EQ(AllNE, KnownNE.has_value() && KnownNE.value()); - EXPECT_EQ(AllUGT, KnownUGT.has_value() && KnownUGT.value()); - EXPECT_EQ(AllUGE, KnownUGE.has_value() && KnownUGE.value()); - EXPECT_EQ(AllULT, KnownULT.has_value() && KnownULT.value()); - EXPECT_EQ(AllULE, KnownULE.has_value() && KnownULE.value()); - EXPECT_EQ(AllSGT, KnownSGT.has_value() && KnownSGT.value()); - EXPECT_EQ(AllSGE, KnownSGE.has_value() && KnownSGE.value()); - EXPECT_EQ(AllSLT, KnownSLT.has_value() && KnownSLT.value()); - EXPECT_EQ(AllSLE, KnownSLE.has_value() && KnownSLE.value()); - - EXPECT_EQ(NoneEQ, KnownEQ.has_value() && !KnownEQ.value()); - EXPECT_EQ(NoneNE, KnownNE.has_value() && !KnownNE.value()); - EXPECT_EQ(NoneUGT, KnownUGT.has_value() && !KnownUGT.value()); - EXPECT_EQ(NoneUGE, KnownUGE.has_value() && !KnownUGE.value()); - EXPECT_EQ(NoneULT, KnownULT.has_value() && !KnownULT.value()); - EXPECT_EQ(NoneULE, KnownULE.has_value() && !KnownULE.value()); - EXPECT_EQ(NoneSGT, KnownSGT.has_value() && !KnownSGT.value()); - EXPECT_EQ(NoneSGE, KnownSGE.has_value() && !KnownSGE.value()); - EXPECT_EQ(NoneSLT, KnownSLT.has_value() && !KnownSLT.value()); - EXPECT_EQ(NoneSLE, KnownSLE.has_value() && !KnownSLE.value()); + EXPECT_EQ(AllEQ, KnownEQ.has_value() && *KnownEQ); + EXPECT_EQ(AllNE, KnownNE.has_value() && *KnownNE); + EXPECT_EQ(AllUGT, KnownUGT.has_value() && *KnownUGT); + EXPECT_EQ(AllUGE, KnownUGE.has_value() && *KnownUGE); + EXPECT_EQ(AllULT, KnownULT.has_value() && *KnownULT); + EXPECT_EQ(AllULE, KnownULE.has_value() && *KnownULE); + EXPECT_EQ(AllSGT, KnownSGT.has_value() && *KnownSGT); + EXPECT_EQ(AllSGE, KnownSGE.has_value() && *KnownSGE); + EXPECT_EQ(AllSLT, KnownSLT.has_value() && *KnownSLT); + EXPECT_EQ(AllSLE, KnownSLE.has_value() && *KnownSLE); + + EXPECT_EQ(NoneEQ, KnownEQ.has_value() && !*KnownEQ); + EXPECT_EQ(NoneNE, KnownNE.has_value() && !*KnownNE); + EXPECT_EQ(NoneUGT, KnownUGT.has_value() && !*KnownUGT); + EXPECT_EQ(NoneUGE, KnownUGE.has_value() && !*KnownUGE); + EXPECT_EQ(NoneULT, KnownULT.has_value() && !*KnownULT); + EXPECT_EQ(NoneULE, KnownULE.has_value() && !*KnownULE); + EXPECT_EQ(NoneSGT, KnownSGT.has_value() && !*KnownSGT); + EXPECT_EQ(NoneSGE, KnownSGE.has_value() && !*KnownSGE); + EXPECT_EQ(NoneSLT, KnownSLT.has_value() && !*KnownSLT); + EXPECT_EQ(NoneSLE, KnownSLE.has_value() && !*KnownSLE); }); }); } diff --git a/llvm/utils/TableGen/GlobalISelEmitter.cpp b/llvm/utils/TableGen/GlobalISelEmitter.cpp index 96afc00..bff1d68 100644 --- a/llvm/utils/TableGen/GlobalISelEmitter.cpp +++ b/llvm/utils/TableGen/GlobalISelEmitter.cpp @@ -2976,7 +2976,7 @@ public: << MatchTable::IntValue(RendererID); if (SubOperand) Table << MatchTable::Comment("SubOperand") - << MatchTable::IntValue(SubOperand.value()); + << MatchTable::IntValue(*SubOperand); Table << MatchTable::Comment(SymbolicName) << MatchTable::LineBreak; } }; @@ -4995,7 +4995,7 @@ Error GlobalISelEmitter::importDefaultOperandRenderers( auto Def = DefaultDefOp->getDef(); if (Def->getName() == "undef_tied_input") { unsigned TempRegID = M.allocateTempRegID(); - M.insertAction(InsertPt, OpTyOrNone.value(), + M.insertAction(InsertPt, *OpTyOrNone, TempRegID); InsertPt = M.insertAction( InsertPt, M.allocateOutputInsnID(), -- 2.7.4