<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [Coroutines] mem2reg causes "cannot move instruction since its users are not dominated by CoroBegin""
   href="https://bugs.llvm.org/show_bug.cgi?id=36578">36578</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[Coroutines] mem2reg causes "cannot move instruction since its users are not dominated by CoroBegin"
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Transformation Utilities
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>superjoe30@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=19988" name="attach_19988" title="repro.ll">attachment 19988</a> <a href="attachment.cgi?id=19988&action=edit" title="repro.ll">[details]</a></span>
repro.ll

In my frontend, I'm careful to store args that are referenced in the Cleanup
block into the coro frame, to avoid tripping "cannot move instruction since its
users are not dominated by CoroBegin":


define internal fastcc i8* @amain(%Allocator*, i16*) unnamed_addr #0 !dbg !234
{
  store %Allocator* %0, %Allocator** %_anon3, align 8, !dbg !248

then later in the cleanup block:

  %28 = load %Allocator*, %Allocator** %_anon3, align 8, !dbg !248
  %29 = getelementptr inbounds %Allocator, %Allocator* %28, i32 0, i32 2, !dbg
!248
  %30 = load void (%Allocator*, %"[]u8"*)*, void (%Allocator*, %"[]u8"*)** %29,
align 8, !dbg !248
  %31 = call i8* @llvm.coro.free(token %6, i8* %12), !dbg !248

This works at -O0. But when mem2reg runs it replaces the load from _anon3 to %0
directly:

  call fastcc void %31(%Allocator* nonnull %0, %"[]u8"* byval nonnull %2) #6,
!dbg !191

This trips the corosplit assertion.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>