diff options
Diffstat (limited to 'llvm/lib/CodeGen/RegisterCoalescer.cpp')
-rw-r--r-- | llvm/lib/CodeGen/RegisterCoalescer.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/RegisterCoalescer.cpp b/llvm/lib/CodeGen/RegisterCoalescer.cpp index 02164d9afbe..5c5f8dc528c 100644 --- a/llvm/lib/CodeGen/RegisterCoalescer.cpp +++ b/llvm/lib/CodeGen/RegisterCoalescer.cpp @@ -589,6 +589,13 @@ bool RegisterCoalescer::adjustCopiesBackFrom(const CoalescerPair &CP, // Do the same for the subregister segments. for (LiveInterval::SubRange &S : IntB.subranges()) { + // Check for SubRange Segments of the form [1234r,1234d:0) which can be + // removed to prevent creating bogus SubRange Segments. + LiveInterval::iterator SS = S.FindSegmentContaining(CopyIdx); + if (SS != S.end() && SlotIndex::isSameInstr(SS->start, SS->end)) { + S.removeSegment(*SS, true); + continue; + } VNInfo *SubBValNo = S.getVNInfoAt(CopyIdx); S.addSegment(LiveInterval::Segment(FillerStart, FillerEnd, SubBValNo)); VNInfo *SubValSNo = S.getVNInfoAt(AValNo->def.getPrevSlot()); @@ -605,11 +612,21 @@ bool RegisterCoalescer::adjustCopiesBackFrom(const CoalescerPair &CP, ValSEndInst->getOperand(UIdx).setIsKill(false); } - // Rewrite the copy. If the copy instruction was killing the destination - // register before the merge, find the last use and trim the live range. That - // will also add the isKill marker. + // Rewrite the copy. CopyMI->substituteRegister(IntA.reg, IntB.reg, 0, *TRI); - if (AS->end == CopyIdx) + // If the copy instruction was killing the destination register or any + // subrange before the merge trim the live range. + bool RecomputeLiveRange = AS->end == CopyIdx; + if (!RecomputeLiveRange) { + for (LiveInterval::SubRange &S : IntA.subranges()) { + LiveInterval::iterator SS = S.FindSegmentContaining(CopyUseIdx); + if (SS != S.end() && SS->end == CopyIdx) { + RecomputeLiveRange = true; + break; + } + } + } + if (RecomputeLiveRange) shrinkToUses(&IntA); ++numExtends; |