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: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]


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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to