1 ; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mattr=-altivec -mtriple powerpc64-ibm-aix-xcoff \
2 ; RUN: -xcoff-traceback-table=false -data-sections=false -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(localexec) global i32 1, align 4
8 @VarInit = global i32 87, align 4
9 @IThreadLocalVarUninit = internal thread_local(localexec) global i32 0, align 4
10 @IThreadLocalVarUninit2 = internal thread_local(localexec) global i32 0, align 4
11 declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull)
13 define void @storeITLUninit(i32 noundef signext %x) {
15 %0 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @IThreadLocalVarUninit)
16 store i32 %x, ptr %0, align 4
20 define signext i32 @loadTLInit() {
22 %0 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @ThreadLocalVarInit)
23 %1 = load i32, ptr %0, align 4
24 %2 = load i32, ptr @VarInit, align 4
25 %add = add nsw i32 %2, %1
29 define signext i32 @loadTLUninit() {
31 %0 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @IThreadLocalVarUninit)
32 store i32 1, ptr %0, align 4
33 %1 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @IThreadLocalVarUninit2)
34 %2 = load i32, ptr %1, align 4
35 %add = add nsw i32 %2, 1
40 ; RELOC-NEXT: Format: aix5coff64-rs6000
41 ; RELOC-NEXT: Arch: powerpc64
42 ; RELOC-NEXT: AddressSize: 64bit
43 ; RELOC-NEXT: Relocations [
44 ; RELOC: Virtual Address: 0x2
45 ; RELOC-NEXT: Symbol: IThreadLocalVarUninit ([[#NFA+21]])
46 ; RELOC-NEXT: IsSigned: No
47 ; RELOC-NEXT: FixupBitValue: 0
48 ; RELOC-NEXT: Length: 16
49 ; RELOC-NEXT: Type: R_TOC (0x3)
51 ; RELOC: Virtual Address: 0x12
52 ; RELOC-NEXT: Symbol: ThreadLocalVarInit ([[#NFA+23]])
53 ; RELOC-NEXT: IsSigned: No
54 ; RELOC-NEXT: FixupBitValue: 0
55 ; RELOC-NEXT: Length: 16
56 ; RELOC-NEXT: Type: R_TOC (0x3)
58 ; RELOC: Virtual Address: 0x3E
59 ; RELOC-NEXT: Symbol: IThreadLocalVarUninit2 ([[#NFA+27]])
60 ; RELOC-NEXT: IsSigned: No
61 ; RELOC-NEXT: FixupBitValue: 0
62 ; RELOC-NEXT: Length: 16
63 ; RELOC-NEXT: Type: R_TOC (0x3)
65 ; RELOC: Virtual Address: 0xA0
66 ; RELOC-NEXT: Symbol: IThreadLocalVarUninit ([[#NFA+33]])
67 ; RELOC-NEXT: IsSigned: No
68 ; RELOC-NEXT: FixupBitValue: 0
69 ; RELOC-NEXT: Length: 64
70 ; RELOC-NEXT: Type: R_TLS_LE (0x23)
72 ; RELOC: Virtual Address: 0xA8
73 ; RELOC-NEXT: Symbol: ThreadLocalVarInit ([[#NFA+31]])
74 ; RELOC-NEXT: IsSigned: No
75 ; RELOC-NEXT: FixupBitValue: 0
76 ; RELOC-NEXT: Length: 64
77 ; RELOC-NEXT: Type: R_TLS_LE (0x23)
79 ; RELOC: Virtual Address: 0xB8
80 ; RELOC-NEXT: Symbol: IThreadLocalVarUninit2 ([[#NFA+35]])
81 ; RELOC-NEXT: IsSigned: No
82 ; RELOC-NEXT: FixupBitValue: 0
83 ; RELOC-NEXT: Length: 64
84 ; RELOC-NEXT: Type: R_TLS_LE (0x23)
88 ; SYM-NEXT: Format: aix5coff64-rs6000
89 ; SYM-NEXT: Arch: powerpc64
90 ; SYM-NEXT: AddressSize: 64bit
92 ; SYM: Index: [[#NFA+21]]
93 ; SYM-NEXT: Name: IThreadLocalVarUninit
94 ; SYM-NEXT: Value (RelocatableAddress): 0xA0
95 ; SYM-NEXT: Section: .data
97 ; SYM-NEXT: StorageClass: C_HIDEXT (0x6B)
98 ; SYM-NEXT: NumberOfAuxEntries: 1
99 ; SYM-NEXT: CSECT Auxiliary Entry {
100 ; SYM-NEXT: Index: [[#NFA+22]]
101 ; SYM-NEXT: SectionLen: 8
102 ; SYM-NEXT: ParameterHashIndex: 0x0
103 ; SYM-NEXT: TypeChkSectNum: 0x0
104 ; SYM-NEXT: SymbolAlignmentLog2: 3
105 ; SYM-NEXT: SymbolType: XTY_SD (0x1)
106 ; SYM-NEXT: StorageMappingClass: XMC_TC (0x3)
107 ; SYM-NEXT: Auxiliary Type: AUX_CSECT (0xFB)
110 ; SYM: Index: [[#NFA+23]]
111 ; SYM-NEXT: Name: ThreadLocalVarInit
112 ; SYM-NEXT: Value (RelocatableAddress): 0xA8
113 ; SYM-NEXT: Section: .data
114 ; SYM-NEXT: Type: 0x0
115 ; SYM-NEXT: StorageClass: C_HIDEXT (0x6B)
116 ; SYM-NEXT: NumberOfAuxEntries: 1
117 ; SYM-NEXT: CSECT Auxiliary Entry {
118 ; SYM-NEXT: Index: [[#NFA+24]]
119 ; SYM-NEXT: SectionLen: 8
120 ; SYM-NEXT: ParameterHashIndex: 0x0
121 ; SYM-NEXT: TypeChkSectNum: 0x0
122 ; SYM-NEXT: SymbolAlignmentLog2: 3
123 ; SYM-NEXT: SymbolType: XTY_SD (0x1)
124 ; SYM-NEXT: StorageMappingClass: XMC_TC (0x3)
125 ; SYM-NEXT: Auxiliary Type: AUX_CSECT (0xFB)
128 ; SYM: Index: [[#NFA+27]]
129 ; SYM-NEXT: Name: IThreadLocalVarUninit2
130 ; SYM-NEXT: Value (RelocatableAddress): 0xB8
131 ; SYM-NEXT: Section: .data
132 ; SYM-NEXT: Type: 0x0
133 ; SYM-NEXT: StorageClass: C_HIDEXT (0x6B)
134 ; SYM-NEXT: NumberOfAuxEntries: 1
135 ; SYM-NEXT: CSECT Auxiliary Entry {
136 ; SYM-NEXT: Index: [[#NFA+28]]
137 ; SYM-NEXT: SectionLen: 8
138 ; SYM-NEXT: ParameterHashIndex: 0x0
139 ; SYM-NEXT: TypeChkSectNum: 0x0
140 ; SYM-NEXT: SymbolAlignmentLog2: 3
141 ; SYM-NEXT: SymbolType: XTY_SD (0x1)
142 ; SYM-NEXT: StorageMappingClass: XMC_TC (0x3)
143 ; SYM-NEXT: Auxiliary Type: AUX_CSECT (0xFB)
146 ; SYM: Index: [[#NFA+31]]
147 ; SYM-NEXT: Name: ThreadLocalVarInit
148 ; SYM-NEXT: Value (RelocatableAddress): 0x0
149 ; SYM-NEXT: Section: .tdata
150 ; SYM-NEXT: Type: 0x0
151 ; SYM-NEXT: StorageClass: C_EXT (0x2)
152 ; SYM-NEXT: NumberOfAuxEntries: 1
153 ; SYM-NEXT: CSECT Auxiliary Entry {
154 ; SYM-NEXT: Index: [[#NFA+32]]
155 ; SYM-NEXT: ContainingCsectSymbolIndex: [[#NFA+29]]
156 ; SYM-NEXT: ParameterHashIndex: 0x0
157 ; SYM-NEXT: TypeChkSectNum: 0x0
158 ; SYM-NEXT: SymbolAlignmentLog2: 0
159 ; SYM-NEXT: SymbolType: XTY_LD (0x2)
160 ; SYM-NEXT: StorageMappingClass: XMC_TL (0x14)
161 ; SYM-NEXT: Auxiliary Type: AUX_CSECT (0xFB)
164 ; SYM: Index: [[#NFA+33]]
165 ; SYM-NEXT: Name: IThreadLocalVarUninit
166 ; SYM-NEXT: Value (RelocatableAddress): 0x4
167 ; SYM-NEXT: Section: .tbss
168 ; SYM-NEXT: Type: 0x0
169 ; SYM-NEXT: StorageClass: C_HIDEXT (0x6B)
170 ; SYM-NEXT: NumberOfAuxEntries: 1
171 ; SYM-NEXT: CSECT Auxiliary Entry {
172 ; SYM-NEXT: Index: [[#NFA+34]]
173 ; SYM-NEXT: SectionLen: 4
174 ; SYM-NEXT: ParameterHashIndex: 0x0
175 ; SYM-NEXT: TypeChkSectNum: 0x0
176 ; SYM-NEXT: SymbolAlignmentLog2: 2
177 ; SYM-NEXT: SymbolType: XTY_CM (0x3)
178 ; SYM-NEXT: StorageMappingClass: XMC_UL (0x15)
179 ; SYM-NEXT: Auxiliary Type: AUX_CSECT (0xFB)
182 ; SYM: Index: [[#NFA+35]]
183 ; SYM-NEXT: Name: IThreadLocalVarUninit2
184 ; SYM-NEXT: Value (RelocatableAddress): 0x8
185 ; SYM-NEXT: Section: .tbss
186 ; SYM-NEXT: Type: 0x0
187 ; SYM-NEXT: StorageClass: C_HIDEXT (0x6B)
188 ; SYM-NEXT: NumberOfAuxEntries: 1
189 ; SYM-NEXT: CSECT Auxiliary Entry {
190 ; SYM-NEXT: Index: [[#NFA+36]]
191 ; SYM-NEXT: SectionLen: 4
192 ; SYM-NEXT: ParameterHashIndex: 0x0
193 ; SYM-NEXT: TypeChkSectNum: 0x0
194 ; SYM-NEXT: SymbolAlignmentLog2: 2
195 ; SYM-NEXT: SymbolType: XTY_CM (0x3)
196 ; SYM-NEXT: StorageMappingClass: XMC_UL (0x15)
197 ; SYM-NEXT: Auxiliary Type: AUX_CSECT (0xFB)
201 ; DIS: file format aix5coff64-rs6000
202 ; DIS: Disassembly of section .text:
203 ; DIS: 0000000000000000 (idx: [[#NFA+3]]) .storeITLUninit:
204 ; DIS-NEXT: [[#%x, ADDR:]]: {{.*}} ld 4, 0(2)
205 ; DIS-NEXT: {{0*}}[[#ADDR + 2]]: R_TOC (idx: [[#NFA+21]]) IThreadLocalVarUninit[TC]
206 ; DIS-NEXT: [[#%x, ADDR:]]: {{.*}} stwx 3, 13, 4
208 ; DIS: 0000000000000010 (idx: [[#NFA+5]]) .loadTLInit:
209 ; DIS-NEXT: [[#%x, ADDR:]]: {{.*}} ld 3, 8(2)
210 ; DIS-NEXT: {{0*}}[[#ADDR + 2]]: R_TOC (idx: [[#NFA+23]]) ThreadLocalVarInit[TC]
211 ; DIS-NEXT: [[#%x, ADDR:]]: {{.*}} ld 4, 16(2)
212 ; DIS-NEXT: {{0*}}[[#ADDR + 2]]: R_TOC (idx: [[#NFA+25]]) VarInit[TC]
213 ; DIS-NEXT: [[#%x, ADDR:]]: {{.*}} lwzx 3, 13, 3
214 ; DIS-NEXT: [[#%x, ADDR:]]: {{.*}} lwz 4, 0(4)
215 ; DIS-NEXT: [[#%x, ADDR:]]: {{.*}} add 3, 4, 3
216 ; DIS-NEXT: [[#%x, ADDR:]]: {{.*}} extsw 3, 3
217 ; DIS-NEXT: [[#%x, ADDR:]]: {{.*}} blr
218 ; DIS: 0000000000000030 (idx: [[#NFA+7]]) .loadTLUninit:
219 ; DIS-NEXT: [[#%x, ADDR:]]: {{.*}} ld 3, 0(2)
220 ; DIS-NEXT: {{0*}}[[#ADDR + 2]]: R_TOC (idx: [[#NFA+21]]) IThreadLocalVarUninit[TC]
221 ; DIS-NEXT: [[#%x, ADDR:]]: {{.*}} li 4, 1
222 ; DIS-NEXT: [[#%x, ADDR:]]: {{.*}} stwx 4, 13, 3
223 ; DIS-NEXT: [[#%x, ADDR:]]: {{.*}} ld 3, 24(2)
224 ; DIS-NEXT: {{0*}}[[#ADDR + 2]]: R_TOC (idx: [[#NFA+27]]) IThreadLocalVarUninit2[TC]
225 ; DIS-NEXT: [[#%x, ADDR:]]: {{.*}} lwzx 3, 13, 3
226 ; DIS-NEXT: [[#%x, ADDR:]]: {{.*}} addi 3, 3, 1
227 ; DIS-NEXT: [[#%x, ADDR:]]: {{.*}} extsw 3, 3
228 ; DIS-NEXT: [[#%x, ADDR:]]: {{.*}} blr
230 ; DIS: Disassembly of section .data:
231 ; DIS: 0000000000000050 (idx: [[#NFA+11]]) VarInit:
232 ; DIS-NEXT: 50: 00 00 00 57
233 ; DIS: 0000000000000058 (idx: [[#NFA+13]]) storeITLUninit[DS]:
234 ; DIS-NEXT: 58: 00 00 00 00
235 ; DIS-NEXT: 0000000000000058: R_POS (idx: [[#NFA+3]]) .storeITLUninit
236 ; DIS-NEXT: 5c: 00 00 00 00
237 ; DIS-NEXT: 60: 00 00 00 00
238 ; DIS-NEXT: 0000000000000060: R_POS (idx: [[#NFA+19]]) TOC[TC0]
239 ; DIS-NEXT: 64: 00 00 00 a0
240 ; DIS: 0000000000000070 (idx: [[#NFA+15]]) loadTLInit[DS]:
241 ; DIS-NEXT: 70: 00 00 00 00
242 ; DIS-NEXT: 0000000000000070: R_POS (idx: [[#NFA+5]]) .loadTLInit
243 ; DIS-NEXT: 74: 00 00 00 10
244 ; DIS-NEXT: 78: 00 00 00 00
245 ; DIS-NEXT: 0000000000000078: R_POS (idx: [[#NFA+19]]) TOC[TC0]
246 ; DIS-NEXT: 7c: 00 00 00 a0
247 ; DIS: 0000000000000088 (idx: [[#NFA+17]]) loadTLUninit[DS]:
248 ; DIS-NEXT: 88: 00 00 00 00
249 ; DIS-NEXT: 0000000000000088: R_POS (idx: [[#NFA+7]]) .loadTLUninit
250 ; DIS-NEXT: 8c: 00 00 00 30
251 ; DIS-NEXT: 90: 00 00 00 00
252 ; DIS-NEXT: 0000000000000090: R_POS (idx: [[#NFA+19]]) TOC[TC0]
253 ; DIS-NEXT: 94: 00 00 00 a0
254 ; DIS: 00000000000000a0 (idx: [[#NFA+21]]) IThreadLocalVarUninit[TC]:
255 ; DIS-NEXT: a0: 00 00 00 00
256 ; DIS-NEXT: 00000000000000a0: R_TLS_LE (idx: [[#NFA+33]]) IThreadLocalVarUninit[UL]
257 ; DIS-NEXT: a4: 00 00 00 04
258 ; DIS: 00000000000000a8 (idx: [[#NFA+23]]) ThreadLocalVarInit[TC]:
259 ; DIS-NEXT: a8: 00 00 00 00
260 ; DIS-NEXT: 00000000000000a8: R_TLS_LE (idx: [[#NFA+31]]) ThreadLocalVarInit
261 ; DIS-NEXT: ac: 00 00 00 00
262 ; DIS: 00000000000000b0 (idx: [[#NFA+25]]) VarInit[TC]:
263 ; DIS-NEXT: b0: 00 00 00 00
264 ; DIS-NEXT: 00000000000000b0: R_POS (idx: [[#NFA+11]]) VarInit
265 ; DIS-NEXT: b4: 00 00 00 50
266 ; DIS: 00000000000000b8 (idx: [[#NFA+27]]) IThreadLocalVarUninit2[TC]:
267 ; DIS-NEXT: b8: 00 00 00 00
268 ; DIS-NEXT: 00000000000000b8: R_TLS_LE (idx: [[#NFA+35]]) IThreadLocalVarUninit2[UL]
269 ; DIS-NEXT: bc: 00 00 00 08
271 ; DIS: Disassembly of section .tdata:
272 ; DIS: 0000000000000000 (idx: [[#NFA+31]]) ThreadLocalVarInit:
273 ; DIS-NEXT: 0: 00 00 00 01
275 ; DIS: Disassembly of section .tbss:
276 ; DIS: 0000000000000004 (idx: [[#NFA+33]]) IThreadLocalVarUninit[UL]:
278 ; DIS: 0000000000000008 (idx: [[#NFA+35]]) IThreadLocalVarUninit2[UL]: