[LLVMbugs] [Bug 5005] New: Win64 stack corruption when spilling callee saved XMM registers.

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Thu Sep 17 18:44:15 PDT 2009


http://llvm.org/bugs/show_bug.cgi?id=5005

           Summary: Win64 stack corruption when spilling callee saved XMM
                    registers.
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Backend: X86
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: llvm at laurentm.net
                CC: llvmbugs at cs.uiuc.edu


If callee saved XMM registers get spilled/restored in the prologue/epilogue,
the instruction walker that skips the push/pop instructions will fail to
recognize the movaps/movups instruction causing the stack update to be
incorrectly placed.

In X86RegisterInfo::emitPrologue:

  while (MBBI != MBB.end() &&
         (MBBI->getOpcode() == X86::PUSH32r ||
          MBBI->getOpcode() == X86::PUSH64r)) {
    PushedRegs = true;
    ++MBBI;

This code should probably skip X86::MOVAPSmr instructions.

Failing to recognize XMM saves/restores will produce the following incorrect
code:
        pushq   %rbp
        movq    %rsp, %rbp
        subq    $328, %rsp       # <=== Incorrect position
        movups  %xmm7, -80(%rbp)
        movups  %xmm6, -64(%rbp)
        pushq   %r15
        pushq   %r14
        pushq   %rsi
        pushq   %rdi
        pushq   %rbx

The correct code should be:
        pushq   %rbp
        movq    %rsp, %rbp
        movups  %xmm7, -80(%rbp)
        movups  %xmm6, -64(%rbp)
        pushq   %r15
        pushq   %r14
        pushq   %rsi
        pushq   %rdi
        pushq   %rbx
        subq    $328, %rsp       # <=== OK


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list