From 181983055f7a543a83ad424bc24b3962af50274a Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Fri, 16 Dec 2016 23:55:37 +0000 Subject: BranchRelaxation: Recompute live-ins when splitting a block Factors out and reuses live-in computation code from BranchFolding. Differential Revision: https://reviews.llvm.org/D27558 llvm-svn: 290013 --- llvm/lib/CodeGen/BranchFolding.cpp | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) (limited to 'llvm/lib/CodeGen/BranchFolding.cpp') diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp index 9c30a14432b..a898e327ccc 100644 --- a/llvm/lib/CodeGen/BranchFolding.cpp +++ b/llvm/lib/CodeGen/BranchFolding.cpp @@ -349,37 +349,16 @@ static unsigned ComputeCommonTailLength(MachineBasicBlock *MBB1, return TailLen; } -void BranchFolder::computeLiveIns(MachineBasicBlock &MBB) { - if (!UpdateLiveIns) - return; - - LiveRegs.init(*TRI); - LiveRegs.addLiveOutsNoPristines(MBB); - for (MachineInstr &MI : make_range(MBB.rbegin(), MBB.rend())) - LiveRegs.stepBackward(MI); - - for (unsigned Reg : LiveRegs) { - // Skip the register if we are about to add one of its super registers. - bool ContainsSuperReg = false; - for (MCSuperRegIterator SReg(Reg, TRI); SReg.isValid(); ++SReg) { - if (LiveRegs.contains(*SReg)) { - ContainsSuperReg = true; - break; - } - } - if (ContainsSuperReg) - continue; - MBB.addLiveIn(Reg); - } -} - /// ReplaceTailWithBranchTo - Delete the instruction OldInst and everything /// after it, replacing it with an unconditional branch to NewDest. void BranchFolder::ReplaceTailWithBranchTo(MachineBasicBlock::iterator OldInst, MachineBasicBlock *NewDest) { TII->ReplaceTailWithBranchTo(OldInst, NewDest); - computeLiveIns(*NewDest); + if (UpdateLiveIns) { + NewDest->clearLiveIns(); + computeLiveIns(LiveRegs, *TRI, *NewDest); + } ++NumTailMerge; } @@ -417,7 +396,8 @@ MachineBasicBlock *BranchFolder::SplitMBBAt(MachineBasicBlock &CurMBB, // NewMBB inherits CurMBB's block frequency. MBBFreqInfo.setBlockFreq(NewMBB, MBBFreqInfo.getBlockFreq(&CurMBB)); - computeLiveIns(*NewMBB); + if (UpdateLiveIns) + computeLiveIns(LiveRegs, *TRI, *NewMBB); // Add the new block to the funclet. const auto &FuncletI = FuncletMembership.find(&CurMBB); -- cgit v1.2.3