Skip to content

Commit dc5b4c5

Browse files
author
Evan Cheng
committed
Replace std::vector<bool> with BitVector.
llvm-svn: 46104
1 parent d8583eb commit dc5b4c5

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

llvm/lib/CodeGen/RegAllocLocal.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,15 @@ namespace {
9191
// scavenged. If a virtual register has simply been rematerialized, there
9292
// is no reason to spill it to memory when we need the register back.
9393
//
94-
std::vector<bool> VirtRegModified;
94+
BitVector VirtRegModified;
9595

9696
void markVirtRegModified(unsigned Reg, bool Val = true) {
9797
assert(MRegisterInfo::isVirtualRegister(Reg) && "Illegal VirtReg!");
9898
Reg -= MRegisterInfo::FirstVirtualRegister;
99-
if (VirtRegModified.size() <= Reg) VirtRegModified.resize(Reg+1);
100-
VirtRegModified[Reg] = Val;
99+
if (Val)
100+
VirtRegModified.set(Reg);
101+
else
102+
VirtRegModified.reset(Reg);
101103
}
102104

103105
bool isVirtRegModified(unsigned Reg) const {
@@ -819,7 +821,9 @@ bool RALocal::runOnMachineFunction(MachineFunction &Fn) {
819821

820822
// initialize the virtual->physical register map to have a 'null'
821823
// mapping for all virtual registers
822-
Virt2PhysRegMap.grow(MF->getRegInfo().getLastVirtReg());
824+
unsigned LastVirtReg = MF->getRegInfo().getLastVirtReg();
825+
Virt2PhysRegMap.grow(LastVirtReg);
826+
VirtRegModified.resize(LastVirtReg-MRegisterInfo::FirstVirtualRegister);
823827

824828
// Loop over all of the basic blocks, eliminating virtual register references
825829
for (MachineFunction::iterator MBB = Fn.begin(), MBBe = Fn.end();

0 commit comments

Comments
 (0)