<div dir="ltr">Nico, this patch was never reviewed. Please, *do not* commit without review. This is not the first time this has happened. Revert immediately.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Jul 6, 2013 at 11:08 AM, Nico Rieck <span dir="ltr"><<a href="mailto:nico.rieck@gmail.com" target="_blank">nico.rieck@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: nrieck<br>
Date: Sat Jul 6 13:08:19 2013<br>
New Revision: 185763<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=185763&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=185763&view=rev</a><br>
Log:<br>
Proper va_arg/va_copy lowering on win64<br>
<br>
Modified:<br>
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp<br>
llvm/trunk/test/CodeGen/X86/win64_vararg.ll<br>
<br>
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=185763&r1=185762&r2=185763&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=185763&r1=185762&r2=185763&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)<br>
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Sat Jul 6 13:08:19 2013<br>
@@ -582,10 +582,12 @@ void X86TargetLowering::resetOperationAc<br>
// VASTART needs to be custom lowered to use the VarArgsFrameIndex<br>
setOperationAction(ISD::VASTART , MVT::Other, Custom);<br>
setOperationAction(ISD::VAEND , MVT::Other, Expand);<br>
- if (Subtarget->is64Bit()) {<br>
+ if (Subtarget->is64Bit() && !Subtarget->isTargetWin64()) {<br>
+ // TargetInfo::X86_64ABIBuiltinVaList<br>
setOperationAction(ISD::VAARG , MVT::Other, Custom);<br>
setOperationAction(ISD::VACOPY , MVT::Other, Custom);<br>
} else {<br>
+ // TargetInfo::CharPtrBuiltinVaList<br>
setOperationAction(ISD::VAARG , MVT::Other, Expand);<br>
setOperationAction(ISD::VACOPY , MVT::Other, Expand);<br>
}<br>
<br>
Modified: llvm/trunk/test/CodeGen/X86/win64_vararg.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/win64_vararg.ll?rev=185763&r1=185762&r2=185763&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/win64_vararg.ll?rev=185763&r1=185762&r2=185763&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/CodeGen/X86/win64_vararg.ll (original)<br>
+++ llvm/trunk/test/CodeGen/X86/win64_vararg.ll Sat Jul 6 13:08:19 2013<br>
@@ -18,6 +18,7 @@ entry:<br>
}<br>
<br>
declare void @llvm.va_start(i8*) nounwind<br>
+declare void @llvm.va_copy(i8*, i8*) nounwind<br>
<br>
; CHECK: f5:<br>
; CHECK: pushq<br>
@@ -51,3 +52,61 @@ entry:<br>
call void @llvm.va_start(i8* %ap1)<br>
ret i8* %ap1<br>
}<br>
+<br>
+; WinX86_64 uses char* for va_list. Verify that the correct amount of bytes<br>
+; are copied using va_copy.<br>
+; CHECK: copy4:<br>
+; CHECK: subq $16<br>
+; CHECK: leaq 56(%rsp), [[REGISTER:%[a-z]+]]<br>
+; CHECK: movq [[REGISTER]], 8(%rsp)<br>
+; CHECK: movq [[REGISTER]], (%rsp)<br>
+; CHECK: addq $16<br>
+; CHECK: ret<br>
+define void @copy4(i64 %a0, i64 %a1, i64 %a2, i64 %a3, ...) nounwind {<br>
+entry:<br>
+ %ap = alloca i8*, align 8<br>
+ %cp = alloca i8*, align 8<br>
+ %ap1 = bitcast i8** %ap to i8*<br>
+ %cp1 = bitcast i8** %cp to i8*<br>
+ call void @llvm.va_start(i8* %ap1)<br>
+ call void @llvm.va_copy(i8* %cp1, i8* %ap1)<br>
+ ret void<br>
+}<br>
+<br>
+; CHECK: copy1:<br>
+; CHECK: subq $16<br>
+; CHECK: leaq 32(%rsp), [[REGISTER:%[a-z]+]]<br>
+; CHECK: movq [[REGISTER]], 8(%rsp)<br>
+; CHECK: movq [[REGISTER]], (%rsp)<br>
+; CHECK: addq $16<br>
+; CHECK: ret<br>
+define void @copy1(i64 %a0, ...) nounwind {<br>
+entry:<br>
+ %ap = alloca i8*, align 8<br>
+ %cp = alloca i8*, align 8<br>
+ %ap1 = bitcast i8** %ap to i8*<br>
+ %cp1 = bitcast i8** %cp to i8*<br>
+ call void @llvm.va_start(i8* %ap1)<br>
+ call void @llvm.va_copy(i8* %cp1, i8* %ap1)<br>
+ ret void<br>
+}<br>
+<br>
+; CHECK: arg4:<br>
+; CHECK: pushq<br>
+; va_start:<br>
+; CHECK: leaq 48(%rsp), [[REG1:%[a-z]+]]<br>
+; CHECK: movq [[REG1]], (%rsp)<br>
+; va_arg:<br>
+; CHECK: leaq 52(%rsp), [[REG2:%[a-z]+]]<br>
+; CHECK: movq [[REG2]], (%rsp)<br>
+; CHECK: movl 48(%rsp), %eax<br>
+; CHECK: popq<br>
+; CHECK: ret<br>
+define i32 @arg4(i64 %a0, i64 %a1, i64 %a2, i64 %a3, ...) nounwind {<br>
+entry:<br>
+ %ap = alloca i8*, align 8<br>
+ %ap1 = bitcast i8** %ap to i8*<br>
+ call void @llvm.va_start(i8* %ap1)<br>
+ %tmp = va_arg i8** %ap, i32<br>
+ ret i32 %tmp<br>
+}<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>