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

    <tr>
        <th>Summary</th>
        <td>
            [mlir][spirv] Non-deterministic structurization in SPIR-V deserializer
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            mlir
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          IgWod-IMG
      </td>
    </tr>
</table>

<pre>
    Currently when the MLIR code is being structured inside the SPIR-V deserializer (run with: `mlir-translate --deserialize-spirv example.spv`) the order in which regions are structured is non-deterministic. This is because the `DenseMap` that holds block merge information (`blockMergeInfo`) uses a pointer to `Block` as a key. Then when `structurizeControlFlow` iterates over the map, the order elements are seen across different runs may vary, as pointer will have different addresses across different runs. So far this doesn't negatively affect supported shaders (or at least not to my knowledge), but it makes debugging harder.

Reported as discussed in #127639
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJxsk0-P4zYMxT-NfCEcKPK_-ODD7AxSBOgUxWzRnmmLttWRJUOUk2Y_fSFP2p0We_KB5POP1HvIbCZH1Inqi6heMtzi7EN3mf7wOr-8_pT1Xt-75y0EctHe4TaTgzgTvP58eYPBawLD0JNxE3AM2xC3QBqMY6Npb_z66-Ut_x00MQWD1nyjAEKdwubgZuIsiicQtVysCXkM6NhiJMjzT_05ryZcgf7CZbV04PUqailUu8v7oCmAcXCbzTBDoMl4x4CB_sPD4LzLNUUKi3GGoxkO8Nts-AN_wI0_cEUtX8gxveIqaglxxgizt5qht354h4XCRGDc6MOC0XiXlhG13KuvqXhxo38AbkwMCKs3LlKA6JP8l9SZtDHV3umeQMh9nFbU8h9s842evYvB27P1tzRgIgWMxOCvSW0mWHAV6vnTIcjSQi4-DkDkAIfgmUGbcaT0iBA2x7DgHa4Y7mka-V_Cm7EWZrzSp37UOhDvm_xI6gBfPYyYeAyD9sROqCaCowmjuZK9A44jDRF4W1cfImngGTUFTqfzATCCJeQIzsd0o-UO787fLOmJhGoTYr9FMBEWfCcGTf02TclxM6alD0I-Cfn0Rg91TIg8bMy7E0Go4qiaumgz3RW6LVrMqDs2pSxVUdSnbO6Ox5LGZmxKJN3W2MpTLYehaUfZy3Fo68x0SqpKKlUeT1UtT4eir4biWJdFo1RzxEqUkhY09mDtdTn4MGWGeaPuqE5V2WQWe7K8h0yp5HWhVIpb6FJ_3m8Ti1Jaw5G_K0QT7R7MfaB6EdWXPQmieoFf_u9m-G6bD1sa96PoZVuw3RzjyqJ4Euos1Hkycd76w-AXoc7p549Pvgb_Jw1RqPO-Cwt1fqxz7dTfAQAA___PQXE7">