1; RUN: llc -O0 -mtriple=i386-unknown-linux-gnu -relocation-model=pic < %s | FileCheck %s
2
3; Unbind the ebx with GOT address in regcall calling convention, or the following
4; case will failed in register allocation by no register can be used.
5
6;#define REGCALL __attribute__((regcall))
7;int REGCALL func (int i1, int i2, int i3, int i4, int i5);
8;int (REGCALL *fptr) (int, int, int, int, int) = func;
9;int test() {
10;    return fptr(1,2,3,4,5);
11;}
12
13@fptr = global i32 (i32, i32, i32, i32, i32)* @__regcall3__func, align 4
14
15declare x86_regcallcc i32 @__regcall3__func(i32 inreg, i32 inreg, i32 inreg, i32 inreg, i32 inreg)
16
17; Function Attrs: noinline nounwind optnone
18define i32 @test() {
19; CHECK-LABEL: test:
20; CHECK:       .L0$pb:
21; CHECK-NEXT:    popl %eax
22; CHECK:       .Ltmp0:
23; CHECK-NEXT:    addl    $_GLOBAL_OFFSET_TABLE_+(.Ltmp0-.L0$pb), %eax
24; CHECK-NEXT:    movl    fptr@GOT(%eax), %eax
25; CHECK-NEXT:    movl    (%eax), %ebx
26; CHECK-NEXT:    movl    $1, %eax
27; CHECK-NEXT:    movl    $2, %ecx
28; CHECK-NEXT:    movl    $3, %edx
29; CHECK-NEXT:    movl    $4, %edi
30; CHECK-NEXT:    movl    $5, %esi
31; CHECK-NEXT:    calll   *%ebx
32
33entry:
34  %0 = load i32 (i32, i32, i32, i32, i32)*, i32 (i32, i32, i32, i32, i32)** @fptr, align 4
35  %call = call x86_regcallcc i32 %0(i32 inreg 1, i32 inreg 2, i32 inreg 3, i32 inreg 4, i32 inreg 5)
36  ret i32 %call
37}
38