[llvm] Do not replace dead constant references in metadata with undef
[llvm-project.git] / lld / test / ELF / ppc64-toc-restore-recursive-call.s
blobc700d71573b9985477a8ef70744f9f27b3e0f50b
1 # REQUIRES: ppc
3 # RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
4 # RUN: ld.lld -shared %t.o -o %t.so
5 # RUN: llvm-objdump -d --no-show-raw-insn -r %t.so | FileCheck %s
7 # For a recursive call that is interposable the linker calls the plt-stub rather
8 # then calling the function directly. Since the call is through a plt stub and
9 # might be interposed with a different definition at runtime, a toc-restore is
10 # required to follow the call.
12 # The decision to use a plt-stub for the recursive call is not one I feel
13 # strongly about either way. It was done because it matches what bfd and gold do
14 # for recursive calls as well as keeps the logic for recursive calls consistent
15 # with non-recursive calls.
17 # CHECK-LABEL: 0000000000010290 <recursive_func>:
18 # CHECK: 102b8: bl 0x102e0
19 # CHECK-NEXT: ld 2, 24(1)
21 # CHECK-LABEL: 00000000000102e0 <__plt_recursive_func>:
23 .abiversion 2
24 .section ".text"
25 .p2align 2
26 .global recursive_func
27 .type recursive_func, @function
28 recursive_func:
29 .Lrf_gep:
30 addis 2, 12, .TOC.-.Lrf_gep@ha
31 addi 2, 2, .TOC.-.Lrf_gep@l
32 .localentry recursive_func, .-recursive_func
33 cmpldi 3, 2
34 blt 0, .Lend
36 mflr 0
37 std 0, 16(1)
38 stdu 1, -32(1)
39 addi 5, 3, -1
40 mulld 4, 4, 3
41 mr 3, 5
42 bl recursive_func
43 nop
44 mr 4, 3
45 addi 1, 1, 32
46 ld 0, 16(1)
47 mtlr 0
49 .Lend:
50 extsw 3, 4
51 blr