Skip to content

Commit d57f9ec

Browse files
committed
Recommit 116056, now with the missing file...
llvm-svn: 116083
1 parent 2f38b94 commit d57f9ec

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1701,8 +1701,12 @@ X86TargetLowering::LowerFormalArguments(SDValue Chain,
17011701
TotalNumXMMRegs = 0;
17021702

17031703
if (IsWin64) {
1704+
const TargetFrameInfo &TFI = *getTargetMachine().getFrameInfo();
1705+
// Get to the caller-allocated home save location. Add 8 to account
1706+
// for the return address.
1707+
int HomeOffset = TFI.getOffsetOfLocalArea() + 8;
17041708
FuncInfo->setRegSaveFrameIndex(
1705-
MFI->CreateFixedObject(1, NumIntRegs * 8, false));
1709+
MFI->CreateFixedObject(1, NumIntRegs * 8 + HomeOffset, false));
17061710
FuncInfo->setVarArgsFrameIndex(FuncInfo->getRegSaveFrameIndex());
17071711
} else {
17081712
// For X86-64, if there are vararg parameters that are passed via

llvm/lib/Target/X86/X86TargetMachine.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ X86TargetMachine::X86TargetMachine(const Target &T, const std::string &TT,
121121
Subtarget(TT, FS, is64Bit),
122122
FrameInfo(TargetFrameInfo::StackGrowsDown,
123123
Subtarget.getStackAlignment(),
124-
Subtarget.is64Bit() ? -8 : -4),
124+
(Subtarget.isTargetWin64() ? -40 :
125+
(Subtarget.is64Bit() ? -8 : -4))),
125126
ELFWriterInfo(is64Bit, true) {
126127
DefRelocModel = getRelocationModel();
127128

llvm/test/CodeGen/X86/win64_params.ll

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
; RUN: llc < %s -mtriple=x86_64-pc-win32 | FileCheck %s
2+
3+
; Verify that the 5th and 6th parameters are coming from the correct location
4+
; on the stack.
5+
define i32 @f6(i32 %p1, i32 %p2, i32 %p3, i32 %p4, i32 %p5, i32 %p6) nounwind readnone optsize {
6+
entry:
7+
; CHECK: movl 80(%rsp), %eax
8+
; CHECK: addl 72(%rsp), %eax
9+
%add = add nsw i32 %p6, %p5
10+
ret i32 %add
11+
}

0 commit comments

Comments
 (0)