aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2008-08-13 21:49:13 +0000
committerOwen Anderson <resistor@mac.com>2008-08-13 21:49:13 +0000
commit348d1d86f8e4ad7f9acc6d2a66c34c54afaa2d9a (patch)
tree1f3e1c1c2dc8bd410854acf3f23f1f619a04f613 /lib/CodeGen
parent30e0563e413fb813ee84457a91bf60a2b6fa0302 (diff)
downloadexternal_llvm-348d1d86f8e4ad7f9acc6d2a66c34c54afaa2d9a.zip
external_llvm-348d1d86f8e4ad7f9acc6d2a66c34c54afaa2d9a.tar.gz
external_llvm-348d1d86f8e4ad7f9acc6d2a66c34c54afaa2d9a.tar.bz2
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
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/LiveIntervalAnalysis.cpp21
-rw-r--r--lib/CodeGen/RegAllocLinearScan.cpp12
-rw-r--r--lib/CodeGen/SimpleRegisterCoalescing.cpp4
3 files changed, 21 insertions, 16 deletions
diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp
index 4be06a3..db8a5a0 100644
--- a/lib/CodeGen/LiveIntervalAnalysis.cpp
+++ b/lib/CodeGen/LiveIntervalAnalysis.cpp
@@ -71,6 +71,11 @@ void LiveIntervals::getAnalysisUsage(AnalysisUsage &AU) const {
}
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();
Idx2MBBMap.clear();
mi2iMap_.clear();
@@ -130,8 +135,8 @@ void LiveIntervals::computeNumbering() {
if (!OldI2MI.empty())
for (iterator OI = begin(), OE = end(); OI != OE; ++OI) {
- for (LiveInterval::iterator LI = OI->second.begin(),
- LE = OI->second.end(); LI != LE; ++LI) {
+ for (LiveInterval::iterator LI = OI->second->begin(),
+ LE = OI->second->end(); LI != LE; ++LI) {
// 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
@@ -174,8 +179,8 @@ void LiveIntervals::computeNumbering() {
}
}
- for (LiveInterval::vni_iterator VNI = OI->second.vni_begin(),
- VNE = OI->second.vni_end(); VNI != VNE; ++VNI) {
+ for (LiveInterval::vni_iterator VNI = OI->second->vni_begin(),
+ VNE = OI->second->vni_end(); VNI != VNE; ++VNI) {
VNInfo* vni = *VNI;
// Remap the VNInfo def index, which works the same as the
@@ -245,7 +250,7 @@ bool LiveIntervals::runOnMachineFunction(MachineFunction &fn) {
DOUT << "********** INTERVALS **********\n";
for (iterator I = begin(), E = end(); I != E; ++I) {
- I->second.print(DOUT, tri_);
+ I->second->print(DOUT, tri_);
DOUT << "\n";
}
@@ -258,7 +263,7 @@ bool LiveIntervals::runOnMachineFunction(MachineFunction &fn) {
void LiveIntervals::print(std::ostream &O, const Module* ) const {
O << "********** INTERVALS **********\n";
for (const_iterator I = begin(), E = end(); I != E; ++I) {
- I->second.print(O, tri_);
+ I->second->print(O, tri_);
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) ?
HUGE_VALF : 0.0F;
- return LiveInterval(reg, Weight);
+ return new LiveInterval(reg, Weight);
}
/// getVNInfoSourceReg - Helper function that parses the specified VNInfo
diff --git a/lib/CodeGen/RegAllocLinearScan.cpp b/lib/CodeGen/RegAllocLinearScan.cpp
index ad830b2..9e5087b 100644
--- a/lib/CodeGen/RegAllocLinearScan.cpp
+++ b/lib/CodeGen/RegAllocLinearScan.cpp
@@ -323,11 +323,11 @@ void RALinScan::initIntervalSets()
"interval sets should be empty on initialization");
for (LiveIntervals::iterator i = li_->begin(), e = li_->end(); i != e; ++i) {
- if (TargetRegisterInfo::isPhysicalRegister(i->second.reg)) {
- reginfo_->setPhysRegUsed(i->second.reg);
- fixed_.push_back(std::make_pair(&i->second, i->second.begin()));
+ if (TargetRegisterInfo::isPhysicalRegister(i->second->reg)) {
+ reginfo_->setPhysRegUsed(i->second->reg);
+ fixed_.push_back(std::make_pair(i->second, i->second->begin()));
} else
- unhandled_.push(&i->second);
+ unhandled_.push(i->second);
}
}
@@ -385,11 +385,11 @@ void RALinScan::linearScan()
MachineFunction::iterator EntryMBB = mf_->begin();
SmallVector<MachineBasicBlock*, 8> LiveInMBBs;
for (LiveIntervals::iterator i = li_->begin(), e = li_->end(); i != e; ++i) {
- LiveInterval &cur = i->second;
+ LiveInterval &cur = *i->second;
unsigned Reg = 0;
bool isPhys = TargetRegisterInfo::isPhysicalRegister(cur.reg);
if (isPhys)
- Reg = i->second.reg;
+ Reg = cur.reg;
else if (vrm_->isAssignedReg(cur.reg))
Reg = attemptTrivialCoalescing(cur, vrm_->getPhys(cur.reg));
if (!Reg)
diff --git a/lib/CodeGen/SimpleRegisterCoalescing.cpp b/lib/CodeGen/SimpleRegisterCoalescing.cpp
index 933465b..b3e3409 100644
--- a/lib/CodeGen/SimpleRegisterCoalescing.cpp
+++ b/lib/CodeGen/SimpleRegisterCoalescing.cpp
@@ -2091,7 +2091,7 @@ bool SimpleRegisterCoalescing::runOnMachineFunction(MachineFunction &fn) {
joinIntervals();
DOUT << "********** INTERVALS POST JOINING **********\n";
for (LiveIntervals::iterator I = li_->begin(), E = li_->end(); I != E; ++I){
- I->second.print(DOUT, tri_);
+ I->second->print(DOUT, tri_);
DOUT << "\n";
}
}
@@ -2164,7 +2164,7 @@ bool SimpleRegisterCoalescing::runOnMachineFunction(MachineFunction &fn) {
}
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 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