'mov' and 'lea' are equivalent when the displacement applied with 'lea'
is zero. However, 'mov' should encode smaller.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230269
91177308-0d34-0410-b5e6-
96231b3b80d8
int SEHFrameOffset = 0;
if (IsWinEH && HasFP) {
SEHFrameOffset = calculateSetFPREG(NumBytes);
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))
if (NeedsWinEH)
BuildMI(MBB, MBBI, DL, TII.get(X86::SEH_SetFrame))
; CHECK-32-NEXT: ret
; CHECK-W64-LABEL: test1
; CHECK-W64: push
; 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
; CHECK-W64-NEXT: leaq (%rbp), %rax
; CHECK-W64-NEXT: pop
; CHECK-W64-NEXT: ret
; CHECK-32-NEXT: ret
; CHECK-W64-LABEL: test2
; CHECK-W64: push
; 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
; CHECK-W64-NEXT: leaq (%rbp), %rax
; CHECK-W64-NEXT: pop
; CHECK-W64-NEXT: ret
define void @f2(i32 %p, ...) "no-frame-pointer-elim"="true" {
; CHECK-LABEL: f2:
; CHECK: .seh_stackalloc 8
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
; CHECK: .seh_setframe 5, 0
; CHECK: movq %rdx, 32(%rbp)
; CHECK: leaq 32(%rbp), %rax
define i8* @f3() "no-frame-pointer-elim"="true" {
; CHECK-LABEL: f3:
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)
; CHECK: .seh_setframe 5, 0
; CHECK: movq 8(%rbp), %rax
%ra = call i8* @llvm.returnaddress(i32 0)