You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Extended Description
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());
CCInfo.AnalyzeCallOperands(Outs, CCAssignFnForNode(CalleeCC));
if (CCInfo.getNextStackOffset()) {
MachineFunction &MF = DAG.getMachineFunction();
The text was updated successfully, but these errors were encountered: