From c4302e4fc2017f293323f436c20bcab31e469d57 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Mon, 27 Jun 2022 10:26:55 -0700 Subject: [PATCH] [BOLT][NFC] Use llvm::less_first 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 | 15 +++------------ bolt/lib/Passes/LongJmp.cpp | 6 +----- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/bolt/lib/Core/DebugData.cpp b/bolt/lib/Core/DebugData.cpp index 6c32651d4be3..c96330796014 100644 --- a/bolt/lib/Core/DebugData.cpp +++ b/bolt/lib/Core/DebugData.cpp @@ -313,10 +313,7 @@ void DebugAddrWriter::AddressForDWOCU::dump() { std::vector 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 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); diff --git a/bolt/lib/Passes/LongJmp.cpp b/bolt/lib/Passes/LongJmp.cpp index 429156655b9a..efd84fa89ee0 100644 --- a/bolt/lib/Passes/LongJmp.cpp +++ b/bolt/lib/Passes/LongJmp.cpp @@ -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 &LHS, - const std::pair &RHS) { - return LHS.first < RHS.first; - }); + llvm::sort(KeyVal.second, llvm::less_first()); } };