[llvm] Use llvm::less_first and llvm::less_second (NFC) (#136272)

This commit is contained in:
Kazu Hirata 2025-04-18 10:05:55 -07:00 committed by GitHub
parent c244daec1c
commit 5e1b0f9773
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 15 deletions

View File

@ -588,12 +588,8 @@ void PipelineSolver::populateReadyList(
ReadyList.push_back(std::pair(*I, -1)); ReadyList.push_back(std::pair(*I, -1));
} }
if (UseCostHeur) { if (UseCostHeur)
std::sort(ReadyList.begin(), ReadyList.end(), llvm::sort(ReadyList, llvm::less_second());
[](std::pair<int, int> A, std::pair<int, int> B) {
return A.second < B.second;
});
}
assert(ReadyList.size() == CurrSU.second.size()); assert(ReadyList.size() == CurrSU.second.size());
} }

View File

@ -6466,10 +6466,7 @@ static bool clusterSortPtrAccesses(ArrayRef<Value *> VL,
for (auto &Base : Bases) { for (auto &Base : Bases) {
for (auto &Vec : Base.second) { for (auto &Vec : Base.second) {
if (Vec.size() > 1) { if (Vec.size() > 1) {
stable_sort(Vec, [](const std::tuple<Value *, int, unsigned> &X, stable_sort(Vec, llvm::less_second());
const std::tuple<Value *, int, unsigned> &Y) {
return std::get<1>(X) < std::get<1>(Y);
});
int InitialOffset = std::get<1>(Vec[0]); int InitialOffset = std::get<1>(Vec[0]);
bool AnyConsecutive = bool AnyConsecutive =
all_of(enumerate(Vec), [InitialOffset](const auto &P) { all_of(enumerate(Vec), [InitialOffset](const auto &P) {
@ -7986,9 +7983,7 @@ bool BoUpSLP::canFormVector(ArrayRef<StoreInst *> StoresVec,
// Check if the stores are consecutive by checking if their difference is 1. // Check if the stores are consecutive by checking if their difference is 1.
if (StoreOffsetVec.size() != StoresVec.size()) if (StoreOffsetVec.size() != StoresVec.size())
return false; return false;
sort(StoreOffsetVec, sort(StoreOffsetVec, llvm::less_first());
[](const std::pair<int, unsigned> &L,
const std::pair<int, unsigned> &R) { return L.first < R.first; });
unsigned Idx = 0; unsigned Idx = 0;
int PrevDist = 0; int PrevDist = 0;
for (const auto &P : StoreOffsetVec) { for (const auto &P : StoreOffsetVec) {

View File

@ -84,8 +84,8 @@ Expected<void *> get_ctor_dtor_array(const void *image, const size_t size,
} }
// Lower priority constructors are run before higher ones. The reverse is true // Lower priority constructors are run before higher ones. The reverse is true
// for destructors. // for destructors.
llvm::sort(ctors, [](auto x, auto y) { return x.second < y.second; }); llvm::sort(ctors, llvm::less_second());
llvm::sort(dtors, [](auto x, auto y) { return x.second < y.second; }); llvm::sort(dtors, llvm::less_second());
// Allocate host pinned memory to make these arrays visible to the GPU. // Allocate host pinned memory to make these arrays visible to the GPU.
CUdeviceptr *dev_memory = reinterpret_cast<CUdeviceptr *>(allocator( CUdeviceptr *dev_memory = reinterpret_cast<CUdeviceptr *>(allocator(