1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 12:43:36 +01:00
llvm-mirror/test/CodeGen/X86/tailregccpic.ll
Xiang1 Zhang 47e9765193 [X86] Unbind the ebx with GOT address in regcall calling convention
No register can be allocated for indirect call when it use regcall calling
convention and passed 5/5+ args.
For example:
call vreg (ag1, ag2, ag3, ag4, ag5, ...) --> 5 regs (EAX, ECX, EDX, ESI, EDI)
used for pass args, 1 reg (EBX )used for hold GOT point, so no regs can be
allocated to vreg.

The Intel386 architecture provides 8 general purpose 32-bit registers. RA
mostly use 6 of them (EAX, EBX, ECX, EDX, ESI, EDI). 5 of this regs can be
used to pass function arguments (EAX, ECX, EDX, ESI, EDI).
EBX used to hold the GOT pointer when making function calls via the PLT.
ESP and EBP usually be "reserved" in register allocation.

Reviewed By: LuoYuanke

Differential Revision: https://reviews.llvm.org/D91020
2020-12-04 10:00:13 +08:00

27 lines
746 B
LLVM

; RUN: llc < %s -mtriple=i386-pc-unknown-linux-gnu -relocation-model=pic | FileCheck %s
@a0 = global i32 0, align 4
define x86_regcallcc void @tail_call_regcall(i32 %a) nounwind {
tail call x86_regcallcc void @__regcall3__func(i32 %a) nounwind
ret void
}
define internal x86_regcallcc void @__regcall3__func(i32 %i1) {
entry:
store i32 %i1, i32* @a0, align 4
ret void
}
;CHECK-LABLE: tail_call_regcall:
;CHECK: # %bb.0:
;CHECK-NEXT: jmp __regcall3__func # TAILCALL
;CHECK-NEXT: .Lfunc_end0:
;CHECK-LABLE: __regcall3__func:
;CHECK: addl $_GLOBAL_OFFSET_TABLE_+({{.*}}), %ecx
;CHECK-NEXT: movl a0@GOT(%ecx), %ecx
;CHECK-NEXT: movl %eax, (%ecx)
;CHECK-NEXT: retl
;CHECK-NEXT: .Lfunc_end1: