[llvm] e0e687a - [llvm] Don't use Optional::hasValue (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 20 10:38:19 PDT 2022
Author: Kazu Hirata
Date: 2022-06-20T10:38:12-07:00
New Revision: e0e687a615c1fdb6ba034fc2e48b0834a372706f
URL: https://github.com/llvm/llvm-project/commit/e0e687a615c1fdb6ba034fc2e48b0834a372706f
DIFF: https://github.com/llvm/llvm-project/commit/e0e687a615c1fdb6ba034fc2e48b0834a372706f.diff
LOG: [llvm] Don't use Optional::hasValue (NFC)
Added:
Modified:
llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
llvm/include/llvm/Analysis/ObjCARCUtil.h
llvm/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h
llvm/include/llvm/DebugInfo/CodeView/SymbolRecord.h
llvm/include/llvm/ExecutionEngine/Orc/Speculation.h
llvm/include/llvm/Support/BinaryStreamRef.h
llvm/include/llvm/Support/FormatProviders.h
llvm/lib/Analysis/CFLGraph.h
llvm/lib/Analysis/CFLSteensAliasAnalysis.cpp
llvm/lib/Analysis/IRSimilarityIdentifier.cpp
llvm/lib/Analysis/InlineAdvisor.cpp
llvm/lib/Analysis/InlineCost.cpp
llvm/lib/Analysis/LazyValueInfo.cpp
llvm/lib/Analysis/MemoryBuiltins.cpp
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/lib/Analysis/StratifiedSets.h
llvm/lib/Analysis/ValueTracking.cpp
llvm/lib/CodeGen/BasicBlockSections.cpp
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
llvm/lib/CodeGen/LiveDebugVariables.cpp
llvm/lib/CodeGen/MachineFunctionSplitter.cpp
llvm/lib/CodeGen/ModuloSchedule.cpp
llvm/lib/CodeGen/SelectOptimize.cpp
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGAddressAnalysis.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
llvm/lib/CodeGen/StackProtector.cpp
llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp
llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp
llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
llvm/lib/DebugInfo/GSYM/FunctionInfo.cpp
llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp
llvm/lib/DebugInfo/PDB/Native/NativeTypeEnum.cpp
llvm/lib/DebugInfo/PDB/Native/NativeTypeUDT.cpp
llvm/lib/ExecutionEngine/Orc/Speculation.cpp
llvm/lib/IR/Globals.cpp
llvm/lib/InterfaceStub/ELFObjHandler.cpp
llvm/lib/LTO/LTO.cpp
llvm/lib/MC/MCDXContainerWriter.cpp
llvm/lib/MC/MCObjectStreamer.cpp
llvm/lib/MC/MCParser/MasmParser.cpp
llvm/lib/Object/ELFObjectFile.cpp
llvm/lib/ObjectYAML/COFFEmitter.cpp
llvm/lib/Support/FormatVariadic.cpp
llvm/lib/Support/raw_ostream.cpp
llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp
llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
llvm/lib/Target/ARM/ARMTargetMachine.cpp
llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
llvm/lib/Target/Mips/MipsTargetMachine.cpp
llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFStreamer.cpp
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
llvm/lib/Target/X86/X86TargetMachine.cpp
llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
llvm/lib/Transforms/Coroutines/CoroFrame.cpp
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
llvm/lib/Transforms/IPO/IROutliner.cpp
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
llvm/lib/Transforms/IPO/SampleProfile.cpp
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
llvm/lib/Transforms/Utils/InlineFunction.cpp
llvm/lib/Transforms/Utils/LoopUtils.cpp
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/tools/llc/llc.cpp
llvm/tools/llvm-objdump/llvm-objdump.cpp
llvm/tools/llvm-pdbutil/BytesOutputStyle.cpp
llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp
llvm/tools/llvm-profgen/ProfileGenerator.cpp
llvm/tools/llvm-readobj/ELFDumper.cpp
llvm/utils/TableGen/GICombinerEmitter.cpp
llvm/utils/TableGen/GlobalISelEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h b/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
index 20fa7a9464a8..3666138ae2fd 100644
--- a/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
+++ b/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
@@ -1039,7 +1039,7 @@ class IRSimilarityIdentifier {
// If we've already analyzed a Module or set of Modules, so we must clear
// the SimilarityCandidates to make sure we do not have only old values
// hanging around.
- if (SimilarityCandidates.hasValue())
+ if (SimilarityCandidates)
SimilarityCandidates->clear();
else
SimilarityCandidates = SimilarityGroupList();
diff --git a/llvm/include/llvm/Analysis/ObjCARCUtil.h b/llvm/include/llvm/Analysis/ObjCARCUtil.h
index 385fa5422926..80844ac8cd32 100644
--- a/llvm/include/llvm/Analysis/ObjCARCUtil.h
+++ b/llvm/include/llvm/Analysis/ObjCARCUtil.h
@@ -59,7 +59,7 @@ inline bool isRetainOrClaimRV(ARCInstKind Kind) {
/// or UnsafeClaimRV.
inline ARCInstKind getAttachedARCFunctionKind(const CallBase *CB) {
Optional<Function *> Fn = getAttachedARCFunction(CB);
- if (!Fn.hasValue())
+ if (!Fn)
return ARCInstKind::None;
auto FnClass = GetFunctionClass(*Fn);
assert(isRetainOrClaimRV(FnClass) && "unexpected ARC runtime function");
diff --git a/llvm/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h b/llvm/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h
index 89a156d9fa4e..4fbe7e835a8a 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h
@@ -248,7 +248,7 @@ class CodeViewRecordIO {
Optional<uint32_t> MaxLength;
Optional<uint32_t> bytesRemaining(uint32_t CurrentOffset) const {
- if (!MaxLength.hasValue())
+ if (!MaxLength)
return None;
assert(CurrentOffset >= BeginOffset);
diff --git a/llvm/include/llvm/DebugInfo/CodeView/SymbolRecord.h b/llvm/include/llvm/DebugInfo/CodeView/SymbolRecord.h
index c37f6b4d5fa7..67fd602f2cf5 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/SymbolRecord.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/SymbolRecord.h
@@ -249,7 +249,7 @@ struct BinaryAnnotationIterator
}
bool ParseCurrentAnnotation() {
- if (Current.hasValue())
+ if (Current)
return true;
Next = Data;
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/Speculation.h b/llvm/include/llvm/ExecutionEngine/Orc/Speculation.h
index b0195e43388f..b7bba7a48786 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/Speculation.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/Speculation.h
@@ -88,7 +88,7 @@ class Speculator {
for (auto &Callee : CandidateSet) {
auto ImplSymbol = AliaseeImplTable.getImplFor(Callee);
// try to distinguish already compiled & library symbols
- if (!ImplSymbol.hasValue())
+ if (!ImplSymbol)
continue;
const auto &ImplSymbolName = ImplSymbol.getPointer()->first;
JITDylib *ImplJD = ImplSymbol.getPointer()->second;
diff --git a/llvm/include/llvm/Support/BinaryStreamRef.h b/llvm/include/llvm/Support/BinaryStreamRef.h
index bc8c6a496ecf..46fc9fb293df 100644
--- a/llvm/include/llvm/Support/BinaryStreamRef.h
+++ b/llvm/include/llvm/Support/BinaryStreamRef.h
@@ -48,7 +48,7 @@ template <class RefType, class StreamType> class BinaryStreamRefBase {
}
uint64_t getLength() const {
- if (Length.hasValue())
+ if (Length)
return *Length;
return BorrowedImpl ? (BorrowedImpl->getLength() - ViewOffset) : 0;
@@ -67,7 +67,7 @@ template <class RefType, class StreamType> class BinaryStreamRefBase {
return Result;
Result.ViewOffset += N;
- if (Result.Length.hasValue())
+ if (Result.Length)
*Result.Length -= N;
return Result;
}
@@ -87,7 +87,7 @@ template <class RefType, class StreamType> class BinaryStreamRefBase {
// Since we're dropping non-zero bytes from the end, stop length-tracking
// by setting the length of the resulting StreamRef to an explicit value.
- if (!Result.Length.hasValue())
+ if (!Result.Length)
Result.Length = getLength();
*Result.Length -= N;
diff --git a/llvm/include/llvm/Support/FormatProviders.h b/llvm/include/llvm/Support/FormatProviders.h
index 3edd8844bc7a..8101ed7968ad 100644
--- a/llvm/include/llvm/Support/FormatProviders.h
+++ b/llvm/include/llvm/Support/FormatProviders.h
@@ -313,7 +313,7 @@ struct format_provider<T,
S = FloatStyle::Fixed;
Optional<size_t> Precision = parseNumericPrecision(Style);
- if (!Precision.hasValue())
+ if (!Precision)
Precision = getDefaultPrecision(S);
write_double(Stream, static_cast<double>(V), S, Precision);
diff --git a/llvm/lib/Analysis/CFLGraph.h b/llvm/lib/Analysis/CFLGraph.h
index 02a13d673f40..60fc8d18678c 100644
--- a/llvm/lib/Analysis/CFLGraph.h
+++ b/llvm/lib/Analysis/CFLGraph.h
@@ -403,7 +403,7 @@ template <typename CFLAA> class CFLGraphBuilder {
auto &RetParamRelations = Summary->RetParamRelations;
for (auto &Relation : RetParamRelations) {
auto IRelation = instantiateExternalRelation(Relation, Call);
- if (IRelation.hasValue()) {
+ if (IRelation) {
Graph.addNode(IRelation->From);
Graph.addNode(IRelation->To);
Graph.addEdge(IRelation->From, IRelation->To);
@@ -413,7 +413,7 @@ template <typename CFLAA> class CFLGraphBuilder {
auto &RetParamAttributes = Summary->RetParamAttributes;
for (auto &Attribute : RetParamAttributes) {
auto IAttr = instantiateExternalAttribute(Attribute, Call);
- if (IAttr.hasValue())
+ if (IAttr)
Graph.addNode(IAttr->IValue, IAttr->Attr);
}
}
diff --git a/llvm/lib/Analysis/CFLSteensAliasAnalysis.cpp b/llvm/lib/Analysis/CFLSteensAliasAnalysis.cpp
index 090dccc53b6e..b831a599cc09 100644
--- a/llvm/lib/Analysis/CFLSteensAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/CFLSteensAliasAnalysis.cpp
@@ -165,7 +165,7 @@ CFLSteensAAResult::FunctionInfo::FunctionInfo(
assert(RetVal != nullptr);
assert(RetVal->getType()->isPointerTy());
auto RetInfo = Sets.find(InstantiatedValue{RetVal, 0});
- if (RetInfo.hasValue())
+ if (RetInfo)
AddToRetParamRelations(0, RetInfo->Index);
}
@@ -174,7 +174,7 @@ CFLSteensAAResult::FunctionInfo::FunctionInfo(
for (auto &Param : Fn.args()) {
if (Param.getType()->isPointerTy()) {
auto ParamInfo = Sets.find(InstantiatedValue{&Param, 0});
- if (ParamInfo.hasValue())
+ if (ParamInfo)
AddToRetParamRelations(I + 1, ParamInfo->Index);
}
++I;
diff --git a/llvm/lib/Analysis/IRSimilarityIdentifier.cpp b/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
index 1b95af96684e..a19eb6114ff8 100644
--- a/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
+++ b/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
@@ -64,7 +64,7 @@ void IRInstructionData::initializeInstruction() {
// Here we collect the operands and their types for determining whether
// the structure of the operand use matches between two
diff erent candidates.
for (Use &OI : Inst->operands()) {
- if (isa<CmpInst>(Inst) && RevisedPredicate.hasValue()) {
+ if (isa<CmpInst>(Inst) && RevisedPredicate) {
// If we have a CmpInst where the predicate is reversed, it means the
// operands must be reversed as well.
OperVals.insert(OperVals.begin(), OI.get());
diff --git a/llvm/lib/Analysis/InlineAdvisor.cpp b/llvm/lib/Analysis/InlineAdvisor.cpp
index 6a78e9b02f22..7a007b5e901f 100644
--- a/llvm/lib/Analysis/InlineAdvisor.cpp
+++ b/llvm/lib/Analysis/InlineAdvisor.cpp
@@ -573,7 +573,7 @@ std::string llvm::AnnotateInlinePassName(InlineContext IC) {
}
const char *InlineAdvisor::getAnnotatedInlinePassName() {
- if (!IC.hasValue())
+ if (!IC)
return DEBUG_TYPE;
// IC is constant and initialized in constructor, so compute the annotated
@@ -598,7 +598,7 @@ InlineAdvisor::getMandatoryKind(CallBase &CB, FunctionAnalysisManager &FAM,
auto TrivialDecision =
llvm::getAttributeBasedInliningDecision(CB, &Callee, TIR, GetTLI);
- if (TrivialDecision.hasValue()) {
+ if (TrivialDecision) {
if (TrivialDecision->isSuccess())
return MandatoryInliningKind::Always;
else
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index c47baf783650..c3451f0e9acd 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -2915,7 +2915,7 @@ InlineCost llvm::getInlineCost(
auto UserDecision =
llvm::getAttributeBasedInliningDecision(Call, Callee, CalleeTTI, GetTLI);
- if (UserDecision.hasValue()) {
+ if (UserDecision) {
if (UserDecision->isSuccess())
return llvm::InlineCost::getAlways("always inline attribute");
return llvm::InlineCost::getNever(UserDecision->getFailureReason());
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp
index ca631374ac33..85aebbea5074 100644
--- a/llvm/lib/Analysis/LazyValueInfo.cpp
+++ b/llvm/lib/Analysis/LazyValueInfo.cpp
@@ -942,7 +942,7 @@ Optional<ValueLatticeElement> LazyValueInfoImpl::solveBlockValueBinaryOpImpl(
// @foo()), 32"
Optional<ConstantRange> LHSRes = getRangeFor(I->getOperand(0), I, BB);
Optional<ConstantRange> RHSRes = getRangeFor(I->getOperand(1), I, BB);
- if (!LHSRes.hasValue() || !RHSRes.hasValue())
+ if (!LHSRes || !RHSRes)
// More work to do before applying this transfer rule.
return None;
diff --git a/llvm/lib/Analysis/MemoryBuiltins.cpp b/llvm/lib/Analysis/MemoryBuiltins.cpp
index 96c585e71f26..ae9bce5937b5 100644
--- a/llvm/lib/Analysis/MemoryBuiltins.cpp
+++ b/llvm/lib/Analysis/MemoryBuiltins.cpp
@@ -335,7 +335,7 @@ bool llvm::isAllocRemovable(const CallBase *CB, const TargetLibraryInfo *TLI) {
Value *llvm::getAllocAlignment(const CallBase *V,
const TargetLibraryInfo *TLI) {
const Optional<AllocFnsTy> FnData = getAllocationData(V, AnyAlloc, TLI);
- if (FnData.hasValue() && FnData->AlignParam >= 0) {
+ if (FnData && FnData->AlignParam >= 0) {
return V->getOperand(FnData->AlignParam);
}
return V->getArgOperandWithAttribute(Attribute::AllocAlign);
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 540d37f9b878..0c8cd72b3caa 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -6885,7 +6885,7 @@ ConstantRange ScalarEvolution::getRangeViaFactoring(const SCEV *Start,
FalseValue = *FalseVal;
// Re-apply the cast we peeled off earlier
- if (CastOp.hasValue())
+ if (CastOp)
switch (*CastOp) {
default:
llvm_unreachable("Unknown SCEV cast type!");
@@ -9733,7 +9733,7 @@ static Optional<APInt> MinOptional(Optional<APInt> X, Optional<APInt> Y) {
/// equation are BW+1 bits wide (to avoid truncation when converting from
/// the addrec to the equation).
static Optional<APInt> TruncIfPossible(Optional<APInt> X, unsigned BitWidth) {
- if (!X.hasValue())
+ if (!X)
return None;
unsigned W = X->getBitWidth();
if (BitWidth > 1 && BitWidth < W && X->isIntN(BitWidth))
@@ -9802,7 +9802,7 @@ SolveQuadraticAddRecRange(const SCEVAddRecExpr *AddRec,
APInt A, B, C, M;
unsigned BitWidth;
auto T = GetQuadraticEquation(AddRec);
- if (!T.hasValue())
+ if (!T)
return None;
// Be careful about the return value: there can be two reasons for not
@@ -9847,7 +9847,7 @@ SolveQuadraticAddRecRange(const SCEVAddRecExpr *AddRec,
// If SolveQuadraticEquationWrap returns None, it means that there can
// be a solution, but the function failed to find it. We cannot treat it
// as "no solution".
- if (!SO.hasValue() || !UO.hasValue())
+ if (!SO || !UO)
return { None, false };
// Check the smaller value first to see if it leaves the range.
diff --git a/llvm/lib/Analysis/StratifiedSets.h b/llvm/lib/Analysis/StratifiedSets.h
index 60ea2451b0ef..8468f2b0d104 100644
--- a/llvm/lib/Analysis/StratifiedSets.h
+++ b/llvm/lib/Analysis/StratifiedSets.h
@@ -560,7 +560,7 @@ template <typename T> class StratifiedSetsBuilder {
Optional<StratifiedIndex> indexOf(const T &Val) {
auto MaybeVal = get(Val);
- if (!MaybeVal.hasValue())
+ if (!MaybeVal)
return None;
auto *Info = *MaybeVal;
auto &Link = linksAt(Info->Index);
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 4ae1c6d5bfbd..bc5bca78b2ec 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -1070,7 +1070,7 @@ static void computeKnownBitsFromShiftOperator(
// bits. This check is sunk down as far as possible to avoid the expensive
// call to isKnownNonZero if the cheaper checks above fail.
if (ShiftAmt == 0) {
- if (!ShifterOperandIsNonZero.hasValue())
+ if (!ShifterOperandIsNonZero)
ShifterOperandIsNonZero =
isKnownNonZero(I->getOperand(1), DemandedElts, Depth + 1, Q);
if (*ShifterOperandIsNonZero)
diff --git a/llvm/lib/CodeGen/BasicBlockSections.cpp b/llvm/lib/CodeGen/BasicBlockSections.cpp
index 38ba651d126f..0c28bfb753f4 100644
--- a/llvm/lib/CodeGen/BasicBlockSections.cpp
+++ b/llvm/lib/CodeGen/BasicBlockSections.cpp
@@ -221,7 +221,7 @@ assignSections(MachineFunction &MF,
// set every basic block's section ID equal to its number (basic block
// id). This further ensures that basic blocks are ordered canonically.
MBB.setSectionID({static_cast<unsigned int>(MBB.getNumber())});
- } else if (FuncBBClusterInfo[MBB.getNumber()].hasValue())
+ } else if (FuncBBClusterInfo[MBB.getNumber()])
MBB.setSectionID(FuncBBClusterInfo[MBB.getNumber()]->ClusterID);
else {
// BB goes into the special cold section if it is not specified in the
diff --git a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
index d742b8070b01..1a62224177a1 100644
--- a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
@@ -3465,7 +3465,7 @@ bool CombinerHelper::matchLoadOrCombine(
// BSWAP.
bool IsBigEndianTarget = MF.getDataLayout().isBigEndian();
Optional<bool> IsBigEndian = isBigEndian(MemOffset2Idx, LowestIdx);
- if (!IsBigEndian.hasValue())
+ if (!IsBigEndian)
return false;
bool NeedsBSwap = IsBigEndianTarget != *IsBigEndian;
if (NeedsBSwap && !isLegalOrBeforeLegalizer({TargetOpcode::G_BSWAP, {Ty}}))
diff --git a/llvm/lib/CodeGen/LiveDebugVariables.cpp b/llvm/lib/CodeGen/LiveDebugVariables.cpp
index 320e68241e4e..35cf25330186 100644
--- a/llvm/lib/CodeGen/LiveDebugVariables.cpp
+++ b/llvm/lib/CodeGen/LiveDebugVariables.cpp
@@ -972,7 +972,7 @@ void UserValue::extendDef(
if (Segment->end < Stop) {
Stop = Segment->end;
Kills = {Stop, {LII.first}};
- } else if (Segment->end == Stop && Kills.hasValue()) {
+ } else if (Segment->end == Stop && Kills) {
// If multiple locations end at the same place, track all of them in
// Kills.
Kills->second.push_back(LII.first);
diff --git a/llvm/lib/CodeGen/MachineFunctionSplitter.cpp b/llvm/lib/CodeGen/MachineFunctionSplitter.cpp
index 3ebe31c19b0f..7d0f294ca552 100644
--- a/llvm/lib/CodeGen/MachineFunctionSplitter.cpp
+++ b/llvm/lib/CodeGen/MachineFunctionSplitter.cpp
@@ -80,7 +80,7 @@ static bool isColdBlock(const MachineBasicBlock &MBB,
const MachineBlockFrequencyInfo *MBFI,
ProfileSummaryInfo *PSI) {
Optional<uint64_t> Count = MBFI->getBlockProfileCount(&MBB);
- if (!Count.hasValue())
+ if (!Count)
return true;
if (PercentileCutoff > 0) {
diff --git a/llvm/lib/CodeGen/ModuloSchedule.cpp b/llvm/lib/CodeGen/ModuloSchedule.cpp
index 342891a7bda2..983aff57d203 100644
--- a/llvm/lib/CodeGen/ModuloSchedule.cpp
+++ b/llvm/lib/CodeGen/ModuloSchedule.cpp
@@ -850,7 +850,7 @@ void ModuloScheduleExpander::addBranches(MachineBasicBlock &PreheaderBB,
Optional<bool> StaticallyGreater =
LoopInfo->createTripCountGreaterCondition(j + 1, *Prolog, Cond);
unsigned numAdded = 0;
- if (!StaticallyGreater.hasValue()) {
+ if (!StaticallyGreater) {
Prolog->addSuccessor(Epilog);
numAdded = TII->insertBranch(*Prolog, Epilog, LastPro, Cond, DebugLoc());
} else if (*StaticallyGreater == false) {
@@ -1421,7 +1421,7 @@ Register KernelRewriter::remapUse(Register Reg, MachineInstr &MI) {
while (DefaultI != Defaults.rend())
LoopReg = phi(LoopReg, *DefaultI++, MRI.getRegClass(Reg));
- if (IllegalPhiDefault.hasValue()) {
+ if (IllegalPhiDefault) {
// The consumer optionally consumes LoopProducer in the same iteration
// (because the producer is scheduled at an earlier cycle than the consumer)
// or the initial value. To facilitate this we create an illegal block here
@@ -1463,7 +1463,7 @@ Register KernelRewriter::phi(Register LoopReg, Optional<Register> InitReg,
auto I = UndefPhis.find(LoopReg);
if (I != UndefPhis.end()) {
Register R = I->second;
- if (!InitReg.hasValue())
+ if (!InitReg)
// Found a phi taking undef as input, and this input is undef so return
// without any more changes.
return R;
@@ -1943,7 +1943,7 @@ void PeelingModuloScheduleExpander::fixupBranches() {
TII->removeBranch(*Prolog);
Optional<bool> StaticallyGreater =
LoopInfo->createTripCountGreaterCondition(TC, *Prolog, Cond);
- if (!StaticallyGreater.hasValue()) {
+ if (!StaticallyGreater) {
LLVM_DEBUG(dbgs() << "Dynamic: TC > " << TC << "\n");
// Dynamically branch based on Cond.
TII->insertBranch(*Prolog, Epilog, Fallthrough, Cond, DebugLoc());
diff --git a/llvm/lib/CodeGen/SelectOptimize.cpp b/llvm/lib/CodeGen/SelectOptimize.cpp
index d55329a8788c..cd54a09e252c 100644
--- a/llvm/lib/CodeGen/SelectOptimize.cpp
+++ b/llvm/lib/CodeGen/SelectOptimize.cpp
@@ -862,7 +862,7 @@ bool SelectOptimize::computeLoopCosts(
}
}
auto ILatency = computeInstCost(&I);
- if (!ILatency.hasValue()) {
+ if (!ILatency) {
OptimizationRemarkMissed ORmissL(DEBUG_TYPE, "SelectOpti", &I);
ORmissL << "Invalid instruction cost preventing analysis and "
"optimization of the inner-most loop containing this "
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index d22f06537605..45b6703ffd2c 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -8116,7 +8116,7 @@ SDValue DAGCombiner::MatchLoadCombine(SDNode *N) {
// little endian value load
Optional<bool> IsBigEndian = isBigEndian(
makeArrayRef(ByteOffsets).drop_back(ZeroExtendedBytes), FirstOffset);
- if (!IsBigEndian.hasValue())
+ if (!IsBigEndian)
return SDValue();
assert(FirstByteProvider && "must be set");
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGAddressAnalysis.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGAddressAnalysis.cpp
index 6d8252046501..d236433f6fb4 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGAddressAnalysis.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGAddressAnalysis.cpp
@@ -96,7 +96,7 @@ bool BaseIndexOffset::computeAliasing(const SDNode *Op0,
if (!(BasePtr0.getBase().getNode() && BasePtr1.getBase().getNode()))
return false;
int64_t PtrDiff;
- if (NumBytes0.hasValue() && NumBytes1.hasValue() &&
+ if (NumBytes0 && NumBytes1 &&
BasePtr0.equalBaseIndex(BasePtr1, DAG, PtrDiff)) {
// If the size of memory access is unknown, do not use it to analysis.
// One example of unknown size memory access is to load/store scalable
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 179583f58e61..9d2c147fac7c 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -269,7 +269,7 @@ static SDValue getCopyFromParts(SelectionDAG &DAG, const SDLoc &DL,
// For a truncate, see if we have any information to
// indicate whether the truncated bits will always be
// zero or sign-extension.
- if (AssertOp.hasValue())
+ if (AssertOp)
Val = DAG.getNode(*AssertOp, DL, PartEVT, Val,
DAG.getValueType(ValueVT));
return DAG.getNode(ISD::TRUNCATE, DL, ValueVT, Val);
@@ -7375,7 +7375,7 @@ static unsigned getISDForVPIntrinsic(const VPIntrinsic &VPIntrin) {
#include "llvm/IR/VPIntrinsics.def"
}
- if (!ResOPC.hasValue())
+ if (!ResOPC)
llvm_unreachable(
"Inconsistency: no SDNode available for this VPIntrinsic!");
diff --git a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
index f33d1c8edbe0..b318c2ae7662 100644
--- a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
@@ -280,7 +280,7 @@ static void reservePreviousStackSlotForValue(const Value *IncomingValue,
const int LookUpDepth = 6;
Optional<int> Index =
findPreviousSpillSlot(IncomingValue, Builder, LookUpDepth);
- if (!Index.hasValue())
+ if (!Index)
return;
const auto &StatepointSlots = Builder.FuncInfo.StatepointStackSlots;
diff --git a/llvm/lib/CodeGen/StackProtector.cpp b/llvm/lib/CodeGen/StackProtector.cpp
index ea950da0693e..510a8e3e4ba2 100644
--- a/llvm/lib/CodeGen/StackProtector.cpp
+++ b/llvm/lib/CodeGen/StackProtector.cpp
@@ -167,7 +167,7 @@ bool StackProtector::HasAddressTaken(const Instruction *AI,
// If this instruction accesses memory make sure it doesn't access beyond
// the bounds of the allocated object.
Optional<MemoryLocation> MemLoc = MemoryLocation::getOrNone(I);
- if (MemLoc.hasValue() && MemLoc->Size.hasValue() &&
+ if (MemLoc && MemLoc->Size.hasValue() &&
!TypeSize::isKnownGE(AllocSize,
TypeSize::getFixed(MemLoc->Size.getValue())))
return true;
diff --git a/llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp b/llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp
index 3c9b41e8a8dd..1554a6eced8a 100644
--- a/llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp
+++ b/llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp
@@ -158,7 +158,7 @@ CVType ContinuationRecordBuilder::createSegmentRecord(
RecordPrefix *Prefix = reinterpret_cast<RecordPrefix *>(Data.data());
Prefix->RecordLen = Data.size() - sizeof(RecordPrefix::RecordLen);
- if (RefersTo.hasValue()) {
+ if (RefersTo) {
auto Continuation = Data.take_back(ContinuationLength);
ContinuationRecord *CR =
reinterpret_cast<ContinuationRecord *>(Continuation.data());
diff --git a/llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp b/llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp
index 3cccd5e85d06..7ddfb7ab2f8d 100644
--- a/llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp
+++ b/llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp
@@ -487,7 +487,7 @@ Expected<bool> TypeStreamMerger::shouldRemapType(const CVType &Type) {
if (auto EC = TypeDeserializer::deserializeAs(const_cast<CVType &>(Type),
EP))
return joinErrors(std::move(EC), errorCorruptRecord());
- if (PCHSignature.hasValue())
+ if (PCHSignature)
return errorCorruptRecord();
PCHSignature.emplace(EP.getSignature());
return false;
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
index 9e5cbc601546..cf9057c99dbd 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
@@ -1145,7 +1145,7 @@ Error DWARFDebugFrame::parse(DWARFDataExtractor Data) {
}
}
- if (AugmentationLength.hasValue()) {
+ if (AugmentationLength) {
if (Offset != EndAugmentationOffset)
return createStringError(errc::invalid_argument,
"parsing augmentation data at 0x%" PRIx64
diff --git a/llvm/lib/DebugInfo/GSYM/FunctionInfo.cpp b/llvm/lib/DebugInfo/GSYM/FunctionInfo.cpp
index 6763869a7197..4f5d240cdf72 100644
--- a/llvm/lib/DebugInfo/GSYM/FunctionInfo.cpp
+++ b/llvm/lib/DebugInfo/GSYM/FunctionInfo.cpp
@@ -108,7 +108,7 @@ llvm::Expected<uint64_t> FunctionInfo::encode(FileWriter &O) const {
// Write the name of this function as a uint32_t string table offset.
O.writeU32(Name);
- if (OptLineTable.hasValue()) {
+ if (OptLineTable) {
O.writeU32(InfoType::LineTableInfo);
// Write a uint32_t length as zero for now, we will fix this up after
// writing the LineTable out with the number of bytes that were written.
@@ -126,7 +126,7 @@ llvm::Expected<uint64_t> FunctionInfo::encode(FileWriter &O) const {
}
// Write out the inline function info if we have any and if it is valid.
- if (Inline.hasValue()) {
+ if (Inline) {
O.writeU32(InfoType::InlineInfo);
// Write a uint32_t length as zero for now, we will fix this up after
// writing the LineTable out with the number of bytes that were written.
diff --git a/llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp
index 69db1279dae5..1cb332c5fd00 100644
--- a/llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp
@@ -71,7 +71,7 @@ void DbiStreamBuilder::setPublicsStreamIndex(uint32_t Index) {
}
void DbiStreamBuilder::addNewFpoData(const codeview::FrameData &FD) {
- if (!NewFpoData.hasValue())
+ if (!NewFpoData)
NewFpoData.emplace(false);
NewFpoData->addFrameData(FD);
@@ -285,7 +285,7 @@ Error DbiStreamBuilder::finalize() {
}
Error DbiStreamBuilder::finalizeMsfLayout() {
- if (NewFpoData.hasValue()) {
+ if (NewFpoData) {
DbgStreams[(int)DbgHeaderType::NewFPO].emplace();
DbgStreams[(int)DbgHeaderType::NewFPO]->Size =
NewFpoData->calculateSerializedSize();
@@ -306,7 +306,7 @@ Error DbiStreamBuilder::finalizeMsfLayout() {
}
for (auto &S : DbgStreams) {
- if (!S.hasValue())
+ if (!S)
continue;
auto ExpectedIndex = Msf.addStream(S->Size);
if (!ExpectedIndex)
diff --git a/llvm/lib/DebugInfo/PDB/Native/NativeTypeEnum.cpp b/llvm/lib/DebugInfo/PDB/Native/NativeTypeEnum.cpp
index fcb642ffa940..645a9963084b 100644
--- a/llvm/lib/DebugInfo/PDB/Native/NativeTypeEnum.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/NativeTypeEnum.cpp
@@ -137,7 +137,7 @@ void NativeTypeEnum::dump(raw_ostream &OS, int Indent,
dumpSymbolField(OS, "name", getName(), Indent);
dumpSymbolIdField(OS, "typeId", getTypeId(), Indent, Session,
PdbSymbolIdField::Type, ShowIdFields, RecurseIdFields);
- if (Modifiers.hasValue())
+ if (Modifiers)
dumpSymbolIdField(OS, "unmodifiedTypeId", getUnmodifiedTypeId(), Indent,
Session, PdbSymbolIdField::UnmodifiedType, ShowIdFields,
RecurseIdFields);
diff --git a/llvm/lib/DebugInfo/PDB/Native/NativeTypeUDT.cpp b/llvm/lib/DebugInfo/PDB/Native/NativeTypeUDT.cpp
index 95fba1114ef2..b708fb644e7a 100644
--- a/llvm/lib/DebugInfo/PDB/Native/NativeTypeUDT.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/NativeTypeUDT.cpp
@@ -45,7 +45,7 @@ void NativeTypeUDT::dump(raw_ostream &OS, int Indent,
dumpSymbolIdField(OS, "lexicalParentId", 0, Indent, Session,
PdbSymbolIdField::LexicalParent, ShowIdFields,
RecurseIdFields);
- if (Modifiers.hasValue())
+ if (Modifiers)
dumpSymbolIdField(OS, "unmodifiedTypeId", getUnmodifiedTypeId(), Indent,
Session, PdbSymbolIdField::UnmodifiedType, ShowIdFields,
RecurseIdFields);
diff --git a/llvm/lib/ExecutionEngine/Orc/Speculation.cpp b/llvm/lib/ExecutionEngine/Orc/Speculation.cpp
index 0b4755fe23cf..0ed3cf395039 100644
--- a/llvm/lib/ExecutionEngine/Orc/Speculation.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/Speculation.cpp
@@ -85,7 +85,7 @@ void IRSpeculationLayer::emit(std::unique_ptr<MaterializationResponsibility> R,
auto IRNames = QueryAnalysis(Fn);
// Instrument and register if Query has result
- if (IRNames.hasValue()) {
+ if (IRNames) {
// Emit globals for each function.
auto LoadValueTy = Type::getInt8Ty(MContext);
diff --git a/llvm/lib/IR/Globals.cpp b/llvm/lib/IR/Globals.cpp
index 9f1ed1d4b120..3265050261c8 100644
--- a/llvm/lib/IR/Globals.cpp
+++ b/llvm/lib/IR/Globals.cpp
@@ -285,7 +285,7 @@ bool GlobalObject::canIncreaseAlignment() const {
// alignment specified. (If it is assigned a section, the global
// could be densely packed with other objects in the section, and
// increasing the alignment could cause padding issues.)
- if (hasSection() && getAlign().hasValue())
+ if (hasSection() && getAlign())
return false;
// On ELF platforms, we're further restricted in that we can't
diff --git a/llvm/lib/InterfaceStub/ELFObjHandler.cpp b/llvm/lib/InterfaceStub/ELFObjHandler.cpp
index 33dc529de60a..55e64d146ceb 100644
--- a/llvm/lib/InterfaceStub/ELFObjHandler.cpp
+++ b/llvm/lib/InterfaceStub/ELFObjHandler.cpp
@@ -493,7 +493,7 @@ static Error populateDynamic(DynamicEntries &Dyn,
return createError(
"Couldn't locate dynamic symbol table (no DT_SYMTAB entry)");
}
- if (Dyn.SONameOffset.hasValue() && *Dyn.SONameOffset >= Dyn.StrSize) {
+ if (Dyn.SONameOffset && *Dyn.SONameOffset >= Dyn.StrSize) {
return createStringError(object_error::parse_failed,
"DT_SONAME string offset (0x%016" PRIx64
") outside of dynamic string table",
@@ -608,7 +608,7 @@ buildStub(const ELFObjectFile<ELFT> &ElfObj) {
DestStub->Target.ObjectFormat = "ELF";
// Populate SoName from .dynamic entries and dynamic string table.
- if (DynEnt.SONameOffset.hasValue()) {
+ if (DynEnt.SONameOffset) {
Expected<StringRef> NameOrErr =
terminatedSubstr(DynStr, *DynEnt.SONameOffset);
if (!NameOrErr) {
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp
index 2cb832faa9c0..b9c1cf962a5e 100644
--- a/llvm/lib/LTO/LTO.cpp
+++ b/llvm/lib/LTO/LTO.cpp
@@ -639,7 +639,7 @@ Error LTO::addModule(InputFile &Input, unsigned ModI,
if (!LTOInfo)
return LTOInfo.takeError();
- if (EnableSplitLTOUnit.hasValue()) {
+ if (EnableSplitLTOUnit) {
// If only some modules were split, flag this in the index so that
// we can skip or error on optimizations that need consistently split
// modules (whole program devirt and lower type tests).
diff --git a/llvm/lib/MC/MCDXContainerWriter.cpp b/llvm/lib/MC/MCDXContainerWriter.cpp
index 9251bd0b3001..f5dad702d6f6 100644
--- a/llvm/lib/MC/MCDXContainerWriter.cpp
+++ b/llvm/lib/MC/MCDXContainerWriter.cpp
@@ -114,7 +114,7 @@ uint64_t DXContainerObjectWriter::writeObject(MCAssembler &Asm,
const Triple &TT = Asm.getContext().getTargetTriple();
VersionTuple Version = TT.getOSVersion();
Header.MajorVersion = static_cast<uint8_t>(Version.getMajor());
- if (Version.getMinor().hasValue())
+ if (Version.getMinor())
Header.MinorVersion = static_cast<uint8_t>(*Version.getMinor());
if (TT.hasEnvironment())
Header.ShaderKind =
diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp
index 4ca060759ce2..0c4ed201a0c5 100644
--- a/llvm/lib/MC/MCObjectStreamer.cpp
+++ b/llvm/lib/MC/MCObjectStreamer.cpp
@@ -796,7 +796,7 @@ MCObjectStreamer::emitRelocDirective(const MCExpr &Offset, StringRef Name,
const MCExpr *Expr, SMLoc Loc,
const MCSubtargetInfo &STI) {
Optional<MCFixupKind> MaybeKind = Assembler->getBackend().getFixupKind(Name);
- if (!MaybeKind.hasValue())
+ if (!MaybeKind)
return std::make_pair(true, std::string("unknown relocation name"));
MCFixupKind Kind = *MaybeKind;
diff --git a/llvm/lib/MC/MCParser/MasmParser.cpp b/llvm/lib/MC/MCParser/MasmParser.cpp
index 8e6db039c2c8..7ed37b02f460 100644
--- a/llvm/lib/MC/MCParser/MasmParser.cpp
+++ b/llvm/lib/MC/MCParser/MasmParser.cpp
@@ -1190,7 +1190,7 @@ bool MasmParser::expandMacros() {
}
}
- if (!ExpandedValue.hasValue())
+ if (!ExpandedValue)
return true;
std::unique_ptr<MemoryBuffer> Instantiation =
MemoryBuffer::getMemBufferCopy(*ExpandedValue, "<instantiation>");
@@ -2902,7 +2902,7 @@ bool MasmParser::expandMacro(raw_svector_ostream &OS, StringRef Body,
if (Body[Pos] == '&')
break;
if (isMacroParameterChar(Body[Pos])) {
- if (!CurrentQuote.hasValue())
+ if (!CurrentQuote)
break;
if (IdentifierPos == End)
IdentifierPos = Pos;
@@ -2911,7 +2911,7 @@ bool MasmParser::expandMacro(raw_svector_ostream &OS, StringRef Body,
}
// Track quotation status
- if (!CurrentQuote.hasValue()) {
+ if (!CurrentQuote) {
if (Body[Pos] == '\'' || Body[Pos] == '"')
CurrentQuote = Body[Pos];
} else if (Body[Pos] == CurrentQuote) {
@@ -3330,7 +3330,7 @@ bool MasmParser::handleMacroInvocation(const MCAsmMacro *M, SMLoc NameLoc) {
ParseStatementInfo Info(&AsmStrRewrites);
bool Parsed = parseStatement(Info, nullptr);
- if (!Parsed && Info.ExitValue.hasValue()) {
+ if (!Parsed && Info.ExitValue) {
ExitValue = std::move(*Info.ExitValue);
break;
}
@@ -3625,7 +3625,7 @@ bool MasmParser::parseTextItem(std::string &Data) {
if (BuiltinIt != BuiltinSymbolMap.end()) {
llvm::Optional<std::string> BuiltinText =
evaluateBuiltinTextMacro(BuiltinIt->getValue(), StartLoc);
- if (!BuiltinText.hasValue()) {
+ if (!BuiltinText) {
// Not a text macro; break without substituting
break;
}
diff --git a/llvm/lib/Object/ELFObjectFile.cpp b/llvm/lib/Object/ELFObjectFile.cpp
index c325e30d2d5f..319b69a98293 100644
--- a/llvm/lib/Object/ELFObjectFile.cpp
+++ b/llvm/lib/Object/ELFObjectFile.cpp
@@ -303,7 +303,7 @@ SubtargetFeatures ELFObjectFileBase::getRISCVFeatures() const {
}
Optional<StringRef> Attr = Attributes.getAttributeString(RISCVAttrs::ARCH);
- if (Attr.hasValue()) {
+ if (Attr) {
// The Arch pattern is [rv32|rv64][i|e]version(_[m|a|f|d|c]version)*
// Version string pattern is (major)p(minor). Major and minor are optional.
// For example, a version number could be 2p0, 2, or p92.
diff --git a/llvm/lib/ObjectYAML/COFFEmitter.cpp b/llvm/lib/ObjectYAML/COFFEmitter.cpp
index fdd86b9f06c8..8c7f7b27a673 100644
--- a/llvm/lib/ObjectYAML/COFFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/COFFEmitter.cpp
@@ -237,7 +237,7 @@ static bool layoutCOFF(COFFParser &CP) {
if (S.SectionData.binary_size() == 0)
S.SectionData = CodeViewYAML::toDebugT(S.DebugP, CP.Allocator, S.Name);
} else if (S.Name == ".debug$H") {
- if (S.DebugH.hasValue() && S.SectionData.binary_size() == 0)
+ if (S.DebugH && S.SectionData.binary_size() == 0)
S.SectionData = CodeViewYAML::toDebugH(*S.DebugH, CP.Allocator);
}
@@ -457,7 +457,7 @@ static bool writeCOFF(COFFParser &CP, raw_ostream &OS) {
CP.Obj.OptionalHeader->DataDirectories;
uint32_t NumDataDir = sizeof(CP.Obj.OptionalHeader->DataDirectories) /
sizeof(Optional<COFF::DataDirectory>);
- if (I >= NumDataDir || !DataDirectories[I].hasValue()) {
+ if (I >= NumDataDir || !DataDirectories[I]) {
OS << zeros(uint32_t(0));
OS << zeros(uint32_t(0));
} else {
diff --git a/llvm/lib/Support/FormatVariadic.cpp b/llvm/lib/Support/FormatVariadic.cpp
index f6d48bcd50e8..0709d65e81e0 100644
--- a/llvm/lib/Support/FormatVariadic.cpp
+++ b/llvm/lib/Support/FormatVariadic.cpp
@@ -130,7 +130,7 @@ formatv_object_base::splitLiteralAndReplacement(StringRef Fmt) {
StringRef Right = Fmt.substr(BC + 1);
auto RI = parseReplacementItem(Spec);
- if (RI.hasValue())
+ if (RI)
return std::make_pair(*RI, Right);
// If there was an error parsing the replacement item, treat it as an
diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
index 69d4fe96bee8..7648dac00598 100644
--- a/llvm/lib/Support/raw_ostream.cpp
+++ b/llvm/lib/Support/raw_ostream.cpp
@@ -408,7 +408,7 @@ raw_ostream &raw_ostream::operator<<(const FormattedBytes &FB) {
const size_t Size = Bytes.size();
HexPrintStyle HPS = FB.Upper ? HexPrintStyle::Upper : HexPrintStyle::Lower;
uint64_t OffsetWidth = 0;
- if (FB.FirstByteOffset.hasValue()) {
+ if (FB.FirstByteOffset) {
// Figure out how many nibbles are needed to print the largest offset
// represented by this data set, so that we can align the offset field
// to the right width.
diff --git a/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp b/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp
index 8de3cba8cd50..a2ab2b855d80 100644
--- a/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp
@@ -33,7 +33,7 @@ void yaml::AArch64FunctionInfo::mappingImpl(yaml::IO &YamlIO) {
void AArch64FunctionInfo::initializeBaseYamlFields(
const yaml::AArch64FunctionInfo &YamlMFI) {
- if (YamlMFI.HasRedZone.hasValue())
+ if (YamlMFI.HasRedZone)
HasRedZone = YamlMFI.HasRedZone;
}
diff --git a/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp b/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
index 3c205fd5c319..fd34bc3334f8 100644
--- a/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
+++ b/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
@@ -274,7 +274,7 @@ static Reloc::Model getEffectiveRelocModel(const Triple &TT,
// On ELF platforms the default static relocation model has a smart enough
// linker to cope with referencing external symbols defined in a shared
// library. Hence DynamicNoPIC doesn't need to be promoted to PIC.
- if (!RM.hasValue() || *RM == Reloc::DynamicNoPIC)
+ if (!RM || *RM == Reloc::DynamicNoPIC)
return Reloc::Static;
return *RM;
}
diff --git a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
index c6055b7116f7..c8e51b713550 100644
--- a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
+++ b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
@@ -6525,7 +6525,7 @@ AArch64InstructionSelector::selectAddrModeIndexed(MachineOperand &Root,
// Before falling back to our general case, check if the unscaled
// instructions can handle this. If so, that's preferable.
- if (selectAddrModeUnscaled(Root, Size).hasValue())
+ if (selectAddrModeUnscaled(Root, Size))
return None;
return {{
diff --git a/llvm/lib/Target/ARM/ARMTargetMachine.cpp b/llvm/lib/Target/ARM/ARMTargetMachine.cpp
index 7854078d88a7..d95c21d6504b 100644
--- a/llvm/lib/Target/ARM/ARMTargetMachine.cpp
+++ b/llvm/lib/Target/ARM/ARMTargetMachine.cpp
@@ -196,7 +196,7 @@ static std::string computeDataLayout(const Triple &TT, StringRef CPU,
static Reloc::Model getEffectiveRelocModel(const Triple &TT,
Optional<Reloc::Model> RM) {
- if (!RM.hasValue())
+ if (!RM)
// Default relocation model on Darwin is PIC.
return TT.isOSBinFormatMachO() ? Reloc::PIC_ : Reloc::Static;
diff --git a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
index fc40308be755..22fd29a3f844 100644
--- a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
@@ -11381,7 +11381,7 @@ bool ARMAsmParser::parseDirectiveEabiAttr(SMLoc L) {
StringRef Name = Parser.getTok().getIdentifier();
Optional<unsigned> Ret = ELFAttrs::attrTypeFromString(
Name, ARMBuildAttrs::getARMAttributeTags());
- if (!Ret.hasValue()) {
+ if (!Ret) {
Error(TagLoc, "attribute name not recognised: " + Name);
return false;
}
diff --git a/llvm/lib/Target/Mips/MipsTargetMachine.cpp b/llvm/lib/Target/Mips/MipsTargetMachine.cpp
index 7654b975ced2..fb0aa397d393 100644
--- a/llvm/lib/Target/Mips/MipsTargetMachine.cpp
+++ b/llvm/lib/Target/Mips/MipsTargetMachine.cpp
@@ -106,7 +106,7 @@ static std::string computeDataLayout(const Triple &TT, StringRef CPU,
static Reloc::Model getEffectiveRelocModel(bool JIT,
Optional<Reloc::Model> RM) {
- if (!RM.hasValue() || JIT)
+ if (!RM || JIT)
return Reloc::Static;
return *RM;
}
diff --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFStreamer.cpp b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFStreamer.cpp
index b0c0023000c7..b020635f4209 100644
--- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFStreamer.cpp
+++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFStreamer.cpp
@@ -98,7 +98,7 @@ void PPCELFStreamer::emitInstruction(const MCInst &Inst,
// For example, the load that will get the relocation as follows:
// .reloc .Lpcrel1-8,R_PPC64_PCREL_OPT,.-(.Lpcrel1-8)
// lwa 3, 4(3)
- if (IsPartOfGOTToPCRelPair.hasValue() && !IsPartOfGOTToPCRelPair.getValue())
+ if (IsPartOfGOTToPCRelPair && !*IsPartOfGOTToPCRelPair)
emitGOTToPCRelReloc(Inst);
// Special handling is only for prefixed instructions.
@@ -113,7 +113,7 @@ void PPCELFStreamer::emitInstruction(const MCInst &Inst,
// follows:
// pld 3, vec at got@pcrel(0), 1
// .Lpcrel1:
- if (IsPartOfGOTToPCRelPair.hasValue() && IsPartOfGOTToPCRelPair.getValue())
+ if (IsPartOfGOTToPCRelPair && *IsPartOfGOTToPCRelPair)
emitGOTToPCRelLabel(Inst);
}
diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index ecae1359bb37..e506c553dd54 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -2175,7 +2175,7 @@ bool RISCVAsmParser::parseDirectiveAttribute() {
StringRef Name = Parser.getTok().getIdentifier();
Optional<unsigned> Ret =
ELFAttrs::attrTypeFromString(Name, RISCVAttrs::getRISCVAttributeTags());
- if (!Ret.hasValue()) {
+ if (!Ret) {
Error(TagLoc, "attribute name not recognised: " + Name);
return false;
}
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 8dc10a99e427..b80dc298890c 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -9900,7 +9900,7 @@ static unsigned allocateRVVReg(MVT ValVT, unsigned ValNo,
// Assign the first mask argument to V0.
// This is an interim calling convention and it may be changed in the
// future.
- if (FirstMaskArgument.hasValue() && ValNo == FirstMaskArgument.getValue())
+ if (FirstMaskArgument && ValNo == *FirstMaskArgument)
return State.AllocateReg(RISCV::V0);
return State.AllocateReg(ArgVRs);
}
diff --git a/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp b/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
index cd223235f569..d571c17ee1fb 100644
--- a/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
@@ -118,7 +118,7 @@ static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) {
static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) {
// Static code is suitable for use in a dynamic executable; there is no
// separate DynamicNoPIC model.
- if (!RM.hasValue() || *RM == Reloc::DynamicNoPIC)
+ if (!RM || *RM == Reloc::DynamicNoPIC)
return Reloc::Static;
return *RM;
}
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
index f63f9f45f4e0..15416c42f926 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
@@ -211,7 +211,7 @@ MCSymbol *WebAssemblyAsmPrinter::getOrCreateWasmSymbol(StringRef Name) {
auto *WasmSym = cast<MCSymbolWasm>(GetExternalSymbolSymbol(Name));
// May be called multiple times, so early out.
- if (WasmSym->getType().hasValue())
+ if (WasmSym->getType())
return WasmSym;
const WebAssemblySubtarget &Subtarget = getSubtarget();
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
index 93dd5466fdd8..76f036358ae8 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
@@ -87,7 +87,7 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeWebAssemblyTarget() {
static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM,
const Triple &TT) {
- if (!RM.hasValue()) {
+ if (!RM) {
// Default to static relocation model. This should always be more optimial
// than PIC since the static linker can determine all global addresses and
// assume direct function calls.
diff --git a/llvm/lib/Target/X86/X86TargetMachine.cpp b/llvm/lib/Target/X86/X86TargetMachine.cpp
index 3818a4955821..af6fed5dbde0 100644
--- a/llvm/lib/Target/X86/X86TargetMachine.cpp
+++ b/llvm/lib/Target/X86/X86TargetMachine.cpp
@@ -158,7 +158,7 @@ static Reloc::Model getEffectiveRelocModel(const Triple &TT,
bool JIT,
Optional<Reloc::Model> RM) {
bool is64Bit = TT.getArch() == Triple::x86_64;
- if (!RM.hasValue()) {
+ if (!RM) {
// JIT codegen should use static relocations by default, since it's
// typically executed in process and not relocatable.
if (JIT)
diff --git a/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp b/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
index 7ecde3ce284a..5f4d0cdf2b57 100644
--- a/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
+++ b/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
@@ -77,7 +77,7 @@ static std::vector<StringRef> getSearchPaths(opt::InputArgList *Args,
// Add $LIB.
Optional<std::string> EnvOpt = sys::Process::GetEnv("LIB");
- if (!EnvOpt.hasValue())
+ if (!EnvOpt)
return Ret;
StringRef Env = Saver.save(*EnvOpt);
while (!Env.empty()) {
diff --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
index 62620dce61d7..dd9f315888f0 100644
--- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
@@ -1479,7 +1479,7 @@ struct AllocaUseVisitor : PtrUseVisitor<AllocaUseVisitor> {
auto Itr = AliasOffetMap.find(&I);
if (Itr == AliasOffetMap.end()) {
AliasOffetMap[&I] = Offset;
- } else if (Itr->second.hasValue() && Itr->second.getValue() != Offset) {
+ } else if (Itr->second && *Itr->second != Offset) {
// If we have seen two
diff erent possible values for this alias, we set
// it to empty.
AliasOffetMap[&I].reset();
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index da309dce25d4..221e688d9066 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -709,7 +709,7 @@ Argument *IRPosition::getAssociatedArgument() const {
assert(ACS.getCalledFunction()->arg_size() > u &&
"ACS mapped into var-args arguments!");
- if (CBCandidateArg.hasValue()) {
+ if (CBCandidateArg) {
CBCandidateArg = nullptr;
break;
}
@@ -1030,7 +1030,7 @@ Attributor::getAssumedConstant(const IRPosition &IRP,
// assume it's simplified.
for (auto &CB : SimplificationCallbacks.lookup(IRP)) {
Optional<Value *> SimplifiedV = CB(IRP, &AA, UsedAssumedInformation);
- if (!SimplifiedV.hasValue())
+ if (!SimplifiedV)
return llvm::None;
if (isa_and_nonnull<Constant>(*SimplifiedV))
return cast<Constant>(*SimplifiedV);
@@ -1044,7 +1044,7 @@ Attributor::getAssumedConstant(const IRPosition &IRP,
ValueSimplifyAA.getAssumedSimplifiedValue(*this);
bool IsKnown = ValueSimplifyAA.isAtFixpoint();
UsedAssumedInformation |= !IsKnown;
- if (!SimplifiedV.hasValue()) {
+ if (!SimplifiedV) {
recordDependence(ValueSimplifyAA, AA, DepClassTy::OPTIONAL);
return llvm::None;
}
@@ -1078,7 +1078,7 @@ Attributor::getAssumedSimplified(const IRPosition &IRP,
ValueSimplifyAA.getAssumedSimplifiedValue(*this);
bool IsKnown = ValueSimplifyAA.isAtFixpoint();
UsedAssumedInformation |= !IsKnown;
- if (!SimplifiedV.hasValue()) {
+ if (!SimplifiedV) {
if (AA)
recordDependence(ValueSimplifyAA, *AA, DepClassTy::OPTIONAL);
return llvm::None;
@@ -1097,7 +1097,7 @@ Attributor::getAssumedSimplified(const IRPosition &IRP,
Optional<Value *> Attributor::translateArgumentToCallSiteContent(
Optional<Value *> V, CallBase &CB, const AbstractAttribute &AA,
bool &UsedAssumedInformation) {
- if (!V.hasValue())
+ if (!V)
return V;
if (*V == nullptr || isa<Constant>(*V))
return V;
@@ -3159,7 +3159,7 @@ raw_ostream &llvm::operator<<(raw_ostream &OS,
OS << " [" << Acc.getKind() << "] " << *Acc.getRemoteInst();
if (Acc.getLocalInst() != Acc.getRemoteInst())
OS << " via " << *Acc.getLocalInst();
- if (Acc.getContent().hasValue()) {
+ if (Acc.getContent()) {
if (*Acc.getContent())
OS << " [" << **Acc.getContent() << "]";
else
diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index cc72b1be7607..9a4dce398fb8 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -551,7 +551,7 @@ static void clampReturnedValueStates(
LLVM_DEBUG(dbgs() << "[Attributor] RV: " << RV << " AA: " << AA.getAsStr()
<< " @ " << RVPos << "\n");
const StateType &AAS = AA.getState();
- if (!T.hasValue())
+ if (!T)
T = StateType::getBestState(AAS);
*T &= AAS;
LLVM_DEBUG(dbgs() << "[Attributor] AA State: " << AAS << " RV State: " << T
@@ -561,7 +561,7 @@ static void clampReturnedValueStates(
if (!A.checkForAllReturnedValues(CheckReturnValue, QueryingAA))
S.indicatePessimisticFixpoint();
- else if (T.hasValue())
+ else if (T)
S ^= *T;
}
@@ -617,7 +617,7 @@ static void clampCallSiteArgumentStates(Attributor &A, const AAType &QueryingAA,
LLVM_DEBUG(dbgs() << "[Attributor] ACS: " << *ACS.getInstruction()
<< " AA: " << AA.getAsStr() << " @" << ACSArgPos << "\n");
const StateType &AAS = AA.getState();
- if (!T.hasValue())
+ if (!T)
T = StateType::getBestState(AAS);
*T &= AAS;
LLVM_DEBUG(dbgs() << "[Attributor] AA State: " << AAS << " CSA State: " << T
@@ -629,7 +629,7 @@ static void clampCallSiteArgumentStates(Attributor &A, const AAType &QueryingAA,
if (!A.checkForAllCallSites(CallSiteCheck, QueryingAA, true,
UsedAssumedInformation))
S.indicatePessimisticFixpoint();
- else if (T.hasValue())
+ else if (T)
S ^= *T;
}
@@ -2667,7 +2667,7 @@ struct AAUndefinedBehaviorImpl : public AAUndefinedBehavior {
// or we got back a simplified value to continue.
Optional<Value *> SimplifiedCond =
stopOnUndefOrAssumed(A, BrInst->getCondition(), BrInst);
- if (!SimplifiedCond.hasValue() || !SimplifiedCond.getValue())
+ if (!SimplifiedCond || !*SimplifiedCond)
return true;
AssumedNoUBInsts.insert(&I);
return true;
@@ -2737,7 +2737,7 @@ struct AAUndefinedBehaviorImpl : public AAUndefinedBehavior {
// or we got back a simplified return value to continue.
Optional<Value *> SimplifiedRetValue =
stopOnUndefOrAssumed(A, RI.getReturnValue(), &I);
- if (!SimplifiedRetValue.hasValue() || !SimplifiedRetValue.getValue())
+ if (!SimplifiedRetValue || !*SimplifiedRetValue)
return true;
// Check if a return instruction always cause UB or not
@@ -2886,7 +2886,7 @@ struct AAUndefinedBehaviorImpl : public AAUndefinedBehavior {
IRPosition::value(*V), *this, UsedAssumedInformation);
if (!UsedAssumedInformation) {
// Don't depend on assumed values.
- if (!SimplifiedV.hasValue()) {
+ if (!SimplifiedV) {
// If it is known (which we tested above) but it doesn't have a value,
// then we can assume `undef` and hence the instruction is UB.
KnownUBInsts.insert(I);
@@ -3529,7 +3529,7 @@ struct AAIsDeadValueImpl : public AAIsDead {
bool UsedAssumedInformation = false;
Optional<Constant *> C =
A.getAssumedConstant(V, *this, UsedAssumedInformation);
- if (!C.hasValue() || *C)
+ if (!C || *C)
return true;
}
@@ -4036,7 +4036,7 @@ identifyAliveSuccessors(Attributor &A, const BranchInst &BI,
} else {
Optional<Constant *> C =
A.getAssumedConstant(*BI.getCondition(), AA, UsedAssumedInformation);
- if (!C.hasValue() || isa_and_nonnull<UndefValue>(C.getValue())) {
+ if (!C || isa_and_nonnull<UndefValue>(*C)) {
// No value yet, assume both edges are dead.
} else if (isa_and_nonnull<ConstantInt>(*C)) {
const BasicBlock *SuccBB =
@@ -5374,7 +5374,7 @@ bool ValueSimplifyStateType::unionAssumed(Optional<Value *> Other) {
return false;
LLVM_DEBUG({
- if (SimplifiedAssociatedValue.hasValue())
+ if (SimplifiedAssociatedValue)
dbgs() << "[ValueSimplify] is assumed to be "
<< **SimplifiedAssociatedValue << "\n";
else
@@ -5535,7 +5535,7 @@ struct AAValueSimplifyImpl : AAValueSimplify {
Optional<Constant *> COpt = AA.getAssumedConstant(A);
- if (!COpt.hasValue()) {
+ if (!COpt) {
SimplifiedAssociatedValue = llvm::None;
A.recordDependence(AA, *this, DepClassTy::OPTIONAL);
return true;
@@ -6228,7 +6228,7 @@ struct AAHeapToStackFunction final : public AAHeapToStack {
const DataLayout &DL = A.getInfoCache().getDL();
Value *Size;
Optional<APInt> SizeAPI = getSize(A, *this, AI);
- if (SizeAPI.hasValue()) {
+ if (SizeAPI) {
Size = ConstantInt::get(AI.CB->getContext(), *SizeAPI);
} else {
LLVMContext &Ctx = AI.CB->getContext();
diff --git a/llvm/lib/Transforms/IPO/IROutliner.cpp b/llvm/lib/Transforms/IPO/IROutliner.cpp
index d30bd097349f..136aaed0c8df 100644
--- a/llvm/lib/Transforms/IPO/IROutliner.cpp
+++ b/llvm/lib/Transforms/IPO/IROutliner.cpp
@@ -1183,7 +1183,7 @@ static Optional<unsigned> getGVNForPHINode(OutlinableRegion &Region,
// adding an extra input. We ignore this case for now, and so ignore the
// region.
Optional<unsigned> OGVN = Cand.getGVN(Incoming);
- if (!OGVN.hasValue() && Blocks.contains(IncomingBlock)) {
+ if (!OGVN && Blocks.contains(IncomingBlock)) {
Region.IgnoreRegion = true;
return None;
}
@@ -1206,7 +1206,7 @@ static Optional<unsigned> getGVNForPHINode(OutlinableRegion &Region,
// If there is no number for the incoming block, it is becaause we have
// split the candidate basic blocks. So we use the previous block that it
// was split from to find the valid global value numbering for the PHINode.
- if (!OGVN.hasValue()) {
+ if (!OGVN) {
assert(Cand.getStartBB() == IncomingBlock &&
"Unknown basic block used in exit path PHINode.");
@@ -1367,7 +1367,7 @@ findExtractedOutputToOverallOutputMapping(OutlinableRegion &Region,
// If two PHINodes have the same canonical values, but
diff erent aggregate
// argument locations, then they will have distinct Canonical Values.
GVN = getGVNForPHINode(Region, PN, BlocksInRegion, AggArgIdx);
- if (!GVN.hasValue())
+ if (!GVN)
return;
} else {
// If we do not have a PHINode we use the global value numbering for the
@@ -1883,7 +1883,7 @@ replaceArgumentUses(OutlinableRegion &Region,
PHINode *PN = cast<PHINode>(SI->getValueOperand());
// If it has a value, it was not split by the code extractor, which
// is what we are looking for.
- if (Region.Candidate->getGVN(PN).hasValue())
+ if (Region.Candidate->getGVN(PN))
continue;
// We record the parent block for the PHINode in the Region so that
@@ -2678,7 +2678,7 @@ void IROutliner::updateOutputMapping(OutlinableRegion &Region,
// If we found an output register, place a mapping of the new value
// to the original in the mapping.
- if (!OutputIdx.hasValue())
+ if (!OutputIdx)
return;
if (OutputMappings.find(Outputs[OutputIdx.getValue()]) ==
diff --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
index 99b996ad57ed..e687641395cf 100644
--- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -2545,7 +2545,7 @@ struct AAICVTrackerFunction : public AAICVTracker {
}
// If we are in the same BB and we have a value, we are done.
- if (CurrBB == I->getParent() && ReplVal.hasValue())
+ if (CurrBB == I->getParent() && ReplVal)
return ReplVal;
// Go through all predecessors and add terminators for analysis.
@@ -2603,7 +2603,7 @@ struct AAICVTrackerFunctionReturned : AAICVTracker {
ICVTrackingAA.getReplacementValue(ICV, &I, A);
// If we found a second ICV value there is no unique returned value.
- if (UniqueICVValue.hasValue() && UniqueICVValue != NewReplVal)
+ if (UniqueICVValue && UniqueICVValue != NewReplVal)
return false;
UniqueICVValue = NewReplVal;
@@ -2654,7 +2654,7 @@ struct AAICVTrackerCallSite : AAICVTracker {
}
ChangeStatus manifest(Attributor &A) override {
- if (!ReplVal.hasValue() || !ReplVal.getValue())
+ if (!ReplVal || !*ReplVal)
return ChangeStatus::UNCHANGED;
A.changeAfterManifest(IRPosition::inst(*getCtxI()), **ReplVal);
@@ -4494,7 +4494,7 @@ struct AAFoldRuntimeCallCallSiteReturned : AAFoldRuntimeCall {
ChangeStatus manifest(Attributor &A) override {
ChangeStatus Changed = ChangeStatus::UNCHANGED;
- if (SimplifiedValue.hasValue() && SimplifiedValue.getValue()) {
+ if (SimplifiedValue && *SimplifiedValue) {
Instruction &I = *getCtxI();
A.changeAfterManifest(IRPosition::inst(I), **SimplifiedValue);
A.deleteAfterManifest(I);
diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp
index bdc792d9dc36..8cf3a64e928e 100644
--- a/llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -2180,7 +2180,7 @@ bool SampleProfileLoader::runOnFunction(Function &F, ModuleAnalysisManager *AM)
// Initialize entry count when the function has no existing entry
// count value.
- if (!F.getEntryCount().hasValue())
+ if (!F.getEntryCount())
F.setEntryCount(ProfileCount(initialEntryCount, Function::PCT_Real));
std::unique_ptr<OptimizationRemarkEmitter> OwnedORE;
if (AM) {
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 759d724192a3..449c0f178bf4 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -3142,7 +3142,7 @@ Instruction *InstCombinerImpl::visitCallBase(CallBase &Call) {
Optional<OperandBundleUse> Bundle =
GCSP.getOperandBundle(LLVMContext::OB_gc_live);
unsigned NumOfGCLives = LiveGcValues.size();
- if (!Bundle.hasValue() || NumOfGCLives == Bundle->Inputs.size())
+ if (!Bundle || NumOfGCLives == Bundle->Inputs.size())
break;
// We can reduce the size of gc live bundle.
DenseMap<Value *, unsigned> Val2Idx;
diff --git a/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp b/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
index fbb5de7b02a9..0005ea9116ce 100644
--- a/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
@@ -1409,7 +1409,7 @@ bool LoopConstrainer::run() {
bool IsSignedPredicate = MainLoopStructure.IsSignedPredicate;
Optional<SubRanges> MaybeSR = calculateSubRanges(IsSignedPredicate);
- if (!MaybeSR.hasValue()) {
+ if (!MaybeSR) {
LLVM_DEBUG(dbgs() << "irce: could not compute subranges\n");
return false;
}
@@ -1856,7 +1856,7 @@ InductiveRangeCheckElimination::isProfitableToTransform(const Loop &L,
LoopStructure &LS) {
if (SkipProfitabilityChecks)
return true;
- if (GetBFI.hasValue()) {
+ if (GetBFI) {
BlockFrequencyInfo &BFI = (*GetBFI)();
uint64_t hFreq = BFI.getBlockFreq(LS.Header).getFrequency();
uint64_t phFreq = BFI.getBlockFreq(L.getLoopPreheader()).getFrequency();
@@ -1922,7 +1922,7 @@ bool InductiveRangeCheckElimination::run(
const char *FailureReason = nullptr;
Optional<LoopStructure> MaybeLoopStructure =
LoopStructure::parseLoopStructure(SE, *L, FailureReason);
- if (!MaybeLoopStructure.hasValue()) {
+ if (!MaybeLoopStructure) {
LLVM_DEBUG(dbgs() << "irce: could not parse loop structure: "
<< FailureReason << "\n";);
return false;
diff --git a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
index 85dc56cf89eb..5f23ebf53a9a 100644
--- a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
+++ b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
@@ -298,7 +298,7 @@ static ArrayRef<Use> GetDeoptBundleOperands(const CallBase *Call) {
Optional<OperandBundleUse> DeoptBundle =
Call->getOperandBundle(LLVMContext::OB_deopt);
- if (!DeoptBundle.hasValue()) {
+ if (!DeoptBundle) {
assert(AllowStatepointWithNoDeoptInfo &&
"Found non-leaf call without deopt info!");
return None;
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index 03cb9e2cc136..29a5e0234b84 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -1609,7 +1609,7 @@ void llvm::updateProfileCallee(
Function *Callee, int64_t EntryDelta,
const ValueMap<const Value *, WeakTrackingVH> *VMap) {
auto CalleeCount = Callee->getEntryCount();
- if (!CalleeCount.hasValue())
+ if (!CalleeCount)
return;
const uint64_t PriorEntryCount = CalleeCount->getCount();
diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp
index 5d16a1e5239d..b7656f43490b 100644
--- a/llvm/lib/Transforms/Utils/LoopUtils.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp
@@ -254,7 +254,7 @@ llvm::getOptionalElementCountLoopAttribute(const Loop *TheLoop) {
Optional<int> Width =
getOptionalIntLoopAttribute(TheLoop, "llvm.loop.vectorize.width");
- if (Width.hasValue()) {
+ if (Width) {
Optional<int> IsScalable = getOptionalIntLoopAttribute(
TheLoop, "llvm.loop.vectorize.scalable.enable");
return ElementCount::get(*Width, IsScalable.value_or(false));
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 8aac36c76c15..ba930c49e05c 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -5861,7 +5861,7 @@ InstructionCost BoUpSLP::getEntryCost(const TreeEntry *E,
SmallVector<const TreeEntry *> Entries;
Optional<TargetTransformInfo::ShuffleKind> Shuffle =
isGatherShuffledEntry(E, Mask, Entries);
- if (Shuffle.hasValue()) {
+ if (Shuffle) {
InstructionCost GatherCost = 0;
if (ShuffleVectorInst::isIdentityMask(Mask)) {
// Perfect match in the graph, will reuse the previously vectorized
@@ -5897,7 +5897,7 @@ InstructionCost BoUpSLP::getEntryCost(const TreeEntry *E,
SmallVector<int> Mask;
Optional<TargetTransformInfo::ShuffleKind> ShuffleKind =
isFixedVectorShuffle(VL, Mask);
- if (ShuffleKind.hasValue()) {
+ if (ShuffleKind) {
// Found the bunch of extractelement instructions that must be gathered
// into a vector and can be represented as a permutation elements in a
// single input vector or of 2 input vectors.
@@ -7768,7 +7768,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) {
SmallVector<const TreeEntry *> Entries;
Optional<TargetTransformInfo::ShuffleKind> Shuffle =
isGatherShuffledEntry(E, Mask, Entries);
- if (Shuffle.hasValue()) {
+ if (Shuffle) {
assert((Entries.size() == 1 || Entries.size() == 2) &&
"Expected shuffle of 1 or 2 entries.");
Vec = Builder.CreateShuffleVector(Entries.front()->VectorizedValue,
diff --git a/llvm/tools/llc/llc.cpp b/llvm/tools/llc/llc.cpp
index 98a2c7327b1a..c4b8adb399e9 100644
--- a/llvm/tools/llc/llc.cpp
+++ b/llvm/tools/llc/llc.cpp
@@ -546,7 +546,7 @@ static int compileModule(char **argv, LLVMContext &Context) {
// On AIX, setting the relocation model to anything other than PIC is
// considered a user error.
- if (TheTriple.isOSAIX() && RM.hasValue() && *RM != Reloc::PIC_)
+ if (TheTriple.isOSAIX() && RM && *RM != Reloc::PIC_)
reportError("invalid relocation model, AIX only supports PIC",
InputFilename);
@@ -589,7 +589,7 @@ static int compileModule(char **argv, LLVMContext &Context) {
// On AIX, setting the relocation model to anything other than PIC is
// considered a user error.
- if (TheTriple.isOSAIX() && RM.hasValue() && *RM != Reloc::PIC_) {
+ if (TheTriple.isOSAIX() && RM && *RM != Reloc::PIC_) {
WithColor::error(errs(), argv[0])
<< "invalid relocation model, AIX only supports PIC.\n";
return 1;
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index aa4b3f97fed4..0fc0913197cd 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -2283,7 +2283,7 @@ static void printFaultMaps(const ObjectFile *Obj) {
outs() << "FaultMap table:\n";
- if (!FaultMapSection.hasValue()) {
+ if (!FaultMapSection) {
outs() << "<not found>\n";
return;
}
diff --git a/llvm/tools/llvm-pdbutil/BytesOutputStyle.cpp b/llvm/tools/llvm-pdbutil/BytesOutputStyle.cpp
index 584d83512036..4c851e14a12d 100644
--- a/llvm/tools/llvm-pdbutil/BytesOutputStyle.cpp
+++ b/llvm/tools/llvm-pdbutil/BytesOutputStyle.cpp
@@ -87,7 +87,7 @@ BytesOutputStyle::BytesOutputStyle(PDBFile &File)
Error BytesOutputStyle::dump() {
- if (opts::bytes::DumpBlockRange.hasValue()) {
+ if (opts::bytes::DumpBlockRange) {
auto &R = *opts::bytes::DumpBlockRange;
uint32_t Max = R.Max.value_or(R.Min);
@@ -104,7 +104,7 @@ Error BytesOutputStyle::dump() {
P.NewLine();
}
- if (opts::bytes::DumpByteRange.hasValue()) {
+ if (opts::bytes::DumpByteRange) {
auto &R = *opts::bytes::DumpByteRange;
uint32_t Max = R.Max.value_or(File.getFileSize());
diff --git a/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp b/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp
index 1b367029c555..3b922a7bea21 100644
--- a/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp
+++ b/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp
@@ -791,7 +791,7 @@ static void yamlToPdb(StringRef Path) {
PDBFileBuilder Builder(Allocator);
uint32_t BlockSize = 4096;
- if (YamlObj.Headers.hasValue())
+ if (YamlObj.Headers)
BlockSize = YamlObj.Headers->SuperBlock.BlockSize;
ExitOnErr(Builder.initialize(BlockSize));
// Add each of the reserved streams. We ignore stream metadata in the
@@ -806,7 +806,7 @@ static void yamlToPdb(StringRef Path) {
StringsAndChecksums Strings;
Strings.setStrings(std::make_shared<DebugStringTableSubsection>());
- if (YamlObj.StringTable.hasValue()) {
+ if (YamlObj.StringTable) {
for (auto S : *YamlObj.StringTable)
Strings.strings()->insert(S);
}
@@ -841,7 +841,7 @@ static void yamlToPdb(StringRef Path) {
for (auto S : MI.SourceFiles)
ExitOnErr(DbiBuilder.addModuleSourceFile(ModiBuilder, S));
- if (MI.Modi.hasValue()) {
+ if (MI.Modi) {
const auto &ModiStream = *MI.Modi;
for (auto Symbol : ModiStream.Symbols) {
ModiBuilder.addSymbol(
diff --git a/llvm/tools/llvm-profgen/ProfileGenerator.cpp b/llvm/tools/llvm-profgen/ProfileGenerator.cpp
index 0bc82efe8426..a7c418154758 100644
--- a/llvm/tools/llvm-profgen/ProfileGenerator.cpp
+++ b/llvm/tools/llvm-profgen/ProfileGenerator.cpp
@@ -824,7 +824,7 @@ void CSProfileGenerator::populateBodySamplesForFunction(
do {
uint64_t Offset = Binary->virtualAddrToOffset(IP.Address);
auto LeafLoc = Binary->getInlineLeafFrameLoc(Offset);
- if (LeafLoc.hasValue()) {
+ if (LeafLoc) {
// Recording body sample for this specific context
updateBodySamplesforFunctionProfile(FunctionProfile, *LeafLoc, Count);
FunctionProfile.addTotalSamples(Count);
@@ -853,7 +853,7 @@ void CSProfileGenerator::populateBoundarySamplesForFunction(
"CallerProfile is null only if ContextId is empty");
// Record called target sample and its count
auto LeafLoc = Binary->getInlineLeafFrameLoc(SourceOffset);
- if (LeafLoc.hasValue()) {
+ if (LeafLoc) {
CallerProfile->addCalledTargetSamples(
LeafLoc->Location.LineOffset,
getBaseDiscriminator(LeafLoc->Location.Discriminator), CalleeName,
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 0597dd979daf..6b27b11d95db 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -5934,7 +5934,7 @@ template <class ELFT>
SmallVector<uint32_t> ELFDumper<ELFT>::getSymbolIndexesForFunctionAddress(
uint64_t SymValue, Optional<const Elf_Shdr *> FunctionSec) {
SmallVector<uint32_t> SymbolIndexes;
- if (!this->AddressToIndexMap.hasValue()) {
+ if (!this->AddressToIndexMap) {
// Populate the address to index map upon the first invocation of this
// function.
this->AddressToIndexMap.emplace();
diff --git a/llvm/utils/TableGen/GICombinerEmitter.cpp b/llvm/utils/TableGen/GICombinerEmitter.cpp
index 3ab44ae52844..77e05aebf53a 100644
--- a/llvm/utils/TableGen/GICombinerEmitter.cpp
+++ b/llvm/utils/TableGen/GICombinerEmitter.cpp
@@ -933,7 +933,7 @@ void GICombinerEmitter::run(raw_ostream &OS) {
"getRuleIdxForIdentifier(RangePair.first);\n"
<< " const auto Last = "
"getRuleIdxForIdentifier(RangePair.second);\n"
- << " if (!First.hasValue() || !Last.hasValue())\n"
+ << " if (!First || !Last)\n"
<< " return None;\n"
<< " if (First >= Last)\n"
<< " report_fatal_error(\"Beginning of range should be before "
@@ -944,7 +944,7 @@ void GICombinerEmitter::run(raw_ostream &OS) {
<< " return {{0, " << Rules.size() << "}};\n"
<< " }\n"
<< " const auto I = getRuleIdxForIdentifier(RangePair.first);\n"
- << " if (!I.hasValue())\n"
+ << " if (!I)\n"
<< " return None;\n"
<< " return {{*I, *I + 1}};\n"
<< "}\n\n";
@@ -953,7 +953,7 @@ void GICombinerEmitter::run(raw_ostream &OS) {
OS << "bool " << getClassName() << "RuleConfig::setRule"
<< (Enabled ? "Enabled" : "Disabled") << "(StringRef RuleIdentifier) {\n"
<< " auto MaybeRange = getRuleRangeForIdentifier(RuleIdentifier);\n"
- << " if (!MaybeRange.hasValue())\n"
+ << " if (!MaybeRange)\n"
<< " return false;\n"
<< " for (auto I = MaybeRange->first; I < MaybeRange->second; ++I)\n"
<< " DisabledRules." << (Enabled ? "reset" : "set") << "(I);\n"
diff --git a/llvm/utils/TableGen/GlobalISelEmitter.cpp b/llvm/utils/TableGen/GlobalISelEmitter.cpp
index 3f7b3f5ddf04..2c2c3c21c3df 100644
--- a/llvm/utils/TableGen/GlobalISelEmitter.cpp
+++ b/llvm/utils/TableGen/GlobalISelEmitter.cpp
@@ -4273,7 +4273,7 @@ Error GlobalISelEmitter::importChildMatcher(
auto MaybeInsnOperand = OM.addPredicate<InstructionOperandMatcher>(
InsnMatcher.getRuleMatcher(), SrcChild->getName());
- if (!MaybeInsnOperand.hasValue()) {
+ if (!MaybeInsnOperand) {
// This isn't strictly true. If the user were to provide exactly the same
// matchers as the original operand then we could allow it. However, it's
// simpler to not permit the redundant specification.
@@ -4404,7 +4404,7 @@ Expected<action_iterator> GlobalISelEmitter::importExplicitUseRenderer(
TreePatternNode *DstChild) {
const auto &SubOperand = Rule.getComplexSubOperand(DstChild->getName());
- if (SubOperand.hasValue()) {
+ if (SubOperand) {
DstMIBuilder.addRenderer<RenderComplexPatternOperand>(
*std::get<0>(*SubOperand), DstChild->getName(),
std::get<1>(*SubOperand), std::get<2>(*SubOperand));
@@ -4806,7 +4806,7 @@ Expected<action_iterator> GlobalISelEmitter::importExplicitUseRenderers(
const auto SrcRCDstRCPair =
RC->getMatchingSubClassWithSubRegs(CGRegs, SubIdx);
- if (SrcRCDstRCPair.hasValue()) {
+ if (SrcRCDstRCPair) {
assert(SrcRCDstRCPair->second && "Couldn't find a matching subclass");
if (SrcRCDstRCPair->first != RC)
return failedImport("EXTRACT_SUBREG requires an additional COPY");
More information about the llvm-commits
mailing list