From c26c03d911f8f686aabc19705ef2f240098cc886 Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Wed, 5 Oct 2016 15:39:27 +0000 Subject: [PATCH] Revert r282920 "X86: Allow conditional tail calls in Win64 "leaf" functions (PR26302)" This is suspected to cause a miscompile in Chromium. Reverting while investigating. llvm-svn: 283329 --- llvm/lib/Target/X86/X86ExpandPseudo.cpp | 5 ++--- llvm/lib/Target/X86/X86InstrInfo.cpp | 7 ++++--- llvm/test/CodeGen/X86/conditional-tailcall.ll | 27 ++------------------------- 3 files changed, 8 insertions(+), 31 deletions(-) diff --git a/llvm/lib/Target/X86/X86ExpandPseudo.cpp b/llvm/lib/Target/X86/X86ExpandPseudo.cpp index c945c02..192b942 100644 --- a/llvm/lib/Target/X86/X86ExpandPseudo.cpp +++ b/llvm/lib/Target/X86/X86ExpandPseudo.cpp @@ -122,9 +122,8 @@ bool X86ExpandPseudo::ExpandMI(MachineBasicBlock &MBB, Op = X86::TAILJMPd_CC; break; case X86::TCRETURNdi64cc: - assert(!MBB.getParent()->hasWinCFI() && - "Conditional tail calls confuse " - "the Win64 unwinder."); + assert(!IsWin64 && "Conditional tail calls confuse the Win64 unwinder."); + // TODO: We could do it for Win64 "leaf" functions though; PR30337. Op = X86::TAILJMPd64_CC; break; default: diff --git a/llvm/lib/Target/X86/X86InstrInfo.cpp b/llvm/lib/Target/X86/X86InstrInfo.cpp index 11fe9d3..20dab29 100644 --- a/llvm/lib/Target/X86/X86InstrInfo.cpp +++ b/llvm/lib/Target/X86/X86InstrInfo.cpp @@ -4277,9 +4277,9 @@ bool X86InstrInfo::canMakeTailCallConditional( return false; } - const MachineFunction *MF = TailCall.getParent()->getParent(); - if (Subtarget.isTargetWin64() && MF->hasWinCFI()) { + if (Subtarget.isTargetWin64()) { // Conditional tail calls confuse the Win64 unwinder. + // TODO: Allow them for "leaf" functions; PR30337. return false; } @@ -4289,7 +4289,8 @@ bool X86InstrInfo::canMakeTailCallConditional( return false; } - const X86MachineFunctionInfo *X86FI = MF->getInfo(); + const X86MachineFunctionInfo *X86FI = + TailCall.getParent()->getParent()->getInfo(); if (X86FI->getTCReturnAddrDelta() != 0 || TailCall.getOperand(1).getImm() != 0) { // A conditional tail call cannot do any stack adjustment. diff --git a/llvm/test/CodeGen/X86/conditional-tailcall.ll b/llvm/test/CodeGen/X86/conditional-tailcall.ll index 331697c..502643d 100644 --- a/llvm/test/CodeGen/X86/conditional-tailcall.ll +++ b/llvm/test/CodeGen/X86/conditional-tailcall.ll @@ -1,6 +1,5 @@ -; RUN: llc < %s -mtriple=i686-linux -show-mc-encoding | FileCheck -check-prefix=CHECK %s -; RUN: llc < %s -mtriple=x86_64-linux -show-mc-encoding | FileCheck -check-prefix=CHECK %s -; RUN: llc < %s -mtriple=x86_64-win32 -show-mc-encoding | FileCheck -check-prefix=CHECK -check-prefix=WIN64 %s +; RUN: llc < %s -mtriple=i686-linux -show-mc-encoding | FileCheck %s +; RUN: llc < %s -mtriple=x86_64-linux -show-mc-encoding | FileCheck %s declare void @foo() declare void @bar() @@ -24,28 +23,6 @@ bb2: ; CHECK: jmp foo } -define void @f_non_leaf(i32 %x, i32 %y) optsize { -entry: - ; Force %ebx to be spilled on the stack, turning this into - ; not a "leaf" function for Win64. - tail call void asm sideeffect "", "~{ebx}"() - - %p = icmp eq i32 %x, %y - br i1 %p, label %bb1, label %bb2 -bb1: - tail call void @foo() - ret void -bb2: - tail call void @bar() - ret void - -; CHECK-LABEL: f_non_leaf: -; WIN64-NOT: je foo -; WIN64-NOT: jne bar -; WIN64: jne -; WIN64: jmp foo -; WIN64: jmp bar -} declare x86_thiscallcc zeroext i1 @baz(i8*, i32) define x86_thiscallcc zeroext i1 @BlockPlacementTest(i8* %this, i32 %x) optsize { -- 2.7.4