<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 - [JumpThreading] Hangs when called with complex switch/state machines as generated by coroutines"
   href="https://bugs.llvm.org/show_bug.cgi?id=43720">43720</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[JumpThreading] Hangs when called with complex switch/state machines as generated by coroutines
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </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>Scalar Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>alex.davies@iinet.net.au
          </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=22690" name="attach_22690" title="A dirty workaround for the bug reported">attachment 22690</a> <a href="attachment.cgi?id=22690&action=edit" title="A dirty workaround for the bug reported">[details]</a></span>
A dirty workaround for the bug reported

In ProcessThreadableEdges, it is possible for PredsToFactor to be empty for its
call to "ThreadEdge".

This seemingly spins the whole thing in an infinite loop, where:

  if (PredBBs.size() == 1)
    PredBB = PredBBs[0];
  else {
    LLVM_DEBUG(dbgs() << "  Factoring out " << PredBBs.size()
                      << " common predecessors.\n");
    PredBB = SplitBlockPreds(BB, PredBBs, ".thr_comm");
  }

Writes "Factors out 0 common predecessors", which seems to be a nop, leading to
the same 0-edge being threaded again, and again, and again.

Perhaps someone who knows the code better than I can see if it is _always_ an
error to pass an empty PredBBs to ThreadEdge, in which case it should be
asserted in ThreadEdge, and/or how it's possible to end up with an empty
PredBBs in the first place.

Workaround attached.</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>