forked from OSchip/llvm-project
Stop tracking unused registers in VirtRegMap.
The information was only used by the register allocator in StackSlotColoring. llvm-svn: 144482
This commit is contained in:
parent
6ddb767fb5
commit
38b3f312ca
|
@ -49,11 +49,8 @@ namespace {
|
||||||
class StackSlotColoring : public MachineFunctionPass {
|
class StackSlotColoring : public MachineFunctionPass {
|
||||||
bool ColorWithRegs;
|
bool ColorWithRegs;
|
||||||
LiveStacks* LS;
|
LiveStacks* LS;
|
||||||
VirtRegMap* VRM;
|
|
||||||
MachineFrameInfo *MFI;
|
MachineFrameInfo *MFI;
|
||||||
MachineRegisterInfo *MRI;
|
|
||||||
const TargetInstrInfo *TII;
|
const TargetInstrInfo *TII;
|
||||||
const TargetRegisterInfo *TRI;
|
|
||||||
const MachineLoopInfo *loopInfo;
|
const MachineLoopInfo *loopInfo;
|
||||||
|
|
||||||
// SSIntervals - Spill slot intervals.
|
// SSIntervals - Spill slot intervals.
|
||||||
|
@ -414,21 +411,16 @@ bool StackSlotColoring::runOnMachineFunction(MachineFunction &MF) {
|
||||||
});
|
});
|
||||||
|
|
||||||
MFI = MF.getFrameInfo();
|
MFI = MF.getFrameInfo();
|
||||||
MRI = &MF.getRegInfo();
|
|
||||||
TII = MF.getTarget().getInstrInfo();
|
TII = MF.getTarget().getInstrInfo();
|
||||||
TRI = MF.getTarget().getRegisterInfo();
|
|
||||||
LS = &getAnalysis<LiveStacks>();
|
LS = &getAnalysis<LiveStacks>();
|
||||||
VRM = &getAnalysis<VirtRegMap>();
|
|
||||||
loopInfo = &getAnalysis<MachineLoopInfo>();
|
loopInfo = &getAnalysis<MachineLoopInfo>();
|
||||||
|
|
||||||
bool Changed = false;
|
bool Changed = false;
|
||||||
|
|
||||||
unsigned NumSlots = LS->getNumIntervals();
|
unsigned NumSlots = LS->getNumIntervals();
|
||||||
if (NumSlots < 2) {
|
if (NumSlots == 0)
|
||||||
if (NumSlots == 0 || !VRM->HasUnusedRegisters())
|
// Nothing to do!
|
||||||
// Nothing to do!
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If there are calls to setjmp or sigsetjmp, don't perform stack slot
|
// If there are calls to setjmp or sigsetjmp, don't perform stack slot
|
||||||
// coloring. The stack could be modified before the longjmp is executed,
|
// coloring. The stack could be modified before the longjmp is executed,
|
||||||
|
|
|
@ -221,41 +221,6 @@ void VirtRegMap::RemoveMachineInstrFromMaps(MachineInstr *MI) {
|
||||||
EmergencySpillMap.erase(MI);
|
EmergencySpillMap.erase(MI);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// FindUnusedRegisters - Gather a list of allocatable registers that
|
|
||||||
/// have not been allocated to any virtual register.
|
|
||||||
bool VirtRegMap::FindUnusedRegisters(LiveIntervals* LIs) {
|
|
||||||
unsigned NumRegs = TRI->getNumRegs();
|
|
||||||
UnusedRegs.reset();
|
|
||||||
UnusedRegs.resize(NumRegs);
|
|
||||||
|
|
||||||
BitVector Used(NumRegs);
|
|
||||||
for (unsigned i = 0, e = MRI->getNumVirtRegs(); i != e; ++i) {
|
|
||||||
unsigned Reg = TargetRegisterInfo::index2VirtReg(i);
|
|
||||||
if (Virt2PhysMap[Reg] != (unsigned)VirtRegMap::NO_PHYS_REG)
|
|
||||||
Used.set(Virt2PhysMap[Reg]);
|
|
||||||
}
|
|
||||||
|
|
||||||
BitVector Allocatable = TRI->getAllocatableSet(*MF);
|
|
||||||
bool AnyUnused = false;
|
|
||||||
for (unsigned Reg = 1; Reg < NumRegs; ++Reg) {
|
|
||||||
if (Allocatable[Reg] && !Used[Reg] && !LIs->hasInterval(Reg)) {
|
|
||||||
bool ReallyUnused = true;
|
|
||||||
for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) {
|
|
||||||
if (Used[*AS] || LIs->hasInterval(*AS)) {
|
|
||||||
ReallyUnused = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ReallyUnused) {
|
|
||||||
AnyUnused = true;
|
|
||||||
UnusedRegs.set(Reg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return AnyUnused;
|
|
||||||
}
|
|
||||||
|
|
||||||
void VirtRegMap::rewrite(SlotIndexes *Indexes) {
|
void VirtRegMap::rewrite(SlotIndexes *Indexes) {
|
||||||
DEBUG(dbgs() << "********** REWRITE VIRTUAL REGISTERS **********\n"
|
DEBUG(dbgs() << "********** REWRITE VIRTUAL REGISTERS **********\n"
|
||||||
<< "********** Function: "
|
<< "********** Function: "
|
||||||
|
|
|
@ -132,9 +132,6 @@ namespace llvm {
|
||||||
/// the register is implicitly defined.
|
/// the register is implicitly defined.
|
||||||
BitVector ImplicitDefed;
|
BitVector ImplicitDefed;
|
||||||
|
|
||||||
/// UnusedRegs - A list of physical registers that have not been used.
|
|
||||||
BitVector UnusedRegs;
|
|
||||||
|
|
||||||
/// createSpillSlot - Allocate a spill slot for RC from MFI.
|
/// createSpillSlot - Allocate a spill slot for RC from MFI.
|
||||||
unsigned createSpillSlot(const TargetRegisterClass *RC);
|
unsigned createSpillSlot(const TargetRegisterClass *RC);
|
||||||
|
|
||||||
|
@ -475,39 +472,6 @@ namespace llvm {
|
||||||
/// the folded instruction map and spill point map.
|
/// the folded instruction map and spill point map.
|
||||||
void RemoveMachineInstrFromMaps(MachineInstr *MI);
|
void RemoveMachineInstrFromMaps(MachineInstr *MI);
|
||||||
|
|
||||||
/// FindUnusedRegisters - Gather a list of allocatable registers that
|
|
||||||
/// have not been allocated to any virtual register.
|
|
||||||
bool FindUnusedRegisters(LiveIntervals* LIs);
|
|
||||||
|
|
||||||
/// HasUnusedRegisters - Return true if there are any allocatable registers
|
|
||||||
/// that have not been allocated to any virtual register.
|
|
||||||
bool HasUnusedRegisters() const {
|
|
||||||
return !UnusedRegs.none();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// setRegisterUsed - Remember the physical register is now used.
|
|
||||||
void setRegisterUsed(unsigned Reg) {
|
|
||||||
UnusedRegs.reset(Reg);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// isRegisterUnused - Return true if the physical register has not been
|
|
||||||
/// used.
|
|
||||||
bool isRegisterUnused(unsigned Reg) const {
|
|
||||||
return UnusedRegs[Reg];
|
|
||||||
}
|
|
||||||
|
|
||||||
/// getFirstUnusedRegister - Return the first physical register that has not
|
|
||||||
/// been used.
|
|
||||||
unsigned getFirstUnusedRegister(const TargetRegisterClass *RC) {
|
|
||||||
int Reg = UnusedRegs.find_first();
|
|
||||||
while (Reg != -1) {
|
|
||||||
if (allocatableRCRegs[RC][Reg])
|
|
||||||
return (unsigned)Reg;
|
|
||||||
Reg = UnusedRegs.find_next(Reg);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// rewrite - Rewrite all instructions in MF to use only physical registers
|
/// rewrite - Rewrite all instructions in MF to use only physical registers
|
||||||
/// by mapping all virtual register operands to their assigned physical
|
/// by mapping all virtual register operands to their assigned physical
|
||||||
/// registers.
|
/// registers.
|
||||||
|
|
Loading…
Reference in New Issue