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

    <tr>
        <th>Summary</th>
        <td>
            In a function with a `noundef` return value, replace `ret undef` with `unreachable`
        </td>
    </tr>

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

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

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

<pre>
    `noundef` on the return value means that

> If the value representation contains any undefined or poison bits, the behavior is undefined.

so if the function `ret`urns `undef`, that must be [`unreachable`](https://llvm.org/docs/LangRef.html#unreachable-instruction).

Alive2 confirms this is allowed: <https://alive2.llvm.org/ce/z/bW2DoM>
```
define i32 @src() noundef {
%start:
  ret i32 undef
}
=>
define i32 @tgt() noundef {
%start:
  assume i1 0
}
Transformation seems to be correct!
```

But seemingly it doesn't happen today: <https://llvm.godbolt.org/z/79a91o59q>

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUU02PmzAQ_TXmMtrI2AksBw7ZzUZaqb1UlXoeYABXxk7tIav011d8bDZp91IpcmR4M2_eGx7GaDpHVIrdk9gdEhy596GMtWce6iGpfHMpRSadH11DrcgkeAfcEwTiMTg4ox0JBkIXgXtkIQ9C7tdTv8BrO6MXWKBToEiOkY13UHvHaFwEdBeY-xtHDfgAJ2-id1AZjkI9zx0q6vFsfAATP7CbW7rowSxs7ejqmUFkMhCLTI7Bxen2rmLpigzDGBkqgkn_9DoQ1j1WlibQ7iDUY898ikLvhToKdbT2PGx86IQ6Nr6OQh2_oOu-UbvpebBC6ZsWD8ZFDuM8ilDF3bB7a86kJgtaE4bJOxMnaWitf6NG6D0I_XzPjXPN5maEmoQ6_hbqWP1QB_9V6JeVI5Prb74uboHRCsRWxlAL9ShUAetWQeRPa53aRcbAE-X8AKY9z4WLcwsqP7wv-HClvOfgjv-DA2McBwKTgvyL4XtAF1sfhuWLiUSTV37aWO1DoJqFSj_VvJxPI89FxnX2Aoah8RSdUDlDj6cTOWDf4OVTu2efO99U3vLq92R1XmCR-l3x6yo9aUrdFLrAhMo0yzOtdnmWJn3Ztk2qUTZVoZRsapTbPCuKnLTeZqiLLDGlkkpLlWqlpNqmm922ruoMJVW5zLApxFbSgMZel56YGEcqM5mneWKxIhvfsxvKCfRQjV0UW2lN5PhRxoYtla8O8CMdb4Z7QLiP922up5QEOlmsaY0SXHFz8T-RScZgy3sbO8P9WG1qP6yern8Pp-B_zgs8zpqmLM2y_gQAAP__nQ9qcQ">