aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/LiveIntervalAnalysis.cpp
diff options
context:
space:
mode:
authorAlkis Evlogimenos <alkis@evlogimenos.com>2003-12-24 15:44:53 +0000
committerAlkis Evlogimenos <alkis@evlogimenos.com>2003-12-24 15:44:53 +0000
commit7a40eaaceec0af76d5b97610f3d4e7a47a19d245 (patch)
tree40c5018a9aa94ce31cc9ef121748472babf07f70 /lib/CodeGen/LiveIntervalAnalysis.cpp
parent71f0a828a6691f079c7f9f6e7499c796c2ec9cd5 (diff)
Do a separate pass to compute spill weights because doing it inline
with live intervals was missing registers that were used before they were defined (in the arbitrary order live intervals numbers instructions). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10603 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/LiveIntervalAnalysis.cpp')
-rw-r--r--lib/CodeGen/LiveIntervalAnalysis.cpp37
1 files changed, 27 insertions, 10 deletions
diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp
index e4b134bc9d..b34a65bc64 100644
--- a/lib/CodeGen/LiveIntervalAnalysis.cpp
+++ b/lib/CodeGen/LiveIntervalAnalysis.cpp
@@ -106,6 +106,33 @@ bool LiveIntervals::runOnMachineFunction(MachineFunction &fn) {
computeIntervals();
+ // compute spill weights
+ const LoopInfo& loopInfo = getAnalysis<LoopInfo>();
+
+ for (MbbIndex2MbbMap::iterator
+ it = mbbi2mbbMap_.begin(), itEnd = mbbi2mbbMap_.end();
+ it != itEnd; ++it) {
+ MachineBasicBlock* mbb = it->second;
+
+ unsigned loopDepth = loopInfo.getLoopDepth(mbb->getBasicBlock());
+
+ for (MachineBasicBlock::iterator mi = mbb->begin(), miEnd = mbb->end();
+ mi != miEnd; ++mi) {
+ MachineInstr* instr = *mi;
+ for (int i = instr->getNumOperands() - 1; i >= 0; --i) {
+ MachineOperand& mop = instr->getOperand(i);
+
+ if (!mop.isVirtualRegister())
+ continue;
+
+ unsigned reg = mop.getAllocatedRegNum();
+ Reg2IntervalMap::iterator r2iit = r2iMap_.find(reg);
+ assert(r2iit != r2iMap_.end());
+ intervals_[r2iit->second].weight += pow(10.0F, loopDepth);
+ }
+ }
+ }
+
return true;
}
@@ -255,8 +282,6 @@ void LiveIntervals::computeIntervals()
{
DEBUG(std::cerr << "computing live intervals:\n");
- const LoopInfo& loopInfo = getAnalysis<LoopInfo>();
-
for (MbbIndex2MbbMap::iterator
it = mbbi2mbbMap_.begin(), itEnd = mbbi2mbbMap_.end();
it != itEnd; ++it) {
@@ -264,8 +289,6 @@ void LiveIntervals::computeIntervals()
DEBUG(std::cerr << "machine basic block: "
<< mbb->getBasicBlock()->getName() << "\n");
- unsigned loopDepth = loopInfo.getLoopDepth(mbb->getBasicBlock());
-
for (MachineBasicBlock::iterator mi = mbb->begin(), miEnd = mbb->end();
mi != miEnd; ++mi) {
MachineInstr* instr = *mi;
@@ -296,12 +319,6 @@ void LiveIntervals::computeIntervals()
else
handleVirtualRegisterDef(mbb, mi, reg);
}
-
- // update weights
- Reg2IntervalMap::iterator r2iit = r2iMap_.find(reg);
- if (r2iit != r2iMap_.end() &&
- reg >= MRegisterInfo::FirstVirtualRegister)
- intervals_[r2iit->second].weight += pow(10.0F, loopDepth);
}
}
}