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

    <tr>
        <th>Summary</th>
        <td>
            [RISCV] Expected<T> must be checked before access or destruction on LLJIT lookup
        </td>
    </tr>

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

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

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

<pre>
    The following exception appears when I do LLJIT's lookup on RISC-V only. x86 works fine.

```
Expected<T> must be checked before access or destruction.
Expected<T> value was in success state. (Note: Expected<T> values in success mode must still be checked prior to being destroyed).
```

Also, there is no such problem on 15.0.2 but there is on main branch. Localized that error appears somewhere here:

https://github.com/llvm/llvm-project/blob/8f104b806a2837f36463277f7d9162f53b595ebd/llvm/lib/ExecutionEngine/Orc/Core.cpp#L2263-L2264
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVUktv2zAM_jX2haghy--DD1maAR2CDdiK3vVgYi2KZUhyk-7Xj3ZbtMN6KSBRJCVSH8lPOv3U3w8IB2etu5jxCHhVOEXjRhDThMIHuAw4wh1oB_v9t7v7hDcBrHOneQJ69fPu1_bmgTT7lMG1reHi_CnAwYyYJew2YZsXWbOXtZq764Qqok6K7X1S7OA8hwgSQQ2oTqhJPTiPIJTCEMB50Biin9WCLPs4xaOwM8JFBDAjhPk5MkQRMYOEt99dxKTYwIdh_8ScncZnQCEaa9_DmrwhLNGRb2nWCso9UTLeZR_W-Sw3NriEbyEOSEWZAKNbfhson5MWz0sj8ypjGQc5x7dn5D4LQia9GNWQwd4pYc0fAhIHEQG9JzSvcwrujJc1chFU6nsEQ4xTWHz8K62jicMsM-XOZFj7-HrcEJ7f1B0ypXWSjvaQs1K2rBa8LZpDUZd1wZvm0Ogur_mhKmTVVSj1uzxmidtdUc3LsHbjkahAnh9ekdzSVDM1TQkv9pzXxc0iyxT7vK67vKxYV6W6L3RXdCKNJlrsk-rLQrKHpLr9b3ifoc3SzZXBL-xNZ2_7T_fFhEB0IaXq8qJLh57xQiFTshUtR6V5V-quLRvFRMOYyMvUCok2LGUknI94gTUF6VRQanrOOM9z2h0vyzqrtOSNUqLGWrdMdknJkDhgswVH5vwx9f0KSc7HQJfWhBjeLkUI5jji2rUlv5jj4HyvT7OP6fpxvwL_C4MvRe8">