diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp --- a/llvm/lib/CodeGen/MachineBasicBlock.cpp +++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp @@ -961,9 +961,10 @@ if (UpdateLiveIns) { // Make sure we add any physregs we define in the block as liveins to the // new block. + MachineBasicBlock::iterator Prev(&MI); LiveRegs.init(*MF->getSubtarget().getRegisterInfo()); LiveRegs.addLiveOuts(*this); - for (auto I = rbegin(), E = SplitPoint.getReverse(); I != E; ++I) + for (auto I = rbegin(), E = Prev.getReverse(); I != E; ++I) LiveRegs.stepBackward(*I); } diff --git a/llvm/test/CodeGen/AMDGPU/si-lower-control-flow.mir b/llvm/test/CodeGen/AMDGPU/si-lower-control-flow.mir --- a/llvm/test/CodeGen/AMDGPU/si-lower-control-flow.mir +++ b/llvm/test/CodeGen/AMDGPU/si-lower-control-flow.mir @@ -233,7 +233,6 @@ ; GCN: $exec = S_OR_B64_term $exec, [[COPY3]], implicit-def $scc ; GCN: bb.3: ; GCN: successors: %bb.2(0x80000000) - ; GCN: liveins: $vgpr3 ; GCN: $vgpr3 = V_MOV_B32_e32 0, implicit $exec ; GCN: $sgpr4_sgpr5 = S_MOV_B64 32 ; GCN: bb.2: