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

    <tr>
        <th>Summary</th>
        <td>
            CoroSplit incompatibility with opaque pointers
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            opaque-pointers
      </td>
    </tr>

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

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

<pre>
    The test /home/npopov/repos/llvm-project/llvm/test/Transforms/Coroutines/coro-retcon-alloca.ll currently asserts when run with `-opaque-pointers=1`.

The problem is that with opaque pointers, the FramePtr is an Argument of the original function (rather than a bitcast of the argument), and the arguments get replaced with undef in https://github.com/llvm/llvm-project/blob/be5c3ca7fbaec90fff004af54d3cd5f6c30a9664/llvm/lib/Transforms/Coroutines/CoroSplit.cpp#L878. Then later, we try to replace that undef with the new frame pointer in https://github.com/llvm/llvm-project/blob/be5c3ca7fbaec90fff004af54d3cd5f6c30a9664/llvm/lib/Transforms/Coroutines/CoroSplit.cpp#L1013, which of course doesn't work.

I'm not really sure what the best way to fix this is. Ideally we'd replace the old frame pointer with the new one directly in the VMap, but the new frame pointer is currently only created after the function is cloned.

cc @ChuanqiXu9 @aeubanks 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzNVE1vnDAQ_TVwsRaxBnbhwCFNFClSK1VqVPU6NsPixtjEH9nuv--YTZNs1FbqrRLCzIxn_ObNM8IOp_5-QhbQB5bx28nOSItZ7GKf6MPhYj2tWj_Nm8XZ7yjDs0lLyqLl3oHxo3Vz2nltnY1BGUyGJGPjMEhrNqC1lVBozWR0Dk3QJwbeowueHSc0zEXDjipMLNuVG7vAY8TNYpUJ6HxW3WzJXWTlTVZend8JN0ESGmemPAsThHP-OZe95PJrCiK7dTDj5-DSZjDsyh3iTDCYHdewdeqgDGg2RiODsob4aB1QyKXahgETKkjwLxnwXCHjXToDzHDh9uyAgRGDGiQOZ2jRDDgyZdgUwkJdXRFJ9BwoFkUh7fxK7jvKhbYiLdjISsJ-FICyK8dxLMsaxqYeKjk0405WJXS7Xf2mjhJ_nVEyvixahUIuS8arj-2-Ldh9mogG4i-1diSFuBML9lc7Z7bP3ayNpcYNHtmYSP5F_X_e6LbcVmt3k5JTGqq00Xlkg0VvMr4nOVn3cKG5O3LPzNg0VxL0ifnokAoQGYkBka7REVamRvWDfKQ15Qt2N5y3H-l27Yc3LJLu9PCOtQtCrSFAyhE3lE58Jv_XT7Ak4CKGPxHv39wya-glCXAgGcIYVkHjq87TZk3nDBetSsmyuryeIphH9S12yQKMAsyDZ_nQV0NXdZAHFTT2L9wSRBruAkEJRebptzcyj073_ywM5X1cB9nUDa_yqRdcwLbdlUPTSV5VXbnf1UNTiW2LTQfNNtcgUPs-az5knL__o3CeNTe56nnJeVnxuuz4tm6Ltt63exLGWHVNyUkgdYkzKF0kNIV1h9z1KzARD56CWvngX4P0R1MHg7geSvUhhsm63qgHJfO1g36F_xP309oX">