diff options
Diffstat (limited to 'contrib/llvm-project/llvm/lib/CodeGen/SplitKit.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/CodeGen/SplitKit.cpp | 48 |
1 files changed, 16 insertions, 32 deletions
diff --git a/contrib/llvm-project/llvm/lib/CodeGen/SplitKit.cpp b/contrib/llvm-project/llvm/lib/CodeGen/SplitKit.cpp index c70620fd7532..7f9518e4c075 100644 --- a/contrib/llvm-project/llvm/lib/CodeGen/SplitKit.cpp +++ b/contrib/llvm-project/llvm/lib/CodeGen/SplitKit.cpp @@ -50,7 +50,6 @@ STATISTIC(NumFinished, "Number of splits finished"); STATISTIC(NumSimple, "Number of splits that were simple"); STATISTIC(NumCopies, "Number of copies inserted for splitting"); STATISTIC(NumRemats, "Number of rematerialized defs for splitting"); -STATISTIC(NumRepairs, "Number of invalid live ranges repaired"); //===----------------------------------------------------------------------===// // Last Insert Point Analysis @@ -160,7 +159,6 @@ void SplitAnalysis::clear() { UseBlocks.clear(); ThroughBlocks.clear(); CurLI = nullptr; - DidRepairRange = false; } /// analyzeUses - Count instructions, basic blocks, and loops using CurLI. @@ -188,20 +186,7 @@ void SplitAnalysis::analyzeUses() { UseSlots.end()); // Compute per-live block info. - if (!calcLiveBlockInfo()) { - // FIXME: calcLiveBlockInfo found inconsistencies in the live range. - // I am looking at you, RegisterCoalescer! - DidRepairRange = true; - ++NumRepairs; - LLVM_DEBUG(dbgs() << "*** Fixing inconsistent live interval! ***\n"); - const_cast<LiveIntervals&>(LIS) - .shrinkToUses(const_cast<LiveInterval*>(CurLI)); - UseBlocks.clear(); - ThroughBlocks.clear(); - bool fixed = calcLiveBlockInfo(); - (void)fixed; - assert(fixed && "Couldn't fix broken live interval"); - } + calcLiveBlockInfo(); LLVM_DEBUG(dbgs() << "Analyze counted " << UseSlots.size() << " instrs in " << UseBlocks.size() << " blocks, through " @@ -210,11 +195,11 @@ void SplitAnalysis::analyzeUses() { /// calcLiveBlockInfo - Fill the LiveBlocks array with information about blocks /// where CurLI is live. -bool SplitAnalysis::calcLiveBlockInfo() { +void SplitAnalysis::calcLiveBlockInfo() { ThroughBlocks.resize(MF.getNumBlockIDs()); NumThroughBlocks = NumGapBlocks = 0; if (CurLI->empty()) - return true; + return; LiveInterval::const_iterator LVI = CurLI->begin(); LiveInterval::const_iterator LVE = CurLI->end(); @@ -240,8 +225,7 @@ bool SplitAnalysis::calcLiveBlockInfo() { ThroughBlocks.set(BI.MBB->getNumber()); // The range shouldn't end mid-block if there are no uses. This shouldn't // happen. - if (LVI->end < Stop) - return false; + assert(LVI->end >= Stop && "range ends mid block with no uses"); } else { // This block has uses. Find the first and last uses in the block. BI.FirstInstr = *UseI; @@ -312,7 +296,6 @@ bool SplitAnalysis::calcLiveBlockInfo() { } assert(getNumLiveBlocks() == countLiveBlocks(CurLI) && "Bad block count"); - return true; } unsigned SplitAnalysis::countLiveBlocks(const LiveInterval *cli) const { @@ -529,19 +512,12 @@ SlotIndex SplitEditor::buildSingleSubRegCopy(Register FromReg, Register ToReg, | getInternalReadRegState(!FirstCopy), SubIdx) .addReg(FromReg, 0, SubIdx); - BumpPtrAllocator &Allocator = LIS.getVNInfoAllocator(); SlotIndexes &Indexes = *LIS.getSlotIndexes(); if (FirstCopy) { Def = Indexes.insertMachineInstrInMaps(*CopyMI, Late).getRegSlot(); } else { CopyMI->bundleWithPred(); } - LaneBitmask LaneMask = TRI.getSubRegIndexLaneMask(SubIdx); - DestLI.refineSubRanges(Allocator, LaneMask, - [Def, &Allocator](LiveInterval::SubRange &SR) { - SR.createDeadDef(Def, Allocator); - }, - Indexes, TRI); return Def; } @@ -549,11 +525,11 @@ SlotIndex SplitEditor::buildCopy(Register FromReg, Register ToReg, LaneBitmask LaneMask, MachineBasicBlock &MBB, MachineBasicBlock::iterator InsertBefore, bool Late, unsigned RegIdx) { const MCInstrDesc &Desc = TII.get(TargetOpcode::COPY); + SlotIndexes &Indexes = *LIS.getSlotIndexes(); if (LaneMask.all() || LaneMask == MRI.getMaxLaneMaskForVReg(FromReg)) { // The full vreg is copied. MachineInstr *CopyMI = BuildMI(MBB, InsertBefore, DebugLoc(), Desc, ToReg).addReg(FromReg); - SlotIndexes &Indexes = *LIS.getSlotIndexes(); return Indexes.insertMachineInstrInMaps(*CopyMI, Late).getRegSlot(); } @@ -567,18 +543,26 @@ SlotIndex SplitEditor::buildCopy(Register FromReg, Register ToReg, const TargetRegisterClass *RC = MRI.getRegClass(FromReg); assert(RC == MRI.getRegClass(ToReg) && "Should have same reg class"); - SmallVector<unsigned, 8> Indexes; + SmallVector<unsigned, 8> SubIndexes; // Abort if we cannot possibly implement the COPY with the given indexes. - if (!TRI.getCoveringSubRegIndexes(MRI, RC, LaneMask, Indexes)) + if (!TRI.getCoveringSubRegIndexes(MRI, RC, LaneMask, SubIndexes)) report_fatal_error("Impossible to implement partial COPY"); SlotIndex Def; - for (unsigned BestIdx : Indexes) { + for (unsigned BestIdx : SubIndexes) { Def = buildSingleSubRegCopy(FromReg, ToReg, MBB, InsertBefore, BestIdx, DestLI, Late, Def); } + BumpPtrAllocator &Allocator = LIS.getVNInfoAllocator(); + DestLI.refineSubRanges( + Allocator, LaneMask, + [Def, &Allocator](LiveInterval::SubRange &SR) { + SR.createDeadDef(Def, Allocator); + }, + Indexes, TRI); + return Def; } |