2 # RUN: rm -rf %t; split-file %s %t
4 # RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/explicit-selrefs-1.s -o %t/explicit-selrefs-1.o
5 # RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/explicit-selrefs-2.s -o %t/explicit-selrefs-2.o
6 # RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/implicit-selrefs.s -o %t/implicit-selrefs.o
8 # RUN: %lld -dylib -arch arm64 -lSystem -o %t/explicit-only-no-icf \
9 # RUN: %t/explicit-selrefs-1.o %t/explicit-selrefs-2.o
10 # RUN: llvm-otool -vs __DATA __objc_selrefs %t/explicit-only-no-icf | \
11 # RUN: FileCheck %s --check-prefix=EXPLICIT-NO-ICF
13 ## NOTE: ld64 always dedups the selrefs unconditionally, but we only do it when
15 # RUN: %lld -dylib -arch arm64 -lSystem -o %t/explicit-only-with-icf \
16 # RUN: %t/explicit-selrefs-1.o %t/explicit-selrefs-2.o
17 # RUN: llvm-otool -vs __DATA __objc_selrefs %t/explicit-only-with-icf \
18 # RUN: | FileCheck %s --check-prefix=EXPLICIT-WITH-ICF
20 # SELREFS: Contents of (__DATA,__objc_selrefs) section
21 # SELREFS-NEXT: __TEXT:__objc_methname:foo
22 # SELREFS-NEXT: __TEXT:__objc_methname:bar
23 # SELREFS-NEXT: __TEXT:__objc_methname:foo
24 # SELREFS-NEXT: __TEXT:__objc_methname:length
27 ## We don't yet support dedup'ing implicitly-defined selrefs.
28 # RUN: %lld -dylib -arch arm64 -lSystem --icf=all -o %t/explicit-and-implicit \
29 # RUN: %t/explicit-selrefs-1.o %t/explicit-selrefs-2.o %t/implicit-selrefs.o
30 # RUN: llvm-otool -vs __DATA __objc_selrefs %t/explicit-and-implicit \
31 # RUN: | FileCheck %s --check-prefix=EXPLICIT-AND-IMPLICIT
33 # EXPLICIT-NO-ICF: Contents of (__DATA,__objc_selrefs) section
34 # EXPLICIT-NO-ICF-NEXT: __TEXT:__objc_methname:foo
35 # EXPLICIT-NO-ICF-NEXT: __TEXT:__objc_methname:bar
36 # EXPLICIT-NO-ICF-NEXT: __TEXT:__objc_methname:bar
37 # EXPLICIT-NO-ICF-NEXT: __TEXT:__objc_methname:foo
39 # EXPLICIT-WITH-ICF: Contents of (__DATA,__objc_selrefs) section
40 # EXPLICIT-WITH-ICF-NEXT: __TEXT:__objc_methname:foo
41 # EXPLICIT-WITH-ICF-NEXT: __TEXT:__objc_methname:bar
43 # EXPLICIT-AND-IMPLICIT: Contents of (__DATA,__objc_selrefs) section
44 # EXPLICIT-AND-IMPLICIT-NEXT: __TEXT:__objc_methname:foo
45 # EXPLICIT-AND-IMPLICIT-NEXT: __TEXT:__objc_methname:bar
46 # NOTE: Ideally this wouldn't exist, but while it does it needs to point to the deduplicated string
47 # EXPLICIT-AND-IMPLICIT-NEXT: __TEXT:__objc_methname:foo
48 # EXPLICIT-AND-IMPLICIT-NEXT: __TEXT:__objc_methname:length
50 #--- explicit-selrefs-1.s
51 .section __TEXT,__objc_methname,cstring_literals
57 .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip
63 #--- explicit-selrefs-2.s
64 .section __TEXT,__objc_methname,cstring_literals
68 .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip
72 #--- implicit-selrefs.s
81 bl _objc_msgSend$length