Is LiveVariables updated correctly when TII->RemoveBranch and TII->InsertBranch are called in the following piece of code?   <br>

<br>- MachineBasicBlock::updateTerminator() line 307 of MachineBasicBlock.cpp:<br>
  if (FBB) {<br>
      // The block has a non-fallthrough conditional branch. If one of its<br>
      // successors is its layout successor, rewrite it to a fallthrough<br>
      // conditional branch.<br>
      if (isLayoutSuccessor(TBB)) {<br>
        if (TII->ReverseBranchCondition(Cond))<br>
          return;<br>
        TII->RemoveBranch(*this);<br>
        TII->InsertBranch(*this, FBB, 0, Cond, dl);<br>
      } else if (isLayoutSuccessor(FBB)) {<br>
<br>
I am investigating an assertion (shown below) that is fired when I run llc with -march=mipsel -mcpu=4ke. It seems to me that the root cause of this assertion is the piece of code shown above that is called during PHI nodes elimination (llc exits normally if I add -disable-phi-elim-edge-splitting).<br>
<br>llc: llvm/lib/CodeGen/SplitKit.cpp:170:
 bool llvm::SplitAnalysis::calcLiveBlockInfo(): Assertion `BI.FirstUse 
>= Start' failed.<br>
<br><br>The following is the Machine IR and LiveVariables::ValInfo dump before and after PHI nodes elimination.<br><br>1. Before PHI nodes elimination.<br>-Machine IR:<br>BB#14: derived from LLVM BB %for.cond151.preheader<br>
    Predecessors according to CFG: BB#12 BB#13<br>    %vreg29<def> = PHI %vreg25, <BB#12>, %vreg28, <BB#13>; CPURegs:%vreg29,%vreg25,%vreg28<br>    %vreg30<def> = PHI %vreg26, <BB#12>, %vreg27, <BB#13>; CPURegs:%vreg30,%vreg26,%vreg27<br>
    BNE %vreg81<kill>, %ZERO, <BB#17>; CPURegs:%vreg81<br>    J <BB#15><br>    Successors according to CFG: BB#15 BB#17<br><br>BB#15: derived from LLVM BB %for.body156.preheader<br>    Predecessors according to CFG: BB#14<br>
<br>BB#17: derived from LLVM BB %for.end241<br>    Predecessors according to CFG: BB#14 BB#16<br><br>-vreg81's VarInfo:<br>  Alive in blocks: 5, 6, 7, 8, 10, 12, 13, 19, <br>  Killed by:<br>    #0: BNE %vreg81<kill>, %ZERO, <BB#17>; CPURegs:%vreg81<br>
<br>2. During PHI nodes elimination, critical edge BB#14-#17 is split and BB#20 is inserted. The two terminators of BB#14 (BNE and J ) are replaced with a conditional branch (BEQ) when MachineBasicBlock::updateTerminator() is called.<br>
 <br>3. After PHI nodes elimination.<br>- Machine IR:<br>BB#14: derived from LLVM BB %for.cond151.preheader<br>    Predecessors according to CFG: BB#13 BB#19<br>    %vreg29<def> = COPY %vreg180<kill>; CPURegs:%vreg29,%vreg180<br>
    %vreg30<def> = COPY %vreg181<kill>; CPURegs:%vreg30,%vreg181<br>    BEQ %vreg81, %ZERO, <BB#15>; CPURegs:%vreg81<br>    Successors according to CFG: BB#15 BB#20<br><br>BB#20: <br>    Predecessors according to CFG: BB#14<br>
    %vreg187<def> = COPY %vreg14<kill>; CPURegs:%vreg187,%vreg14<br>    %vreg188<def> = COPY %vreg29<kill>; CPURegs:%vreg188,%vreg29<br>    J <BB#17><br>    Successors according to CFG: BB#17<br>
<br>BB#15: derived from LLVM BB %for.body156.preheader<br>    Predecessors according to CFG: BB#14<br>    <br>BB#17: derived from LLVM BB %for.end241<br>    Predecessors according to CFG: BB#16 BB#20<br><br>- vreg81's VarInfo:<br>
  Alive in blocks: 5, 6, 7, 8, 10, 12, 13, 19, <br>  Killed by:<br>    #0: J <BB#17><br><br><br>As you can see, VarInfo vreg81 is killed by the unconditional jump instruction of BB#20 when it should be killed by the newly created conditional branch in BB#14 (BEQ). Is this a bug in updateTerminator() or is the back-end responsible for updating LiveVariables?  <br>
<br>