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

    <tr>
        <th>Summary</th>
        <td>
            Clang drops variable, keeps it when referenced by __asm__
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

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

<pre>
    Attached is the preprocessed source. In the bad file, at the line 11882, `pool` only contains garbage at the end. In the one with the workaround, which references `pool` via an empty `__asm__` block, `pool` has the correct value. Looking at the disassembly, with the workaround Clang is reserving more space on the stack and no other change.

I think Clang falsely thinks the variable isn't being used anymore and reuses the stack space without the `__asm__` block.

Tested with Clang 13, 15, 17 and 18 on OpenIndiana, and they all exhibit this behavior.
Could not reproduce this on any other OS.

[preprocessed-bad.txt](https://github.com/llvm/llvm-project/files/14977057/preprocessed-bad.txt)
[preprocessed-workaround.txt](https://github.com/llvm/llvm-project/files/14977059/preprocessed-workaround.txt)

See openindiana/oi-userland#16894

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyslE1v5CgQhn8NvpTSsvH3wYdMopYi7WoOs_eogIphmwYLcGf636-w8725rLQXWl1AvU9VvQZjNLMjmlj7g7X3Ba5J-zD9aRSGQnh1nW5TQqlJgYmQNMESaAleUoykIPo1SDrAg9v2BCp4MpYYvwNMW8gaR1BVw8BzkHXl4r1lXQne2StI7xIaF2HGIHCm11vk1FtS7wieTdLbn2cfThj86lRO96yN1BDoiQI5SfFj_otBQAd0XtI1xx8fMZ4fH_OWsF6evuBo3MuTPgSSCS5oVzrAH96fjJtfuZSJGCOdhb1u-v_GgjuLbs7NChQpXPLlsw8EcUGZi9nOx4TyBOgUOA8-aQogNbqZDqy8Z-Xtvj5A0sadXlI-oY1kr3tsh71gMCgsgYmO8T6BoKy35tGgu266WSTQGil-UN5hMr5f98q-6dAnlr8oJlJ7xTtPVecWVO229ptONeQCfy7kHpwy6HAzglNZ4QpoLdBvbYTJkiaCII0X48OL0J1fbW5Igs1iapW0n_MuV_PSp5-_PnGx9sdHR94IVIf0O7H2nvFBp7REVt8yfmT8OJukV3GQ_sz40drL68_NEvzfJBPjx2zeyPixasa-L9ue8eO32fn4vfq7D_4_iPErxBeRN5Zt_UUEfiFnXgdw9OZmjRQs5m-mrrphbPajhZpqNdYjFjRVfVVXfdMNfaGnQdTNULcDPcmq5WPFO1l2fOyE6MtR9E1hJl7ypmyqthzbivcHEqIZBfZ1qzpshpo1JZ3R2EMu7eDDXJgYV5qGoS-7wqIgG7cnh3OZzcQ4z69PmLZWiHWOrCmtiSm-Z0gmWZp276ngl_hm_-yyE9ESwSR41uTenwQF4govxi7WYKf_PI0NPI9jY_8nAAD__4l6th4">