forked from OSchip/llvm-project
X86: Use 'mov' instead of 'lea' in Win64 SEH prologues when possible
'mov' and 'lea' are equivalent when the displacement applied with 'lea' is zero. However, 'mov' should encode smaller. llvm-svn: 230269
This commit is contained in:
parent
b85e023b8b
commit
31d868b618
|
@ -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))
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue