Skip to content

Commit a07b5c2

Browse files
committed
Small patch to restore home register stack space allocation for the Win64 case. Add test case. This code eventually needs to be tighter, since it's always allocating it, even in leaf routines.
llvm-svn: 116056
1 parent 056b694 commit a07b5c2

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
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/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)