When optimizing for size, replace "addl $4, %esp" and "addl $8, %esp" following a call by one or two pops, respectively. We don't try to do it in general, but only when the stack adjustment immediately follows a call - which is the most common case. That allows taking a short-cut when trying to find a free register to pop into, instead of a full-blown liveness check. If the adjustment immediately follows a call, then every register the call clobbers but doesn't define should be dead at that point, and can be used. Differential Revision: http://reviews.llvm.org/D11749 llvm-svn: 244578
41 lines
1.1 KiB
LLVM
41 lines
1.1 KiB
LLVM
; RUN: llc < %s -mtriple=i686-windows | FileCheck %s -check-prefix=CHECK -check-prefix=NORMAL
|
|
; RUN: llc < %s -mtriple=i686-windows -mattr=call-reg-indirect | FileCheck %s -check-prefix=CHECK -check-prefix=SLM
|
|
|
|
declare void @foo(i32 %r)
|
|
|
|
define void @test(i32 %a, i32 %b) optsize {
|
|
; CHECK-LABEL: test:
|
|
; CHECK: movl [[EAX:%e..]], (%esp)
|
|
; CHECK-NEXT: pushl [[EAX]]
|
|
; CHECK-NEXT: calll
|
|
; CHECK-NEXT: addl $4, %esp
|
|
; CHECK: nop
|
|
; NORMAL: pushl (%esp)
|
|
; SLM: movl (%esp), [[RELOAD:%e..]]
|
|
; SLM-NEXT: pushl [[RELOAD]]
|
|
; CHECK: calll
|
|
; CHECK-NEXT: addl $4, %esp
|
|
%c = add i32 %a, %b
|
|
call void @foo(i32 %c)
|
|
call void asm sideeffect "nop", "~{ax},~{bx},~{cx},~{dx},~{bp},~{si},~{di}"()
|
|
call void @foo(i32 %c)
|
|
ret void
|
|
}
|
|
|
|
define void @test_min(i32 %a, i32 %b) minsize {
|
|
; CHECK-LABEL: test_min:
|
|
; CHECK: movl [[EAX:%e..]], (%esp)
|
|
; CHECK-NEXT: pushl [[EAX]]
|
|
; CHECK-NEXT: calll
|
|
; CHECK-NEXT: popl
|
|
; CHECK: nop
|
|
; CHECK: pushl (%esp)
|
|
; CHECK: calll
|
|
; CHECK-NEXT: popl
|
|
%c = add i32 %a, %b
|
|
call void @foo(i32 %c)
|
|
call void asm sideeffect "nop", "~{ax},~{bx},~{cx},~{dx},~{bp},~{si},~{di}"()
|
|
call void @foo(i32 %c)
|
|
ret void
|
|
}
|