1# REQUIRES: x86
2# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
3# RUN: ld.lld %t.o -o /dev/null --keep-unique fu --icf=all --print-icf-sections | FileCheck %s
4
5## Check that ICF is able to merge equivalent sections with relocations to
6## different symbols, e.g. aliases, that refer to the same section which is
7## ineligible for ICF.
8
9# CHECK: selected section {{.*}}:(.text.f1)
10# CHECK:   removing identical section {{.*}}:(.text.f2)
11# CHECK:   removing identical section {{.*}}:(.text.f3)
12# CHECK: selected section {{.*}}:(.text.f4)
13# CHECK:   removing identical section {{.*}}:(.text.f5)
14
15.globl d, d_alias, fu, f1, f2, f3, f4, f5
16
17.section .data.d,"aw",@progbits
18d:
19d_alias:
20.long 42
21
22.section .text.fu,"ax",@progbits
23fu:
24  nop
25
26.section .text.f1,"ax",@progbits
27f1:
28.quad d
29
30.section .text.f2,"ax",@progbits
31f2:
32.quad d_alias
33
34.section .text.f3,"ax",@progbits
35f3:
36.quad .data.d
37
38.section .text.f4,"ax",@progbits
39f4:
40.quad fu
41
42.section .text.f5,"ax",@progbits
43f5:
44.quad .text.fu
45