Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / MachO / cstring-dedup.s
bloba4b15f26afff0bedef196e05b11fd3f42d2c296f
1 # REQUIRES: x86
2 # RUN: rm -rf %t; split-file %s %t
3 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
4 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/more-foo.s -o %t/more-foo.o
5 # RUN: %lld -dylib %t/test.o %t/more-foo.o -o %t/test
6 # RUN: llvm-objdump --macho --section="__TEXT,__cstring" %t/test | \
7 # RUN: FileCheck %s --check-prefix=STR --implicit-check-not foo --implicit-check-not bar
8 # RUN: llvm-objdump --macho --section="__DATA,ptrs" --syms %t/test | FileCheck %s
9 # RUN: llvm-readobj --section-headers %t/test | FileCheck %s --check-prefix=HEADER
11 ## Make sure we only have 3 deduplicated strings in __cstring.
12 # STR: Contents of (__TEXT,__cstring) section
13 # STR: {{[[:xdigit:]]+}} foo
14 # STR: {{[[:xdigit:]]+}} barbaz
15 # STR: {{[[:xdigit:]]+}} {{$}}
17 ## Make sure both symbol and section relocations point to the right thing.
18 # CHECK: Contents of (__DATA,ptrs) section
19 # CHECK-NEXT: __TEXT:__cstring:foo
20 # CHECK-NEXT: __TEXT:__cstring:foo
21 # CHECK-NEXT: __TEXT:__cstring:foo
22 # CHECK-NEXT: __TEXT:__cstring:foo
23 # CHECK-NEXT: __TEXT:__cstring:foo
24 # CHECK-NEXT: __TEXT:__cstring:foo
25 # CHECK-NEXT: __TEXT:__cstring:barbaz
26 # CHECK-NEXT: __TEXT:__cstring:baz
27 # CHECK-NEXT: __TEXT:__cstring:barbaz
28 # CHECK-NEXT: __TEXT:__cstring:baz
29 # CHECK-NEXT: __TEXT:__cstring:{{$}}
30 # CHECK-NEXT: __TEXT:__cstring:{{$}}
32 ## Make sure the symbol addresses are correct too.
33 # CHECK: SYMBOL TABLE:
34 # CHECK-DAG: [[#%.16x,FOO:]] l O __TEXT,__cstring _local_foo1
35 # CHECK-DAG: [[#FOO]] l O __TEXT,__cstring _local_foo2
36 # CHECK-DAG: [[#FOO]] g O __TEXT,__cstring _globl_foo1
37 # CHECK-DAG: [[#FOO]] g O __TEXT,__cstring _globl_foo2
38 # CHECK-DAG: [[#%.16x,BAR:]] l O __TEXT,__cstring _bar1
39 # CHECK-DAG: [[#BAR]] l O __TEXT,__cstring _bar2
40 # CHECK-DAG: [[#%.16x,ZERO:]] l O __TEXT,__cstring _zero1
41 # CHECK-DAG: [[#ZERO]] l O __TEXT,__cstring _zero2
43 ## Make sure we set the right alignment and flags.
44 # HEADER: Name: __cstring
45 # HEADER-NEXT: Segment: __TEXT
46 # HEADER-NEXT: Address:
47 # HEADER-NEXT: Size:
48 # HEADER-NEXT: Offset:
49 # HEADER-NEXT: Alignment: 4
50 # HEADER-NEXT: RelocationOffset:
51 # HEADER-NEXT: RelocationCount: 0
52 # HEADER-NEXT: Type: CStringLiterals
53 # HEADER-NEXT: Attributes [ (0x0)
54 # HEADER-NEXT: ]
55 # HEADER-NEXT: Reserved1: 0x0
56 # HEADER-NEXT: Reserved2: 0x0
57 # HEADER-NEXT: Reserved3: 0x0
59 #--- test.s
60 .cstring
61 .p2align 2
62 _local_foo1:
63 .asciz "foo"
64 _local_foo2:
65 .asciz "foo"
66 L_.foo1:
67 .asciz "foo"
68 L_.foo2:
69 .asciz "foo"
71 _bar1:
72 .ascii "bar"
73 _baz1:
74 .asciz "baz"
75 _bar2:
76 .ascii "bar"
77 _baz2:
78 .asciz "baz"
80 _zero1:
81 .asciz ""
82 _zero2:
83 .asciz ""
85 .section __DATA,ptrs,literal_pointers
86 .quad L_.foo1
87 .quad L_.foo2
88 .quad _local_foo1
89 .quad _local_foo2
90 .quad _globl_foo1
91 .quad _globl_foo2
92 .quad _bar1
93 .quad _baz1
94 .quad _bar2
95 .quad _baz2
96 .quad _zero1
97 .quad _zero2
99 #--- more-foo.s
100 .globl _globl_foo1, _globl_foo2
101 .cstring
102 .p2align 4
103 _globl_foo1:
104 .asciz "foo"
105 _globl_foo2:
106 .asciz "foo"