<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 - Exception handling miscompile with -Oz on ARM"
   href="https://bugs.llvm.org/show_bug.cgi?id=35379">35379</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Exception handling miscompile with -Oz on ARM
          </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>Backend: ARM
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>srhines@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>chh@google.com, kongy.dev@gmail.com, kristof.beyls@arm.com, llvm-bugs@lists.llvm.org, peter.smith@linaro.org, pirama@google.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This is a matching bug for <a href="https://github.com/android-ndk/ndk/issues/573">https://github.com/android-ndk/ndk/issues/573</a> in the
Android NDK bug tracker. The issue can be seen with
<a href="https://github.com/rprichard/android-ndk-r16-miscompilation">https://github.com/rprichard/android-ndk-r16-miscompilation</a> which uses two
source files to create some C++ routines that throw exceptions. I think it is
easiest to say with Ryan's reduced example at <a href="https://godbolt.org/g/rJRr75">https://godbolt.org/g/rJRr75</a>.
This code is clearly squashing r10 on line 31 of the assembly code.

My suspicion here is an "optimization" to keep code size down that creates a
small amount of extra stack space by pushing unused registers. This would be
instead of doing this with an extra instruction that just subtracts from the
stack frame. The bug then is that the .save directive specifies those extra
registers, such that any unwinding here will unexpectedly clobber the register
with the temporary. Those registers are only there to create 4 or 8 bytes of
extra storage, and aren't normally restored in the normal code exit path.</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>