Adds support for spilling previously allocated live intervals to
handle cases in which a register is unavailable for spill code.
Adds LiveIntervalUnion::extract. While processing interferences on a
live virtual register, reuses the same Query object for each
physcial reg.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118423 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/RegAllocBase.h b/lib/CodeGen/RegAllocBase.h
index 1534c0d..f4ca972 100644
--- a/lib/CodeGen/RegAllocBase.h
+++ b/lib/CodeGen/RegAllocBase.h
@@ -94,6 +94,10 @@
   LiveIntervals *lis_;
   LIUArray physReg2liu_;
 
+  // Current queries, one per physreg. They must be reinitialized each time we
+  // query on a new live virtual register.
+  OwningArrayPtr<LiveIntervalUnion::Query> queries_;
+
   RegAllocBase(): tri_(0), vrm_(0), lis_(0) {}
 
   virtual ~RegAllocBase() {}
@@ -120,9 +124,15 @@
   virtual void releaseMemory();
 
   // Helper for checking interference between a live virtual register and a
-  // physical register, including all its register aliases.
-  bool checkPhysRegInterference(LiveIntervalUnion::Query &query, unsigned preg);
-  
+  // physical register, including all its register aliases. If an interference
+  // exists, return the interfering register, which may be preg or an alias.
+  unsigned checkPhysRegInterference(LiveInterval& lvr, unsigned preg);
+
+  // Helper that spills all live virtual registers currently unified under preg
+  // that interfere with the most recently queried lvr.
+  void spillInterferences(unsigned preg,
+                          SmallVectorImpl<LiveInterval*> &splitLVRs);
+
 private:
   void seedLiveVirtRegs(LiveVirtRegQueue &lvrQ);
 };