Check TRI->getReservedRegs because other allocators do it. Even though
it makes no sense for allocation_order iterators to visit reserved regs.
The inline spiller depends on AliasAnalysis.
Manage the Query state to avoid uninitialized or stale results.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118800 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/RegAllocBase.h b/lib/CodeGen/RegAllocBase.h
index 8c3971d..c8c7856 100644
--- a/lib/CodeGen/RegAllocBase.h
+++ b/lib/CodeGen/RegAllocBase.h
@@ -106,6 +106,15 @@
// A RegAlloc pass should call this before allocatePhysRegs.
void init(const TargetRegisterInfo &tri, VirtRegMap &vrm, LiveIntervals &lis);
+ // Get an initialized query to check interferences between lvr and preg. Note
+ // that Query::init must be called at least once for each physical register
+ // before querying a new live virtual register. This ties queries_ and
+ // physReg2liu_ together.
+ LiveIntervalUnion::Query &query(LiveInterval &lvr, unsigned preg) {
+ queries_[preg].init(&lvr, &physReg2liu_[preg]);
+ return queries_[preg];
+ }
+
// The top-level driver. The output is a VirtRegMap that us updated with
// physical register assignments.
//
@@ -135,7 +144,7 @@
// Helper for spilling all live virtual registers currently unified under preg
// that interfere with the most recently queried lvr. Return true if spilling
// was successful, and append any new spilled/split intervals to splitLVRs.
- bool spillInterferences(unsigned preg,
+ bool spillInterferences(LiveInterval &lvr, unsigned preg,
SmallVectorImpl<LiveInterval*> &splitLVRs);
#ifndef NDEBUG
@@ -146,7 +155,8 @@
private:
void seedLiveVirtRegs(LiveVirtRegQueue &lvrQ);
- void spillReg(unsigned reg, SmallVectorImpl<LiveInterval*> &splitLVRs);
+ void spillReg(LiveInterval &lvr, unsigned reg,
+ SmallVectorImpl<LiveInterval*> &splitLVRs);
};
} // end namespace llvm