]> granicus.if.org Git - llvm/commitdiff
[RegAllocGreedy] Fix an assertion and condition when last chance recoloring is used.
authorQuentin Colombet <qcolombet@apple.com>
Fri, 16 Sep 2016 22:00:42 +0000 (22:00 +0000)
committerQuentin Colombet <qcolombet@apple.com>
Fri, 16 Sep 2016 22:00:42 +0000 (22:00 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281782 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/RegAllocGreedy.cpp

index 01d0f11bc81121935dbe181022827297c4949a35..9d1d5c68365b681e3377de0c11dac983bc02b6f8 100644 (file)
@@ -2524,7 +2524,7 @@ unsigned RAGreedy::selectOrSplitImpl(LiveInterval &VirtReg,
       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(LiveInterval &VirtReg,
                                    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.