<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/96885>96885</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [DebugInfo][JumpThreading] Missing debug location updates for branch instructions
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Apochens
      </td>
    </tr>
</table>

<pre>
    [**JumpThreading-L1041**](https://github.com/llvm/llvm-project/blob/8467cc61cef88818b5ac811176aa6fd7b22c7538/llvm/lib/Transforms/Scalar/JumpThreading.cpp#L1041)

The debug location of `BBTerm` does not be propagated to the new branch instruction, though the new branch instruction replaces `BBTerm`.

```cpp
 BranchInst::Create(BBTerm->getSuccessor(BestSucc), BBTerm->getIterator());
    ++NumFolds;
 BBTerm->eraseFromParent();
```

[**JumpThreading-L1660**](https://github.com/llvm/llvm-project/blob/8467cc61cef88818b5ac811176aa6fd7b22c7538/llvm/lib/Transforms/Scalar/JumpThreading.cpp#L1660)

The debug location of `Term` does not be propagated to the new branch instruction, though the new branch instruction replaces `Term`.

```cpp
      Instruction *Term = BB->getTerminator();
 BranchInst::Create(OnlyDest, Term->getIterator());
 ++NumFolds;
      Term->eraseFromParent();
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUlN1uqzgQx59muLEamQEMXHARmkXKar-k5gVsM3ysCEa26apvvzJJN8nq9Ki9OdKxEAjP-O__wM8jnRv7maiCrIbsEMnVD8ZW-8XogWYXKdO-bTHcA-5_Xc_LabAk23Hun36LeRpfApAdAIvB-8VBsgdsAJt-9MOqdtqcAZtpen1_PC3W_E3aAzZqMgqwKVKRay1iTV1RFHGhMqmLOI5zIaXo2lwh6jxLijudMaw7WTm7ztizA2xetJykBWweTO70sgAmV6sl8APw_eV-Goi1pNaeTUZLP5qZmY6B4HV9InsGwVlryLHZeKaILdYsspeeWuYN8wOxmf5hyspZD2ycnberDiKAz8wPZu2H7yQxS8skNbmH_Xb39kDwyxUq2GZYvekcZ-fDR072z5akJ8DiovAEyS89-ZdVa3LO2BAgt72H0vGZPeQdPVnpt7QtXEJSXzdijAHWgPUf67kxU-tuoZsEWemoseb8l7Q0-6vMe-J_9h9q-ggkIfjPAtJm9XMg_ViMPgnRNo53GoD7sJRBcmB1fYUjzIzzHR43AD6C8M95ejuQ88H55zD7iLFtfBGzqK2StkxKGVEV53GZFoiJiIaKJ2mWYq4SLkSq4jRNFMlCtUmHbSviOBor5JhygTkvszwWu6RQRanilDJeao4dpJzOcpx2gZmdsX00OrdSVYqiyKJJKprcpUdi-E1bEBBDO7XVBqpaewcpn0bn3U3Fj37aGu8hwHOcOxPoz-oH7iA7sN9H58a5_z9k69JKT451xn6DDRetdqq-fJI29-EYXKp7rfDfAAAA___adOId">