Eliminate MachineBasicBlock::const_livein_iterator and make

MachineBasicBlock::livein_iterator a const_iterator, because
clients shouldn't ever be using the iterator interface to
mutate the livein set.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101147 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman 2010-04-13 16:57:55 +00:00
parent 9e9aa44d1a
commit 81bf03eb5c
8 changed files with 14 additions and 16 deletions

View File

@ -201,12 +201,9 @@ public:
// Iteration support for live in sets. These sets are kept in sorted // Iteration support for live in sets. These sets are kept in sorted
// order by their register number. // order by their register number.
typedef std::vector<unsigned>::iterator livein_iterator; typedef std::vector<unsigned>::const_iterator livein_iterator;
typedef std::vector<unsigned>::const_iterator const_livein_iterator; livein_iterator livein_begin() const { return LiveIns.begin(); }
livein_iterator livein_begin() { return LiveIns.begin(); } livein_iterator livein_end() const { return LiveIns.end(); }
const_livein_iterator livein_begin() const { return LiveIns.begin(); }
livein_iterator livein_end() { return LiveIns.end(); }
const_livein_iterator livein_end() const { return LiveIns.end(); }
bool livein_empty() const { return LiveIns.empty(); } bool livein_empty() const { return LiveIns.empty(); }
/// getAlignment - Return alignment of the basic block. /// getAlignment - Return alignment of the basic block.

View File

@ -668,7 +668,7 @@ void LiveIntervals::computeIntervals() {
DEBUG(dbgs() << MBB->getName() << ":\n"); DEBUG(dbgs() << MBB->getName() << ":\n");
// Create intervals for live-ins to this BB first. // Create intervals for live-ins to this BB first.
for (MachineBasicBlock::const_livein_iterator LI = MBB->livein_begin(), for (MachineBasicBlock::livein_iterator LI = MBB->livein_begin(),
LE = MBB->livein_end(); LI != LE; ++LI) { LE = MBB->livein_end(); LI != LE; ++LI) {
handleLiveInRegister(MBB, MIIndex, getOrCreateInterval(*LI)); handleLiveInRegister(MBB, MIIndex, getOrCreateInterval(*LI));
// Multiple live-ins can alias the same register. // Multiple live-ins can alias the same register.

View File

@ -531,7 +531,7 @@ bool LiveVariables::runOnMachineFunction(MachineFunction &mf) {
// Mark live-in registers as live-in. // Mark live-in registers as live-in.
SmallVector<unsigned, 4> Defs; SmallVector<unsigned, 4> Defs;
for (MachineBasicBlock::const_livein_iterator II = MBB->livein_begin(), for (MachineBasicBlock::livein_iterator II = MBB->livein_begin(),
EE = MBB->livein_end(); II != EE; ++II) { EE = MBB->livein_end(); II != EE; ++II) {
assert(TargetRegisterInfo::isPhysicalRegister(*II) && assert(TargetRegisterInfo::isPhysicalRegister(*II) &&
"Cannot have a live-in virtual register!"); "Cannot have a live-in virtual register!");

View File

@ -191,7 +191,7 @@ void MachineBasicBlock::print(raw_ostream &OS) const {
const TargetRegisterInfo *TRI = MF->getTarget().getRegisterInfo(); const TargetRegisterInfo *TRI = MF->getTarget().getRegisterInfo();
if (!livein_empty()) { if (!livein_empty()) {
OS << " Live Ins:"; OS << " Live Ins:";
for (const_livein_iterator I = livein_begin(),E = livein_end(); I != E; ++I) for (livein_iterator I = livein_begin(),E = livein_end(); I != E; ++I)
OutputReg(OS, *I, TRI); OutputReg(OS, *I, TRI);
OS << '\n'; OS << '\n';
} }
@ -218,13 +218,14 @@ void MachineBasicBlock::print(raw_ostream &OS) const {
} }
void MachineBasicBlock::removeLiveIn(unsigned Reg) { void MachineBasicBlock::removeLiveIn(unsigned Reg) {
livein_iterator I = std::find(livein_begin(), livein_end(), Reg); std::vector<unsigned>::iterator I =
assert(I != livein_end() && "Not a live in!"); std::find(LiveIns.begin(), LiveIns.end(), Reg);
assert(I != LiveIns.end() && "Not a live in!");
LiveIns.erase(I); LiveIns.erase(I);
} }
bool MachineBasicBlock::isLiveIn(unsigned Reg) const { bool MachineBasicBlock::isLiveIn(unsigned Reg) const {
const_livein_iterator I = std::find(livein_begin(), livein_end(), Reg); livein_iterator I = std::find(livein_begin(), livein_end(), Reg);
return I != livein_end(); return I != livein_end();
} }

View File

@ -360,7 +360,7 @@ void MachineLICM::HoistRegionPostRA(MachineDomTreeNode *N) {
// Conservatively treat live-in's as an external def. // Conservatively treat live-in's as an external def.
// FIXME: That means a reload that're reused in successor block(s) will not // FIXME: That means a reload that're reused in successor block(s) will not
// be LICM'ed. // be LICM'ed.
for (MachineBasicBlock::const_livein_iterator I = BB->livein_begin(), for (MachineBasicBlock::livein_iterator I = BB->livein_begin(),
E = BB->livein_end(); I != E; ++I) { E = BB->livein_end(); I != E; ++I) {
unsigned Reg = *I; unsigned Reg = *I;
++PhysRegDefs[Reg]; ++PhysRegDefs[Reg];

View File

@ -470,7 +470,7 @@ MachineVerifier::visitMachineBasicBlockBefore(const MachineBasicBlock *MBB) {
} }
regsLive.clear(); regsLive.clear();
for (MachineBasicBlock::const_livein_iterator I = MBB->livein_begin(), for (MachineBasicBlock::livein_iterator I = MBB->livein_begin(),
E = MBB->livein_end(); I != E; ++I) { E = MBB->livein_end(); I != E; ++I) {
if (!TargetRegisterInfo::isPhysicalRegister(*I)) { if (!TargetRegisterInfo::isPhysicalRegister(*I)) {
report("MBB live-in list contains non-physical register", MBB); report("MBB live-in list contains non-physical register", MBB);

View File

@ -64,7 +64,7 @@ void RegScavenger::initRegState() {
return; return;
// Live-in registers are in use. // Live-in registers are in use.
for (MachineBasicBlock::const_livein_iterator I = MBB->livein_begin(), for (MachineBasicBlock::livein_iterator I = MBB->livein_begin(),
E = MBB->livein_end(); I != E; ++I) E = MBB->livein_end(); I != E; ++I)
setUsed(*I); setUsed(*I);

View File

@ -270,7 +270,7 @@ bool SSEDomainFixPass::Merge(DomainValue *A, DomainValue *B) {
void SSEDomainFixPass::enterBasicBlock() { void SSEDomainFixPass::enterBasicBlock() {
// Try to coalesce live-out registers from predecessors. // Try to coalesce live-out registers from predecessors.
for (MachineBasicBlock::const_livein_iterator i = MBB->livein_begin(), for (MachineBasicBlock::livein_iterator i = MBB->livein_begin(),
e = MBB->livein_end(); i != e; ++i) { e = MBB->livein_end(); i != e; ++i) {
int rx = RegIndex(*i); int rx = RegIndex(*i);
if (rx < 0) continue; if (rx < 0) continue;