[llvm-commits] Win64 calling convention patches for X86FastIsel
Jan Sjodin
jan_sjodin at yahoo.com
Tue Jun 1 11:39:52 PDT 2010
There is a problem with handling the Win64 calling convention for
function calls in X86FastIsel regarding the shadow space. The shadow
space is supposed to be allocated before any arguments are pushed on
the stack. This is handled in the regular code generation, but not
in the FastIsel. There are two ways of solving this.
1. Do not handle Win64:
Index: lib/Target/X86/X86FastISel.cpp
===================================================================
--- lib/Target/X86/X86FastISel.cpp (revision 105274)
+++ lib/Target/X86/X86FastISel.cpp (working copy)
@@ -1318,6 +1318,10 @@
if (Subtarget->IsCalleePop(FTy->isVarArg(), CC))
return false;
+ // Fast-isel doesn't know about Win64 CC.
+ if (Subtarget->isTargetWin64())
+ return false;
+
// Handle *simple* calls for now.
const Type *RetTy = CS.getType();
EVT RetVT;
2. Allocate space before arguments are processed:
Index: lib/Target/X86/X86FastISel.cpp
===================================================================
--- lib/Target/X86/X86FastISel.cpp (revision 105274)
+++ lib/Target/X86/X86FastISel.cpp (working copy)
@@ -1391,6 +1391,12 @@
// Analyze operands of the call, assigning locations to each operand.
SmallVector<CCValAssign, 16> ArgLocs;
CCState CCInfo(CC, false, TM, ArgLocs, I->getParent()->getContext());
+
+ // Allocate shadow area for Win64
+ if (Subtarget->isTargetWin64()) {
+ CCInfo.AllocateStack(32, 8);
+ }
+
CCInfo.AnalyzeCallOperands(ArgVTs, ArgFlags, CCAssignFnForCall(CC));
// Get a count of how many bytes are to be pushed on the stack.
I don't know which is preferable. On IRC it was mentioned that Win64
is a non-standard calling convention and it should not be handled in
FastIsel. I posted both patches here and more people can decide what
is the better approach.
- Jan
More information about the llvm-commits
mailing list