forked from OSchip/llvm-project
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 llvm-svn: 281003
This commit is contained in:
parent
f205a274c4
commit
c39ef776fc
|
@ -121,7 +121,9 @@ bool X86ExpandPseudo::ExpandMI(MachineBasicBlock &MBB,
|
|||
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));
|
||||
|
|
|
@ -24521,7 +24521,6 @@ X86TargetLowering::EmitInstrWithCustomInserter(MachineInstr &MI,
|
|||
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.");
|
||||
|
|
|
@ -323,11 +323,8 @@ let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1,
|
|||
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>;
|
||||
|
||||
|
|
|
@ -8286,7 +8286,6 @@ bool X86InstrInfo::isTailCall(const MachineInstr &Inst) const {
|
|||
case X86::TAILJMPd64:
|
||||
case X86::TAILJMPm64:
|
||||
case X86::TAILJMPr64:
|
||||
case X86::TAILJMPd64_REX:
|
||||
case X86::TAILJMPm64_REX:
|
||||
case X86::TAILJMPr64_REX:
|
||||
return true;
|
||||
|
|
|
@ -1311,7 +1311,6 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) {
|
|||
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;
|
||||
|
|
|
@ -173,7 +173,7 @@ entry:
|
|||
; CHECK: "?filt$0@0@main@@": # @"\01?filt$0@0@main@@"
|
||||
; CHECK: .seh_proc "?filt$0@0@main@@"
|
||||
; CHECK: .seh_endprologue
|
||||
; CHECK: rex64 jmp filt # TAILCALL
|
||||
; CHECK: jmp filt # TAILCALL
|
||||
; CHECK: .seh_handlerdata
|
||||
|
||||
declare i32 @filt() #1
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue