llvm.org GIT mirror llvm / 17678da
Fix Win64 va_arg. --- Merging r127328 into '.': U test/CodeGen/X86/win64_vararg.ll U lib/Target/X86/X86ISelLowering.cpp git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_29@128044 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 9 years ago
2 changed file(s) with 38 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
17491749 // If the function takes variable number of arguments, make a frame index for
17501750 // the start of the first vararg value... for expansion of llvm.va_start.
17511751 if (isVarArg) {
1752 if (!IsWin64 && (Is64Bit || (CallConv != CallingConv::X86_FastCall &&
1753 CallConv != CallingConv::X86_ThisCall))) {
1752 if (Is64Bit || (CallConv != CallingConv::X86_FastCall &&
1753 CallConv != CallingConv::X86_ThisCall)) {
17541754 FuncInfo->setVarArgsFrameIndex(MFI->CreateFixedObject(1, StackSize,true));
17551755 }
17561756 if (Is64Bit) {
18021802 int HomeOffset = TFI.getOffsetOfLocalArea() + 8;
18031803 FuncInfo->setRegSaveFrameIndex(
18041804 MFI->CreateFixedObject(1, NumIntRegs * 8 + HomeOffset, false));
1805 FuncInfo->setVarArgsFrameIndex(FuncInfo->getRegSaveFrameIndex());
1805 // Fixup to set vararg frame on shadow area (4 x i64).
1806 if (NumIntRegs < 4)
1807 FuncInfo->setVarArgsFrameIndex(FuncInfo->getRegSaveFrameIndex());
18061808 } else {
18071809 // For X86-64, if there are vararg parameters that are passed via
18081810 // registers, then we must store them to their spots on the stack so they
1717 }
1818
1919 declare void @llvm.va_start(i8*) nounwind
20
21 ; CHECK: f5:
22 ; CHECK: pushq
23 ; CHECK: leaq 56(%rsp),
24 define i8* @f5(i64 %a0, i64 %a1, i64 %a2, i64 %a3, i64 %a4, ...) nounwind {
25 entry:
26 %ap = alloca i8*, align 8
27 %ap1 = bitcast i8** %ap to i8*
28 call void @llvm.va_start(i8* %ap1)
29 ret i8* %ap1
30 }
31
32 ; CHECK: f4:
33 ; CHECK: pushq
34 ; CHECK: leaq 48(%rsp),
35 define i8* @f4(i64 %a0, i64 %a1, i64 %a2, i64 %a3, ...) nounwind {
36 entry:
37 %ap = alloca i8*, align 8
38 %ap1 = bitcast i8** %ap to i8*
39 call void @llvm.va_start(i8* %ap1)
40 ret i8* %ap1
41 }
42
43 ; CHECK: f3:
44 ; CHECK: pushq
45 ; CHECK: leaq 40(%rsp),
46 define i8* @f3(i64 %a0, i64 %a1, i64 %a2, ...) nounwind {
47 entry:
48 %ap = alloca i8*, align 8
49 %ap1 = bitcast i8** %ap to i8*
50 call void @llvm.va_start(i8* %ap1)
51 ret i8* %ap1
52 }