Fix PR9883. Make sure all caches are invalidated when a live range is repaired.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Tue, 10 May 2011 17:37:41 +0000 (17:37 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Tue, 10 May 2011 17:37:41 +0000 (17:37 +0000)
The previous invalidation missed the alias interference caches.

Also add a stats counter for the number of repaired ranges.

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

lib/CodeGen/RegAllocBase.h
lib/CodeGen/RegAllocBasic.cpp
lib/CodeGen/RegAllocGreedy.cpp
lib/CodeGen/SplitKit.cpp

index f431d5a5a026aeec0ec478b0fbb5c3e7ed6578ac..b25ea23f8543bfb9fd07dc6acbb75847922744c2 100644 (file)
@@ -113,6 +113,10 @@ protected:
     return Queries[PhysReg];
   }
 
+  // Invalidate all cached information about virtual registers - live ranges may
+  // have changed.
+  void invalidateVirtRegs() { ++UserTag; }
+
   // The top-level driver. The output is a VirtRegMap that us updated with
   // physical register assignments.
   //
index 32cb62223b5f87cdae2125c910794d79584fe3fc..fdc4418c9184216a1c438a2d74b2888892705465 100644 (file)
@@ -309,7 +309,7 @@ void RegAllocBase::allocatePhysRegs() {
     }
 
     // Invalidate all interference queries, live ranges could have changed.
-    ++UserTag;
+    invalidateVirtRegs();
 
     // selectOrSplit requests the allocator to return an available physical
     // register if possible and populate a list of new live intervals that
index e9920b82712766a1cac50c1ae5d91dd5897f1b92..87e08ba199fdf9b9c3799157f5028b996b8762fd 100644 (file)
@@ -1325,9 +1325,7 @@ unsigned RAGreedy::trySplit(LiveInterval &VirtReg, AllocationOrder &Order,
   // an assertion when the coalescer is fixed.
   if (SA->didRepairRange()) {
     // VirtReg has changed, so all cached queries are invalid.
-    Order.rewind();
-    while (unsigned PhysReg = Order.next())
-      query(VirtReg, PhysReg).clear();
+    invalidateVirtRegs();
     if (unsigned PhysReg = tryAssign(VirtReg, Order, NewVRegs))
       return PhysReg;
   }
index 739ba362745918e6d30a44ba3256bdd4f8158fda..55ae97c792add0afdb9ebc6b04c0aa7c7cc51f74 100644 (file)
@@ -32,6 +32,7 @@ STATISTIC(NumFinished, "Number of splits finished");
 STATISTIC(NumSimple,   "Number of splits that were simple");
 STATISTIC(NumCopies,   "Number of copies inserted for splitting");
 STATISTIC(NumRemats,   "Number of rematerialized defs for splitting");
+STATISTIC(NumRepairs,  "Number of invalid live ranges repaired");
 
 //===----------------------------------------------------------------------===//
 //                                 Split Analysis
@@ -123,6 +124,7 @@ void SplitAnalysis::analyzeUses() {
     // FIXME: calcLiveBlockInfo found inconsistencies in the live range.
     // I am looking at you, SimpleRegisterCoalescing!
     DidRepairRange = true;
+    ++NumRepairs;
     DEBUG(dbgs() << "*** Fixing inconsistent live interval! ***\n");
     const_cast<LiveIntervals&>(LIS)
       .shrinkToUses(const_cast<LiveInterval*>(CurLI));