<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - IRPGO crashes calling getBBInfo on BB not in BBInfos"
   href="https://llvm.org/bugs/show_bug.cgi?id=27299">27299</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>IRPGO crashes calling getBBInfo on BB not in BBInfos
          </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>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>Miscellaneous Instrumentation passes
          </td>
        </tr>

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

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

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=16193" name="attach_16193" title="Minimal reproducer. Requires attached profdata.">attachment 16193</a> <a href="attachment.cgi?id=16193&action=edit" title="Minimal reproducer. Requires attached profdata.">[details]</a></span>
Minimal reproducer. Requires attached profdata.

When applying prof data to a function with 2 Basic Blocks where the 2nd is
unreachable, the IRPGO pass crashes. I believe this is due to the unreachable
block not being entered into BBInfos in CFGMST and then later having getBBInfo
called on it. I will attach a patch which applies one of a couple solutions.

The attached profdata has a few counts for the entry block.

Minimal repro shown below and attached:

declare void @foo(%footype*) unnamed_addr #1 align 2

define void @mainfunc(%footype* %this) unnamed_addr #1 align 2 {
entry:
  unreachable

foo.exit:                ; No predecessors!
  ret void
}</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>