[llvm-commits] X86 FastISel: Emit immediate call arguments locally to save stack size when compiling with -O0

Jakob Stoklund Olesen stoklund at 2pi.dk
Mon Aug 1 22:35:00 PDT 2011


On Aug 1, 2011, at 2:13 PM, Ivan Krasin wrote:

> this patch fixes the FastISel stack allocation strategy issue described here:
> http://lists.cs.uiuc.edu/pipermail/llvmdev/2011-July/041452.html
> The solution is to emit immediate int arguments just before the call
> (instead of spilling them on stack at the beginning of the function)

Thanks for working on this, Ivan.

I don't think there is any reason to special-case function arguments. It is just as bad when fast-isel hoists the immediate in 'x+1'.

I would prefer an approach that handled all immediates.

> --- test/CodeGen/X86/fast-isel-call-x86-64.ll	(revision 0)
> +++ test/CodeGen/X86/fast-isel-call-x86-64.ll	(revision 0)
> @@ -0,0 +1,59 @@
> +; RUN: llc < %s -O0 -fast-isel-abort -march=x86-64 | FileCheck %s
> +; This test should be merged with fast-isel-call.ll,
> +; but currently it's not possible because FastISel lacks
> +; of llvm.memcpy and llvm.memset.

Huh? None of the tests use memcpy or memset.

> +define i32 @test1() nounwind {
> +tak:
> +	%tmp = call i1 @foo()
> +	br i1 %tmp, label %BB1, label %BB2
> +BB1:
> +	ret i32 1
> +BB2:
> +	ret i32 0
> +; CHECK: test1:
> +; CHECK: callq
> +; CHECK-NEXT: testb	$1
> +}

Please add a comment describing what you are testing for here.

> +define void @test2(%struct.s* %d) nounwind {
> +  call void @foo2(%struct.s* byval %d )
> +  ret void
> +
> +; CHECK: test2:
> +; CHECK: subq	$24, %rsp
> +; CHECK: movq	(%rdi), %rax
> +; CHECK: movq	%rax, (%rsp)
> +; CHECK: movl	8(%rdi), %ecx
> +; CHECK: movl	%ecx, 8(%rsp)
> +; CHECK: callq	foo2
> +; CHECK: addq	$24, %rsp
> +; CHECK: ret
> +}

Same thing here. Also, is this related to your patch at all? Why must the byval argument be copied in that order and using exactly those temporary registers?

The last test looks good.

/jakob

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110801/4bec86ff/attachment.html>


More information about the llvm-commits mailing list