diff options
-rw-r--r-- | lib/CodeGen/LiveRangeEdit.h | 2 | ||||
-rw-r--r-- | lib/CodeGen/SplitKit.cpp | 35 |
2 files changed, 20 insertions, 17 deletions
diff --git a/lib/CodeGen/LiveRangeEdit.h b/lib/CodeGen/LiveRangeEdit.h index d6ba256aee..3230a2e9fc 100644 --- a/lib/CodeGen/LiveRangeEdit.h +++ b/lib/CodeGen/LiveRangeEdit.h @@ -77,6 +77,8 @@ public: typedef SmallVectorImpl<LiveInterval*>::const_iterator iterator; iterator begin() const { return newRegs_.begin()+firstNew_; } iterator end() const { return newRegs_.end(); } + unsigned size() const { return newRegs_.size()-firstNew_; } + LiveInterval *get(unsigned idx) const { return newRegs_[idx-firstNew_]; } /// assignStackSlot - Ensure a stack slot is assigned to parent. /// @return the assigned stack slot number. diff --git a/lib/CodeGen/SplitKit.cpp b/lib/CodeGen/SplitKit.cpp index 446475e6d1..9307286a61 100644 --- a/lib/CodeGen/SplitKit.cpp +++ b/lib/CodeGen/SplitKit.cpp @@ -842,26 +842,27 @@ void SplitEditor::finish() { for (LiveRangeEdit::iterator I = edit_.begin(), E = edit_.end(); I != E; ++I) (*I)->RenumberValues(lis_); - // Now check if dupli was separated into multiple connected components. - ConnectedVNInfoEqClasses ConEQ(lis_); - if (unsigned NumComp = ConEQ.Classify(dupli_.getLI())) { - DEBUG(dbgs() << " Remainder has " << NumComp << " connected components: " - << *dupli_.getLI() << '\n'); - // Did the remainder break up? Create intervals for all the components. - if (NumComp > 1) { - SmallVector<LiveInterval*, 8> dups; - dups.push_back(dupli_.getLI()); - for (unsigned i = 1; i != NumComp; ++i) - dups.push_back(&edit_.create(mri_, lis_, vrm_)); - ConEQ.Distribute(&dups[0]); - // Rewrite uses to the new regs. - rewrite(dupli_.getLI()->reg); - } - } - // Rewrite instructions. rewrite(edit_.getReg()); + // Now check if any registers were separated into multiple components. + ConnectedVNInfoEqClasses ConEQ(lis_); + for (unsigned i = 0, e = edit_.size(); i != e; ++i) { + // Don't use iterators, they are invalidated by create() below. + LiveInterval *li = edit_.get(i); + unsigned NumComp = ConEQ.Classify(li); + if (NumComp <= 1) + continue; + DEBUG(dbgs() << " " << NumComp << " components: " << *li << '\n'); + SmallVector<LiveInterval*, 8> dups; + dups.push_back(li); + for (unsigned i = 1; i != NumComp; ++i) + dups.push_back(&edit_.create(mri_, lis_, vrm_)); + ConEQ.Distribute(&dups[0]); + // Rewrite uses to the new regs. + rewrite(li->reg); + } + // Calculate spill weight and allocation hints for new intervals. VirtRegAuxInfo vrai(vrm_.getMachineFunction(), lis_, sa_.loops_); for (LiveRangeEdit::iterator I = edit_.begin(), E = edit_.end(); I != E; ++I){ |