[BOLT][NFC] Use llvm::less_first
authorAmir Ayupov <aaupov@fb.com>
Mon, 27 Jun 2022 17:26:55 +0000 (10:26 -0700)
committerAmir Ayupov <aaupov@fb.com>
Mon, 27 Jun 2022 17:27:17 +0000 (10:27 -0700)
Follow the case of https://reviews.llvm.org/D126068 and simplify call sites
with `llvm::less_first`.

Reviewed By: rafauler

Differential Revision: https://reviews.llvm.org/D128242

bolt/lib/Core/DebugData.cpp
bolt/lib/Passes/LongJmp.cpp

index 6c32651..c963307 100644 (file)
@@ -313,10 +313,7 @@ void DebugAddrWriter::AddressForDWOCU::dump() {
   std::vector<IndexAddressPair> SortedMap(indexToAddressBegin(),
                                           indexToAdddessEnd());
   // Sorting address in increasing order of indices.
-  llvm::sort(SortedMap,
-             [](const IndexAddressPair &A, const IndexAddressPair &B) {
-               return A.first < B.first;
-             });
+  llvm::sort(SortedMap, llvm::less_first());
   for (auto &Pair : SortedMap)
     dbgs() << Twine::utohexstr(Pair.second) << "\t" << Pair.first << "\n";
 }
@@ -375,10 +372,7 @@ AddressSectionBuffer DebugAddrWriter::finalize() {
     std::vector<IndexAddressPair> SortedMap(AM->second.indexToAddressBegin(),
                                             AM->second.indexToAdddessEnd());
     // Sorting address in increasing order of indices.
-    llvm::sort(SortedMap,
-               [](const IndexAddressPair &A, const IndexAddressPair &B) {
-                 return A.first < B.first;
-               });
+    llvm::sort(SortedMap, llvm::less_first());
 
     uint8_t AddrSize = CU->getAddressByteSize();
     uint32_t Counter = 0;
@@ -449,10 +443,7 @@ AddressSectionBuffer DebugAddrWriterDwarf5::finalize() {
         AMIter->second.indexToAddressBegin(),
         AMIter->second.indexToAdddessEnd());
     // Sorting address in increasing order of indices.
-    llvm::sort(SortedMap,
-               [](const IndexAddressPair &A, const IndexAddressPair &B) {
-                 return A.first < B.first;
-               });
+    llvm::sort(SortedMap, llvm::less_first());
     // Writing out Header
     const uint32_t Length = SortedMap.size() * AddrSize + 4;
     support::endian::write(AddressStream, Length, Endian);
index 4291566..efd84fa 100644 (file)
@@ -255,11 +255,7 @@ void LongJmpPass::updateStubGroups() {
     for (auto &KeyVal : StubGroups) {
       for (StubTy &Elem : KeyVal.second)
         Elem.first = BBAddresses[Elem.second];
-      llvm::sort(KeyVal.second,
-                 [&](const std::pair<uint64_t, BinaryBasicBlock *> &LHS,
-                     const std::pair<uint64_t, BinaryBasicBlock *> &RHS) {
-                   return LHS.first < RHS.first;
-                 });
+      llvm::sort(KeyVal.second, llvm::less_first());
     }
   };