1 ; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mattr=-altivec -mtriple powerpc64-ibm-aix-xcoff \
2 ; RUN: -xcoff-traceback-table=false --code-model=large -filetype=obj -o %t.o < %s
3 ; RUN: llvm-readobj --relocs --expand-relocs %t.o | FileCheck -D#NFA=2 --check-prefix=RELOC %s
4 ; RUN: llvm-readobj --syms %t.o | FileCheck -D#NFA=2 --check-prefix=SYM %s
5 ; RUN: llvm-objdump -D -r --symbol-description %t.o | FileCheck -D#NFA=2 --check-prefix=DIS %s
7 @ThreadLocalVarInit = thread_local(localdynamic) global i64 1, align 8
8 @IThreadLocalVarUninit = internal thread_local(localdynamic) global i64 0, align 8
9 @IThreadLocalVarUninit2 = internal thread_local(localdynamic) global i64 0, align 8
10 declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull)
12 define void @storeITLUninit(i64 noundef %x) {
14 %0 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @IThreadLocalVarUninit)
15 store i64 %x, ptr %0, align 8
19 define i64 @loadTLInit() {
21 %0 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @ThreadLocalVarInit)
22 %1 = load i64, ptr %0, align 8
26 define signext i64 @loadTLUninit() {
28 %0 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @IThreadLocalVarUninit)
29 store i64 1, ptr %0, align 8
30 %1 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @IThreadLocalVarUninit2)
31 %2 = load i64, ptr %1, align 8
32 %add = add nsw i64 %2, 1
36 ; RELOC: File: {{.*}}aix-tls-ld-xcoff-reloc-large.ll.tmp.o
37 ; RELOC-NEXT: Format: aix5coff64-rs6000
38 ; RELOC-NEXT: Arch: powerpc64
39 ; RELOC-NEXT: AddressSize: 64bit
40 ; RELOC-NEXT: Relocations [
41 ; RELOC: Virtual Address: 0xE
42 ; RELOC-NEXT: Symbol: _$TLSML ([[#NFA+19]])
43 ; RELOC-NEXT: IsSigned: No
44 ; RELOC-NEXT: FixupBitValue: 0
45 ; RELOC-NEXT: Length: 16
46 ; RELOC-NEXT: Type: R_TOCU (0x30)
48 ; RELOC: Virtual Address: 0x12
49 ; RELOC-NEXT: Symbol: IThreadLocalVarUninit ([[#NFA+21]])
50 ; RELOC-NEXT: IsSigned: No
51 ; RELOC-NEXT: FixupBitValue: 0
52 ; RELOC-NEXT: Length: 16
53 ; RELOC-NEXT: Type: R_TOCU (0x30)
55 ; RELOC: Virtual Address: 0x1A
56 ; RELOC-NEXT: Symbol: _$TLSML ([[#NFA+19]])
57 ; RELOC-NEXT: IsSigned: No
58 ; RELOC-NEXT: FixupBitValue: 0
59 ; RELOC-NEXT: Length: 16
60 ; RELOC-NEXT: Type: R_TOCL (0x31)
62 ; RELOC: Virtual Address: 0x1C
63 ; RELOC-NEXT: Symbol: .__tls_get_mod ([[#NFA+1]])
64 ; RELOC-NEXT: IsSigned: No
65 ; RELOC-NEXT: FixupBitValue: 0
66 ; RELOC-NEXT: Length: 26
67 ; RELOC-NEXT: Type: R_RBA (0x18)
69 ; RELOC: Virtual Address: 0x22
70 ; RELOC-NEXT: Symbol: IThreadLocalVarUninit ([[#NFA+21]])
71 ; RELOC-NEXT: IsSigned: No
72 ; RELOC-NEXT: FixupBitValue: 0
73 ; RELOC-NEXT: Length: 16
74 ; RELOC-NEXT: Type: R_TOCL (0x31)
76 ; RELOC: Virtual Address: 0x4A
77 ; RELOC-NEXT: Symbol: _$TLSML ([[#NFA+19]])
78 ; RELOC-NEXT: IsSigned: No
79 ; RELOC-NEXT: FixupBitValue: 0
80 ; RELOC-NEXT: Length: 16
81 ; RELOC-NEXT: Type: R_TOCU (0x30)
83 ; RELOC: Virtual Address: 0x4E
84 ; RELOC-NEXT: Symbol: ThreadLocalVarInit ([[#NFA+23]])
85 ; RELOC-NEXT: IsSigned: No
86 ; RELOC-NEXT: FixupBitValue: 0
87 ; RELOC-NEXT: Length: 16
88 ; RELOC-NEXT: Type: R_TOCU (0x30)
90 ; RELOC: Virtual Address: 0x56
91 ; RELOC-NEXT: Symbol: _$TLSML ([[#NFA+19]])
92 ; RELOC-NEXT: IsSigned: No
93 ; RELOC-NEXT: FixupBitValue: 0
94 ; RELOC-NEXT: Length: 16
95 ; RELOC-NEXT: Type: R_TOCL (0x31)
97 ; RELOC: Virtual Address: 0x58
98 ; RELOC-NEXT: Symbol: .__tls_get_mod ([[#NFA+1]])
99 ; RELOC-NEXT: IsSigned: No
100 ; RELOC-NEXT: FixupBitValue: 0
101 ; RELOC-NEXT: Length: 26
102 ; RELOC-NEXT: Type: R_RBA (0x18)
104 ; RELOC: Virtual Address: 0x5E
105 ; RELOC-NEXT: Symbol: ThreadLocalVarInit ([[#NFA+23]])
106 ; RELOC-NEXT: IsSigned: No
107 ; RELOC-NEXT: FixupBitValue: 0
108 ; RELOC-NEXT: Length: 16
109 ; RELOC-NEXT: Type: R_TOCL (0x31)
111 ; RELOC: Virtual Address: 0x8A
112 ; RELOC-NEXT: Symbol: _$TLSML ([[#NFA+19]])
113 ; RELOC-NEXT: IsSigned: No
114 ; RELOC-NEXT: FixupBitValue: 0
115 ; RELOC-NEXT: Length: 16
116 ; RELOC-NEXT: Type: R_TOCU (0x30)
118 ; RELOC: Virtual Address: 0x8E
119 ; RELOC-NEXT: Symbol: IThreadLocalVarUninit ([[#NFA+21]])
120 ; RELOC-NEXT: IsSigned: No
121 ; RELOC-NEXT: FixupBitValue: 0
122 ; RELOC-NEXT: Length: 16
123 ; RELOC-NEXT: Type: R_TOCU (0x30)
125 ; RELOC: Virtual Address: 0x96
126 ; RELOC-NEXT: Symbol: _$TLSML ([[#NFA+19]])
127 ; RELOC-NEXT: IsSigned: No
128 ; RELOC-NEXT: FixupBitValue: 0
129 ; RELOC-NEXT: Length: 16
130 ; RELOC-NEXT: Type: R_TOCL (0x31)
132 ; RELOC: Virtual Address: 0x98
133 ; RELOC-NEXT: Symbol: .__tls_get_mod (3)
134 ; RELOC-NEXT: IsSigned: No
135 ; RELOC-NEXT: FixupBitValue: 0
136 ; RELOC-NEXT: Length: 26
137 ; RELOC-NEXT: Type: R_RBA (0x18)
139 ; RELOC: Virtual Address: 0x9E
140 ; RELOC-NEXT: Symbol: IThreadLocalVarUninit ([[#NFA+21]])
141 ; RELOC-NEXT: IsSigned: No
142 ; RELOC-NEXT: FixupBitValue: 0
143 ; RELOC-NEXT: Length: 16
144 ; RELOC-NEXT: Type: R_TOCL (0x31)
146 ; RELOC: Virtual Address: 0xAA
147 ; RELOC-NEXT: Symbol: IThreadLocalVarUninit2 ([[#NFA+25]])
148 ; RELOC-NEXT: IsSigned: No
149 ; RELOC-NEXT: FixupBitValue: 0
150 ; RELOC-NEXT: Length: 16
151 ; RELOC-NEXT: Type: R_TOCU (0x30)
153 ; RELOC: Virtual Address: 0xAE
154 ; RELOC-NEXT: Symbol: IThreadLocalVarUninit2 ([[#NFA+25]])
155 ; RELOC-NEXT: IsSigned: No
156 ; RELOC-NEXT: FixupBitValue: 0
157 ; RELOC-NEXT: Length: 16
158 ; RELOC-NEXT: Type: R_TOCL (0x31)
160 ; RELOC: Virtual Address: 0x110
161 ; RELOC-NEXT: Symbol: _$TLSML ([[#NFA+19]])
162 ; RELOC-NEXT: IsSigned: No
163 ; RELOC-NEXT: FixupBitValue: 0
164 ; RELOC-NEXT: Length: 64
165 ; RELOC-NEXT: Type: R_TLSML (0x25)
167 ; RELOC: Virtual Address: 0x118
168 ; RELOC-NEXT: Symbol: IThreadLocalVarUninit ([[#NFA+29]])
169 ; RELOC-NEXT: IsSigned: No
170 ; RELOC-NEXT: FixupBitValue: 0
171 ; RELOC-NEXT: Length: 64
172 ; RELOC-NEXT: Type: R_TLS_LD (0x22)
174 ; RELOC: Virtual Address: 0x120
175 ; RELOC-NEXT: Symbol: ThreadLocalVarInit ([[#NFA+27]])
176 ; RELOC-NEXT: IsSigned: No
177 ; RELOC-NEXT: FixupBitValue: 0
178 ; RELOC-NEXT: Length: 64
179 ; RELOC-NEXT: Type: R_TLS_LD (0x22)
181 ; RELOC: Virtual Address: 0x128
182 ; RELOC-NEXT: Symbol: IThreadLocalVarUninit2 ([[#NFA+31]])
183 ; RELOC-NEXT: IsSigned: No
184 ; RELOC-NEXT: FixupBitValue: 0
185 ; RELOC-NEXT: Length: 64
186 ; RELOC-NEXT: Type: R_TLS_LD (0x22)
189 ; SYM: File: {{.*}}aix-tls-ld-xcoff-reloc-large.ll.tmp.o
190 ; SYM-NEXT: Format: aix5coff64-rs6000
191 ; SYM-NEXT: Arch: powerpc64
192 ; SYM-NEXT: AddressSize: 64bit
193 ; SYM-NEXT: Symbols [
194 ; SYM: Index: [[#NFA+19]]
195 ; SYM-NEXT: Name: _$TLSML
196 ; SYM-NEXT: Value (RelocatableAddress): 0x110
197 ; SYM-NEXT: Section: .data
198 ; SYM-NEXT: Type: 0x0
199 ; SYM-NEXT: StorageClass: C_HIDEXT (0x6B)
200 ; SYM-NEXT: NumberOfAuxEntries: 1
201 ; SYM-NEXT: CSECT Auxiliary Entry {
202 ; SYM-NEXT: Index: [[#NFA+20]]
203 ; SYM-NEXT: SectionLen: 8
204 ; SYM-NEXT: ParameterHashIndex: 0x0
205 ; SYM-NEXT: TypeChkSectNum: 0x0
206 ; SYM-NEXT: SymbolAlignmentLog2: 3
207 ; SYM-NEXT: SymbolType: XTY_SD (0x1)
208 ; SYM-NEXT: StorageMappingClass: XMC_TC (0x3)
209 ; SYM-NEXT: Auxiliary Type: AUX_CSECT (0xFB)
212 ; SYM: Index: [[#NFA+21]]
213 ; SYM-NEXT: Name: IThreadLocalVarUninit
214 ; SYM-NEXT: Value (RelocatableAddress): 0x118
215 ; SYM-NEXT: Section: .data
216 ; SYM-NEXT: Type: 0x0
217 ; SYM-NEXT: StorageClass: C_HIDEXT (0x6B)
218 ; SYM-NEXT: NumberOfAuxEntries: 1
219 ; SYM-NEXT: CSECT Auxiliary Entry {
220 ; SYM-NEXT: Index: [[#NFA+22]]
221 ; SYM-NEXT: SectionLen: 8
222 ; SYM-NEXT: ParameterHashIndex: 0x0
223 ; SYM-NEXT: TypeChkSectNum: 0x0
224 ; SYM-NEXT: SymbolAlignmentLog2: 3
225 ; SYM-NEXT: SymbolType: XTY_SD (0x1)
226 ; SYM-NEXT: StorageMappingClass: XMC_TE (0x16)
227 ; SYM-NEXT: Auxiliary Type: AUX_CSECT (0xFB)
230 ; SYM: Index: [[#NFA+23]]
231 ; SYM-NEXT: Name: ThreadLocalVarInit
232 ; SYM-NEXT: Value (RelocatableAddress): 0x120
233 ; SYM-NEXT: Section: .data
234 ; SYM-NEXT: Type: 0x0
235 ; SYM-NEXT: StorageClass: C_HIDEXT (0x6B)
236 ; SYM-NEXT: NumberOfAuxEntries: 1
237 ; SYM-NEXT: CSECT Auxiliary Entry {
238 ; SYM-NEXT: Index: [[#NFA+24]]
239 ; SYM-NEXT: SectionLen: 8
240 ; SYM-NEXT: ParameterHashIndex: 0x0
241 ; SYM-NEXT: TypeChkSectNum: 0x0
242 ; SYM-NEXT: SymbolAlignmentLog2: 3
243 ; SYM-NEXT: SymbolType: XTY_SD (0x1)
244 ; SYM-NEXT: StorageMappingClass: XMC_TE (0x16)
245 ; SYM-NEXT: Auxiliary Type: AUX_CSECT (0xFB)
248 ; SYM: Index: [[#NFA+25]]
249 ; SYM-NEXT: Name: IThreadLocalVarUninit2
250 ; SYM-NEXT: Value (RelocatableAddress): 0x128
251 ; SYM-NEXT: Section: .data
252 ; SYM-NEXT: Type: 0x0
253 ; SYM-NEXT: StorageClass: C_HIDEXT (0x6B)
254 ; SYM-NEXT: NumberOfAuxEntries: 1
255 ; SYM-NEXT: CSECT Auxiliary Entry {
256 ; SYM-NEXT: Index: [[#NFA+26]]
257 ; SYM-NEXT: SectionLen: 8
258 ; SYM-NEXT: ParameterHashIndex: 0x0
259 ; SYM-NEXT: TypeChkSectNum: 0x0
260 ; SYM-NEXT: SymbolAlignmentLog2: 3
261 ; SYM-NEXT: SymbolType: XTY_SD (0x1)
262 ; SYM-NEXT: StorageMappingClass: XMC_TE (0x16)
263 ; SYM-NEXT: Auxiliary Type: AUX_CSECT (0xFB)
266 ; SYM: Index: [[#NFA+27]]
267 ; SYM-NEXT: Name: ThreadLocalVarInit
268 ; SYM-NEXT: Value (RelocatableAddress): 0x0
269 ; SYM-NEXT: Section: .tdata
270 ; SYM-NEXT: Type: 0x0
271 ; SYM-NEXT: StorageClass: C_EXT (0x2)
272 ; SYM-NEXT: NumberOfAuxEntries: 1
273 ; SYM-NEXT: CSECT Auxiliary Entry {
274 ; SYM-NEXT: Index: [[#NFA+28]]
275 ; SYM-NEXT: SectionLen: 8
276 ; SYM-NEXT: ParameterHashIndex: 0x0
277 ; SYM-NEXT: TypeChkSectNum: 0x0
278 ; SYM-NEXT: SymbolAlignmentLog2: 3
279 ; SYM-NEXT: SymbolType: XTY_SD (0x1)
280 ; SYM-NEXT: StorageMappingClass: XMC_TL (0x14)
281 ; SYM-NEXT: Auxiliary Type: AUX_CSECT (0xFB)
284 ; SYM: Index: [[#NFA+29]]
285 ; SYM-NEXT: Name: IThreadLocalVarUninit
286 ; SYM-NEXT: Value (RelocatableAddress): 0x8
287 ; SYM-NEXT: Section: .tbss
288 ; SYM-NEXT: Type: 0x0
289 ; SYM-NEXT: StorageClass: C_HIDEXT (0x6B)
290 ; SYM-NEXT: NumberOfAuxEntries: 1
291 ; SYM-NEXT: CSECT Auxiliary Entry {
292 ; SYM-NEXT: Index: [[#NFA+30]]
293 ; SYM-NEXT: SectionLen: 8
294 ; SYM-NEXT: ParameterHashIndex: 0x0
295 ; SYM-NEXT: TypeChkSectNum: 0x0
296 ; SYM-NEXT: SymbolAlignmentLog2: 3
297 ; SYM-NEXT: SymbolType: XTY_CM (0x3)
298 ; SYM-NEXT: StorageMappingClass: XMC_UL (0x15)
299 ; SYM-NEXT: Auxiliary Type: AUX_CSECT (0xFB)
302 ; SYM: Index: [[#NFA+31]]
303 ; SYM-NEXT: Name: IThreadLocalVarUninit2
304 ; SYM-NEXT: Value (RelocatableAddress): 0x10
305 ; SYM-NEXT: Section: .tbss
306 ; SYM-NEXT: Type: 0x0
307 ; SYM-NEXT: StorageClass: C_HIDEXT (0x6B)
308 ; SYM-NEXT: NumberOfAuxEntries: 1
309 ; SYM-NEXT: CSECT Auxiliary Entry {
310 ; SYM-NEXT: Index: [[#NFA+32]]
311 ; SYM-NEXT: SectionLen: 8
312 ; SYM-NEXT: ParameterHashIndex: 0x0
313 ; SYM-NEXT: TypeChkSectNum: 0x0
314 ; SYM-NEXT: SymbolAlignmentLog2: 3
315 ; SYM-NEXT: SymbolType: XTY_CM (0x3)
316 ; SYM-NEXT: StorageMappingClass: XMC_UL (0x15)
317 ; SYM-NEXT: Auxiliary Type: AUX_CSECT (0xFB)
321 ; DIS: {{.*}}aix-tls-ld-xcoff-reloc-large.ll.tmp.o: file format aix5coff64-rs6000
322 ; DIS: Disassembly of section .data:
323 ; DIS: 0000000000000110 (idx: [[#NFA+19]]) _$TLSML[TC]:
324 ; DIS-NEXT: 110: 00 00 00 00
325 ; DIS-NEXT: 0000000000000110: R_TLSML (idx: [[#NFA+19]]) _$TLSML[TC]
326 ; DIS-NEXT: 114: 00 00 00 00
327 ; DIS: 0000000000000118 (idx: [[#NFA+21]]) IThreadLocalVarUninit[TE]:
328 ; DIS-NEXT: 118: 00 00 00 00
329 ; DIS-NEXT: 0000000000000118: R_TLS_LD (idx: [[#NFA+29]]) IThreadLocalVarUninit[UL]
330 ; DIS-NEXT: 11c: 00 00 00 08
331 ; DIS: 0000000000000120 (idx: [[#NFA+23]]) ThreadLocalVarInit[TE]:
332 ; DIS-NEXT: 120: 00 00 00 00
333 ; DIS-NEXT: 0000000000000120: R_TLS_LD (idx: [[#NFA+27]]) ThreadLocalVarInit[TL]
334 ; DIS-NEXT: 124: 00 00 00 00
335 ; DIS: 0000000000000128 (idx: [[#NFA+25]]) IThreadLocalVarUninit2[TE]:
336 ; DIS-NEXT: 128: 00 00 00 00
337 ; DIS-NEXT: 0000000000000128: R_TLS_LD (idx: [[#NFA+31]]) IThreadLocalVarUninit2[UL]
338 ; DIS-NEXT: 12c: 00 00 00 10
340 ; DIS: Disassembly of section .tdata:
341 ; DIS: 0000000000000000 (idx: [[#NFA+27]]) ThreadLocalVarInit[TL]:
342 ; DIS-NEXT: 0: 00 00 00 00
343 ; DIS-NEXT: 4: 00 00 00 01
345 ; DIS: Disassembly of section .tbss:
346 ; DIS: 0000000000000008 (idx: [[#NFA+29]]) IThreadLocalVarUninit[UL]:
348 ; DIS: 0000000000000010 (idx: [[#NFA+31]]) IThreadLocalVarUninit2[UL]: