Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / ELF / amdgpu-relocs.s
blobf0a75130d69dc46c95fc63ddbbea64fe49163fa8
1 # REQUIRES: amdgpu
2 # RUN: llvm-mc -filetype=obj -triple=amdgcn--amdhsa -mcpu=fiji %s -o %t.o
3 # RUN: ld.lld --hash-style=sysv -shared %t.o -o %t.so
4 # RUN: llvm-readobj -r %t.so | FileCheck %s
5 # RUN: llvm-nm %t.so | FileCheck %s --check-prefix=NM
6 # RUN: llvm-readelf -x .rodata -x nonalloc %t.so | FileCheck %s --check-prefix=HEX
8 ## ABS64 and RELATIVE64 relocs do not cause --check-dynamic-relocations errors.
9 # RUN: ld.lld --hash-style=sysv -shared %t.o -o /dev/null --apply-dynamic-relocs
11 .text
13 kernel0:
14 s_mov_b32 s0, common_var0@GOTPCREL+4
15 s_mov_b32 s0, common_var1@gotpcrel32@lo+4
16 s_mov_b32 s0, common_var2@gotpcrel32@hi+4
18 s_mov_b32 s0, global_var0@GOTPCREL+4
19 s_mov_b32 s0, global_var1@gotpcrel32@lo+4
20 s_mov_b32 s0, global_var2@gotpcrel32@hi+4
22 s_mov_b32 s0, extern_var0@GOTPCREL+4
23 s_mov_b32 s0, extern_var1@gotpcrel32@lo+4
24 s_mov_b32 s0, extern_var2@gotpcrel32@hi+4
26 s_mov_b32 s0, weak_var0@GOTPCREL+4
27 s_mov_b32 s0, weak_var1@gotpcrel32@lo+4
28 s_mov_b32 s0, weak_var2@gotpcrel32@hi+4
30 s_mov_b32 s0, weakref_var0@GOTPCREL+4
31 s_mov_b32 s0, weakref_var1@gotpcrel32@lo+4
32 s_mov_b32 s0, weakref_var2@gotpcrel32@hi+4
34 s_mov_b32 s0, local_var0+4
35 s_mov_b32 s0, local_var1@rel32@lo+4
36 s_mov_b32 s0, local_var2@rel32@hi+4
38 s_endpgm
40 .comm common_var0,1024,4
41 .comm common_var1,1024,4
42 .comm common_var2,1024,4
43 .globl global_var0
44 .globl global_var1
45 .globl global_var1
46 .weak weak_var0
47 .weak weak_var1
48 .weak weak_var2
49 .weakref weakref_var0, weakref_alias_var0
50 .weakref weakref_var1, weakref_alias_var1
51 .weakref weakref_var2, weakref_alias_var2
52 .local local_var0
53 .local local_var1
54 .local local_var2
55 local_var0:
56 local_var1:
57 local_var2:
59 # R_AMDGPU_ABS32:
60 .section nonalloc, "w", @progbits
61 .long var0, common_var2+4
62 .long var1, common_var1+8
63 .long var2, common_var0+12
65 # R_AMDGPU_ABS64:
66 .type ptr, @object
67 .data
68 .globl ptr
69 .p2align 3
70 ptr:
71 .quad temp
72 .size ptr, 8
74 # R_AMDGPU_RELATIVE64:
75 .type temp2, @object
76 .local temp2
77 .size temp2, 4
78 temp2:
80 .type ptr2, @object
81 .globl ptr2
82 .size ptr2, 8
83 .p2align 3
84 ptr2:
85 .quad temp2
87 # R_AMDGPU_REL64:
88 .type foo, @object
89 .rodata
90 .globl foo
91 .p2align 3
92 foo:
93 .quad temp2@rel64
94 .size foo, 8
96 # The relocation for local_var{0, 1, 2} and var should be resolved by the
97 # linker.
98 # CHECK: Relocations [
99 # CHECK: .rela.dyn {
100 # CHECK-NEXT: R_AMDGPU_RELATIVE64 - 0x3928
101 # CHECK-NEXT: R_AMDGPU_ABS64 common_var0 0x0
102 # CHECK-NEXT: R_AMDGPU_ABS64 common_var1 0x0
103 # CHECK-NEXT: R_AMDGPU_ABS64 common_var2 0x0
104 # CHECK-NEXT: R_AMDGPU_ABS64 global_var0 0x0
105 # CHECK-NEXT: R_AMDGPU_ABS64 global_var1 0x0
106 # CHECK-NEXT: R_AMDGPU_ABS64 global_var2 0x0
107 # CHECK-NEXT: R_AMDGPU_ABS64 extern_var0 0x0
108 # CHECK-NEXT: R_AMDGPU_ABS64 extern_var1 0x0
109 # CHECK-NEXT: R_AMDGPU_ABS64 extern_var2 0x0
110 # CHECK-NEXT: R_AMDGPU_ABS64 weak_var0 0x0
111 # CHECK-NEXT: R_AMDGPU_ABS64 weak_var1 0x0
112 # CHECK-NEXT: R_AMDGPU_ABS64 weak_var2 0x0
113 # CHECK-NEXT: R_AMDGPU_ABS64 weakref_alias_var0 0x0
114 # CHECK-NEXT: R_AMDGPU_ABS64 weakref_alias_var1 0x0
115 # CHECK-NEXT: R_AMDGPU_ABS64 weakref_alias_var2 0x0
116 # CHECK-NEXT: R_AMDGPU_ABS64 temp 0x0
117 # CHECK-NEXT: }
118 # CHECK-NEXT: ]
120 # NM: 0000000000003930 B common_var0
121 # NM: 0000000000003d30 B common_var1
122 # NM: 0000000000004130 B common_var2
123 # NM: 0000000000003928 d temp2
125 # temp2 - foo = 0x3928-0x768 = 0x31c0
126 # HEX: section '.rodata':
127 # HEX-NEXT: 0x00000768 c0310000 00000000
129 # common_var2+4, common_var1+8, and common_var0+12.
130 # HEX: section 'nonalloc':
131 # HEX-NEXT: 0x00000000 00000000 34410000 00000000 383d0000
132 # HEX-NEXT: 0x00000010 00000000 3c390000