[llvm] 2fa744e - std::optional::value => operator*/operator->
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 16 14:44:16 PST 2022
Author: Fangrui Song
Date: 2022-12-16T22:44:08Z
New Revision: 2fa744e631cbabe583da010ec56560edbc7a5384
URL: https://github.com/llvm/llvm-project/commit/2fa744e631cbabe583da010ec56560edbc7a5384
DIFF: https://github.com/llvm/llvm-project/commit/2fa744e631cbabe583da010ec56560edbc7a5384.diff
LOG: 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.
Added:
Modified:
llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
llvm/include/llvm/Analysis/VectorUtils.h
llvm/include/llvm/Bitstream/BitstreamWriter.h
llvm/include/llvm/IR/IRBuilder.h
llvm/include/llvm/MC/MCSymbolWasm.h
llvm/include/llvm/MC/MCSymbolXCOFF.h
llvm/include/llvm/Support/Casting.h
llvm/lib/Analysis/BranchProbabilityInfo.cpp
llvm/lib/Analysis/IRSimilarityIdentifier.cpp
llvm/lib/Analysis/InlineCost.cpp
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/lib/Analysis/LazyValueInfo.cpp
llvm/lib/Analysis/MemoryBuiltins.cpp
llvm/lib/Analysis/MustExecute.cpp
llvm/lib/Analysis/ProfileSummaryInfo.cpp
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/lib/Analysis/VectorUtils.cpp
llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
llvm/lib/IR/DebugInfo.cpp
llvm/lib/IR/Instructions.cpp
llvm/lib/IR/IntrinsicInst.cpp
llvm/lib/IR/LLVMContextImpl.cpp
llvm/lib/InterfaceStub/IFSHandler.cpp
llvm/lib/MC/MCAsmStreamer.cpp
llvm/lib/MC/MCContext.cpp
llvm/lib/MC/MCDisassembler/MCDisassembler.cpp
llvm/lib/MC/MCParser/MasmParser.cpp
llvm/lib/MC/MCSchedule.cpp
llvm/lib/MC/MCSectionXCOFF.cpp
llvm/lib/Object/ELFObjectFile.cpp
llvm/lib/Support/Process.cpp
llvm/lib/Support/VirtualFileSystem.cpp
llvm/lib/Support/raw_ostream.cpp
llvm/lib/TableGen/Record.cpp
llvm/unittests/FileCheck/FileCheckTest.cpp
llvm/unittests/Support/AlignmentTest.cpp
llvm/unittests/Support/KnownBitsTest.cpp
llvm/utils/TableGen/GlobalISelEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
index 68d9d1bcf18cb..2186ace5a9422 100644
--- a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
+++ b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
@@ -1277,10 +1277,10 @@ bool BlockFrequencyInfoImpl<BT>::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<BT>::print(raw_ostream &OS) const {
if (std::optional<uint64_t> ProfileCount =
BlockFrequencyInfoImplBase::getBlockProfileCount(
F->getFunction(), getNode(&BB)))
- OS << ", count = " << ProfileCount.value();
+ OS << ", count = " << *ProfileCount;
if (std::optional<uint64_t> 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 b04d08748e242..cb09a1cd4f956 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 0516d53b7be9a..89b1d5c482b66 100644
--- a/llvm/include/llvm/Bitstream/BitstreamWriter.h
+++ b/llvm/include/llvm/Bitstream/BitstreamWriter.h
@@ -385,12 +385,12 @@ class BitstreamWriter {
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 52bd48b344c0b..4627957a448a8 100644
--- a/llvm/include/llvm/IR/IRBuilder.h
+++ b/llvm/include/llvm/IR/IRBuilder.h
@@ -1199,26 +1199,21 @@ class IRBuilderBase {
RoundingMode UseRounding = DefaultConstrainedRounding;
if (Rounding)
- UseRounding = Rounding.value();
+ UseRounding = *Rounding;
std::optional<StringRef> 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<fp::ExceptionBehavior> Except) {
- fp::ExceptionBehavior UseExcept = DefaultConstrainedExcept;
-
- if (Except)
- UseExcept = Except.value();
-
- std::optional<StringRef> ExceptStr =
- convertExceptionBehaviorToStr(UseExcept);
+ std::optional<StringRef> 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 66f0e3a90e8a6..c67bd64e7cbdf 100644
--- a/llvm/include/llvm/MC/MCSymbolWasm.h
+++ b/llvm/include/llvm/MC/MCSymbolWasm.h
@@ -89,7 +89,7 @@ class MCSymbolWasm : public MCSymbol {
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 @@ class MCSymbolWasm : public MCSymbol {
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 @@ class MCSymbolWasm : public MCSymbol {
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 e57f47d1b054c..af5759f72618d 100644
--- a/llvm/include/llvm/MC/MCSymbolXCOFF.h
+++ b/llvm/include/llvm/MC/MCSymbolXCOFF.h
@@ -39,7 +39,7 @@ class MCSymbolXCOFF : public MCSymbol {
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 9d1228b5a1343..4ff5865185d75 100644
--- a/llvm/include/llvm/Support/Casting.h
+++ b/llvm/include/llvm/Support/Casting.h
@@ -612,9 +612,7 @@ template <typename T> struct ValueIsPresent<std::optional<T>> {
static inline bool isPresent(const std::optional<T> &t) {
return t.has_value();
}
- static inline decltype(auto) unwrapValue(std::optional<T> &t) {
- return t.value();
- }
+ static inline decltype(auto) unwrapValue(std::optional<T> &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 b99c361cd5e56..fc908e136c240 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 8a11f66b2fe71..f471e32344cbc 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<CmpInst>(Inst)->getPredicate();
}
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index b6f50b8d4dbb9..e39940ed6a9b5 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<int> 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<int> 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 63eee20845200..32b1aa52273b2 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<bool> 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<ConstrainedFPIntrinsic>(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<ConstrainedFPIntrinsic>(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<ConstrainedFPIntrinsic>(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<ConstrainedFPIntrinsic>(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<ConstrainedFPIntrinsic>(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<ConstrainedFPIntrinsic>(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 502ac68e1a0e8..2a655af9dde9c 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 af5ef4e4c3c20..27005e547182f 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 5598e33efb831..2f68996e1c608 100644
--- a/llvm/lib/Analysis/MustExecute.cpp
+++ b/llvm/lib/Analysis/MustExecute.cpp
@@ -503,7 +503,7 @@ static V getOrCreateCachedOptional(K Key, DenseMap<K, std::optional<V>> &Map,
std::optional<V> &OptVal = Map[Key];
if (!OptVal)
OptVal = Fn(std::forward<ArgsTy>(args)...);
- return OptVal.value();
+ return *OptVal;
}
const BasicBlock *
diff --git a/llvm/lib/Analysis/ProfileSummaryInfo.cpp b/llvm/lib/Analysis/ProfileSummaryInfo.cpp
index c8a2ddf0567b4..6b9f15bf2f647 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 <bool isHot>
@@ -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 2e46ae57eb4cf..bcfb8a88e1a7e 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -4943,7 +4943,7 @@ class SCEVBackedgeConditionFolder
std::optional<const SCEV *> Res =
compareWithBackedgeCondition(SI->getCondition());
if (Res) {
- bool IsOne = cast<SCEVConstant>(Res.value())->getValue()->isOne();
+ bool IsOne = cast<SCEVConstant>(*Res)->getValue()->isOne();
Result = SE.getSCEV(IsOne ? SI->getTrueValue() : SI->getFalseValue());
}
break;
@@ -4951,7 +4951,7 @@ class SCEVBackedgeConditionFolder
default: {
std::optional<const SCEV *> Res = compareWithBackedgeCondition(I);
if (Res)
- Result = Res.value();
+ Result = *Res;
break;
}
}
@@ -6778,7 +6778,7 @@ const ConstantRange &ScalarEvolution::getRangeRef(
std::optional<ConstantRange> 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 ae766378680a0..bcd748cb64716 100644
--- a/llvm/lib/Analysis/VectorUtils.cpp
+++ b/llvm/lib/Analysis/VectorUtils.cpp
@@ -1546,7 +1546,7 @@ void VFABI::getVectorVariantNames(
std::optional<VFInfo> 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 184eeff0ad9c4..c9be03a8fd0a6 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 e9d307c3ebc03..0725bd7744aea 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 5375edcf42f90..2a6f9b9673a36 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 46afae12e0803..cdd2770bf29f9 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<uint32_t, 8>(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 6f9cd2d6d0ea0..6fd59d8070ae4 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<fp::ExceptionBehavior> Except = getExceptionBehavior();
if (Except) {
- if (Except.value() != fp::ebIgnore)
+ if (*Except != fp::ebIgnore)
return false;
}
std::optional<RoundingMode> 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<unsigned> 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<unsigned> VPIntrinsic::getMemoryDataParamPos(Intrinsic::ID VPID) {
diff --git a/llvm/lib/IR/LLVMContextImpl.cpp b/llvm/lib/IR/LLVMContextImpl.cpp
index e0e25f23ad62c..e3917f12d2413 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 c8e9c11bc3a66..2204b49ae0ae7 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<IFSStubTriple> 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<std::string> 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<StringError>(
"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<StringError>(
"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<StringError>(
"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<StringError>(
"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 f562289305b0b..282bdb95acacc 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 cde77be929a1a..29dd0e4ed6a08 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 6d7f6ed48ea00..80c32ac560822 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 309458eaace6e..a3882ad18ee94 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 2641d525cf05d..209b24a7d4ac4 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 a48a936f64db4..e13f30ccbbdca 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 a3593eae7cb4b..6b29703caa65c 100644
--- a/llvm/lib/Object/ELFObjectFile.cpp
+++ b/llvm/lib/Object/ELFObjectFile.cpp
@@ -169,11 +169,11 @@ SubtargetFeatures ELFObjectFileBase::getARMFeatures() const {
std::optional<unsigned> 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<unsigned> 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<unsigned> 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 a7fa5a4aeb27b..30c64d3ed9ed1 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<StringRef, 8> 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 1c0d2a044448f..fb6ce477777a3 100644
--- a/llvm/lib/Support/VirtualFileSystem.cpp
+++ b/llvm/lib/Support/VirtualFileSystem.cpp
@@ -2724,14 +2724,14 @@ void JSONWriter::write(ArrayRef<YAMLVFSEntry> 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 2a05081592ba3..92b15f14c62fd 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 112ae082aaa02..91bf3f1b61ff6 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<StringRef>
diff --git a/llvm/unittests/FileCheck/FileCheckTest.cpp b/llvm/unittests/FileCheck/FileCheckTest.cpp
index 8f7512844e8d7..6f154b181d381 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 01ac02f49bef3..7b771977027b4 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 0c3d9dfa76304..2f5d2e81bac6c 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 96afc00dc98d0..bff1d68a5f92b 100644
--- a/llvm/utils/TableGen/GlobalISelEmitter.cpp
+++ b/llvm/utils/TableGen/GlobalISelEmitter.cpp
@@ -2976,7 +2976,7 @@ class RenderComplexPatternOperand : public OperandRenderer {
<< 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<MakeTempRegisterAction>(InsertPt, OpTyOrNone.value(),
+ M.insertAction<MakeTempRegisterAction>(InsertPt, *OpTyOrNone,
TempRegID);
InsertPt = M.insertAction<BuildMIAction>(
InsertPt, M.allocateOutputInsnID(),
More information about the llvm-commits
mailing list