<html>
    <head>
      <base href="http://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 --- - llvm.eh.unwind.init() is mostly a no-op, which subtly breaks libgcc_eh"
   href="http://llvm.org/bugs/show_bug.cgi?id=16298">16298</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>llvm.eh.unwind.init() is mostly a no-op, which subtly breaks libgcc_eh
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>tools
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>llc
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>mseaborn@chromium.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>If libgcc_eh is built with Clang + LLVM, it is subtly broken, because
__builtin_unwind_init() is compiled to the llvm.eh.unwind.init() intrinsic,
which is largely a no-op.

__builtin_unwind_init() is supposed to cause the function's prologue and
epilogue to save and restore all registers, but llvm.eh.unwind.init() doesn't
have this effect.  _Unwind_RaiseException(), _Unwind_Resume() etc. use other
GCC builtins to get the address of the register save area and modify the saved
register values, before calling __builtin_eh_return() to return and modify the
stack pointer at the same time.

This means that when libgcc_eh is compiled with LLVM, _Unwind_RaiseException(),
_Unwind_Resume() etc. won't necessarily restore all registers properly when
unwinding the stack to handle a C++ exception.  If they work, it's by luck.

It would be better if __builtin_unwind_init() were rejected at compile time,
rather than being accepted but not having the intended effect.

See also this PNaCl bug:
<a href="https://code.google.com/p/nativeclient/issues/detail?id=3486">https://code.google.com/p/nativeclient/issues/detail?id=3486</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>