From f16acbd2f983adaa285f6d38c8a4302ebfc64c19 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Wed, 6 Jul 2016 18:55:10 +0000 Subject: [PATCH] TailDuplicator: Remove live-in updating logic This logic was introduced in r157663 and does not make any sense to me. The motivating example in rdar://11538365 looks like this: This is the tail: BB#16: derived from LLVM BB %if.end68 Live Ins: %R0 %R4 %R5 Predecessors according to CFG: BB#15 BB#5 tBLXi pred:14, pred:%noreg, , %R0, , %LR, %SP, %SP t2B , pred:14, pred:%noreg Successors according to CFG: BB#20 This is the predBB: BB#5: Live Ins: %R5 Predecessors according to CFG: BB#4 %R4 = t2MOVi 0, pred:14, pred:%noreg, opt:%noreg t2B , pred:14, pred:%noreg Successors according to CFG: BB#16 However this is invalid machine code to begin with, if %R0 is live-in to BB#16 then it must be live-in to BB#5 as well if BB#5 does not define it. We should not need logic to retroactively fix broken machine code and in fact the example from r157663 passes cleanly with the code removed and I do not see any (newly) failing tests with the machine verifier enabled. Differential Revision: http://reviews.llvm.org/D22031 llvm-svn: 274655 --- llvm/include/llvm/CodeGen/TailDuplicator.h | 1 - llvm/lib/CodeGen/TailDuplicator.cpp | 18 ------------------ 2 files changed, 19 deletions(-) diff --git a/llvm/include/llvm/CodeGen/TailDuplicator.h b/llvm/include/llvm/CodeGen/TailDuplicator.h index 7c70fbfceca1..8e65199418a6 100644 --- a/llvm/include/llvm/CodeGen/TailDuplicator.h +++ b/llvm/include/llvm/CodeGen/TailDuplicator.h @@ -33,7 +33,6 @@ class TailDuplicator { const MachineBranchProbabilityInfo *MBPI; const MachineModuleInfo *MMI; MachineRegisterInfo *MRI; - std::unique_ptr RS; bool PreRegAlloc; // A list of virtual registers for which to update SSA form. diff --git a/llvm/lib/CodeGen/TailDuplicator.cpp b/llvm/lib/CodeGen/TailDuplicator.cpp index 05421ac64a45..3c122358fd0d 100644 --- a/llvm/lib/CodeGen/TailDuplicator.cpp +++ b/llvm/lib/CodeGen/TailDuplicator.cpp @@ -67,10 +67,6 @@ void TailDuplicator::initMF(MachineFunction &MF, const MachineModuleInfo *MMIin, assert(MBPI != nullptr && "Machine Branch Probability Info required"); PreRegAlloc = MRI->isSSA(); - RS.reset(); - - if (MRI->tracksLiveness() && TRI->trackLivenessAfterRegAlloc(MF)) - RS.reset(new RegScavenger()); } static void VerifyPHIs(MachineFunction &MF, bool CheckExtra) { @@ -770,20 +766,6 @@ bool TailDuplicator::tailDuplicate(MachineFunction &MF, bool IsSimple, // Remove PredBB's unconditional branch. TII->RemoveBranch(*PredBB); - if (RS && !TailBB->livein_empty()) { - // Update PredBB livein. - RS->enterBasicBlock(*PredBB); - if (!PredBB->empty()) - RS->forward(std::prev(PredBB->end())); - for (const auto &LI : TailBB->liveins()) { - if (!RS->isRegUsed(LI.PhysReg, false)) - // If a register is previously livein to the tail but it's not live - // at the end of predecessor BB, then it should be added to its - // livein list. - PredBB->addLiveIn(LI); - } - } - // Clone the contents of TailBB into PredBB. DenseMap LocalVRMap; SmallVector, 4> CopyInfos;