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

    <tr>
        <th>Summary</th>
        <td>
            [LLVM][Verifier] Crash in unreachable code on the token that is poisoned or undef.
        </td>
    </tr>

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

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

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

<pre>
    Godbolt link: https://godbolt.org/z/c1eK43ehY

Run `opt -passes=verify`

on the following test:
```llvm
define void @foo() gc "statepoint_example" personality ptr @P {
entry:
    br i1 true, label %label_1, label %label_2

label_1:
    ret void

label_2:
    %a = call noundef i32 @llvm.experimental.gc.result.i32(token poison)
    unreachable
}   

declare i32 @llvm.experimental.gc.result.i32(token)

declare ptr @P()
```

The bug was found using FuzzGen  (https://github.com/AzulSystems/FuzzGen)
Description:
The verifier checks that the token of “experimental_gc_result” intrinsic is some kind of call. Therefore, checks that the token is not poison or undef.

Possible fixes:
1. Disable verifier on this intrinsic;
2. Add exceptions for poison and undef tokens in the verifier.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVVE2PmzAQ_TVwGS0Ckw9y4JDddPfQrbRqq5V6iowZghsHI9tkk_z6DiYf7HZVqRFJsJl58-bNM4Uuj_mTLgutHCjZbIN0CbVzraWbgD3StRmeRtpsaHWir0jw6yTF-lcQr4J4Ofx-7xoIZrFuHdy13FokhNUejayOtD2O1A24GqHSSuk32WzAoXV9uSGGgv2l1H43bJVYyQZhr2UJwSSutA5YFrAFbAQEjFnHHbZaNm6NB75rFdImtGisbriS7gitM33iCwTz-wESG2eO15pAn8KATMCZjrIfQPECFYFP_c06-WSPjXu6hI0RDTrP-e849i6OEDmQWCC4UtDorqGGQaas59yrEOGBupE7Is1VtBGRQdvRRCiEhHB6iw1Q_9QuiXLD7RqDXNS8IEEGCvNVX25Ep0ShuMH_LHat8h7kovIwnA_THCf8pOkX3QbeuCUXULvQ2d4Hj93p9ES9kCLZBw9KV3dFJPSOFstTp34crcOdpdU56VpxhVYY2TpJaqSjgt6KEg2IGsXWkgW58z4c9NMVBF9YkMXB4mGswHoj1oMCl8crIKcZ2VgpQFqweoewldQEQfQTjIDKGay08U76vBwlNtqdpwbagB96NFbpRVsraXZQyQPaay9JBCtp-6HeWvIniiCvxIL07HMWwbIsAQ8CvSS94OZSlvfKe7N5Un2-p3jBjULMk9ksnc9SliVhmaflIl3w0EmnMA-m98_Pr9-C6YruXs8ptIIHw23dY40MCEKXCOeTP0jgFSHSAxksbyqEnVH5Pwzg3wzD311r9G8UjpbS2g57R0zn2TwJ67xIMkG8F4tFkcTxlE0mk1nMRDbPJqKsqmnoD6PtGyHaocxZzFi8YEnCWBYnUVoWWTWfsPk0nZUiLcjbuONSRf6Y0OswNLnnQF62_emR1tnbQ3oHyk2DeMHnnau1ycuCb7sG91LUoaece75_AEDau_s">