diff --git a/lib/Target/X86/X86FrameLowering.cpp b/lib/Target/X86/X86FrameLowering.cpp index 5657def8ce9..75fd4fdb434 100644 --- a/lib/Target/X86/X86FrameLowering.cpp +++ b/lib/Target/X86/X86FrameLowering.cpp @@ -863,8 +863,11 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF) const { int SEHFrameOffset = 0; if (IsWinEH && HasFP) { SEHFrameOffset = calculateSetFPREG(NumBytes); - addRegOffset(BuildMI(MBB, MBBI, DL, TII.get(X86::LEA64r), FramePtr), - StackPtr, false, SEHFrameOffset); + if (SEHFrameOffset) + addRegOffset(BuildMI(MBB, MBBI, DL, TII.get(X86::LEA64r), FramePtr), + StackPtr, false, SEHFrameOffset); + else + BuildMI(MBB, MBBI, DL, TII.get(X86::MOV64rr), FramePtr).addReg(StackPtr); if (NeedsWinEH) BuildMI(MBB, MBBI, DL, TII.get(X86::SEH_SetFrame)) diff --git a/test/CodeGen/X86/frameaddr.ll b/test/CodeGen/X86/frameaddr.ll index 27eac634078..5646196a586 100644 --- a/test/CodeGen/X86/frameaddr.ll +++ b/test/CodeGen/X86/frameaddr.ll @@ -18,7 +18,7 @@ entry: ; CHECK-32-NEXT: ret ; CHECK-W64-LABEL: test1 ; CHECK-W64: push -; CHECK-W64-NEXT: leaq (%rsp), %rbp +; CHECK-W64-NEXT: movq %rsp, %rbp ; CHECK-W64-NEXT: leaq (%rbp), %rax ; CHECK-W64-NEXT: pop ; CHECK-W64-NEXT: ret @@ -53,7 +53,7 @@ entry: ; CHECK-32-NEXT: ret ; CHECK-W64-LABEL: test2 ; CHECK-W64: push -; CHECK-W64-NEXT: leaq (%rsp), %rbp +; CHECK-W64-NEXT: movq %rsp, %rbp ; CHECK-W64-NEXT: leaq (%rbp), %rax ; CHECK-W64-NEXT: pop ; CHECK-W64-NEXT: ret diff --git a/test/CodeGen/X86/win64_frame.ll b/test/CodeGen/X86/win64_frame.ll index 535f8b4b059..ddba716d691 100644 --- a/test/CodeGen/X86/win64_frame.ll +++ b/test/CodeGen/X86/win64_frame.ll @@ -9,7 +9,7 @@ define i32 @f1(i32 %p1, i32 %p2, i32 %p3, i32 %p4, i32 %p5) "no-frame-pointer-el define void @f2(i32 %p, ...) "no-frame-pointer-elim"="true" { ; CHECK-LABEL: f2: ; CHECK: .seh_stackalloc 8 - ; CHECK: leaq (%rsp), %rbp + ; CHECK: movq %rsp, %rbp ; CHECK: .seh_setframe 5, 0 ; CHECK: movq %rdx, 32(%rbp) ; CHECK: leaq 32(%rbp), %rax @@ -20,7 +20,7 @@ define void @f2(i32 %p, ...) "no-frame-pointer-elim"="true" { define i8* @f3() "no-frame-pointer-elim"="true" { ; CHECK-LABEL: f3: - ; CHECK: leaq (%rsp), %rbp + ; CHECK: movq %rsp, %rbp ; CHECK: .seh_setframe 5, 0 ; CHECK: movq 8(%rbp), %rax %ra = call i8* @llvm.returnaddress(i32 0)