[llvm] 129b531 - [llvm] Use value_or instead of getValueOr (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 18 23:07:18 PDT 2022
Author: Kazu Hirata
Date: 2022-06-18T23:07:11-07:00
New Revision: 129b531c9c67fc50ef9dcb7d28d7081546213ac1
URL: https://github.com/llvm/llvm-project/commit/129b531c9c67fc50ef9dcb7d28d7081546213ac1
DIFF: https://github.com/llvm/llvm-project/commit/129b531c9c67fc50ef9dcb7d28d7081546213ac1.diff
LOG: [llvm] Use value_or instead of getValueOr (NFC)
Added:
Modified:
llvm/include/llvm/Analysis/ProfileSummaryInfo.h
llvm/include/llvm/CodeGen/CodeGenPassBuilder.h
llvm/include/llvm/CodeGen/SelectionDAG.h
llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
llvm/include/llvm/IR/DebugInfoMetadata.h
llvm/include/llvm/Object/ELF.h
llvm/lib/Analysis/AliasAnalysis.cpp
llvm/lib/Analysis/BranchProbabilityInfo.cpp
llvm/lib/Analysis/InlineAdvisor.cpp
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/lib/Analysis/LazyValueInfo.cpp
llvm/lib/Analysis/LoopInfo.cpp
llvm/lib/Analysis/MemoryBuiltins.cpp
llvm/lib/Analysis/OptimizationRemarkEmitter.cpp
llvm/lib/Analysis/ProfileSummaryInfo.cpp
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/lib/Analysis/StackSafetyAnalysis.cpp
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/CodeGen/CommandFlags.cpp
llvm/lib/CodeGen/ExpandVectorPredication.cpp
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
llvm/lib/CodeGen/MIRParser/MIRParser.cpp
llvm/lib/CodeGen/MachineOptimizationRemarkEmitter.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
llvm/lib/DWARFLinker/DWARFLinker.cpp
llvm/lib/DebugInfo/CodeView/CVSymbolVisitor.cpp
llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
llvm/lib/IR/AsmWriter.cpp
llvm/lib/IR/Attributes.cpp
llvm/lib/IR/DebugInfoMetadata.cpp
llvm/lib/IR/Instructions.cpp
llvm/lib/IR/LLVMContext.cpp
llvm/lib/IR/LLVMContextImpl.h
llvm/lib/IR/VectorBuilder.cpp
llvm/lib/InterfaceStub/ELFObjHandler.cpp
llvm/lib/MC/MCDwarf.cpp
llvm/lib/MC/MCStreamer.cpp
llvm/lib/MC/MachObjectWriter.cpp
llvm/lib/MC/WasmObjectWriter.cpp
llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
llvm/lib/ObjectYAML/DWARFEmitter.cpp
llvm/lib/ObjectYAML/DWARFYAML.cpp
llvm/lib/ObjectYAML/ELFEmitter.cpp
llvm/lib/ObjectYAML/MinidumpEmitter.cpp
llvm/lib/ObjectYAML/XCOFFEmitter.cpp
llvm/lib/ProfileData/InstrProfCorrelator.cpp
llvm/lib/Support/NativeFormatting.cpp
llvm/lib/Support/VirtualFileSystem.cpp
llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
llvm/lib/Target/ARC/ARCTargetMachine.cpp
llvm/lib/Target/AVR/AVRTargetMachine.cpp
llvm/lib/Target/BPF/BPFTargetMachine.cpp
llvm/lib/Target/CSKY/CSKYTargetMachine.cpp
llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp
llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp
llvm/lib/Target/Lanai/LanaiTargetMachine.cpp
llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
llvm/lib/Target/Sparc/SparcTargetMachine.cpp
llvm/lib/Target/VE/VECustomDAG.cpp
llvm/lib/Target/VE/VETargetMachine.cpp
llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmTypeCheck.cpp
llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
llvm/lib/Target/XCore/XCoreTargetMachine.cpp
llvm/lib/Testing/Support/Annotations.cpp
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/lib/Transforms/IPO/ConstantMerge.cpp
llvm/lib/Transforms/IPO/IROutliner.cpp
llvm/lib/Transforms/IPO/Inliner.cpp
llvm/lib/Transforms/IPO/PartialInlining.cpp
llvm/lib/Transforms/IPO/SampleProfileProbe.cpp
llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
llvm/lib/Transforms/Scalar/GVN.cpp
llvm/lib/Transforms/Scalar/LoopDistribute.cpp
llvm/lib/Transforms/Scalar/Scalarizer.cpp
llvm/lib/Transforms/Scalar/WarnMissedTransforms.cpp
llvm/lib/Transforms/Utils/InlineFunction.cpp
llvm/lib/Transforms/Utils/LoopUtils.cpp
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/tools/llvm-mca/Views/InstructionInfoView.cpp
llvm/tools/llvm-objdump/llvm-objdump.cpp
llvm/tools/llvm-pdbutil/BytesOutputStyle.cpp
llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp
llvm/tools/llvm-rc/ResourceFileWriter.cpp
llvm/tools/llvm-readobj/ELFDumper.cpp
llvm/tools/obj2yaml/elf2yaml.cpp
llvm/utils/TableGen/GlobalISelEmitter.cpp
llvm/utils/TableGen/OptParserEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/ProfileSummaryInfo.h b/llvm/include/llvm/Analysis/ProfileSummaryInfo.h
index 886800d8a0f5..773784ac418c 100644
--- a/llvm/include/llvm/Analysis/ProfileSummaryInfo.h
+++ b/llvm/include/llvm/Analysis/ProfileSummaryInfo.h
@@ -170,11 +170,11 @@ class ProfileSummaryInfo {
uint64_t getOrCompColdCountThreshold() const;
/// Returns HotCountThreshold if set.
uint64_t getHotCountThreshold() const {
- return HotCountThreshold.getValueOr(0);
+ return HotCountThreshold.value_or(0);
}
/// Returns ColdCountThreshold if set.
uint64_t getColdCountThreshold() const {
- return ColdCountThreshold.getValueOr(0);
+ return ColdCountThreshold.value_or(0);
}
private:
diff --git a/llvm/include/llvm/CodeGen/CodeGenPassBuilder.h b/llvm/include/llvm/CodeGen/CodeGenPassBuilder.h
index f387b28a4ccb..f4b1980b9ede 100644
--- a/llvm/include/llvm/CodeGen/CodeGenPassBuilder.h
+++ b/llvm/include/llvm/CodeGen/CodeGenPassBuilder.h
@@ -750,7 +750,7 @@ template <typename Derived>
Error CodeGenPassBuilder<Derived>::addCoreISelPasses(
AddMachinePass &addPass) const {
// Enable FastISel with -fast-isel, but allow that to be overridden.
- TM.setO0WantsFastISel(Opt.EnableFastISelOption.getValueOr(true));
+ TM.setO0WantsFastISel(Opt.EnableFastISelOption.value_or(true));
// Determine an instruction selector.
enum class SelectorType { SelectionDAG, FastISel, GlobalISel };
diff --git a/llvm/include/llvm/CodeGen/SelectionDAG.h b/llvm/include/llvm/CodeGen/SelectionDAG.h
index 7042b4fddeba..e844eb8f4a79 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAG.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAG.h
@@ -1180,7 +1180,7 @@ class SelectionDAG {
uint64_t Size = 0, const AAMDNodes &AAInfo = AAMDNodes()) {
// Ensure that codegen never sees alignment 0
return getMemIntrinsicNode(Opcode, dl, VTList, Ops, MemVT, PtrInfo,
- Alignment.getValueOr(getEVTAlign(MemVT)), Flags,
+ Alignment.value_or(getEVTAlign(MemVT)), Flags,
Size, AAInfo);
}
@@ -1261,7 +1261,7 @@ class SelectionDAG {
const AAMDNodes &AAInfo = AAMDNodes(), const MDNode *Ranges = nullptr) {
// Ensures that codegen never sees a None Alignment.
return getLoad(AM, ExtType, VT, dl, Chain, Ptr, Offset, PtrInfo, MemVT,
- Alignment.getValueOr(getEVTAlign(MemVT)), MMOFlags, AAInfo,
+ Alignment.value_or(getEVTAlign(MemVT)), MMOFlags, AAInfo,
Ranges);
}
/// FIXME: Remove once transition to Align is over.
@@ -1295,7 +1295,7 @@ class SelectionDAG {
MachineMemOperand::Flags MMOFlags = MachineMemOperand::MONone,
const AAMDNodes &AAInfo = AAMDNodes()) {
return getStore(Chain, dl, Val, Ptr, PtrInfo,
- Alignment.getValueOr(getEVTAlign(Val.getValueType())),
+ Alignment.value_or(getEVTAlign(Val.getValueType())),
MMOFlags, AAInfo);
}
/// FIXME: Remove once transition to Align is over.
@@ -1321,7 +1321,7 @@ class SelectionDAG {
MachineMemOperand::Flags MMOFlags = MachineMemOperand::MONone,
const AAMDNodes &AAInfo = AAMDNodes()) {
return getTruncStore(Chain, dl, Val, Ptr, PtrInfo, SVT,
- Alignment.getValueOr(getEVTAlign(SVT)), MMOFlags,
+ Alignment.value_or(getEVTAlign(SVT)), MMOFlags,
AAInfo);
}
/// FIXME: Remove once transition to Align is over.
@@ -1354,7 +1354,7 @@ class SelectionDAG {
const MDNode *Ranges = nullptr, bool IsExpanding = false) {
// Ensures that codegen never sees a None Alignment.
return getLoadVP(AM, ExtType, VT, dl, Chain, Ptr, Offset, Mask, EVL,
- PtrInfo, MemVT, Alignment.getValueOr(getEVTAlign(MemVT)),
+ PtrInfo, MemVT, Alignment.value_or(getEVTAlign(MemVT)),
MMOFlags, AAInfo, Ranges, IsExpanding);
}
SDValue getLoadVP(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType, EVT VT,
@@ -1414,7 +1414,7 @@ class SelectionDAG {
// Ensures that codegen never sees a None Alignment.
return getStridedLoadVP(AM, ExtType, VT, DL, Chain, Ptr, Offset, Stride,
Mask, EVL, PtrInfo, MemVT,
- Alignment.getValueOr(getEVTAlign(MemVT)), MMOFlags,
+ Alignment.value_or(getEVTAlign(MemVT)), MMOFlags,
AAInfo, Ranges, IsExpanding);
}
SDValue getStridedLoadVP(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType,
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
index c583688f2ac9..c2c1df5b590b 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
@@ -236,7 +236,7 @@ inline Optional<uint64_t> toUnsigned(const Optional<DWARFFormValue> &V) {
/// value or the form value's encoding wasn't an unsigned constant form.
inline uint64_t toUnsigned(const Optional<DWARFFormValue> &V,
uint64_t Default) {
- return toUnsigned(V).getValueOr(Default);
+ return toUnsigned(V).value_or(Default);
}
/// Take an optional DWARFFormValue and try to extract an reference.
@@ -258,7 +258,7 @@ inline Optional<uint64_t> toReference(const Optional<DWARFFormValue> &V) {
/// value or the form value's encoding wasn't a reference form.
inline uint64_t toReference(const Optional<DWARFFormValue> &V,
uint64_t Default) {
- return toReference(V).getValueOr(Default);
+ return toReference(V).value_or(Default);
}
/// Take an optional DWARFFormValue and try to extract an signed constant.
@@ -279,7 +279,7 @@ inline Optional<int64_t> toSigned(const Optional<DWARFFormValue> &V) {
/// \returns the extracted signed integer value or Default if the V doesn't
/// have a value or the form value's encoding wasn't a signed integer form.
inline int64_t toSigned(const Optional<DWARFFormValue> &V, int64_t Default) {
- return toSigned(V).getValueOr(Default);
+ return toSigned(V).value_or(Default);
}
/// Take an optional DWARFFormValue and try to extract an address.
@@ -307,7 +307,7 @@ toSectionedAddress(const Optional<DWARFFormValue> &V) {
/// \returns the extracted address value or Default if the V doesn't have a
/// value or the form value's encoding wasn't an address form.
inline uint64_t toAddress(const Optional<DWARFFormValue> &V, uint64_t Default) {
- return toAddress(V).getValueOr(Default);
+ return toAddress(V).value_or(Default);
}
/// Take an optional DWARFFormValue and try to extract an section offset.
@@ -329,7 +329,7 @@ inline Optional<uint64_t> toSectionOffset(const Optional<DWARFFormValue> &V) {
/// have a value or the form value's encoding wasn't a section offset form.
inline uint64_t toSectionOffset(const Optional<DWARFFormValue> &V,
uint64_t Default) {
- return toSectionOffset(V).getValueOr(Default);
+ return toSectionOffset(V).value_or(Default);
}
/// Take an optional DWARFFormValue and try to extract block data.
diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h
index 0eb96d2343a0..f451e4a7865b 100644
--- a/llvm/include/llvm/IR/DebugInfoMetadata.h
+++ b/llvm/include/llvm/IR/DebugInfoMetadata.h
@@ -3644,7 +3644,7 @@ class DebugVariable {
const DILocation *getInlinedAt() const { return InlinedAt; }
FragmentInfo getFragmentOrDefault() const {
- return Fragment.getValueOr(DefaultFragment);
+ return Fragment.value_or(DefaultFragment);
}
static bool isDefaultFragment(const FragmentInfo F) {
diff --git a/llvm/include/llvm/Object/ELF.h b/llvm/include/llvm/Object/ELF.h
index 37f23c435ae1..1a59ba94098f 100644
--- a/llvm/include/llvm/Object/ELF.h
+++ b/llvm/include/llvm/Object/ELF.h
@@ -855,7 +855,7 @@ Expected<StringRef> ELFFile<ELFT>::getSymbolVersionByIndex(
const VersionEntry &Entry = *VersionMap[VersionIndex];
// A default version (@@) is only available for defined symbols.
- if (!Entry.IsVerDef || IsSymHidden.getValueOr(false))
+ if (!Entry.IsVerDef || IsSymHidden.value_or(false))
IsDefault = false;
else
IsDefault = !(SymbolVersionIndex & llvm::ELF::VERSYM_HIDDEN);
diff --git a/llvm/lib/Analysis/AliasAnalysis.cpp b/llvm/lib/Analysis/AliasAnalysis.cpp
index ff80d80f7fff..7a8cccc82140 100644
--- a/llvm/lib/Analysis/AliasAnalysis.cpp
+++ b/llvm/lib/Analysis/AliasAnalysis.cpp
@@ -679,7 +679,7 @@ ModRefInfo AAResults::getModRefInfo(const Instruction *I,
}
}
- const MemoryLocation &Loc = OptLoc.getValueOr(MemoryLocation());
+ const MemoryLocation &Loc = OptLoc.value_or(MemoryLocation());
switch (I->getOpcode()) {
case Instruction::VAArg:
diff --git a/llvm/lib/Analysis/BranchProbabilityInfo.cpp b/llvm/lib/Analysis/BranchProbabilityInfo.cpp
index ffb80134749a..3c5566a2ffb8 100644
--- a/llvm/lib/Analysis/BranchProbabilityInfo.cpp
+++ b/llvm/lib/Analysis/BranchProbabilityInfo.cpp
@@ -913,7 +913,7 @@ bool BranchProbabilityInfo::calcEstimatedHeuristics(const BasicBlock *BB) {
// Scale down loop exiting weight by trip count.
Weight = std::max(
static_cast<uint32_t>(BlockExecWeight::LOWEST_NON_ZERO),
- Weight.getValueOr(static_cast<uint32_t>(BlockExecWeight::DEFAULT)) /
+ Weight.value_or(static_cast<uint32_t>(BlockExecWeight::DEFAULT)) /
TC);
}
bool IsUnlikelyEdge = LoopBB.getLoop() && UnlikelyBlocks.contains(SuccBB);
@@ -923,15 +923,14 @@ bool BranchProbabilityInfo::calcEstimatedHeuristics(const BasicBlock *BB) {
// 'Unlikely' blocks have twice lower weight.
Weight = std::max(
static_cast<uint32_t>(BlockExecWeight::LOWEST_NON_ZERO),
- Weight.getValueOr(static_cast<uint32_t>(BlockExecWeight::DEFAULT)) /
- 2);
+ Weight.value_or(static_cast<uint32_t>(BlockExecWeight::DEFAULT)) / 2);
}
if (Weight)
FoundEstimatedWeight = true;
auto WeightVal =
- Weight.getValueOr(static_cast<uint32_t>(BlockExecWeight::DEFAULT));
+ Weight.value_or(static_cast<uint32_t>(BlockExecWeight::DEFAULT));
TotalWeight += WeightVal;
SuccWeights.push_back(WeightVal);
}
diff --git a/llvm/lib/Analysis/InlineAdvisor.cpp b/llvm/lib/Analysis/InlineAdvisor.cpp
index ebad9d21257b..6a78e9b02f22 100644
--- a/llvm/lib/Analysis/InlineAdvisor.cpp
+++ b/llvm/lib/Analysis/InlineAdvisor.cpp
@@ -153,7 +153,7 @@ llvm::Optional<llvm::InlineCost> static getDefaultInlineAdvice(
};
return llvm::shouldInline(
CB, GetInlineCost, ORE,
- Params.EnableDeferral.getValueOr(EnableInlineDeferral));
+ Params.EnableDeferral.value_or(EnableInlineDeferral));
}
std::unique_ptr<InlineAdvice>
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index b810f32643b6..23ec186c2f57 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -2221,10 +2221,10 @@ static Value *simplifyAndInst(Value *Op0, Value *Op1, const SimplifyQuery &Q,
if (Op0->getType()->isIntOrIntVectorTy(1)) {
// Op0&Op1 -> Op0 where Op0 implies Op1
- if (isImpliedCondition(Op0, Op1, Q.DL).getValueOr(false))
+ if (isImpliedCondition(Op0, Op1, Q.DL).value_or(false))
return Op0;
// Op0&Op1 -> Op1 where Op1 implies Op0
- if (isImpliedCondition(Op1, Op0, Q.DL).getValueOr(false))
+ if (isImpliedCondition(Op1, Op0, Q.DL).value_or(false))
return Op1;
}
@@ -2461,10 +2461,10 @@ static Value *simplifyOrInst(Value *Op0, Value *Op1, const SimplifyQuery &Q,
if (Op0->getType()->isIntOrIntVectorTy(1)) {
// Op0|Op1 -> Op1 where Op0 implies Op1
- if (isImpliedCondition(Op0, Op1, Q.DL).getValueOr(false))
+ if (isImpliedCondition(Op0, Op1, Q.DL).value_or(false))
return Op1;
// Op0|Op1 -> Op0 where Op1 implies Op0
- if (isImpliedCondition(Op1, Op0, Q.DL).getValueOr(false))
+ if (isImpliedCondition(Op1, Op0, Q.DL).value_or(false))
return Op0;
}
@@ -2877,7 +2877,7 @@ static Value *simplifyICmpOfBools(CmpInst::Predicate Pred, Value *LHS,
default:
break;
case ICmpInst::ICMP_UGE:
- if (isImpliedCondition(RHS, LHS, Q.DL).getValueOr(false))
+ if (isImpliedCondition(RHS, LHS, Q.DL).value_or(false))
return getTrue(ITy);
break;
case ICmpInst::ICMP_SGE:
@@ -2888,11 +2888,11 @@ static Value *simplifyICmpOfBools(CmpInst::Predicate Pred, Value *LHS,
/// 0 | 1 | 1 (0 >= -1) | 1
/// 1 | 0 | 0 (-1 >= 0) | 0
/// 1 | 1 | 1 (-1 >= -1) | 1
- if (isImpliedCondition(LHS, RHS, Q.DL).getValueOr(false))
+ if (isImpliedCondition(LHS, RHS, Q.DL).value_or(false))
return getTrue(ITy);
break;
case ICmpInst::ICMP_ULE:
- if (isImpliedCondition(LHS, RHS, Q.DL).getValueOr(false))
+ if (isImpliedCondition(LHS, RHS, Q.DL).value_or(false))
return getTrue(ITy);
break;
}
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp
index 14447f0acb8d..ca631374ac33 100644
--- a/llvm/lib/Analysis/LazyValueInfo.cpp
+++ b/llvm/lib/Analysis/LazyValueInfo.cpp
@@ -1424,8 +1424,9 @@ Optional<ValueLatticeElement> LazyValueInfoImpl::getEdgeValue(
if (Constant *VC = dyn_cast<Constant>(Val))
return ValueLatticeElement::get(VC);
- ValueLatticeElement LocalResult = getEdgeValueLocal(Val, BBFrom, BBTo)
- .getValueOr(ValueLatticeElement::getOverdefined());
+ ValueLatticeElement LocalResult =
+ getEdgeValueLocal(Val, BBFrom, BBTo)
+ .value_or(ValueLatticeElement::getOverdefined());
if (hasSingleValue(LocalResult))
// Can't get any more precise here
return LocalResult;
diff --git a/llvm/lib/Analysis/LoopInfo.cpp b/llvm/lib/Analysis/LoopInfo.cpp
index 7d46e1c28df3..29c2437ff5ea 100644
--- a/llvm/lib/Analysis/LoopInfo.cpp
+++ b/llvm/lib/Analysis/LoopInfo.cpp
@@ -1082,13 +1082,13 @@ Optional<bool> llvm::getOptionalBoolLoopAttribute(const Loop *TheLoop,
}
bool llvm::getBooleanLoopAttribute(const Loop *TheLoop, StringRef Name) {
- return getOptionalBoolLoopAttribute(TheLoop, Name).getValueOr(false);
+ return getOptionalBoolLoopAttribute(TheLoop, Name).value_or(false);
}
llvm::Optional<int> llvm::getOptionalIntLoopAttribute(const Loop *TheLoop,
StringRef Name) {
const MDOperand *AttrMD =
- findStringMetadataForLoop(TheLoop, Name).getValueOr(nullptr);
+ findStringMetadataForLoop(TheLoop, Name).value_or(nullptr);
if (!AttrMD)
return None;
@@ -1101,7 +1101,7 @@ llvm::Optional<int> llvm::getOptionalIntLoopAttribute(const Loop *TheLoop,
int llvm::getIntLoopAttribute(const Loop *TheLoop, StringRef Name,
int Default) {
- return getOptionalIntLoopAttribute(TheLoop, Name).getValueOr(Default);
+ return getOptionalIntLoopAttribute(TheLoop, Name).value_or(Default);
}
bool llvm::isFinite(const Loop *L) {
diff --git a/llvm/lib/Analysis/MemoryBuiltins.cpp b/llvm/lib/Analysis/MemoryBuiltins.cpp
index eaf1b6fa7796..a0f19bd3cf5f 100644
--- a/llvm/lib/Analysis/MemoryBuiltins.cpp
+++ b/llvm/lib/Analysis/MemoryBuiltins.cpp
@@ -260,7 +260,7 @@ static Optional<AllocFnsTy> getAllocationSize(const Value *V,
Result.AllocTy = MallocLike;
Result.NumParams = Callee->getNumOperands();
Result.FstParam = Args.first;
- Result.SndParam = Args.second.getValueOr(-1);
+ Result.SndParam = Args.second.value_or(-1);
// Allocsize has no way to specify an alignment argument
Result.AlignParam = -1;
return Result;
diff --git a/llvm/lib/Analysis/OptimizationRemarkEmitter.cpp b/llvm/lib/Analysis/OptimizationRemarkEmitter.cpp
index 33f7b54d5b7b..17b40f03a5a5 100644
--- a/llvm/lib/Analysis/OptimizationRemarkEmitter.cpp
+++ b/llvm/lib/Analysis/OptimizationRemarkEmitter.cpp
@@ -80,7 +80,7 @@ void OptimizationRemarkEmitter::emit(
computeHotness(OptDiag);
// Only emit it if its hotness meets the threshold.
- if (OptDiag.getHotness().getValueOr(0) <
+ if (OptDiag.getHotness().value_or(0) <
F->getContext().getDiagnosticsHotnessThreshold()) {
return;
}
diff --git a/llvm/lib/Analysis/ProfileSummaryInfo.cpp b/llvm/lib/Analysis/ProfileSummaryInfo.cpp
index 79dbdb5e46f4..66303e172a30 100644
--- a/llvm/lib/Analysis/ProfileSummaryInfo.cpp
+++ b/llvm/lib/Analysis/ProfileSummaryInfo.cpp
@@ -315,11 +315,11 @@ bool ProfileSummaryInfo::isColdCountNthPercentile(int PercentileCutoff,
}
uint64_t ProfileSummaryInfo::getOrCompHotCountThreshold() const {
- return HotCountThreshold.getValueOr(UINT64_MAX);
+ return HotCountThreshold.value_or(UINT64_MAX);
}
uint64_t ProfileSummaryInfo::getOrCompColdCountThreshold() const {
- return ColdCountThreshold.getValueOr(0);
+ return ColdCountThreshold.value_or(0);
}
bool ProfileSummaryInfo::isHotBlock(const BasicBlock *BB,
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 57d1366b4066..540d37f9b878 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -7826,7 +7826,7 @@ unsigned ScalarEvolution::getSmallConstantTripMultiple(const Loop *L) {
Res = Multiple;
Res = (unsigned)GreatestCommonDivisor64(*Res, Multiple);
}
- return Res.getValueOr(1);
+ return Res.value_or(1);
}
unsigned ScalarEvolution::getSmallConstantTripMultiple(const Loop *L,
diff --git a/llvm/lib/Analysis/StackSafetyAnalysis.cpp b/llvm/lib/Analysis/StackSafetyAnalysis.cpp
index 1b0e309b60aa..94b646ab7c06 100644
--- a/llvm/lib/Analysis/StackSafetyAnalysis.cpp
+++ b/llvm/lib/Analysis/StackSafetyAnalysis.cpp
@@ -383,9 +383,9 @@ bool StackSafetyLocalAnalysis::isSafeAccess(const Use &U, AllocaInst *AI,
const SCEV *Max = SE.getMinusSCEV(ToDiffTy(SE.getConstant(Size.getUpper())),
ToDiffTy(AccessSize));
return SE.evaluatePredicateAt(ICmpInst::Predicate::ICMP_SGE, Diff, Min, I)
- .getValueOr(false) &&
+ .value_or(false) &&
SE.evaluatePredicateAt(ICmpInst::Predicate::ICMP_SLE, Diff, Max, I)
- .getValueOr(false);
+ .value_or(false);
}
/// The function analyzes all local uses of Ptr (alloca or argument) and
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index e5ee36f2fe5f..a32408b9347d 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -7451,9 +7451,9 @@ int LLParser::parseCmpXchg(Instruction *&Inst, PerFunctionState &PFS) {
PFS.getFunction().getParent()->getDataLayout().getTypeStoreSize(
Cmp->getType()));
- AtomicCmpXchgInst *CXI = new AtomicCmpXchgInst(
- Ptr, Cmp, New, Alignment.getValueOr(DefaultAlignment), SuccessOrdering,
- FailureOrdering, SSID);
+ AtomicCmpXchgInst *CXI =
+ new AtomicCmpXchgInst(Ptr, Cmp, New, Alignment.value_or(DefaultAlignment),
+ SuccessOrdering, FailureOrdering, SSID);
CXI->setVolatile(isVolatile);
CXI->setWeak(isWeak);
@@ -7551,7 +7551,7 @@ int LLParser::parseAtomicRMW(Instruction *&Inst, PerFunctionState &PFS) {
Val->getType()));
AtomicRMWInst *RMWI =
new AtomicRMWInst(Operation, Ptr, Val,
- Alignment.getValueOr(DefaultAlignment), Ordering, SSID);
+ Alignment.value_or(DefaultAlignment), Ordering, SSID);
RMWI->setVolatile(isVolatile);
Inst = RMWI;
return AteExtraComma ? InstExtraComma : InstNormal;
diff --git a/llvm/lib/CodeGen/CommandFlags.cpp b/llvm/lib/CodeGen/CommandFlags.cpp
index cdf160db0f02..fd52191882cb 100644
--- a/llvm/lib/CodeGen/CommandFlags.cpp
+++ b/llvm/lib/CodeGen/CommandFlags.cpp
@@ -539,7 +539,7 @@ codegen::InitTargetOptionsFromCodeGenFlags(const Triple &TheTriple) {
Options.LowerGlobalDtorsViaCxaAtExit = getLowerGlobalDtorsViaCxaAtExit();
Options.RelaxELFRelocations = getRelaxELFRelocations();
Options.DataSections =
- getExplicitDataSections().getValueOr(TheTriple.hasDefaultDataSections());
+ getExplicitDataSections().value_or(TheTriple.hasDefaultDataSections());
Options.FunctionSections = getFunctionSections();
Options.IgnoreXCOFFVisibility = getIgnoreXCOFFVisibility();
Options.XCOFFTracebackTable = getXCOFFTracebackTable();
@@ -714,4 +714,3 @@ void codegen::setFunctionAttributes(StringRef CPU, StringRef Features,
for (Function &F : M)
setFunctionAttributes(CPU, Features, F);
}
-
diff --git a/llvm/lib/CodeGen/ExpandVectorPredication.cpp b/llvm/lib/CodeGen/ExpandVectorPredication.cpp
index fbb89a7d68d9..7883a48d121c 100644
--- a/llvm/lib/CodeGen/ExpandVectorPredication.cpp
+++ b/llvm/lib/CodeGen/ExpandVectorPredication.cpp
@@ -119,7 +119,7 @@ static bool maySpeculateLanes(VPIntrinsic &VPI) {
return false;
// Fallback to whether the intrinsic is speculatable.
Optional<unsigned> OpcOpt = VPI.getFunctionalOpcode();
- unsigned FunctionalOpc = OpcOpt.getValueOr((unsigned)Instruction::Call);
+ unsigned FunctionalOpc = OpcOpt.value_or((unsigned)Instruction::Call);
return isSafeToSpeculativelyExecuteWithOpcode(FunctionalOpc,
cast<Operator>(&VPI));
}
diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
index f5f097f4bce0..6cb37873eacb 100644
--- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -2425,7 +2425,7 @@ bool IRTranslator::translateCall(const User &U, MachineIRBuilder &MIRBuilder) {
TargetLowering::IntrinsicInfo Info;
// TODO: Add a GlobalISel version of getTgtMemIntrinsic.
if (TLI.getTgtMemIntrinsic(Info, CI, *MF, ID)) {
- Align Alignment = Info.align.getValueOr(
+ Align Alignment = Info.align.value_or(
DL->getABITypeAlign(Info.memVT.getTypeForEVT(F->getContext())));
LLT MemTy = Info.memVT.isSimple()
? getLLTForMVT(Info.memVT.getSimpleVT())
diff --git a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
index 88eb76090cf4..85df134088f4 100644
--- a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
@@ -923,7 +923,7 @@ bool MIRParserImpl::initializeConstantPool(PerFunctionMIParsingState &PFS,
return error(Error, YamlConstant.Value.SourceRange);
const Align PrefTypeAlign =
M.getDataLayout().getPrefTypeAlign(Value->getType());
- const Align Alignment = YamlConstant.Alignment.getValueOr(PrefTypeAlign);
+ const Align Alignment = YamlConstant.Alignment.value_or(PrefTypeAlign);
unsigned Index = ConstantPool.getConstantPoolIndex(Value, Alignment);
if (!ConstantPoolSlots.insert(std::make_pair(YamlConstant.ID.Value, Index))
.second)
diff --git a/llvm/lib/CodeGen/MachineOptimizationRemarkEmitter.cpp b/llvm/lib/CodeGen/MachineOptimizationRemarkEmitter.cpp
index 5347a7b0d890..631768ec986c 100644
--- a/llvm/lib/CodeGen/MachineOptimizationRemarkEmitter.cpp
+++ b/llvm/lib/CodeGen/MachineOptimizationRemarkEmitter.cpp
@@ -53,10 +53,8 @@ void MachineOptimizationRemarkEmitter::emit(
LLVMContext &Ctx = MF.getFunction().getContext();
// Only emit it if its hotness meets the threshold.
- if (OptDiag.getHotness().getValueOr(0) <
- Ctx.getDiagnosticsHotnessThreshold()) {
+ if (OptDiag.getHotness().value_or(0) < Ctx.getDiagnosticsHotnessThreshold())
return;
- }
Ctx.diagnose(OptDiag);
}
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index dca2478dc2f5..179583f58e61 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -4425,7 +4425,7 @@ void SelectionDAGBuilder::visitMaskedScatter(const CallInst &I) {
EVT VT = Src0.getValueType();
Align Alignment = cast<ConstantInt>(I.getArgOperand(2))
->getMaybeAlignValue()
- .getValueOr(DAG.getEVTAlign(VT.getScalarType()));
+ .value_or(DAG.getEVTAlign(VT.getScalarType()));
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
SDValue Base;
@@ -4531,7 +4531,7 @@ void SelectionDAGBuilder::visitMaskedGather(const CallInst &I) {
EVT VT = TLI.getValueType(DAG.getDataLayout(), I.getType());
Align Alignment = cast<ConstantInt>(I.getArgOperand(1))
->getMaybeAlignValue()
- .getValueOr(DAG.getEVTAlign(VT.getScalarType()));
+ .value_or(DAG.getEVTAlign(VT.getScalarType()));
const MDNode *Ranges = I.getMetadata(LLVMContext::MD_range);
diff --git a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
index aa1595414c10..f33d1c8edbe0 100644
--- a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
@@ -1169,8 +1169,8 @@ void SelectionDAGBuilder::LowerCallSiteWithDeoptBundleImpl(
unsigned DefaultID = StatepointDirectives::DeoptBundleStatepointID;
auto SD = parseStatepointDirectivesFromAttrs(Call->getAttributes());
- SI.ID = SD.StatepointID.getValueOr(DefaultID);
- SI.NumPatchBytes = SD.NumPatchBytes.getValueOr(0);
+ SI.ID = SD.StatepointID.value_or(DefaultID);
+ SI.NumPatchBytes = SD.NumPatchBytes.value_or(0);
SI.DeoptState =
ArrayRef<const Use>(DeoptBundle.Inputs.begin(), DeoptBundle.Inputs.end());
diff --git a/llvm/lib/DWARFLinker/DWARFLinker.cpp b/llvm/lib/DWARFLinker/DWARFLinker.cpp
index 7c2b5a7c8b74..6cb5006a7dc9 100644
--- a/llvm/lib/DWARFLinker/DWARFLinker.cpp
+++ b/llvm/lib/DWARFLinker/DWARFLinker.cpp
@@ -490,7 +490,7 @@ unsigned DWARFLinker::shouldKeepSubprogramDIE(
// generation bugs aside, this is really wrong in the case of labels, where
// a label marking the end of a function will have a PC == CU's high_pc.
if (dwarf::toAddress(OrigUnit.getUnitDIE().find(dwarf::DW_AT_high_pc))
- .getValueOr(UINT64_MAX) <= LowPc)
+ .value_or(UINT64_MAX) <= LowPc)
return Flags;
Unit.addLabelLowPc(*LowPc, MyInfo.AddrAdjust);
return Flags | TF_Keep;
@@ -1480,12 +1480,12 @@ DIE *DWARFLinker::DIECloner::cloneDIE(const DWARFDie &InputDIE,
uint32_t Hash = hashFullyQualifiedName(InputDIE, Unit, File);
uint64_t RuntimeLang =
dwarf::toUnsigned(InputDIE.find(dwarf::DW_AT_APPLE_runtime_class))
- .getValueOr(0);
+ .value_or(0);
bool ObjCClassIsImplementation =
(RuntimeLang == dwarf::DW_LANG_ObjC ||
RuntimeLang == dwarf::DW_LANG_ObjC_plus_plus) &&
dwarf::toUnsigned(InputDIE.find(dwarf::DW_AT_APPLE_objc_complete_type))
- .getValueOr(0);
+ .value_or(0);
Unit.addTypeAccelerator(Die, AttrInfo.Name, ObjCClassIsImplementation,
Hash);
}
diff --git a/llvm/lib/DebugInfo/CodeView/CVSymbolVisitor.cpp b/llvm/lib/DebugInfo/CodeView/CVSymbolVisitor.cpp
index da2041d54104..2154aa2b8d00 100644
--- a/llvm/lib/DebugInfo/CodeView/CVSymbolVisitor.cpp
+++ b/llvm/lib/DebugInfo/CodeView/CVSymbolVisitor.cpp
@@ -90,8 +90,8 @@ Error CVSymbolVisitor::visitSymbolStreamFiltered(const CVSymbolArray &Symbols,
if (!Filter.SymbolOffset)
return visitSymbolStream(Symbols);
uint32_t SymbolOffset = *Filter.SymbolOffset;
- uint32_t ParentRecurseDepth = Filter.ParentRecursiveDepth.getValueOr(0);
- uint32_t ChildrenRecurseDepth = Filter.ChildRecursiveDepth.getValueOr(0);
+ uint32_t ParentRecurseDepth = Filter.ParentRecursiveDepth.value_or(0);
+ uint32_t ChildrenRecurseDepth = Filter.ChildRecursiveDepth.value_or(0);
if (!Symbols.isOffsetValid(SymbolOffset))
return createStringError(inconvertibleErrorCode(), "Invalid symbol offset");
CVSymbol Sym = *Symbols.at(SymbolOffset);
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
index fb982804c7b1..19863c92947b 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
@@ -533,7 +533,7 @@ Optional<uint64_t> DWARFDie::getTypeSize(uint64_t PointerSize) {
UpperBoundAttr->getAsSignedConstant()) {
int64_t LowerBound = 0;
if (auto LowerBoundAttr = Child.find(DW_AT_lower_bound))
- LowerBound = LowerBoundAttr->getAsSignedConstant().getValueOr(0);
+ LowerBound = LowerBoundAttr->getAsSignedConstant().value_or(0);
Size *= *UpperBound - LowerBound + 1;
}
}
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
index 29c769834b06..74667fcb92bc 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
@@ -624,7 +624,7 @@ bool DWARFUnit::parseDWO() {
DWO->setAddrOffsetSection(AddrOffsetSection, *AddrOffsetSectionBase);
if (getVersion() == 4) {
auto DWORangesBase = UnitDie.getRangesBaseAttribute();
- DWO->setRangesSection(RangeSection, DWORangesBase.getValueOr(0));
+ DWO->setRangesSection(RangeSection, DWORangesBase.value_or(0));
}
return true;
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index 7bed90500045..596348ddb462 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -2075,7 +2075,7 @@ static void writeDIFile(raw_ostream &Out, const DIFile *N, AsmWriterContext &) {
// Print all values for checksum together, or not at all.
if (N->getChecksum())
Printer.printChecksum(*N->getChecksum());
- Printer.printString("source", N->getSource().getValueOr(StringRef()),
+ Printer.printString("source", N->getSource().value_or(StringRef()),
/* ShouldSkipEmpty */ true);
Out << ")";
}
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp
index 2006d2f43b22..fa6638f6779b 100644
--- a/llvm/lib/IR/Attributes.cpp
+++ b/llvm/lib/IR/Attributes.cpp
@@ -60,7 +60,7 @@ static uint64_t packAllocSizeArgs(unsigned ElemSizeArg,
"Attempting to pack a reserved value");
return uint64_t(ElemSizeArg) << 32 |
- NumElemsArg.getValueOr(AllocSizeNumElemsNotPresent);
+ NumElemsArg.value_or(AllocSizeNumElemsNotPresent);
}
static std::pair<unsigned, Optional<unsigned>>
@@ -76,7 +76,7 @@ unpackAllocSizeArgs(uint64_t Num) {
static uint64_t packVScaleRangeArgs(unsigned MinValue,
Optional<unsigned> MaxValue) {
- return uint64_t(MinValue) << 32 | MaxValue.getValueOr(0);
+ return uint64_t(MinValue) << 32 | MaxValue.value_or(0);
}
static std::pair<unsigned, Optional<unsigned>>
@@ -438,7 +438,7 @@ std::string Attribute::getAsString(bool InAttrGrp) const {
unsigned MinValue = getVScaleRangeMin();
Optional<unsigned> MaxValue = getVScaleRangeMax();
return ("vscale_range(" + Twine(MinValue) + "," +
- Twine(MaxValue.getValueOr(0)) + ")")
+ Twine(MaxValue.value_or(0)) + ")")
.str();
}
diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp
index b23ab3563919..115a57740546 100644
--- a/llvm/lib/IR/DebugInfoMetadata.cpp
+++ b/llvm/lib/IR/DebugInfoMetadata.cpp
@@ -807,7 +807,7 @@ DIFile *DIFile::getImpl(LLVMContext &Context, MDString *Filename,
assert((!Source || isCanonical(*Source)) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(DIFile, (Filename, Directory, CS, Source));
Metadata *Ops[] = {Filename, Directory, CS ? CS->Value : nullptr,
- Source.getValueOr(nullptr)};
+ Source.value_or(nullptr)};
DEFINE_GETIMPL_STORE(DIFile, (CS, Source), Ops);
}
DICompileUnit::DICompileUnit(LLVMContext &C, StorageType Storage,
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 1b546ce3a3a0..5efd6082a76c 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -4477,7 +4477,7 @@ void SwitchInstProfUpdateWrapper::addCase(
Weights.getValue()[SI.getNumSuccessors() - 1] = *W;
} else if (Weights) {
Changed = true;
- Weights.getValue().push_back(W.getValueOr(0));
+ Weights.getValue().push_back(W.value_or(0));
}
if (Weights)
assert(SI.getNumSuccessors() == Weights->size() &&
diff --git a/llvm/lib/IR/LLVMContext.cpp b/llvm/lib/IR/LLVMContext.cpp
index 9a0e9ac85c26..5dfca4abb198 100644
--- a/llvm/lib/IR/LLVMContext.cpp
+++ b/llvm/lib/IR/LLVMContext.cpp
@@ -145,14 +145,14 @@ bool LLVMContext::getMisExpectWarningRequested() const {
return pImpl->MisExpectWarningRequested;
}
uint64_t LLVMContext::getDiagnosticsHotnessThreshold() const {
- return pImpl->DiagnosticsHotnessThreshold.getValueOr(UINT64_MAX);
+ return pImpl->DiagnosticsHotnessThreshold.value_or(UINT64_MAX);
}
void LLVMContext::setDiagnosticsMisExpectTolerance(
Optional<uint64_t> Tolerance) {
pImpl->DiagnosticsMisExpectTolerance = Tolerance;
}
uint64_t LLVMContext::getDiagnosticsMisExpectTolerance() const {
- return pImpl->DiagnosticsMisExpectTolerance.getValueOr(0);
+ return pImpl->DiagnosticsMisExpectTolerance.value_or(0);
}
bool LLVMContext::isDiagnosticsHotnessThresholdSetFromPSI() const {
diff --git a/llvm/lib/IR/LLVMContextImpl.h b/llvm/lib/IR/LLVMContextImpl.h
index 04b0b11b18f3..47add940f603 100644
--- a/llvm/lib/IR/LLVMContextImpl.h
+++ b/llvm/lib/IR/LLVMContextImpl.h
@@ -687,7 +687,7 @@ template <> struct MDNodeKeyImpl<DIFile> {
unsigned getHashValue() const {
return hash_combine(Filename, Directory, Checksum ? Checksum->Kind : 0,
Checksum ? Checksum->Value : nullptr,
- Source.getValueOr(nullptr));
+ Source.value_or(nullptr));
}
};
diff --git a/llvm/lib/IR/VectorBuilder.cpp b/llvm/lib/IR/VectorBuilder.cpp
index 34d943a9b10b..f6c59de66a58 100644
--- a/llvm/lib/IR/VectorBuilder.cpp
+++ b/llvm/lib/IR/VectorBuilder.cpp
@@ -70,8 +70,8 @@ Value *VectorBuilder::createVectorInstruction(unsigned Opcode, Type *ReturnTy,
// Whether the mask and vlen parameter are at the end of the parameter list.
bool TrailingMaskAndVLen =
- std::min<size_t>(MaskPosOpt.getValueOr(NumInstParams),
- VLenPosOpt.getValueOr(NumInstParams)) >= NumInstParams;
+ std::min<size_t>(MaskPosOpt.value_or(NumInstParams),
+ VLenPosOpt.value_or(NumInstParams)) >= NumInstParams;
if (TrailingMaskAndVLen) {
// Fast path for trailing mask, vector length.
@@ -82,8 +82,8 @@ Value *VectorBuilder::createVectorInstruction(unsigned Opcode, Type *ReturnTy,
// Insert mask and evl operands in between the instruction operands.
for (size_t VPParamIdx = 0, ParamIdx = 0; VPParamIdx < NumVPParams;
++VPParamIdx) {
- if ((MaskPosOpt && MaskPosOpt.getValueOr(NumVPParams) == VPParamIdx) ||
- (VLenPosOpt && VLenPosOpt.getValueOr(NumVPParams) == VPParamIdx))
+ if ((MaskPosOpt && MaskPosOpt.value_or(NumVPParams) == VPParamIdx) ||
+ (VLenPosOpt && VLenPosOpt.value_or(NumVPParams) == VPParamIdx))
continue;
assert(ParamIdx < NumInstParams);
IntrinParams[VPParamIdx] = InstOpArray[ParamIdx++];
diff --git a/llvm/lib/InterfaceStub/ELFObjHandler.cpp b/llvm/lib/InterfaceStub/ELFObjHandler.cpp
index 55d06cd224f7..33dc529de60a 100644
--- a/llvm/lib/InterfaceStub/ELFObjHandler.cpp
+++ b/llvm/lib/InterfaceStub/ELFObjHandler.cpp
@@ -217,7 +217,7 @@ template <class ELFT> class ELFStubBuilder {
// time as long as it is not SHN_UNDEF. Set shndx to 1, which
// points to ".dynsym".
uint16_t Shndx = Sym.Undefined ? SHN_UNDEF : 1;
- uint64_t Size = Sym.Size.getValueOr(0);
+ uint64_t Size = Sym.Size.value_or(0);
DynSym.Content.add(DynStr.Content.getOffset(Sym.Name), Size, Bind,
convertIFSSymbolTypeToELF(Sym.Type), 0, Shndx);
}
diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp
index d151b8b3f89a..db38c2810d76 100644
--- a/llvm/lib/MC/MCDwarf.cpp
+++ b/llvm/lib/MC/MCDwarf.cpp
@@ -397,11 +397,10 @@ static void emitOneV5FileEntry(MCStreamer *MCOS, const MCDwarfFile &DwarfFile,
}
if (HasSource) {
if (LineStr)
- LineStr->emitRef(MCOS, DwarfFile.Source.getValueOr(StringRef()));
+ LineStr->emitRef(MCOS, DwarfFile.Source.value_or(StringRef()));
else {
- MCOS->emitBytes(
- DwarfFile.Source.getValueOr(StringRef())); // Source and...
- MCOS->emitBytes(StringRef("\0", 1)); // its null terminator.
+ MCOS->emitBytes(DwarfFile.Source.value_or(StringRef())); // Source and...
+ MCOS->emitBytes(StringRef("\0", 1)); // its null terminator.
}
}
}
diff --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp
index 88237a059b60..a229d282dabe 100644
--- a/llvm/lib/MC/MCStreamer.cpp
+++ b/llvm/lib/MC/MCStreamer.cpp
@@ -1371,15 +1371,14 @@ void MCStreamer::emitVersionForTarget(
emitDarwinTargetVariantBuildVersion(
getMachoBuildVersionPlatformType(Target),
LinkedTargetVersion.getMajor(),
- LinkedTargetVersion.getMinor().getValueOr(0),
- LinkedTargetVersion.getSubminor().getValueOr(0), SDKVersion);
+ LinkedTargetVersion.getMinor().value_or(0),
+ LinkedTargetVersion.getSubminor().value_or(0), SDKVersion);
return;
}
emitBuildVersion(getMachoBuildVersionPlatformType(Target),
LinkedTargetVersion.getMajor(),
- LinkedTargetVersion.getMinor().getValueOr(0),
- LinkedTargetVersion.getSubminor().getValueOr(0),
- SDKVersion);
+ LinkedTargetVersion.getMinor().value_or(0),
+ LinkedTargetVersion.getSubminor().value_or(0), SDKVersion);
ShouldEmitBuildVersion = true;
}
@@ -1390,8 +1389,8 @@ void MCStreamer::emitVersionForTarget(
emitDarwinTargetVariantBuildVersion(
getMachoBuildVersionPlatformType(*TVT),
TVLinkedTargetVersion.getMajor(),
- TVLinkedTargetVersion.getMinor().getValueOr(0),
- TVLinkedTargetVersion.getSubminor().getValueOr(0),
+ TVLinkedTargetVersion.getMinor().value_or(0),
+ TVLinkedTargetVersion.getSubminor().value_or(0),
DarwinTargetVariantSDKVersion);
}
}
@@ -1401,6 +1400,6 @@ void MCStreamer::emitVersionForTarget(
emitVersionMin(getMachoVersionMinLoadCommandType(Target),
LinkedTargetVersion.getMajor(),
- LinkedTargetVersion.getMinor().getValueOr(0),
- LinkedTargetVersion.getSubminor().getValueOr(0), SDKVersion);
+ LinkedTargetVersion.getMinor().value_or(0),
+ LinkedTargetVersion.getSubminor().value_or(0), SDKVersion);
}
diff --git a/llvm/lib/MC/MachObjectWriter.cpp b/llvm/lib/MC/MachObjectWriter.cpp
index 173755df2b85..78d0d9cec556 100644
--- a/llvm/lib/MC/MachObjectWriter.cpp
+++ b/llvm/lib/MC/MachObjectWriter.cpp
@@ -915,8 +915,8 @@ uint64_t MachObjectWriter::writeObject(MCAssembler &Asm,
[&](const MCAssembler::VersionInfoType &VersionInfo) {
auto EncodeVersion = [](VersionTuple V) -> uint32_t {
assert(!V.empty() && "empty version");
- unsigned Update = V.getSubminor().getValueOr(0);
- unsigned Minor = V.getMinor().getValueOr(0);
+ unsigned Update = V.getSubminor().value_or(0);
+ unsigned Minor = V.getMinor().value_or(0);
assert(Update < 256 && "unencodable update target version");
assert(Minor < 256 && "unencodable minor target version");
assert(V.getMajor() < 65536 && "unencodable major target version");
diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp
index ab5d9f8431cf..7cc11d24f286 100644
--- a/llvm/lib/MC/WasmObjectWriter.cpp
+++ b/llvm/lib/MC/WasmObjectWriter.cpp
@@ -1570,9 +1570,9 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm,
continue;
const auto &WS = static_cast<const MCSymbolWasm &>(S);
- LLVM_DEBUG(dbgs()
- << "MCSymbol: "
- << toString(WS.getType().getValueOr(wasm::WASM_SYMBOL_TYPE_DATA))
+ LLVM_DEBUG(
+ dbgs() << "MCSymbol: "
+ << toString(WS.getType().value_or(wasm::WASM_SYMBOL_TYPE_DATA))
<< " '" << S << "'"
<< " isDefined=" << S.isDefined() << " isExternal="
<< S.isExternal() << " isTemporary=" << S.isTemporary()
@@ -1809,7 +1809,7 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm,
wasm::WasmSymbolInfo Info;
Info.Name = WS.getName();
- Info.Kind = WS.getType().getValueOr(wasm::WASM_SYMBOL_TYPE_DATA);
+ Info.Kind = WS.getType().value_or(wasm::WASM_SYMBOL_TYPE_DATA);
Info.Flags = Flags;
if (!WS.isData()) {
assert(WasmIndices.count(&WS) > 0);
diff --git a/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp b/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
index f759fac5ac11..a7b7a47e49ca 100644
--- a/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
+++ b/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
@@ -774,7 +774,7 @@ Error objcopy::elf::executeObjcopyOnIHex(const CommonConfig &Config,
return Obj.takeError();
const ElfType OutputElfType =
- getOutputElfType(Config.OutputArch.getValueOr(MachineInfo()));
+ getOutputElfType(Config.OutputArch.value_or(MachineInfo()));
if (Error E = handleArgs(Config, ELFConfig, **Obj))
return E;
return writeOutput(Config, **Obj, Out, OutputElfType);
@@ -792,7 +792,7 @@ Error objcopy::elf::executeObjcopyOnRawBinary(const CommonConfig &Config,
// Prefer OutputArch (-O<format>) if set, otherwise fallback to BinaryArch
// (-B<arch>).
const ElfType OutputElfType =
- getOutputElfType(Config.OutputArch.getValueOr(MachineInfo()));
+ getOutputElfType(Config.OutputArch.value_or(MachineInfo()));
if (Error E = handleArgs(Config, ELFConfig, **Obj))
return E;
return writeOutput(Config, **Obj, Out, OutputElfType);
diff --git a/llvm/lib/ObjectYAML/DWARFEmitter.cpp b/llvm/lib/ObjectYAML/DWARFEmitter.cpp
index eec733c7d7f9..c0e2cdd54f07 100644
--- a/llvm/lib/ObjectYAML/DWARFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/DWARFEmitter.cpp
@@ -423,7 +423,7 @@ Error DWARFYAML::emitDebugInfo(raw_ostream &OS, const DWARFYAML::Data &DI) {
std::string EntryBuffer;
raw_string_ostream EntryBufferOS(EntryBuffer);
- uint64_t AbbrevTableID = Unit.AbbrevTableID.getValueOr(I);
+ uint64_t AbbrevTableID = Unit.AbbrevTableID.value_or(I);
for (const DWARFYAML::Entry &Entry : Unit.Entries) {
if (Expected<uint64_t> EntryLength =
writeDIE(DI, I, AbbrevTableID, Params, Entry, EntryBufferOS,
@@ -507,7 +507,7 @@ static void writeExtendedOpcode(const DWARFYAML::LineTableOpcode &Op,
for (auto OpByte : Op.UnknownOpcodeData)
writeInteger((uint8_t)OpByte, OpBufferOS, IsLittleEndian);
}
- uint64_t ExtLen = Op.ExtLen.getValueOr(OpBuffer.size());
+ uint64_t ExtLen = Op.ExtLen.value_or(OpBuffer.size());
encodeULEB128(ExtLen, OS);
OS.write(OpBuffer.data(), OpBuffer.size());
}
@@ -582,7 +582,7 @@ Error DWARFYAML::emitDebugLine(raw_ostream &OS, const DWARFYAML::Data &DI) {
writeInteger(LineTable.LineRange, BufferOS, DI.IsLittleEndian);
std::vector<uint8_t> StandardOpcodeLengths =
- LineTable.StandardOpcodeLengths.getValueOr(
+ LineTable.StandardOpcodeLengths.value_or(
getStandardOpcodeLengths(LineTable.Version, LineTable.OpcodeBase));
uint8_t OpcodeBase = LineTable.OpcodeBase
? *LineTable.OpcodeBase
diff --git a/llvm/lib/ObjectYAML/DWARFYAML.cpp b/llvm/lib/ObjectYAML/DWARFYAML.cpp
index 2591bf4d5af4..37116ada9901 100644
--- a/llvm/lib/ObjectYAML/DWARFYAML.cpp
+++ b/llvm/lib/ObjectYAML/DWARFYAML.cpp
@@ -62,7 +62,7 @@ DWARFYAML::Data::getAbbrevTableInfoByID(uint64_t ID) const {
for (auto &AbbrevTable : enumerate(DebugAbbrev)) {
// If the abbrev table's ID isn't specified, we use the index as its ID.
uint64_t AbbrevTableID =
- AbbrevTable.value().ID.getValueOr(AbbrevTable.index());
+ AbbrevTable.value().ID.value_or(AbbrevTable.index());
auto It = AbbrevTableInfoMap.insert(
{AbbrevTableID, AbbrevTableInfo{/*Index=*/AbbrevTable.index(),
/*Offset=*/AbbrevTableOffset}});
diff --git a/llvm/lib/ObjectYAML/ELFEmitter.cpp b/llvm/lib/ObjectYAML/ELFEmitter.cpp
index e378be3892fe..018298928b41 100644
--- a/llvm/lib/ObjectYAML/ELFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/ELFEmitter.cpp
@@ -412,7 +412,7 @@ ELFState<ELFT>::ELFState(ELFYAML::Object &D, yaml::ErrorHandler EH)
}
// TODO: Only create the .strtab here if any symbols have been requested.
ImplicitSections.insert(".strtab");
- if (!SecHdrTable || !SecHdrTable->NoHeaders.getValueOr(false))
+ if (!SecHdrTable || !SecHdrTable->NoHeaders.value_or(false))
ImplicitSections.insert(SectionHeaderStringTableName);
// Insert placeholders for implicit sections that are not
@@ -600,8 +600,7 @@ unsigned ELFState<ELFT>::toSectionIndex(StringRef S, StringRef LocSec,
SectionHeaders.isDefault())
return Index;
- assert(!SectionHeaders.NoHeaders.getValueOr(false) ||
- !SectionHeaders.Sections);
+ assert(!SectionHeaders.NoHeaders.value_or(false) || !SectionHeaders.Sections);
size_t FirstExcluded =
SectionHeaders.Sections ? SectionHeaders.Sections->size() : 0;
if (Index > FirstExcluded) {
@@ -771,7 +770,7 @@ void ELFState<ELFT>::initSectionHeaders(std::vector<Elf_Shdr> &SHeaders,
if (ELFYAML::SectionHeaderTable *S =
dyn_cast<ELFYAML::SectionHeaderTable>(D.get())) {
- if (S->NoHeaders.getValueOr(false))
+ if (S->NoHeaders.value_or(false))
continue;
if (!S->Offset)
@@ -808,7 +807,7 @@ void ELFState<ELFT>::initSectionHeaders(std::vector<Elf_Shdr> &SHeaders,
SHeader.sh_entsize = *Sec->EntSize;
else
SHeader.sh_entsize = ELFYAML::getDefaultShEntSize<ELFT>(
- Doc.Header.Machine.getValueOr(ELF::EM_NONE), Sec->Type, Sec->Name);
+ Doc.Header.Machine.value_or(ELF::EM_NONE), Sec->Type, Sec->Name);
// We have a few sections like string or symbol tables that are usually
// added implicitly to the end. However, if they are explicitly specified
@@ -958,9 +957,9 @@ ELFState<ELFT>::toELFSymbols(ArrayRef<ELFYAML::Symbol> Symbols,
else if (Sym.Index)
Symbol.st_shndx = *Sym.Index;
- Symbol.st_value = Sym.Value.getValueOr(yaml::Hex64(0));
+ Symbol.st_value = Sym.Value.value_or(yaml::Hex64(0));
Symbol.st_other = Sym.Other ? *Sym.Other : 0;
- Symbol.st_size = Sym.Size.getValueOr(yaml::Hex64(0));
+ Symbol.st_size = Sym.Size.value_or(yaml::Hex64(0));
}
return Ret;
@@ -1399,7 +1398,7 @@ void ELFState<ELFT>::writeSectionContent(
// Write number of BBEntries (number of basic blocks in the function). This
// is overridden by the 'NumBlocks' YAML field when specified.
uint64_t NumBlocks =
- E.NumBlocks.getValueOr(E.BBEntries ? E.BBEntries->size() : 0);
+ E.NumBlocks.value_or(E.BBEntries ? E.BBEntries->size() : 0);
SHeader.sh_size += sizeof(uintX_t) + CBA.writeULEB128(NumBlocks);
// Write all BBEntries.
if (!E.BBEntries)
@@ -1486,10 +1485,10 @@ void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
return;
CBA.write<uint32_t>(
- Section.NBucket.getValueOr(llvm::yaml::Hex64(Section.Bucket->size())),
+ Section.NBucket.value_or(llvm::yaml::Hex64(Section.Bucket->size())),
ELFT::TargetEndianness);
CBA.write<uint32_t>(
- Section.NChain.getValueOr(llvm::yaml::Hex64(Section.Chain->size())),
+ Section.NChain.value_or(llvm::yaml::Hex64(Section.Chain->size())),
ELFT::TargetEndianness);
for (uint32_t Val : *Section.Bucket)
@@ -1518,10 +1517,10 @@ void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
const ELFYAML::VerdefEntry &E = (*Section.Entries)[I];
Elf_Verdef VerDef;
- VerDef.vd_version = E.Version.getValueOr(1);
- VerDef.vd_flags = E.Flags.getValueOr(0);
- VerDef.vd_ndx = E.VersionNdx.getValueOr(0);
- VerDef.vd_hash = E.Hash.getValueOr(0);
+ VerDef.vd_version = E.Version.value_or(1);
+ VerDef.vd_flags = E.Flags.value_or(0);
+ VerDef.vd_ndx = E.VersionNdx.value_or(0);
+ VerDef.vd_hash = E.Hash.value_or(0);
VerDef.vd_aux = sizeof(Elf_Verdef);
VerDef.vd_cnt = E.VerNames.size();
if (I == Section.Entries->size() - 1)
@@ -1830,7 +1829,7 @@ template <class ELFT> void ELFState<ELFT>::buildSectionIndex() {
if (!ExcludedSectionHeaders.insert(Hdr.Name).second)
llvm_unreachable("buildSectionIndex() failed");
- if (SectionHeaders.NoHeaders.getValueOr(false))
+ if (SectionHeaders.NoHeaders.value_or(false))
for (const ELFYAML::Section *S : Sections)
if (!ExcludedSectionHeaders.insert(S->Name).second)
llvm_unreachable("buildSectionIndex() failed");
@@ -1960,7 +1959,7 @@ bool ELFState<ELFT>::writeELF(raw_ostream &OS, ELFYAML::Object &Doc,
writeArrayData(OS, makeArrayRef(PHeaders));
const ELFYAML::SectionHeaderTable &SHT = Doc.getSectionHeaderTable();
- if (!SHT.NoHeaders.getValueOr(false))
+ if (!SHT.NoHeaders.value_or(false))
CBA.updateDataAt(*SHT.Offset, SHeaders.data(),
SHT.getNumHeaders(SHeaders.size()) * sizeof(Elf_Shdr));
diff --git a/llvm/lib/ObjectYAML/MinidumpEmitter.cpp b/llvm/lib/ObjectYAML/MinidumpEmitter.cpp
index bbfd2cd8cbab..9505473a2415 100644
--- a/llvm/lib/ObjectYAML/MinidumpEmitter.cpp
+++ b/llvm/lib/ObjectYAML/MinidumpEmitter.cpp
@@ -219,7 +219,7 @@ static Directory layout(BlobAllocator &File, Stream &S) {
// If DataEnd is not set, we assume everything we generated is a part of the
// stream.
Result.Location.DataSize =
- DataEnd.getValueOr(File.tell()) - Result.Location.RVA;
+ DataEnd.value_or(File.tell()) - Result.Location.RVA;
return Result;
}
diff --git a/llvm/lib/ObjectYAML/XCOFFEmitter.cpp b/llvm/lib/ObjectYAML/XCOFFEmitter.cpp
index 2a7204d3f773..1ceac6c05893 100644
--- a/llvm/lib/ObjectYAML/XCOFFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/XCOFFEmitter.cpp
@@ -212,8 +212,8 @@ bool XCOFFWriter::initStringTable() {
for (const std::unique_ptr<XCOFFYAML::AuxSymbolEnt> &AuxSym :
YamlSym.AuxEntries) {
if (auto AS = dyn_cast<XCOFFYAML::FileAuxEnt>(AuxSym.get()))
- if (nameShouldBeInStringTable(AS->FileNameOrString.getValueOr("")))
- StrTblBuilder.add(AS->FileNameOrString.getValueOr(""));
+ if (nameShouldBeInStringTable(AS->FileNameOrString.value_or("")))
+ StrTblBuilder.add(AS->FileNameOrString.value_or(""));
}
}
@@ -247,8 +247,7 @@ bool XCOFFWriter::initFileHeader(uint64_t CurrentOffset) {
Twine(AuxCount));
return false;
}
- YamlSym.NumberOfAuxEntries =
- YamlSym.NumberOfAuxEntries.getValueOr(AuxCount);
+ YamlSym.NumberOfAuxEntries = YamlSym.NumberOfAuxEntries.value_or(AuxCount);
// Add the number of auxiliary symbols to the total number.
InitFileHdr.NumberOfSymTableEntries += *YamlSym.NumberOfAuxEntries;
}
@@ -378,59 +377,60 @@ void XCOFFWriter::writeFileHeader() {
}
void XCOFFWriter::writeAuxFileHeader() {
- W.write<uint16_t>(InitAuxFileHdr.Magic.getValueOr(yaml::Hex16(1)));
- W.write<uint16_t>(InitAuxFileHdr.Version.getValueOr(yaml::Hex16(1)));
+ W.write<uint16_t>(InitAuxFileHdr.Magic.value_or(yaml::Hex16(1)));
+ W.write<uint16_t>(InitAuxFileHdr.Version.value_or(yaml::Hex16(1)));
if (Is64Bit) {
W.OS.write_zeros(4); // Reserved for debugger.
- W.write<uint64_t>(InitAuxFileHdr.TextStartAddr.getValueOr(yaml::Hex64(0)));
- W.write<uint64_t>(InitAuxFileHdr.DataStartAddr.getValueOr(yaml::Hex64(0)));
- W.write<uint64_t>(InitAuxFileHdr.TOCAnchorAddr.getValueOr(yaml::Hex64(0)));
+ W.write<uint64_t>(InitAuxFileHdr.TextStartAddr.value_or(yaml::Hex64(0)));
+ W.write<uint64_t>(InitAuxFileHdr.DataStartAddr.value_or(yaml::Hex64(0)));
+ W.write<uint64_t>(InitAuxFileHdr.TOCAnchorAddr.value_or(yaml::Hex64(0)));
} else {
- W.write<uint32_t>(InitAuxFileHdr.TextSize.getValueOr(yaml::Hex64(0)));
- W.write<uint32_t>(InitAuxFileHdr.InitDataSize.getValueOr(yaml::Hex64(0)));
- W.write<uint32_t>(InitAuxFileHdr.BssDataSize.getValueOr(yaml::Hex64(0)));
- W.write<uint32_t>(InitAuxFileHdr.EntryPointAddr.getValueOr(yaml::Hex64(0)));
- W.write<uint32_t>(InitAuxFileHdr.TextStartAddr.getValueOr(yaml::Hex64(0)));
- W.write<uint32_t>(InitAuxFileHdr.DataStartAddr.getValueOr(yaml::Hex64(0)));
- W.write<uint32_t>(InitAuxFileHdr.TOCAnchorAddr.getValueOr(yaml::Hex64(0)));
+ W.write<uint32_t>(InitAuxFileHdr.TextSize.value_or(yaml::Hex64(0)));
+ W.write<uint32_t>(InitAuxFileHdr.InitDataSize.value_or(yaml::Hex64(0)));
+ W.write<uint32_t>(InitAuxFileHdr.BssDataSize.value_or(yaml::Hex64(0)));
+ W.write<uint32_t>(InitAuxFileHdr.EntryPointAddr.value_or(yaml::Hex64(0)));
+ W.write<uint32_t>(InitAuxFileHdr.TextStartAddr.value_or(yaml::Hex64(0)));
+ W.write<uint32_t>(InitAuxFileHdr.DataStartAddr.value_or(yaml::Hex64(0)));
+ W.write<uint32_t>(InitAuxFileHdr.TOCAnchorAddr.value_or(yaml::Hex64(0)));
}
- W.write<uint16_t>(InitAuxFileHdr.SecNumOfEntryPoint.getValueOr(0));
- W.write<uint16_t>(InitAuxFileHdr.SecNumOfText.getValueOr(0));
- W.write<uint16_t>(InitAuxFileHdr.SecNumOfData.getValueOr(0));
- W.write<uint16_t>(InitAuxFileHdr.SecNumOfTOC.getValueOr(0));
- W.write<uint16_t>(InitAuxFileHdr.SecNumOfLoader.getValueOr(0));
- W.write<uint16_t>(InitAuxFileHdr.SecNumOfBSS.getValueOr(0));
- W.write<uint16_t>(InitAuxFileHdr.MaxAlignOfText.getValueOr(yaml::Hex16(0)));
- W.write<uint16_t>(InitAuxFileHdr.MaxAlignOfData.getValueOr(yaml::Hex16(0)));
- W.write<uint16_t>(InitAuxFileHdr.ModuleType.getValueOr(yaml::Hex16(0)));
- W.write<uint8_t>(InitAuxFileHdr.CpuFlag.getValueOr(yaml::Hex8(0)));
+ W.write<uint16_t>(InitAuxFileHdr.SecNumOfEntryPoint.value_or(0));
+ W.write<uint16_t>(InitAuxFileHdr.SecNumOfText.value_or(0));
+ W.write<uint16_t>(InitAuxFileHdr.SecNumOfData.value_or(0));
+ W.write<uint16_t>(InitAuxFileHdr.SecNumOfTOC.value_or(0));
+ W.write<uint16_t>(InitAuxFileHdr.SecNumOfLoader.value_or(0));
+ W.write<uint16_t>(InitAuxFileHdr.SecNumOfBSS.value_or(0));
+ W.write<uint16_t>(InitAuxFileHdr.MaxAlignOfText.value_or(yaml::Hex16(0)));
+ W.write<uint16_t>(InitAuxFileHdr.MaxAlignOfData.value_or(yaml::Hex16(0)));
+ W.write<uint16_t>(InitAuxFileHdr.ModuleType.value_or(yaml::Hex16(0)));
+ W.write<uint8_t>(InitAuxFileHdr.CpuFlag.value_or(yaml::Hex8(0)));
W.write<uint8_t>(0); // Reserved for CPU type.
if (Is64Bit) {
- W.write<uint8_t>(InitAuxFileHdr.TextPageSize.getValueOr(yaml::Hex8(0)));
- W.write<uint8_t>(InitAuxFileHdr.DataPageSize.getValueOr(yaml::Hex8(0)));
- W.write<uint8_t>(InitAuxFileHdr.StackPageSize.getValueOr(yaml::Hex8(0)));
+ W.write<uint8_t>(InitAuxFileHdr.TextPageSize.value_or(yaml::Hex8(0)));
+ W.write<uint8_t>(InitAuxFileHdr.DataPageSize.value_or(yaml::Hex8(0)));
+ W.write<uint8_t>(InitAuxFileHdr.StackPageSize.value_or(yaml::Hex8(0)));
W.write<uint8_t>(
- InitAuxFileHdr.FlagAndTDataAlignment.getValueOr(yaml::Hex8(0x80)));
- W.write<uint64_t>(InitAuxFileHdr.TextSize.getValueOr(yaml::Hex64(0)));
- W.write<uint64_t>(InitAuxFileHdr.InitDataSize.getValueOr(yaml::Hex64(0)));
- W.write<uint64_t>(InitAuxFileHdr.BssDataSize.getValueOr(yaml::Hex64(0)));
- W.write<uint64_t>(InitAuxFileHdr.EntryPointAddr.getValueOr(yaml::Hex64(0)));
- W.write<uint64_t>(InitAuxFileHdr.MaxStackSize.getValueOr(yaml::Hex64(0)));
- W.write<uint64_t>(InitAuxFileHdr.MaxDataSize.getValueOr(yaml::Hex64(0)));
+ InitAuxFileHdr.FlagAndTDataAlignment.value_or(yaml::Hex8(0x80)));
+ W.write<uint64_t>(InitAuxFileHdr.TextSize.value_or(yaml::Hex64(0)));
+ W.write<uint64_t>(InitAuxFileHdr.InitDataSize.value_or(yaml::Hex64(0)));
+ W.write<uint64_t>(InitAuxFileHdr.BssDataSize.value_or(yaml::Hex64(0)));
+ W.write<uint64_t>(InitAuxFileHdr.EntryPointAddr.value_or(yaml::Hex64(0)));
+ W.write<uint64_t>(InitAuxFileHdr.MaxStackSize.value_or(yaml::Hex64(0)));
+ W.write<uint64_t>(InitAuxFileHdr.MaxDataSize.value_or(yaml::Hex64(0)));
} else {
- W.write<uint32_t>(InitAuxFileHdr.MaxStackSize.getValueOr(yaml::Hex64(0)));
- W.write<uint32_t>(InitAuxFileHdr.MaxDataSize.getValueOr(yaml::Hex64(0)));
+ W.write<uint32_t>(InitAuxFileHdr.MaxStackSize.value_or(yaml::Hex64(0)));
+ W.write<uint32_t>(InitAuxFileHdr.MaxDataSize.value_or(yaml::Hex64(0)));
W.OS.write_zeros(4); // Reserved for debugger.
- W.write<uint8_t>(InitAuxFileHdr.TextPageSize.getValueOr(yaml::Hex8(0)));
- W.write<uint8_t>(InitAuxFileHdr.DataPageSize.getValueOr(yaml::Hex8(0)));
- W.write<uint8_t>(InitAuxFileHdr.StackPageSize.getValueOr(yaml::Hex8(0)));
+ W.write<uint8_t>(InitAuxFileHdr.TextPageSize.value_or(yaml::Hex8(0)));
+ W.write<uint8_t>(InitAuxFileHdr.DataPageSize.value_or(yaml::Hex8(0)));
+ W.write<uint8_t>(InitAuxFileHdr.StackPageSize.value_or(yaml::Hex8(0)));
W.write<uint8_t>(
- InitAuxFileHdr.FlagAndTDataAlignment.getValueOr(yaml::Hex8(0)));
+ InitAuxFileHdr.FlagAndTDataAlignment.value_or(yaml::Hex8(0)));
}
- W.write<uint16_t>(InitAuxFileHdr.SecNumOfTData.getValueOr(0));
- W.write<uint16_t>(InitAuxFileHdr.SecNumOfTBSS.getValueOr(0));
+ W.write<uint16_t>(InitAuxFileHdr.SecNumOfTData.value_or(0));
+ W.write<uint16_t>(InitAuxFileHdr.SecNumOfTBSS.value_or(0));
if (Is64Bit) {
- W.write<uint16_t>(InitAuxFileHdr.Flag.getValueOr(yaml::Hex16(XCOFF::SHR_SYMTAB)));
+ W.write<uint16_t>(
+ InitAuxFileHdr.Flag.value_or(yaml::Hex16(XCOFF::SHR_SYMTAB)));
if (InitFileHdr.AuxHeaderSize > XCOFF::AuxFileHeaderSize64)
W.OS.write_zeros(InitFileHdr.AuxHeaderSize - XCOFF::AuxFileHeaderSize64);
} else if (InitFileHdr.AuxHeaderSize > XCOFF::AuxFileHeaderSize32) {
@@ -526,52 +526,52 @@ bool XCOFFWriter::writeRelocations() {
void XCOFFWriter::writeAuxSymbol(const XCOFFYAML::CsectAuxEnt &AuxSym) {
if (Is64Bit) {
- W.write<uint32_t>(AuxSym.SectionOrLengthLo.getValueOr(0));
- W.write<uint32_t>(AuxSym.ParameterHashIndex.getValueOr(0));
- W.write<uint16_t>(AuxSym.TypeChkSectNum.getValueOr(0));
- W.write<uint8_t>(AuxSym.SymbolAlignmentAndType.getValueOr(0));
- W.write<uint8_t>(AuxSym.StorageMappingClass.getValueOr(XCOFF::XMC_PR));
- W.write<uint32_t>(AuxSym.SectionOrLengthHi.getValueOr(0));
+ W.write<uint32_t>(AuxSym.SectionOrLengthLo.value_or(0));
+ W.write<uint32_t>(AuxSym.ParameterHashIndex.value_or(0));
+ W.write<uint16_t>(AuxSym.TypeChkSectNum.value_or(0));
+ W.write<uint8_t>(AuxSym.SymbolAlignmentAndType.value_or(0));
+ W.write<uint8_t>(AuxSym.StorageMappingClass.value_or(XCOFF::XMC_PR));
+ W.write<uint32_t>(AuxSym.SectionOrLengthHi.value_or(0));
W.write<uint8_t>(0);
W.write<uint8_t>(XCOFF::AUX_CSECT);
} else {
- W.write<uint32_t>(AuxSym.SectionOrLength.getValueOr(0));
- W.write<uint32_t>(AuxSym.ParameterHashIndex.getValueOr(0));
- W.write<uint16_t>(AuxSym.TypeChkSectNum.getValueOr(0));
- W.write<uint8_t>(AuxSym.SymbolAlignmentAndType.getValueOr(0));
- W.write<uint8_t>(AuxSym.StorageMappingClass.getValueOr(XCOFF::XMC_PR));
- W.write<uint32_t>(AuxSym.StabInfoIndex.getValueOr(0));
- W.write<uint16_t>(AuxSym.StabSectNum.getValueOr(0));
+ W.write<uint32_t>(AuxSym.SectionOrLength.value_or(0));
+ W.write<uint32_t>(AuxSym.ParameterHashIndex.value_or(0));
+ W.write<uint16_t>(AuxSym.TypeChkSectNum.value_or(0));
+ W.write<uint8_t>(AuxSym.SymbolAlignmentAndType.value_or(0));
+ W.write<uint8_t>(AuxSym.StorageMappingClass.value_or(XCOFF::XMC_PR));
+ W.write<uint32_t>(AuxSym.StabInfoIndex.value_or(0));
+ W.write<uint16_t>(AuxSym.StabSectNum.value_or(0));
}
}
void XCOFFWriter::writeAuxSymbol(const XCOFFYAML::ExcpetionAuxEnt &AuxSym) {
assert(Is64Bit && "can't write the exception auxiliary symbol for XCOFF32");
- W.write<uint64_t>(AuxSym.OffsetToExceptionTbl.getValueOr(0));
- W.write<uint32_t>(AuxSym.SizeOfFunction.getValueOr(0));
- W.write<uint32_t>(AuxSym.SymIdxOfNextBeyond.getValueOr(0));
+ W.write<uint64_t>(AuxSym.OffsetToExceptionTbl.value_or(0));
+ W.write<uint32_t>(AuxSym.SizeOfFunction.value_or(0));
+ W.write<uint32_t>(AuxSym.SymIdxOfNextBeyond.value_or(0));
W.write<uint8_t>(0);
W.write<uint8_t>(XCOFF::AUX_EXCEPT);
}
void XCOFFWriter::writeAuxSymbol(const XCOFFYAML::FunctionAuxEnt &AuxSym) {
if (Is64Bit) {
- W.write<uint64_t>(AuxSym.PtrToLineNum.getValueOr(0));
- W.write<uint32_t>(AuxSym.SizeOfFunction.getValueOr(0));
- W.write<uint32_t>(AuxSym.SymIdxOfNextBeyond.getValueOr(0));
+ W.write<uint64_t>(AuxSym.PtrToLineNum.value_or(0));
+ W.write<uint32_t>(AuxSym.SizeOfFunction.value_or(0));
+ W.write<uint32_t>(AuxSym.SymIdxOfNextBeyond.value_or(0));
W.write<uint8_t>(0);
W.write<uint8_t>(XCOFF::AUX_FCN);
} else {
- W.write<uint32_t>(AuxSym.OffsetToExceptionTbl.getValueOr(0));
- W.write<uint32_t>(AuxSym.SizeOfFunction.getValueOr(0));
- W.write<uint32_t>(AuxSym.PtrToLineNum.getValueOr(0));
- W.write<uint32_t>(AuxSym.SymIdxOfNextBeyond.getValueOr(0));
+ W.write<uint32_t>(AuxSym.OffsetToExceptionTbl.value_or(0));
+ W.write<uint32_t>(AuxSym.SizeOfFunction.value_or(0));
+ W.write<uint32_t>(AuxSym.PtrToLineNum.value_or(0));
+ W.write<uint32_t>(AuxSym.SymIdxOfNextBeyond.value_or(0));
W.OS.write_zeros(2);
}
}
void XCOFFWriter::writeAuxSymbol(const XCOFFYAML::FileAuxEnt &AuxSym) {
- StringRef FileName = AuxSym.FileNameOrString.getValueOr("");
+ StringRef FileName = AuxSym.FileNameOrString.value_or("");
if (nameShouldBeInStringTable(FileName)) {
W.write<int32_t>(0);
W.write<uint32_t>(StrTblBuilder.getOffset(FileName));
@@ -579,7 +579,7 @@ void XCOFFWriter::writeAuxSymbol(const XCOFFYAML::FileAuxEnt &AuxSym) {
writeName(FileName, W);
}
W.OS.write_zeros(XCOFF::FileNamePadSize);
- W.write<uint8_t>(AuxSym.FileStringType.getValueOr(XCOFF::XFT_FN));
+ W.write<uint8_t>(AuxSym.FileStringType.value_or(XCOFF::XFT_FN));
if (Is64Bit) {
W.OS.write_zeros(2);
W.write<uint8_t>(XCOFF::AUX_FILE);
@@ -590,36 +590,36 @@ void XCOFFWriter::writeAuxSymbol(const XCOFFYAML::FileAuxEnt &AuxSym) {
void XCOFFWriter::writeAuxSymbol(const XCOFFYAML::BlockAuxEnt &AuxSym) {
if (Is64Bit) {
- W.write<uint32_t>(AuxSym.LineNum.getValueOr(0));
+ W.write<uint32_t>(AuxSym.LineNum.value_or(0));
W.OS.write_zeros(13);
W.write<uint8_t>(XCOFF::AUX_SYM);
} else {
W.OS.write_zeros(2);
- W.write<uint16_t>(AuxSym.LineNumHi.getValueOr(0));
- W.write<uint16_t>(AuxSym.LineNumLo.getValueOr(0));
+ W.write<uint16_t>(AuxSym.LineNumHi.value_or(0));
+ W.write<uint16_t>(AuxSym.LineNumLo.value_or(0));
W.OS.write_zeros(12);
}
}
void XCOFFWriter::writeAuxSymbol(const XCOFFYAML::SectAuxEntForDWARF &AuxSym) {
if (Is64Bit) {
- W.write<uint64_t>(AuxSym.LengthOfSectionPortion.getValueOr(0));
- W.write<uint64_t>(AuxSym.NumberOfRelocEnt.getValueOr(0));
+ W.write<uint64_t>(AuxSym.LengthOfSectionPortion.value_or(0));
+ W.write<uint64_t>(AuxSym.NumberOfRelocEnt.value_or(0));
W.write<uint8_t>(0);
W.write<uint8_t>(XCOFF::AUX_SECT);
} else {
- W.write<uint32_t>(AuxSym.LengthOfSectionPortion.getValueOr(0));
+ W.write<uint32_t>(AuxSym.LengthOfSectionPortion.value_or(0));
W.OS.write_zeros(4);
- W.write<uint32_t>(AuxSym.NumberOfRelocEnt.getValueOr(0));
+ W.write<uint32_t>(AuxSym.NumberOfRelocEnt.value_or(0));
W.OS.write_zeros(6);
}
}
void XCOFFWriter::writeAuxSymbol(const XCOFFYAML::SectAuxEntForStat &AuxSym) {
assert(!Is64Bit && "can't write the stat auxiliary symbol for XCOFF64");
- W.write<uint32_t>(AuxSym.SectionLength.getValueOr(0));
- W.write<uint16_t>(AuxSym.NumberOfRelocEnt.getValueOr(0));
- W.write<uint16_t>(AuxSym.NumberOfLineNum.getValueOr(0));
+ W.write<uint32_t>(AuxSym.SectionLength.value_or(0));
+ W.write<uint16_t>(AuxSym.NumberOfRelocEnt.value_or(0));
+ W.write<uint16_t>(AuxSym.NumberOfLineNum.value_or(0));
W.OS.write_zeros(10);
}
@@ -686,7 +686,7 @@ bool XCOFFWriter::writeSymbols() {
W.write<uint16_t>(YamlSym.Type);
W.write<uint8_t>(YamlSym.StorageClass);
- uint8_t NumOfAuxSym = YamlSym.NumberOfAuxEntries.getValueOr(0);
+ uint8_t NumOfAuxSym = YamlSym.NumberOfAuxEntries.value_or(0);
W.write<uint8_t>(NumOfAuxSym);
if (!NumOfAuxSym && !YamlSym.AuxEntries.size())
diff --git a/llvm/lib/ProfileData/InstrProfCorrelator.cpp b/llvm/lib/ProfileData/InstrProfCorrelator.cpp
index 0fed6adf8b08..4b8212c546f7 100644
--- a/llvm/lib/ProfileData/InstrProfCorrelator.cpp
+++ b/llvm/lib/ProfileData/InstrProfCorrelator.cpp
@@ -284,7 +284,7 @@ void DwarfInstrProfCorrelator<IntPtrT>::correlateProfileDataImpl() {
LLVM_DEBUG(Die.dump(dbgs()));
}
this->addProbe(*FunctionName, *CFGHash, *CounterPtr - CountersStart,
- FunctionPtr.getValueOr(0), *NumCounters);
+ FunctionPtr.value_or(0), *NumCounters);
};
for (auto &CU : DICtx->normal_units())
for (const auto &Entry : CU->dies())
diff --git a/llvm/lib/Support/NativeFormatting.cpp b/llvm/lib/Support/NativeFormatting.cpp
index fa417be95fb7..95971321c194 100644
--- a/llvm/lib/Support/NativeFormatting.cpp
+++ b/llvm/lib/Support/NativeFormatting.cpp
@@ -133,7 +133,7 @@ void llvm::write_hex(raw_ostream &S, uint64_t N, HexPrintStyle Style,
Optional<size_t> Width) {
const size_t kMaxWidth = 128u;
- size_t W = std::min(kMaxWidth, Width.getValueOr(0u));
+ size_t W = std::min(kMaxWidth, Width.value_or(0u));
unsigned Nibbles = (64 - countLeadingZeros(N) + 3) / 4;
bool Prefix = (Style == HexPrintStyle::PrefixLower ||
@@ -161,7 +161,7 @@ void llvm::write_hex(raw_ostream &S, uint64_t N, HexPrintStyle Style,
void llvm::write_double(raw_ostream &S, double N, FloatStyle Style,
Optional<size_t> Precision) {
- size_t Prec = Precision.getValueOr(getDefaultPrecision(Style));
+ size_t Prec = Precision.value_or(getDefaultPrecision(Style));
if (std::isnan(N)) {
S << "nan";
diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp
index c9273f00ad73..d94554bc1be9 100644
--- a/llvm/lib/Support/VirtualFileSystem.cpp
+++ b/llvm/lib/Support/VirtualFileSystem.cpp
@@ -806,10 +806,10 @@ bool InMemoryFileSystem::addFile(const Twine &P, time_t ModificationTime,
detail::InMemoryDirectory *Dir = Root.get();
auto I = llvm::sys::path::begin(Path), E = sys::path::end(Path);
- const auto ResolvedUser = User.getValueOr(0);
- const auto ResolvedGroup = Group.getValueOr(0);
- const auto ResolvedType = Type.getValueOr(sys::fs::file_type::regular_file);
- const auto ResolvedPerms = Perms.getValueOr(sys::fs::all_all);
+ const auto ResolvedUser = User.value_or(0);
+ const auto ResolvedGroup = Group.value_or(0);
+ const auto ResolvedType = Type.value_or(sys::fs::file_type::regular_file);
+ const auto ResolvedPerms = Perms.value_or(sys::fs::all_all);
// Any intermediate directories we create should be accessible by
// the owner, even if Perms says otherwise for the final path.
const auto NewDirectoryPerms = ResolvedPerms | sys::fs::owner_all;
diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
index 7636f3d07ea7..77135de1d3f3 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
@@ -7324,7 +7324,7 @@ bool AArch64InstrInfo::isFunctionSafeToOutlineFrom(
// modify the stack. Check if hasRedZone is true or unknown; if yes, don't
// outline from it.
AArch64FunctionInfo *AFI = MF.getInfo<AArch64FunctionInfo>();
- if (!AFI || AFI->hasRedZone().getValueOr(true))
+ if (!AFI || AFI->hasRedZone().value_or(true))
return false;
// FIXME: Teach the outliner to generate/handle Windows unwind info.
diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
index e9cea25f63a2..e9057dcfd832 100644
--- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
@@ -2760,8 +2760,8 @@ AArch64AsmParser::tryParsePrefetch(OperandVector &Operands) {
}
auto PRFM = LookupByEncoding(MCE->getValue());
- Operands.push_back(AArch64Operand::CreatePrefetch(
- prfop, PRFM.getValueOr(""), S, getContext()));
+ Operands.push_back(AArch64Operand::CreatePrefetch(prfop, PRFM.value_or(""),
+ S, getContext()));
return MatchOperand_Success;
}
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
index 8f9aa9d7e286..938ac1124f8c 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
@@ -332,7 +332,7 @@ void AMDGPUAsmPrinter::emitGlobalVariable(const GlobalVariable *GV) {
const DataLayout &DL = GV->getParent()->getDataLayout();
uint64_t Size = DL.getTypeAllocSize(GV->getValueType());
- Align Alignment = GV->getAlign().getValueOr(Align(4));
+ Align Alignment = GV->getAlign().value_or(Align(4));
emitVisibility(GVSym, GV->getVisibility(), !GV->isDeclaration());
emitLinkage(GV, GVSym);
diff --git a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
index f02e7fb19558..bda3c25e956b 100644
--- a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
+++ b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
@@ -263,5 +263,5 @@ MCAsmBackend *llvm::createAMDGPUAsmBackend(const Target &T,
const MCRegisterInfo &MRI,
const MCTargetOptions &Options) {
return new ELFAMDGPUAsmBackend(T, STI.getTargetTriple(),
- getHsaAbiVersion(&STI).getValueOr(0));
+ getHsaAbiVersion(&STI).value_or(0));
}
diff --git a/llvm/lib/Target/ARC/ARCTargetMachine.cpp b/llvm/lib/Target/ARC/ARCTargetMachine.cpp
index e145beabb0ea..21757927d873 100644
--- a/llvm/lib/Target/ARC/ARCTargetMachine.cpp
+++ b/llvm/lib/Target/ARC/ARCTargetMachine.cpp
@@ -21,7 +21,7 @@
using namespace llvm;
static Reloc::Model getRelocModel(Optional<Reloc::Model> RM) {
- return RM.getValueOr(Reloc::Static);
+ return RM.value_or(Reloc::Static);
}
/// ARCTargetMachine ctor - Create an ILP32 architecture model
diff --git a/llvm/lib/Target/AVR/AVRTargetMachine.cpp b/llvm/lib/Target/AVR/AVRTargetMachine.cpp
index c8be3f150662..b9d77e0d1a51 100644
--- a/llvm/lib/Target/AVR/AVRTargetMachine.cpp
+++ b/llvm/lib/Target/AVR/AVRTargetMachine.cpp
@@ -38,7 +38,7 @@ static StringRef getCPU(StringRef CPU) {
}
static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) {
- return RM.getValueOr(Reloc::Static);
+ return RM.value_or(Reloc::Static);
}
AVRTargetMachine::AVRTargetMachine(const Target &T, const Triple &TT,
diff --git a/llvm/lib/Target/BPF/BPFTargetMachine.cpp b/llvm/lib/Target/BPF/BPFTargetMachine.cpp
index ba0924df004d..97d9ed3cad47 100644
--- a/llvm/lib/Target/BPF/BPFTargetMachine.cpp
+++ b/llvm/lib/Target/BPF/BPFTargetMachine.cpp
@@ -59,7 +59,7 @@ static std::string computeDataLayout(const Triple &TT) {
}
static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) {
- return RM.getValueOr(Reloc::PIC_);
+ return RM.value_or(Reloc::PIC_);
}
BPFTargetMachine::BPFTargetMachine(const Target &T, const Triple &TT,
diff --git a/llvm/lib/Target/CSKY/CSKYTargetMachine.cpp b/llvm/lib/Target/CSKY/CSKYTargetMachine.cpp
index baba29b62324..d19f28fddd53 100644
--- a/llvm/lib/Target/CSKY/CSKYTargetMachine.cpp
+++ b/llvm/lib/Target/CSKY/CSKYTargetMachine.cpp
@@ -52,7 +52,7 @@ CSKYTargetMachine::CSKYTargetMachine(const Target &T, const Triple &TT,
Optional<CodeModel::Model> CM,
CodeGenOpt::Level OL, bool JIT)
: LLVMTargetMachine(T, computeDataLayout(TT), TT, CPU, FS, Options,
- RM.getValueOr(Reloc::Static),
+ RM.value_or(Reloc::Static),
getEffectiveCodeModel(CM, CodeModel::Small), OL),
TLOF(std::make_unique<CSKYELFTargetObjectFile>()) {
initAsmInfo();
diff --git a/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp b/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp
index e587dd53c62a..634ead98a6ae 100644
--- a/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp
+++ b/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp
@@ -44,7 +44,7 @@ static void emitDXILValidatorVersion(Module &M, VersionTuple &ValidatorVer) {
auto &Ctx = M.getContext();
Metadata *MDVals[DXILVersionNumFields];
MDVals[0] = Uint32ToConstMD(ValidatorVer.getMajor(), Ctx);
- MDVals[1] = Uint32ToConstMD(ValidatorVer.getMinor().getValueOr(0), Ctx);
+ MDVals[1] = Uint32ToConstMD(ValidatorVer.getMinor().value_or(0), Ctx);
DXILValidatorVersionMD->addOperand(MDNode::get(Ctx, MDVals));
}
diff --git a/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp b/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp
index e4d9602f4c4a..4e04939e6690 100644
--- a/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp
@@ -194,7 +194,7 @@ namespace llvm {
} // end namespace llvm;
static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) {
- return RM.getValueOr(Reloc::Static);
+ return RM.value_or(Reloc::Static);
}
extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeHexagonTarget() {
diff --git a/llvm/lib/Target/Lanai/LanaiTargetMachine.cpp b/llvm/lib/Target/Lanai/LanaiTargetMachine.cpp
index e874c5b1c5d7..8af40d18d106 100644
--- a/llvm/lib/Target/Lanai/LanaiTargetMachine.cpp
+++ b/llvm/lib/Target/Lanai/LanaiTargetMachine.cpp
@@ -48,7 +48,7 @@ static std::string computeDataLayout() {
}
static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) {
- return RM.getValueOr(Reloc::PIC_);
+ return RM.value_or(Reloc::PIC_);
}
LanaiTargetMachine::LanaiTargetMachine(const Target &T, const Triple &TT,
diff --git a/llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp b/llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp
index 0a19455e0c1d..53812d7552a9 100644
--- a/llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp
@@ -373,7 +373,7 @@ void NVPTXLowerArgs::handleByValParam(Argument *Arg) {
// later load/stores assume that alignment, and we are going to replace
// the use of the byval parameter with this alloca instruction.
AllocA->setAlignment(Func->getParamAlign(Arg->getArgNo())
- .getValueOr(DL.getPrefTypeAlign(StructType)));
+ .value_or(DL.getPrefTypeAlign(StructType)));
Arg->replaceAllUsesWith(AllocA);
Value *ArgInParam = new AddrSpaceCastInst(
diff --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
index 0ac698850873..22f35c8fa8d3 100644
--- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -2407,7 +2407,7 @@ void PPCAIXAsmPrinter::emitGlobalVariableHelper(const GlobalVariable *GV) {
// Handle common and zero-initialized local symbols.
if (GV->hasCommonLinkage() || GVKind.isBSSLocal() ||
GVKind.isThreadBSSLocal()) {
- Align Alignment = GV->getAlign().getValueOr(DL.getPreferredAlign(GV));
+ Align Alignment = GV->getAlign().value_or(DL.getPreferredAlign(GV));
uint64_t Size = DL.getTypeAllocSize(GV->getValueType());
GVSym->setStorageClass(
TargetLoweringObjectFileXCOFF::getStorageClassForGlobal(GV));
diff --git a/llvm/lib/Target/Sparc/SparcTargetMachine.cpp b/llvm/lib/Target/Sparc/SparcTargetMachine.cpp
index 3212d612eb15..8bd51a703d47 100644
--- a/llvm/lib/Target/Sparc/SparcTargetMachine.cpp
+++ b/llvm/lib/Target/Sparc/SparcTargetMachine.cpp
@@ -55,7 +55,7 @@ static std::string computeDataLayout(const Triple &T, bool is64Bit) {
}
static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) {
- return RM.getValueOr(Reloc::Static);
+ return RM.value_or(Reloc::Static);
}
// Code models. Some only make sense for 64-bit code.
diff --git a/llvm/lib/Target/VE/VECustomDAG.cpp b/llvm/lib/Target/VE/VECustomDAG.cpp
index 8fa0a506100a..8f11eba6d5fd 100644
--- a/llvm/lib/Target/VE/VECustomDAG.cpp
+++ b/llvm/lib/Target/VE/VECustomDAG.cpp
@@ -84,7 +84,7 @@ Optional<unsigned> getVVPOpcode(unsigned Opcode) {
bool maySafelyIgnoreMask(SDValue Op) {
auto VVPOpc = getVVPOpcode(Op->getOpcode());
- auto Opc = VVPOpc.getValueOr(Op->getOpcode());
+ auto Opc = VVPOpc.value_or(Op->getOpcode());
switch (Opc) {
case VEISD::VVP_SDIV:
diff --git a/llvm/lib/Target/VE/VETargetMachine.cpp b/llvm/lib/Target/VE/VETargetMachine.cpp
index 21cc68ad3b1b..d7c1457fb0a8 100644
--- a/llvm/lib/Target/VE/VETargetMachine.cpp
+++ b/llvm/lib/Target/VE/VETargetMachine.cpp
@@ -61,7 +61,7 @@ static std::string computeDataLayout(const Triple &T) {
}
static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) {
- return RM.getValueOr(Reloc::Static);
+ return RM.value_or(Reloc::Static);
}
class VEELFTargetObjectFile : public TargetLoweringObjectFileELF {
diff --git a/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmTypeCheck.cpp b/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmTypeCheck.cpp
index 84dc19f636bf..61097e115a1c 100644
--- a/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmTypeCheck.cpp
+++ b/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmTypeCheck.cpp
@@ -173,7 +173,7 @@ bool WebAssemblyAsmTypeCheck::getGlobal(SMLoc ErrorLoc, const MCInst &Inst,
if (getSymRef(ErrorLoc, Inst, SymRef))
return true;
auto WasmSym = cast<MCSymbolWasm>(&SymRef->getSymbol());
- switch (WasmSym->getType().getValueOr(wasm::WASM_SYMBOL_TYPE_DATA)) {
+ switch (WasmSym->getType().value_or(wasm::WASM_SYMBOL_TYPE_DATA)) {
case wasm::WASM_SYMBOL_TYPE_GLOBAL:
Type = static_cast<wasm::ValType>(WasmSym->getGlobalType().Type);
break;
@@ -201,7 +201,7 @@ bool WebAssemblyAsmTypeCheck::getTable(SMLoc ErrorLoc, const MCInst &Inst,
if (getSymRef(ErrorLoc, Inst, SymRef))
return true;
auto WasmSym = cast<MCSymbolWasm>(&SymRef->getSymbol());
- if (WasmSym->getType().getValueOr(wasm::WASM_SYMBOL_TYPE_DATA) !=
+ if (WasmSym->getType().value_or(wasm::WASM_SYMBOL_TYPE_DATA) !=
wasm::WASM_SYMBOL_TYPE_TABLE)
return typeError(ErrorLoc, StringRef("symbol ") + WasmSym->getName() +
" missing .tabletype");
diff --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
index 9e0f88717227..f88037e95d33 100644
--- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
+++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
@@ -3499,7 +3499,7 @@ bool X86DAGToDAGISel::matchBitExtract(SDNode *Node) {
const bool AllowExtraUsesByDefault = Subtarget->hasBMI2();
auto checkUses = [AllowExtraUsesByDefault](SDValue Op, unsigned NUses,
Optional<bool> AllowExtraUses) {
- return AllowExtraUses.getValueOr(AllowExtraUsesByDefault) ||
+ return AllowExtraUses.value_or(AllowExtraUsesByDefault) ||
Op.getNode()->hasNUsesOfValue(NUses, Op.getResNo());
};
auto checkOneUse = [checkUses](SDValue Op,
diff --git a/llvm/lib/Target/XCore/XCoreTargetMachine.cpp b/llvm/lib/Target/XCore/XCoreTargetMachine.cpp
index ef0473fa578c..3c27fcd9ba53 100644
--- a/llvm/lib/Target/XCore/XCoreTargetMachine.cpp
+++ b/llvm/lib/Target/XCore/XCoreTargetMachine.cpp
@@ -26,7 +26,7 @@
using namespace llvm;
static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) {
- return RM.getValueOr(Reloc::Static);
+ return RM.value_or(Reloc::Static);
}
static CodeModel::Model
diff --git a/llvm/lib/Testing/Support/Annotations.cpp b/llvm/lib/Testing/Support/Annotations.cpp
index 44d3acccfdb2..557b6cdf98ce 100644
--- a/llvm/lib/Testing/Support/Annotations.cpp
+++ b/llvm/lib/Testing/Support/Annotations.cpp
@@ -33,12 +33,12 @@ Annotations::Annotations(llvm::StringRef Text) {
Code.reserve(Text.size());
while (!Text.empty()) {
if (Text.consume_front("^")) {
- Points[Name.getValueOr("")].push_back(Code.size());
+ Points[Name.value_or("")].push_back(Code.size());
Name = llvm::None;
continue;
}
if (Text.consume_front("[[")) {
- OpenRanges.emplace_back(Name.getValueOr(""), Code.size());
+ OpenRanges.emplace_back(Name.value_or(""), Code.size());
Name = llvm::None;
continue;
}
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index 0c23a8b20ed6..da309dce25d4 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -1642,7 +1642,7 @@ void Attributor::runTillFixpoint() {
unsigned IterationCounter = 1;
unsigned MaxIterations =
- Configuration.MaxFixpointIterations.getValueOr(SetFixpointIterations);
+ Configuration.MaxFixpointIterations.value_or(SetFixpointIterations);
SmallVector<AbstractAttribute *, 32> ChangedAAs;
SetVector<AbstractAttribute *> Worklist, InvalidAAs;
diff --git a/llvm/lib/Transforms/IPO/ConstantMerge.cpp b/llvm/lib/Transforms/IPO/ConstantMerge.cpp
index 178d3f41963e..73af30ece47c 100644
--- a/llvm/lib/Transforms/IPO/ConstantMerge.cpp
+++ b/llvm/lib/Transforms/IPO/ConstantMerge.cpp
@@ -85,7 +85,7 @@ static void copyDebugLocMetadata(const GlobalVariable *From,
}
static Align getAlign(GlobalVariable *GV) {
- return GV->getAlign().getValueOr(
+ return GV->getAlign().value_or(
GV->getParent()->getDataLayout().getPreferredAlign(GV));
}
diff --git a/llvm/lib/Transforms/IPO/IROutliner.cpp b/llvm/lib/Transforms/IPO/IROutliner.cpp
index 280474a14e74..d30bd097349f 100644
--- a/llvm/lib/Transforms/IPO/IROutliner.cpp
+++ b/llvm/lib/Transforms/IPO/IROutliner.cpp
@@ -186,7 +186,7 @@ Value *OutlinableRegion::findCorrespondingValueIn(const OutlinableRegion &Other,
Optional<unsigned> CanonNum = Candidate->getCanonicalNum(*GVN);
Optional<unsigned> FirstGVN = Other.Candidate->fromCanonicalNum(*CanonNum);
Optional<Value *> FoundValueOpt = Other.Candidate->fromGVN(*FirstGVN);
- return FoundValueOpt.getValueOr(nullptr);
+ return FoundValueOpt.value_or(nullptr);
}
BasicBlock *
diff --git a/llvm/lib/Transforms/IPO/Inliner.cpp b/llvm/lib/Transforms/IPO/Inliner.cpp
index b30d9696ab24..3ac06c22cba1 100644
--- a/llvm/lib/Transforms/IPO/Inliner.cpp
+++ b/llvm/lib/Transforms/IPO/Inliner.cpp
@@ -904,7 +904,7 @@ PreservedAnalyses InlinerPass::run(LazyCallGraph::SCC &InitialC,
int CBCostMult =
getStringFnAttrAsInt(
*CB, InlineConstants::FunctionInlineCostMultiplierAttributeName)
- .getValueOr(1);
+ .value_or(1);
// Setup the data structure used to plumb customization into the
// `InlineFunction` routine.
diff --git a/llvm/lib/Transforms/IPO/PartialInlining.cpp b/llvm/lib/Transforms/IPO/PartialInlining.cpp
index bf7dd0981480..54c72bdbb203 100644
--- a/llvm/lib/Transforms/IPO/PartialInlining.cpp
+++ b/llvm/lib/Transforms/IPO/PartialInlining.cpp
@@ -438,7 +438,7 @@ PartialInlinerImpl::computeOutliningColdRegionsInfo(
};
auto BBProfileCount = [BFI](BasicBlock *BB) {
- return BFI->getBlockProfileCount(BB).getValueOr(0);
+ return BFI->getBlockProfileCount(BB).value_or(0);
};
// Use the same computeBBInlineCost function to compute the cost savings of
diff --git a/llvm/lib/Transforms/IPO/SampleProfileProbe.cpp b/llvm/lib/Transforms/IPO/SampleProfileProbe.cpp
index d457ef853e30..d1ab2649ee2e 100644
--- a/llvm/lib/Transforms/IPO/SampleProfileProbe.cpp
+++ b/llvm/lib/Transforms/IPO/SampleProfileProbe.cpp
@@ -414,7 +414,7 @@ void PseudoProbeUpdatePass::runOnFunction(Function &F,
FunctionAnalysisManager &FAM) {
BlockFrequencyInfo &BFI = FAM.getResult<BlockFrequencyAnalysis>(F);
auto BBProfileCount = [&BFI](BasicBlock *BB) {
- return BFI.getBlockProfileCount(BB).getValueOr(0);
+ return BFI.getBlockProfileCount(BB).value_or(0);
};
// Collect the sum of execution weight for each probe.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
index de42188a441a..22659a8e4951 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -878,7 +878,7 @@ Instruction *InstCombinerImpl::foldAggregateConstructionIntoAggregateReuse(
// of an aggregate. If we did, that means the CurrIVI will later be
// overwritten with the already-recorded value. But if not, let's record it!
Optional<Instruction *> &Elt = AggElts[Indices.front()];
- Elt = Elt.getValueOr(InsertedValue);
+ Elt = Elt.value_or(InsertedValue);
// FIXME: should we handle chain-terminating undef base operand?
}
diff --git a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
index 995809ea89ba..e5c0705b916e 100644
--- a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
+++ b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
@@ -1765,7 +1765,7 @@ void CHR::transformScopes(CHRScope *Scope, DenseSet<PHINode *> &TrivialPHIs) {
// Create the combined branch condition and constant-fold the branches/selects
// in the hot path.
fixupBranchesAndSelects(Scope, PreEntryBlock, MergedBr,
- ProfileCount.getValueOr(0));
+ ProfileCount.value_or(0));
}
// A helper for transformScopes. Clone the blocks in the scope (excluding the
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp
index 58896ca5d093..888ca69e69b8 100644
--- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -693,24 +693,24 @@ void GVNPass::ValueTable::verifyRemoved(const Value *V) const {
//===----------------------------------------------------------------------===//
bool GVNPass::isPREEnabled() const {
- return Options.AllowPRE.getValueOr(GVNEnablePRE);
+ return Options.AllowPRE.value_or(GVNEnablePRE);
}
bool GVNPass::isLoadPREEnabled() const {
- return Options.AllowLoadPRE.getValueOr(GVNEnableLoadPRE);
+ return Options.AllowLoadPRE.value_or(GVNEnableLoadPRE);
}
bool GVNPass::isLoadInLoopPREEnabled() const {
- return Options.AllowLoadInLoopPRE.getValueOr(GVNEnableLoadInLoopPRE);
+ return Options.AllowLoadInLoopPRE.value_or(GVNEnableLoadInLoopPRE);
}
bool GVNPass::isLoadPRESplitBackedgeEnabled() const {
- return Options.AllowLoadPRESplitBackedge.getValueOr(
+ return Options.AllowLoadPRESplitBackedge.value_or(
GVNEnableSplitBackedgeInLoadPRE);
}
bool GVNPass::isMemDepEnabled() const {
- return Options.AllowMemDep.getValueOr(GVNEnableMemDep);
+ return Options.AllowMemDep.value_or(GVNEnableMemDep);
}
PreservedAnalyses GVNPass::run(Function &F, FunctionAnalysisManager &AM) {
diff --git a/llvm/lib/Transforms/Scalar/LoopDistribute.cpp b/llvm/lib/Transforms/Scalar/LoopDistribute.cpp
index 1141fc91e706..f606e9b7a484 100644
--- a/llvm/lib/Transforms/Scalar/LoopDistribute.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopDistribute.cpp
@@ -775,13 +775,13 @@ class LoopDistributeForLoop {
"may not insert runtime check with convergent operation");
}
- if (Pred.getComplexity() > (IsForced.getValueOr(false)
+ if (Pred.getComplexity() > (IsForced.value_or(false)
? PragmaDistributeSCEVCheckThreshold
: DistributeSCEVCheckThreshold))
return fail("TooManySCEVRuntimeChecks",
"too many SCEV run-time checks needed.\n");
- if (!IsForced.getValueOr(false) && hasDisableAllTransformsHint(L))
+ if (!IsForced.value_or(false) && hasDisableAllTransformsHint(L))
return fail("HeuristicDisabled", "distribution heuristic disabled");
LLVM_DEBUG(dbgs() << "\nDistributing loop: " << *L << "\n");
@@ -858,7 +858,7 @@ class LoopDistributeForLoop {
/// Provide diagnostics then \return with false.
bool fail(StringRef RemarkName, StringRef Message) {
LLVMContext &Ctx = F->getContext();
- bool Forced = isForced().getValueOr(false);
+ bool Forced = isForced().value_or(false);
LLVM_DEBUG(dbgs() << "Skipping; " << Message << "\n");
@@ -990,7 +990,7 @@ static bool runImpl(Function &F, LoopInfo *LI, DominatorTree *DT,
// If distribution was forced for the specific loop to be
// enabled/disabled, follow that. Otherwise use the global flag.
- if (LDL.isForced().getValueOr(EnableLoopDistribute))
+ if (LDL.isForced().value_or(EnableLoopDistribute))
Changed |= LDL.processLoop(GetLAA);
}
diff --git a/llvm/lib/Transforms/Scalar/Scalarizer.cpp b/llvm/lib/Transforms/Scalar/Scalarizer.cpp
index 344f89e8ded1..a7672a91de3a 100644
--- a/llvm/lib/Transforms/Scalar/Scalarizer.cpp
+++ b/llvm/lib/Transforms/Scalar/Scalarizer.cpp
@@ -190,7 +190,7 @@ template <typename T>
T getWithDefaultOverride(const cl::opt<T> &ClOption,
const llvm::Optional<T> &DefaultOverride) {
return ClOption.getNumOccurrences() ? ClOption
- : DefaultOverride.getValueOr(ClOption);
+ : DefaultOverride.value_or(ClOption);
}
class ScalarizerVisitor : public InstVisitor<ScalarizerVisitor, bool> {
diff --git a/llvm/lib/Transforms/Scalar/WarnMissedTransforms.cpp b/llvm/lib/Transforms/Scalar/WarnMissedTransforms.cpp
index 80a7d3a43ad6..8367e61c1a47 100644
--- a/llvm/lib/Transforms/Scalar/WarnMissedTransforms.cpp
+++ b/llvm/lib/Transforms/Scalar/WarnMissedTransforms.cpp
@@ -61,7 +61,7 @@ static void warnAboutLeftoverTransformations(Loop *L,
<< "loop not vectorized: the optimizer was unable to perform the "
"requested transformation; the transformation might be disabled "
"or specified as part of an unsupported transformation ordering");
- else if (InterleaveCount.getValueOr(0) != 1)
+ else if (InterleaveCount.value_or(0) != 1)
ORE->emit(
DiagnosticInfoOptimizationFailure(DEBUG_TYPE,
"FailedRequestedInterleaving",
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index c4123906aa8d..8f88ca24708f 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -1600,7 +1600,7 @@ static void updateCallProfile(Function *Callee, const ValueToValueMapTy &VMap,
return;
auto CallSiteCount = PSI ? PSI->getProfileCount(TheCall, CallerBFI) : None;
int64_t CallCount =
- std::min(CallSiteCount.getValueOr(0), CalleeEntryCount.getCount());
+ std::min(CallSiteCount.value_or(0), CalleeEntryCount.getCount());
updateProfileCallee(Callee, -CallCount, &VMap);
}
diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp
index 1310abbc126a..5d16a1e5239d 100644
--- a/llvm/lib/Transforms/Utils/LoopUtils.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp
@@ -257,7 +257,7 @@ llvm::getOptionalElementCountLoopAttribute(const Loop *TheLoop) {
if (Width.hasValue()) {
Optional<int> IsScalable = getOptionalIntLoopAttribute(
TheLoop, "llvm.loop.vectorize.scalable.enable");
- return ElementCount::get(*Width, IsScalable.getValueOr(false));
+ return ElementCount::get(*Width, IsScalable.value_or(false));
}
return None;
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index b1e187a9e843..8aac36c76c15 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -6799,14 +6799,14 @@ static bool areTwoInsertFromSameBuildVector(InsertElementInst *VU,
return V->hasOneUse();
if (IE1) {
if ((IE1 != VU && !IE1->hasOneUse()) ||
- getInsertIndex(IE1).getValueOr(Idx2) == Idx2)
+ getInsertIndex(IE1).value_or(Idx2) == Idx2)
IE1 = nullptr;
else
IE1 = dyn_cast<InsertElementInst>(IE1->getOperand(0));
}
if (IE2) {
if ((IE2 != V && !IE2->hasOneUse()) ||
- getInsertIndex(IE2).getValueOr(Idx1) == Idx1)
+ getInsertIndex(IE2).value_or(Idx1) == Idx1)
IE2 = nullptr;
else
IE2 = dyn_cast<InsertElementInst>(IE2->getOperand(0));
@@ -6835,10 +6835,10 @@ static bool isFirstInsertElement(const InsertElementInst *IE1,
PrevI1 = I1;
PrevI2 = I2;
if (I1 && (I1 == IE1 || I1->hasOneUse()) &&
- getInsertIndex(I1).getValueOr(Idx2) != Idx2)
+ getInsertIndex(I1).value_or(Idx2) != Idx2)
I1 = dyn_cast<InsertElementInst>(I1->getOperand(0));
if (I2 && ((I2 == IE2 || I2->hasOneUse())) &&
- getInsertIndex(I2).getValueOr(Idx1) != Idx1)
+ getInsertIndex(I2).value_or(Idx1) != Idx1)
I2 = dyn_cast<InsertElementInst>(I2->getOperand(0));
} while ((I1 && PrevI1 != I1) || (I2 && PrevI2 != I2));
llvm_unreachable("Two
diff erent buildvectors not expected.");
@@ -7030,7 +7030,7 @@ InstructionCost BoUpSLP::getTreeCost(ArrayRef<Value *> VectorizedVals) {
while (auto *IEBase = dyn_cast<InsertElementInst>(Base)) {
if (IEBase != EU.User &&
(!IEBase->hasOneUse() ||
- getInsertIndex(IEBase).getValueOr(*InsertIdx) == *InsertIdx))
+ getInsertIndex(IEBase).value_or(*InsertIdx) == *InsertIdx))
break;
// Build the mask for the vectorized insertelement instructions.
if (const TreeEntry *E = getTreeEntry(IEBase)) {
@@ -8495,7 +8495,7 @@ BoUpSLP::vectorizeTree(ExtraValueToDebugLocsMap &ExternallyUsedValues) {
while (auto *IEBase = dyn_cast<InsertElementInst>(Base)) {
if (IEBase != User &&
(!IEBase->hasOneUse() ||
- getInsertIndex(IEBase).getValueOr(Idx) == Idx))
+ getInsertIndex(IEBase).value_or(Idx) == Idx))
break;
// Build the mask for the vectorized insertelement instructions.
if (const TreeEntry *E = getTreeEntry(IEBase)) {
diff --git a/llvm/tools/llvm-mca/Views/InstructionInfoView.cpp b/llvm/tools/llvm-mca/Views/InstructionInfoView.cpp
index caa8554a416a..28915e5a2ae5 100644
--- a/llvm/tools/llvm-mca/Views/InstructionInfoView.cpp
+++ b/llvm/tools/llvm-mca/Views/InstructionInfoView.cpp
@@ -152,7 +152,7 @@ InstructionInfoView::toJSON(const InstructionInfoViewData &IIVD) const {
{"mayLoad", IIVD.mayLoad},
{"mayStore", IIVD.mayStore},
{"hasUnmodeledSideEffects", IIVD.hasUnmodeledSideEffects}});
- JO.try_emplace("RThroughput", IIVD.RThroughput.getValueOr(0.0));
+ JO.try_emplace("RThroughput", IIVD.RThroughput.value_or(0.0));
return JO;
}
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 615eb873c082..aa4b3f97fed4 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -1709,7 +1709,7 @@ static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
"no assembly info for target " + TripleName);
if (MCPU.empty())
- MCPU = Obj->tryGetCPUName().getValueOr("").str();
+ MCPU = Obj->tryGetCPUName().value_or("").str();
std::unique_ptr<const MCSubtargetInfo> STI(
TheTarget->createMCSubtargetInfo(TripleName, MCPU, Features.getString()));
diff --git a/llvm/tools/llvm-pdbutil/BytesOutputStyle.cpp b/llvm/tools/llvm-pdbutil/BytesOutputStyle.cpp
index eba3a4a3198e..584d83512036 100644
--- a/llvm/tools/llvm-pdbutil/BytesOutputStyle.cpp
+++ b/llvm/tools/llvm-pdbutil/BytesOutputStyle.cpp
@@ -89,7 +89,7 @@ Error BytesOutputStyle::dump() {
if (opts::bytes::DumpBlockRange.hasValue()) {
auto &R = *opts::bytes::DumpBlockRange;
- uint32_t Max = R.Max.getValueOr(R.Min);
+ uint32_t Max = R.Max.value_or(R.Min);
if (Max < R.Min)
return make_error<StringError>(
@@ -106,7 +106,7 @@ Error BytesOutputStyle::dump() {
if (opts::bytes::DumpByteRange.hasValue()) {
auto &R = *opts::bytes::DumpByteRange;
- uint32_t Max = R.Max.getValueOr(File.getFileSize());
+ uint32_t Max = R.Max.value_or(File.getFileSize());
if (Max < R.Min)
return make_error<StringError>("Invalid byte range specified. Max < Min",
diff --git a/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp b/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp
index 63fe97130bb9..1b367029c555 100644
--- a/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp
+++ b/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp
@@ -816,7 +816,7 @@ static void yamlToPdb(StringRef Path) {
pdb::yaml::PdbTpiStream DefaultTpiStream;
pdb::yaml::PdbTpiStream DefaultIpiStream;
- const auto &Info = YamlObj.PdbStream.getValueOr(DefaultInfoStream);
+ const auto &Info = YamlObj.PdbStream.value_or(DefaultInfoStream);
auto &InfoBuilder = Builder.getInfoBuilder();
InfoBuilder.setAge(Info.Age);
@@ -826,7 +826,7 @@ static void yamlToPdb(StringRef Path) {
for (auto F : Info.Features)
InfoBuilder.addFeature(F);
- const auto &Dbi = YamlObj.DbiStream.getValueOr(DefaultDbiStream);
+ const auto &Dbi = YamlObj.DbiStream.value_or(DefaultDbiStream);
auto &DbiBuilder = Builder.getDbiBuilder();
DbiBuilder.setAge(Dbi.Age);
DbiBuilder.setBuildNumber(Dbi.BuildNumber);
@@ -861,7 +861,7 @@ static void yamlToPdb(StringRef Path) {
}
auto &TpiBuilder = Builder.getTpiBuilder();
- const auto &Tpi = YamlObj.TpiStream.getValueOr(DefaultTpiStream);
+ const auto &Tpi = YamlObj.TpiStream.value_or(DefaultTpiStream);
TpiBuilder.setVersionHeader(Tpi.Version);
AppendingTypeTableBuilder TS(Allocator);
for (const auto &R : Tpi.Records) {
@@ -869,7 +869,7 @@ static void yamlToPdb(StringRef Path) {
TpiBuilder.addTypeRecord(Type.RecordData, None);
}
- const auto &Ipi = YamlObj.IpiStream.getValueOr(DefaultIpiStream);
+ const auto &Ipi = YamlObj.IpiStream.value_or(DefaultIpiStream);
auto &IpiBuilder = Builder.getIpiBuilder();
IpiBuilder.setVersionHeader(Ipi.Version);
for (const auto &R : Ipi.Records) {
diff --git a/llvm/tools/llvm-rc/ResourceFileWriter.cpp b/llvm/tools/llvm-rc/ResourceFileWriter.cpp
index 866232080575..c1b4921ac287 100644
--- a/llvm/tools/llvm-rc/ResourceFileWriter.cpp
+++ b/llvm/tools/llvm-rc/ResourceFileWriter.cpp
@@ -988,8 +988,8 @@ Error ResourceFileWriter::writeSingleDialogControl(const Control &Ctl,
auto TypeInfo = Control::SupportedCtls.lookup(Ctl.Type);
IntWithNotMask CtlStyle(TypeInfo.Style);
- CtlStyle |= Ctl.Style.getValueOr(RCInt(0));
- uint32_t CtlExtStyle = Ctl.ExtStyle.getValueOr(0);
+ CtlStyle |= Ctl.Style.value_or(RCInt(0));
+ uint32_t CtlExtStyle = Ctl.ExtStyle.value_or(0);
// DIALOG(EX) item header prefix.
if (!IsExtended) {
@@ -1003,7 +1003,7 @@ Error ResourceFileWriter::writeSingleDialogControl(const Control &Ctl,
ulittle32_t HelpID;
ulittle32_t ExtStyle;
ulittle32_t Style;
- } Prefix{ulittle32_t(Ctl.HelpID.getValueOr(0)), ulittle32_t(CtlExtStyle),
+ } Prefix{ulittle32_t(Ctl.HelpID.value_or(0)), ulittle32_t(CtlExtStyle),
ulittle32_t(CtlStyle.getValue())};
writeObject(Prefix);
}
@@ -1059,7 +1059,7 @@ Error ResourceFileWriter::writeDialogBody(const RCResource *Base) {
const uint32_t StyleFontFlag = 0x40;
const uint32_t StyleCaptionFlag = 0x00C00000;
- uint32_t UsedStyle = ObjectData.Style.getValueOr(DefaultStyle);
+ uint32_t UsedStyle = ObjectData.Style.value_or(DefaultStyle);
if (ObjectData.Font)
UsedStyle |= StyleFontFlag;
else
@@ -1071,7 +1071,7 @@ Error ResourceFileWriter::writeDialogBody(const RCResource *Base) {
UsedStyle |= StyleCaptionFlag;
const uint16_t DialogExMagic = 0xFFFF;
- uint32_t ExStyle = ObjectData.ExStyle.getValueOr(0);
+ uint32_t ExStyle = ObjectData.ExStyle.value_or(0);
// Write DIALOG(EX) header prefix. These are pretty
diff erent.
if (!Res->IsExtended) {
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index d0925a322e26..0597dd979daf 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -6087,9 +6087,8 @@ void ELFDumper<ELFT>::printStackSize(const Relocation<ELFT> &R,
return;
}
- uint64_t SymValue =
- Resolver(R.Type, Offset, RelocSymValue, Data.getAddress(&Offset),
- R.Addend.getValueOr(0));
+ uint64_t SymValue = Resolver(R.Type, Offset, RelocSymValue,
+ Data.getAddress(&Offset), R.Addend.value_or(0));
this->printFunctionStackSize(SymValue, FunctionSec, StackSizeSec, Data,
&Offset);
}
diff --git a/llvm/tools/obj2yaml/elf2yaml.cpp b/llvm/tools/obj2yaml/elf2yaml.cpp
index be8dc1668a2e..9426996d3d41 100644
--- a/llvm/tools/obj2yaml/elf2yaml.cpp
+++ b/llvm/tools/obj2yaml/elf2yaml.cpp
@@ -206,7 +206,7 @@ bool ELFDumper<ELFT>::shouldPrintSection(const ELFYAML::Section &S,
RawSec->EntSize)
return true;
- ELFYAML::ELF_SHF ShFlags = RawSec->Flags.getValueOr(ELFYAML::ELF_SHF(0));
+ ELFYAML::ELF_SHF ShFlags = RawSec->Flags.value_or(ELFYAML::ELF_SHF(0));
if (SecName == "debug_str")
return ShFlags != ELFYAML::ELF_SHF(ELF::SHF_MERGE | ELF::SHF_STRINGS);
@@ -226,7 +226,7 @@ bool ELFDumper<ELFT>::shouldPrintSection(const ELFYAML::Section &S,
// are empty, which should not normally happen.
if (S.Type == ELF::SHT_STRTAB || S.Type == ELF::SHT_SYMTAB ||
S.Type == ELF::SHT_DYNSYM) {
- return S.Size || S.Flags.getValueOr(ELFYAML::ELF_SHF(0)) & ELF::SHF_ALLOC;
+ return S.Size || S.Flags.value_or(ELFYAML::ELF_SHF(0)) & ELF::SHF_ALLOC;
}
return true;
diff --git a/llvm/utils/TableGen/GlobalISelEmitter.cpp b/llvm/utils/TableGen/GlobalISelEmitter.cpp
index 0646e3aaaa0e..3f7b3f5ddf04 100644
--- a/llvm/utils/TableGen/GlobalISelEmitter.cpp
+++ b/llvm/utils/TableGen/GlobalISelEmitter.cpp
@@ -466,7 +466,7 @@ struct MatchTableRecord {
MatchTableRecord(Optional<unsigned> LabelID_, StringRef EmitStr,
unsigned NumElements, unsigned Flags,
int64_t RawValue = std::numeric_limits<int64_t>::min())
- : LabelID(LabelID_.getValueOr(~0u)), EmitStr(EmitStr),
+ : LabelID(LabelID_.value_or(~0u)), EmitStr(EmitStr),
NumElements(NumElements), Flags(Flags), RawValue(RawValue) {
assert((!LabelID_.hasValue() || LabelID != ~0u) &&
"This value is reserved for non-labels");
diff --git a/llvm/utils/TableGen/OptParserEmitter.cpp b/llvm/utils/TableGen/OptParserEmitter.cpp
index d54132f3190b..182cd0076090 100644
--- a/llvm/utils/TableGen/OptParserEmitter.cpp
+++ b/llvm/utils/TableGen/OptParserEmitter.cpp
@@ -172,7 +172,7 @@ static MarshallingInfo createMarshallingInfo(const Record &R) {
Ret.NormalizedValuesScope = R.getValueAsString("NormalizedValuesScope");
Ret.ImpliedCheck = R.getValueAsString("ImpliedCheck");
Ret.ImpliedValue =
- R.getValueAsOptionalString("ImpliedValue").getValueOr(Ret.DefaultValue);
+ R.getValueAsOptionalString("ImpliedValue").value_or(Ret.DefaultValue);
Ret.ShouldParse = R.getValueAsString("ShouldParse");
Ret.Normalizer = R.getValueAsString("Normalizer");
More information about the llvm-commits
mailing list