Skip to content

Commit

Permalink
Use llvm::less_first and llvm::less_second (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazutakahirata committed Jul 24, 2022
1 parent 5e29360 commit acf648b
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 18 deletions.
Expand Up @@ -1430,9 +1430,7 @@ static bool ImportOffsetMap(llvm::DenseMap<const D *, O> &destination_map,
std::vector<PairType> sorted_items;
sorted_items.reserve(source_map.size());
sorted_items.assign(source_map.begin(), source_map.end());
llvm::sort(sorted_items, [](const PairType &lhs, const PairType &rhs) {
return lhs.second < rhs.second;
});
llvm::sort(sorted_items, llvm::less_second());

for (const auto &item : sorted_items) {
DeclFromUser<D> user_decl(const_cast<D *>(item.first));
Expand Down
4 changes: 1 addition & 3 deletions llvm/lib/Analysis/LoopAccessAnalysis.cpp
Expand Up @@ -1500,9 +1500,7 @@ bool llvm::sortPtrAccesses(ArrayRef<Value *> VL, Type *ElemTy,
Value *Ptr0 = VL[0];

using DistOrdPair = std::pair<int64_t, int>;
auto Compare = [](const DistOrdPair &L, const DistOrdPair &R) {
return L.first < R.first;
};
auto Compare = llvm::less_first();
std::set<DistOrdPair, decltype(Compare)> Offsets(Compare);
Offsets.emplace(0, 0);
int Cnt = 1;
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
Expand Up @@ -3136,8 +3136,7 @@ bool InstrRefBasedLDV::emitTransfers(
MI->getDebugLoc()->getInlinedAt());
Insts.emplace_back(AllVarsNumbering.find(Var)->second, MI);
}
llvm::sort(Insts,
[](const auto &A, const auto &B) { return A.first < B.first; });
llvm::sort(Insts, llvm::less_first());

// Insert either before or after the designated point...
if (P.MBB) {
Expand Down
4 changes: 1 addition & 3 deletions llvm/lib/Target/DirectX/DXILWriter/DXILValueEnumerator.cpp
Expand Up @@ -260,9 +260,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;

Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
Expand Up @@ -631,8 +631,7 @@ static bool findArgParts(Argument *Arg, const DataLayout &DL, AAResults &AAR,

// Sort parts by offset.
append_range(ArgPartsVec, ArgParts);
sort(ArgPartsVec,
[](const auto &A, const auto &B) { return A.first < B.first; });
sort(ArgPartsVec, llvm::less_first());

// Make sure the parts are non-overlapping.
int64_t Offset = ArgPartsVec[0].first;
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/Transforms/IPO/GlobalOpt.cpp
Expand Up @@ -470,8 +470,7 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV, const DataLayout &DL) {
// Sort by offset.
SmallVector<std::pair<uint64_t, Type *>, 16> TypesVector;
append_range(TypesVector, Types);
sort(TypesVector,
[](const auto &A, const auto &B) { return A.first < B.first; });
sort(TypesVector, llvm::less_first());

// Check that the types are non-overlapping.
uint64_t Offset = 0;
Expand Down
4 changes: 1 addition & 3 deletions llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Expand Up @@ -10972,9 +10972,7 @@ class HorizontalReduction {
It != E; ++It) {
PossibleRedValsVect.emplace_back();
auto RedValsVect = It->second.takeVector();
stable_sort(RedValsVect, [](const auto &P1, const auto &P2) {
return P1.second < P2.second;
});
stable_sort(RedValsVect, llvm::less_second());
for (const std::pair<Value *, unsigned> &Data : RedValsVect)
PossibleRedValsVect.back().append(Data.second, Data.first);
}
Expand Down

0 comments on commit acf648b

Please sign in to comment.