Skip to content

Commit 38b3f31

Browse files
committed
Stop tracking unused registers in VirtRegMap.
The information was only used by the register allocator in StackSlotColoring. llvm-svn: 144482
1 parent 6ddb767 commit 38b3f31

File tree

3 files changed

+3
-82
lines changed

3 files changed

+3
-82
lines changed

llvm/lib/CodeGen/StackSlotColoring.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,8 @@ namespace {
4949
class StackSlotColoring : public MachineFunctionPass {
5050
bool ColorWithRegs;
5151
LiveStacks* LS;
52-
VirtRegMap* VRM;
5352
MachineFrameInfo *MFI;
54-
MachineRegisterInfo *MRI;
5553
const TargetInstrInfo *TII;
56-
const TargetRegisterInfo *TRI;
5754
const MachineLoopInfo *loopInfo;
5855

5956
// SSIntervals - Spill slot intervals.
@@ -414,21 +411,16 @@ bool StackSlotColoring::runOnMachineFunction(MachineFunction &MF) {
414411
});
415412

416413
MFI = MF.getFrameInfo();
417-
MRI = &MF.getRegInfo();
418414
TII = MF.getTarget().getInstrInfo();
419-
TRI = MF.getTarget().getRegisterInfo();
420415
LS = &getAnalysis<LiveStacks>();
421-
VRM = &getAnalysis<VirtRegMap>();
422416
loopInfo = &getAnalysis<MachineLoopInfo>();
423417

424418
bool Changed = false;
425419

426420
unsigned NumSlots = LS->getNumIntervals();
427-
if (NumSlots < 2) {
428-
if (NumSlots == 0 || !VRM->HasUnusedRegisters())
429-
// Nothing to do!
430-
return false;
431-
}
421+
if (NumSlots == 0)
422+
// Nothing to do!
423+
return false;
432424

433425
// If there are calls to setjmp or sigsetjmp, don't perform stack slot
434426
// coloring. The stack could be modified before the longjmp is executed,

llvm/lib/CodeGen/VirtRegMap.cpp

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -221,41 +221,6 @@ void VirtRegMap::RemoveMachineInstrFromMaps(MachineInstr *MI) {
221221
EmergencySpillMap.erase(MI);
222222
}
223223

224-
/// FindUnusedRegisters - Gather a list of allocatable registers that
225-
/// have not been allocated to any virtual register.
226-
bool VirtRegMap::FindUnusedRegisters(LiveIntervals* LIs) {
227-
unsigned NumRegs = TRI->getNumRegs();
228-
UnusedRegs.reset();
229-
UnusedRegs.resize(NumRegs);
230-
231-
BitVector Used(NumRegs);
232-
for (unsigned i = 0, e = MRI->getNumVirtRegs(); i != e; ++i) {
233-
unsigned Reg = TargetRegisterInfo::index2VirtReg(i);
234-
if (Virt2PhysMap[Reg] != (unsigned)VirtRegMap::NO_PHYS_REG)
235-
Used.set(Virt2PhysMap[Reg]);
236-
}
237-
238-
BitVector Allocatable = TRI->getAllocatableSet(*MF);
239-
bool AnyUnused = false;
240-
for (unsigned Reg = 1; Reg < NumRegs; ++Reg) {
241-
if (Allocatable[Reg] && !Used[Reg] && !LIs->hasInterval(Reg)) {
242-
bool ReallyUnused = true;
243-
for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) {
244-
if (Used[*AS] || LIs->hasInterval(*AS)) {
245-
ReallyUnused = false;
246-
break;
247-
}
248-
}
249-
if (ReallyUnused) {
250-
AnyUnused = true;
251-
UnusedRegs.set(Reg);
252-
}
253-
}
254-
}
255-
256-
return AnyUnused;
257-
}
258-
259224
void VirtRegMap::rewrite(SlotIndexes *Indexes) {
260225
DEBUG(dbgs() << "********** REWRITE VIRTUAL REGISTERS **********\n"
261226
<< "********** Function: "

llvm/lib/CodeGen/VirtRegMap.h

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,6 @@ namespace llvm {
132132
/// the register is implicitly defined.
133133
BitVector ImplicitDefed;
134134

135-
/// UnusedRegs - A list of physical registers that have not been used.
136-
BitVector UnusedRegs;
137-
138135
/// createSpillSlot - Allocate a spill slot for RC from MFI.
139136
unsigned createSpillSlot(const TargetRegisterClass *RC);
140137

@@ -475,39 +472,6 @@ namespace llvm {
475472
/// the folded instruction map and spill point map.
476473
void RemoveMachineInstrFromMaps(MachineInstr *MI);
477474

478-
/// FindUnusedRegisters - Gather a list of allocatable registers that
479-
/// have not been allocated to any virtual register.
480-
bool FindUnusedRegisters(LiveIntervals* LIs);
481-
482-
/// HasUnusedRegisters - Return true if there are any allocatable registers
483-
/// that have not been allocated to any virtual register.
484-
bool HasUnusedRegisters() const {
485-
return !UnusedRegs.none();
486-
}
487-
488-
/// setRegisterUsed - Remember the physical register is now used.
489-
void setRegisterUsed(unsigned Reg) {
490-
UnusedRegs.reset(Reg);
491-
}
492-
493-
/// isRegisterUnused - Return true if the physical register has not been
494-
/// used.
495-
bool isRegisterUnused(unsigned Reg) const {
496-
return UnusedRegs[Reg];
497-
}
498-
499-
/// getFirstUnusedRegister - Return the first physical register that has not
500-
/// been used.
501-
unsigned getFirstUnusedRegister(const TargetRegisterClass *RC) {
502-
int Reg = UnusedRegs.find_first();
503-
while (Reg != -1) {
504-
if (allocatableRCRegs[RC][Reg])
505-
return (unsigned)Reg;
506-
Reg = UnusedRegs.find_next(Reg);
507-
}
508-
return 0;
509-
}
510-
511475
/// rewrite - Rewrite all instructions in MF to use only physical registers
512476
/// by mapping all virtual register operands to their assigned physical
513477
/// registers.

0 commit comments

Comments
 (0)