Original file line number Diff line number Diff line change
Expand Up @@ -745,4 +745,4 @@ lldb_private::npdb::GetRegisterSize(llvm::codeview::RegisterId register_id) {
default:
return 0;
}
}
}
4 changes: 2 additions & 2 deletions lldb/source/Plugins/TraceExporter/common/TraceHTR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ size_t HTRBlockMetadata::GetNumInstructions() const {
llvm::Optional<llvm::StringRef>
HTRBlockMetadata::GetMostFrequentlyCalledFunction() const {
size_t max_ncalls = 0;
llvm::Optional<llvm::StringRef> max_name = llvm::None;
llvm::Optional<llvm::StringRef> max_name;
for (const auto &it : m_func_calls) {
ConstString name = it.first;
size_t ncalls = it.second;
Expand Down Expand Up @@ -316,7 +316,7 @@ HTRBlockLayerUP lldb_private::BasicSuperBlockMerge(IHTRLayer &layer) {
// Each super block always has the same first unit (we call this the
// super block head) This gurantee allows us to use the super block head as
// the unique key mapping to the super block it begins
llvm::Optional<size_t> superblock_head = llvm::None;
llvm::Optional<size_t> superblock_head;
auto construct_next_layer = [&](size_t merge_start, size_t n) -> void {
if (!superblock_head)
return;
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Target/Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4374,7 +4374,7 @@ void TargetProperties::CheckJITObjectsDir() {
else if (!writable)
os << "is not writable";

llvm::Optional<lldb::user_id_t> debugger_id = llvm::None;
llvm::Optional<lldb::user_id_t> debugger_id;
if (m_target)
debugger_id = m_target->GetDebugger().GetID();
Debugger::ReportError(os.str(), debugger_id);
Expand Down
20 changes: 8 additions & 12 deletions lldb/source/Utility/ArchSpec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,13 @@ struct ArchDefinition {
};

void ArchSpec::ListSupportedArchNames(StringList &list) {
for (uint32_t i = 0; i < llvm::array_lengthof(g_core_definitions); ++i)
list.AppendString(g_core_definitions[i].name);
for (const auto &def : g_core_definitions)
list.AppendString(def.name);
}

void ArchSpec::AutoComplete(CompletionRequest &request) {
for (uint32_t i = 0; i < llvm::array_lengthof(g_core_definitions); ++i)
request.TryCompleteCurrentArg(g_core_definitions[i].name);
for (const auto &def : g_core_definitions)
request.TryCompleteCurrentArg(def.name);
}

#define CPU_ANY (UINT32_MAX)
Expand Down Expand Up @@ -446,16 +446,12 @@ static const ArchDefinition g_coff_arch_def = {
static const ArchDefinition *g_arch_definitions[] = {
&g_macho_arch_def, &g_elf_arch_def, &g_coff_arch_def};

static const size_t k_num_arch_definitions =
llvm::array_lengthof(g_arch_definitions);

//===----------------------------------------------------------------------===//
// Static helper functions.

// Get the architecture definition for a given object type.
static const ArchDefinition *FindArchDefinition(ArchitectureType arch_type) {
for (unsigned int i = 0; i < k_num_arch_definitions; ++i) {
const ArchDefinition *def = g_arch_definitions[i];
for (const ArchDefinition *def : g_arch_definitions) {
if (def->type == arch_type)
return def;
}
Expand All @@ -464,9 +460,9 @@ static const ArchDefinition *FindArchDefinition(ArchitectureType arch_type) {

// Get an architecture definition by name.
static const CoreDefinition *FindCoreDefinition(llvm::StringRef name) {
for (unsigned int i = 0; i < llvm::array_lengthof(g_core_definitions); ++i) {
if (name.equals_insensitive(g_core_definitions[i].name))
return &g_core_definitions[i];
for (const auto &def : g_core_definitions) {
if (name.equals_insensitive(def.name))
return &def;
}
return nullptr;
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/ExecutionEngine/JITLink/i386.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ const char *getEdgeKindName(Edge::Kind K);
} // namespace jitlink
} // namespace llvm

#endif // LLVM_EXECUTIONENGINE_JITLINK_I386_H
#endif // LLVM_EXECUTIONENGINE_JITLINK_I386_H
4 changes: 2 additions & 2 deletions llvm/lib/Analysis/ScalarEvolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8086,7 +8086,7 @@ unsigned ScalarEvolution::getSmallConstantTripMultiple(const Loop *L) {
SmallVector<BasicBlock *, 8> ExitingBlocks;
L->getExitingBlocks(ExitingBlocks);

Optional<unsigned> Res = None;
Optional<unsigned> Res;
for (auto *ExitingBB : ExitingBlocks) {
unsigned Multiple = getSmallConstantTripMultiple(L, ExitingBB);
if (!Res)
Expand Down Expand Up @@ -10049,7 +10049,7 @@ SolveQuadraticAddRecRange(const SCEVAddRecExpr *AddRec,
<< Bound << " (before multiplying by " << M << ")\n");
Bound *= M; // The quadratic equation multiplier.

Optional<APInt> SO = None;
Optional<APInt> SO;
if (BitWidth > 1) {
LLVM_DEBUG(dbgs() << "SolveQuadraticAddRecRange: solving for "
"signed overflow\n");
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ Error BitcodeAnalyzer::parseBlock(unsigned BlockID, unsigned IndentLevel,
// Keep it for later, when we see a MODULE_HASH record
uint64_t BlockEntryPos = Stream.getCurrentByteNo();

Optional<const char *> BlockName = None;
Optional<const char *> BlockName;
if (DumpRecords) {
O->OS << Indent << "<";
if ((BlockName = GetBlockName(BlockID, BlockInfo, CurStreamType)))
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ bool DwarfExpression::addExpression(
// and not any other parts of the following DWARF expression.
assert(!IsEmittingEntryValue && "Can't emit entry value around expression");

Optional<DIExpression::ExprOperand> PrevConvertOp = None;
Optional<DIExpression::ExprOperand> PrevConvertOp;

while (ExprCursor) {
auto Op = ExprCursor.take();
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1841,7 +1841,7 @@ LegalizerHelper::widenScalarAddSubOverflow(MachineInstr &MI, unsigned TypeIdx,
LLT WideTy) {
unsigned Opcode;
unsigned ExtOpcode;
Optional<Register> CarryIn = None;
Optional<Register> CarryIn;
switch (MI.getOpcode()) {
default:
llvm_unreachable("Unexpected opcode!");
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/GlobalISel/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ Optional<ValueAndVReg> getAnyConstantSplat(Register VReg,
if (!isBuildVectorOp(MI->getOpcode()))
return None;

Optional<ValueAndVReg> SplatValAndReg = None;
Optional<ValueAndVReg> SplatValAndReg;
for (MachineOperand &Op : MI->uses()) {
Register Element = Op.getReg();
auto ElementValAndReg =
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ class TransferTracker {

// Examine the remaining variable locations: if we can find the same value
// again, we can recover the location.
Optional<LocIdx> NewLoc = None;
Optional<LocIdx> NewLoc;
for (auto Loc : MTracker->locations())
if (Loc.Value == OldValue)
NewLoc = Loc.Idx;
Expand Down Expand Up @@ -1145,7 +1145,7 @@ bool InstrRefBasedLDV::transferDebugInstrRef(MachineInstr &MI,

// Default machine value number is <None> -- if no instruction defines
// the corresponding value, it must have been optimized out.
Optional<ValueIDNum> NewID = None;
Optional<ValueIDNum> NewID;

// Try to lookup the instruction number, and find the machine value number
// that it defines. It could be an instruction, or a PHI.
Expand Down Expand Up @@ -1278,7 +1278,7 @@ bool InstrRefBasedLDV::transferDebugInstrRef(MachineInstr &MI,

// Pick a location for the machine value number, if such a location exists.
// (This information could be stored in TransferTracker to make it faster).
Optional<LocIdx> FoundLoc = None;
Optional<LocIdx> FoundLoc;
for (auto Location : MTracker->locations()) {
LocIdx CurL = Location.Idx;
ValueIDNum ID = MTracker->readMLoc(CurL);
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/SelectOptimize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ Optional<uint64_t> SelectOptimize::computeInstCost(const Instruction *I) {
TTI->getInstructionCost(I, TargetTransformInfo::TCK_Latency);
if (auto OC = ICost.getValue())
return Optional<uint64_t>(*OC);
return Optional<uint64_t>(None);
return Optional<uint64_t>();
}

ScaledNumber<uint64_t>
Expand Down
10 changes: 5 additions & 5 deletions llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2579,11 +2579,11 @@ void DAGTypeLegalizer::SplitVecRes_VECTOR_SHUFFLE(ShuffleVectorSDNode *N,
NewElts](SmallVectorImpl<int> &Mask) {
SetVector<SDValue> UniqueInputs;
SetVector<SDValue> UniqueConstantInputs;
for (unsigned I = 0; I < array_lengthof(Inputs); ++I) {
if (IsConstant(Inputs[I]))
UniqueConstantInputs.insert(Inputs[I]);
else if (!Inputs[I].isUndef())
UniqueInputs.insert(Inputs[I]);
for (const auto &I : Inputs) {
if (IsConstant(I))
UniqueConstantInputs.insert(I);
else if (!I.isUndef())
UniqueInputs.insert(I);
}
// Adjust mask in case of reused inputs. Also, need to insert constant
// inputs at first, otherwise it affects the final outcome.
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10489,7 +10489,7 @@ void SelectionDAGISel::LowerArguments(const Function &F) {
ValueVTs);
MVT VT = ValueVTs[0].getSimpleVT();
MVT RegVT = TLI->getRegisterType(*CurDAG->getContext(), VT);
Optional<ISD::NodeType> AssertOp = None;
Optional<ISD::NodeType> AssertOp;
SDValue ArgValue = getCopyFromParts(DAG, dl, &InVals[0], 1, RegVT, VT,
nullptr, F.getCallingConv(), AssertOp);

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ static Optional<int> findPreviousSpillSlot(const Value *Val,
// All incoming values should have same known stack slot, otherwise result
// is unknown.
if (const PHINode *Phi = dyn_cast<PHINode>(Val)) {
Optional<int> MergedResult = None;
Optional<int> MergedResult;

for (const auto &IncomingValue : Phi->incoming_values()) {
Optional<int> SpillSlot =
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class SourceCode {

SourceCode(
StringRef FileName, int64_t Line, int Lines,
const Optional<StringRef> &EmbeddedSource = Optional<StringRef>(None))
const Optional<StringRef> &EmbeddedSource = Optional<StringRef>())
: Line(Line), Lines(Lines),
FirstLine(std::max(static_cast<int64_t>(1), Line - Lines / 2)),
LastLine(FirstLine + Lines - 1),
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/ExecutionEngine/JITLink/ELF_i386.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,4 @@ void link_ELF_i386(std::unique_ptr<LinkGraph> G,
}

} // namespace jitlink
} // namespace llvm
} // namespace llvm
2 changes: 1 addition & 1 deletion llvm/lib/ExecutionEngine/JITLink/i386.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ const char *getEdgeKindName(Edge::Kind K) {
}
} // namespace i386
} // namespace jitlink
} // namespace llvm
} // namespace llvm
4 changes: 2 additions & 2 deletions llvm/lib/IR/FPEnv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Optional<RoundingMode> convertStrToRoundingMode(StringRef RoundingArg) {
}

Optional<StringRef> convertRoundingModeToStr(RoundingMode UseRounding) {
Optional<StringRef> RoundingStr = None;
Optional<StringRef> RoundingStr;
switch (UseRounding) {
case RoundingMode::Dynamic:
RoundingStr = "round.dynamic";
Expand Down Expand Up @@ -71,7 +71,7 @@ convertStrToExceptionBehavior(StringRef ExceptionArg) {

Optional<StringRef>
convertExceptionBehaviorToStr(fp::ExceptionBehavior UseExcept) {
Optional<StringRef> ExceptStr = None;
Optional<StringRef> ExceptStr;
switch (UseExcept) {
case fp::ebStrict:
ExceptStr = "fpexcept.strict";
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/LTO/LTOBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ createTargetMachine(const Config &Conf, const Target *TheTarget, Module &M) {
for (const std::string &A : Conf.MAttrs)
Features.AddFeature(A);

Optional<Reloc::Model> RelocModel = None;
Optional<Reloc::Model> RelocModel;
if (Conf.RelocModel)
RelocModel = *Conf.RelocModel;
else if (M.getModuleFlag("PIC Level"))
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Object/ELFObjectFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ ELFObjectFileBase::getPltAddresses() const {
T->createMCInstrAnalysis(MII.get()));
if (!MIA)
return {};
Optional<SectionRef> Plt = None, RelaPlt = None, GotPlt = None;
Optional<SectionRef> Plt, RelaPlt, GotPlt;
for (const SectionRef &Section : sections()) {
Expected<StringRef> NameOrErr = Section.getName();
if (!NameOrErr) {
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Remarks/RemarkLinker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Error RemarkLinker::link(StringRef Buffer, Optional<Format> RemarkFormat) {
createRemarkParserFromMeta(
*RemarkFormat, Buffer, /*StrTab=*/None,
PrependPath ? Optional<StringRef>(StringRef(*PrependPath))
: Optional<StringRef>(None));
: Optional<StringRef>());
if (!MaybeParser)
return MaybeParser.takeError();

Expand Down
8 changes: 3 additions & 5 deletions llvm/lib/Support/ARMAttributeParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,11 +463,9 @@ Error ARMAttributeParser::also_compatible_with(AttrType tag) {

Error ARMAttributeParser::handler(uint64_t tag, bool &handled) {
handled = false;
for (unsigned AHI = 0, AHE = array_lengthof(displayRoutines); AHI != AHE;
++AHI) {
if (uint64_t(displayRoutines[AHI].attribute) == tag) {
if (Error e =
(this->*displayRoutines[AHI].routine)(static_cast<AttrType>(tag)))
for (const auto &AH : displayRoutines) {
if (uint64_t(AH.attribute) == tag) {
if (Error e = (this->*AH.routine)(static_cast<AttrType>(tag)))
return e;
handled = true;
break;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Support/ARMBuildAttrs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ static const TagNameItem tagData[] = {
constexpr TagNameMap ARMAttributeTags{tagData};
const TagNameMap &llvm::ARMBuildAttrs::getARMAttributeTags() {
return ARMAttributeTags;
}
}
7 changes: 3 additions & 4 deletions llvm/lib/Support/CSKYAttributeParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,9 @@ const CSKYAttributeParser::DisplayHandler

Error CSKYAttributeParser::handler(uint64_t tag, bool &handled) {
handled = false;
for (unsigned AHI = 0, AHE = array_lengthof(displayRoutines); AHI != AHE;
++AHI) {
if (uint64_t(displayRoutines[AHI].attribute) == tag) {
if (Error e = (this->*displayRoutines[AHI].routine)(tag))
for (const auto &AH : displayRoutines) {
if (uint64_t(AH.attribute) == tag) {
if (Error e = (this->*AH.routine)(tag))
return e;
handled = true;
break;
Expand Down
7 changes: 3 additions & 4 deletions llvm/lib/Support/RISCVAttributeParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ Error RISCVAttributeParser::stackAlign(unsigned tag) {

Error RISCVAttributeParser::handler(uint64_t tag, bool &handled) {
handled = false;
for (unsigned AHI = 0, AHE = array_lengthof(displayRoutines); AHI != AHE;
++AHI) {
if (uint64_t(displayRoutines[AHI].attribute) == tag) {
if (Error e = (this->*displayRoutines[AHI].routine)(tag))
for (const auto &AH : displayRoutines) {
if (uint64_t(AH.attribute) == tag) {
if (Error e = (this->*AH.routine)(tag))
return e;
handled = true;
break;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Support/Threading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ unsigned llvm::ThreadPoolStrategy::compute_thread_count() const {
// main thread (8MB) before creation.
const llvm::Optional<unsigned> llvm::thread::DefaultStackSize = 8 * 1024 * 1024;
#else
const llvm::Optional<unsigned> llvm::thread::DefaultStackSize = None;
const llvm::Optional<unsigned> llvm::thread::DefaultStackSize;
#endif


Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1522,7 +1522,7 @@ AArch64LoadStoreOpt::findMatchingInsn(MachineBasicBlock::iterator I,
int OffsetStride = IsUnscaled ? TII->getMemScale(FirstMI) : 1;
bool IsPromotableZeroStore = isPromotableZeroStoreInst(FirstMI);

Optional<bool> MaybeCanRename = None;
Optional<bool> MaybeCanRename;
if (!EnableRenaming)
MaybeCanRename = {false};

Expand Down
7 changes: 2 additions & 5 deletions llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,11 +676,8 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
// to be the same size as the dest.
if (DstTy != SrcTy)
return false;
for (auto &Ty : {v2s32, v4s32, v2s64, v2p0, v16s8, v8s16}) {
if (DstTy == Ty)
return true;
}
return false;
return llvm::is_contained({v2s32, v4s32, v2s64, v2p0, v16s8, v8s16},
DstTy);
})
// G_SHUFFLE_VECTOR can have scalar sources (from 1 x s vectors), we
// just want those lowered into G_BUILD_VECTOR
Expand Down
7 changes: 3 additions & 4 deletions llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,10 +705,9 @@ static const LdStNInstrDesc LdStNInstInfo[] = {
};

static const LdStNInstrDesc *getLdStNInstrDesc(unsigned Opcode) {
unsigned Idx;
for (Idx = 0; Idx != array_lengthof(LdStNInstInfo); ++Idx)
if (LdStNInstInfo[Idx].Opcode == Opcode)
return &LdStNInstInfo[Idx];
for (const auto &Info : LdStNInstInfo)
if (Info.Opcode == Opcode)
return &Info;

return nullptr;
}
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2468,9 +2468,9 @@ static const AddSubFlagsOpcodePair AddSubFlagsOpcodeMap[] = {
};

unsigned llvm::convertAddSubFlagsOpcode(unsigned OldOpc) {
for (unsigned i = 0, e = array_lengthof(AddSubFlagsOpcodeMap); i != e; ++i)
if (OldOpc == AddSubFlagsOpcodeMap[i].PseudoOpc)
return AddSubFlagsOpcodeMap[i].MachineOpc;
for (const auto &Entry : AddSubFlagsOpcodeMap)
if (OldOpc == Entry.PseudoOpc)
return Entry.MachineOpc;
return 0;
}

Expand Down
9 changes: 4 additions & 5 deletions llvm/lib/Target/PowerPC/PPCLoopInstrFormPrep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1049,16 +1049,15 @@ bool PPCLoopInstrFormPrep::rewriteLoadStores(
SmallPtrSet<Value *, 16> NewPtrs;
NewPtrs.insert(Base.first);

for (auto I = std::next(BucketChain.Elements.begin()),
IE = BucketChain.Elements.end(); I != IE; ++I) {
Value *Ptr = getPointerOperandAndType(I->Instr);
for (const BucketElement &BE : llvm::drop_begin(BucketChain.Elements)) {
Value *Ptr = getPointerOperandAndType(BE.Instr);
assert(Ptr && "No pointer operand");
if (NewPtrs.count(Ptr))
continue;

Instruction *NewPtr = rewriteForBucketElement(
Base, *I,
I->Offset ? cast<SCEVConstant>(I->Offset)->getValue() : nullptr,
Base, BE,
BE.Offset ? cast<SCEVConstant>(BE.Offset)->getValue() : nullptr,
DeletedPtrs);
assert(NewPtr && "wrong rewrite!\n");
NewPtrs.insert(NewPtr);
Expand Down
9 changes: 4 additions & 5 deletions llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ SystemZELFFrameLowering::SystemZELFFrameLowering()
// Create a mapping from register number to save slot offset.
// These offsets are relative to the start of the register save area.
RegSpillOffsets.grow(SystemZ::NUM_TARGET_REGS);
for (unsigned I = 0, E = array_lengthof(ELFSpillOffsetTable); I != E; ++I)
RegSpillOffsets[ELFSpillOffsetTable[I].Reg] = ELFSpillOffsetTable[I].Offset;
for (const auto &Entry : ELFSpillOffsetTable)
RegSpillOffsets[Entry.Reg] = Entry.Offset;
}

// Add GPR64 to the save instruction being built by MIB, which is in basic
Expand Down Expand Up @@ -906,9 +906,8 @@ SystemZXPLINKFrameLowering::SystemZXPLINKFrameLowering()
// Create a mapping from register number to save slot offset.
// These offsets are relative to the start of the local are area.
RegSpillOffsets.grow(SystemZ::NUM_TARGET_REGS);
for (unsigned I = 0, E = array_lengthof(XPLINKSpillOffsetTable); I != E; ++I)
RegSpillOffsets[XPLINKSpillOffsetTable[I].Reg] =
XPLINKSpillOffsetTable[I].Offset;
for (const auto &Entry : XPLINKSpillOffsetTable)
RegSpillOffsets[Entry.Reg] = Entry.Offset;
}

// Checks if the function is a potential candidate for being a XPLeaf routine.
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/X86/X86DynAllocaExpander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ void X86DynAllocaExpander::lower(MachineInstr *MI, Lowering L) {
bool Is64BitAlloca = MI->getOpcode() == X86::DYN_ALLOCA_64;
assert(SlotSize == 4 || SlotSize == 8);

Optional<MachineFunction::DebugInstrOperandPair> InstrNum = None;
Optional<MachineFunction::DebugInstrOperandPair> InstrNum;
if (unsigned Num = MI->peekDebugInstrNum()) {
// Operand 2 of DYN_ALLOCAs contains the stack def.
InstrNum = {Num, 2};
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/IPO/IROutliner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2671,7 +2671,7 @@ void IROutliner::updateOutputMapping(OutlinableRegion &Region,
LoadInst *LI) {
// For and load instructions following the call
Value *Operand = LI->getPointerOperand();
Optional<unsigned> OutputIdx = None;
Optional<unsigned> OutputIdx;
// Find if the operand it is an output register.
for (unsigned ArgIdx = Region.NumExtractedInputs;
ArgIdx < Region.Call->arg_size(); ArgIdx++) {
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/IPO/SyntheticCountsPropagation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ PreservedAnalyses SyntheticCountsPropagation::run(Module &M,
// parameter.
auto GetCallSiteProfCount = [&](const CallGraphNode *,
const CallGraphNode::CallRecord &Edge) {
Optional<Scaled64> Res = None;
Optional<Scaled64> Res;
if (!Edge.first)
return Res;
CallBase &CB = *cast<CallBase>(*Edge.first);
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Scalar/ADCE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ void AggressiveDeadCodeElimination::initialize() {
}

// This child is something else, like an infinite loop.
for (auto DFNode : depth_first(PDTChild))
for (auto *DFNode : depth_first(PDTChild))
markLive(BlockInfo[DFNode->getBlock()].Terminator);
}

Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ static void findBestInsertionSet(DominatorTree &DT, BlockFrequencyInfo &BFI,
Orders.push_back(Entry);
while (Idx != Orders.size()) {
BasicBlock *Node = Orders[Idx++];
for (auto ChildDomNode : DT.getNode(Node)->children()) {
for (auto *ChildDomNode : DT.getNode(Node)->children()) {
if (Candidates.count(ChildDomNode->getBlock()))
Orders.push_back(ChildDomNode->getBlock());
}
Expand Down Expand Up @@ -534,7 +534,7 @@ void ConstantHoistingPass::collectConstantCandidates(Function &Fn) {
// represented in uint64 we return an "empty" APInt. This is then interpreted
// as the value is not in range.
static Optional<APInt> calculateOffsetDiff(const APInt &V1, const APInt &V2) {
Optional<APInt> Res = None;
Optional<APInt> Res;
unsigned BW = V1.getBitWidth() > V2.getBitWidth() ?
V1.getBitWidth() : V2.getBitWidth();
uint64_t LimVal1 = V1.getLimitedValue();
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Scalar/GVNHoist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ class GVNHoist {
if (!Root)
return;
// Depth first walk on PDom tree to fill the CHIargs at each PDF.
for (auto Node : depth_first(Root)) {
for (auto *Node : depth_first(Root)) {
BasicBlock *BB = Node->getBlock();
if (!BB)
continue;
Expand Down Expand Up @@ -842,7 +842,7 @@ void GVNHoist::fillRenameStack(BasicBlock *BB, InValuesType &ValueBBs,
void GVNHoist::fillChiArgs(BasicBlock *BB, OutValuesType &CHIBBs,
GVNHoist::RenameStackType &RenameStack) {
// For each *predecessor* (because Post-DOM) of BB check if it has a CHI
for (auto Pred : predecessors(BB)) {
for (auto *Pred : predecessors(BB)) {
auto P = CHIBBs.find(Pred);
if (P == CHIBBs.end()) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1898,7 +1898,7 @@ bool InductiveRangeCheckElimination::run(
LLVMContext &Context = Preheader->getContext();
SmallVector<InductiveRangeCheck, 16> RangeChecks;

for (auto BBI : L->getBlocks())
for (auto *BBI : L->getBlocks())
if (BranchInst *TBI = dyn_cast<BranchInst>(BBI->getTerminator()))
InductiveRangeCheck::extractRangeChecksFromBranch(TBI, L, SE, BPI,
RangeChecks);
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Scalar/JumpThreading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2456,7 +2456,7 @@ BasicBlock *JumpThreadingPass::splitBlockPreds(BasicBlock *BB,
for (auto *NewBB : NewBBs) {
BlockFrequency NewBBFreq(0);
Updates.push_back({DominatorTree::Insert, NewBB, BB});
for (auto Pred : predecessors(NewBB)) {
for (auto *Pred : predecessors(NewBB)) {
Updates.push_back({DominatorTree::Delete, Pred, BB});
Updates.push_back({DominatorTree::Insert, Pred, NewBB});
if (HasProfileData) // Update frequencies between Pred -> NewBB.
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Scalar/LICM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2145,7 +2145,7 @@ bool llvm::promoteLoopAccessesToScalars(

// Look at all the loop uses, and try to merge their locations.
std::vector<const DILocation *> LoopUsesLocs;
for (auto U : LoopUses)
for (auto *U : LoopUses)
LoopUsesLocs.push_back(U->getDebugLoc().get());
auto DL = DebugLoc(DILocation::getMergedLocations(LoopUsesLocs));

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Scalar/LoopDistribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ class InstPartitionContainer {
continue;

auto PartI = I->getData();
for (auto PartJ : make_range(std::next(ToBeMerged.member_begin(I)),
for (auto *PartJ : make_range(std::next(ToBeMerged.member_begin(I)),
ToBeMerged.member_end())) {
PartJ->moveTo(*PartI);
}
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Scalar/LoopFuse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ struct LoopDepthTree {
#ifndef NDEBUG
static void printLoopVector(const LoopVector &LV) {
dbgs() << "****************************\n";
for (auto L : LV)
for (auto *L : LV)
printLoop(*L, dbgs());
dbgs() << "****************************\n";
}
Expand Down Expand Up @@ -743,7 +743,7 @@ struct LoopFuser {
return {false, None};
}

Optional<unsigned> Difference = None;
Optional<unsigned> Difference;
int Diff = TC0 - TC1;

if (Diff > 0)
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4267,8 +4267,7 @@ void LSRInstance::GenerateCrossUseConstantOffsets() {
ImmMapTy::const_iterator OtherImms[] = {
Imms.begin(), std::prev(Imms.end()),
Imms.lower_bound(Avg)};
for (size_t i = 0, e = array_lengthof(OtherImms); i != e; ++i) {
ImmMapTy::const_iterator M = OtherImms[i];
for (const auto &M : OtherImms) {
if (M == J || M == JE) continue;

// Compute the difference between the two.
Expand Down
20 changes: 10 additions & 10 deletions llvm/lib/Transforms/Scalar/NewGVN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2109,7 +2109,7 @@ void NewGVN::markMemoryLeaderChangeTouched(CongruenceClass *CC) {
// Touch the instructions that need to be updated after a congruence class has a
// leader change, and mark changed values.
void NewGVN::markValueLeaderChangeTouched(CongruenceClass *CC) {
for (auto M : *CC) {
for (auto *M : *CC) {
if (auto *I = dyn_cast<Instruction>(M))
TouchedInstructions.set(InstrToDFSNum(I));
LeaderChanges.insert(M);
Expand Down Expand Up @@ -2798,7 +2798,7 @@ NewGVN::makePossiblePHIOfOps(Instruction *I,
// We failed to find a leader for the current ValueOp, but this might
// change in case of the translated operands change.
if (SafeForPHIOfOps)
for (auto Dep : CurrentDeps)
for (auto *Dep : CurrentDeps)
addAdditionalUsers(Dep, I);

return nullptr;
Expand All @@ -2816,7 +2816,7 @@ NewGVN::makePossiblePHIOfOps(Instruction *I,
LLVM_DEBUG(dbgs() << "Found phi of ops operand " << *FoundVal << " in "
<< getBlockName(PredBB) << "\n");
}
for (auto Dep : Deps)
for (auto *Dep : Deps)
addAdditionalUsers(Dep, I);
sortPHIOps(PHIOps);
auto *E = performSymbolicPHIEvaluation(PHIOps, I, PHIBlock);
Expand Down Expand Up @@ -2883,7 +2883,7 @@ void NewGVN::initializeCongruenceClasses(Function &F) {
MemoryAccessToClass[MSSA->getLiveOnEntryDef()] =
createMemoryClass(MSSA->getLiveOnEntryDef());

for (auto DTN : nodes(DT)) {
for (auto *DTN : nodes(DT)) {
BasicBlock *BB = DTN->getBlock();
// All MemoryAccesses are equivalent to live on entry to start. They must
// be initialized to something so that initial changes are noticed. For
Expand Down Expand Up @@ -3456,7 +3456,7 @@ bool NewGVN::runGVN() {
}

// Now a standard depth first ordering of the domtree is equivalent to RPO.
for (auto DTN : depth_first(DT->getRootNode())) {
for (auto *DTN : depth_first(DT->getRootNode())) {
BasicBlock *B = DTN->getBlock();
const auto &BlockRange = assignDFSNumbers(B, ICount);
BlockInstRange.insert({B, BlockRange});
Expand Down Expand Up @@ -3576,7 +3576,7 @@ void NewGVN::convertClassToDFSOrdered(
const CongruenceClass &Dense, SmallVectorImpl<ValueDFS> &DFSOrderedSet,
DenseMap<const Value *, unsigned int> &UseCounts,
SmallPtrSetImpl<Instruction *> &ProbablyDead) const {
for (auto D : Dense) {
for (auto *D : Dense) {
// First add the value.
BasicBlock *BB = getBlockForValue(D);
// Constants are handled prior to ever calling this function, so
Expand Down Expand Up @@ -3666,7 +3666,7 @@ void NewGVN::convertClassToDFSOrdered(
void NewGVN::convertClassToLoadsAndStores(
const CongruenceClass &Dense,
SmallVectorImpl<ValueDFS> &LoadsAndStores) const {
for (auto D : Dense) {
for (auto *D : Dense) {
if (!isa<LoadInst>(D) && !isa<StoreInst>(D))
continue;

Expand Down Expand Up @@ -3804,7 +3804,7 @@ Value *NewGVN::findPHIOfOpsLeader(const Expression *E,
if (alwaysAvailable(CC->getLeader()))
return CC->getLeader();

for (auto Member : *CC) {
for (auto *Member : *CC) {
auto *MemberInst = dyn_cast<Instruction>(Member);
if (MemberInst == OrigInst)
continue;
Expand Down Expand Up @@ -3897,7 +3897,7 @@ bool NewGVN::eliminateInstructions(Function &F) {
continue;
// Everything still in the TOP class is unreachable or dead.
if (CC == TOPClass) {
for (auto M : *CC) {
for (auto *M : *CC) {
auto *VTE = ValueToExpression.lookup(M);
if (VTE && isa<DeadExpression>(VTE))
markInstructionForDeletion(cast<Instruction>(M));
Expand All @@ -3918,7 +3918,7 @@ bool NewGVN::eliminateInstructions(Function &F) {
CC->getStoredValue() ? CC->getStoredValue() : CC->getLeader();
if (alwaysAvailable(Leader)) {
CongruenceClass::MemberSet MembersLeft;
for (auto M : *CC) {
for (auto *M : *CC) {
Value *Member = M;
// Void things have no uses we can replace.
if (Member == Leader || !isa<Instruction>(Member) ||
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2447,7 +2447,7 @@ static void rematerializeLiveValues(CallBase *Call,
assert(LastValue);
ClonedValue->replaceUsesOfWith(LastValue, LastClonedValue);
#ifndef NDEBUG
for (auto OpValue : ClonedValue->operand_values()) {
for (auto *OpValue : ClonedValue->operand_values()) {
// Assert that cloned instruction does not use any instructions from
// this chain other than LastClonedValue
assert(!is_contained(ChainToBase, OpValue) &&
Expand Down Expand Up @@ -2501,7 +2501,7 @@ static void rematerializeLiveValues(CallBase *Call,
}

// Remove rematerializaed values from the live set
for (auto LiveValue: LiveValuesToBeDeleted) {
for (auto *LiveValue: LiveValuesToBeDeleted) {
Info.LiveSet.remove(LiveValue);
}
}
Expand Down Expand Up @@ -3270,7 +3270,7 @@ static void recomputeLiveInValues(GCPtrLivenessData &RevisedLivenessData,

// We may have base pointers which are now live that weren't before. We need
// to update the PointerToBase structure to reflect this.
for (auto V : Updated)
for (auto *V : Updated)
PointerToBase.insert({ V, V });

Info.LiveSet = Updated;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Scalar/SCCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ bool llvm::runIPSCCP(
findReturnsToZap(*F, ReturnsToZap, Solver);
}

for (auto F : Solver.getMRVFunctionsTracked()) {
for (auto *F : Solver.getMRVFunctionsTracked()) {
assert(F->getReturnType()->isStructTy() &&
"The return type should be a struct");
StructType *STy = cast<StructType>(F->getReturnType());
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Scalar/StructurizeCFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ static bool hasOnlyUniformBranches(Region *R, unsigned UniformMDKindID,
// Count of how many direct children are conditional.
unsigned ConditionalDirectChildren = 0;

for (auto E : R->elements()) {
for (auto *E : R->elements()) {
if (!E->isSubRegion()) {
auto Br = dyn_cast<BranchInst>(E->getEntry()->getTerminator());
if (!Br || !Br->isConditional())
Expand All @@ -998,7 +998,7 @@ static bool hasOnlyUniformBranches(Region *R, unsigned UniformMDKindID,
// their direct child basic blocks' terminators, regardless of whether
// subregions are uniform or not. However, this requires a very careful
// look at SIAnnotateControlFlow to make sure nothing breaks there.
for (auto BB : E->getNodeAs<Region>()->blocks()) {
for (auto *BB : E->getNodeAs<Region>()->blocks()) {
auto Br = dyn_cast<BranchInst>(BB->getTerminator());
if (!Br || !Br->isConditional())
continue;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Utils/LoopPeel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ static Optional<unsigned> calculateIterationsToInvariance(
// Place infinity to map to avoid infinite recursion for cycled Phis. Such
// cycles can never stop on an invariant.
IterationsToInvariance[Phi] = None;
Optional<unsigned> ToInvariance = None;
Optional<unsigned> ToInvariance;

if (L->isLoopInvariant(Input))
ToInvariance = 1u;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2027,7 +2027,7 @@ class BoUpSLP {
LookAheadHeuristics LookAhead(*DL, *SE, *this, /*NumLanes=*/2,
RootLookAheadMaxDepth);
int BestScore = Limit;
Optional<int> Index = None;
Optional<int> Index;
for (int I : seq<int>(0, Candidates.size())) {
int Score = LookAhead.getScoreAtLevelRec(Candidates[I].first,
Candidates[I].second,
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ int main(int argc, char **argv) {
O.DumpBlockinfo = DumpBlockinfo;

ExitOnErr(BA.analyze(
Dump ? Optional<BCDumpOptions>(O) : Optional<BCDumpOptions>(None),
Dump ? Optional<BCDumpOptions>(O) : Optional<BCDumpOptions>(),
CheckHash.empty() ? None : Optional<StringRef>(CheckHash)));

if (Dump)
Expand Down
17 changes: 7 additions & 10 deletions llvm/tools/llvm-config/llvm-config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,8 @@ static std::vector<std::string> ComputeLibsForComponents(

// Build a map of component names to information.
StringMap<AvailableComponent *> ComponentMap;
for (unsigned i = 0; i != array_lengthof(AvailableComponents); ++i) {
AvailableComponent *AC = &AvailableComponents[i];
ComponentMap[AC->Name] = AC;
}
for (auto &AC : AvailableComponents)
ComponentMap[AC.Name] = &AC;

// Visit the components.
for (unsigned i = 0, e = Components.size(); i != e; ++i) {
Expand Down Expand Up @@ -546,15 +544,14 @@ int main(int argc, char **argv) {
/// built, print LLVM_DYLIB_COMPONENTS instead of everything
/// in the manifest.
std::vector<std::string> Components;
for (unsigned j = 0; j != array_lengthof(AvailableComponents); ++j) {
for (const auto &AC : AvailableComponents) {
// Only include non-installed components when in a development tree.
if (!AvailableComponents[j].IsInstalled && !IsInDevelopmentTree)
if (!AC.IsInstalled && !IsInDevelopmentTree)
continue;

Components.push_back(AvailableComponents[j].Name);
if (AvailableComponents[j].Library && !IsInDevelopmentTree) {
std::string path(
GetComponentLibraryPath(AvailableComponents[j].Library, false));
Components.push_back(AC.Name);
if (AC.Library && !IsInDevelopmentTree) {
std::string path(GetComponentLibraryPath(AC.Library, false));
if (DirSep == "\\") {
std::replace(path.begin(), path.end(), '/', '\\');
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-objdump/llvm-objdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ addMissingWasmCodeSymbols(const WasmObjectFile &Obj,
static void addPltEntries(const ObjectFile &Obj,
std::map<SectionRef, SectionSymbolsTy> &AllSymbols,
StringSaver &Saver) {
Optional<SectionRef> Plt = None;
Optional<SectionRef> Plt;
for (const SectionRef &Section : Obj.sections()) {
Expected<StringRef> SecNameOrErr = Section.getName();
if (!SecNameOrErr) {
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-readobj/ELFDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7078,7 +7078,7 @@ template <class ELFT> void LLVMELFDumper<ELFT>::printBBAddrMaps() {
Sec.sh_type != SHT_LLVM_BB_ADDR_MAP_V0) {
continue;
}
Optional<const Elf_Shdr *> FunctionSec = None;
Optional<const Elf_Shdr *> FunctionSec;
if (IsRelocatable)
FunctionSec =
unwrapOrError(this->FileName, this->Obj.getSection(Sec.sh_link));
Expand Down
2 changes: 1 addition & 1 deletion llvm/utils/TableGen/CodeGenSchedule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ struct InstRegexOp : public SetTheory::Operator {
if (removeParens(Original).find_first_of("|?") != std::string::npos)
FirstMeta = 0;

Optional<Regex> Regexpr = None;
Optional<Regex> Regexpr;
StringRef Prefix = Original.substr(0, FirstMeta);
StringRef PatStr = Original.substr(FirstMeta);
if (!PatStr.empty()) {
Expand Down
4 changes: 2 additions & 2 deletions llvm/utils/TableGen/GlobalISelEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4536,7 +4536,7 @@ Expected<action_iterator> GlobalISelEmitter::importExplicitUseRenderer(
if (ChildTypes.size() != 1)
return failedImport("Dst pattern child has multiple results");

Optional<LLTCodeGen> OpTyOrNone = None;
Optional<LLTCodeGen> OpTyOrNone;
if (ChildTypes.front().isMachineValueType())
OpTyOrNone = MVTToLLT(ChildTypes.front().getMachineValueType().SimpleTy);
if (!OpTyOrNone)
Expand Down Expand Up @@ -4968,7 +4968,7 @@ Error GlobalISelEmitter::importDefaultOperandRenderers(
action_iterator InsertPt, RuleMatcher &M, BuildMIAction &DstMIBuilder,
DagInit *DefaultOps) const {
for (const auto *DefaultOp : DefaultOps->getArgs()) {
Optional<LLTCodeGen> OpTyOrNone = None;
Optional<LLTCodeGen> OpTyOrNone;

// Look through ValueType operators.
if (const DagInit *DefaultDagOp = dyn_cast<DagInit>(DefaultOp)) {
Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/Analysis/Presburger/IntegerRelation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1455,7 +1455,7 @@ Optional<int64_t> IntegerRelation::getConstantBoundOnDimSize(
/*eqIndices=*/nullptr, /*offset=*/0,
/*num=*/getNumDimVars());

Optional<int64_t> minDiff = None;
Optional<int64_t> minDiff;
unsigned minLbPosition = 0, minUbPosition = 0;
for (auto ubPos : ubIndices) {
for (auto lbPos : lbIndices) {
Expand Down Expand Up @@ -1538,7 +1538,7 @@ IntegerRelation::computeConstantLowerOrUpperBound(unsigned pos) {
// If it doesn't, there isn't a bound on it.
return None;

Optional<int64_t> minOrMaxConst = None;
Optional<int64_t> minOrMaxConst;

// Take the max across all const lower bounds (or min across all constant
// upper bounds).
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/CAPI/Interfaces/Interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ MlirLogicalResult mlirInferTypeOpInterfaceInferReturnTypes(
if (!info)
return mlirLogicalResultFailure();

llvm::Optional<Location> maybeLocation = llvm::None;
llvm::Optional<Location> maybeLocation;
if (!mlirLocationIsNull(location))
maybeLocation = unwrap(location);
SmallVector<Value> unwrappedOperands;
Expand Down
6 changes: 3 additions & 3 deletions mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1124,10 +1124,10 @@ static bool isFusionProfitable(Operation *srcOpInst, Operation *srcStoreOpInst,
// loop nest at 'dstLoopDepth'.
uint64_t minFusedLoopNestComputeCost = std::numeric_limits<uint64_t>::max();
double maxStorageReduction = 0.0;
Optional<uint64_t> sliceMemEstimate = None;
Optional<uint64_t> sliceMemEstimate;

// The best loop depth at which to materialize the slice.
Optional<unsigned> bestDstLoopDepth = None;
Optional<unsigned> bestDstLoopDepth;

// Compute op instance count for the src loop nest without iteration slicing.
uint64_t srcLoopNestCost = getComputeCost(srcLoopIVs[0], srcLoopNestStats);
Expand Down Expand Up @@ -1260,7 +1260,7 @@ static bool isFusionProfitable(Operation *srcOpInst, Operation *srcStoreOpInst,
auto dstMemSize = getMemoryFootprintBytes(dstForOp);
auto srcMemSize = getMemoryFootprintBytes(srcLoopIVs[0]);

Optional<double> storageReduction = None;
Optional<double> storageReduction;

if (!dstMemSize || !srcMemSize) {
LLVM_DEBUG(llvm::dbgs()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ bufferization::getBufferType(Value value, const BufferizationOptions &options) {

// Check value is a new buffer allocation with a memory space attribute. In
// that case we can at least infer the memory space.
Optional<unsigned> memorySpace = None;
Optional<unsigned> memorySpace;
if (auto opResult = value.dyn_cast<OpResult>()) {
if (auto bufferizableOp =
options.dynCastBufferizableOp(opResult.getDefiningOp())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@ using namespace mlir::sparse_tensor;
// Helper to detect a sparse tensor type operand.
static bool isSparseTensor(OpOperand *op) {
if (auto enc = getSparseTensorEncoding(op->get().getType())) {
ArrayRef<SparseTensorEncodingAttr::DimLevelType> dimTypes =
enc.getDimLevelType();
for (auto dimType : dimTypes)
if (dimType == SparseTensorEncodingAttr::DimLevelType::Compressed)
return true; // at least one compressed
if (llvm::is_contained(enc.getDimLevelType(),
SparseTensorEncodingAttr::DimLevelType::Compressed))
return true;
}
return false;
}
Expand Down