forked from OSchip/llvm-project
[llvm] Convert for_each to range-based for loops (NFC)
This commit is contained in:
parent
4c78386f44
commit
3b9707dbc0
|
@ -314,12 +314,11 @@ void LoopBase<BlockT, LoopT>::verifyLoop() const {
|
|||
"Loop block has no in-loop predecessors!");
|
||||
|
||||
SmallVector<BlockT *, 2> OutsideLoopPreds;
|
||||
std::for_each(GraphTraits<Inverse<BlockT *>>::child_begin(BB),
|
||||
GraphTraits<Inverse<BlockT *>>::child_end(BB),
|
||||
[&](BlockT *B) {
|
||||
if (!contains(B))
|
||||
OutsideLoopPreds.push_back(B);
|
||||
});
|
||||
for (BlockT *B :
|
||||
llvm::make_range(GraphTraits<Inverse<BlockT *>>::child_begin(BB),
|
||||
GraphTraits<Inverse<BlockT *>>::child_end(BB)))
|
||||
if (!contains(B))
|
||||
OutsideLoopPreds.push_back(B);
|
||||
|
||||
if (BB == getHeader()) {
|
||||
assert(!OutsideLoopPreds.empty() && "Loop is unreachable!");
|
||||
|
|
|
@ -855,9 +855,10 @@ bool MachineOutliner::outline(Module &M,
|
|||
MBB.erase(std::next(StartIt), std::next(EndIt));
|
||||
|
||||
// Keep track of what we removed by marking them all as -1.
|
||||
std::for_each(Mapper.UnsignedVec.begin() + C.getStartIdx(),
|
||||
Mapper.UnsignedVec.begin() + C.getEndIdx() + 1,
|
||||
[](unsigned &I) { I = static_cast<unsigned>(-1); });
|
||||
for (unsigned &I :
|
||||
llvm::make_range(Mapper.UnsignedVec.begin() + C.getStartIdx(),
|
||||
Mapper.UnsignedVec.begin() + C.getEndIdx() + 1))
|
||||
I = static_cast<unsigned>(-1);
|
||||
OutlinedSomething = true;
|
||||
|
||||
// Statistics.
|
||||
|
|
|
@ -750,8 +750,8 @@ Error SymbolTableSection::removeSectionReferences(
|
|||
}
|
||||
|
||||
void SymbolTableSection::updateSymbols(function_ref<void(Symbol &)> Callable) {
|
||||
std::for_each(std::begin(Symbols) + 1, std::end(Symbols),
|
||||
[Callable](SymPtr &Sym) { Callable(*Sym); });
|
||||
for (SymPtr &Sym : llvm::drop_begin(Symbols))
|
||||
Callable(*Sym);
|
||||
std::stable_partition(
|
||||
std::begin(Symbols), std::end(Symbols),
|
||||
[](const SymPtr &Sym) { return Sym->Binding == STB_LOCAL; });
|
||||
|
|
|
@ -55,10 +55,8 @@ TGLexer::TGLexer(SourceMgr &SM, ArrayRef<std::string> Macros) : SrcMgr(SM) {
|
|||
std::make_unique<std::vector<PreprocessorControlDesc>>());
|
||||
|
||||
// Put all macros defined in the command line into the DefinedMacros set.
|
||||
std::for_each(Macros.begin(), Macros.end(),
|
||||
[this](const std::string &MacroName) {
|
||||
DefinedMacros.insert(MacroName);
|
||||
});
|
||||
for (const std::string &MacroName : Macros)
|
||||
DefinedMacros.insert(MacroName);
|
||||
}
|
||||
|
||||
SMLoc TGLexer::getLoc() const {
|
||||
|
|
|
@ -6955,10 +6955,8 @@ outliner::OutlinedFunction AArch64InstrInfo::getOutliningCandidateInfo(
|
|||
unsigned FlagsSetInAll = 0xF;
|
||||
|
||||
// Compute liveness information for each candidate, and set FlagsSetInAll.
|
||||
std::for_each(RepeatedSequenceLocs.begin(), RepeatedSequenceLocs.end(),
|
||||
[&FlagsSetInAll](outliner::Candidate &C) {
|
||||
FlagsSetInAll &= C.Flags;
|
||||
});
|
||||
for (outliner::Candidate &C : RepeatedSequenceLocs)
|
||||
FlagsSetInAll &= C.Flags;
|
||||
|
||||
// According to the AArch64 Procedure Call Standard, the following are
|
||||
// undefined on entry/exit from a function call:
|
||||
|
@ -7314,8 +7312,8 @@ bool AArch64InstrInfo::isMBBSafeToOutlineFrom(MachineBasicBlock &MBB,
|
|||
"Suitable Machine Function for outlining must track liveness");
|
||||
LiveRegUnits LRU(getRegisterInfo());
|
||||
|
||||
std::for_each(MBB.rbegin(), MBB.rend(),
|
||||
[&LRU](MachineInstr &MI) { LRU.accumulate(MI); });
|
||||
for (MachineInstr &MI : llvm::reverse(MBB))
|
||||
LRU.accumulate(MI);
|
||||
|
||||
// Check if each of the unsafe registers are available...
|
||||
bool W16AvailableInBlock = LRU.available(AArch64::W16);
|
||||
|
|
|
@ -5861,9 +5861,8 @@ outliner::OutlinedFunction ARMBaseInstrInfo::getOutliningCandidateInfo(
|
|||
|
||||
// Compute liveness information for each candidate, and set FlagsSetInAll.
|
||||
const TargetRegisterInfo &TRI = getRegisterInfo();
|
||||
std::for_each(
|
||||
RepeatedSequenceLocs.begin(), RepeatedSequenceLocs.end(),
|
||||
[&FlagsSetInAll](outliner::Candidate &C) { FlagsSetInAll &= C.Flags; });
|
||||
for (outliner::Candidate &C : RepeatedSequenceLocs)
|
||||
FlagsSetInAll &= C.Flags;
|
||||
|
||||
// According to the ARM Procedure Call Standard, the following are
|
||||
// undefined on entry/exit from a function call:
|
||||
|
@ -6214,8 +6213,8 @@ bool ARMBaseInstrInfo::isMBBSafeToOutlineFrom(MachineBasicBlock &MBB,
|
|||
|
||||
LiveRegUnits LRU(getRegisterInfo());
|
||||
|
||||
std::for_each(MBB.rbegin(), MBB.rend(),
|
||||
[&LRU](MachineInstr &MI) { LRU.accumulate(MI); });
|
||||
for (MachineInstr &MI : llvm::reverse(MBB))
|
||||
LRU.accumulate(MI);
|
||||
|
||||
// Check if each of the unsafe registers are available...
|
||||
bool R12AvailableInBlock = LRU.available(ARM::R12);
|
||||
|
|
|
@ -207,10 +207,8 @@ static void convertToParamAS(Value *OldUser, Value *Param) {
|
|||
// We've created a new instruction. Queue users of the old instruction to
|
||||
// be converted and the instruction itself to be deleted. We can't delete
|
||||
// the old instruction yet, because it's still in use by a load somewhere.
|
||||
llvm::for_each(
|
||||
I.OldInstruction->users(), [NewInst, &ItemsToConvert](Value *V) {
|
||||
ItemsToConvert.push_back({cast<Instruction>(V), NewInst});
|
||||
});
|
||||
for (Value *V : I.OldInstruction->users())
|
||||
ItemsToConvert.push_back({cast<Instruction>(V), NewInst});
|
||||
|
||||
InstructionsToDelete.push_back(I.OldInstruction);
|
||||
}
|
||||
|
@ -223,8 +221,8 @@ static void convertToParamAS(Value *OldUser, Value *Param) {
|
|||
// E.g if we have Value = Load(BitCast(GEP(arg))), InstructionsToDelete will
|
||||
// have {GEP,BitCast}. GEP can't be deleted first, because it's still used by
|
||||
// the BitCast.
|
||||
llvm::for_each(reverse(InstructionsToDelete),
|
||||
[](Instruction *I) { I->eraseFromParent(); });
|
||||
for (Instruction *I : llvm::reverse(InstructionsToDelete))
|
||||
I->eraseFromParent();
|
||||
}
|
||||
|
||||
// Adjust alignment of arguments passed byval in .param address space. We can
|
||||
|
@ -351,9 +349,8 @@ void NVPTXLowerArgs::handleByValParam(Argument *Arg) {
|
|||
Value *ArgInParamAS = new AddrSpaceCastInst(
|
||||
Arg, PointerType::get(StructType, ADDRESS_SPACE_PARAM), Arg->getName(),
|
||||
FirstInst);
|
||||
llvm::for_each(UsersToUpdate, [ArgInParamAS](Value *V) {
|
||||
for (Value *V : UsersToUpdate)
|
||||
convertToParamAS(V, ArgInParamAS);
|
||||
});
|
||||
LLVM_DEBUG(dbgs() << "No need to copy " << *Arg << "\n");
|
||||
|
||||
// Further optimizations require target lowering info.
|
||||
|
|
|
@ -2432,9 +2432,8 @@ void PPCAIXAsmPrinter::emitGlobalVariableHelper(const GlobalVariable *GV) {
|
|||
}
|
||||
|
||||
// Emit aliasing label for global variable.
|
||||
llvm::for_each(GOAliasMap[GV], [this](const GlobalAlias *Alias) {
|
||||
for (const GlobalAlias *Alias : GOAliasMap[GV])
|
||||
OutStreamer->emitLabel(getSymbol(Alias));
|
||||
});
|
||||
|
||||
emitGlobalConstant(GV->getParent()->getDataLayout(), GV->getInitializer());
|
||||
}
|
||||
|
@ -2449,10 +2448,8 @@ void PPCAIXAsmPrinter::emitFunctionDescriptor() {
|
|||
cast<MCSymbolXCOFF>(CurrentFnDescSym)->getRepresentedCsect());
|
||||
|
||||
// Emit aliasing label for function descriptor csect.
|
||||
llvm::for_each(GOAliasMap[&MF->getFunction()],
|
||||
[this](const GlobalAlias *Alias) {
|
||||
OutStreamer->emitLabel(getSymbol(Alias));
|
||||
});
|
||||
for (const GlobalAlias *Alias : GOAliasMap[&MF->getFunction()])
|
||||
OutStreamer->emitLabel(getSymbol(Alias));
|
||||
|
||||
// Emit function entry point address.
|
||||
OutStreamer->emitValue(MCSymbolRefExpr::create(CurrentFnSym, OutContext),
|
||||
|
@ -2476,11 +2473,9 @@ void PPCAIXAsmPrinter::emitFunctionEntryLabel() {
|
|||
PPCAsmPrinter::emitFunctionEntryLabel();
|
||||
|
||||
// Emit aliasing label for function entry point label.
|
||||
llvm::for_each(
|
||||
GOAliasMap[&MF->getFunction()], [this](const GlobalAlias *Alias) {
|
||||
OutStreamer->emitLabel(
|
||||
getObjFileLowering().getFunctionEntryPointSymbol(Alias, TM));
|
||||
});
|
||||
for (const GlobalAlias *Alias : GOAliasMap[&MF->getFunction()])
|
||||
OutStreamer->emitLabel(
|
||||
getObjFileLowering().getFunctionEntryPointSymbol(Alias, TM));
|
||||
}
|
||||
|
||||
void PPCAIXAsmPrinter::emitPGORefs() {
|
||||
|
|
|
@ -2393,7 +2393,7 @@ bool PPCFrameLowering::spillCalleeSavedRegisters(
|
|||
|
||||
// Map each VSR to GPRs to be spilled with into it. Single VSR can contain one
|
||||
// or two GPRs, so we need table to record information for later save/restore.
|
||||
llvm::for_each(CSI, [&](const CalleeSavedInfo &Info) {
|
||||
for (const CalleeSavedInfo &Info : CSI) {
|
||||
if (Info.isSpilledToReg()) {
|
||||
auto &SpilledVSR =
|
||||
VSRContainingGPRs.FindAndConstruct(Info.getDstReg()).second;
|
||||
|
@ -2404,7 +2404,7 @@ bool PPCFrameLowering::spillCalleeSavedRegisters(
|
|||
else
|
||||
SpilledVSR.second = Info.getReg();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
for (const CalleeSavedInfo &I : CSI) {
|
||||
Register Reg = I.getReg();
|
||||
|
|
|
@ -855,10 +855,9 @@ static StringRef solveTypeName(Type *Ty) {
|
|||
auto Name = Ty->getStructName();
|
||||
|
||||
SmallString<16> Buffer(Name);
|
||||
for_each(Buffer, [](auto &Iter) {
|
||||
for (auto &Iter : Buffer)
|
||||
if (Iter == '.' || Iter == ':')
|
||||
Iter = '_';
|
||||
});
|
||||
auto *MDName = MDString::get(Ty->getContext(), Buffer.str());
|
||||
return MDName->getString();
|
||||
}
|
||||
|
@ -2794,10 +2793,9 @@ void coro::buildCoroutineFrame(Function &F, Shape &Shape) {
|
|||
auto *V = Iter.first;
|
||||
SmallVector<DbgValueInst *, 16> DVIs;
|
||||
findDbgValues(DVIs, V);
|
||||
llvm::for_each(DVIs, [&](DbgValueInst *DVI) {
|
||||
for (DbgValueInst *DVI : DVIs)
|
||||
if (Checker.isDefinitionAcrossSuspend(*V, DVI))
|
||||
FrameData.Spills[V].push_back(DVI);
|
||||
});
|
||||
}
|
||||
|
||||
LLVM_DEBUG(dumpSpills("Spills", FrameData.Spills));
|
||||
|
|
Loading…
Reference in New Issue