llvm.org GIT mirror llvm / d837ce2
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281003 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 3 years ago
9 changed file(s) with 8 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
120120 Op = X86::TAILJMPd_CC;
121121 break;
122122 default:
123 Op = IsWin64 ? X86::TAILJMPd64_REX : X86::TAILJMPd64;
123 // Note: Win64 uses REX prefixes indirect jumps out of functions, but
124 // not direct ones.
125 Op = X86::TAILJMPd64;
124126 break;
125127 }
126128 MachineInstrBuilder MIB = BuildMI(MBB, MBBI, DL, TII->get(Op));
2452024520 case X86::TAILJMPd64:
2452124521 case X86::TAILJMPr64:
2452224522 case X86::TAILJMPm64:
24523 case X86::TAILJMPd64_REX:
2452424523 case X86::TAILJMPr64_REX:
2452524524 case X86::TAILJMPm64_REX:
2452624525 llvm_unreachable("TAILJMP64 would not be touched here.");
322322 def TAILJMPm64 : I<0xFF, MRM4m, (outs), (ins i64mem_TC:$dst),
323323 "jmp{q}\t{*}$dst", [], IIC_JMP_MEM>;
324324
325 // Win64 wants jumps leaving the function to have a REX_W prefix.
325 // Win64 wants indirect jumps leaving the function to have a REX_W prefix.
326326 let hasREX_WPrefix = 1 in {
327 def TAILJMPd64_REX : Ii32PCRel<0xE9, RawFrm, (outs),
328 (ins i64i32imm_pcrel:$dst),
329 "rex64 jmp\t$dst", [], IIC_JMP_REL>;
330327 def TAILJMPr64_REX : I<0xFF, MRM4r, (outs), (ins ptr_rc_tailcall:$dst),
331328 "rex64 jmp{q}\t{*}$dst", [], IIC_JMP_MEM>;
332329
82858285 case X86::TAILJMPd64:
82868286 case X86::TAILJMPm64:
82878287 case X86::TAILJMPr64:
8288 case X86::TAILJMPd64_REX:
82898288 case X86::TAILJMPm64_REX:
82908289 case X86::TAILJMPr64_REX:
82918290 return true;
13101310 case X86::TAILJMPd64:
13111311 case X86::TAILJMPr64_REX:
13121312 case X86::TAILJMPm64_REX:
1313 case X86::TAILJMPd64_REX:
13141313 // Lower these as normal, but add some comments.
13151314 OutStreamer->AddComment("TAILCALL");
13161315 break;
172172 ; CHECK: "?filt$0@0@main@@": # @"\01?filt$0@0@main@@"
173173 ; CHECK: .seh_proc "?filt$0@0@main@@"
174174 ; CHECK: .seh_endprologue
175 ; CHECK: rex64 jmp filt # TAILCALL
175 ; CHECK: jmp filt # TAILCALL
176176 ; CHECK: .seh_handlerdata
177177
178178 declare i32 @filt() #1
2121 }
2222
2323 ; CHECK-LABEL: tail_jmp_imm:
24 ; CHECK: rex64 jmp tail_tgt
24 ; CHECK: jmp tail_tgt
2525
2626 @g_fptr = global void ()* @tail_tgt
2727
2020
2121 ; WIN_X64: xorl %r8d, %r8d
2222 ; WIN_X64: popq %rax
23 ; WIN_X64: rex64 jmp C2 # TAILCALL
23 ; WIN_X64: jmp C2 # TAILCALL
2424 ; LINUX: xorl %edx, %edx
2525 ; LINUX: jmp C2 # TAILCALL
2626
5353 ; ASM: addq $32, %rsp
5454 ; ASM: popq %rsi
5555 ; ASM: [[func_end:\.Ltmp.*]]:
56 ; ASM: rex64 jmp putint # TAILCALL
56 ; ASM: jmp putint # TAILCALL
5757
5858 ; ASM: .short 4414 # Record kind: S_LOCAL
5959 ; ASM: .asciz "p"