[PATCH] D145887: [BOLT][NFC] Use llvm::make_range
Amir Ayupov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 17 10:51:18 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG17f3cbe3af81: [BOLT][NFC] Use llvm::make_range (authored by Amir).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D145887/new/
https://reviews.llvm.org/D145887
Files:
bolt/lib/Profile/DataAggregator.cpp
bolt/lib/Profile/DataReader.cpp
Index: bolt/lib/Profile/DataReader.cpp
===================================================================
--- bolt/lib/Profile/DataReader.cpp
+++ bolt/lib/Profile/DataReader.cpp
@@ -215,9 +215,9 @@
}
};
auto Range = std::equal_range(Data.begin(), Data.end(), From, Compare());
- for (auto I = Range.first; I != Range.second; ++I)
- if (I->From.Name != I->To.Name)
- return *I;
+ for (const auto &RI : llvm::make_range(Range))
+ if (RI.From.Name != RI.To.Name)
+ return RI;
return make_error_code(llvm::errc::invalid_argument);
}
Index: bolt/lib/Profile/DataAggregator.cpp
===================================================================
--- bolt/lib/Profile/DataAggregator.cpp
+++ bolt/lib/Profile/DataAggregator.cpp
@@ -1983,14 +1983,11 @@
continue;
// Consider only the first mapping of the file for any given PID
- bool PIDExists = false;
auto Range = GlobalMMapInfo.equal_range(FileMMapInfo.first);
- for (auto MI = Range.first; MI != Range.second; ++MI) {
- if (MI->second.PID == FileMMapInfo.second.PID) {
- PIDExists = true;
- break;
- }
- }
+ bool PIDExists = llvm::any_of(make_range(Range), [&](const auto &MI) {
+ return MI.second.PID == FileMMapInfo.second.PID;
+ });
+
if (PIDExists)
continue;
@@ -2014,8 +2011,7 @@
}
auto Range = GlobalMMapInfo.equal_range(NameToUse);
- for (auto I = Range.first; I != Range.second; ++I) {
- MMapInfo &MMapInfo = I->second;
+ for (MMapInfo &MMapInfo : llvm::make_second_range(make_range(Range))) {
if (BC->HasFixedLoadAddress && MMapInfo.MMapAddress) {
// Check that the binary mapping matches one of the segments.
bool MatchFound = llvm::any_of(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145887.523112.patch
Type: text/x-patch
Size: 1742 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230517/2d5e90dc/attachment-0001.bin>
More information about the llvm-commits
mailing list