[llvm] 47b9837 - [llvm] Use std::tie to implement comparison functors (NFC) (#141353)

via llvm-commits llvm-commits at lists.llvm.org
Sat May 24 09:37:35 PDT 2025


Author: Kazu Hirata
Date: 2025-05-24T09:37:32-07:00
New Revision: 47b9837dad85be73fdb28c211c8d849fafcec1ec

URL: https://github.com/llvm/llvm-project/commit/47b9837dad85be73fdb28c211c8d849fafcec1ec
DIFF: https://github.com/llvm/llvm-project/commit/47b9837dad85be73fdb28c211c8d849fafcec1ec.diff

LOG: [llvm] Use std::tie to implement comparison functors (NFC) (#141353)

Added: 
    

Modified: 
    llvm/lib/Transforms/IPO/SampleProfile.cpp
    llvm/tools/llvm-exegesis/lib/SchedClassResolution.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp
index 616eeae3b1fec..000b3ccbb3cbc 100644
--- a/llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -897,9 +897,7 @@ updateIDTMetaData(Instruction &Inst,
 
   llvm::sort(NewCallTargets,
              [](const InstrProfValueData &L, const InstrProfValueData &R) {
-               if (L.Count != R.Count)
-                 return L.Count > R.Count;
-               return L.Value > R.Value;
+               return std::tie(L.Count, L.Value) > std::tie(R.Count, R.Value);
              });
 
   uint32_t MaxMDCount =

diff  --git a/llvm/tools/llvm-exegesis/lib/SchedClassResolution.cpp b/llvm/tools/llvm-exegesis/lib/SchedClassResolution.cpp
index 0690c21220f89..d6dfb65bf82e6 100644
--- a/llvm/tools/llvm-exegesis/lib/SchedClassResolution.cpp
+++ b/llvm/tools/llvm-exegesis/lib/SchedClassResolution.cpp
@@ -69,11 +69,7 @@ getNonRedundantWriteProcRes(const MCSchedClassDesc &SCDesc,
        [](const ResourceMaskAndEntry &A, const ResourceMaskAndEntry &B) {
          unsigned popcntA = popcount(A.first);
          unsigned popcntB = popcount(B.first);
-         if (popcntA < popcntB)
-           return true;
-         if (popcntA > popcntB)
-           return false;
-         return A.first < B.first;
+         return std::tie(popcntA, A.first) < std::tie(popcntB, B.first);
        });
 
   SmallVector<float, 32> ProcResUnitUsage(NumProcRes);


        


More information about the llvm-commits mailing list