[LLVMbugs] [Bug 9010] New: Function parameter corruption when using tail call optimization in Windows 64
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Jan 20 03:52:27 PST 2011
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: unassignedbugs at nondot.org
ReportedBy: artiom.myaskouvskey at intel.com
CC: llvmbugs at cs.uiuc.edu
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.
More information about the llvm-bugs
mailing list