http://llvm.org/bugs/show_bug.cgi?id=9010
Summary: Function parameter corruption when using tail call
optimization in Windows 64
Product: libraries
Version: trunk
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: normal
Priority: P
Component: Backend: X86
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
Created an attachment (id=6028)
--> (http://llvm.org/bugs/attachment.cgi?id=6028)
.ll and generated .s file
Tail call optimization is erroneously applied in Windows 64.
As result stack area which contains function parameters is released (RSP is
updated) before the call (replaced by jump in tail call optimization). It may
cause to wrong function behavior. See attached .s example. Specifically these 3
lines may explain the problem:
lea R8, QWORD PTR [RSP + 32] ; using stack to for parameter storage
...
add RSP, 232 ;; Stack is freed and allocated parameter with it
jmp testcall # TAILCALL
Attached are .ll and .s file generated with latest llc.
The simple inlined fix is solves the problem.
Index: lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- lib/Target/X86/X86ISelLowering.cpp (revision 2609)
+++ lib/Target/X86/X86ISelLowering.cpp (working copy)
@@ -2501,6 +2501,9 @@
SmallVector<CCValAssign, 16> ArgLocs;
CCState CCInfo(CalleeCC, isVarArg, getTargetMachine(),
ArgLocs, *DAG.getContext());
+ if (Subtarget->isTargetWin64()) {
+ CCInfo.AllocateStack(32, 8);
+ }
CCInfo.AnalyzeCallOperands(Outs, CCAssignFnForNode(CalleeCC));
if (CCInfo.getNextStackOffset()) {
MachineFunction &MF = DAG.getMachineFunction();
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs