summaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2010-11-20 02:57:05 +0000
committerAndrew Trick <atrick@apple.com>2010-11-20 02:57:05 +0000
commit316df4bfe3db625a4394ff018c51d61f223aad86 (patch)
tree0d12189252ce49ff0b3e05cd609b69a44f0a2e8f /lib/CodeGen
parent13bdbb0544900643b4520f67cc48c6046c515c65 (diff)
downloadllvm-316df4bfe3db625a4394ff018c51d61f223aad86.tar.gz
llvm-316df4bfe3db625a4394ff018c51d61f223aad86.tar.bz2
llvm-316df4bfe3db625a4394ff018c51d61f223aad86.tar.xz
RABasic fix. Regalloc is responsible for updating block live ins.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119896 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/RegAllocBasic.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/CodeGen/RegAllocBasic.cpp b/lib/CodeGen/RegAllocBasic.cpp
index 605180f55c..76c243c743 100644
--- a/lib/CodeGen/RegAllocBasic.cpp
+++ b/lib/CodeGen/RegAllocBasic.cpp
@@ -107,6 +107,9 @@ public:
virtual bool runOnMachineFunction(MachineFunction &mf);
static char ID;
+
+private:
+ void addMBBLiveIns();
};
char RABasic::ID = 0;
@@ -465,6 +468,31 @@ unsigned RABasic::selectOrSplit(LiveInterval &lvr,
return 0;
}
+// Add newly allocated physical register to the MBB live in sets.
+void RABasic::addMBBLiveIns() {
+ SmallVector<MachineBasicBlock*, 8> liveInMBBs;
+ MachineBasicBlock &entryMBB = *mf_->begin();
+
+ for (unsigned preg = 0; preg < physReg2liu_.numRegs(); ++preg) {
+ LiveIntervalUnion &liu = physReg2liu_[preg];
+ for (LiveIntervalUnion::SegmentIter segI = liu.begin(), segE = liu.end();
+ segI != segE; ++segI) {
+ // Find the set of basic blocks which this range is live into...
+ if (lis_->findLiveInMBBs(segI->start, segI->end, liveInMBBs)) {
+ // And add the physreg for this interval to their live-in sets.
+ for (unsigned i = 0; i != liveInMBBs.size(); ++i) {
+ if (liveInMBBs[i] != &entryMBB) {
+ if (!liveInMBBs[i]->isLiveIn(preg)) {
+ liveInMBBs[i]->addLiveIn(preg);
+ }
+ }
+ }
+ liveInMBBs.clear();
+ }
+ }
+ }
+}
+
namespace llvm {
Spiller *createInlineSpiller(MachineFunctionPass &pass,
MachineFunction &mf,
@@ -496,6 +524,8 @@ bool RABasic::runOnMachineFunction(MachineFunction &mf) {
allocatePhysRegs();
+ addMBBLiveIns();
+
// Diagnostic output before rewriting
DEBUG(dbgs() << "Post alloc VirtRegMap:\n" << *vrm_ << "\n");