Set REQUIRES shell on the test cases for r186044
[oota-llvm.git] / lib / CodeGen / AllocationOrder.cpp
index a76791025d9a013f6f42017460779239b8e3553b..3fa1f8ff206cdf0373efc6867e0e5ccbb724a9f8 100644 (file)
@@ -22,7 +22,6 @@
 #include "llvm/CodeGen/VirtRegMap.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
-#include "llvm/Target/TargetMachine.h"
 
 using namespace llvm;
 
@@ -35,6 +34,7 @@ AllocationOrder::AllocationOrder(unsigned VirtReg,
   const TargetRegisterInfo *TRI = &VRM.getTargetRegInfo();
   Order = RegClassInfo.getOrder(MF.getRegInfo().getRegClass(VirtReg));
   TRI->getRegAllocationHints(VirtReg, Order, Hints, MF, &VRM);
+  rewind();
 
   DEBUG({
     if (!Hints.empty()) {
@@ -44,22 +44,9 @@ AllocationOrder::AllocationOrder(unsigned VirtReg,
       dbgs() << '\n';
     }
   });
-}
-
-bool AllocationOrder::isHint(unsigned PhysReg) const {
-  return std::find(Hints.begin(), Hints.end(), PhysReg) != Hints.end();
-}
-
-unsigned AllocationOrder::next() {
-  if (Pos < Hints.size())
-    return Hints[Pos++];
-  ArrayRef<MCPhysReg>::iterator I = Order.begin() + (Pos - Hints.size());
-  ArrayRef<MCPhysReg>::iterator E = Order.end();
-  while (I != E) {
-    unsigned Reg = *I++;
-    ++Pos;
-    if (!isHint(Reg))
-      return Reg;
-  }
-  return 0;
+#ifndef NDEBUG
+  for (unsigned I = 0, E = Hints.size(); I != E; ++I)
+    assert(std::find(Order.begin(), Order.end(), Hints[I]) != Order.end() &&
+           "Target hint is outside allocation order.");
+#endif
 }