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

            Bug ID: 37876
           Summary: Shrink-wrap generates bad code in presence of stack
                    save/restore
           Product: libraries
           Version: 6.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Common Code Generator Code
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

Created attachment 20447
  --> https://bugs.llvm.org/attachment.cgi?id=20447&action=edit
Input LLVM IR file.

See attached file bug.ll and look at the function whose name ends with
"decompose".  Run "llc bug.ll" and look at the same function in bug.s.  The
shrink wrapper is setting up a prologue at %false4.  That pushes %rbp.  Then it
compiles the  "%3 = call i8* @llvm.stacksave()" into  "movq %rsp, %r8".  It
puts the epilogue at the end of block %end7, which is just "movq %rbp, %rsp;
popq %rbp".
But then it (eventually) branches to %if-next, which, at the end, has "call
void @llvm.stackrestore(i8* %3)", which restores the save above.  Then it
returns.  These two things are "movq %r8, %rsp; retq".  Unfortunately, %rsp was
saved *before* the push of %rbp, but restored after.  So %rsp is restore
incorrectly, no longer points to the return address,and the return goes to a
bogus place (the saved value of %rbp) and we get a SIGSEGV.  Running with
-enable-shrink-wrap=0 works around this.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to