[llvm] Don't use Optional::hasValue (NFC)
This patch replaces Optional::hasValue with the implicit cast to bool in conditionals only.
This commit is contained in:
parent
77295c5486
commit
a7938c74f1
|
@ -236,7 +236,7 @@ class VFDatabase {
|
|||
// ensuring that the variant described in the attribute has a
|
||||
// corresponding definition or declaration of the vector
|
||||
// function in the Module M.
|
||||
if (Shape.hasValue() && (Shape.getValue().ScalarName == ScalarName)) {
|
||||
if (Shape && (Shape.getValue().ScalarName == ScalarName)) {
|
||||
assert(CI.getModule()->getFunction(Shape.getValue().VectorName) &&
|
||||
"Vector function is missing.");
|
||||
Mappings.push_back(Shape.getValue());
|
||||
|
|
|
@ -674,7 +674,7 @@ bool InstructionSelector::executeMatchTable(
|
|||
ComplexRendererFns Renderer =
|
||||
(ISel.*ISelInfo.ComplexPredicates[ComplexPredicateID])(
|
||||
State.MIs[InsnID]->getOperand(OpIdx));
|
||||
if (Renderer.hasValue())
|
||||
if (Renderer)
|
||||
State.Renderers[RendererID] = Renderer.getValue();
|
||||
else
|
||||
if (handleReject() == RejectAndGiveUp)
|
||||
|
|
|
@ -1168,11 +1168,11 @@ private:
|
|||
Value *getConstrainedFPRounding(Optional<RoundingMode> Rounding) {
|
||||
RoundingMode UseRounding = DefaultConstrainedRounding;
|
||||
|
||||
if (Rounding.hasValue())
|
||||
if (Rounding)
|
||||
UseRounding = Rounding.getValue();
|
||||
|
||||
Optional<StringRef> RoundingStr = convertRoundingModeToStr(UseRounding);
|
||||
assert(RoundingStr.hasValue() && "Garbage strict rounding mode!");
|
||||
assert(RoundingStr && "Garbage strict rounding mode!");
|
||||
auto *RoundingMDS = MDString::get(Context, RoundingStr.getValue());
|
||||
|
||||
return MetadataAsValue::get(Context, RoundingMDS);
|
||||
|
@ -1181,11 +1181,11 @@ private:
|
|||
Value *getConstrainedFPExcept(Optional<fp::ExceptionBehavior> Except) {
|
||||
fp::ExceptionBehavior UseExcept = DefaultConstrainedExcept;
|
||||
|
||||
if (Except.hasValue())
|
||||
if (Except)
|
||||
UseExcept = Except.getValue();
|
||||
|
||||
Optional<StringRef> ExceptStr = convertExceptionBehaviorToStr(UseExcept);
|
||||
assert(ExceptStr.hasValue() && "Garbage strict exception behavior!");
|
||||
assert(ExceptStr && "Garbage strict exception behavior!");
|
||||
auto *ExceptMDS = MDString::get(Context, ExceptStr.getValue());
|
||||
|
||||
return MetadataAsValue::get(Context, ExceptMDS);
|
||||
|
|
|
@ -88,7 +88,7 @@ public:
|
|||
|
||||
bool hasImportModule() const { return ImportModule.hasValue(); }
|
||||
StringRef getImportModule() const {
|
||||
if (ImportModule.hasValue())
|
||||
if (ImportModule)
|
||||
return ImportModule.getValue();
|
||||
// Use a default module name of "env" for now, for compatibility with
|
||||
// existing tools.
|
||||
|
@ -100,7 +100,7 @@ public:
|
|||
|
||||
bool hasImportName() const { return ImportName.hasValue(); }
|
||||
StringRef getImportName() const {
|
||||
if (ImportName.hasValue())
|
||||
if (ImportName)
|
||||
return ImportName.getValue();
|
||||
return getName();
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ public:
|
|||
void setSignature(wasm::WasmSignature *Sig) { Signature = Sig; }
|
||||
|
||||
const wasm::WasmGlobalType &getGlobalType() const {
|
||||
assert(GlobalType.hasValue());
|
||||
assert(GlobalType);
|
||||
return GlobalType.getValue();
|
||||
}
|
||||
void setGlobalType(wasm::WasmGlobalType GT) { GlobalType = GT; }
|
||||
|
|
|
@ -39,8 +39,7 @@ public:
|
|||
};
|
||||
|
||||
XCOFF::StorageClass getStorageClass() const {
|
||||
assert(StorageClass.hasValue() &&
|
||||
"StorageClass not set on XCOFF MCSymbol.");
|
||||
assert(StorageClass && "StorageClass not set on XCOFF MCSymbol.");
|
||||
return StorageClass.getValue();
|
||||
}
|
||||
|
||||
|
|
|
@ -1269,7 +1269,7 @@ public:
|
|||
void log(raw_ostream &OS) const override {
|
||||
assert(Err && "Trying to log after takeError().");
|
||||
OS << "'" << FileName << "': ";
|
||||
if (Line.hasValue())
|
||||
if (Line)
|
||||
OS << "line " << Line.getValue() << ": ";
|
||||
Err->log(OS);
|
||||
}
|
||||
|
|
|
@ -1668,14 +1668,13 @@ template <typename T, typename Context>
|
|||
void IO::processKeyWithDefault(const char *Key, Optional<T> &Val,
|
||||
const Optional<T> &DefaultValue, bool Required,
|
||||
Context &Ctx) {
|
||||
assert(DefaultValue.hasValue() == false &&
|
||||
"Optional<T> shouldn't have a value!");
|
||||
assert(!DefaultValue && "Optional<T> shouldn't have a value!");
|
||||
void *SaveInfo;
|
||||
bool UseDefault = true;
|
||||
const bool sameAsDefault = outputting() && !Val.hasValue();
|
||||
if (!outputting() && !Val.hasValue())
|
||||
if (!outputting() && !Val)
|
||||
Val = T();
|
||||
if (Val.hasValue() &&
|
||||
if (Val &&
|
||||
this->preflightKey(Key, Required, sameAsDefault, UseDefault, SaveInfo)) {
|
||||
|
||||
// When reading an Optional<X> key from a YAML description, we allow the
|
||||
|
|
|
@ -831,14 +831,14 @@ CFLAndersAAResult::ensureCached(const Function &Fn) {
|
|||
scan(Fn);
|
||||
Iter = Cache.find(&Fn);
|
||||
assert(Iter != Cache.end());
|
||||
assert(Iter->second.hasValue());
|
||||
assert(Iter->second);
|
||||
}
|
||||
return Iter->second;
|
||||
}
|
||||
|
||||
const AliasSummary *CFLAndersAAResult::getAliasSummary(const Function &Fn) {
|
||||
auto &FunInfo = ensureCached(Fn);
|
||||
if (FunInfo.hasValue())
|
||||
if (FunInfo)
|
||||
return &FunInfo->getAliasSummary();
|
||||
else
|
||||
return nullptr;
|
||||
|
|
|
@ -250,14 +250,14 @@ CFLSteensAAResult::ensureCached(Function *Fn) {
|
|||
scan(Fn);
|
||||
Iter = Cache.find(Fn);
|
||||
assert(Iter != Cache.end());
|
||||
assert(Iter->second.hasValue());
|
||||
assert(Iter->second);
|
||||
}
|
||||
return Iter->second;
|
||||
}
|
||||
|
||||
const AliasSummary *CFLSteensAAResult::getAliasSummary(Function &Fn) {
|
||||
auto &FunInfo = ensureCached(&Fn);
|
||||
if (FunInfo.hasValue())
|
||||
if (FunInfo)
|
||||
return &FunInfo->getAliasSummary();
|
||||
else
|
||||
return nullptr;
|
||||
|
@ -293,15 +293,15 @@ AliasResult CFLSteensAAResult::query(const MemoryLocation &LocA,
|
|||
|
||||
assert(Fn != nullptr);
|
||||
auto &MaybeInfo = ensureCached(Fn);
|
||||
assert(MaybeInfo.hasValue());
|
||||
assert(MaybeInfo);
|
||||
|
||||
auto &Sets = MaybeInfo->getStratifiedSets();
|
||||
auto MaybeA = Sets.find(InstantiatedValue{ValA, 0});
|
||||
if (!MaybeA.hasValue())
|
||||
if (!MaybeA)
|
||||
return AliasResult::MayAlias;
|
||||
|
||||
auto MaybeB = Sets.find(InstantiatedValue{ValB, 0});
|
||||
if (!MaybeB.hasValue())
|
||||
if (!MaybeB)
|
||||
return AliasResult::MayAlias;
|
||||
|
||||
auto SetA = *MaybeA;
|
||||
|
|
|
@ -183,7 +183,7 @@ CmpInst::Predicate IRInstructionData::getPredicate() const {
|
|||
assert(isa<CmpInst>(Inst) &&
|
||||
"Can only get a predicate from a compare instruction");
|
||||
|
||||
if (RevisedPredicate.hasValue())
|
||||
if (RevisedPredicate)
|
||||
return RevisedPredicate.getValue();
|
||||
|
||||
return cast<CmpInst>(Inst)->getPredicate();
|
||||
|
|
|
@ -703,7 +703,7 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
|
|||
BlockFrequencyInfo *BFI = &(GetBFI(F));
|
||||
assert(BFI && "BFI must be available");
|
||||
auto ProfileCount = BFI->getBlockProfileCount(BB);
|
||||
assert(ProfileCount.hasValue());
|
||||
assert(ProfileCount);
|
||||
if (ProfileCount.getValue() == 0)
|
||||
ColdSize += Cost - CostAtBBStart;
|
||||
}
|
||||
|
@ -828,14 +828,14 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
|
|||
}
|
||||
|
||||
auto ProfileCount = CalleeBFI->getBlockProfileCount(&BB);
|
||||
assert(ProfileCount.hasValue());
|
||||
assert(ProfileCount);
|
||||
CurrentSavings *= ProfileCount.getValue();
|
||||
CycleSavings += CurrentSavings;
|
||||
}
|
||||
|
||||
// Compute the cycle savings per call.
|
||||
auto EntryProfileCount = F.getEntryCount();
|
||||
assert(EntryProfileCount.hasValue() && EntryProfileCount->getCount());
|
||||
assert(EntryProfileCount && EntryProfileCount->getCount());
|
||||
auto EntryCount = EntryProfileCount->getCount();
|
||||
CycleSavings += EntryCount / 2;
|
||||
CycleSavings = CycleSavings.udiv(EntryCount);
|
||||
|
|
|
@ -918,7 +918,7 @@ Optional<ValueLatticeElement> LazyValueInfoImpl::solveBlockValueCast(
|
|||
// transfer rule on the full set since we may be able to locally infer
|
||||
// interesting facts.
|
||||
Optional<ConstantRange> LHSRes = getRangeFor(CI->getOperand(0), CI, BB);
|
||||
if (!LHSRes.hasValue())
|
||||
if (!LHSRes)
|
||||
// More work to do before applying this transfer rule.
|
||||
return None;
|
||||
const ConstantRange &LHSRange = LHSRes.getValue();
|
||||
|
|
|
@ -645,8 +645,8 @@ bool CacheCost::populateReferenceGroups(ReferenceGroupsTy &RefGroups) const {
|
|||
Optional<bool> HasSpacialReuse =
|
||||
R->hasSpacialReuse(Representative, CLS, AA);
|
||||
|
||||
if ((HasTemporalReuse.hasValue() && *HasTemporalReuse) ||
|
||||
(HasSpacialReuse.hasValue() && *HasSpacialReuse)) {
|
||||
if ((HasTemporalReuse && *HasTemporalReuse) ||
|
||||
(HasSpacialReuse && *HasSpacialReuse)) {
|
||||
RefGroup.push_back(std::move(R));
|
||||
Added = true;
|
||||
break;
|
||||
|
|
|
@ -501,10 +501,10 @@ Optional<StringRef> llvm::getAllocationFamily(const Value *I,
|
|||
if (!TLI || !TLI->getLibFunc(*Callee, TLIFn) || !TLI->has(TLIFn))
|
||||
return None;
|
||||
const auto AllocData = getAllocationDataForFunction(Callee, AnyAlloc, TLI);
|
||||
if (AllocData.hasValue())
|
||||
if (AllocData)
|
||||
return mangledNameForMallocFamily(AllocData.getValue().Family);
|
||||
const auto FreeData = getFreeFunctionDataForFunction(Callee, TLIFn);
|
||||
if (FreeData.hasValue())
|
||||
if (FreeData)
|
||||
return mangledNameForMallocFamily(FreeData.getValue().Family);
|
||||
return None;
|
||||
}
|
||||
|
@ -512,7 +512,7 @@ Optional<StringRef> llvm::getAllocationFamily(const Value *I,
|
|||
/// isLibFreeFunction - Returns true if the function is a builtin free()
|
||||
bool llvm::isLibFreeFunction(const Function *F, const LibFunc TLIFn) {
|
||||
Optional<FreeFnsTy> FnData = getFreeFunctionDataForFunction(F, TLIFn);
|
||||
if (!FnData.hasValue())
|
||||
if (!FnData)
|
||||
return false;
|
||||
|
||||
// Check free prototype.
|
||||
|
|
|
@ -751,7 +751,7 @@ template <class AliasAnalysisType> class ClobberWalker {
|
|||
bool operator==(const generic_def_path_iterator &O) const {
|
||||
if (N.hasValue() != O.N.hasValue())
|
||||
return false;
|
||||
return !N.hasValue() || *N == *O.N;
|
||||
return !N || *N == *O.N;
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -491,7 +491,7 @@ template <typename K, typename V, typename FnTy, typename... ArgsTy>
|
|||
static V getOrCreateCachedOptional(K Key, DenseMap<K, Optional<V>> &Map,
|
||||
FnTy &&Fn, ArgsTy&&... args) {
|
||||
Optional<V> &OptVal = Map[Key];
|
||||
if (!OptVal.hasValue())
|
||||
if (!OptVal)
|
||||
OptVal = Fn(std::forward<ArgsTy>(args)...);
|
||||
return OptVal.getValue();
|
||||
}
|
||||
|
|
|
@ -4847,7 +4847,7 @@ public:
|
|||
SelectInst *SI = cast<SelectInst>(I);
|
||||
Optional<const SCEV *> Res =
|
||||
compareWithBackedgeCondition(SI->getCondition());
|
||||
if (Res.hasValue()) {
|
||||
if (Res) {
|
||||
bool IsOne = cast<SCEVConstant>(Res.getValue())->getValue()->isOne();
|
||||
Result = SE.getSCEV(IsOne ? SI->getTrueValue() : SI->getFalseValue());
|
||||
}
|
||||
|
@ -4855,7 +4855,7 @@ public:
|
|||
}
|
||||
default: {
|
||||
Optional<const SCEV *> Res = compareWithBackedgeCondition(I);
|
||||
if (Res.hasValue())
|
||||
if (Res)
|
||||
Result = Res.getValue();
|
||||
break;
|
||||
}
|
||||
|
@ -6596,7 +6596,7 @@ ScalarEvolution::getRangeRef(const SCEV *S,
|
|||
|
||||
// Check if the IR explicitly contains !range metadata.
|
||||
Optional<ConstantRange> MDRange = GetRangeFromMetadata(U->getValue());
|
||||
if (MDRange.hasValue())
|
||||
if (MDRange)
|
||||
ConservativeResult = ConservativeResult.intersectWith(MDRange.getValue(),
|
||||
RangeType);
|
||||
|
||||
|
@ -9710,15 +9710,15 @@ GetQuadraticEquation(const SCEVAddRecExpr *AddRec) {
|
|||
/// (b) if neither X nor Y exist, return None,
|
||||
/// (c) if exactly one of X and Y exists, return that value.
|
||||
static Optional<APInt> MinOptional(Optional<APInt> X, Optional<APInt> Y) {
|
||||
if (X.hasValue() && Y.hasValue()) {
|
||||
if (X && Y) {
|
||||
unsigned W = std::max(X->getBitWidth(), Y->getBitWidth());
|
||||
APInt XW = X->sext(W);
|
||||
APInt YW = Y->sext(W);
|
||||
return XW.slt(YW) ? *X : *Y;
|
||||
}
|
||||
if (!X.hasValue() && !Y.hasValue())
|
||||
if (!X && !Y)
|
||||
return None;
|
||||
return X.hasValue() ? *X : *Y;
|
||||
return X ? *X : *Y;
|
||||
}
|
||||
|
||||
/// Helper function to truncate an optional APInt to a given BitWidth.
|
||||
|
@ -9760,13 +9760,13 @@ SolveQuadraticAddRecExact(const SCEVAddRecExpr *AddRec, ScalarEvolution &SE) {
|
|||
APInt A, B, C, M;
|
||||
unsigned BitWidth;
|
||||
auto T = GetQuadraticEquation(AddRec);
|
||||
if (!T.hasValue())
|
||||
if (!T)
|
||||
return None;
|
||||
|
||||
std::tie(A, B, C, M, BitWidth) = *T;
|
||||
LLVM_DEBUG(dbgs() << __func__ << ": solving for unsigned overflow\n");
|
||||
Optional<APInt> X = APIntOps::SolveQuadraticEquationWrap(A, B, C, BitWidth+1);
|
||||
if (!X.hasValue())
|
||||
if (!X)
|
||||
return None;
|
||||
|
||||
ConstantInt *CX = ConstantInt::get(SE.getContext(), *X);
|
||||
|
@ -10471,7 +10471,7 @@ ScalarEvolution::getMonotonicPredicateType(const SCEVAddRecExpr *LHS,
|
|||
auto ResultSwapped =
|
||||
getMonotonicPredicateTypeImpl(LHS, ICmpInst::getSwappedPredicate(Pred));
|
||||
|
||||
assert(ResultSwapped.hasValue() && "should be able to analyze both!");
|
||||
assert(ResultSwapped && "should be able to analyze both!");
|
||||
assert(ResultSwapped.getValue() != Result.getValue() &&
|
||||
"monotonicity should flip as we flip the predicate");
|
||||
}
|
||||
|
|
|
@ -343,7 +343,7 @@ public:
|
|||
bool has(const T &Elem) const { return get(Elem).hasValue(); }
|
||||
|
||||
bool add(const T &Main) {
|
||||
if (get(Main).hasValue())
|
||||
if (get(Main))
|
||||
return false;
|
||||
|
||||
auto NewIndex = getNewUnlinkedIndex();
|
||||
|
|
|
@ -1501,7 +1501,7 @@ void VFABI::getVectorVariantNames(
|
|||
#ifndef NDEBUG
|
||||
LLVM_DEBUG(dbgs() << "VFABI: adding mapping '" << S << "'\n");
|
||||
Optional<VFInfo> Info = VFABI::tryDemangleForVFABI(S, *(CI.getModule()));
|
||||
assert(Info.hasValue() && "Invalid name for a VFABI variant.");
|
||||
assert(Info && "Invalid name for a VFABI variant.");
|
||||
assert(CI.getModule()->getFunction(Info.getValue().VectorName) &&
|
||||
"Vector function is missing.");
|
||||
#endif
|
||||
|
|
|
@ -1296,7 +1296,7 @@ bool CombinerHelper::matchCombineConstantFoldFpUnary(MachineInstr &MI,
|
|||
|
||||
void CombinerHelper::applyCombineConstantFoldFpUnary(MachineInstr &MI,
|
||||
Optional<APFloat> &Cst) {
|
||||
assert(Cst.hasValue() && "Optional is unexpectedly empty!");
|
||||
assert(Cst && "Optional is unexpectedly empty!");
|
||||
Builder.setInstrAndDebugLoc(MI);
|
||||
MachineFunction &MF = Builder.getMF();
|
||||
auto *FPVal = ConstantFP::get(MF.getFunction().getContext(), *Cst);
|
||||
|
|
|
@ -741,7 +741,7 @@ bool MIParser::parseBasicBlockDefinition(
|
|||
MBB->setIsEHPad(IsLandingPad);
|
||||
MBB->setIsInlineAsmBrIndirectTarget(IsInlineAsmBrIndirectTarget);
|
||||
MBB->setIsEHFuncletEntry(IsEHFuncletEntry);
|
||||
if (SectionID.hasValue()) {
|
||||
if (SectionID) {
|
||||
MBB->setSectionID(SectionID.getValue());
|
||||
MF.setBBSectionsType(BasicBlockSection::List);
|
||||
}
|
||||
|
|
|
@ -106,9 +106,8 @@ bool MachineFunctionSplitter::runOnMachineFunction(MachineFunction &MF) {
|
|||
// We don't want to proceed further for cold functions
|
||||
// or functions of unknown hotness. Lukewarm functions have no prefix.
|
||||
Optional<StringRef> SectionPrefix = MF.getFunction().getSectionPrefix();
|
||||
if (SectionPrefix.hasValue() &&
|
||||
(SectionPrefix.getValue().equals("unlikely") ||
|
||||
SectionPrefix.getValue().equals("unknown"))) {
|
||||
if (SectionPrefix && (SectionPrefix.getValue().equals("unlikely") ||
|
||||
SectionPrefix.getValue().equals("unknown"))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1447,7 +1447,7 @@ Register KernelRewriter::remapUse(Register Reg, MachineInstr &MI) {
|
|||
Register KernelRewriter::phi(Register LoopReg, Optional<Register> InitReg,
|
||||
const TargetRegisterClass *RC) {
|
||||
// If the init register is not undef, try and find an existing phi.
|
||||
if (InitReg.hasValue()) {
|
||||
if (InitReg) {
|
||||
auto I = Phis.find({LoopReg, InitReg.getValue()});
|
||||
if (I != Phis.end())
|
||||
return I->second;
|
||||
|
@ -1483,18 +1483,18 @@ Register KernelRewriter::phi(Register LoopReg, Optional<Register> InitReg,
|
|||
if (!RC)
|
||||
RC = MRI.getRegClass(LoopReg);
|
||||
Register R = MRI.createVirtualRegister(RC);
|
||||
if (InitReg.hasValue()) {
|
||||
if (InitReg) {
|
||||
const TargetRegisterClass *ConstrainRegClass =
|
||||
MRI.constrainRegClass(R, MRI.getRegClass(*InitReg));
|
||||
assert(ConstrainRegClass && "Expected a valid constrained register class!");
|
||||
(void)ConstrainRegClass;
|
||||
}
|
||||
BuildMI(*BB, BB->getFirstNonPHI(), DebugLoc(), TII->get(TargetOpcode::PHI), R)
|
||||
.addReg(InitReg.hasValue() ? *InitReg : undef(RC))
|
||||
.addReg(InitReg ? *InitReg : undef(RC))
|
||||
.addMBB(PreheaderBB)
|
||||
.addReg(LoopReg)
|
||||
.addMBB(BB);
|
||||
if (!InitReg.hasValue())
|
||||
if (!InitReg)
|
||||
UndefPhis[LoopReg] = R;
|
||||
else
|
||||
Phis[{LoopReg, *InitReg}] = R;
|
||||
|
|
|
@ -8867,7 +8867,7 @@ void SelectionDAGBuilder::visitInlineAsm(const CallBase &Call,
|
|||
: OpInfo;
|
||||
const auto RegError =
|
||||
getRegistersForValue(DAG, getCurSDLoc(), OpInfo, RefOpInfo);
|
||||
if (RegError.hasValue()) {
|
||||
if (RegError) {
|
||||
const MachineFunction &MF = DAG.getMachineFunction();
|
||||
const TargetRegisterInfo &TRI = *MF.getSubtarget().getRegisterInfo();
|
||||
const char *RegName = TRI.getName(RegError.getValue());
|
||||
|
|
|
@ -196,10 +196,10 @@ static Optional<int> findPreviousSpillSlot(const Value *Val,
|
|||
for (auto &IncomingValue : Phi->incoming_values()) {
|
||||
Optional<int> SpillSlot =
|
||||
findPreviousSpillSlot(IncomingValue, Builder, LookUpDepth - 1);
|
||||
if (!SpillSlot.hasValue())
|
||||
if (!SpillSlot)
|
||||
return None;
|
||||
|
||||
if (MergedResult.hasValue() && *MergedResult != *SpillSlot)
|
||||
if (MergedResult && *MergedResult != *SpillSlot)
|
||||
return None;
|
||||
|
||||
MergedResult = SpillSlot;
|
||||
|
@ -530,14 +530,14 @@ lowerStatepointMetaArgs(SmallVectorImpl<SDValue> &Ops,
|
|||
GCStrategy &S = GFI->getStrategy();
|
||||
for (const Value *V : SI.Bases) {
|
||||
auto Opt = S.isGCManagedPointer(V->getType()->getScalarType());
|
||||
if (Opt.hasValue()) {
|
||||
if (Opt) {
|
||||
assert(Opt.getValue() &&
|
||||
"non gc managed base pointer found in statepoint");
|
||||
}
|
||||
}
|
||||
for (const Value *V : SI.Ptrs) {
|
||||
auto Opt = S.isGCManagedPointer(V->getType()->getScalarType());
|
||||
if (Opt.hasValue()) {
|
||||
if (Opt) {
|
||||
assert(Opt.getValue() &&
|
||||
"non gc managed derived pointer found in statepoint");
|
||||
}
|
||||
|
|
|
@ -70,10 +70,10 @@ uint32_t CodeViewRecordIO::maxFieldLength() const {
|
|||
Optional<uint32_t> Min = Limits.front().bytesRemaining(Offset);
|
||||
for (auto X : makeArrayRef(Limits).drop_front()) {
|
||||
Optional<uint32_t> ThisMin = X.bytesRemaining(Offset);
|
||||
if (ThisMin.hasValue())
|
||||
Min = (Min.hasValue()) ? std::min(*Min, *ThisMin) : *ThisMin;
|
||||
if (ThisMin)
|
||||
Min = Min ? std::min(*Min, *ThisMin) : *ThisMin;
|
||||
}
|
||||
assert(Min.hasValue() && "Every field must have a maximum length!");
|
||||
assert(Min && "Every field must have a maximum length!");
|
||||
|
||||
return *Min;
|
||||
}
|
||||
|
|
|
@ -228,8 +228,8 @@ static Error mapNameAndUniqueName(CodeViewRecordIO &IO, StringRef &Name,
|
|||
}
|
||||
|
||||
Error TypeRecordMapping::visitTypeBegin(CVType &CVR) {
|
||||
assert(!TypeKind.hasValue() && "Already in a type mapping!");
|
||||
assert(!MemberKind.hasValue() && "Already in a member mapping!");
|
||||
assert(!TypeKind && "Already in a type mapping!");
|
||||
assert(!MemberKind && "Already in a member mapping!");
|
||||
|
||||
// FieldList and MethodList records can be any length because they can be
|
||||
// split with continuation records. All other record types cannot be
|
||||
|
@ -260,8 +260,8 @@ Error TypeRecordMapping::visitTypeBegin(CVType &CVR, TypeIndex Index) {
|
|||
}
|
||||
|
||||
Error TypeRecordMapping::visitTypeEnd(CVType &Record) {
|
||||
assert(TypeKind.hasValue() && "Not in a type mapping!");
|
||||
assert(!MemberKind.hasValue() && "Still in a member mapping!");
|
||||
assert(TypeKind && "Not in a type mapping!");
|
||||
assert(!MemberKind && "Still in a member mapping!");
|
||||
|
||||
error(IO.endRecord());
|
||||
|
||||
|
@ -270,8 +270,8 @@ Error TypeRecordMapping::visitTypeEnd(CVType &Record) {
|
|||
}
|
||||
|
||||
Error TypeRecordMapping::visitMemberBegin(CVMemberRecord &Record) {
|
||||
assert(TypeKind.hasValue() && "Not in a type mapping!");
|
||||
assert(!MemberKind.hasValue() && "Already in a member mapping!");
|
||||
assert(TypeKind && "Not in a type mapping!");
|
||||
assert(!MemberKind && "Already in a member mapping!");
|
||||
|
||||
// The largest possible subrecord is one in which there is a record prefix,
|
||||
// followed by the subrecord, followed by a continuation, and that entire
|
||||
|
@ -296,8 +296,8 @@ Error TypeRecordMapping::visitMemberBegin(CVMemberRecord &Record) {
|
|||
}
|
||||
|
||||
Error TypeRecordMapping::visitMemberEnd(CVMemberRecord &Record) {
|
||||
assert(TypeKind.hasValue() && "Not in a type mapping!");
|
||||
assert(MemberKind.hasValue() && "Not in a member mapping!");
|
||||
assert(TypeKind && "Not in a type mapping!");
|
||||
assert(MemberKind && "Not in a member mapping!");
|
||||
|
||||
if (IO.isReading()) {
|
||||
if (auto EC = IO.skipPadding())
|
||||
|
|
|
@ -427,14 +427,14 @@ Error DbiStreamBuilder::commit(const msf::MSFLayout &Layout,
|
|||
|
||||
for (auto &Stream : DbgStreams) {
|
||||
uint16_t StreamNumber = kInvalidStreamIndex;
|
||||
if (Stream.hasValue())
|
||||
if (Stream)
|
||||
StreamNumber = Stream->StreamNumber;
|
||||
if (auto EC = Writer.writeInteger(StreamNumber))
|
||||
return EC;
|
||||
}
|
||||
|
||||
for (auto &Stream : DbgStreams) {
|
||||
if (!Stream.hasValue())
|
||||
if (!Stream)
|
||||
continue;
|
||||
assert(Stream->StreamNumber != kInvalidStreamIndex);
|
||||
|
||||
|
|
|
@ -213,7 +213,7 @@ static int isVariantApplicableInContextHelper(
|
|||
});
|
||||
|
||||
Optional<bool> Result = HandleTrait(Property, IsActiveTrait);
|
||||
if (Result.hasValue())
|
||||
if (Result)
|
||||
return Result.getValue();
|
||||
}
|
||||
|
||||
|
@ -234,7 +234,7 @@ static int isVariantApplicableInContextHelper(
|
|||
ConstructMatches->push_back(ConstructIdx - 1);
|
||||
|
||||
Optional<bool> Result = HandleTrait(Property, FoundInOrder);
|
||||
if (Result.hasValue())
|
||||
if (Result)
|
||||
return Result.getValue();
|
||||
|
||||
if (!FoundInOrder) {
|
||||
|
|
|
@ -363,7 +363,7 @@ VPIntrinsic::getVectorLengthParamPos(Intrinsic::ID IntrinsicID) {
|
|||
/// scatter.
|
||||
MaybeAlign VPIntrinsic::getPointerAlignment() const {
|
||||
Optional<unsigned> PtrParamOpt = getMemoryPointerParamPos(getIntrinsicID());
|
||||
assert(PtrParamOpt.hasValue() && "no pointer argument!");
|
||||
assert(PtrParamOpt && "no pointer argument!");
|
||||
return getParamAlign(PtrParamOpt.getValue());
|
||||
}
|
||||
|
||||
|
@ -389,7 +389,7 @@ Optional<unsigned> VPIntrinsic::getMemoryPointerParamPos(Intrinsic::ID VPID) {
|
|||
/// \return The data (payload) operand of this store or scatter.
|
||||
Value *VPIntrinsic::getMemoryDataParam() const {
|
||||
auto DataParamOpt = getMemoryDataParamPos(getIntrinsicID());
|
||||
if (!DataParamOpt.hasValue())
|
||||
if (!DataParamOpt)
|
||||
return nullptr;
|
||||
return getArgOperand(DataParamOpt.getValue());
|
||||
}
|
||||
|
|
|
@ -254,13 +254,13 @@ bool LLVMContextImpl::hasOpaquePointersValue() {
|
|||
}
|
||||
|
||||
bool LLVMContextImpl::getOpaquePointers() {
|
||||
if (LLVM_UNLIKELY(!(OpaquePointers.hasValue())))
|
||||
if (LLVM_UNLIKELY(!OpaquePointers))
|
||||
OpaquePointers = OpaquePointersCL;
|
||||
return *OpaquePointers;
|
||||
}
|
||||
|
||||
void LLVMContextImpl::setOpaquePointers(bool OP) {
|
||||
assert((!OpaquePointers.hasValue() || OpaquePointers.getValue() == OP) &&
|
||||
assert((!OpaquePointers || OpaquePointers.getValue() == OP) &&
|
||||
"Cannot change opaque pointers mode once set");
|
||||
OpaquePointers = OP;
|
||||
}
|
||||
|
|
|
@ -90,9 +90,9 @@ Value *VectorBuilder::createVectorInstruction(unsigned Opcode, Type *ReturnTy,
|
|||
}
|
||||
}
|
||||
|
||||
if (MaskPosOpt.hasValue())
|
||||
if (MaskPosOpt)
|
||||
IntrinParams[*MaskPosOpt] = &requestMask();
|
||||
if (VLenPosOpt.hasValue())
|
||||
if (VLenPosOpt)
|
||||
IntrinParams[*VLenPosOpt] = &requestEVL();
|
||||
|
||||
auto *VPDecl = VPIntrinsic::getDeclarationForParams(&getModule(), VPID,
|
||||
|
|
|
@ -86,7 +86,7 @@ bool XCOFFSymbolInfo::operator<(const XCOFFSymbolInfo &SymInfo) const {
|
|||
if (StorageMappingClass.hasValue() != SymInfo.StorageMappingClass.hasValue())
|
||||
return SymInfo.StorageMappingClass.hasValue();
|
||||
|
||||
if (StorageMappingClass.hasValue()) {
|
||||
if (StorageMappingClass) {
|
||||
return getSMCPriority(StorageMappingClass.getValue()) <
|
||||
getSMCPriority(SymInfo.StorageMappingClass.getValue());
|
||||
}
|
||||
|
|
|
@ -4239,7 +4239,7 @@ bool MasmParser::parseStructInitializer(const StructInfo &Structure,
|
|||
|
||||
auto &FieldInitializers = Initializer.FieldInitializers;
|
||||
size_t FieldIndex = 0;
|
||||
if (EndToken.hasValue()) {
|
||||
if (EndToken) {
|
||||
// Initialize all fields with given initializers.
|
||||
while (getTok().isNot(EndToken.getValue()) &&
|
||||
FieldIndex < Structure.Fields.size()) {
|
||||
|
@ -4272,7 +4272,7 @@ bool MasmParser::parseStructInitializer(const StructInfo &Structure,
|
|||
FieldInitializers.push_back(Field.Contents);
|
||||
}
|
||||
|
||||
if (EndToken.hasValue()) {
|
||||
if (EndToken) {
|
||||
if (EndToken.getValue() == AsmToken::Greater)
|
||||
return parseAngleBracketClose();
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ MCSchedModel::getReciprocalThroughput(const MCSubtargetInfo &STI,
|
|||
double Temp = NumUnits * 1.0 / I->Cycles;
|
||||
Throughput = Throughput ? std::min(Throughput.getValue(), Temp) : Temp;
|
||||
}
|
||||
if (Throughput.hasValue())
|
||||
if (Throughput)
|
||||
return 1.0 / Throughput.getValue();
|
||||
|
||||
// If no throughput value was calculated, assume that we can execute at the
|
||||
|
@ -142,7 +142,7 @@ MCSchedModel::getReciprocalThroughput(unsigned SchedClass,
|
|||
double Temp = countPopulation(I->getUnits()) * 1.0 / I->getCycles();
|
||||
Throughput = Throughput ? std::min(Throughput.getValue(), Temp) : Temp;
|
||||
}
|
||||
if (Throughput.hasValue())
|
||||
if (Throughput)
|
||||
return 1.0 / Throughput.getValue();
|
||||
|
||||
// If there are no execution resources specified for this class, then assume
|
||||
|
|
|
@ -639,7 +639,7 @@ static Error handleArgs(const CommonConfig &Config, const ELFConfig &ELFConfig,
|
|||
if (Iter != Config.SectionsToRename.end()) {
|
||||
const SectionRename &SR = Iter->second;
|
||||
Sec.Name = std::string(SR.NewName);
|
||||
if (SR.NewFlags.hasValue())
|
||||
if (SR.NewFlags)
|
||||
setSectionFlagsAndType(Sec, SR.NewFlags.getValue());
|
||||
RenamedSections.insert(&Sec);
|
||||
} else if (RelocSec && !(Sec.Flags & SHF_ALLOC))
|
||||
|
|
|
@ -167,11 +167,11 @@ SubtargetFeatures ELFObjectFileBase::getARMFeatures() const {
|
|||
bool isV7 = false;
|
||||
Optional<unsigned> Attr =
|
||||
Attributes.getAttributeValue(ARMBuildAttrs::CPU_arch);
|
||||
if (Attr.hasValue())
|
||||
if (Attr)
|
||||
isV7 = Attr.getValue() == ARMBuildAttrs::v7;
|
||||
|
||||
Attr = Attributes.getAttributeValue(ARMBuildAttrs::CPU_arch_profile);
|
||||
if (Attr.hasValue()) {
|
||||
if (Attr) {
|
||||
switch (Attr.getValue()) {
|
||||
case ARMBuildAttrs::ApplicationProfile:
|
||||
Features.AddFeature("aclass");
|
||||
|
@ -190,7 +190,7 @@ SubtargetFeatures ELFObjectFileBase::getARMFeatures() const {
|
|||
}
|
||||
|
||||
Attr = Attributes.getAttributeValue(ARMBuildAttrs::THUMB_ISA_use);
|
||||
if (Attr.hasValue()) {
|
||||
if (Attr) {
|
||||
switch (Attr.getValue()) {
|
||||
default:
|
||||
break;
|
||||
|
@ -205,7 +205,7 @@ SubtargetFeatures ELFObjectFileBase::getARMFeatures() const {
|
|||
}
|
||||
|
||||
Attr = Attributes.getAttributeValue(ARMBuildAttrs::FP_arch);
|
||||
if (Attr.hasValue()) {
|
||||
if (Attr) {
|
||||
switch (Attr.getValue()) {
|
||||
default:
|
||||
break;
|
||||
|
@ -229,7 +229,7 @@ SubtargetFeatures ELFObjectFileBase::getARMFeatures() const {
|
|||
}
|
||||
|
||||
Attr = Attributes.getAttributeValue(ARMBuildAttrs::Advanced_SIMD_arch);
|
||||
if (Attr.hasValue()) {
|
||||
if (Attr) {
|
||||
switch (Attr.getValue()) {
|
||||
default:
|
||||
break;
|
||||
|
@ -248,7 +248,7 @@ SubtargetFeatures ELFObjectFileBase::getARMFeatures() const {
|
|||
}
|
||||
|
||||
Attr = Attributes.getAttributeValue(ARMBuildAttrs::MVE_arch);
|
||||
if (Attr.hasValue()) {
|
||||
if (Attr) {
|
||||
switch (Attr.getValue()) {
|
||||
default:
|
||||
break;
|
||||
|
@ -267,7 +267,7 @@ SubtargetFeatures ELFObjectFileBase::getARMFeatures() const {
|
|||
}
|
||||
|
||||
Attr = Attributes.getAttributeValue(ARMBuildAttrs::DIV_use);
|
||||
if (Attr.hasValue()) {
|
||||
if (Attr) {
|
||||
switch (Attr.getValue()) {
|
||||
default:
|
||||
break;
|
||||
|
@ -521,7 +521,7 @@ void ELFObjectFileBase::setARMSubArch(Triple &TheTriple) const {
|
|||
|
||||
Optional<unsigned> Attr =
|
||||
Attributes.getAttributeValue(ARMBuildAttrs::CPU_arch);
|
||||
if (Attr.hasValue()) {
|
||||
if (Attr) {
|
||||
switch (Attr.getValue()) {
|
||||
case ARMBuildAttrs::v4:
|
||||
Triple += "v4";
|
||||
|
@ -553,7 +553,7 @@ void ELFObjectFileBase::setARMSubArch(Triple &TheTriple) const {
|
|||
case ARMBuildAttrs::v7: {
|
||||
Optional<unsigned> ArchProfileAttr =
|
||||
Attributes.getAttributeValue(ARMBuildAttrs::CPU_arch_profile);
|
||||
if (ArchProfileAttr.hasValue() &&
|
||||
if (ArchProfileAttr &&
|
||||
ArchProfileAttr.getValue() == ARMBuildAttrs::MicroControllerProfile)
|
||||
Triple += "v7m";
|
||||
else
|
||||
|
|
|
@ -42,7 +42,7 @@ Optional<std::string> Process::FindInEnvPath(StringRef EnvName,
|
|||
assert(!path::is_absolute(FileName));
|
||||
Optional<std::string> FoundPath;
|
||||
Optional<std::string> OptPath = Process::GetEnv(EnvName);
|
||||
if (!OptPath.hasValue())
|
||||
if (!OptPath)
|
||||
return FoundPath;
|
||||
|
||||
const char EnvPathSeparatorStr[] = {Separator, '\0'};
|
||||
|
|
|
@ -2667,14 +2667,14 @@ void JSONWriter::write(ArrayRef<YAMLVFSEntry> Entries,
|
|||
|
||||
OS << "{\n"
|
||||
" 'version': 0,\n";
|
||||
if (IsCaseSensitive.hasValue())
|
||||
if (IsCaseSensitive)
|
||||
OS << " 'case-sensitive': '"
|
||||
<< (IsCaseSensitive.getValue() ? "true" : "false") << "',\n";
|
||||
if (UseExternalNames.hasValue())
|
||||
if (UseExternalNames)
|
||||
OS << " 'use-external-names': '"
|
||||
<< (UseExternalNames.getValue() ? "true" : "false") << "',\n";
|
||||
bool UseOverlayRelative = false;
|
||||
if (IsOverlayRelative.hasValue()) {
|
||||
if (IsOverlayRelative) {
|
||||
UseOverlayRelative = IsOverlayRelative.getValue();
|
||||
OS << " 'overlay-relative': '" << (UseOverlayRelative ? "true" : "false")
|
||||
<< "',\n";
|
||||
|
|
|
@ -428,7 +428,7 @@ raw_ostream &raw_ostream::operator<<(const FormattedBytes &FB) {
|
|||
while (!Bytes.empty()) {
|
||||
indent(FB.IndentLevel);
|
||||
|
||||
if (FB.FirstByteOffset.hasValue()) {
|
||||
if (FB.FirstByteOffset) {
|
||||
uint64_t Offset = FB.FirstByteOffset.getValue();
|
||||
llvm::write_hex(*this, Offset + LineIndex, HPS, OffsetWidth);
|
||||
*this << ": ";
|
||||
|
|
|
@ -2598,7 +2598,7 @@ Init *Record::getValueInit(StringRef FieldName) const {
|
|||
|
||||
StringRef Record::getValueAsString(StringRef FieldName) const {
|
||||
llvm::Optional<StringRef> S = getValueAsOptionalString(FieldName);
|
||||
if (!S.hasValue())
|
||||
if (!S)
|
||||
PrintFatalError(getLoc(), "Record `" + getName() +
|
||||
"' does not have a field named `" + FieldName + "'!\n");
|
||||
return S.getValue();
|
||||
|
|
|
@ -1171,7 +1171,7 @@ bool AMDGPUInstructionSelector::selectBallot(MachineInstr &I) const {
|
|||
Optional<ValueAndVReg> Arg =
|
||||
getIConstantVRegValWithLookThrough(I.getOperand(2).getReg(), *MRI);
|
||||
|
||||
if (Arg.hasValue()) {
|
||||
if (Arg) {
|
||||
const int64_t Value = Arg.getValue().Value.getSExtValue();
|
||||
if (Value == 0) {
|
||||
unsigned Opcode = Is64 ? AMDGPU::S_MOV_B64 : AMDGPU::S_MOV_B32;
|
||||
|
@ -4201,7 +4201,7 @@ AMDGPUInstructionSelector::selectMUBUFScratchOffen(MachineOperand &Root) const {
|
|||
MIB.addReg(Info->getScratchRSrcReg());
|
||||
},
|
||||
[=](MachineInstrBuilder &MIB) { // vaddr
|
||||
if (FI.hasValue())
|
||||
if (FI)
|
||||
MIB.addFrameIndex(FI.getValue());
|
||||
else
|
||||
MIB.addReg(VAddr);
|
||||
|
|
|
@ -1023,7 +1023,7 @@ findCFILocation(MachineBasicBlock &B) {
|
|||
void HexagonFrameLowering::insertCFIInstructions(MachineFunction &MF) const {
|
||||
for (auto &B : MF) {
|
||||
auto At = findCFILocation(B);
|
||||
if (At.hasValue())
|
||||
if (At)
|
||||
insertCFIInstructionsAt(B, At.getValue());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -704,14 +704,14 @@ LanaiAsmParser::parseRegister(bool RestoreOnFailure) {
|
|||
if (Lexer.getKind() == AsmToken::Identifier) {
|
||||
RegNum = MatchRegisterName(Lexer.getTok().getIdentifier());
|
||||
if (RegNum == 0) {
|
||||
if (PercentTok.hasValue() && RestoreOnFailure)
|
||||
if (PercentTok && RestoreOnFailure)
|
||||
Lexer.UnLex(PercentTok.getValue());
|
||||
return nullptr;
|
||||
}
|
||||
Parser.Lex(); // Eat identifier token
|
||||
return LanaiOperand::createReg(RegNum, Start, End);
|
||||
}
|
||||
if (PercentTok.hasValue() && RestoreOnFailure)
|
||||
if (PercentTok && RestoreOnFailure)
|
||||
Lexer.UnLex(PercentTok.getValue());
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -1860,7 +1860,7 @@ SDValue NVPTXTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
|
|||
Chain = Ret.getValue(1);
|
||||
InFlag = Ret.getValue(2);
|
||||
|
||||
if (ProxyRegTruncates[i].hasValue()) {
|
||||
if (ProxyRegTruncates[i]) {
|
||||
Ret = DAG.getNode(ISD::TRUNCATE, dl, ProxyRegTruncates[i].getValue(), Ret);
|
||||
}
|
||||
|
||||
|
|
|
@ -267,13 +267,13 @@ static bool shouldScheduleAdjacent(const TargetInstrInfo &TII,
|
|||
continue;
|
||||
|
||||
auto DepOpIdx = Feature.depOpIdx();
|
||||
if (DepOpIdx.hasValue()) {
|
||||
if (DepOpIdx) {
|
||||
// Checking if the result of the FirstMI is the desired operand of the
|
||||
// SecondMI if the DepOpIdx is set. Otherwise, ignore it.
|
||||
if (!matchingRegOps(*FirstMI, 0, SecondMI, *DepOpIdx))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Checking more on the instruction operands.
|
||||
if (checkOpConstraints(Feature.getKind(), *FirstMI, SecondMI))
|
||||
return true;
|
||||
|
|
|
@ -246,10 +246,10 @@ static PPCTargetMachine::PPCABI computeTargetABI(const Triple &TT,
|
|||
|
||||
static Reloc::Model getEffectiveRelocModel(const Triple &TT,
|
||||
Optional<Reloc::Model> RM) {
|
||||
assert((!TT.isOSAIX() || !RM.hasValue() || *RM == Reloc::PIC_) &&
|
||||
assert((!TT.isOSAIX() || !RM || *RM == Reloc::PIC_) &&
|
||||
"Invalid relocation model for AIX.");
|
||||
|
||||
if (RM.hasValue())
|
||||
if (RM)
|
||||
return *RM;
|
||||
|
||||
// Big Endian PPC and AIX default to PIC.
|
||||
|
|
|
@ -39,7 +39,7 @@ SDValue VETargetLowering::lowerToVVP(SDValue Op, SelectionDAG &DAG) const {
|
|||
// Can we represent this as a VVP node.
|
||||
const unsigned Opcode = Op->getOpcode();
|
||||
auto VVPOpcodeOpt = getVVPOpcode(Opcode);
|
||||
if (!VVPOpcodeOpt.hasValue())
|
||||
if (!VVPOpcodeOpt)
|
||||
return SDValue();
|
||||
unsigned VVPOpcode = VVPOpcodeOpt.getValue();
|
||||
const bool FromVP = ISD::isVPOpcode(Opcode);
|
||||
|
|
|
@ -86,14 +86,12 @@ bool WebAssemblyAsmTypeCheck::popType(SMLoc ErrorLoc,
|
|||
Optional<wasm::ValType> EVT) {
|
||||
if (Stack.empty()) {
|
||||
return typeError(ErrorLoc,
|
||||
EVT.hasValue()
|
||||
? StringRef("empty stack while popping ") +
|
||||
WebAssembly::typeToString(EVT.getValue())
|
||||
: StringRef(
|
||||
"empty stack while popping value"));
|
||||
EVT ? StringRef("empty stack while popping ") +
|
||||
WebAssembly::typeToString(EVT.getValue())
|
||||
: StringRef("empty stack while popping value"));
|
||||
}
|
||||
auto PVT = Stack.pop_back_val();
|
||||
if (EVT.hasValue() && EVT.getValue() != PVT) {
|
||||
if (EVT && EVT.getValue() != PVT) {
|
||||
return typeError(
|
||||
ErrorLoc, StringRef("popped ") + WebAssembly::typeToString(PVT) +
|
||||
", expected " +
|
||||
|
|
|
@ -552,7 +552,7 @@ Value *WebAssemblyLowerEmscriptenEHSjLj::wrapInvoke(CallBase *CI) {
|
|||
Optional<unsigned> NEltArg;
|
||||
std::tie(SizeArg, NEltArg) = FnAttrs.getAllocSizeArgs();
|
||||
SizeArg += 1;
|
||||
if (NEltArg.hasValue())
|
||||
if (NEltArg)
|
||||
NEltArg = NEltArg.getValue() + 1;
|
||||
FnAttrs.addAllocSizeAttr(SizeArg, NEltArg);
|
||||
}
|
||||
|
|
|
@ -297,11 +297,11 @@ AA::combineOptionalValuesInAAValueLatice(const Optional<Value *> &A,
|
|||
const Optional<Value *> &B, Type *Ty) {
|
||||
if (A == B)
|
||||
return A;
|
||||
if (!B.hasValue())
|
||||
if (!B)
|
||||
return A;
|
||||
if (*B == nullptr)
|
||||
return nullptr;
|
||||
if (!A.hasValue())
|
||||
if (!A)
|
||||
return Ty ? getWithType(**B, *Ty) : nullptr;
|
||||
if (*A == nullptr)
|
||||
return nullptr;
|
||||
|
@ -718,7 +718,7 @@ Argument *IRPosition::getAssociatedArgument() const {
|
|||
}
|
||||
|
||||
// If we found a unique callback candidate argument, return it.
|
||||
if (CBCandidateArg.hasValue() && CBCandidateArg.getValue())
|
||||
if (CBCandidateArg && CBCandidateArg.getValue())
|
||||
return CBCandidateArg.getValue();
|
||||
|
||||
// If no callbacks were found, or none used the underlying call site operand
|
||||
|
@ -2695,7 +2695,7 @@ void InformationCache::initializeInformationCache(const Function &CF,
|
|||
while (!Worklist.empty()) {
|
||||
const Instruction *I = Worklist.pop_back_val();
|
||||
Optional<short> &NumUses = AssumeUsesMap[I];
|
||||
if (!NumUses.hasValue())
|
||||
if (!NumUses)
|
||||
NumUses = I->getNumUses();
|
||||
NumUses = NumUses.getValue() - /* this assume */ 1;
|
||||
if (NumUses.getValue() != 0)
|
||||
|
|
|
@ -395,7 +395,7 @@ static bool genericValueTraversal(
|
|||
if (UseValueSimplify && !isa<Constant>(V)) {
|
||||
Optional<Value *> SimpleV =
|
||||
A.getAssumedSimplified(*V, QueryingAA, UsedAssumedInformation);
|
||||
if (!SimpleV.hasValue())
|
||||
if (!SimpleV)
|
||||
continue;
|
||||
Value *NewV = SimpleV.getValue();
|
||||
if (NewV && NewV != V) {
|
||||
|
@ -1851,7 +1851,7 @@ ChangeStatus AAReturnedValuesImpl::manifest(Attributor &A) {
|
|||
// Check if we have an assumed unique return value that we could manifest.
|
||||
Optional<Value *> UniqueRV = getAssumedUniqueReturnValue(A);
|
||||
|
||||
if (!UniqueRV.hasValue() || !UniqueRV.getValue())
|
||||
if (!UniqueRV || !UniqueRV.getValue())
|
||||
return Changed;
|
||||
|
||||
// Bookkeeping.
|
||||
|
@ -2626,7 +2626,7 @@ struct AAUndefinedBehaviorImpl : public AAUndefinedBehavior {
|
|||
// Either we stopped and the appropriate action was taken,
|
||||
// or we got back a simplified value to continue.
|
||||
Optional<Value *> SimplifiedPtrOp = stopOnUndefOrAssumed(A, PtrOp, &I);
|
||||
if (!SimplifiedPtrOp.hasValue() || !SimplifiedPtrOp.getValue())
|
||||
if (!SimplifiedPtrOp || !SimplifiedPtrOp.getValue())
|
||||
return true;
|
||||
const Value *PtrOpVal = SimplifiedPtrOp.getValue();
|
||||
|
||||
|
@ -2717,10 +2717,9 @@ struct AAUndefinedBehaviorImpl : public AAUndefinedBehavior {
|
|||
IRPosition::value(*ArgVal), *this, UsedAssumedInformation);
|
||||
if (UsedAssumedInformation)
|
||||
continue;
|
||||
if (SimplifiedVal.hasValue() && !SimplifiedVal.getValue())
|
||||
if (SimplifiedVal && !SimplifiedVal.getValue())
|
||||
return true;
|
||||
if (!SimplifiedVal.hasValue() ||
|
||||
isa<UndefValue>(*SimplifiedVal.getValue())) {
|
||||
if (!SimplifiedVal || isa<UndefValue>(*SimplifiedVal.getValue())) {
|
||||
KnownUBInsts.insert(&I);
|
||||
continue;
|
||||
}
|
||||
|
@ -4062,7 +4061,7 @@ identifyAliveSuccessors(Attributor &A, const SwitchInst &SI,
|
|||
bool UsedAssumedInformation = false;
|
||||
Optional<Constant *> C =
|
||||
A.getAssumedConstant(*SI.getCondition(), AA, UsedAssumedInformation);
|
||||
if (!C.hasValue() || isa_and_nonnull<UndefValue>(C.getValue())) {
|
||||
if (!C || isa_and_nonnull<UndefValue>(C.getValue())) {
|
||||
// No value yet, assume all edges are dead.
|
||||
} else if (isa_and_nonnull<ConstantInt>(C.getValue())) {
|
||||
for (auto &CaseIt : SI.cases()) {
|
||||
|
@ -5481,7 +5480,7 @@ struct AAValueSimplifyImpl : AAValueSimplify {
|
|||
bool UsedAssumedInformation = false;
|
||||
Optional<Value *> SimpleV =
|
||||
A.getAssumedSimplified(V, QueryingAA, UsedAssumedInformation);
|
||||
if (!SimpleV.hasValue())
|
||||
if (!SimpleV)
|
||||
return PoisonValue::get(&Ty);
|
||||
Value *EffectiveV = &V;
|
||||
if (SimpleV.getValue())
|
||||
|
@ -5631,7 +5630,7 @@ struct AAValueSimplifyArgument final : AAValueSimplifyImpl {
|
|||
bool UsedAssumedInformation = false;
|
||||
Optional<Constant *> SimpleArgOp =
|
||||
A.getAssumedConstant(ACSArgPos, *this, UsedAssumedInformation);
|
||||
if (!SimpleArgOp.hasValue())
|
||||
if (!SimpleArgOp)
|
||||
return true;
|
||||
if (!SimpleArgOp.getValue())
|
||||
return false;
|
||||
|
@ -5746,7 +5745,7 @@ struct AAValueSimplifyFloating : AAValueSimplifyImpl {
|
|||
const auto &SimplifiedLHS =
|
||||
A.getAssumedSimplified(IRPosition::value(*LHS, getCallBaseContext()),
|
||||
*this, UsedAssumedInformation);
|
||||
if (!SimplifiedLHS.hasValue())
|
||||
if (!SimplifiedLHS)
|
||||
return true;
|
||||
if (!SimplifiedLHS.getValue())
|
||||
return false;
|
||||
|
@ -5755,7 +5754,7 @@ struct AAValueSimplifyFloating : AAValueSimplifyImpl {
|
|||
const auto &SimplifiedRHS =
|
||||
A.getAssumedSimplified(IRPosition::value(*RHS, getCallBaseContext()),
|
||||
*this, UsedAssumedInformation);
|
||||
if (!SimplifiedRHS.hasValue())
|
||||
if (!SimplifiedRHS)
|
||||
return true;
|
||||
if (!SimplifiedRHS.getValue())
|
||||
return false;
|
||||
|
@ -5826,7 +5825,7 @@ struct AAValueSimplifyFloating : AAValueSimplifyImpl {
|
|||
*this, UsedAssumedInformation);
|
||||
// If we are not sure about any operand we are not sure about the entire
|
||||
// instruction, we'll wait.
|
||||
if (!SimplifiedOp.hasValue())
|
||||
if (!SimplifiedOp)
|
||||
return true;
|
||||
|
||||
if (SimplifiedOp.getValue())
|
||||
|
@ -6249,8 +6248,7 @@ struct AAHeapToStackFunction final : public AAHeapToStack {
|
|||
Alignment = std::max(Alignment, *RetAlign);
|
||||
if (Value *Align = getAllocAlignment(AI.CB, TLI)) {
|
||||
Optional<APInt> AlignmentAPI = getAPInt(A, *this, *Align);
|
||||
assert(AlignmentAPI.hasValue() &&
|
||||
AlignmentAPI.getValue().getZExtValue() > 0 &&
|
||||
assert(AlignmentAPI && AlignmentAPI.getValue().getZExtValue() > 0 &&
|
||||
"Expected an alignment during manifest!");
|
||||
Alignment = std::max(
|
||||
Alignment, assumeAligned(AlignmentAPI.getValue().getZExtValue()));
|
||||
|
@ -6299,7 +6297,7 @@ struct AAHeapToStackFunction final : public AAHeapToStack {
|
|||
bool UsedAssumedInformation = false;
|
||||
Optional<Constant *> SimpleV =
|
||||
A.getAssumedConstant(V, AA, UsedAssumedInformation);
|
||||
if (!SimpleV.hasValue())
|
||||
if (!SimpleV)
|
||||
return APInt(64, 0);
|
||||
if (auto *CI = dyn_cast_or_null<ConstantInt>(SimpleV.getValue()))
|
||||
return CI->getValue();
|
||||
|
@ -6578,9 +6576,9 @@ ChangeStatus AAHeapToStackFunction::updateImpl(Attributor &A) {
|
|||
|
||||
if (MaxHeapToStackSize != -1) {
|
||||
Optional<APInt> Size = getSize(A, *this, AI);
|
||||
if (!Size.hasValue() || Size.getValue().ugt(MaxHeapToStackSize)) {
|
||||
if (!Size || Size.getValue().ugt(MaxHeapToStackSize)) {
|
||||
LLVM_DEBUG({
|
||||
if (!Size.hasValue())
|
||||
if (!Size)
|
||||
dbgs() << "[H2S] Unknown allocation size: " << *AI.CB << "\n";
|
||||
else
|
||||
dbgs() << "[H2S] Allocation size too large: " << *AI.CB << " vs. "
|
||||
|
@ -6633,9 +6631,9 @@ struct AAPrivatizablePtrImpl : public AAPrivatizablePtr {
|
|||
/// Return a privatizable type that encloses both T0 and T1.
|
||||
/// TODO: This is merely a stub for now as we should manage a mapping as well.
|
||||
Optional<Type *> combineTypes(Optional<Type *> T0, Optional<Type *> T1) {
|
||||
if (!T0.hasValue())
|
||||
if (!T0)
|
||||
return T1;
|
||||
if (!T1.hasValue())
|
||||
if (!T1)
|
||||
return T0;
|
||||
if (T0 == T1)
|
||||
return T0;
|
||||
|
@ -6695,9 +6693,9 @@ struct AAPrivatizablePtrArgument final : public AAPrivatizablePtrImpl {
|
|||
|
||||
LLVM_DEBUG({
|
||||
dbgs() << "[AAPrivatizablePtr] ACSPos: " << ACSArgPos << ", CSTy: ";
|
||||
if (CSTy.hasValue() && CSTy.getValue())
|
||||
if (CSTy && CSTy.getValue())
|
||||
CSTy.getValue()->print(dbgs());
|
||||
else if (CSTy.hasValue())
|
||||
else if (CSTy)
|
||||
dbgs() << "<nullptr>";
|
||||
else
|
||||
dbgs() << "<none>";
|
||||
|
@ -6707,16 +6705,16 @@ struct AAPrivatizablePtrArgument final : public AAPrivatizablePtrImpl {
|
|||
|
||||
LLVM_DEBUG({
|
||||
dbgs() << " : New Type: ";
|
||||
if (Ty.hasValue() && Ty.getValue())
|
||||
if (Ty && Ty.getValue())
|
||||
Ty.getValue()->print(dbgs());
|
||||
else if (Ty.hasValue())
|
||||
else if (Ty)
|
||||
dbgs() << "<nullptr>";
|
||||
else
|
||||
dbgs() << "<none>";
|
||||
dbgs() << "\n";
|
||||
});
|
||||
|
||||
return !Ty.hasValue() || Ty.getValue();
|
||||
return !Ty || Ty.getValue();
|
||||
};
|
||||
|
||||
if (!A.checkForAllCallSites(CallSiteCheck, *this, true,
|
||||
|
@ -6728,7 +6726,7 @@ struct AAPrivatizablePtrArgument final : public AAPrivatizablePtrImpl {
|
|||
/// See AbstractAttribute::updateImpl(...).
|
||||
ChangeStatus updateImpl(Attributor &A) override {
|
||||
PrivatizableType = identifyPrivatizableType(A);
|
||||
if (!PrivatizableType.hasValue())
|
||||
if (!PrivatizableType)
|
||||
return ChangeStatus::UNCHANGED;
|
||||
if (!PrivatizableType.getValue())
|
||||
return indicatePessimisticFixpoint();
|
||||
|
@ -6817,7 +6815,7 @@ struct AAPrivatizablePtrArgument final : public AAPrivatizablePtrImpl {
|
|||
*this, IRPosition::argument(CBArg), DepClassTy::REQUIRED);
|
||||
if (CBArgPrivAA.isValidState()) {
|
||||
auto CBArgPrivTy = CBArgPrivAA.getPrivatizableType();
|
||||
if (!CBArgPrivTy.hasValue())
|
||||
if (!CBArgPrivTy)
|
||||
continue;
|
||||
if (CBArgPrivTy.getValue() == PrivatizableType)
|
||||
continue;
|
||||
|
@ -6864,7 +6862,7 @@ struct AAPrivatizablePtrArgument final : public AAPrivatizablePtrImpl {
|
|||
DepClassTy::REQUIRED);
|
||||
if (DCArgPrivAA.isValidState()) {
|
||||
auto DCArgPrivTy = DCArgPrivAA.getPrivatizableType();
|
||||
if (!DCArgPrivTy.hasValue())
|
||||
if (!DCArgPrivTy)
|
||||
return true;
|
||||
if (DCArgPrivTy.getValue() == PrivatizableType)
|
||||
return true;
|
||||
|
@ -7006,7 +7004,7 @@ struct AAPrivatizablePtrArgument final : public AAPrivatizablePtrImpl {
|
|||
|
||||
/// See AbstractAttribute::manifest(...)
|
||||
ChangeStatus manifest(Attributor &A) override {
|
||||
if (!PrivatizableType.hasValue())
|
||||
if (!PrivatizableType)
|
||||
return ChangeStatus::UNCHANGED;
|
||||
assert(PrivatizableType.getValue() && "Expected privatizable type!");
|
||||
|
||||
|
@ -7149,7 +7147,7 @@ struct AAPrivatizablePtrCallSiteArgument final
|
|||
/// See AbstractAttribute::updateImpl(...).
|
||||
ChangeStatus updateImpl(Attributor &A) override {
|
||||
PrivatizableType = identifyPrivatizableType(A);
|
||||
if (!PrivatizableType.hasValue())
|
||||
if (!PrivatizableType)
|
||||
return ChangeStatus::UNCHANGED;
|
||||
if (!PrivatizableType.getValue())
|
||||
return indicatePessimisticFixpoint();
|
||||
|
@ -8610,7 +8608,7 @@ struct AAValueConstantRangeFloating : AAValueConstantRangeImpl {
|
|||
const auto &SimplifiedLHS =
|
||||
A.getAssumedSimplified(IRPosition::value(*LHS, getCallBaseContext()),
|
||||
*this, UsedAssumedInformation);
|
||||
if (!SimplifiedLHS.hasValue())
|
||||
if (!SimplifiedLHS)
|
||||
return true;
|
||||
if (!SimplifiedLHS.getValue())
|
||||
return false;
|
||||
|
@ -8619,7 +8617,7 @@ struct AAValueConstantRangeFloating : AAValueConstantRangeImpl {
|
|||
const auto &SimplifiedRHS =
|
||||
A.getAssumedSimplified(IRPosition::value(*RHS, getCallBaseContext()),
|
||||
*this, UsedAssumedInformation);
|
||||
if (!SimplifiedRHS.hasValue())
|
||||
if (!SimplifiedRHS)
|
||||
return true;
|
||||
if (!SimplifiedRHS.getValue())
|
||||
return false;
|
||||
|
@ -8663,7 +8661,7 @@ struct AAValueConstantRangeFloating : AAValueConstantRangeImpl {
|
|||
const auto &SimplifiedOpV =
|
||||
A.getAssumedSimplified(IRPosition::value(*OpV, getCallBaseContext()),
|
||||
*this, UsedAssumedInformation);
|
||||
if (!SimplifiedOpV.hasValue())
|
||||
if (!SimplifiedOpV)
|
||||
return true;
|
||||
if (!SimplifiedOpV.getValue())
|
||||
return false;
|
||||
|
@ -8693,7 +8691,7 @@ struct AAValueConstantRangeFloating : AAValueConstantRangeImpl {
|
|||
const auto &SimplifiedLHS =
|
||||
A.getAssumedSimplified(IRPosition::value(*LHS, getCallBaseContext()),
|
||||
*this, UsedAssumedInformation);
|
||||
if (!SimplifiedLHS.hasValue())
|
||||
if (!SimplifiedLHS)
|
||||
return true;
|
||||
if (!SimplifiedLHS.getValue())
|
||||
return false;
|
||||
|
@ -8702,7 +8700,7 @@ struct AAValueConstantRangeFloating : AAValueConstantRangeImpl {
|
|||
const auto &SimplifiedRHS =
|
||||
A.getAssumedSimplified(IRPosition::value(*RHS, getCallBaseContext()),
|
||||
*this, UsedAssumedInformation);
|
||||
if (!SimplifiedRHS.hasValue())
|
||||
if (!SimplifiedRHS)
|
||||
return true;
|
||||
if (!SimplifiedRHS.getValue())
|
||||
return false;
|
||||
|
@ -8767,7 +8765,7 @@ struct AAValueConstantRangeFloating : AAValueConstantRangeImpl {
|
|||
const auto &SimplifiedOpV =
|
||||
A.getAssumedSimplified(IRPosition::value(V, getCallBaseContext()),
|
||||
*this, UsedAssumedInformation);
|
||||
if (!SimplifiedOpV.hasValue())
|
||||
if (!SimplifiedOpV)
|
||||
return true;
|
||||
if (!SimplifiedOpV.getValue())
|
||||
return false;
|
||||
|
@ -9128,7 +9126,7 @@ struct AAPotentialConstantValuesFloating : AAPotentialConstantValuesImpl {
|
|||
const auto &SimplifiedLHS =
|
||||
A.getAssumedSimplified(IRPosition::value(*LHS, getCallBaseContext()),
|
||||
*this, UsedAssumedInformation);
|
||||
if (!SimplifiedLHS.hasValue())
|
||||
if (!SimplifiedLHS)
|
||||
return ChangeStatus::UNCHANGED;
|
||||
if (!SimplifiedLHS.getValue())
|
||||
return indicatePessimisticFixpoint();
|
||||
|
@ -9137,7 +9135,7 @@ struct AAPotentialConstantValuesFloating : AAPotentialConstantValuesImpl {
|
|||
const auto &SimplifiedRHS =
|
||||
A.getAssumedSimplified(IRPosition::value(*RHS, getCallBaseContext()),
|
||||
*this, UsedAssumedInformation);
|
||||
if (!SimplifiedRHS.hasValue())
|
||||
if (!SimplifiedRHS)
|
||||
return ChangeStatus::UNCHANGED;
|
||||
if (!SimplifiedRHS.getValue())
|
||||
return indicatePessimisticFixpoint();
|
||||
|
@ -9211,7 +9209,7 @@ struct AAPotentialConstantValuesFloating : AAPotentialConstantValuesImpl {
|
|||
const auto &SimplifiedLHS =
|
||||
A.getAssumedSimplified(IRPosition::value(*LHS, getCallBaseContext()),
|
||||
*this, UsedAssumedInformation);
|
||||
if (!SimplifiedLHS.hasValue())
|
||||
if (!SimplifiedLHS)
|
||||
return ChangeStatus::UNCHANGED;
|
||||
if (!SimplifiedLHS.getValue())
|
||||
return indicatePessimisticFixpoint();
|
||||
|
@ -9220,7 +9218,7 @@ struct AAPotentialConstantValuesFloating : AAPotentialConstantValuesImpl {
|
|||
const auto &SimplifiedRHS =
|
||||
A.getAssumedSimplified(IRPosition::value(*RHS, getCallBaseContext()),
|
||||
*this, UsedAssumedInformation);
|
||||
if (!SimplifiedRHS.hasValue())
|
||||
if (!SimplifiedRHS)
|
||||
return ChangeStatus::UNCHANGED;
|
||||
if (!SimplifiedRHS.getValue())
|
||||
return indicatePessimisticFixpoint();
|
||||
|
@ -9234,9 +9232,9 @@ struct AAPotentialConstantValuesFloating : AAPotentialConstantValuesImpl {
|
|||
|
||||
// Check if we only need one operand.
|
||||
bool OnlyLeft = false, OnlyRight = false;
|
||||
if (C.hasValue() && *C && (*C)->isOneValue())
|
||||
if (C && *C && (*C)->isOneValue())
|
||||
OnlyLeft = true;
|
||||
else if (C.hasValue() && *C && (*C)->isZeroValue())
|
||||
else if (C && *C && (*C)->isZeroValue())
|
||||
OnlyRight = true;
|
||||
|
||||
const AAPotentialConstantValues *LHSAA = nullptr, *RHSAA = nullptr;
|
||||
|
@ -9286,7 +9284,7 @@ struct AAPotentialConstantValuesFloating : AAPotentialConstantValuesImpl {
|
|||
const auto &SimplifiedSrc =
|
||||
A.getAssumedSimplified(IRPosition::value(*Src, getCallBaseContext()),
|
||||
*this, UsedAssumedInformation);
|
||||
if (!SimplifiedSrc.hasValue())
|
||||
if (!SimplifiedSrc)
|
||||
return ChangeStatus::UNCHANGED;
|
||||
if (!SimplifiedSrc.getValue())
|
||||
return indicatePessimisticFixpoint();
|
||||
|
@ -9319,7 +9317,7 @@ struct AAPotentialConstantValuesFloating : AAPotentialConstantValuesImpl {
|
|||
const auto &SimplifiedLHS =
|
||||
A.getAssumedSimplified(IRPosition::value(*LHS, getCallBaseContext()),
|
||||
*this, UsedAssumedInformation);
|
||||
if (!SimplifiedLHS.hasValue())
|
||||
if (!SimplifiedLHS)
|
||||
return ChangeStatus::UNCHANGED;
|
||||
if (!SimplifiedLHS.getValue())
|
||||
return indicatePessimisticFixpoint();
|
||||
|
@ -9328,7 +9326,7 @@ struct AAPotentialConstantValuesFloating : AAPotentialConstantValuesImpl {
|
|||
const auto &SimplifiedRHS =
|
||||
A.getAssumedSimplified(IRPosition::value(*RHS, getCallBaseContext()),
|
||||
*this, UsedAssumedInformation);
|
||||
if (!SimplifiedRHS.hasValue())
|
||||
if (!SimplifiedRHS)
|
||||
return ChangeStatus::UNCHANGED;
|
||||
if (!SimplifiedRHS.getValue())
|
||||
return indicatePessimisticFixpoint();
|
||||
|
@ -9387,7 +9385,7 @@ struct AAPotentialConstantValuesFloating : AAPotentialConstantValuesImpl {
|
|||
const auto &SimplifiedIncomingValue = A.getAssumedSimplified(
|
||||
IRPosition::value(*IncomingValue, getCallBaseContext()), *this,
|
||||
UsedAssumedInformation);
|
||||
if (!SimplifiedIncomingValue.hasValue())
|
||||
if (!SimplifiedIncomingValue)
|
||||
continue;
|
||||
if (!SimplifiedIncomingValue.getValue())
|
||||
return indicatePessimisticFixpoint();
|
||||
|
@ -9877,7 +9875,7 @@ private:
|
|||
ArrayRef<const AACallEdges *> AAEdgesList,
|
||||
const Function &Fn) {
|
||||
Optional<bool> Cached = isCachedReachable(Fn);
|
||||
if (Cached.hasValue())
|
||||
if (Cached)
|
||||
return Cached.getValue();
|
||||
|
||||
// The query was not cached, thus it is new. We need to request an update
|
||||
|
|
|
@ -554,7 +554,7 @@ collectRegionsConstants(OutlinableRegion &Region,
|
|||
// the the number has been found to be not the same value in each instance.
|
||||
for (Value *V : ID.OperVals) {
|
||||
Optional<unsigned> GVNOpt = C.getGVN(V);
|
||||
assert(GVNOpt.hasValue() && "Expected a GVN for operand?");
|
||||
assert(GVNOpt && "Expected a GVN for operand?");
|
||||
unsigned GVN = GVNOpt.getValue();
|
||||
|
||||
// Check if this global value has been found to not be the same already.
|
||||
|
@ -569,7 +569,7 @@ collectRegionsConstants(OutlinableRegion &Region,
|
|||
// global value number. If the global value does not map to a Constant,
|
||||
// it is considered to not be the same value.
|
||||
Optional<bool> ConstantMatches = constantMatches(V, GVN, GVNToConstant);
|
||||
if (ConstantMatches.hasValue()) {
|
||||
if (ConstantMatches) {
|
||||
if (ConstantMatches.getValue())
|
||||
continue;
|
||||
else
|
||||
|
@ -650,7 +650,7 @@ Function *IROutliner::createFunction(Module &M, OutlinableGroup &Group,
|
|||
"outlined_ir_func_" + std::to_string(FunctionNameSuffix), M);
|
||||
|
||||
// Transfer the swifterr attribute to the correct function parameter.
|
||||
if (Group.SwiftErrorArgument.hasValue())
|
||||
if (Group.SwiftErrorArgument)
|
||||
Group.OutlinedFunction->addParamAttr(Group.SwiftErrorArgument.getValue(),
|
||||
Attribute::SwiftError);
|
||||
|
||||
|
@ -808,8 +808,7 @@ static void mapInputsToGVNs(IRSimilarityCandidate &C,
|
|||
assert(Input && "Have a nullptr as an input");
|
||||
if (OutputMappings.find(Input) != OutputMappings.end())
|
||||
Input = OutputMappings.find(Input)->second;
|
||||
assert(C.getGVN(Input).hasValue() &&
|
||||
"Could not find a numbering for the given input");
|
||||
assert(C.getGVN(Input) && "Could not find a numbering for the given input");
|
||||
EndInputNumbers.push_back(C.getGVN(Input).getValue());
|
||||
}
|
||||
}
|
||||
|
@ -948,11 +947,11 @@ findExtractedInputToOverallInputMapping(OutlinableRegion &Region,
|
|||
// numbering overrides any discovered location for the extracted code.
|
||||
for (unsigned InputVal : InputGVNs) {
|
||||
Optional<unsigned> CanonicalNumberOpt = C.getCanonicalNum(InputVal);
|
||||
assert(CanonicalNumberOpt.hasValue() && "Canonical number not found?");
|
||||
assert(CanonicalNumberOpt && "Canonical number not found?");
|
||||
unsigned CanonicalNumber = CanonicalNumberOpt.getValue();
|
||||
|
||||
Optional<Value *> InputOpt = C.fromGVN(InputVal);
|
||||
assert(InputOpt.hasValue() && "Global value number not found?");
|
||||
assert(InputOpt && "Global value number not found?");
|
||||
Value *Input = InputOpt.getValue();
|
||||
|
||||
DenseMap<unsigned, unsigned>::iterator AggArgIt =
|
||||
|
@ -1235,11 +1234,10 @@ static Optional<unsigned> getGVNForPHINode(OutlinableRegion &Region,
|
|||
DenseMap<hash_code, unsigned>::iterator GVNToPHIIt;
|
||||
DenseMap<unsigned, PHINodeData>::iterator PHIToGVNIt;
|
||||
Optional<unsigned> BBGVN = Cand.getGVN(PHIBB);
|
||||
assert(BBGVN.hasValue() && "Could not find GVN for the incoming block!");
|
||||
assert(BBGVN && "Could not find GVN for the incoming block!");
|
||||
|
||||
BBGVN = Cand.getCanonicalNum(BBGVN.getValue());
|
||||
assert(BBGVN.hasValue() &&
|
||||
"Could not find canonical number for the incoming block!");
|
||||
assert(BBGVN && "Could not find canonical number for the incoming block!");
|
||||
// Create a pair of the exit block canonical value, and the aggregate
|
||||
// argument location, connected to the canonical numbers stored in the
|
||||
// PHINode.
|
||||
|
@ -1517,7 +1515,7 @@ CallInst *replaceCalledFunction(Module &M, OutlinableRegion &Region) {
|
|||
|
||||
// Make sure that the argument in the new function has the SwiftError
|
||||
// argument.
|
||||
if (Group.SwiftErrorArgument.hasValue())
|
||||
if (Group.SwiftErrorArgument)
|
||||
Call->addParamAttr(Group.SwiftErrorArgument.getValue(),
|
||||
Attribute::SwiftError);
|
||||
|
||||
|
@ -1650,9 +1648,9 @@ static void findCanonNumsForPHI(
|
|||
|
||||
// Find and add the canonical number for the incoming value.
|
||||
Optional<unsigned> GVN = Region.Candidate->getGVN(IVal);
|
||||
assert(GVN.hasValue() && "No GVN for incoming value");
|
||||
assert(GVN && "No GVN for incoming value");
|
||||
Optional<unsigned> CanonNum = Region.Candidate->getCanonicalNum(*GVN);
|
||||
assert(CanonNum.hasValue() && "No Canonical Number for GVN");
|
||||
assert(CanonNum && "No Canonical Number for GVN");
|
||||
CanonNums.push_back(std::make_pair(*CanonNum, IBlock));
|
||||
}
|
||||
}
|
||||
|
@ -2081,7 +2079,7 @@ static void alignOutputBlockWithAggFunc(
|
|||
|
||||
// If there is, we remove the new output blocks. If it does not,
|
||||
// we add it to our list of sets of output blocks.
|
||||
if (MatchingBB.hasValue()) {
|
||||
if (MatchingBB) {
|
||||
LLVM_DEBUG(dbgs() << "Set output block for region in function"
|
||||
<< Region.ExtractedFunction << " to "
|
||||
<< MatchingBB.getValue());
|
||||
|
@ -2504,9 +2502,9 @@ static Value *findOutputValueInRegion(OutlinableRegion &Region,
|
|||
OutputCanon = *It->second.second.begin();
|
||||
}
|
||||
Optional<unsigned> OGVN = Region.Candidate->fromCanonicalNum(OutputCanon);
|
||||
assert(OGVN.hasValue() && "Could not find GVN for Canonical Number?");
|
||||
assert(OGVN && "Could not find GVN for Canonical Number?");
|
||||
Optional<Value *> OV = Region.Candidate->fromGVN(*OGVN);
|
||||
assert(OV.hasValue() && "Could not find value for GVN?");
|
||||
assert(OV && "Could not find value for GVN?");
|
||||
return *OV;
|
||||
}
|
||||
|
||||
|
|
|
@ -2514,13 +2514,13 @@ struct AAICVTrackerFunction : public AAICVTracker {
|
|||
if (ValuesMap.count(CurrInst)) {
|
||||
Optional<Value *> NewReplVal = ValuesMap.lookup(CurrInst);
|
||||
// Unknown value, track new.
|
||||
if (!ReplVal.hasValue()) {
|
||||
if (!ReplVal) {
|
||||
ReplVal = NewReplVal;
|
||||
break;
|
||||
}
|
||||
|
||||
// If we found a new value, we can't know the icv value anymore.
|
||||
if (NewReplVal.hasValue())
|
||||
if (NewReplVal)
|
||||
if (ReplVal != NewReplVal)
|
||||
return nullptr;
|
||||
|
||||
|
@ -2528,11 +2528,11 @@ struct AAICVTrackerFunction : public AAICVTracker {
|
|||
}
|
||||
|
||||
Optional<Value *> NewReplVal = getValueForCall(A, *CurrInst, ICV);
|
||||
if (!NewReplVal.hasValue())
|
||||
if (!NewReplVal)
|
||||
continue;
|
||||
|
||||
// Unknown value, track new.
|
||||
if (!ReplVal.hasValue()) {
|
||||
if (!ReplVal) {
|
||||
ReplVal = NewReplVal;
|
||||
break;
|
||||
}
|
||||
|
@ -4422,7 +4422,7 @@ struct AAFoldRuntimeCallCallSiteReturned : AAFoldRuntimeCall {
|
|||
|
||||
std::string Str("simplified value: ");
|
||||
|
||||
if (!SimplifiedValue.hasValue())
|
||||
if (!SimplifiedValue)
|
||||
return Str + std::string("none");
|
||||
|
||||
if (!SimplifiedValue.getValue())
|
||||
|
@ -4452,8 +4452,8 @@ struct AAFoldRuntimeCallCallSiteReturned : AAFoldRuntimeCall {
|
|||
IRPosition::callsite_returned(CB),
|
||||
[&](const IRPosition &IRP, const AbstractAttribute *AA,
|
||||
bool &UsedAssumedInformation) -> Optional<Value *> {
|
||||
assert((isValidState() || (SimplifiedValue.hasValue() &&
|
||||
SimplifiedValue.getValue() == nullptr)) &&
|
||||
assert((isValidState() ||
|
||||
(SimplifiedValue && SimplifiedValue.getValue() == nullptr)) &&
|
||||
"Unexpected invalid state!");
|
||||
|
||||
if (!isAtFixpoint()) {
|
||||
|
|
|
@ -132,7 +132,7 @@ void ContextTrieNode::setFunctionSamples(FunctionSamples *FSamples) {
|
|||
Optional<uint32_t> ContextTrieNode::getFunctionSize() const { return FuncSize; }
|
||||
|
||||
void ContextTrieNode::addFunctionSize(uint32_t FSize) {
|
||||
if (!FuncSize.hasValue())
|
||||
if (!FuncSize)
|
||||
FuncSize = 0;
|
||||
|
||||
FuncSize = FuncSize.getValue() + FSize;
|
||||
|
|
|
@ -2678,7 +2678,7 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
|
|||
default: {
|
||||
// Handle target specific intrinsics
|
||||
Optional<Instruction *> V = targetInstCombineIntrinsic(*II);
|
||||
if (V.hasValue())
|
||||
if (V)
|
||||
return V.getValue();
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -924,7 +924,7 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
|
|||
// Handle target specific intrinsics
|
||||
Optional<Value *> V = targetSimplifyDemandedUseBitsIntrinsic(
|
||||
*II, DemandedMask, Known, KnownBitsComputed);
|
||||
if (V.hasValue())
|
||||
if (V)
|
||||
return V.getValue();
|
||||
break;
|
||||
}
|
||||
|
@ -1635,7 +1635,7 @@ Value *InstCombinerImpl::SimplifyDemandedVectorElts(Value *V,
|
|||
Optional<Value *> V = targetSimplifyDemandedVectorEltsIntrinsic(
|
||||
*II, DemandedElts, UndefElts, UndefElts2, UndefElts3,
|
||||
simplifyAndSetOp);
|
||||
if (V.hasValue())
|
||||
if (V)
|
||||
return V.getValue();
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -483,7 +483,7 @@ void ThreadSanitizer::chooseInstructionsToInstrument(
|
|||
static bool isTsanAtomic(const Instruction *I) {
|
||||
// TODO: Ask TTI whether synchronization scope is between threads.
|
||||
auto SSID = getAtomicSyncScopeID(I);
|
||||
if (!SSID.hasValue())
|
||||
if (!SSID)
|
||||
return false;
|
||||
if (isa<LoadInst>(I) || isa<StoreInst>(I))
|
||||
return SSID.getValue() != SyncScope::SingleThread;
|
||||
|
|
|
@ -1708,7 +1708,7 @@ IntersectSignedRange(ScalarEvolution &SE,
|
|||
const InductiveRangeCheck::Range &R2) {
|
||||
if (R2.isEmpty(SE, /* IsSigned */ true))
|
||||
return None;
|
||||
if (!R1.hasValue())
|
||||
if (!R1)
|
||||
return R2;
|
||||
auto &R1Value = R1.getValue();
|
||||
// We never return empty ranges from this function, and R1 is supposed to be
|
||||
|
@ -1737,7 +1737,7 @@ IntersectUnsignedRange(ScalarEvolution &SE,
|
|||
const InductiveRangeCheck::Range &R2) {
|
||||
if (R2.isEmpty(SE, /* IsSigned */ false))
|
||||
return None;
|
||||
if (!R1.hasValue())
|
||||
if (!R1)
|
||||
return R2;
|
||||
auto &R1Value = R1.getValue();
|
||||
// We never return empty ranges from this function, and R1 is supposed to be
|
||||
|
@ -1948,10 +1948,10 @@ bool InductiveRangeCheckElimination::run(
|
|||
for (InductiveRangeCheck &IRC : RangeChecks) {
|
||||
auto Result = IRC.computeSafeIterationSpace(SE, IndVar,
|
||||
LS.IsSignedPredicate);
|
||||
if (Result.hasValue()) {
|
||||
if (Result) {
|
||||
auto MaybeSafeIterRange =
|
||||
IntersectRange(SE, SafeIterRange, Result.getValue());
|
||||
if (MaybeSafeIterRange.hasValue()) {
|
||||
if (MaybeSafeIterRange) {
|
||||
assert(
|
||||
!MaybeSafeIterRange.getValue().isEmpty(SE, LS.IsSignedPredicate) &&
|
||||
"We should never return empty ranges!");
|
||||
|
@ -1961,7 +1961,7 @@ bool InductiveRangeCheckElimination::run(
|
|||
}
|
||||
}
|
||||
|
||||
if (!SafeIterRange.hasValue())
|
||||
if (!SafeIterRange)
|
||||
return false;
|
||||
|
||||
LoopConstrainer LC(*L, LI, LPMAddNewLoop, LS, SE, DT,
|
||||
|
|
|
@ -600,7 +600,7 @@ private:
|
|||
{LLVMLoopDistributeFollowupAll,
|
||||
Part->hasDepCycle() ? LLVMLoopDistributeFollowupSequential
|
||||
: LLVMLoopDistributeFollowupCoincident});
|
||||
if (PartitionID.hasValue()) {
|
||||
if (PartitionID) {
|
||||
Loop *NewLoop = Part->getDistributedLoop();
|
||||
NewLoop->setLoopID(PartitionID.getValue());
|
||||
}
|
||||
|
|
|
@ -1481,7 +1481,7 @@ bool LoopIdiomRecognize::processLoopStoreOfLoopLoad(
|
|||
return Changed;
|
||||
// We cannot allow unaligned ops for unordered load/store, so reject
|
||||
// anything where the alignment isn't at least the element size.
|
||||
assert((StoreAlign.hasValue() && LoadAlign.hasValue()) &&
|
||||
assert((StoreAlign && LoadAlign) &&
|
||||
"Expect unordered load/store to have align.");
|
||||
if (StoreAlign.getValue() < StoreSize || LoadAlign.getValue() < StoreSize)
|
||||
return Changed;
|
||||
|
|
|
@ -372,7 +372,7 @@ tryToUnrollAndJamLoop(Loop *L, DominatorTree &DT, LoopInfo *LI,
|
|||
Optional<MDNode *> NewInnerEpilogueLoopID = makeFollowupLoopID(
|
||||
OrigOuterLoopID, {LLVMLoopUnrollAndJamFollowupAll,
|
||||
LLVMLoopUnrollAndJamFollowupRemainderInner});
|
||||
if (NewInnerEpilogueLoopID.hasValue())
|
||||
if (NewInnerEpilogueLoopID)
|
||||
SubLoop->setLoopID(NewInnerEpilogueLoopID.getValue());
|
||||
|
||||
// Find trip count and trip multiple
|
||||
|
@ -402,14 +402,14 @@ tryToUnrollAndJamLoop(Loop *L, DominatorTree &DT, LoopInfo *LI,
|
|||
Optional<MDNode *> NewOuterEpilogueLoopID = makeFollowupLoopID(
|
||||
OrigOuterLoopID, {LLVMLoopUnrollAndJamFollowupAll,
|
||||
LLVMLoopUnrollAndJamFollowupRemainderOuter});
|
||||
if (NewOuterEpilogueLoopID.hasValue())
|
||||
if (NewOuterEpilogueLoopID)
|
||||
EpilogueOuterLoop->setLoopID(NewOuterEpilogueLoopID.getValue());
|
||||
}
|
||||
|
||||
Optional<MDNode *> NewInnerLoopID =
|
||||
makeFollowupLoopID(OrigOuterLoopID, {LLVMLoopUnrollAndJamFollowupAll,
|
||||
LLVMLoopUnrollAndJamFollowupInner});
|
||||
if (NewInnerLoopID.hasValue())
|
||||
if (NewInnerLoopID)
|
||||
SubLoop->setLoopID(NewInnerLoopID.getValue());
|
||||
else
|
||||
SubLoop->setLoopID(OrigSubLoopID);
|
||||
|
@ -418,7 +418,7 @@ tryToUnrollAndJamLoop(Loop *L, DominatorTree &DT, LoopInfo *LI,
|
|||
Optional<MDNode *> NewOuterLoopID = makeFollowupLoopID(
|
||||
OrigOuterLoopID,
|
||||
{LLVMLoopUnrollAndJamFollowupAll, LLVMLoopUnrollAndJamFollowupOuter});
|
||||
if (NewOuterLoopID.hasValue()) {
|
||||
if (NewOuterLoopID) {
|
||||
L->setLoopID(NewOuterLoopID.getValue());
|
||||
|
||||
// Do not setLoopAlreadyUnrolled if a followup was given.
|
||||
|
|
|
@ -253,19 +253,19 @@ TargetTransformInfo::UnrollingPreferences llvm::gatherUnrollingPreferences(
|
|||
UP.MaxIterationsCountToAnalyze = UnrollMaxIterationsCountToAnalyze;
|
||||
|
||||
// Apply user values provided by argument
|
||||
if (UserThreshold.hasValue()) {
|
||||
if (UserThreshold) {
|
||||
UP.Threshold = *UserThreshold;
|
||||
UP.PartialThreshold = *UserThreshold;
|
||||
}
|
||||
if (UserCount.hasValue())
|
||||
if (UserCount)
|
||||
UP.Count = *UserCount;
|
||||
if (UserAllowPartial.hasValue())
|
||||
if (UserAllowPartial)
|
||||
UP.Partial = *UserAllowPartial;
|
||||
if (UserRuntime.hasValue())
|
||||
if (UserRuntime)
|
||||
UP.Runtime = *UserRuntime;
|
||||
if (UserUpperBound.hasValue())
|
||||
if (UserUpperBound)
|
||||
UP.UpperBound = *UserUpperBound;
|
||||
if (UserFullUnrollMaxCount.hasValue())
|
||||
if (UserFullUnrollMaxCount)
|
||||
UP.FullUnrollMaxCount = *UserFullUnrollMaxCount;
|
||||
|
||||
return UP;
|
||||
|
@ -1323,7 +1323,7 @@ static LoopUnrollResult tryToUnrollLoop(
|
|||
Optional<MDNode *> RemainderLoopID =
|
||||
makeFollowupLoopID(OrigLoopID, {LLVMLoopUnrollFollowupAll,
|
||||
LLVMLoopUnrollFollowupRemainder});
|
||||
if (RemainderLoopID.hasValue())
|
||||
if (RemainderLoopID)
|
||||
RemainderLoop->setLoopID(RemainderLoopID.getValue());
|
||||
}
|
||||
|
||||
|
@ -1331,7 +1331,7 @@ static LoopUnrollResult tryToUnrollLoop(
|
|||
Optional<MDNode *> NewLoopID =
|
||||
makeFollowupLoopID(OrigLoopID, {LLVMLoopUnrollFollowupAll,
|
||||
LLVMLoopUnrollFollowupUnrolled});
|
||||
if (NewLoopID.hasValue()) {
|
||||
if (NewLoopID) {
|
||||
L->setLoopID(NewLoopID.getValue());
|
||||
|
||||
// Do not setLoopAlreadyUnrolled if loop attributes have been specified
|
||||
|
|
|
@ -1775,7 +1775,7 @@ CodeExtractor::extractCodeRegion(const CodeExtractorAnalysisCache &CEAC,
|
|||
// Update the entry count of the function.
|
||||
if (BFI) {
|
||||
auto Count = BFI->getProfileCountFromFreq(EntryFreq.getFrequency());
|
||||
if (Count.hasValue())
|
||||
if (Count)
|
||||
newFunction->setEntryCount(
|
||||
ProfileCount(Count.getValue(), Function::PCT_Real)); // FIXME
|
||||
BFI->setBlockFreq(codeReplacer, EntryFreq.getFrequency());
|
||||
|
|
|
@ -719,9 +719,9 @@ TargetTransformInfo::PeelingPreferences llvm::gatherPeelingPreferences(
|
|||
}
|
||||
|
||||
// User specifed values provided by argument.
|
||||
if (UserAllowPeeling.hasValue())
|
||||
if (UserAllowPeeling)
|
||||
PP.AllowPeeling = *UserAllowPeeling;
|
||||
if (UserAllowProfileBasedPeeling.hasValue())
|
||||
if (UserAllowProfileBasedPeeling)
|
||||
PP.PeelProfiledIterations = *UserAllowProfileBasedPeeling;
|
||||
|
||||
return PP;
|
||||
|
|
|
@ -397,7 +397,7 @@ CloneLoopBlocks(Loop *L, Value *NewIter, const bool UseEpilogRemainder,
|
|||
|
||||
Optional<MDNode *> NewLoopID = makeFollowupLoopID(
|
||||
LoopID, {LLVMLoopUnrollFollowupAll, LLVMLoopUnrollFollowupRemainder});
|
||||
if (NewLoopID.hasValue()) {
|
||||
if (NewLoopID) {
|
||||
NewLoop->setLoopID(NewLoopID.getValue());
|
||||
|
||||
// Do not setLoopAlreadyUnrolled if loop attributes have been defined
|
||||
|
|
|
@ -358,7 +358,7 @@ TransformationMode llvm::hasUnrollTransformation(const Loop *L) {
|
|||
|
||||
Optional<int> Count =
|
||||
getOptionalIntLoopAttribute(L, "llvm.loop.unroll.count");
|
||||
if (Count.hasValue())
|
||||
if (Count)
|
||||
return Count.getValue() == 1 ? TM_SuppressedByUser : TM_ForcedByUser;
|
||||
|
||||
if (getBooleanLoopAttribute(L, "llvm.loop.unroll.enable"))
|
||||
|
@ -379,7 +379,7 @@ TransformationMode llvm::hasUnrollAndJamTransformation(const Loop *L) {
|
|||
|
||||
Optional<int> Count =
|
||||
getOptionalIntLoopAttribute(L, "llvm.loop.unroll_and_jam.count");
|
||||
if (Count.hasValue())
|
||||
if (Count)
|
||||
return Count.getValue() == 1 ? TM_SuppressedByUser : TM_ForcedByUser;
|
||||
|
||||
if (getBooleanLoopAttribute(L, "llvm.loop.unroll_and_jam.enable"))
|
||||
|
|
|
@ -219,7 +219,7 @@ void verifyMisExpect(Instruction &I, ArrayRef<uint32_t> RealWeights,
|
|||
void checkBackendInstrumentation(Instruction &I,
|
||||
const ArrayRef<uint32_t> RealWeights) {
|
||||
auto ExpectedWeightsOpt = extractWeights(&I, I.getContext());
|
||||
if (!ExpectedWeightsOpt.hasValue())
|
||||
if (!ExpectedWeightsOpt)
|
||||
return;
|
||||
auto ExpectedWeights = ExpectedWeightsOpt.getValue();
|
||||
verifyMisExpect(I, RealWeights, ExpectedWeights);
|
||||
|
@ -228,7 +228,7 @@ void checkBackendInstrumentation(Instruction &I,
|
|||
void checkFrontendInstrumentation(Instruction &I,
|
||||
const ArrayRef<uint32_t> ExpectedWeights) {
|
||||
auto RealWeightsOpt = extractWeights(&I, I.getContext());
|
||||
if (!RealWeightsOpt.hasValue())
|
||||
if (!RealWeightsOpt)
|
||||
return;
|
||||
auto RealWeights = RealWeightsOpt.getValue();
|
||||
verifyMisExpect(I, RealWeights, ExpectedWeights);
|
||||
|
|
|
@ -254,7 +254,7 @@ void VFABI::setVectorVariantNames(CallInst *CI,
|
|||
for (const std::string &VariantMapping : VariantMappings) {
|
||||
LLVM_DEBUG(dbgs() << "VFABI: adding mapping '" << VariantMapping << "'\n");
|
||||
Optional<VFInfo> VI = VFABI::tryDemangleForVFABI(VariantMapping, *M);
|
||||
assert(VI.hasValue() && "Cannot add an invalid VFABI name.");
|
||||
assert(VI && "Cannot add an invalid VFABI name.");
|
||||
assert(M->getNamedValue(VI.getValue().VectorName) &&
|
||||
"Cannot add variant to attribute: "
|
||||
"vector function declaration is missing.");
|
||||
|
|
|
@ -7612,7 +7612,7 @@ void LoopVectorizationPlanner::executePlan(ElementCount BestVF, unsigned BestUF,
|
|||
VPBasicBlock *HeaderVPBB =
|
||||
BestVPlan.getVectorLoopRegion()->getEntryBasicBlock();
|
||||
Loop *L = LI->getLoopFor(State.CFG.VPBB2IRBB[HeaderVPBB]);
|
||||
if (VectorizedLoopID.hasValue())
|
||||
if (VectorizedLoopID)
|
||||
L->setLoopID(VectorizedLoopID.getValue());
|
||||
else {
|
||||
// Keep all loop hints from the original loop on the vector loop (we'll
|
||||
|
@ -10622,7 +10622,7 @@ bool LoopVectorizePass::processLoop(Loop *L) {
|
|||
Optional<MDNode *> RemainderLoopID =
|
||||
makeFollowupLoopID(OrigLoopID, {LLVMLoopVectorizeFollowupAll,
|
||||
LLVMLoopVectorizeFollowupEpilogue});
|
||||
if (RemainderLoopID.hasValue()) {
|
||||
if (RemainderLoopID) {
|
||||
L->setLoopID(RemainderLoopID.getValue());
|
||||
} else {
|
||||
if (DisableRuntimeUnroll)
|
||||
|
|
|
@ -2636,7 +2636,7 @@ private:
|
|||
// First check if the result is already in the cache.
|
||||
AliasCacheKey key = std::make_pair(Inst1, Inst2);
|
||||
Optional<bool> &result = AliasCache[key];
|
||||
if (result.hasValue()) {
|
||||
if (result) {
|
||||
return result.getValue();
|
||||
}
|
||||
bool aliased = true;
|
||||
|
|
|
@ -98,14 +98,14 @@ static bool getWindowsSDKDirViaCommandLine(
|
|||
llvm::Optional<llvm::StringRef> WinSdkVersion,
|
||||
llvm::Optional<llvm::StringRef> WinSysRoot, std::string &Path, int &Major,
|
||||
std::string &Version) {
|
||||
if (WinSdkDir.hasValue() || WinSysRoot.hasValue()) {
|
||||
if (WinSdkDir || WinSysRoot) {
|
||||
// Don't validate the input; trust the value supplied by the user.
|
||||
// The motivation is to prevent unnecessary file and registry access.
|
||||
llvm::VersionTuple SDKVersion;
|
||||
if (WinSdkVersion.hasValue())
|
||||
if (WinSdkVersion)
|
||||
SDKVersion.tryParse(*WinSdkVersion);
|
||||
|
||||
if (WinSysRoot.hasValue()) {
|
||||
if (WinSysRoot) {
|
||||
llvm::SmallString<128> SDKPath(*WinSysRoot);
|
||||
llvm::sys::path::append(SDKPath, "Windows Kits");
|
||||
if (!SDKVersion.empty())
|
||||
|
@ -479,12 +479,12 @@ bool findVCToolChainViaCommandLine(vfs::FileSystem &VFS,
|
|||
std::string &Path, ToolsetLayout &VSLayout) {
|
||||
// Don't validate the input; trust the value supplied by the user.
|
||||
// The primary motivation is to prevent unnecessary file and registry access.
|
||||
if (VCToolsDir.hasValue() || WinSysRoot.hasValue()) {
|
||||
if (WinSysRoot.hasValue()) {
|
||||
if (VCToolsDir || WinSysRoot) {
|
||||
if (WinSysRoot) {
|
||||
SmallString<128> ToolsPath(*WinSysRoot);
|
||||
sys::path::append(ToolsPath, "VC", "Tools", "MSVC");
|
||||
std::string ToolsVersion;
|
||||
if (VCToolsVersion.hasValue())
|
||||
if (VCToolsVersion)
|
||||
ToolsVersion = VCToolsVersion->str();
|
||||
else
|
||||
ToolsVersion = getHighestNumericTupleInDirectory(VFS, ToolsPath);
|
||||
|
|
|
@ -561,12 +561,12 @@ void SourceCoverageViewHTML::renderLine(raw_ostream &OS, LineRef L,
|
|||
else
|
||||
Color = None;
|
||||
|
||||
if (Color.hasValue())
|
||||
if (Color)
|
||||
Snippets[I + 1] = Highlight(Snippets[I + 1], CurSeg->Col,
|
||||
CurSeg->Col + Snippets[I + 1].size());
|
||||
}
|
||||
|
||||
if (Color.hasValue() && Segments.empty())
|
||||
if (Color && Segments.empty())
|
||||
Snippets.back() = Highlight(Snippets.back(), 1, 1 + Snippets.back().size());
|
||||
|
||||
if (getOptions().Debug) {
|
||||
|
|
|
@ -70,7 +70,7 @@ void InstructionInfoView::printView(raw_ostream &OS) const {
|
|||
else if (IIVDEntry.Latency < 100)
|
||||
TempStream << ' ';
|
||||
|
||||
if (IIVDEntry.RThroughput.hasValue()) {
|
||||
if (IIVDEntry.RThroughput) {
|
||||
double RT = IIVDEntry.RThroughput.getValue();
|
||||
TempStream << format("%.2f", RT) << ' ';
|
||||
if (RT < 10.0)
|
||||
|
|
|
@ -1408,7 +1408,7 @@ static void disassembleObject(const Target *TheTarget, const ObjectFile *Obj,
|
|||
// Right now, most targets return None i.e ignore to treat a symbol
|
||||
// separately. But WebAssembly decodes preludes for some symbols.
|
||||
//
|
||||
if (Status.hasValue()) {
|
||||
if (Status) {
|
||||
if (Status.getValue() == MCDisassembler::Fail) {
|
||||
outs() << "// Error in decoding " << SymbolName
|
||||
<< " : Decoding failed region as bytes.\n";
|
||||
|
|
|
@ -777,12 +777,12 @@ mergeSampleProfile(const WeightedFileVector &Inputs, SymbolRemapper *Remapper,
|
|||
}
|
||||
|
||||
SampleProfileMap &Profiles = Reader->getProfiles();
|
||||
if (ProfileIsProbeBased.hasValue() &&
|
||||
if (ProfileIsProbeBased &&
|
||||
ProfileIsProbeBased != FunctionSamples::ProfileIsProbeBased)
|
||||
exitWithError(
|
||||
"cannot merge probe-based profile with non-probe-based profile");
|
||||
ProfileIsProbeBased = FunctionSamples::ProfileIsProbeBased;
|
||||
if (ProfileIsCS.hasValue() && ProfileIsCS != FunctionSamples::ProfileIsCS)
|
||||
if (ProfileIsCS && ProfileIsCS != FunctionSamples::ProfileIsCS)
|
||||
exitWithError("cannot merge CS profile with non-CS profile");
|
||||
ProfileIsCS = FunctionSamples::ProfileIsCS;
|
||||
for (SampleProfileMap::iterator I = Profiles.begin(), E = Profiles.end();
|
||||
|
|
|
@ -100,25 +100,24 @@ BinarySizeContextTracker::getFuncSizeForContext(const SampleContext &Context) {
|
|||
PrevNode = CurrNode;
|
||||
CurrNode =
|
||||
CurrNode->getChildContext(ChildFrame.Location, ChildFrame.FuncName);
|
||||
if (CurrNode && CurrNode->getFunctionSize().hasValue())
|
||||
if (CurrNode && CurrNode->getFunctionSize())
|
||||
Size = CurrNode->getFunctionSize().getValue();
|
||||
}
|
||||
|
||||
// If we traversed all nodes along the path of the context and haven't
|
||||
// found a size yet, pivot to look for size from sibling nodes, i.e size
|
||||
// of inlinee under different context.
|
||||
if (!Size.hasValue()) {
|
||||
if (!Size) {
|
||||
if (!CurrNode)
|
||||
CurrNode = PrevNode;
|
||||
while (!Size.hasValue() && CurrNode &&
|
||||
!CurrNode->getAllChildContext().empty()) {
|
||||
while (!Size && CurrNode && !CurrNode->getAllChildContext().empty()) {
|
||||
CurrNode = &CurrNode->getAllChildContext().begin()->second;
|
||||
if (CurrNode->getFunctionSize().hasValue())
|
||||
if (CurrNode->getFunctionSize())
|
||||
Size = CurrNode->getFunctionSize().getValue();
|
||||
}
|
||||
}
|
||||
|
||||
assert(Size.hasValue() && "We should at least find one context size.");
|
||||
assert(Size && "We should at least find one context size.");
|
||||
return Size.getValue();
|
||||
}
|
||||
|
||||
|
|
|
@ -85,10 +85,9 @@ exportToFile(const StringRef FilePath,
|
|||
Optional<unsigned> End =
|
||||
getPositionInModule((*C.back()).Inst, LLVMInstNum);
|
||||
|
||||
assert(Start.hasValue() &&
|
||||
assert(Start &&
|
||||
"Could not find instruction number for first instruction");
|
||||
assert(End.hasValue() &&
|
||||
"Could not find instruction number for last instruction");
|
||||
assert(End && "Could not find instruction number for last instruction");
|
||||
|
||||
J.object([&] {
|
||||
J.attribute("start", Start.getValue());
|
||||
|
|
|
@ -40,8 +40,8 @@ dumpDXContainer(MemoryBufferRef Source) {
|
|||
Obj->Header.PartOffsets->push_back(P.Offset);
|
||||
if (P.Part.getName() == "DXIL") {
|
||||
Optional<DXContainer::DXILData> DXIL = Container.getDXIL();
|
||||
assert(DXIL.hasValue() && "Since we are iterating and found a DXIL part, "
|
||||
"this should never not have a value");
|
||||
assert(DXIL && "Since we are iterating and found a DXIL part, "
|
||||
"this should never not have a value");
|
||||
Obj->Parts.push_back(DXContainerYAML::Part{
|
||||
P.Part.getName().str(), P.Part.Size,
|
||||
DXContainerYAML::DXILProgram{
|
||||
|
|
|
@ -75,7 +75,7 @@ protected:
|
|||
reset(Name, IRType);
|
||||
|
||||
const auto OptInfo = VFABI::tryDemangleForVFABI(MangledName, *(M.get()));
|
||||
if (OptInfo.hasValue()) {
|
||||
if (OptInfo) {
|
||||
Info = OptInfo.getValue();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -233,7 +233,7 @@ TEST_F(VPIntrinsicTest, GetParamPos) {
|
|||
ASSERT_TRUE(F.isIntrinsic());
|
||||
Optional<unsigned> MaskParamPos =
|
||||
VPIntrinsic::getMaskParamPos(F.getIntrinsicID());
|
||||
if (MaskParamPos.hasValue()) {
|
||||
if (MaskParamPos) {
|
||||
Type *MaskParamType = F.getArg(MaskParamPos.getValue())->getType();
|
||||
ASSERT_TRUE(MaskParamType->isVectorTy());
|
||||
ASSERT_TRUE(
|
||||
|
@ -242,7 +242,7 @@ TEST_F(VPIntrinsicTest, GetParamPos) {
|
|||
|
||||
Optional<unsigned> VecLenParamPos =
|
||||
VPIntrinsic::getVectorLengthParamPos(F.getIntrinsicID());
|
||||
if (VecLenParamPos.hasValue()) {
|
||||
if (VecLenParamPos) {
|
||||
Type *VecLenParamType = F.getArg(VecLenParamPos.getValue())->getType();
|
||||
ASSERT_TRUE(VecLenParamType->isIntegerTy(32));
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ MATCHER_P4(FrameContains, FunctionName, LineOffset, Column, Inline, "") {
|
|||
*result_listener << "Hash mismatch";
|
||||
return false;
|
||||
}
|
||||
if (F.SymbolName.hasValue() && F.SymbolName.getValue() != FunctionName) {
|
||||
if (F.SymbolName && F.SymbolName.getValue() != FunctionName) {
|
||||
*result_listener << "SymbolName mismatch\nWant: " << FunctionName
|
||||
<< "\nGot: " << F.SymbolName.getValue();
|
||||
return false;
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
StringRef getName() const { return Name; }
|
||||
unsigned getInstrID() const { return InstrID; }
|
||||
unsigned getOpIdx() const {
|
||||
assert(OpIdx.hasValue() && "Is not an operand binding");
|
||||
assert(OpIdx && "Is not an operand binding");
|
||||
return *OpIdx;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -2936,12 +2936,12 @@ public:
|
|||
}
|
||||
|
||||
void emitRenderOpcodes(MatchTable &Table, RuleMatcher &Rule) const override {
|
||||
Table << MatchTable::Opcode(SubOperand.hasValue() ? "GIR_ComplexSubOperandRenderer"
|
||||
: "GIR_ComplexRenderer")
|
||||
Table << MatchTable::Opcode(SubOperand ? "GIR_ComplexSubOperandRenderer"
|
||||
: "GIR_ComplexRenderer")
|
||||
<< MatchTable::Comment("InsnID") << MatchTable::IntValue(InsnID)
|
||||
<< MatchTable::Comment("RendererID")
|
||||
<< MatchTable::IntValue(RendererID);
|
||||
if (SubOperand.hasValue())
|
||||
if (SubOperand)
|
||||
Table << MatchTable::Comment("SubOperand")
|
||||
<< MatchTable::IntValue(SubOperand.getValue());
|
||||
Table << MatchTable::Comment(SymbolicName) << MatchTable::LineBreak;
|
||||
|
|
Loading…
Reference in New Issue