<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 --- - MachineCodeSink Is Incorrect for SetJmp/LongJmp with Spill"
   href="https://llvm.org/bugs/show_bug.cgi?id=28068">28068</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>MachineCodeSink Is Incorrect for SetJmp/LongJmp with Spill
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Common Code Generator Code
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>wmoses@mit.edu
          </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=16500" name="attach_16500" title="Sample Case for the bug">attachment 16500</a> <a href="attachment.cgi?id=16500&action=edit" title="Sample Case for the bug">[details]</a></span>
Sample Case for the bug

I've come across a bug in MachineSink for
llvm.eh.sjlj.setjmp/llvm.eh.sjlj.longjmp. The bug occurs when an instruction is
sunk past a setjmp and the instruction later needs to be spilled.

The attached C code illustrates an example of this error when run with the
following flags to clang/opt/llc.

clang -O0 test.c -S -emit-llvm -o bad.ll
opt -mem2reg bad.ll -S -o bad2.ll
llc -O1 bad2.ll -o bad2.s
clang bad2.s -o bad2.o
./bad2.o

The expected output of the program should be four "0"'s, however the actual
output is two "0"'s followed by two "-1"'s.

In the attached example, MachineSink effectively moves x-- past the setjmp.
Because this value is spilled, the register value (as stored inside the stack)
is not restored to the value beforehand -- resulting in the decrement occuring</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>