mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 17:32:19 +00:00
Make the allocation of LiveIntervals explicit, rather than holding them in the r2iMap_ by value. This will prevent references to them from being invalidated
if the map is changed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54763 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
49bfdd63f4
commit
03857b29d8
@ -86,7 +86,7 @@ namespace llvm {
|
|||||||
typedef std::vector<MachineInstr*> Index2MiMap;
|
typedef std::vector<MachineInstr*> Index2MiMap;
|
||||||
Index2MiMap i2miMap_;
|
Index2MiMap i2miMap_;
|
||||||
|
|
||||||
typedef std::map<unsigned, LiveInterval> Reg2IntervalMap;
|
typedef std::map<unsigned, LiveInterval*> Reg2IntervalMap;
|
||||||
Reg2IntervalMap r2iMap_;
|
Reg2IntervalMap r2iMap_;
|
||||||
|
|
||||||
BitVector allocatableRegs_;
|
BitVector allocatableRegs_;
|
||||||
@ -141,13 +141,13 @@ namespace llvm {
|
|||||||
LiveInterval &getInterval(unsigned reg) {
|
LiveInterval &getInterval(unsigned reg) {
|
||||||
Reg2IntervalMap::iterator I = r2iMap_.find(reg);
|
Reg2IntervalMap::iterator I = r2iMap_.find(reg);
|
||||||
assert(I != r2iMap_.end() && "Interval does not exist for register");
|
assert(I != r2iMap_.end() && "Interval does not exist for register");
|
||||||
return I->second;
|
return *I->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
const LiveInterval &getInterval(unsigned reg) const {
|
const LiveInterval &getInterval(unsigned reg) const {
|
||||||
Reg2IntervalMap::const_iterator I = r2iMap_.find(reg);
|
Reg2IntervalMap::const_iterator I = r2iMap_.find(reg);
|
||||||
assert(I != r2iMap_.end() && "Interval does not exist for register");
|
assert(I != r2iMap_.end() && "Interval does not exist for register");
|
||||||
return I->second;
|
return *I->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasInterval(unsigned reg) const {
|
bool hasInterval(unsigned reg) const {
|
||||||
@ -237,7 +237,7 @@ namespace llvm {
|
|||||||
Reg2IntervalMap::iterator I = r2iMap_.find(reg);
|
Reg2IntervalMap::iterator I = r2iMap_.find(reg);
|
||||||
if (I == r2iMap_.end())
|
if (I == r2iMap_.end())
|
||||||
I = r2iMap_.insert(I, std::make_pair(reg, createInterval(reg)));
|
I = r2iMap_.insert(I, std::make_pair(reg, createInterval(reg)));
|
||||||
return I->second;
|
return *I->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// addLiveRangeToEndOfBlock - Given a register and an instruction,
|
/// addLiveRangeToEndOfBlock - Given a register and an instruction,
|
||||||
@ -248,7 +248,9 @@ namespace llvm {
|
|||||||
// Interval removal
|
// Interval removal
|
||||||
|
|
||||||
void removeInterval(unsigned Reg) {
|
void removeInterval(unsigned Reg) {
|
||||||
r2iMap_.erase(Reg);
|
std::map<unsigned, LiveInterval*>::iterator I = r2iMap_.find(Reg);
|
||||||
|
delete I->second;
|
||||||
|
r2iMap_.erase(I);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// isRemoved - returns true if the specified machine instr has been
|
/// isRemoved - returns true if the specified machine instr has been
|
||||||
@ -459,7 +461,7 @@ namespace llvm {
|
|||||||
std::map<unsigned,unsigned> &MBBVRegsMap,
|
std::map<unsigned,unsigned> &MBBVRegsMap,
|
||||||
std::vector<LiveInterval*> &NewLIs, float &SSWeight);
|
std::vector<LiveInterval*> &NewLIs, float &SSWeight);
|
||||||
|
|
||||||
static LiveInterval createInterval(unsigned Reg);
|
static LiveInterval* createInterval(unsigned Reg);
|
||||||
|
|
||||||
void printRegName(unsigned reg) const;
|
void printRegName(unsigned reg) const;
|
||||||
};
|
};
|
||||||
|
@ -71,6 +71,11 @@ void LiveIntervals::getAnalysisUsage(AnalysisUsage &AU) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LiveIntervals::releaseMemory() {
|
void LiveIntervals::releaseMemory() {
|
||||||
|
// Free the live intervals themselves.
|
||||||
|
for (std::map<unsigned, LiveInterval*>::iterator I = r2iMap_.begin(),
|
||||||
|
E = r2iMap_.end(); I != E; ++I)
|
||||||
|
delete I->second;
|
||||||
|
|
||||||
MBB2IdxMap.clear();
|
MBB2IdxMap.clear();
|
||||||
Idx2MBBMap.clear();
|
Idx2MBBMap.clear();
|
||||||
mi2iMap_.clear();
|
mi2iMap_.clear();
|
||||||
@ -130,8 +135,8 @@ void LiveIntervals::computeNumbering() {
|
|||||||
|
|
||||||
if (!OldI2MI.empty())
|
if (!OldI2MI.empty())
|
||||||
for (iterator OI = begin(), OE = end(); OI != OE; ++OI) {
|
for (iterator OI = begin(), OE = end(); OI != OE; ++OI) {
|
||||||
for (LiveInterval::iterator LI = OI->second.begin(),
|
for (LiveInterval::iterator LI = OI->second->begin(),
|
||||||
LE = OI->second.end(); LI != LE; ++LI) {
|
LE = OI->second->end(); LI != LE; ++LI) {
|
||||||
|
|
||||||
// Remap the start index of the live range to the corresponding new
|
// Remap the start index of the live range to the corresponding new
|
||||||
// number, or our best guess at what it _should_ correspond to if the
|
// number, or our best guess at what it _should_ correspond to if the
|
||||||
@ -174,8 +179,8 @@ void LiveIntervals::computeNumbering() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (LiveInterval::vni_iterator VNI = OI->second.vni_begin(),
|
for (LiveInterval::vni_iterator VNI = OI->second->vni_begin(),
|
||||||
VNE = OI->second.vni_end(); VNI != VNE; ++VNI) {
|
VNE = OI->second->vni_end(); VNI != VNE; ++VNI) {
|
||||||
VNInfo* vni = *VNI;
|
VNInfo* vni = *VNI;
|
||||||
|
|
||||||
// Remap the VNInfo def index, which works the same as the
|
// Remap the VNInfo def index, which works the same as the
|
||||||
@ -245,7 +250,7 @@ bool LiveIntervals::runOnMachineFunction(MachineFunction &fn) {
|
|||||||
|
|
||||||
DOUT << "********** INTERVALS **********\n";
|
DOUT << "********** INTERVALS **********\n";
|
||||||
for (iterator I = begin(), E = end(); I != E; ++I) {
|
for (iterator I = begin(), E = end(); I != E; ++I) {
|
||||||
I->second.print(DOUT, tri_);
|
I->second->print(DOUT, tri_);
|
||||||
DOUT << "\n";
|
DOUT << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,7 +263,7 @@ bool LiveIntervals::runOnMachineFunction(MachineFunction &fn) {
|
|||||||
void LiveIntervals::print(std::ostream &O, const Module* ) const {
|
void LiveIntervals::print(std::ostream &O, const Module* ) const {
|
||||||
O << "********** INTERVALS **********\n";
|
O << "********** INTERVALS **********\n";
|
||||||
for (const_iterator I = begin(), E = end(); I != E; ++I) {
|
for (const_iterator I = begin(), E = end(); I != E; ++I) {
|
||||||
I->second.print(O, tri_);
|
I->second->print(O, tri_);
|
||||||
O << "\n";
|
O << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -729,10 +734,10 @@ bool LiveIntervals::findLiveInMBBs(const LiveRange &LR,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LiveInterval LiveIntervals::createInterval(unsigned reg) {
|
LiveInterval* LiveIntervals::createInterval(unsigned reg) {
|
||||||
float Weight = TargetRegisterInfo::isPhysicalRegister(reg) ?
|
float Weight = TargetRegisterInfo::isPhysicalRegister(reg) ?
|
||||||
HUGE_VALF : 0.0F;
|
HUGE_VALF : 0.0F;
|
||||||
return LiveInterval(reg, Weight);
|
return new LiveInterval(reg, Weight);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getVNInfoSourceReg - Helper function that parses the specified VNInfo
|
/// getVNInfoSourceReg - Helper function that parses the specified VNInfo
|
||||||
|
@ -323,11 +323,11 @@ void RALinScan::initIntervalSets()
|
|||||||
"interval sets should be empty on initialization");
|
"interval sets should be empty on initialization");
|
||||||
|
|
||||||
for (LiveIntervals::iterator i = li_->begin(), e = li_->end(); i != e; ++i) {
|
for (LiveIntervals::iterator i = li_->begin(), e = li_->end(); i != e; ++i) {
|
||||||
if (TargetRegisterInfo::isPhysicalRegister(i->second.reg)) {
|
if (TargetRegisterInfo::isPhysicalRegister(i->second->reg)) {
|
||||||
reginfo_->setPhysRegUsed(i->second.reg);
|
reginfo_->setPhysRegUsed(i->second->reg);
|
||||||
fixed_.push_back(std::make_pair(&i->second, i->second.begin()));
|
fixed_.push_back(std::make_pair(i->second, i->second->begin()));
|
||||||
} else
|
} else
|
||||||
unhandled_.push(&i->second);
|
unhandled_.push(i->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,11 +385,11 @@ void RALinScan::linearScan()
|
|||||||
MachineFunction::iterator EntryMBB = mf_->begin();
|
MachineFunction::iterator EntryMBB = mf_->begin();
|
||||||
SmallVector<MachineBasicBlock*, 8> LiveInMBBs;
|
SmallVector<MachineBasicBlock*, 8> LiveInMBBs;
|
||||||
for (LiveIntervals::iterator i = li_->begin(), e = li_->end(); i != e; ++i) {
|
for (LiveIntervals::iterator i = li_->begin(), e = li_->end(); i != e; ++i) {
|
||||||
LiveInterval &cur = i->second;
|
LiveInterval &cur = *i->second;
|
||||||
unsigned Reg = 0;
|
unsigned Reg = 0;
|
||||||
bool isPhys = TargetRegisterInfo::isPhysicalRegister(cur.reg);
|
bool isPhys = TargetRegisterInfo::isPhysicalRegister(cur.reg);
|
||||||
if (isPhys)
|
if (isPhys)
|
||||||
Reg = i->second.reg;
|
Reg = cur.reg;
|
||||||
else if (vrm_->isAssignedReg(cur.reg))
|
else if (vrm_->isAssignedReg(cur.reg))
|
||||||
Reg = attemptTrivialCoalescing(cur, vrm_->getPhys(cur.reg));
|
Reg = attemptTrivialCoalescing(cur, vrm_->getPhys(cur.reg));
|
||||||
if (!Reg)
|
if (!Reg)
|
||||||
|
@ -2091,7 +2091,7 @@ bool SimpleRegisterCoalescing::runOnMachineFunction(MachineFunction &fn) {
|
|||||||
joinIntervals();
|
joinIntervals();
|
||||||
DOUT << "********** INTERVALS POST JOINING **********\n";
|
DOUT << "********** INTERVALS POST JOINING **********\n";
|
||||||
for (LiveIntervals::iterator I = li_->begin(), E = li_->end(); I != E; ++I){
|
for (LiveIntervals::iterator I = li_->begin(), E = li_->end(); I != E; ++I){
|
||||||
I->second.print(DOUT, tri_);
|
I->second->print(DOUT, tri_);
|
||||||
DOUT << "\n";
|
DOUT << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2164,7 +2164,7 @@ bool SimpleRegisterCoalescing::runOnMachineFunction(MachineFunction &fn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (LiveIntervals::iterator I = li_->begin(), E = li_->end(); I != E; ++I) {
|
for (LiveIntervals::iterator I = li_->begin(), E = li_->end(); I != E; ++I) {
|
||||||
LiveInterval &LI = I->second;
|
LiveInterval &LI = *I->second;
|
||||||
if (TargetRegisterInfo::isVirtualRegister(LI.reg)) {
|
if (TargetRegisterInfo::isVirtualRegister(LI.reg)) {
|
||||||
// If the live interval length is essentially zero, i.e. in every live
|
// If the live interval length is essentially zero, i.e. in every live
|
||||||
// range the use follows def immediately, it doesn't make sense to spill
|
// range the use follows def immediately, it doesn't make sense to spill
|
||||||
|
Loading…
x
Reference in New Issue
Block a user