From 9c9cf2a54c838b66b9e17741043184ad94b18401 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sat, 28 Jun 2025 13:26:57 -0700 Subject: [PATCH] [CodeGen] Use std::tie to implement a comparison functor (NFC) std::tie clearly expresses the intent while slightly shortening the code. --- llvm/lib/CodeGen/MachineScheduler.cpp | 28 +++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp index 7b4f29e82fe6f..76cba2949af60 100644 --- a/llvm/lib/CodeGen/MachineScheduler.cpp +++ b/llvm/lib/CodeGen/MachineScheduler.cpp @@ -1290,13 +1290,13 @@ LLVM_DUMP_METHOD void ScheduleDAGMI::dumpScheduleTraceTopDown() const { SchedModel.getWriteProcResEnd(SC))); if (MISchedSortResourcesInTrace) - llvm::stable_sort(ResourcesIt, - [](const MCWriteProcResEntry &LHS, - const MCWriteProcResEntry &RHS) -> bool { - return LHS.AcquireAtCycle < RHS.AcquireAtCycle || - (LHS.AcquireAtCycle == RHS.AcquireAtCycle && - LHS.ReleaseAtCycle < RHS.ReleaseAtCycle); - }); + llvm::stable_sort( + ResourcesIt, + [](const MCWriteProcResEntry &LHS, + const MCWriteProcResEntry &RHS) -> bool { + return std::tie(LHS.AcquireAtCycle, LHS.ReleaseAtCycle) < + std::tie(RHS.AcquireAtCycle, RHS.ReleaseAtCycle); + }); for (const MCWriteProcResEntry &PI : ResourcesIt) { C = FirstCycle; const std::string ResName = @@ -1371,13 +1371,13 @@ LLVM_DUMP_METHOD void ScheduleDAGMI::dumpScheduleTraceBottomUp() const { SchedModel.getWriteProcResEnd(SC))); if (MISchedSortResourcesInTrace) - llvm::stable_sort(ResourcesIt, - [](const MCWriteProcResEntry &LHS, - const MCWriteProcResEntry &RHS) -> bool { - return LHS.AcquireAtCycle < RHS.AcquireAtCycle || - (LHS.AcquireAtCycle == RHS.AcquireAtCycle && - LHS.ReleaseAtCycle < RHS.ReleaseAtCycle); - }); + llvm::stable_sort( + ResourcesIt, + [](const MCWriteProcResEntry &LHS, + const MCWriteProcResEntry &RHS) -> bool { + return std::tie(LHS.AcquireAtCycle, LHS.ReleaseAtCycle) < + std::tie(RHS.AcquireAtCycle, RHS.ReleaseAtCycle); + }); for (const MCWriteProcResEntry &PI : ResourcesIt) { C = FirstCycle; const std::string ResName =