<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=http://email.email.llvm.org/c/eJylVtuO2zYQ_Rr7hYigi-XLgx823m6xQB-KND9AiSOJWUpUSMqb7df3DGlvnM0GRVHA0MWcG8-cOVRj1cvxM_ngV9WdGEKY-WFVPuDX6zAsTdbaES_GnK-3D7OzX6gNeMXaqPmhaNV2U2-koupQV_JAB7krmk27r8qG1GFf75qupq5c5fer_C5dT9FZPA_kSISBhPZ-IdFp54PwRJNYlftmCcLoJzIvwo9hEF6P2kgn6Jv2gZRoqLOOVuWBy07Bt_nlF19TiaLdN7JstjuZo8ZGFbVqldzlu-1WbaiRMqc2r3blxeluCYN1DMknO8pJ_EHYBZ3FqjqZ9Jg5vdrk_Si1iQhVvyXPexmI_YT4jL08UCP2oizwT7HDpaxEmZclNvYxr_L8Fg14iFX98S89zkZ3L6eH31f1PQx3I7meBHLMMujGAKbpbJ_IY4kTdYthbJZ5ti5gTWmH3rwavclw54WxUy-kR-g7aQyuCftkj3t89RSEdPQab1Wevgd5RjkAJRUGaxDjJLhRyk6oKlxWfqwE92CvsX8IR2fipHbpB8F8sIvhvgpDvTQCTspm77Y2Xf90FqiMjAWoNIkbBFMh_jtiJ04wyhdBkxLLHNc14LjW-AzKo-6uAyWnIOxMTsKyWSZlkn9Y3MQeYcDVR2q-W1uKWHBLFdkZO97rqhQ5M7W-TzZZlt0al2-Ni1vjn-IH-_4CHOdBg6r3fEeonOuOsW6SZREa9TZl9Px11nT9PEQ-jgzRhS-OjORxbK1Cg5e-Z0nBigyMuPZisgEzO4MQcWgHedYYsNQQL1_8u-kwEVGJxGM_WcewS9cvnDf1YiBPAtZpS3jwYlwgHiCPVrDSrTQ3VLsE01NrFsXR3vT3fZY9Yvzl1H-i7pIT-5DgdWunEEnSiYjgNQrv1lCHhSUuGjgvEvPgW-QTnA8WIB-Y7RYUOVImkKSTccyEtyOxX9rdWZoFMZmzDcP8dcFUKfZtkihoQx84Btfjg7xAw1lCFNaIvWgNQTSfEQWe6IMjz-3B4iUkg5qJE2KQO0Nozqh0htDLdriaePa1E9RGWZGEe2ItYJ2QSkInQ-r461T5NMOxzRl2eUVIXgTfS977xyWSBIo_XijDa0BjwfjzMMfiUJOdGJfU7NckypJPqhNZxY6tdbG9UW-4CNvrNrtl8CPrauRkARUua1CWoQL-O1SHOlkSflASBpTtJfrZPnEdFxQZqdk-k3vFQ5FvnUZ7bmSD1fELU9ORTLUNLgreZY6u2mSsfUqqEiNplbammWoqaSHMMoGz53ImfXpkMYccy3hmJeZg0wHM9jgbozjD68UuUbSertsESlGfX4exekjgrNWxUofqINcp5HGU3z58XeTfclovzhz_81dCPNexw4e62teb9XCs864oqcp3u33VFc1e7mVFXVPIfb3tStqvjWzI-CPEaVWWEz2nTwM8Q5jW_78CfeRTOC-Lutjku2Kb7dr6UGxJKWSvq80W8FI82jlOZl2_dscYEszwWDT4-PDfFyVo0E9EsWBUGHQwdPz1QfQv58w6lnuMtf4DweYbvQ>53854</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            SimplifyCFG merges invokes with different operand bundles
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          max-quazan
      </td>
    </tr>
</table>

<pre>
    Tests: https://github.com/llvm/llvm-project/commit/1cd6454ade3953a9e9a71b4c832bed9857bf5ef2

Commit where the issue first seen (but likely smth similar existed before):
```
commit c8ba2b67a0adebd15dcda70766d4ebaa0ec03720
Author: Roman Lebedev <lebedev.ri@gmail.com>
Date:   Tue Feb 8 21:17:23 2022 +0300

    [SimplifyCFG] 'merge compatible invokes': fully support indirect invokes

    As long as *all* the invokes in the set are indirect,
    we can merge them, but don't merge direct invokes into the set,
    even though it would be legal to do.
```

Problem: when SimplifyCFG merges invokes, it may end up merging invokes with different operand bundles, turning things like
```
invoke1 [deopt(i32 0)]
...
invoke2 [deopt(i32 1)]
```
into
```
i32 phi = phi(0, 1)
invoke.merged [deopt(i32 phi )]
```

The comment in the related code suggests that it is not expected behavior, it says
```
  // Ignoring arguments, these `invoke`s must be identical,
  // including operand bundles.
```
In LangRef, the exact content of deopt bundles is left out of language scope and is up to runtime. In fact, some of these values may be required to be compile-time constants, and there is no clear way to express this requirement. Conservative approach requires to only do it when we are adamant that merging is legal, i.e. bundles are the same. But it seems that the actual implementation of invoke merging doesn't behave according to this logic.

I'm not 100% sure it's a bug in SimplifyCFG and not a lack of expressive power when we describe bundles, but just reading through comments, it looks like we didn't intend to do it. @LebedevRI as an author of this transform, do you think it's correct behavior?

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVVttu4zYQ_Rr7hVhBlixfHvyQdZoiQB-K7f4AJY4kbihRS1LOpl_fM6SceNMsigKGLubceObMoWqrXk5fyQe_Ku9EH8LED6viAb9Oh36us8YOeDHmcr19mpz9Rk3AK9YGzQ-bRu221VYqKo9VKY90lPtNvW0OZVGTOh6qfd1W1Bar_H6V36XrOTqL554cidCT0N7PJFrtfBCeaBSr4lDPQRj9ROZF-CH0wutBG-kE_dA-kBI1tdbRqjhy2Sn4Ll9-8TWVKJpDLYt6t5c5aqzVplKNkvt8v9upLdVS5tTk5b5YnO7m0FvHkHyxgxzFH4Rd0EWsyrNJj5nTq23eDVKbiFD5W_K8l4HYT4iv2MsD1eIgig3-2exxKUpR5EWBjX3Oyzy_RQMeYlV9_ksPk9Hty_nh91V1D8P9QK4jgRyTDLo2gGm82CfyWOJE7WwYm3marAtYU9qhN69G7zLceWHs2AnpEfpOGoNrwj7Z4x5fPQUhHb3GWxXntyDPKAegpMJgDWKcBTdK2RFVhWXl50pwD_Ya-6dwdCFOaueuF8wHOxvuqzDUSSPgpGz2YWvT9U9ngcrAWIBKo7hBMBXi3xA7c4JBvggalZinuK4Bx7XGZ1AedbctKDkGYSdyEpb1PCqT_MPsRvYIPa4-UvPD2lLEDbdUkZ2w44M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