[X86] Fix tailcall return address clobber bug.
authorQuentin Colombet <qcolombet@apple.com>
Mon, 11 Jul 2016 21:03:03 +0000 (21:03 +0000)
committerQuentin Colombet <qcolombet@apple.com>
Mon, 11 Jul 2016 21:03:03 +0000 (21:03 +0000)
commitfb82c7bc94bd9e66898a1d03902caf50bd406f58
tree7f647ace526af3a0203e84371e8eb5af8cde79e2
parentbb7d87ee2515d0fd728e2b9b3b86cc8e56025e81
[X86] Fix tailcall return address clobber bug.

This bug (llvm.org/PR28124) was introduced by r237977, which refactored
the tail call  sequence to be generated in two passes instead of one.

Unfortunately, the stack adjustment produced by the first pass was not
recognized by X86FrameLowering::mergeSPUpdates() in all cases, causing
code such as the following, which clobbers the return address, to be
generated:

popl    %edi
popl    %edi
pushl   %eax
jmp     tailcallee              # TAILCALL

To fix the problem, the entire stack adjustment is performed in
X86ExpandPseudo::ExpandMI() for tail calls.

Patch by Magnus Lång <margnus1@gmail.com>

Differential Revision: http://reviews.llvm.org/D21325

llvm-svn: 275103
llvm/lib/Target/X86/X86ExpandPseudo.cpp
llvm/lib/Target/X86/X86FrameLowering.cpp
llvm/test/CodeGen/X86/hipe-cc.ll
llvm/test/CodeGen/X86/hipe-cc64.ll