Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / MachO / icf-arm64.s
blob7d74af8ce5bf80b64b2e1bdd3a17f3e6ed6aa9c6
1 # REQUIRES: aarch64
2 # RUN: rm -rf %t; split-file %s %t
4 # RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin19.0.0 %t/main.s -o %t/main.o
5 # RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin19.0.0 %t/f2.s -o %t/f2.o
6 # RUN: %lld -arch arm64 -lSystem --icf=all -o %t/main %t/main.o %t/f2.o
7 # RUN: llvm-objdump -d --syms --print-imm-hex %t/main | FileCheck %s
9 # CHECK-LABEL: SYMBOL TABLE:
10 # CHECK: [[#%x,F1_REF:]] g F __TEXT,__text _f1
11 # CHECK: [[#%x,F1_REF:]] g F __TEXT,__text _f2
13 # CHECK-LABEL: Disassembly of section __TEXT,__text:
14 # CHECK: <_main>:
15 # CHECK: bl 0x[[#%x,F1_REF:]]
16 # CHECK: bl 0x[[#%x,F1_REF:]]
18 #--- main.s
20 .subsections_via_symbols
22 .literal16
23 .p2align 3
24 L_align16:
25 .quad 0xffffffffffffffff
26 .short 0xaaaa
27 .short 0xaaaa
28 .space 4, 0xaa
30 .literal8
31 .p2align 3
32 L_align8:
33 .quad 0xeeeeeeeeeeeeeeee
35 .literal4
36 .p2align 2
37 L_align4:
38 .short 0xbbbb
39 .short 0xbbbb
42 .text
43 .p2align 2
45 .globl _main, _f1, _f2
47 ## Test that loading from __literalN sections at non-literal boundaries
48 ## doesn't confuse ICF. This function should be folded with the identical
49 ## _f2 in f2 (which uses literals of the same value in a different isec).
50 _f1:
51 adrp x9, L_align16@PAGE + 4
52 add x9, x9, L_align16@PAGEOFF + 4
53 ldr x10, [x9]
55 adrp x9, L_align8@PAGE + 4
56 add x9, x9, L_align8@PAGEOFF + 4
57 ldr w11, [x9]
59 adrp x9, L_align4@PAGE + 2
60 add x9, x9, L_align4@PAGEOFF + 2
61 ldrh w12, [x9]
63 ret
65 _main:
66 bl _f1
67 bl _f2
69 #--- f2.s
71 .subsections_via_symbols
73 .literal16
74 .p2align 3
75 L_align16:
76 .quad 0xffffffffffffffff
77 .short 0xaaaa
78 .short 0xaaaa
79 .space 4, 170
81 .literal8
82 .p2align 3
83 L_align8:
84 .quad 0xeeeeeeeeeeeeeeee
86 .literal4
87 .p2align 2
88 L_align4:
89 .short 0xbbbb
90 .short 0xbbbb
92 .text
93 .p2align 2
95 .globl _f2
96 _f2:
97 adrp x9, L_align16@PAGE + 4
98 add x9, x9, L_align16@PAGEOFF + 4
99 ldr x10, [x9]
101 adrp x9, L_align8@PAGE + 4
102 add x9, x9, L_align8@PAGEOFF + 4
103 ldr w11, [x9]
105 adrp x9, L_align4@PAGE + 2
106 add x9, x9, L_align4@PAGEOFF + 2
107 ldrh w12, [x9]