[llvm] r241823 - [StackMap] Use lambdas to specify the sort and erase conditions. NFC.

Juergen Ributzka juergen at apple.com
Thu Jul 9 10:11:15 PDT 2015


Author: ributzka
Date: Thu Jul  9 12:11:15 2015
New Revision: 241823

URL: http://llvm.org/viewvc/llvm-project?rev=241823&view=rev
Log:
[StackMap] Use lambdas to specify the sort and erase conditions. NFC.

Modified:
    llvm/trunk/include/llvm/CodeGen/StackMaps.h
    llvm/trunk/lib/CodeGen/StackMaps.cpp

Modified: llvm/trunk/include/llvm/CodeGen/StackMaps.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/StackMaps.h?rev=241823&r1=241822&r2=241823&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/StackMaps.h (original)
+++ llvm/trunk/include/llvm/CodeGen/StackMaps.h Thu Jul  9 12:11:15 2015
@@ -152,13 +152,6 @@ public:
     unsigned short DwarfRegNum;
     unsigned short Size;
 
-    void MarkInvalid() { Reg = 0; }
-
-    // Only sort by the dwarf register number.
-    bool operator<(const LiveOutReg &LO) const {
-      return DwarfRegNum < LO.DwarfRegNum;
-    }
-    static bool IsInvalid(const LiveOutReg &LO) { return LO.Reg == 0; }
     LiveOutReg() : Reg(0), DwarfRegNum(0), Size(0) {}
     LiveOutReg(unsigned short Reg, unsigned short DwarfRegNum,
                unsigned short Size)

Modified: llvm/trunk/lib/CodeGen/StackMaps.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StackMaps.cpp?rev=241823&r1=241822&r2=241823&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/StackMaps.cpp (original)
+++ llvm/trunk/lib/CodeGen/StackMaps.cpp Thu Jul  9 12:11:15 2015
@@ -248,10 +248,15 @@ StackMaps::parseRegisterLiveOutMask(cons
   // We don't need to keep track of a register if its super-register is already
   // in the list. Merge entries that refer to the same dwarf register and use
   // the maximum size that needs to be spilled.
-  std::sort(LiveOuts.begin(), LiveOuts.end());
-  for (LiveOutVec::iterator I = LiveOuts.begin(), E = LiveOuts.end(); I != E;
-       ++I) {
-    for (LiveOutVec::iterator II = std::next(I); II != E; ++II) {
+
+  std::sort(LiveOuts.begin(), LiveOuts.end(),
+            [](const LiveOutReg &LHS, const LiveOutReg &RHS) {
+              // Only sort by the dwarf register number.
+              return LHS.DwarfRegNum < RHS.DwarfRegNum;
+            });
+
+  for (auto I = LiveOuts.begin(), E = LiveOuts.end(); I != E; ++I) {
+    for (auto II = std::next(I); II != E; ++II) {
       if (I->DwarfRegNum != II->DwarfRegNum) {
         // Skip all the now invalid entries.
         I = --II;
@@ -260,12 +265,15 @@ StackMaps::parseRegisterLiveOutMask(cons
       I->Size = std::max(I->Size, II->Size);
       if (TRI->isSuperRegister(I->Reg, II->Reg))
         I->Reg = II->Reg;
-      II->MarkInvalid();
+      II->Reg = 0; // mark for deletion.
     }
   }
+
   LiveOuts.erase(
-      std::remove_if(LiveOuts.begin(), LiveOuts.end(), LiveOutReg::IsInvalid),
+      std::remove_if(LiveOuts.begin(), LiveOuts.end(),
+                     [](const LiveOutReg &LO) { return LO.Reg == 0; }),
       LiveOuts.end());
+
   return LiveOuts;
 }
 





More information about the llvm-commits mailing list