Replace std::cerr uses of the "DEBUG" macro with "DOUT" instead. Removes

a #include of iostream.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31800 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bill Wendling
2006-11-17 00:50:36 +00:00
parent 8781466176
commit 54fcc7f704

View File

@@ -29,7 +29,6 @@
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
#include "llvm/Support/Compiler.h" #include "llvm/Support/Compiler.h"
#include <algorithm> #include <algorithm>
#include <iostream>
#include <set> #include <set>
#include <queue> #include <queue>
#include <memory> #include <memory>
@@ -138,14 +137,14 @@ namespace {
template <typename ItTy> template <typename ItTy>
void printIntervals(const char* const str, ItTy i, ItTy e) const { void printIntervals(const char* const str, ItTy i, ItTy e) const {
if (str) std::cerr << str << " intervals:\n"; if (str) DOUT << str << " intervals:\n";
for (; i != e; ++i) { for (; i != e; ++i) {
std::cerr << "\t" << *i->first << " -> "; DOUT << "\t" << *i->first << " -> ";
unsigned reg = i->first->reg; unsigned reg = i->first->reg;
if (MRegisterInfo::isVirtualRegister(reg)) { if (MRegisterInfo::isVirtualRegister(reg)) {
reg = vrm_->getPhys(reg); reg = vrm_->getPhys(reg);
} }
std::cerr << mri_->getName(reg) << '\n'; DOUT << mri_->getName(reg) << '\n';
} }
} }
}; };
@@ -243,9 +242,8 @@ void RA::initIntervalSets()
void RA::linearScan() void RA::linearScan()
{ {
// linear scan algorithm // linear scan algorithm
DEBUG(std::cerr << "********** LINEAR SCAN **********\n"); DOUT << "********** LINEAR SCAN **********\n";
DEBUG(std::cerr << "********** Function: " DOUT << "********** Function: " << mf_->getFunction()->getName() << '\n';
<< mf_->getFunction()->getName() << '\n');
// DEBUG(printIntervals("unhandled", unhandled_.begin(), unhandled_.end())); // DEBUG(printIntervals("unhandled", unhandled_.begin(), unhandled_.end()));
DEBUG(printIntervals("fixed", fixed_.begin(), fixed_.end())); DEBUG(printIntervals("fixed", fixed_.begin(), fixed_.end()));
@@ -257,7 +255,7 @@ void RA::linearScan()
LiveInterval* cur = unhandled_.top(); LiveInterval* cur = unhandled_.top();
unhandled_.pop(); unhandled_.pop();
++numIterations; ++numIterations;
DEBUG(std::cerr << "\n*** CURRENT ***: " << *cur << '\n'); DOUT << "\n*** CURRENT ***: " << *cur << '\n';
processActiveIntervals(cur->beginNumber()); processActiveIntervals(cur->beginNumber());
processInactiveIntervals(cur->beginNumber()); processInactiveIntervals(cur->beginNumber());
@@ -280,7 +278,7 @@ void RA::linearScan()
for (IntervalPtrs::reverse_iterator for (IntervalPtrs::reverse_iterator
i = active_.rbegin(); i != active_.rend(); ) { i = active_.rbegin(); i != active_.rend(); ) {
unsigned reg = i->first->reg; unsigned reg = i->first->reg;
DEBUG(std::cerr << "\tinterval " << *i->first << " expired\n"); DOUT << "\tinterval " << *i->first << " expired\n";
assert(MRegisterInfo::isVirtualRegister(reg) && assert(MRegisterInfo::isVirtualRegister(reg) &&
"Can only allocate virtual registers!"); "Can only allocate virtual registers!");
reg = vrm_->getPhys(reg); reg = vrm_->getPhys(reg);
@@ -291,18 +289,18 @@ void RA::linearScan()
// expire any remaining inactive intervals // expire any remaining inactive intervals
for (IntervalPtrs::reverse_iterator for (IntervalPtrs::reverse_iterator
i = inactive_.rbegin(); i != inactive_.rend(); ) { i = inactive_.rbegin(); i != inactive_.rend(); ) {
DEBUG(std::cerr << "\tinterval " << *i->first << " expired\n"); DOUT << "\tinterval " << *i->first << " expired\n";
i = IntervalPtrs::reverse_iterator(inactive_.erase(i.base()-1)); i = IntervalPtrs::reverse_iterator(inactive_.erase(i.base()-1));
} }
DEBUG(std::cerr << *vrm_); DOUT << *vrm_;
} }
/// processActiveIntervals - expire old intervals and move non-overlapping ones /// processActiveIntervals - expire old intervals and move non-overlapping ones
/// to the inactive list. /// to the inactive list.
void RA::processActiveIntervals(unsigned CurPoint) void RA::processActiveIntervals(unsigned CurPoint)
{ {
DEBUG(std::cerr << "\tprocessing active intervals:\n"); DOUT << "\tprocessing active intervals:\n";
for (unsigned i = 0, e = active_.size(); i != e; ++i) { for (unsigned i = 0, e = active_.size(); i != e; ++i) {
LiveInterval *Interval = active_[i].first; LiveInterval *Interval = active_[i].first;
@@ -312,7 +310,7 @@ void RA::processActiveIntervals(unsigned CurPoint)
IntervalPos = Interval->advanceTo(IntervalPos, CurPoint); IntervalPos = Interval->advanceTo(IntervalPos, CurPoint);
if (IntervalPos == Interval->end()) { // Remove expired intervals. if (IntervalPos == Interval->end()) { // Remove expired intervals.
DEBUG(std::cerr << "\t\tinterval " << *Interval << " expired\n"); DOUT << "\t\tinterval " << *Interval << " expired\n";
assert(MRegisterInfo::isVirtualRegister(reg) && assert(MRegisterInfo::isVirtualRegister(reg) &&
"Can only allocate virtual registers!"); "Can only allocate virtual registers!");
reg = vrm_->getPhys(reg); reg = vrm_->getPhys(reg);
@@ -325,7 +323,7 @@ void RA::processActiveIntervals(unsigned CurPoint)
} else if (IntervalPos->start > CurPoint) { } else if (IntervalPos->start > CurPoint) {
// Move inactive intervals to inactive list. // Move inactive intervals to inactive list.
DEBUG(std::cerr << "\t\tinterval " << *Interval << " inactive\n"); DOUT << "\t\tinterval " << *Interval << " inactive\n";
assert(MRegisterInfo::isVirtualRegister(reg) && assert(MRegisterInfo::isVirtualRegister(reg) &&
"Can only allocate virtual registers!"); "Can only allocate virtual registers!");
reg = vrm_->getPhys(reg); reg = vrm_->getPhys(reg);
@@ -348,7 +346,7 @@ void RA::processActiveIntervals(unsigned CurPoint)
/// ones to the active list. /// ones to the active list.
void RA::processInactiveIntervals(unsigned CurPoint) void RA::processInactiveIntervals(unsigned CurPoint)
{ {
DEBUG(std::cerr << "\tprocessing inactive intervals:\n"); DOUT << "\tprocessing inactive intervals:\n";
for (unsigned i = 0, e = inactive_.size(); i != e; ++i) { for (unsigned i = 0, e = inactive_.size(); i != e; ++i) {
LiveInterval *Interval = inactive_[i].first; LiveInterval *Interval = inactive_[i].first;
@@ -358,7 +356,7 @@ void RA::processInactiveIntervals(unsigned CurPoint)
IntervalPos = Interval->advanceTo(IntervalPos, CurPoint); IntervalPos = Interval->advanceTo(IntervalPos, CurPoint);
if (IntervalPos == Interval->end()) { // remove expired intervals. if (IntervalPos == Interval->end()) { // remove expired intervals.
DEBUG(std::cerr << "\t\tinterval " << *Interval << " expired\n"); DOUT << "\t\tinterval " << *Interval << " expired\n";
// Pop off the end of the list. // Pop off the end of the list.
inactive_[i] = inactive_.back(); inactive_[i] = inactive_.back();
@@ -366,7 +364,7 @@ void RA::processInactiveIntervals(unsigned CurPoint)
--i; --e; --i; --e;
} else if (IntervalPos->start <= CurPoint) { } else if (IntervalPos->start <= CurPoint) {
// move re-activated intervals in active list // move re-activated intervals in active list
DEBUG(std::cerr << "\t\tinterval " << *Interval << " active\n"); DOUT << "\t\tinterval " << *Interval << " active\n";
assert(MRegisterInfo::isVirtualRegister(reg) && assert(MRegisterInfo::isVirtualRegister(reg) &&
"Can only allocate virtual registers!"); "Can only allocate virtual registers!");
reg = vrm_->getPhys(reg); reg = vrm_->getPhys(reg);
@@ -416,7 +414,7 @@ static void RevertVectorIteratorsTo(RA::IntervalPtrs &V, unsigned Point) {
/// spill. /// spill.
void RA::assignRegOrStackSlotAtInterval(LiveInterval* cur) void RA::assignRegOrStackSlotAtInterval(LiveInterval* cur)
{ {
DEBUG(std::cerr << "\tallocating current interval: "); DOUT << "\tallocating current interval: ";
PhysRegTracker backupPrt = *prt_; PhysRegTracker backupPrt = *prt_;
@@ -516,14 +514,14 @@ void RA::assignRegOrStackSlotAtInterval(LiveInterval* cur)
// the free physical register and add this interval to the active // the free physical register and add this interval to the active
// list. // list.
if (physReg) { if (physReg) {
DEBUG(std::cerr << mri_->getName(physReg) << '\n'); DOUT << mri_->getName(physReg) << '\n';
vrm_->assignVirt2Phys(cur->reg, physReg); vrm_->assignVirt2Phys(cur->reg, physReg);
prt_->addRegUse(physReg); prt_->addRegUse(physReg);
active_.push_back(std::make_pair(cur, cur->begin())); active_.push_back(std::make_pair(cur, cur->begin()));
handled_.push_back(cur); handled_.push_back(cur);
return; return;
} }
DEBUG(std::cerr << "no free registers\n"); DOUT << "no free registers\n";
// Compile the spill weights into an array that is better for scanning. // Compile the spill weights into an array that is better for scanning.
std::vector<float> SpillWeights(mri_->getNumRegs(), 0.0); std::vector<float> SpillWeights(mri_->getNumRegs(), 0.0);
@@ -541,7 +539,7 @@ void RA::assignRegOrStackSlotAtInterval(LiveInterval* cur)
updateSpillWeights(SpillWeights, reg, i->first->weight, mri_); updateSpillWeights(SpillWeights, reg, i->first->weight, mri_);
} }
DEBUG(std::cerr << "\tassigning stack slot at interval "<< *cur << ":\n"); DOUT << "\tassigning stack slot at interval "<< *cur << ":\n";
// Find a register to spill. // Find a register to spill.
float minWeight = HUGE_VALF; float minWeight = HUGE_VALF;
@@ -575,14 +573,14 @@ void RA::assignRegOrStackSlotAtInterval(LiveInterval* cur)
minReg = *RC->allocation_order_begin(*mf_); minReg = *RC->allocation_order_begin(*mf_);
} }
DEBUG(std::cerr << "\t\tregister with min weight: " DOUT << "\t\tregister with min weight: "
<< mri_->getName(minReg) << " (" << minWeight << ")\n"); << mri_->getName(minReg) << " (" << minWeight << ")\n";
// if the current has the minimum weight, we need to spill it and // if the current has the minimum weight, we need to spill it and
// add any added intervals back to unhandled, and restart // add any added intervals back to unhandled, and restart
// linearscan. // linearscan.
if (cur->weight != HUGE_VALF && cur->weight <= minWeight) { if (cur->weight != HUGE_VALF && cur->weight <= minWeight) {
DEBUG(std::cerr << "\t\t\tspilling(c): " << *cur << '\n';); DOUT << "\t\t\tspilling(c): " << *cur << '\n';
int slot = vrm_->assignVirt2StackSlot(cur->reg); int slot = vrm_->assignVirt2StackSlot(cur->reg);
std::vector<LiveInterval*> added = std::vector<LiveInterval*> added =
li_->addIntervalsForSpills(*cur, *vrm_, slot); li_->addIntervalsForSpills(*cur, *vrm_, slot);
@@ -634,7 +632,7 @@ void RA::assignRegOrStackSlotAtInterval(LiveInterval* cur)
if (//MRegisterInfo::isVirtualRegister(reg) && if (//MRegisterInfo::isVirtualRegister(reg) &&
toSpill[vrm_->getPhys(reg)] && toSpill[vrm_->getPhys(reg)] &&
cur->overlapsFrom(*i->first, i->second)) { cur->overlapsFrom(*i->first, i->second)) {
DEBUG(std::cerr << "\t\t\tspilling(a): " << *i->first << '\n'); DOUT << "\t\t\tspilling(a): " << *i->first << '\n';
earliestStart = std::min(earliestStart, i->first->beginNumber()); earliestStart = std::min(earliestStart, i->first->beginNumber());
int slot = vrm_->assignVirt2StackSlot(i->first->reg); int slot = vrm_->assignVirt2StackSlot(i->first->reg);
std::vector<LiveInterval*> newIs = std::vector<LiveInterval*> newIs =
@@ -648,7 +646,7 @@ void RA::assignRegOrStackSlotAtInterval(LiveInterval* cur)
if (//MRegisterInfo::isVirtualRegister(reg) && if (//MRegisterInfo::isVirtualRegister(reg) &&
toSpill[vrm_->getPhys(reg)] && toSpill[vrm_->getPhys(reg)] &&
cur->overlapsFrom(*i->first, i->second-1)) { cur->overlapsFrom(*i->first, i->second-1)) {
DEBUG(std::cerr << "\t\t\tspilling(i): " << *i->first << '\n'); DOUT << "\t\t\tspilling(i): " << *i->first << '\n';
earliestStart = std::min(earliestStart, i->first->beginNumber()); earliestStart = std::min(earliestStart, i->first->beginNumber());
int slot = vrm_->assignVirt2StackSlot(reg); int slot = vrm_->assignVirt2StackSlot(reg);
std::vector<LiveInterval*> newIs = std::vector<LiveInterval*> newIs =
@@ -658,7 +656,7 @@ void RA::assignRegOrStackSlotAtInterval(LiveInterval* cur)
} }
} }
DEBUG(std::cerr << "\t\trolling back to: " << earliestStart << '\n'); DOUT << "\t\trolling back to: " << earliestStart << '\n';
// Scan handled in reverse order up to the earliest start of a // Scan handled in reverse order up to the earliest start of a
// spilled live interval and undo each one, restoring the state of // spilled live interval and undo each one, restoring the state of
@@ -668,7 +666,7 @@ void RA::assignRegOrStackSlotAtInterval(LiveInterval* cur)
// If this interval starts before t we are done. // If this interval starts before t we are done.
if (i->beginNumber() < earliestStart) if (i->beginNumber() < earliestStart)
break; break;
DEBUG(std::cerr << "\t\t\tundo changes for: " << *i << '\n'); DOUT << "\t\t\tundo changes for: " << *i << '\n';
handled_.pop_back(); handled_.pop_back();
// When undoing a live interval allocation we must know if it is active or // When undoing a live interval allocation we must know if it is active or
@@ -708,7 +706,7 @@ void RA::assignRegOrStackSlotAtInterval(LiveInterval* cur)
LiveInterval *HI = handled_[i]; LiveInterval *HI = handled_[i];
if (!HI->expiredAt(earliestStart) && if (!HI->expiredAt(earliestStart) &&
HI->expiredAt(cur->beginNumber())) { HI->expiredAt(cur->beginNumber())) {
DEBUG(std::cerr << "\t\t\tundo changes for: " << *HI << '\n'); DOUT << "\t\t\tundo changes for: " << *HI << '\n';
active_.push_back(std::make_pair(HI, HI->begin())); active_.push_back(std::make_pair(HI, HI->begin()));
assert(!MRegisterInfo::isPhysicalRegister(HI->reg)); assert(!MRegisterInfo::isPhysicalRegister(HI->reg));
prt_->addRegUse(vrm_->getPhys(HI->reg)); prt_->addRegUse(vrm_->getPhys(HI->reg));