]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/ELF/ppc64-toc-restore.s
Vendor import of lld trunk r338150:
[FreeBSD/FreeBSD.git] / test / ELF / ppc64-toc-restore.s
1 // REQUIRES: ppc
2
3 // RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
4 // RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/shared-ppc64.s -o %t2.o
5 // RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/ppc64-func.s -o %t3.o
6 // RUN: ld.lld -shared %t2.o -o %t2.so
7 // RUN: ld.lld %t.o %t2.so %t3.o -o %t
8 // RUN: llvm-objdump -d %t | FileCheck %s
9
10 // RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o
11 // RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/shared-ppc64.s -o %t2.o
12 // RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/ppc64-func.s -o %t3.o
13 // RUN: ld.lld -shared %t2.o -o %t2.so
14 // RUN: ld.lld %t.o %t2.so %t3.o -o %t
15 // RUN: llvm-objdump -d %t | FileCheck %s
16
17     .text
18     .abiversion 2
19 .global bar_local
20 bar_local:
21   li 3, 2
22   blr
23
24 # Calling external function foo in a shared object needs a nop.
25 # Calling local function bar_local doe snot need a nop.
26 .global _start
27 _start:
28   bl foo
29   nop
30   bl bar_local
31
32
33 // CHECK: Disassembly of section .text:
34 // CHECK: _start:
35 // CHECK:     1001001c: {{.*}}  bl .+67108836
36 // CHECK-NOT: 10010020: {{.*}}  nop
37 // CHECK:     10010020: {{.*}}  ld 2, 24(1)
38 // CHECK:     10010024: {{.*}}  bl .+67108848
39 // CHECK-NOT: 10010028: {{.*}}  nop
40 // CHECK-NOT: 10010028: {{.*}}  ld 2, 24(1)
41
42 # Calling a function in another object file which will have same
43 # TOC base does not need a nop. If nop present, do not rewrite to
44 # a toc restore
45 .global diff_object
46 _diff_object:
47   bl foo_not_shared
48   bl foo_not_shared
49   nop
50
51 // CHECK: _diff_object:
52 // CHECK-NEXT: 10010028: {{.*}}  bl .+24
53 // CHECK-NEXT: 1001002c: {{.*}}  bl .+20
54 // CHECK-NEXT: 10010030: {{.*}}  nop
55
56 # Branching to a local function does not need a nop
57 .global noretbranch
58 noretbranch:
59   b bar_local
60 // CHECK: noretbranch:
61 // CHECK:     10010034:  {{.*}}  b .+67108832
62 // CHECK-NOT: 10010038:  {{.*}}  nop
63 // CHECK-NOT: 1001003c:  {{.*}}  ld 2, 24(1)
64
65 // This should come last to check the end-of-buffer condition.
66 .global last
67 last:
68   bl foo
69   nop
70 // CHECK: last:
71 // CHECK:      10010038: {{.*}}   bl .+67108808
72 // CHECK-NEXT: 1001003c: {{.*}}   ld 2, 24(1)