1 ; RUN: llc -mtriple=arm64-unknown-linux-gnu %s -o - | FileCheck %s --check-prefixes=ELF
2 ; RUN: llc -mtriple=arm64-apple-darwin %s -o - | FileCheck %s --check-prefix=MACHO
3 ; RUN: llc -mtriple=arm64-apple-darwin %s -global-isel -o - | FileCheck %s --check-prefix=MACHO
5 define internal ptr @the_resolver() {
9 ; ELF: .type the_resolver,@function
10 ; ELF-NEXT: the_resolver:
13 ; MACHO-NEXT: _the_resolver:
16 @global_ifunc = ifunc i32 (i32), ptr @the_resolver
17 ; ELF: .globl global_ifunc
18 ; ELF-NEXT: .type global_ifunc,@gnu_indirect_function
19 ; ELF-NEXT: .set global_ifunc, the_resolver
21 ; MACHO: .section __DATA,__data
22 ; MACHO-NEXT: .p2align 3, 0x0
23 ; MACHO-NEXT: _global_ifunc.lazy_pointer:
24 ; MACHO-NEXT: .quad _global_ifunc.stub_helper
26 ; MACHO: .section __TEXT,__text,regular,pure_instructions
27 ; MACHO-NEXT: .globl _global_ifunc
28 ; MACHO-NEXT: .p2align 2
29 ; MACHO-NEXT: _global_ifunc:
30 ; MACHO-NEXT: adrp x16, _global_ifunc.lazy_pointer@GOTPAGE
31 ; MACHO-NEXT: ldr x16, [x16, _global_ifunc.lazy_pointer@GOTPAGEOFF]
32 ; MACHO-NEXT: ldr x16, [x16]
34 ; MACHO-NEXT: .p2align 2
35 ; MACHO-NEXT: _global_ifunc.stub_helper:
36 ; MACHO-NEXT: stp x29, x30, [sp, #-16]!
37 ; MACHO-NEXT: mov x29, sp
38 ; MACHO-NEXT: stp x1, x0, [sp, #-16]!
39 ; MACHO-NEXT: stp x3, x2, [sp, #-16]!
40 ; MACHO-NEXT: stp x5, x4, [sp, #-16]!
41 ; MACHO-NEXT: stp x7, x6, [sp, #-16]!
42 ; MACHO-NEXT: stp d1, d0, [sp, #-16]!
43 ; MACHO-NEXT: stp d3, d2, [sp, #-16]!
44 ; MACHO-NEXT: stp d5, d4, [sp, #-16]!
45 ; MACHO-NEXT: stp d7, d6, [sp, #-16]!
46 ; MACHO-NEXT: bl _the_resolver
47 ; MACHO-NEXT: adrp x16, _global_ifunc.lazy_pointer@GOTPAGE
48 ; MACHO-NEXT: ldr x16, [x16, _global_ifunc.lazy_pointer@GOTPAGEOFF]
49 ; MACHO-NEXT: str x0, [x16]
50 ; MACHO-NEXT: add x16, x0, #0
51 ; MACHO-NEXT: ldp d7, d6, [sp], #16
52 ; MACHO-NEXT: ldp d5, d4, [sp], #16
53 ; MACHO-NEXT: ldp d3, d2, [sp], #16
54 ; MACHO-NEXT: ldp d1, d0, [sp], #16
55 ; MACHO-NEXT: ldp x7, x6, [sp], #16
56 ; MACHO-NEXT: ldp x5, x4, [sp], #16
57 ; MACHO-NEXT: ldp x3, x2, [sp], #16
58 ; MACHO-NEXT: ldp x1, x0, [sp], #16
59 ; MACHO-NEXT: ldp x29, x30, [sp], #16
63 @weak_ifunc = weak ifunc i32 (i32), ptr @the_resolver
64 ; ELF: .type weak_ifunc,@gnu_indirect_function
65 ; MACHO-NOT: .weak_reference _weak_ifunc.lazy_pointer
66 ; MACHO: _weak_ifunc.lazy_pointer:
67 ; MACHO: .weak_reference _weak_ifunc
69 ; MACHO-NOT: .weak_reference _weak_ifunc.stub_helper
70 ; MACHO: _weak_ifunc.stub_helper: