Skip to content

[llvm] Use range-based for loops (NFC) #105861

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions llvm/include/llvm/IR/ModuleSummaryIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -1808,9 +1808,9 @@ class ModuleSummaryIndex {
/// the ThinLTO backends.
TypeIdSummary &getOrInsertTypeIdSummary(StringRef TypeId) {
auto TidIter = TypeIdMap.equal_range(GlobalValue::getGUID(TypeId));
for (auto It = TidIter.first; It != TidIter.second; ++It)
if (It->second.first == TypeId)
return It->second.second;
for (auto &[GUID, TypeIdPair] : make_range(TidIter))
if (TypeIdPair.first == TypeId)
return TypeIdPair.second;
auto It = TypeIdMap.insert(
{GlobalValue::getGUID(TypeId), {std::string(TypeId), TypeIdSummary()}});
return It->second.second;
Expand All @@ -1820,9 +1820,9 @@ class ModuleSummaryIndex {
/// summary map) or null (if not present). This may be used when importing.
const TypeIdSummary *getTypeIdSummary(StringRef TypeId) const {
auto TidIter = TypeIdMap.equal_range(GlobalValue::getGUID(TypeId));
for (auto It = TidIter.first; It != TidIter.second; ++It)
if (It->second.first == TypeId)
return &It->second.second;
for (const auto &[GUID, TypeIdPair] : make_range(TidIter))
if (TypeIdPair.first == TypeId)
return &TypeIdPair.second;
return nullptr;
}

Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4807,9 +4807,9 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() {
// corresponding type id records.
for (auto &T : ReferencedTypeIds) {
auto TidIter = Index.typeIds().equal_range(T);
for (auto It = TidIter.first; It != TidIter.second; ++It) {
writeTypeIdSummaryRecord(NameVals, StrtabBuilder, It->second.first,
It->second.second);
for (const auto &[GUID, TypeIdPair] : make_range(TidIter)) {
writeTypeIdSummaryRecord(NameVals, StrtabBuilder, TypeIdPair.first,
TypeIdPair.second);
Stream.EmitRecord(bitc::FS_TYPE_ID, NameVals);
NameVals.clear();
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,7 @@ void VarLocBasedLDV::cleanupEntryValueTransfers(
return;

auto TransRange = EntryValTransfers.equal_range(TRInst);
for (auto &TDPair : llvm::make_range(TransRange.first, TransRange.second)) {
for (auto &TDPair : llvm::make_range(TransRange)) {
const VarLoc &EmittedEV = VarLocIDs[TDPair.second];
if (std::tie(EntryVL.Var, EntryVL.Locs[0].Value.RegNo, EntryVL.Expr) ==
std::tie(EmittedEV.Var, EmittedEV.Locs[0].Value.RegNo,
Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/IR/AsmWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3488,9 +3488,9 @@ void AssemblyWriter::printTypeIdInfo(
continue;
}
// Print all type id that correspond to this GUID.
for (auto It = TidIter.first; It != TidIter.second; ++It) {
for (const auto &[GUID, TypeIdPair] : make_range(TidIter)) {
Out << FS;
auto Slot = Machine.getTypeIdSlot(It->second.first);
auto Slot = Machine.getTypeIdSlot(TypeIdPair.first);
assert(Slot != -1);
Out << "^" << Slot;
}
Expand Down Expand Up @@ -3529,10 +3529,10 @@ void AssemblyWriter::printVFuncId(const FunctionSummary::VFuncId VFId) {
}
// Print all type id that correspond to this GUID.
FieldSeparator FS;
for (auto It = TidIter.first; It != TidIter.second; ++It) {
for (const auto &[GUID, TypeIdPair] : make_range(TidIter)) {
Out << FS;
Out << "vFuncId: (";
auto Slot = Machine.getTypeIdSlot(It->second.first);
auto Slot = Machine.getTypeIdSlot(TypeIdPair.first);
assert(Slot != -1);
Out << "^" << Slot;
Out << ", offset: " << VFId.Offset;
Expand Down
4 changes: 2 additions & 2 deletions llvm/tools/llvm-profgen/ProfiledBinary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,8 @@ void ProfiledBinary::decodePseudoProbe(const ELFObjectFileBase *Obj) {
GuidFilter.insert(Function::getGUID(F->FuncName));
for (auto &Range : F->Ranges) {
auto GUIDs = StartAddrToSymMap.equal_range(Range.first);
for (auto I = GUIDs.first; I != GUIDs.second; ++I)
FuncStartAddresses[I->second] = I->first;
for (const auto &[StartAddr, Func] : make_range(GUIDs))
FuncStartAddresses[Func] = StartAddr;
}
}
}
Expand Down
Loading