diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2011-02-04 19:33:11 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2011-02-04 19:33:11 +0000 |
commit | cb6404711b7fe6f583480adce8d7e9d5e4b99ae6 (patch) | |
tree | 29716725af4a8e0da2d14822dd1a6e572b63278a /lib/CodeGen/LiveIntervalAnalysis.cpp | |
parent | 9b3d24bf3d4663bfaf98eb97a94081e07a3f62da (diff) |
Add LiveIntervals::getLastSplitPoint().
A live range cannot be split everywhere in a basic block. A split must go before
the first terminator, and if the variable is live into a landing pad, the split
must happen before the call that can throw.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124894 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/LiveIntervalAnalysis.cpp')
-rw-r--r-- | lib/CodeGen/LiveIntervalAnalysis.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp index 000fc40ac4..32c553ff12 100644 --- a/lib/CodeGen/LiveIntervalAnalysis.cpp +++ b/lib/CodeGen/LiveIntervalAnalysis.cpp @@ -746,6 +746,28 @@ LiveInterval* LiveIntervals::dupInterval(LiveInterval *li) { // Register allocator hooks. // +MachineBasicBlock::iterator +LiveIntervals::getLastSplitPoint(const LiveInterval &li, + MachineBasicBlock *mbb) { + const MachineBasicBlock *lpad = mbb->getLandingPadSuccessor(); + + // If li is not live into a landing pad, we can insert spill code before the + // first terminator. + if (!lpad || !isLiveInToMBB(li, lpad)) + return mbb->getFirstTerminator(); + + // When there is a landing pad, spill code must go before the call instruction + // that can throw. + MachineBasicBlock::iterator I = mbb->end(), B = mbb->begin(); + while (I != B) { + --I; + if (I->getDesc().isCall()) + return I; + } + assert(0 && "Block with landing pad successor contains no call instruction"); + return mbb->getFirstTerminator(); +} + /// getReMatImplicitUse - If the remat definition MI has one (for now, we only /// allow one) virtual register operand, then its uses are implicitly using /// the register. Returns the virtual register. |