Use llvm::less_second (NFC)

This commit is contained in:
Kazu Hirata 2022-06-04 22:48:32 -07:00
parent 9a8e65de8c
commit e0039b8d6a
10 changed files with 11 additions and 48 deletions

View File

@ -205,12 +205,6 @@ class UnexploredFirstPriorityQueue : public WorkList {
using QueuePriority = std::pair<int, unsigned long>;
using QueueItem = std::pair<WorkListUnit, QueuePriority>;
struct ExplorationComparator {
bool operator() (const QueueItem &LHS, const QueueItem &RHS) {
return LHS.second < RHS.second;
}
};
// Number of inserted nodes, used to emulate DFS ordering in the priority
// queue when insertions are equal.
unsigned long Counter = 0;
@ -219,7 +213,7 @@ class UnexploredFirstPriorityQueue : public WorkList {
VisitedTimesMap NumReached;
// The top item is the largest one.
llvm::PriorityQueue<QueueItem, std::vector<QueueItem>, ExplorationComparator>
llvm::PriorityQueue<QueueItem, std::vector<QueueItem>, llvm::less_second>
queue;
public:
@ -267,12 +261,6 @@ class UnexploredFirstPriorityLocationQueue : public WorkList {
using QueuePriority = std::pair<int, unsigned long>;
using QueueItem = std::pair<WorkListUnit, QueuePriority>;
struct ExplorationComparator {
bool operator() (const QueueItem &LHS, const QueueItem &RHS) {
return LHS.second < RHS.second;
}
};
// Number of inserted nodes, used to emulate DFS ordering in the priority
// queue when insertions are equal.
unsigned long Counter = 0;
@ -281,7 +269,7 @@ class UnexploredFirstPriorityLocationQueue : public WorkList {
VisitedTimesMap NumReached;
// The top item is the largest one.
llvm::PriorityQueue<QueueItem, std::vector<QueueItem>, ExplorationComparator>
llvm::PriorityQueue<QueueItem, std::vector<QueueItem>, llvm::less_second>
queue;
public:

View File

@ -257,9 +257,7 @@ static void predictValueUseListOrderImpl(const Value *V, const Function *F,
return LU->getOperandNo() > RU->getOperandNo();
});
if (llvm::is_sorted(List, [](const Entry &L, const Entry &R) {
return L.second < R.second;
}))
if (llvm::is_sorted(List, llvm::less_second()))
// Order is already correct.
return;

View File

@ -521,11 +521,7 @@ GlobalCtorDtorScraper::operator()(ThreadSafeModule TSM,
for (auto E : COrDtors)
InitsOrDeInits.push_back(std::make_pair(E.Func, E.Priority));
llvm::sort(InitsOrDeInits,
[](const std::pair<Function *, unsigned> &LHS,
const std::pair<Function *, unsigned> &RHS) {
return LHS.second < RHS.second;
});
llvm::sort(InitsOrDeInits, llvm::less_second());
auto *InitOrDeInitFuncEntryBlock =
BasicBlock::Create(Ctx, "entry", InitOrDeInitFunc);

View File

@ -223,9 +223,7 @@ predictValueUseListOrder(const Value *V, unsigned ID, const OrderMap &OM) {
return LU->getOperandNo() > RU->getOperandNo();
});
if (llvm::is_sorted(List, [](const Entry &L, const Entry &R) {
return L.second < R.second;
}))
if (llvm::is_sorted(List, llvm::less_second()))
// Order is already correct.
return {};

View File

@ -282,9 +282,7 @@ void ReplaceableMetadataImpl::replaceAllUsesWith(Metadata *MD) {
// Copy out uses since UseMap will get touched below.
using UseTy = std::pair<void *, std::pair<OwnerTy, uint64_t>>;
SmallVector<UseTy, 8> Uses(UseMap.begin(), UseMap.end());
llvm::sort(Uses, [](const UseTy &L, const UseTy &R) {
return L.second.second < R.second.second;
});
llvm::sort(Uses, llvm::less_second());
for (const auto &Pair : Uses) {
// Check that this Ref hasn't disappeared after RAUW (when updating a
// previous Ref).

View File

@ -778,10 +778,7 @@ bool AMDGPUPromoteAllocaImpl::hasSufficientLocalMem(const Function &F) {
//
// FIXME: We should really do something to fix the addresses to a more optimal
// value instead
llvm::sort(AllocatedSizes, [](std::pair<uint64_t, Align> LHS,
std::pair<uint64_t, Align> RHS) {
return LHS.second < RHS.second;
});
llvm::sort(AllocatedSizes, llvm::less_second());
// Check how much local memory is being used by global objects
CurrentLocalMemUsage = 0;

View File

@ -2131,8 +2131,7 @@ SDValue WebAssemblyTargetLowering::LowerBUILD_VECTOR(SDValue Op,
auto GetMostCommon = [](auto &Counts) {
auto CommonIt =
std::max_element(Counts.begin(), Counts.end(),
[](auto A, auto B) { return A.second < B.second; });
std::max_element(Counts.begin(), Counts.end(), llvm::less_second());
assert(CommonIt != Counts.end() && "Unexpected all-undef build_vector");
return *CommonIt;
};

View File

@ -2200,11 +2200,7 @@ bool LowerTypeTestsModule::lower() {
}
Sets.emplace_back(I, MaxUniqueId);
}
llvm::sort(Sets,
[](const std::pair<GlobalClassesTy::iterator, unsigned> &S1,
const std::pair<GlobalClassesTy::iterator, unsigned> &S2) {
return S1.second < S2.second;
});
llvm::sort(Sets, llvm::less_second());
// For each disjoint set we found...
for (const auto &S : Sets) {

View File

@ -658,12 +658,7 @@ Optional<SinkingInstructionCandidate> GVNSink::analyzeInstructionForSinking(
VNums[N]++;
}
unsigned VNumToSink =
std::max_element(VNums.begin(), VNums.end(),
[](const std::pair<uint32_t, unsigned> &I,
const std::pair<uint32_t, unsigned> &J) {
return I.second < J.second;
})
->first;
std::max_element(VNums.begin(), VNums.end(), llvm::less_second())->first;
if (VNums[VNumToSink] == 1)
// Can't sink anything!

View File

@ -1559,10 +1559,8 @@ findMostPopularDest(BasicBlock *BB,
DestPopularity[PredToDest.second]++;
// Find the most popular dest.
using VT = decltype(DestPopularity)::value_type;
auto MostPopular = std::max_element(
DestPopularity.begin(), DestPopularity.end(),
[](const VT &L, const VT &R) { return L.second < R.second; });
DestPopularity.begin(), DestPopularity.end(), llvm::less_second());
// Okay, we have finally picked the most popular destination.
return MostPopular->first;