[llvm] r281003 - Win64: Don't use REX prefix for direct tail calls
Hans Wennborg via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 8 16:35:11 PDT 2016
Author: hans
Date: Thu Sep 8 18:35:10 2016
New Revision: 281003
URL: http://llvm.org/viewvc/llvm-project?rev=281003&view=rev
Log:
Win64: Don't use REX prefix for direct tail calls
The REX prefix should be used on indirect jmps, but not direct ones.
For direct jumps, the unwinder looks at the offset to determine if
it's inside the current function.
Differential Revision: https://reviews.llvm.org/D24359
Modified:
llvm/trunk/lib/Target/X86/X86ExpandPseudo.cpp
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
llvm/trunk/lib/Target/X86/X86InstrControl.td
llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
llvm/trunk/lib/Target/X86/X86MCInstLower.cpp
llvm/trunk/test/CodeGen/X86/seh-catchpad.ll
llvm/trunk/test/CodeGen/X86/tail-call-win64.ll
llvm/trunk/test/CodeGen/X86/win64_sibcall.ll
llvm/trunk/test/DebugInfo/COFF/register-variables.ll
Modified: llvm/trunk/lib/Target/X86/X86ExpandPseudo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ExpandPseudo.cpp?rev=281003&r1=281002&r2=281003&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ExpandPseudo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ExpandPseudo.cpp Thu Sep 8 18:35:10 2016
@@ -121,7 +121,9 @@ bool X86ExpandPseudo::ExpandMI(MachineBa
Op = X86::TAILJMPd_CC;
break;
default:
- Op = IsWin64 ? X86::TAILJMPd64_REX : X86::TAILJMPd64;
+ // Note: Win64 uses REX prefixes indirect jumps out of functions, but
+ // not direct ones.
+ Op = X86::TAILJMPd64;
break;
}
MachineInstrBuilder MIB = BuildMI(MBB, MBBI, DL, TII->get(Op));
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=281003&r1=281002&r2=281003&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Thu Sep 8 18:35:10 2016
@@ -24521,7 +24521,6 @@ X86TargetLowering::EmitInstrWithCustomIn
case X86::TAILJMPd64:
case X86::TAILJMPr64:
case X86::TAILJMPm64:
- case X86::TAILJMPd64_REX:
case X86::TAILJMPr64_REX:
case X86::TAILJMPm64_REX:
llvm_unreachable("TAILJMP64 would not be touched here.");
Modified: llvm/trunk/lib/Target/X86/X86InstrControl.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrControl.td?rev=281003&r1=281002&r2=281003&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrControl.td (original)
+++ llvm/trunk/lib/Target/X86/X86InstrControl.td Thu Sep 8 18:35:10 2016
@@ -323,11 +323,8 @@ let isCall = 1, isTerminator = 1, isRetu
def TAILJMPm64 : I<0xFF, MRM4m, (outs), (ins i64mem_TC:$dst),
"jmp{q}\t{*}$dst", [], IIC_JMP_MEM>;
- // Win64 wants jumps leaving the function to have a REX_W prefix.
+ // Win64 wants indirect jumps leaving the function to have a REX_W prefix.
let hasREX_WPrefix = 1 in {
- def TAILJMPd64_REX : Ii32PCRel<0xE9, RawFrm, (outs),
- (ins i64i32imm_pcrel:$dst),
- "rex64 jmp\t$dst", [], IIC_JMP_REL>;
def TAILJMPr64_REX : I<0xFF, MRM4r, (outs), (ins ptr_rc_tailcall:$dst),
"rex64 jmp{q}\t{*}$dst", [], IIC_JMP_MEM>;
Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=281003&r1=281002&r2=281003&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Thu Sep 8 18:35:10 2016
@@ -8286,7 +8286,6 @@ bool X86InstrInfo::isTailCall(const Mach
case X86::TAILJMPd64:
case X86::TAILJMPm64:
case X86::TAILJMPr64:
- case X86::TAILJMPd64_REX:
case X86::TAILJMPm64_REX:
case X86::TAILJMPr64_REX:
return true;
Modified: llvm/trunk/lib/Target/X86/X86MCInstLower.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86MCInstLower.cpp?rev=281003&r1=281002&r2=281003&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86MCInstLower.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86MCInstLower.cpp Thu Sep 8 18:35:10 2016
@@ -1311,7 +1311,6 @@ void X86AsmPrinter::EmitInstruction(cons
case X86::TAILJMPd64:
case X86::TAILJMPr64_REX:
case X86::TAILJMPm64_REX:
- case X86::TAILJMPd64_REX:
// Lower these as normal, but add some comments.
OutStreamer->AddComment("TAILCALL");
break;
Modified: llvm/trunk/test/CodeGen/X86/seh-catchpad.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/seh-catchpad.ll?rev=281003&r1=281002&r2=281003&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/seh-catchpad.ll (original)
+++ llvm/trunk/test/CodeGen/X86/seh-catchpad.ll Thu Sep 8 18:35:10 2016
@@ -173,7 +173,7 @@ entry:
; CHECK: "?filt$0 at 0@main@@": # @"\01?filt$0 at 0@main@@"
; CHECK: .seh_proc "?filt$0 at 0@main@@"
; CHECK: .seh_endprologue
-; CHECK: rex64 jmp filt # TAILCALL
+; CHECK: jmp filt # TAILCALL
; CHECK: .seh_handlerdata
declare i32 @filt() #1
Modified: llvm/trunk/test/CodeGen/X86/tail-call-win64.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tail-call-win64.ll?rev=281003&r1=281002&r2=281003&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/tail-call-win64.ll (original)
+++ llvm/trunk/test/CodeGen/X86/tail-call-win64.ll Thu Sep 8 18:35:10 2016
@@ -22,7 +22,7 @@ define void @tail_jmp_imm() {
}
; CHECK-LABEL: tail_jmp_imm:
-; CHECK: rex64 jmp tail_tgt
+; CHECK: jmp tail_tgt
@g_fptr = global void ()* @tail_tgt
Modified: llvm/trunk/test/CodeGen/X86/win64_sibcall.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/win64_sibcall.ll?rev=281003&r1=281002&r2=281003&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/win64_sibcall.ll (original)
+++ llvm/trunk/test/CodeGen/X86/win64_sibcall.ll Thu Sep 8 18:35:10 2016
@@ -21,7 +21,7 @@ entry:
; WIN_X64: xorl %r8d, %r8d
; WIN_X64: popq %rax
-; WIN_X64: rex64 jmp C2 # TAILCALL
+; WIN_X64: jmp C2 # TAILCALL
; LINUX: xorl %edx, %edx
; LINUX: jmp C2 # TAILCALL
Modified: llvm/trunk/test/DebugInfo/COFF/register-variables.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/register-variables.ll?rev=281003&r1=281002&r2=281003&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/register-variables.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/register-variables.ll Thu Sep 8 18:35:10 2016
@@ -54,7 +54,7 @@
; ASM: addq $32, %rsp
; ASM: popq %rsi
; ASM: [[func_end:\.Ltmp.*]]:
-; ASM: rex64 jmp putint # TAILCALL
+; ASM: jmp putint # TAILCALL
; ASM: .short 4414 # Record kind: S_LOCAL
; ASM: .asciz "p"
More information about the llvm-commits
mailing list