[llvm-bugs] [Bug 28068] New: MachineCodeSink Is Incorrect for SetJmp/LongJmp with Spill

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jun 9 13:18:51 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=28068

            Bug ID: 28068
           Summary: MachineCodeSink Is Incorrect for SetJmp/LongJmp with
                    Spill
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedbugs at nondot.org
          Reporter: wmoses at mit.edu
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Created attachment 16500
  --> https://llvm.org/bugs/attachment.cgi?id=16500&action=edit
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

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160609/0ea243f0/attachment.html>


More information about the llvm-bugs mailing list