<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 - SJLJ EH broken on x86_64"
   href="https://bugs.llvm.org/show_bug.cgi?id=34720">34720</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>SJLJ EH broken on x86_64
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Backend: X86
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>martin@martin.st
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>While SJLJ EH was implemented for x86 in r271244 (as a fix for PR27749), it was
a bit incomplete (see <a href="https://reviews.llvm.org/D38251">https://reviews.llvm.org/D38251</a>), and even though the
code hints of supporting x86_64 (with separate codepaths for bits == 64), it
doesn't really work on x86_64. Some x86_64 specific issues are fixed by
<a href="https://reviews.llvm.org/D38254">https://reviews.llvm.org/D38254</a>, however two issues remain:

The __lsda field gets populated by setting the GCC_except_table* pointer into
the eax register, which truncates the pointer, since it gets matched by
MOV32ri64 for some reason. See line 91 in the diff in
<a href="https://reviews.llvm.org/D38254">https://reviews.llvm.org/D38254</a>, where the current code generated is this:

 ; CHECK-X64: movl $[[LSDA:GCC_except_table[0-9]+]], %eax

If mov64imm32 is removed from X86InstrCompiler.td, this pointer isn't truncated
any longer.


Secondly, the jmpq call encodes a an address to the jump table as the immediate
offset in the jmpq instruction, with the base register eax used as index in the
table.

If the address to the table doesn't fit in the 32 bit immediate, this fails.
This also is incorrect in case PIC code generation is requested (although that
isn't an issue on windows, but is an issue if you try to manually build an
x86_64 sjlj environment on e.g. linux).</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>