From e324f6e05ff7a157347edb48203db0250805f748 Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Fri, 18 Feb 2011 22:35:20 +0000 Subject: Use VirtRegMap's Virt2SplitMap to keep track of the original live range 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 --- lib/CodeGen/LiveRangeEdit.cpp | 8 +++++++- lib/CodeGen/LiveRangeEdit.h | 4 ++++ lib/CodeGen/VirtRegMap.h | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/CodeGen/LiveRangeEdit.cpp b/lib/CodeGen/LiveRangeEdit.cpp index 3c7d9f66e7..e23f382834 100644 --- a/lib/CodeGen/LiveRangeEdit.cpp +++ b/lib/CodeGen/LiveRangeEdit.cpp @@ -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; diff --git a/lib/CodeGen/LiveRangeEdit.h b/lib/CodeGen/LiveRangeEdit.h index 73f69ed639..832a12db4f 100644 --- a/lib/CodeGen/LiveRangeEdit.h +++ b/lib/CodeGen/LiveRangeEdit.h @@ -73,6 +73,10 @@ public: 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::const_iterator iterator; iterator begin() const { return newRegs_.begin()+firstNew_; } diff --git a/lib/CodeGen/VirtRegMap.h b/lib/CodeGen/VirtRegMap.h index a43ac5fc82..23101ce74f 100644 --- a/lib/CodeGen/VirtRegMap.h +++ b/lib/CodeGen/VirtRegMap.h @@ -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]; } -- cgit v1.2.3-18-g5258