[llvm] r281782 - [RegAllocGreedy] Fix an assertion and condition when last chance recoloring is used.

Quentin Colombet via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 16 15:00:42 PDT 2016


Author: qcolombet
Date: Fri Sep 16 17:00:42 2016
New Revision: 281782

URL: http://llvm.org/viewvc/llvm-project?rev=281782&view=rev
Log:
[RegAllocGreedy] Fix an assertion and condition when last chance recoloring is used.

When last chance recoloring is used, the list of NewVRegs may not be
empty when calling selectOrSplitImpl. Indeed, another coloring may have
taken place with splitting/spilling in the same recoloring session.

Relax an assertion to take this into account and adapt a condition to
act as if the NewVRegs were local to this selectOrSplitImpl instance.

Unfortunately I am unable to produce a test case for this, I was only
able to reproduce the conditions on an out-of-tree target.

Modified:
    llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp

Modified: llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp?rev=281782&r1=281781&r2=281782&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp Fri Sep 16 17:00:42 2016
@@ -2524,7 +2524,7 @@ unsigned RAGreedy::selectOrSplitImpl(Liv
       return PhysReg;
     }
 
-  assert(NewVRegs.empty() && "Cannot append to existing NewVRegs");
+  assert((NewVRegs.empty() || Depth) && "Cannot append to existing NewVRegs");
 
   // The first time we see a live range, don't try to split or spill.
   // Wait until the second time, when all smaller ranges have been allocated.
@@ -2543,8 +2543,9 @@ unsigned RAGreedy::selectOrSplitImpl(Liv
                                    Depth);
 
   // Try splitting VirtReg or interferences.
+  unsigned NewVRegSizeBefore = NewVRegs.size();
   unsigned PhysReg = trySplit(VirtReg, Order, NewVRegs);
-  if (PhysReg || !NewVRegs.empty())
+  if (PhysReg || (NewVRegs.size() - NewVRegSizeBefore))
     return PhysReg;
 
   // Finally spill VirtReg itself.




More information about the llvm-commits mailing list