Skip to content

Commit

Permalink
Use VirtRegMap's Virt2SplitMap to keep track of the original live ran…
Browse files Browse the repository at this point in the history
…ge before splitting.

All new virtual registers created for spilling or splitting point back to their original.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125980 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
stoklund committed Feb 18, 2011
1 parent 188a7e0 commit e324f6e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 7 additions & 1 deletion lib/CodeGen/LiveRangeEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,18 @@

using namespace llvm;

unsigned LiveRangeEdit::getOriginal(const VirtRegMap &vrm) const {
unsigned Orig = vrm.getPreSplitReg(getReg());
return Orig ? Orig : getReg();
}

LiveInterval &LiveRangeEdit::create(MachineRegisterInfo &mri,
LiveIntervals &lis,
VirtRegMap &vrm) {
const TargetRegisterClass *RC = mri.getRegClass(parent_.reg);
const TargetRegisterClass *RC = mri.getRegClass(getReg());
unsigned VReg = mri.createVirtualRegister(RC);
vrm.grow();
vrm.setIsSplitFromReg(VReg, getOriginal(vrm));
LiveInterval &li = lis.getOrCreateInterval(VReg);
newRegs_.push_back(&li);
return li;
Expand Down
4 changes: 4 additions & 0 deletions lib/CodeGen/LiveRangeEdit.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ class LiveRangeEdit {
LiveInterval &getParent() const { return parent_; }
unsigned getReg() const { return parent_.reg; }

/// getOriginal - Return the original virtual register that parent descends
/// from through splitting. The original was not created by splitting.
unsigned getOriginal(const VirtRegMap&) const;

/// Iterator for accessing the new registers added by this edit.
typedef SmallVectorImpl<LiveInterval*>::const_iterator iterator;
iterator begin() const { return newRegs_.begin()+firstNew_; }
Expand Down
2 changes: 1 addition & 1 deletion lib/CodeGen/VirtRegMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ namespace llvm {
}

/// @brief returns the live interval virtReg is split from.
unsigned getPreSplitReg(unsigned virtReg) {
unsigned getPreSplitReg(unsigned virtReg) const {
return Virt2SplitMap[virtReg];
}

Expand Down

0 comments on commit e324f6e

Please sign in to comment.