<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 - [NewPM][SEH] Regression due to lack of PruneEH"
   href="https://bugs.llvm.org/show_bug.cgi?id=51969">51969</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[NewPM][SEH] Regression due to lack of PruneEH
          </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>Linux
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Interprocedural Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>nikita.ppv@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>aeubanks@google.com, llvm-bugs@lists.llvm.org, rnk@google.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Under the legacy pass manager, a PruneEH pass ran prior to inlining, which both
propagated nounwind and converted invokes to calls. With the new pass manager
this has been removed, on the premise that these optimizations are already
covered by PostOrderFunctionAttrs and SimplifyCFG, and there's no particular
need to perform this optimization before inlining.

There is one case where doing this before inlining is important though: If a
call of a nounwind function is inlined, then the nounwind information is lost.

This is not a problem when using the Itanium exception ABI via landingpads,
because in that case nounwind can usually be trivially inferred again -- if the
landingpad doesn't resume (but traps for example) we can determine that it is
nounwind.

However, this is not true for the SEH exception handling mechanism. The problem
there is that cleanuppads also run for asynchronous exceptions (like longjmp)
so we can't simply trap within a cleanuppad. Instead we need to use a catch-all
catchswitch, but this comes with an "unwinds to caller". This "unwind" does not
violate "nounwind" because it applies only to asynchronous exceptions, but LLVM
doesn't know that.

So I think we need to either
a) make sure that nounwind information is used before it is inlined away, e.g.
by reintroducing PruneEH, or
b) have a way to to construct a "nounwind" catchswitch -- or maybe there is one
and I'm just not aware of it?

Here is an example of the problem: <a href="https://llvm.godbolt.org/z/M1PvnYf85">https://llvm.godbolt.org/z/M1PvnYf85</a></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>