[llvm-branch-commits] [llvm-branch] r70073 - in /llvm/branches/Apple/Dib: include/llvm/CodeGen/LiveInterval.h lib/CodeGen/LiveInterval.cpp test/CodeGen/X86/2009-04-25-CoalescerBug.ll

Bill Wendling isanbard at gmail.com
Sat Apr 25 13:47:51 PDT 2009


Author: void
Date: Sat Apr 25 15:47:51 2009
New Revision: 70073

URL: http://llvm.org/viewvc/llvm-project?rev=70073&view=rev
Log:
Merge r70026:

Do not share a single unknown val# for all the live ranges merged into a
physical sub-register live interval. When coalescer is merging in clobbered
virtaul register live interval into a physical register live interval, give each
virtual register val# a separate val# in the physical register live
interval. Otherwise, the coalescer would have lost track of the definitions
information it needs to make correct coalescing decisions.

and r70069:

Reuse unused val#'s to avoid running out of memory in extreme cases.

into Dib.

Added:
    llvm/branches/Apple/Dib/test/CodeGen/X86/2009-04-25-CoalescerBug.ll
      - copied unchanged from r70026, llvm/trunk/test/CodeGen/X86/2009-04-25-CoalescerBug.ll
Modified:
    llvm/branches/Apple/Dib/include/llvm/CodeGen/LiveInterval.h
    llvm/branches/Apple/Dib/lib/CodeGen/LiveInterval.cpp

Modified: llvm/branches/Apple/Dib/include/llvm/CodeGen/LiveInterval.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/include/llvm/CodeGen/LiveInterval.h?rev=70073&r1=70072&r2=70073&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/include/llvm/CodeGen/LiveInterval.h (original)
+++ llvm/branches/Apple/Dib/include/llvm/CodeGen/LiveInterval.h Sat Apr 25 15:47:51 2009
@@ -213,10 +213,6 @@
       return VNI;
     }
 
-    /// getUnknownValNo - Find a value# for unknown values, if there isn't one
-    /// create a new one.
-    VNInfo *getUnknownValNo(BumpPtrAllocator &VNInfoAllocator);
-
     /// addKill - Add a kill instruction index to the specified value
     /// number.
     static void addKill(VNInfo *VNI, unsigned KillIdx) {

Modified: llvm/branches/Apple/Dib/lib/CodeGen/LiveInterval.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/CodeGen/LiveInterval.cpp?rev=70073&r1=70072&r2=70073&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/lib/CodeGen/LiveInterval.cpp (original)
+++ llvm/branches/Apple/Dib/lib/CodeGen/LiveInterval.cpp Sat Apr 25 15:47:51 2009
@@ -19,6 +19,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/CodeGen/LiveInterval.h"
+#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Streams.h"
@@ -567,20 +568,6 @@
   }
 }
 
-VNInfo *LiveInterval::getUnknownValNo(BumpPtrAllocator &VNInfoAllocator) {
-  unsigned i = getNumValNums();
-  if (i) {
-    do {
-      --i;
-      VNInfo *VNI = getValNumInfo(i);
-      if (VNI->def == ~0U && !VNI->copy &&
-          !VNI->hasPHIKill && !VNI->redefByEC && VNI->kills.empty())
-        return VNI;
-    } while (i != 0);
-  }
-  return getNextValue(~0U, 0, VNInfoAllocator);
-}
-
 
 /// MergeInClobberRanges - For any live ranges that are not defined in the
 /// current interval, but are defined in the Clobbers interval, mark them
@@ -589,12 +576,22 @@
                                         BumpPtrAllocator &VNInfoAllocator) {
   if (Clobbers.empty()) return;
   
-  // Find a value # to use for the clobber ranges.  If there is already a value#
-  // for unknown values, use it.
-  VNInfo *ClobberValNo = getUnknownValNo(VNInfoAllocator);
-  
+  DenseMap<VNInfo*, VNInfo*> ValNoMaps;
+  VNInfo *UnusedValNo = 0;
   iterator IP = begin();
   for (const_iterator I = Clobbers.begin(), E = Clobbers.end(); I != E; ++I) {
+    // For every val# in the Clobbers interval, create a new "unknown" val#.
+    VNInfo *ClobberValNo = 0;
+    DenseMap<VNInfo*, VNInfo*>::iterator VI = ValNoMaps.find(I->valno);
+    if (VI != ValNoMaps.end())
+      ClobberValNo = VI->second;
+    else if (UnusedValNo)
+      ClobberValNo = UnusedValNo;
+    else {
+      UnusedValNo = ClobberValNo = getNextValue(~0U, 0, VNInfoAllocator);
+      ValNoMaps.insert(std::make_pair(I->valno, ClobberValNo));
+    }
+
     bool Done = false;
     unsigned Start = I->start, End = I->end;
     // If a clobber range starts before an existing range and ends after
@@ -629,6 +626,7 @@
       // Insert the clobber interval.
       IP = addRangeFrom(LiveRange(SubRangeStart, SubRangeEnd, ClobberValNo),
                         IP);
+      UnusedValNo = 0;
     }
   }
 }
@@ -637,7 +635,7 @@
                                        BumpPtrAllocator &VNInfoAllocator) {
   // Find a value # to use for the clobber ranges.  If there is already a value#
   // for unknown values, use it.
-  VNInfo *ClobberValNo = getUnknownValNo(VNInfoAllocator);
+  VNInfo *ClobberValNo = getNextValue(~0U, 0, VNInfoAllocator);
   
   iterator IP = begin();
   IP = std::upper_bound(IP, end(), Start);





More information about the llvm-branch-commits mailing list