Check hint registers for interference only once before evictions
authorAditya Nandakumar <aditya_nandakumar@apple.com>
Thu, 5 Dec 2013 21:18:40 +0000 (21:18 +0000)
committerAditya Nandakumar <aditya_nandakumar@apple.com>
Thu, 5 Dec 2013 21:18:40 +0000 (21:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196536 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AllocationOrder.h
lib/CodeGen/RegAllocGreedy.cpp

index aed461a7ed028d2e62c4a5458d4fcaf5f2c48901..64ff2a7ce8367bbc24e4d7b2bcd8bf3c4f74bcc0 100644 (file)
@@ -45,10 +45,12 @@ public:
   /// Return the next physical register in the allocation order, or 0.
   /// It is safe to call next() again after it returned 0, it will keep
   /// returning 0 until rewind() is called.
-  unsigned next() {
+  unsigned next(unsigned Limit = 0) {
     if (Pos < 0)
       return Hints.end()[Pos++];
-    while (Pos < int(Order.size())) {
+    if (!Limit)
+      Limit = Order.size();
+    while (Pos < int(Limit)) {
       unsigned Reg = Order[Pos++];
       if (!isHint(Reg))
         return Reg;
index 3a02aaec3448e30eb30fbef6b27b781805c57a9c..7ddc4d5ad86e95d4bc085b88cf609b388c7402a5 100644 (file)
@@ -723,7 +723,7 @@ unsigned RAGreedy::tryEvict(LiveInterval &VirtReg,
   }
 
   Order.rewind();
-  while (unsigned PhysReg = Order.nextWithDups(OrderLimit)) {
+  while (unsigned PhysReg = Order.next(OrderLimit)) {
     if (TRI->getCostPerUse(PhysReg) >= CostPerUseLimit)
       continue;
     // The first use of a callee-saved register in a function has cost 1.