Skip to content

Commit 9bcc0d1

Browse files
[CodeGen, Transforms] Use llvm::sort (NFC)
1 parent 2423ec5 commit 9bcc0d1

File tree

9 files changed

+20
-24
lines changed

9 files changed

+20
-24
lines changed

llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ void DbgValueHistoryMap::trimLocationRanges(
242242
if (ReferenceCount[i] <= 0 && HistoryMapEntries[i].isClobber())
243243
ToRemove.push_back(i);
244244

245-
std::sort(ToRemove.begin(), ToRemove.end());
245+
llvm::sort(ToRemove);
246246

247247
// Build an offset map so we can update the EndIndex of the remaining
248248
// entries.

llvm/lib/CodeGen/FixupStatepointCallerSaved.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ class FrameIndexesCache {
301301
void sortRegisters(SmallVectorImpl<Register> &Regs) {
302302
if (!FixupSCSExtendSlotSize)
303303
return;
304-
llvm::sort(Regs.begin(), Regs.end(), [&](Register &A, Register &B) {
304+
llvm::sort(Regs, [&](Register &A, Register &B) {
305305
return getRegisterSize(TRI, A) > getRegisterSize(TRI, B);
306306
});
307307
}

llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2282,7 +2282,7 @@ InstrRefBasedLDV::mlocJoin(MachineBasicBlock &MBB,
22822282
auto Cmp = [&](const MachineBasicBlock *A, const MachineBasicBlock *B) {
22832283
return BBToOrder.find(A)->second < BBToOrder.find(B)->second;
22842284
};
2285-
llvm::sort(BlockOrders.begin(), BlockOrders.end(), Cmp);
2285+
llvm::sort(BlockOrders, Cmp);
22862286

22872287
// Skip entry block.
22882288
if (BlockOrders.size() == 0)
@@ -2649,7 +2649,7 @@ std::tuple<bool, bool> InstrRefBasedLDV::vlocJoin(
26492649
return BBToOrder[A] < BBToOrder[B];
26502650
};
26512651

2652-
llvm::sort(BlockOrders.begin(), BlockOrders.end(), Cmp);
2652+
llvm::sort(BlockOrders, Cmp);
26532653

26542654
unsigned CurBlockRPONum = BBToOrder[&MBB];
26552655

@@ -2991,7 +2991,7 @@ void InstrRefBasedLDV::vlocDataflow(
29912991
for (auto *MBB : BlocksToExplore)
29922992
BlockOrders.push_back(const_cast<MachineBasicBlock *>(MBB));
29932993

2994-
llvm::sort(BlockOrders.begin(), BlockOrders.end(), Cmp);
2994+
llvm::sort(BlockOrders, Cmp);
29952995
unsigned NumBlocks = BlockOrders.size();
29962996

29972997
// Allocate some vectors for storing the live ins and live outs. Large.
@@ -3170,7 +3170,7 @@ void InstrRefBasedLDV::emitLocations(
31703170
// in the middle.
31713171
for (auto &P : TTracker->Transfers) {
31723172
// Sort them according to appearance order.
3173-
llvm::sort(P.Insts.begin(), P.Insts.end(), OrderDbgValues);
3173+
llvm::sort(P.Insts, OrderDbgValues);
31743174
// Insert either before or after the designated point...
31753175
if (P.MBB) {
31763176
MachineBasicBlock &MBB = *P.MBB;

llvm/lib/CodeGen/RDFLiveness.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,11 @@ NodeList Liveness::getAllReachingDefs(RegisterRef RefRR,
230230
TmpBB.push_back(Bucket.first);
231231
if (Bucket.second.size() > 2)
232232
GetOrder(*Bucket.first);
233-
llvm::sort(Bucket.second.begin(), Bucket.second.end(), Precedes);
233+
llvm::sort(Bucket.second, Precedes);
234234
}
235235

236236
// Sort the blocks with respect to dominance.
237-
llvm::sort(TmpBB.begin(), TmpBB.end(),
237+
llvm::sort(TmpBB,
238238
[this](auto A, auto B) { return MDT.properlyDominates(A, B); });
239239

240240
std::vector<NodeId> TmpInst;

llvm/lib/CodeGen/RegAllocFast.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,8 +1157,7 @@ void RegAllocFast::allocateInstruction(MachineInstr &MI) {
11571157
}
11581158
}
11591159

1160-
llvm::sort(DefOperandIndexes.begin(), DefOperandIndexes.end(),
1161-
[&](uint16_t I0, uint16_t I1) {
1160+
llvm::sort(DefOperandIndexes, [&](uint16_t I0, uint16_t I1) {
11621161
const MachineOperand &MO0 = MI.getOperand(I0);
11631162
const MachineOperand &MO1 = MI.getOperand(I1);
11641163
Register Reg0 = MO0.getReg();

llvm/lib/Transforms/Coroutines/CoroFrame.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2003,11 +2003,10 @@ static void sinkSpillUsesAfterCoroBegin(Function &F,
20032003

20042004
// Sort by dominance.
20052005
SmallVector<Instruction *, 64> InsertionList(ToMove.begin(), ToMove.end());
2006-
std::sort(InsertionList.begin(), InsertionList.end(),
2007-
[&Dom](Instruction *A, Instruction *B) -> bool {
2008-
// If a dominates b it should preceed (<) b.
2009-
return Dom.dominates(A, B);
2010-
});
2006+
llvm::sort(InsertionList, [&Dom](Instruction *A, Instruction *B) -> bool {
2007+
// If a dominates b it should preceed (<) b.
2008+
return Dom.dominates(A, B);
2009+
});
20112010

20122011
Instruction *InsertPt = CoroBegin->getNextNode();
20132012
for (Instruction *Inst : InsertionList)

llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ void ModuleSanitizerCoverage::InjectTraceForSwitch(
795795
C = ConstantExpr::getCast(CastInst::ZExt, It.getCaseValue(), Int64Ty);
796796
Initializers.push_back(C);
797797
}
798-
llvm::sort(Initializers.begin() + 2, Initializers.end(),
798+
llvm::sort(drop_begin(Initializers, 2),
799799
[](const Constant *A, const Constant *B) {
800800
return cast<ConstantInt>(A)->getLimitedValue() <
801801
cast<ConstantInt>(B)->getLimitedValue();

llvm/lib/Transforms/Scalar/ConstraintElimination.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,9 @@ static bool eliminateConstraints(Function &F, DominatorTree &DT) {
259259
// come before blocks and conditions dominated by them. If a block and a
260260
// condition have the same numbers, the condition comes before the block, as
261261
// it holds on entry to the block.
262-
sort(WorkList.begin(), WorkList.end(),
263-
[](const ConstraintOrBlock &A, const ConstraintOrBlock &B) {
264-
return std::tie(A.NumIn, A.IsBlock) < std::tie(B.NumIn, B.IsBlock);
265-
});
262+
sort(WorkList, [](const ConstraintOrBlock &A, const ConstraintOrBlock &B) {
263+
return std::tie(A.NumIn, A.IsBlock) < std::tie(B.NumIn, B.IsBlock);
264+
});
266265

267266
// Finally, process ordered worklist and eliminate implied conditions.
268267
SmallVector<StackEntry, 16> DFSInStack;

llvm/lib/Transforms/Scalar/NewGVN.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3372,10 +3372,9 @@ bool NewGVN::runGVN() {
33723372
for (auto &B : RPOT) {
33733373
auto *Node = DT->getNode(B);
33743374
if (Node->getNumChildren() > 1)
3375-
llvm::sort(Node->begin(), Node->end(),
3376-
[&](const DomTreeNode *A, const DomTreeNode *B) {
3377-
return RPOOrdering[A] < RPOOrdering[B];
3378-
});
3375+
llvm::sort(*Node, [&](const DomTreeNode *A, const DomTreeNode *B) {
3376+
return RPOOrdering[A] < RPOOrdering[B];
3377+
});
33793378
}
33803379

33813380
// Now a standard depth first ordering of the domtree is equivalent to RPO.

0 commit comments

Comments
 (0)