diff options
author | Hans Wennborg <hans@hanshq.net> | 2016-09-30 20:07:35 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2016-09-30 20:07:35 +0000 |
commit | 68604c21e7bae0d5339fef86ac64d4c769aa824d (patch) | |
tree | 8c5413f6d2507a509e9cb60dbf5b5b2d318e6106 /lib | |
parent | d8588ac73f8891c0a7a23fe87825753546766cff (diff) | |
download | llvm-68604c21e7bae0d5339fef86ac64d4c769aa824d.tar.gz |
X86: Allow conditional tail calls in Win64 "leaf" functions (PR26302)
We can't use Jcc to leave a Win64 function in general, because that
confuses the unwinder. However, for "leaf" functions, that is, functions
where the return address is always on top of the stack and which don't
have unwind info, it's OK.
Differential Revision: https://reviews.llvm.org/D24836
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282920 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Target/X86/X86ExpandPseudo.cpp | 5 | ||||
-rw-r--r-- | lib/Target/X86/X86InstrInfo.cpp | 7 |
2 files changed, 6 insertions, 6 deletions
diff --git a/lib/Target/X86/X86ExpandPseudo.cpp b/lib/Target/X86/X86ExpandPseudo.cpp index 63e8f017fe2a..8ae214901f3b 100644 --- a/lib/Target/X86/X86ExpandPseudo.cpp +++ b/lib/Target/X86/X86ExpandPseudo.cpp @@ -122,8 +122,9 @@ bool X86ExpandPseudo::ExpandMI(MachineBasicBlock &MBB, Op = X86::TAILJMPd_CC; break; case X86::TCRETURNdi64cc: - assert(!IsWin64 && "Conditional tail calls confuse the Win64 unwinder."); - // TODO: We could do it for Win64 "leaf" functions though; PR30337. + assert(!MBB.getParent()->hasWinCFI() && + "Conditional tail calls confuse " + "the Win64 unwinder."); Op = X86::TAILJMPd64_CC; break; default: diff --git a/lib/Target/X86/X86InstrInfo.cpp b/lib/Target/X86/X86InstrInfo.cpp index a71aac10c839..fd3849f95bfb 100644 --- a/lib/Target/X86/X86InstrInfo.cpp +++ b/lib/Target/X86/X86InstrInfo.cpp @@ -4240,9 +4240,9 @@ bool X86InstrInfo::canMakeTailCallConditional( return false; } - if (Subtarget.isTargetWin64()) { + const MachineFunction *MF = TailCall.getParent()->getParent(); + if (Subtarget.isTargetWin64() && MF->hasWinCFI()) { // Conditional tail calls confuse the Win64 unwinder. - // TODO: Allow them for "leaf" functions; PR30337. return false; } @@ -4252,8 +4252,7 @@ bool X86InstrInfo::canMakeTailCallConditional( return false; } - const X86MachineFunctionInfo *X86FI = - TailCall.getParent()->getParent()->getInfo<X86MachineFunctionInfo>(); + const X86MachineFunctionInfo *X86FI = MF->getInfo<X86MachineFunctionInfo>(); if (X86FI->getTCReturnAddrDelta() != 0 || TailCall.getOperand(1).getImm() != 0) { // A conditional tail call cannot do any stack adjustment. |