Index: llvm/trunk/lib/Target/X86/X86FrameLowering.cpp =================================================================== --- llvm/trunk/lib/Target/X86/X86FrameLowering.cpp +++ llvm/trunk/lib/Target/X86/X86FrameLowering.cpp @@ -185,7 +185,8 @@ } for (auto CS : AvailableRegs) - if (!Uses.count(CS) && CS != X86::RIP) + if (!Uses.count(CS) && CS != X86::RIP && CS != X86::RSP && + CS != X86::ESP) return CS; } } Index: llvm/trunk/test/CodeGen/X86/pr40289-64bit.ll =================================================================== --- llvm/trunk/test/CodeGen/X86/pr40289-64bit.ll +++ llvm/trunk/test/CodeGen/X86/pr40289-64bit.ll @@ -0,0 +1,10 @@ +; RUN: llc < %s -mtriple=x86_64-pc-windows-msvc | FileCheck %s + +define cc 92 < 9 x i64 > @clobber() { + %1 = alloca i64 + %2 = load volatile i64, i64* %1 + ret < 9 x i64 > undef + ; CHECK-LABEL: clobber: + ; CHECK-NOT: popq %rsp + ; CHECK: addq $8, %rsp +} Index: llvm/trunk/test/CodeGen/X86/pr40289.ll =================================================================== --- llvm/trunk/test/CodeGen/X86/pr40289.ll +++ llvm/trunk/test/CodeGen/X86/pr40289.ll @@ -0,0 +1,10 @@ +; RUN: llc < %s -mtriple=i686-pc-windows-msvc | FileCheck %s + +define < 3 x i32 > @clobber() { + %1 = alloca i32 + %2 = load volatile i32, i32* %1 + ret < 3 x i32 > undef + ; CHECK-LABEL: clobber: + ; CHECK-NOT: popl %esp + ; CHECK: addl $4, %esp +}