Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / MachO / literal-dedup.s
blob9fb51edf4d4274b536e19715c8c584169029049a
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/qux.s -o %t/qux.o
5 # RUN: %lld -dylib %t/test.o %t/qux.o -o %t/test
6 # RUN: llvm-objdump --macho --section="__TEXT,__literals" --section="__DATA,ptrs" --syms %t/test | FileCheck %s
7 # RUN: llvm-readobj --section-headers %t/test | FileCheck %s --check-prefix=HEADER
9 # RUN: %lld -dylib -no_deduplicate %t/test.o %t/qux.o -o %t/test
10 # RUN: llvm-objdump --macho --section="__TEXT,__literals" --section="__DATA,ptrs" --syms %t/test | FileCheck %s
11 # RUN: llvm-readobj --section-headers %t/test | FileCheck %s --check-prefix=HEADER
13 # CHECK: Contents of (__TEXT,__literals) section
14 # CHECK-NEXT: [[#%.16x,DEADBEEF16:]] ef be ad de ef be ad de ef be ad de ef be ad de
15 # CHECK-NEXT: [[#%.16x,FEEDFACE16:]] ce fa ed fe ce fa ed fe ce fa ed fe ce fa ed fe
16 # CHECK-NEXT: [[#%.16x,DEADBEEF8:]] ef be ad de ef be ad de ce fa ed fe ce fa ed fe
17 # CHECK-NEXT: [[#%.16x,DEADBEEF4:]] ef be ad de ce fa ed fe
18 # CHECK-NEXT: Contents of (__DATA,ptrs) section
19 # CHECK-NEXT: 0000000000001000 0x[[#%x,DEADBEEF16]]
20 # CHECK-NEXT: 0000000000001008 0x[[#%x,DEADBEEF16]]
21 # CHECK-NEXT: 0000000000001010 0x[[#%x,FEEDFACE16]]
22 # CHECK-NEXT: 0000000000001018 0x[[#%x,DEADBEEF16]]
23 # CHECK-NEXT: 0000000000001020 0x[[#%x,DEADBEEF8]]
24 # CHECK-NEXT: 0000000000001028 0x[[#%x,DEADBEEF8]]
25 # CHECK-NEXT: 0000000000001030 0x[[#%x,DEADBEEF8 + 8]]
26 # CHECK-NEXT: 0000000000001038 0x[[#%x,DEADBEEF8]]
27 # CHECK-NEXT: 0000000000001040 0x[[#%x,DEADBEEF4]]
28 # CHECK-NEXT: 0000000000001048 0x[[#%x,DEADBEEF4]]
29 # CHECK-NEXT: 0000000000001050 0x[[#%x,DEADBEEF4 + 4]]
30 # CHECK-NEXT: 0000000000001058 0x[[#%x,DEADBEEF4]]
32 ## Make sure the symbol addresses are correct too.
33 # CHECK: SYMBOL TABLE:
34 # CHECK-DAG: [[#DEADBEEF16]] g O __TEXT,__literals _qux16
35 # CHECK-DAG: [[#DEADBEEF8]] g O __TEXT,__literals _qux8
36 # CHECK-DAG: [[#DEADBEEF4]] g O __TEXT,__literals _qux4
38 ## Make sure we set the right alignment and flags.
39 # HEADER: Name: __literals
40 # HEADER-NEXT: Segment: __TEXT
41 # HEADER-NEXT: Address:
42 # HEADER-NEXT: Size:
43 # HEADER-NEXT: Offset:
44 # HEADER-NEXT: Alignment: 4
45 # HEADER-NEXT: RelocationOffset:
46 # HEADER-NEXT: RelocationCount: 0
47 # HEADER-NEXT: Type: Regular
48 # HEADER-NEXT: Attributes [ (0x0)
49 # HEADER-NEXT: ]
50 # HEADER-NEXT: Reserved1: 0x0
51 # HEADER-NEXT: Reserved2: 0x0
52 # HEADER-NEXT: Reserved3: 0x0
54 #--- test.s
55 .literal4
56 .p2align 2
57 L._foo4:
58 .long 0xdeadbeef
59 L._bar4:
60 .long 0xdeadbeef
61 L._baz4:
62 .long 0xfeedface
64 .literal8
65 L._foo8:
66 .quad 0xdeadbeefdeadbeef
67 L._bar8:
68 .quad 0xdeadbeefdeadbeef
69 L._baz8:
70 .quad 0xfeedfacefeedface
72 .literal16
73 L._foo16:
74 .quad 0xdeadbeefdeadbeef
75 .quad 0xdeadbeefdeadbeef
76 L._bar16:
77 .quad 0xdeadbeefdeadbeef
78 .quad 0xdeadbeefdeadbeef
79 L._baz16:
80 .quad 0xfeedfacefeedface
81 .quad 0xfeedfacefeedface
83 .section __DATA,ptrs,literal_pointers
84 .quad L._foo16
85 .quad L._bar16
86 .quad L._baz16
87 .quad _qux16
89 .quad L._foo8
90 .quad L._bar8
91 .quad L._baz8
92 .quad _qux8
94 .quad L._foo4
95 .quad L._bar4
96 .quad L._baz4
97 .quad _qux4
99 #--- qux.s
100 .globl _qux4, _qux8, _qux16
102 .literal4
103 .p2align 2
104 _qux4:
105 .long 0xdeadbeef
107 .literal8
108 _qux8:
109 .quad 0xdeadbeefdeadbeef
111 .literal16
112 _qux16:
113 .quad 0xdeadbeefdeadbeef
114 .quad 0xdeadbeefdeadbeef