This patch corrects the handling of byval arguments for tailcall
authorArnold Schwaighofer <arnold.schwaighofer@gmail.com>
Sat, 12 Apr 2008 18:11:06 +0000 (18:11 +0000)
committerArnold Schwaighofer <arnold.schwaighofer@gmail.com>
Sat, 12 Apr 2008 18:11:06 +0000 (18:11 +0000)
commit4b5324ad2cbf774c9c6ed02ea0fcc864f2f5f885
treeb51fd2fb6c3ff45ccbbfb62170b614c9efd2489e
parent460a14e09c2af630fc1e840dcb3e0f725663067b
This patch corrects the handling of byval arguments for tailcall
optimized x86-64 (and x86) calls so that they work (... at least for
my test cases).

Should fix the following problems:

Problem 1: When i introduced the optimized handling of arguments for
tail called functions (using a sequence of copyto/copyfrom virtual
registers instead of always lowering to top of the stack) i did not
handle byval arguments correctly e.g they did not work at all :).

Problem 2: On x86-64 after the arguments of the tail called function
are moved to their registers (which include ESI/RSI etc), tail call
optimization performs byval lowering which causes xSI,xDI, xCX
registers to be overwritten. This is handled in this patch by moving
the arguments to virtual registers first and after the byval lowering
the arguments are moved from those virtual registers back to
RSI/RDI/RCX.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49584 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/X86/X86ISelLowering.cpp
lib/Target/X86/X86ISelLowering.h
test/CodeGen/X86/tailcallbyval.ll
test/CodeGen/X86/tailcallbyval64.ll [new file with mode: 0644]