// 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();
/// 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");
Optional<uint32_t> MaxLength;
Optional<uint32_t> bytesRemaining(uint32_t CurrentOffset) const {
- if (!MaxLength.hasValue())
+ if (!MaxLength)
return None;
assert(CurrentOffset >= BeginOffset);
}
bool ParseCurrentAnnotation() {
- if (Current.hasValue())
+ if (Current)
return true;
Next = Data;
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;
}
uint64_t getLength() const {
- if (Length.hasValue())
+ if (Length)
return *Length;
return BorrowedImpl ? (BorrowedImpl->getLength() - ViewOffset) : 0;
return Result;
Result.ViewOffset += N;
- if (Result.Length.hasValue())
+ if (Result.Length)
*Result.Length -= N;
return Result;
}
// 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;
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);
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);
auto &RetParamAttributes = Summary->RetParamAttributes;
for (auto &Attribute : RetParamAttributes) {
auto IAttr = instantiateExternalAttribute(Attribute, Call);
- if (IAttr.hasValue())
+ if (IAttr)
Graph.addNode(IAttr->IValue, IAttr->Attr);
}
}
assert(RetVal != nullptr);
assert(RetVal->getType()->isPointerTy());
auto RetInfo = Sets.find(InstantiatedValue{RetVal, 0});
- if (RetInfo.hasValue())
+ if (RetInfo)
AddToRetParamRelations(0, RetInfo->Index);
}
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;
// Here we collect the operands and their types for determining whether
// the structure of the operand use matches between two different 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());
}
const char *InlineAdvisor::getAnnotatedInlinePassName() {
- if (!IC.hasValue())
+ if (!IC)
return DEBUG_TYPE;
// IC is constant and initialized in constructor, so compute the annotated
auto TrivialDecision =
llvm::getAttributeBasedInliningDecision(CB, &Callee, TIR, GetTLI);
- if (TrivialDecision.hasValue()) {
+ if (TrivialDecision) {
if (TrivialDecision->isSuccess())
return MandatoryInliningKind::Always;
else
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());
// @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;
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);
FalseValue = *FalseVal;
// Re-apply the cast we peeled off earlier
- if (CastOp.hasValue())
+ if (CastOp)
switch (*CastOp) {
default:
llvm_unreachable("Unknown SCEV cast type!");
/// 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))
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
// 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.
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);
// 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)
// 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
// 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}}))
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);
const MachineBlockFrequencyInfo *MBFI,
ProfileSummaryInfo *PSI) {
Optional<uint64_t> Count = MBFI->getBlockProfileCount(&MBB);
- if (!Count.hasValue())
+ if (!Count)
return true;
if (PercentileCutoff > 0) {
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) {
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
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;
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());
}
}
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 "
// 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");
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
// 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);
#include "llvm/IR/VPIntrinsics.def"
}
- if (!ResOPC.hasValue())
+ if (!ResOPC)
llvm_unreachable(
"Inconsistency: no SDNode available for this VPIntrinsic!");
const int LookUpDepth = 6;
Optional<int> Index =
findPreviousSpillSlot(IncomingValue, Builder, LookUpDepth);
- if (!Index.hasValue())
+ if (!Index)
return;
const auto &StatepointSlots = Builder.FuncInfo.StatepointStackSlots;
// 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;
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());
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;
}
}
- if (AugmentationLength.hasValue()) {
+ if (AugmentationLength) {
if (Offset != EndAugmentationOffset)
return createStringError(errc::invalid_argument,
"parsing augmentation data at 0x%" PRIx64
// 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.
}
// 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.
}
void DbiStreamBuilder::addNewFpoData(const codeview::FrameData &FD) {
- if (!NewFpoData.hasValue())
+ if (!NewFpoData)
NewFpoData.emplace(false);
NewFpoData->addFrameData(FD);
}
Error DbiStreamBuilder::finalizeMsfLayout() {
- if (NewFpoData.hasValue()) {
+ if (NewFpoData) {
DbgStreams[(int)DbgHeaderType::NewFPO].emplace();
DbgStreams[(int)DbgHeaderType::NewFPO]->Size =
NewFpoData->calculateSerializedSize();
}
for (auto &S : DbgStreams) {
- if (!S.hasValue())
+ if (!S)
continue;
auto ExpectedIndex = Msf.addStream(S->Size);
if (!ExpectedIndex)
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);
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);
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);
// 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
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",
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) {
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).
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 =
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;
}
}
- if (!ExpandedValue.hasValue())
+ if (!ExpandedValue)
return true;
std::unique_ptr<MemoryBuffer> Instantiation =
MemoryBuffer::getMemBufferCopy(*ExpandedValue, "<instantiation>");
if (Body[Pos] == '&')
break;
if (isMacroParameterChar(Body[Pos])) {
- if (!CurrentQuote.hasValue())
+ if (!CurrentQuote)
break;
if (IdentifierPos == End)
IdentifierPos = Pos;
}
// Track quotation status
- if (!CurrentQuote.hasValue()) {
+ if (!CurrentQuote) {
if (Body[Pos] == '\'' || Body[Pos] == '"')
CurrentQuote = Body[Pos];
} else if (Body[Pos] == CurrentQuote) {
ParseStatementInfo Info(&AsmStrRewrites);
bool Parsed = parseStatement(Info, nullptr);
- if (!Parsed && Info.ExitValue.hasValue()) {
+ if (!Parsed && Info.ExitValue) {
ExitValue = std::move(*Info.ExitValue);
break;
}
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;
}
}
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.
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);
}
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 {
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
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.
void AArch64FunctionInfo::initializeBaseYamlFields(
const yaml::AArch64FunctionInfo &YamlMFI) {
- if (YamlMFI.HasRedZone.hasValue())
+ if (YamlMFI.HasRedZone)
HasRedZone = YamlMFI.HasRedZone;
}
// 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;
}
// 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 {{
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;
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;
}
static Reloc::Model getEffectiveRelocModel(bool JIT,
Optional<Reloc::Model> RM) {
- if (!RM.hasValue() || JIT)
+ if (!RM || JIT)
return Reloc::Static;
return *RM;
}
// 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.
// follows:
// pld 3, vec@got@pcrel(0), 1
// .Lpcrel1:
- if (IsPartOfGOTToPCRelPair.hasValue() && IsPartOfGOTToPCRelPair.getValue())
+ if (IsPartOfGOTToPCRelPair && *IsPartOfGOTToPCRelPair)
emitGOTToPCRelLabel(Inst);
}
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;
}
// 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);
}
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;
}
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();
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.
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)
// 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()) {
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 different possible values for this alias, we set
// it to empty.
AliasOffetMap[&I].reset();
assert(ACS.getCalledFunction()->arg_size() > u &&
"ACS mapped into var-args arguments!");
- if (CBCandidateArg.hasValue()) {
+ if (CBCandidateArg) {
CBCandidateArg = nullptr;
break;
}
// 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);
ValueSimplifyAA.getAssumedSimplifiedValue(*this);
bool IsKnown = ValueSimplifyAA.isAtFixpoint();
UsedAssumedInformation |= !IsKnown;
- if (!SimplifiedV.hasValue()) {
+ if (!SimplifiedV) {
recordDependence(ValueSimplifyAA, AA, DepClassTy::OPTIONAL);
return llvm::None;
}
ValueSimplifyAA.getAssumedSimplifiedValue(*this);
bool IsKnown = ValueSimplifyAA.isAtFixpoint();
UsedAssumedInformation |= !IsKnown;
- if (!SimplifiedV.hasValue()) {
+ if (!SimplifiedV) {
if (AA)
recordDependence(ValueSimplifyAA, *AA, DepClassTy::OPTIONAL);
return llvm::None;
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;
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
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
if (!A.checkForAllReturnedValues(CheckReturnValue, QueryingAA))
S.indicatePessimisticFixpoint();
- else if (T.hasValue())
+ else if (T)
S ^= *T;
}
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
if (!A.checkForAllCallSites(CallSiteCheck, QueryingAA, true,
UsedAssumedInformation))
S.indicatePessimisticFixpoint();
- else if (T.hasValue())
+ else if (T)
S ^= *T;
}
// 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;
// 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
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);
bool UsedAssumedInformation = false;
Optional<Constant *> C =
A.getAssumedConstant(V, *this, UsedAssumedInformation);
- if (!C.hasValue() || *C)
+ if (!C || *C)
return true;
}
} 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 =
return false;
LLVM_DEBUG({
- if (SimplifiedAssociatedValue.hasValue())
+ if (SimplifiedAssociatedValue)
dbgs() << "[ValueSimplify] is assumed to be "
<< **SimplifiedAssociatedValue << "\n";
else
Optional<Constant *> COpt = AA.getAssumedConstant(A);
- if (!COpt.hasValue()) {
+ if (!COpt) {
SimplifiedAssociatedValue = llvm::None;
A.recordDependence(AA, *this, DepClassTy::OPTIONAL);
return true;
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();
// 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;
}
// 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.");
// If two PHINodes have the same canonical values, but different 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
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
// 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()]) ==
}
// 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.
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;
}
ChangeStatus manifest(Attributor &A) override {
- if (!ReplVal.hasValue() || !ReplVal.getValue())
+ if (!ReplVal || !*ReplVal)
return ChangeStatus::UNCHANGED;
A.changeAfterManifest(IRPosition::inst(*getCtxI()), **ReplVal);
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);
// 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) {
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;
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;
}
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();
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;
Optional<OperandBundleUse> DeoptBundle =
Call->getOperandBundle(LLVMContext::OB_deopt);
- if (!DeoptBundle.hasValue()) {
+ if (!DeoptBundle) {
assert(AllowStatepointWithNoDeoptInfo &&
"Found non-leaf call without deopt info!");
return None;
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();
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));
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
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.
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,
// 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);
// 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;
outs() << "FaultMap table:\n";
- if (!FaultMapSection.hasValue()) {
+ if (!FaultMapSection) {
outs() << "<not found>\n";
return;
}
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);
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());
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
StringsAndChecksums Strings;
Strings.setStrings(std::make_shared<DebugStringTableSubsection>());
- if (YamlObj.StringTable.hasValue()) {
+ if (YamlObj.StringTable) {
for (auto S : *YamlObj.StringTable)
Strings.strings()->insert(S);
}
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(
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);
"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,
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();
"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 "
<< " 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";
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"
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.
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));
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");