Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 8e07f28

Browse files
committed
Revert r282920 "X86: Allow conditional tail calls in Win64 "leaf" functions (PR26302)"
This is suspected to cause a miscompile in Chromium. Reverting while investigating. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283329 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 20d3d70 commit 8e07f28

File tree

3 files changed

+8
-31
lines changed

3 files changed

+8
-31
lines changed

lib/Target/X86/X86ExpandPseudo.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,8 @@ bool X86ExpandPseudo::ExpandMI(MachineBasicBlock &MBB,
122122
Op = X86::TAILJMPd_CC;
123123
break;
124124
case X86::TCRETURNdi64cc:
125-
assert(!MBB.getParent()->hasWinCFI() &&
126-
"Conditional tail calls confuse "
127-
"the Win64 unwinder.");
125+
assert(!IsWin64 && "Conditional tail calls confuse the Win64 unwinder.");
126+
// TODO: We could do it for Win64 "leaf" functions though; PR30337.
128127
Op = X86::TAILJMPd64_CC;
129128
break;
130129
default:

lib/Target/X86/X86InstrInfo.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4277,9 +4277,9 @@ bool X86InstrInfo::canMakeTailCallConditional(
42774277
return false;
42784278
}
42794279

4280-
const MachineFunction *MF = TailCall.getParent()->getParent();
4281-
if (Subtarget.isTargetWin64() && MF->hasWinCFI()) {
4280+
if (Subtarget.isTargetWin64()) {
42824281
// Conditional tail calls confuse the Win64 unwinder.
4282+
// TODO: Allow them for "leaf" functions; PR30337.
42834283
return false;
42844284
}
42854285

@@ -4289,7 +4289,8 @@ bool X86InstrInfo::canMakeTailCallConditional(
42894289
return false;
42904290
}
42914291

4292-
const X86MachineFunctionInfo *X86FI = MF->getInfo<X86MachineFunctionInfo>();
4292+
const X86MachineFunctionInfo *X86FI =
4293+
TailCall.getParent()->getParent()->getInfo<X86MachineFunctionInfo>();
42934294
if (X86FI->getTCReturnAddrDelta() != 0 ||
42944295
TailCall.getOperand(1).getImm() != 0) {
42954296
// A conditional tail call cannot do any stack adjustment.

test/CodeGen/X86/conditional-tailcall.ll

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
; RUN: llc < %s -mtriple=i686-linux -show-mc-encoding | FileCheck -check-prefix=CHECK %s
2-
; RUN: llc < %s -mtriple=x86_64-linux -show-mc-encoding | FileCheck -check-prefix=CHECK %s
3-
; RUN: llc < %s -mtriple=x86_64-win32 -show-mc-encoding | FileCheck -check-prefix=CHECK -check-prefix=WIN64 %s
1+
; RUN: llc < %s -mtriple=i686-linux -show-mc-encoding | FileCheck %s
2+
; RUN: llc < %s -mtriple=x86_64-linux -show-mc-encoding | FileCheck %s
43

54
declare void @foo()
65
declare void @bar()
@@ -24,28 +23,6 @@ bb2:
2423
; CHECK: jmp foo
2524
}
2625

27-
define void @f_non_leaf(i32 %x, i32 %y) optsize {
28-
entry:
29-
; Force %ebx to be spilled on the stack, turning this into
30-
; not a "leaf" function for Win64.
31-
tail call void asm sideeffect "", "~{ebx}"()
32-
33-
%p = icmp eq i32 %x, %y
34-
br i1 %p, label %bb1, label %bb2
35-
bb1:
36-
tail call void @foo()
37-
ret void
38-
bb2:
39-
tail call void @bar()
40-
ret void
41-
42-
; CHECK-LABEL: f_non_leaf:
43-
; WIN64-NOT: je foo
44-
; WIN64-NOT: jne bar
45-
; WIN64: jne
46-
; WIN64: jmp foo
47-
; WIN64: jmp bar
48-
}
4926

5027
declare x86_thiscallcc zeroext i1 @baz(i8*, i32)
5128
define x86_thiscallcc zeroext i1 @BlockPlacementTest(i8* %this, i32 %x) optsize {

0 commit comments

Comments
 (0)