turn off GOT on archs that didn't use it (not that it appeard to harm them much with...
[oota-llvm.git] / lib / CodeGen / RegAllocLinearScan.cpp
index 2b389117e7e0385d8458e8deebcbbbfcfe18df34..61cc11e413d23f9d58f2338ef8169194570ff787 100644 (file)
@@ -48,6 +48,7 @@ namespace {
     const TargetMachine* tm_;
     const MRegisterInfo* mri_;
     LiveIntervals* li_;
+    bool *PhysRegsUsed;
 
     /// handled_ - Intervals are added to the handled_ set in the order of their
     /// start value.  This is uses for backtracking.
@@ -139,6 +140,10 @@ bool RA::runOnMachineFunction(MachineFunction &fn) {
   mri_ = tm_->getRegisterInfo();
   li_ = &getAnalysis<LiveIntervals>();
 
+  PhysRegsUsed = new bool[mri_->getNumRegs()];
+  std::fill(PhysRegsUsed, PhysRegsUsed+mri_->getNumRegs(), false);
+  fn.setUsedPhysRegs(PhysRegsUsed);
+
   if (!prt_.get()) prt_.reset(new PhysRegTracker(*mri_));
   vrm_.reset(new VirtRegMap(*mf_));
   if (!spiller_.get()) spiller_.reset(createSpiller());
@@ -147,6 +152,7 @@ bool RA::runOnMachineFunction(MachineFunction &fn) {
 
   linearScan();
 
+  // Rewrite spill code and update the PhysRegsUsed set.
   spiller_->runOnMachineFunction(*mf_, *vrm_);
 
   vrm_.reset();  // Free the VirtRegMap
@@ -170,9 +176,10 @@ void RA::initIntervalSets()
          "interval sets should be empty on initialization");
 
   for (LiveIntervals::iterator i = li_->begin(), e = li_->end(); i != e; ++i) {
-    if (MRegisterInfo::isPhysicalRegister(i->second.reg))
+    if (MRegisterInfo::isPhysicalRegister(i->second.reg)) {
+      PhysRegsUsed[i->second.reg] = true;
       fixed_.push_back(std::make_pair(&i->second, i->second.begin()));
-    else
+    else
       unhandled_.push(&i->second);
   }
 }
@@ -201,7 +208,7 @@ void RA::linearScan()
 
     assert(MRegisterInfo::isVirtualRegister(cur->reg) &&
            "Can only allocate virtual registers!");
-    
+
     // Allocating a virtual register. try to find a free
     // physical register or spill an interval (possibly this one) in order to
     // assign it one.
@@ -259,7 +266,7 @@ void RA::processActiveIntervals(unsigned CurPoint)
       active_[i] = active_.back();
       active_.pop_back();
       --i; --e;
-      
+
     } else if (IntervalPos->start > CurPoint) {
       // Move inactive intervals to inactive list.
       DEBUG(std::cerr << "\t\tinterval " << *Interval << " inactive\n");
@@ -293,7 +300,7 @@ void RA::processInactiveIntervals(unsigned CurPoint)
     unsigned reg = Interval->reg;
 
     IntervalPos = Interval->advanceTo(IntervalPos, CurPoint);
-    
+
     if (IntervalPos == Interval->end()) {       // remove expired intervals.
       DEBUG(std::cerr << "\t\tinterval " << *Interval << " expired\n");
 
@@ -324,7 +331,7 @@ void RA::processInactiveIntervals(unsigned CurPoint)
 
 /// updateSpillWeights - updates the spill weights of the specifed physical
 /// register and its weight.
-static void updateSpillWeights(std::vector<float> &Weights, 
+static void updateSpillWeights(std::vector<float> &Weights,
                                unsigned reg, float weight,
                                const MRegisterInfo *MRI) {
   Weights[reg] += weight;
@@ -423,7 +430,7 @@ void RA::assignRegOrStackSlotAtInterval(LiveInterval* cur)
 
   DEBUG(std::cerr << "\tassigning stack slot at interval "<< *cur << ":\n");
 
-  float minWeight = HUGE_VAL;
+  float minWeight = float(HUGE_VAL);
   unsigned minReg = 0;
   const TargetRegisterClass* rc = mf_->getSSARegMap()->getRegClass(cur->reg);
   for (TargetRegisterClass::iterator i = rc->allocation_order_begin(*mf_),