File: icf-arm64.s

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (109 lines) | stat: -rw-r--r-- 2,013 bytes parent folder | download | duplicates (18)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# REQUIRES: aarch64
# RUN: rm -rf %t; split-file %s %t

# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin19.0.0 %t/main.s -o %t/main.o
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin19.0.0 %t/f2.s -o %t/f2.o
# RUN: %lld -arch arm64 -lSystem --icf=all -o %t/main %t/main.o %t/f2.o
# RUN: llvm-objdump -d --syms --print-imm-hex %t/main | FileCheck %s

# CHECK-LABEL: SYMBOL TABLE:
# CHECK: [[#%x,F1_REF:]]                 g     F __TEXT,__text _f1
# CHECK: [[#%x,F1_REF:]]                 g     F __TEXT,__text _f2

# CHECK-LABEL: Disassembly of section __TEXT,__text:
# CHECK:        <_main>:
# CHECK: bl 0x[[#%x,F1_REF:]]
# CHECK: bl 0x[[#%x,F1_REF:]]

#--- main.s

.subsections_via_symbols

.literal16
.p2align 3
L_align16:
.quad 0xffffffffffffffff
.short 0xaaaa
.short 0xaaaa
.space 4, 0xaa

.literal8
.p2align 3
L_align8:
.quad 0xeeeeeeeeeeeeeeee

.literal4
.p2align 2
L_align4:
.short 0xbbbb
.short 0xbbbb


.text
.p2align 2

.globl _main, _f1, _f2

## Test that loading from __literalN sections at non-literal boundaries
## doesn't confuse ICF. This function should be folded with the identical
## _f2 in f2 (which uses literals of the same value in a different isec).
_f1:
  adrp x9, L_align16@PAGE + 4
  add x9, x9, L_align16@PAGEOFF + 4
  ldr x10, [x9]

  adrp x9, L_align8@PAGE + 4
  add x9, x9, L_align8@PAGEOFF + 4
  ldr w11, [x9]

  adrp x9, L_align4@PAGE + 2
  add x9, x9, L_align4@PAGEOFF + 2
  ldrh w12, [x9]

  ret

_main:
  bl _f1
  bl _f2

#--- f2.s

.subsections_via_symbols

.literal16
.p2align 3
L_align16:
.quad 0xffffffffffffffff
.short 0xaaaa
.short 0xaaaa
.space 4, 170

.literal8
.p2align 3
L_align8:
.quad 0xeeeeeeeeeeeeeeee

.literal4
.p2align 2
L_align4:
.short 0xbbbb
.short 0xbbbb

.text
.p2align 2

.globl _f2
_f2:
  adrp x9, L_align16@PAGE + 4
  add x9, x9, L_align16@PAGEOFF + 4
  ldr x10, [x9]

  adrp x9, L_align8@PAGE + 4
  add x9, x9, L_align8@PAGEOFF + 4
  ldr w11, [x9]

  adrp x9, L_align4@PAGE + 2
  add x9, x9, L_align4@PAGEOFF + 2
  ldrh w12, [x9]

  ret