[llvm] [llvm] Use range-based for loops (NFC) (PR #105861)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 23 10:20:22 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-debuginfo
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/105861.diff
5 Files Affected:
- (modified) llvm/include/llvm/IR/ModuleSummaryIndex.h (+6-6)
- (modified) llvm/lib/Bitcode/Writer/BitcodeWriter.cpp (+3-3)
- (modified) llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp (+1-1)
- (modified) llvm/lib/IR/AsmWriter.cpp (+4-4)
- (modified) llvm/tools/llvm-profgen/ProfiledBinary.cpp (+2-2)
``````````diff
diff --git a/llvm/include/llvm/IR/ModuleSummaryIndex.h b/llvm/include/llvm/IR/ModuleSummaryIndex.h
index 00934cc1ce6f2d..22a6cba7c89464 100644
--- a/llvm/include/llvm/IR/ModuleSummaryIndex.h
+++ b/llvm/include/llvm/IR/ModuleSummaryIndex.h
@@ -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 &KV : make_range(TidIter))
+ if (KV.second.first == TypeId)
+ return KV.second.second;
auto It = TypeIdMap.insert(
{GlobalValue::getGUID(TypeId), {std::string(TypeId), TypeIdSummary()}});
return It->second.second;
@@ -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 &KV : make_range(TidIter))
+ if (KV.second.first == TypeId)
+ return &KV.second.second;
return nullptr;
}
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index 03d0537291dada..cd8f9033c62a02 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -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 &KV : make_range(TidIter)) {
+ writeTypeIdSummaryRecord(NameVals, StrtabBuilder, KV.second.first,
+ KV.second.second);
Stream.EmitRecord(bitc::FS_TYPE_ID, NameVals);
NameVals.clear();
}
diff --git a/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
index e146fb7e576819..2959d3261bea71 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
@@ -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,
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index 01a16ccd688f43..1b569715345cca 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -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 &KV : make_range(TidIter)) {
Out << FS;
- auto Slot = Machine.getTypeIdSlot(It->second.first);
+ auto Slot = Machine.getTypeIdSlot(KV.second.first);
assert(Slot != -1);
Out << "^" << Slot;
}
@@ -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 &KV : make_range(TidIter)) {
Out << FS;
Out << "vFuncId: (";
- auto Slot = Machine.getTypeIdSlot(It->second.first);
+ auto Slot = Machine.getTypeIdSlot(KV.second.first);
assert(Slot != -1);
Out << "^" << Slot;
Out << ", offset: " << VFId.Offset;
diff --git a/llvm/tools/llvm-profgen/ProfiledBinary.cpp b/llvm/tools/llvm-profgen/ProfiledBinary.cpp
index 574a9c9f52bf18..07966bc92e3933 100644
--- a/llvm/tools/llvm-profgen/ProfiledBinary.cpp
+++ b/llvm/tools/llvm-profgen/ProfiledBinary.cpp
@@ -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 &[K, V] : make_range(GUIDs))
+ FuncStartAddresses[V] = K;
}
}
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/105861
More information about the llvm-commits
mailing list