• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; This file tests TOC entry generation and undefined symbol generation.
2
3; RUN: llc  -verify-machineinstrs -mcpu=pwr4 -mattr=-altivec -mtriple powerpc-ibm-aix-xcoff < %s | FileCheck --check-prefixes CHECK,CHECK32 %s
4; RUN: llc  -verify-machineinstrs -mcpu=pwr4 -mattr=-altivec -mtriple powerpc64-ibm-aix-xcoff < %s 2>&1 | FileCheck --check-prefixes CHECK,CHECK64  %s
5
6; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mattr=-altivec -mtriple powerpc-ibm-aix-xcoff -filetype=obj -o %t.o < %s
7; RUN: llvm-readobj --syms %t.o | FileCheck --check-prefix=SYM %s
8
9; RUN: not --crash llc -verify-machineinstrs -mcpu=pwr4 -mattr=-altivec -mtriple powerpc64-ibm-aix-xcoff -filetype=obj -o %t.o 2>&1 \
10; RUN: < %s | FileCheck --check-prefix=XCOFF64 %s
11; XCOFF64: LLVM ERROR: 64-bit XCOFF object files are not supported yet.
12
13@a = external global i32, align 4
14@b = external global i64, align 8
15@c = external global i16, align 2
16@globa = common global i32 0, align 4
17
18@ptr = internal global void (...)* null, align 4
19
20declare void @foo()
21
22define void @bar() {
23  %1 = alloca i8*, align 8
24  %2 = alloca i8*, align 8
25  store i32 0, i32* @a, align 4
26  store i64 0, i64* @b, align 8
27  store i16 0, i16* @c, align 2
28  store i32 0, i32* @globa, align 4
29  store void (...)* bitcast (void ()* @bar to void (...)*), void (...)** @ptr, align 4
30  store i8* bitcast (void ()* @foo to i8*), i8** %1, align 8
31  store i8* bitcast (void ()* @foobar to i8*), i8** %2, align 8
32  ret void
33}
34
35; We initialize a csect when we first reference an external global, so make sure we don't run into problems when we see it again.
36define void @bar2() {
37  store i32 0, i32* @a, align 4
38  store i64 0, i64* @b, align 8
39  store i16 0, i16* @c, align 2
40  ret void
41}
42
43define void @foobar() {
44  ret void
45}
46
47; Test tc entry assembly generation.
48
49; CHECK-NOT: .comm a
50; CHECK-NOT: .lcomm a
51; CHECK-NOT: .comm b
52; CHECK-NOT: .lcomm b
53; CHECK-NOT: .comm c
54; CHECK-NOT: .lcomm c
55; CHECK: .comm globa[RW],4,2
56; CHECK32: .lcomm ptr,4,ptr[BS],2
57; CHECK64: .lcomm ptr,8,ptr[BS],2
58; CHECK:      .toc
59; CHECK-NEXT: L..C0:
60; CHECK-NEXT: .tc   a[TC],a[UA]
61; CHECK-NEXT: L..C1:
62; CHECK-NEXT: .tc   b[TC],b[UA]
63; CHECK-NEXT: L..C2:
64; CHECK-NEXT: .tc   c[TC],c[UA]
65; CHECK-NEXT: L..C3:
66; CHECK-NEXT: .tc   globa[TC],globa[RW]
67; CHECK-NEXT: L..C4:
68; CHECK-NEXT: .tc   ptr[TC],ptr[BS]
69; CHECK-NEXT: L..C5:
70; CHECK-NEXT: .tc   bar[TC],bar[DS]
71; CHECK-NEXT: L..C6:
72; CHECK-NEXT: .tc   foo[TC],foo[DS]
73; CHECK-NEXT: L..C7:
74; CHECK-NEXT: .tc   foobar[TC],foobar[DS]
75
76
77; Test undefined symbol generation.
78
79; SYM:       File: {{.*}}aix-xcoff-toc.ll.tmp.o
80; SYM:       Symbol {{[{][[:space:]] *}}Index: [[#UNDEF_INDX:]]{{[[:space:]] *}}Name: a
81; SYM-NEXT:   Value (RelocatableAddress): 0x0
82; SYM-NEXT:   Section: N_UNDEF
83; SYM-NEXT:   Type: 0x0
84; SYM-NEXT:   StorageClass: C_EXT (0x2)
85; SYM-NEXT:   NumberOfAuxEntries: 1
86; SYM-NEXT:   CSECT Auxiliary Entry {
87; SYM-NEXT:     Index: [[#UNDEF_INDX+1]]
88; SYM-NEXT:     SectionLen: 0
89; SYM-NEXT:     ParameterHashIndex: 0x0
90; SYM-NEXT:     TypeChkSectNum: 0x0
91; SYM-NEXT:     SymbolAlignmentLog2: 0
92; SYM-NEXT:     SymbolType: XTY_ER (0x0)
93; SYM-NEXT:     StorageMappingClass: XMC_UA (0x4)
94; SYM-NEXT:     StabInfoIndex: 0x0
95; SYM-NEXT:     StabSectNum: 0x0
96; SYM-NEXT:   }
97; SYM-NEXT: }
98; SYM-NEXT: Symbol {
99; SYM-NEXT:   Index: [[#UNDEF_INDX+2]]
100; SYM-NEXT:   Name: b
101; SYM-NEXT:   Value (RelocatableAddress): 0x0
102; SYM-NEXT:   Section: N_UNDEF
103; SYM-NEXT:   Type: 0x0
104; SYM-NEXT:   StorageClass: C_EXT (0x2)
105; SYM-NEXT:   NumberOfAuxEntries: 1
106; SYM-NEXT:   CSECT Auxiliary Entry {
107; SYM-NEXT:     Index: [[#UNDEF_INDX+3]]
108; SYM-NEXT:     SectionLen: 0
109; SYM-NEXT:     ParameterHashIndex: 0x0
110; SYM-NEXT:     TypeChkSectNum: 0x0
111; SYM-NEXT:     SymbolAlignmentLog2: 0
112; SYM-NEXT:     SymbolType: XTY_ER (0x0)
113; SYM-NEXT:     StorageMappingClass: XMC_UA (0x4)
114; SYM-NEXT:     StabInfoIndex: 0x0
115; SYM-NEXT:     StabSectNum: 0x0
116; SYM-NEXT:   }
117; SYM-NEXT: }
118; SYM-NEXT: Symbol {
119; SYM-NEXT:   Index: [[#UNDEF_INDX+4]]
120; SYM-NEXT:   Name: c
121; SYM-NEXT:   Value (RelocatableAddress): 0x0
122; SYM-NEXT:   Section: N_UNDEF
123; SYM-NEXT:   Type: 0x0
124; SYM-NEXT:   StorageClass: C_EXT (0x2)
125; SYM-NEXT:   NumberOfAuxEntries: 1
126; SYM-NEXT:   CSECT Auxiliary Entry {
127; SYM-NEXT:     Index: [[#UNDEF_INDX+5]]
128; SYM-NEXT:     SectionLen: 0
129; SYM-NEXT:     ParameterHashIndex: 0x0
130; SYM-NEXT:     TypeChkSectNum: 0x0
131; SYM-NEXT:     SymbolAlignmentLog2: 0
132; SYM-NEXT:     SymbolType: XTY_ER (0x0)
133; SYM-NEXT:     StorageMappingClass: XMC_UA (0x4)
134; SYM-NEXT:     StabInfoIndex: 0x0
135; SYM-NEXT:     StabSectNum: 0x0
136; SYM-NEXT:   }
137; SYM-NEXT: }
138; SYM-NEXT: Symbol {
139; SYM-NEXT:   Index: [[#UNDEF_INDX+6]]
140; SYM-NEXT:   Name: .foo
141; SYM-NEXT:   Value (RelocatableAddress): 0x0
142; SYM-NEXT:   Section: N_UNDEF
143; SYM-NEXT:   Type: 0x0
144; SYM-NEXT:   StorageClass: C_EXT (0x2)
145; SYM-NEXT:   NumberOfAuxEntries: 1
146; SYM-NEXT:   CSECT Auxiliary Entry {
147; SYM-NEXT:     Index: [[#UNDEF_INDX+7]]
148; SYM-NEXT:     SectionLen: 0
149; SYM-NEXT:     ParameterHashIndex: 0x0
150; SYM-NEXT:     TypeChkSectNum: 0x0
151; SYM-NEXT:     SymbolAlignmentLog2: 0
152; SYM-NEXT:     SymbolType: XTY_ER (0x0)
153; SYM-NEXT:     StorageMappingClass: XMC_PR (0x0)
154; SYM-NEXT:     StabInfoIndex: 0x0
155; SYM-NEXT:     StabSectNum: 0x0
156; SYM-NEXT:   }
157; SYM-NEXT: }
158; SYM-NEXT: Symbol {
159; SYM-NEXT:   Index: [[#UNDEF_INDX+8]]
160; SYM-NEXT:   Name: foo
161; SYM-NEXT:   Value (RelocatableAddress): 0x0
162; SYM-NEXT:   Section: N_UNDEF
163; SYM-NEXT:   Type: 0x0
164; SYM-NEXT:   StorageClass: C_EXT (0x2)
165; SYM-NEXT:   NumberOfAuxEntries: 1
166; SYM-NEXT:   CSECT Auxiliary Entry {
167; SYM-NEXT:     Index: [[#UNDEF_INDX+9]]
168; SYM-NEXT:     SectionLen: 0
169; SYM-NEXT:     ParameterHashIndex: 0x0
170; SYM-NEXT:     TypeChkSectNum: 0x0
171; SYM-NEXT:     SymbolAlignmentLog2: 0
172; SYM-NEXT:     SymbolType: XTY_ER (0x0)
173; SYM-NEXT:     StorageMappingClass: XMC_DS (0xA)
174; SYM-NEXT:     StabInfoIndex: 0x0
175; SYM-NEXT:     StabSectNum: 0x0
176; SYM-NEXT:   }
177; SYM-NEXT: }
178
179; Test TOC entry symbol generation.
180
181; SYM:       Symbol {{[{][[:space:]] *}}Index: [[#TOC_INDX:]]{{[[:space:]] *}}Name: TOC
182; SYM-NEXT:    Value (RelocatableAddress): 0xA8
183; SYM-NEXT:    Section: .data
184; SYM-NEXT:    Type: 0x0
185; SYM-NEXT:    StorageClass: C_HIDEXT (0x6B)
186; SYM-NEXT:    NumberOfAuxEntries: 1
187; SYM-NEXT:    CSECT Auxiliary Entry {
188; SYM-NEXT:      Index: [[#TOC_INDX+1]]
189; SYM-NEXT:      SectionLen: 0
190; SYM-NEXT:      ParameterHashIndex: 0x0
191; SYM-NEXT:      TypeChkSectNum: 0x0
192; SYM-NEXT:      SymbolAlignmentLog2: 2
193; SYM-NEXT:      SymbolType: XTY_SD (0x1)
194; SYM-NEXT:      StorageMappingClass: XMC_TC0 (0xF)
195; SYM-NEXT:      StabInfoIndex: 0x0
196; SYM-NEXT:      StabSectNum: 0x0
197; SYM-NEXT:    }
198; SYM-NEXT:  }
199; SYM-NEXT:  Symbol {
200; SYM-NEXT:    Index: [[#TOC_INDX+2]]
201; SYM-NEXT:    Name: a
202; SYM-NEXT:    Value (RelocatableAddress): 0xA8
203; SYM-NEXT:    Section: .data
204; SYM-NEXT:    Type: 0x0
205; SYM-NEXT:    StorageClass: C_HIDEXT (0x6B)
206; SYM-NEXT:    NumberOfAuxEntries: 1
207; SYM-NEXT:    CSECT Auxiliary Entry {
208; SYM-NEXT:      Index: [[#TOC_INDX+3]]
209; SYM-NEXT:      SectionLen: 4
210; SYM-NEXT:      ParameterHashIndex: 0x0
211; SYM-NEXT:      TypeChkSectNum: 0x0
212; SYM-NEXT:      SymbolAlignmentLog2: 2
213; SYM-NEXT:      SymbolType: XTY_SD (0x1)
214; SYM-NEXT:      StorageMappingClass: XMC_TC (0x3)
215; SYM-NEXT:      StabInfoIndex: 0x0
216; SYM-NEXT:      StabSectNum: 0x0
217; SYM-NEXT:    }
218; SYM-NEXT:  }
219; SYM-NEXT:  Symbol {
220; SYM-NEXT:    Index: [[#TOC_INDX+4]]
221; SYM-NEXT:    Name: b
222; SYM-NEXT:    Value (RelocatableAddress): 0xAC
223; SYM-NEXT:    Section: .data
224; SYM-NEXT:    Type: 0x0
225; SYM-NEXT:    StorageClass: C_HIDEXT (0x6B)
226; SYM-NEXT:    NumberOfAuxEntries: 1
227; SYM-NEXT:    CSECT Auxiliary Entry {
228; SYM-NEXT:      Index: [[#TOC_INDX+5]]
229; SYM-NEXT:      SectionLen: 4
230; SYM-NEXT:      ParameterHashIndex: 0x0
231; SYM-NEXT:      TypeChkSectNum: 0x0
232; SYM-NEXT:      SymbolAlignmentLog2: 2
233; SYM-NEXT:      SymbolType: XTY_SD (0x1)
234; SYM-NEXT:      StorageMappingClass: XMC_TC (0x3)
235; SYM-NEXT:      StabInfoIndex: 0x0
236; SYM-NEXT:      StabSectNum: 0x0
237; SYM-NEXT:    }
238; SYM-NEXT:  }
239; SYM-NEXT:  Symbol {
240; SYM-NEXT:    Index: [[#TOC_INDX+6]]
241; SYM-NEXT:    Name: c
242; SYM-NEXT:    Value (RelocatableAddress): 0xB0
243; SYM-NEXT:    Section: .data
244; SYM-NEXT:    Type: 0x0
245; SYM-NEXT:    StorageClass: C_HIDEXT (0x6B)
246; SYM-NEXT:    NumberOfAuxEntries: 1
247; SYM-NEXT:    CSECT Auxiliary Entry {
248; SYM-NEXT:      Index: [[#TOC_INDX+7]]
249; SYM-NEXT:      SectionLen: 4
250; SYM-NEXT:      ParameterHashIndex: 0x0
251; SYM-NEXT:      TypeChkSectNum: 0x0
252; SYM-NEXT:      SymbolAlignmentLog2: 2
253; SYM-NEXT:      SymbolType: XTY_SD (0x1)
254; SYM-NEXT:      StorageMappingClass: XMC_TC (0x3)
255; SYM-NEXT:      StabInfoIndex: 0x0
256; SYM-NEXT:      StabSectNum: 0x0
257; SYM-NEXT:    }
258; SYM-NEXT:  }
259; SYM-NEXT:  Symbol {
260; SYM-NEXT:    Index: [[#TOC_INDX+8]]
261; SYM-NEXT:    Name: globa
262; SYM-NEXT:    Value (RelocatableAddress): 0xB4
263; SYM-NEXT:    Section: .data
264; SYM-NEXT:    Type: 0x0
265; SYM-NEXT:    StorageClass: C_HIDEXT (0x6B)
266; SYM-NEXT:    NumberOfAuxEntries: 1
267; SYM-NEXT:    CSECT Auxiliary Entry {
268; SYM-NEXT:      Index: [[#TOC_INDX+9]]
269; SYM-NEXT:      SectionLen: 4
270; SYM-NEXT:      ParameterHashIndex: 0x0
271; SYM-NEXT:      TypeChkSectNum: 0x0
272; SYM-NEXT:      SymbolAlignmentLog2: 2
273; SYM-NEXT:      SymbolType: XTY_SD (0x1)
274; SYM-NEXT:      StorageMappingClass: XMC_TC (0x3)
275; SYM-NEXT:      StabInfoIndex: 0x0
276; SYM-NEXT:      StabSectNum: 0x0
277; SYM-NEXT:    }
278; SYM-NEXT:  }
279; SYM-NEXT:  Symbol {
280; SYM-NEXT:    Index: [[#TOC_INDX+10]]
281; SYM-NEXT:    Name: ptr
282; SYM-NEXT:    Value (RelocatableAddress): 0xB8
283; SYM-NEXT:    Section: .data
284; SYM-NEXT:    Type: 0x0
285; SYM-NEXT:    StorageClass: C_HIDEXT (0x6B)
286; SYM-NEXT:    NumberOfAuxEntries: 1
287; SYM-NEXT:    CSECT Auxiliary Entry {
288; SYM-NEXT:      Index: [[#TOC_INDX+11]]
289; SYM-NEXT:      SectionLen: 4
290; SYM-NEXT:      ParameterHashIndex: 0x0
291; SYM-NEXT:      TypeChkSectNum: 0x0
292; SYM-NEXT:      SymbolAlignmentLog2: 2
293; SYM-NEXT:      SymbolType: XTY_SD (0x1)
294; SYM-NEXT:      StorageMappingClass: XMC_TC (0x3)
295; SYM-NEXT:      StabInfoIndex: 0x0
296; SYM-NEXT:      StabSectNum: 0x0
297; SYM-NEXT:    }
298; SYM-NEXT:  }
299; SYM-NEXT:  Symbol {
300; SYM-NEXT:    Index: [[#TOC_INDX+12]]
301; SYM-NEXT:    Name: bar
302; SYM-NEXT:    Value (RelocatableAddress): 0xBC
303; SYM-NEXT:    Section: .data
304; SYM-NEXT:    Type: 0x0
305; SYM-NEXT:    StorageClass: C_HIDEXT (0x6B)
306; SYM-NEXT:    NumberOfAuxEntries: 1
307; SYM-NEXT:    CSECT Auxiliary Entry {
308; SYM-NEXT:      Index: [[#TOC_INDX+13]]
309; SYM-NEXT:      SectionLen: 4
310; SYM-NEXT:      ParameterHashIndex: 0x0
311; SYM-NEXT:      TypeChkSectNum: 0x0
312; SYM-NEXT:      SymbolAlignmentLog2: 2
313; SYM-NEXT:      SymbolType: XTY_SD (0x1)
314; SYM-NEXT:      StorageMappingClass: XMC_TC (0x3)
315; SYM-NEXT:      StabInfoIndex: 0x0
316; SYM-NEXT:      StabSectNum: 0x0
317; SYM-NEXT:    }
318; SYM-NEXT:  }
319; SYM-NEXT:  Symbol {
320; SYM-NEXT:    Index: [[#TOC_INDX+14]]
321; SYM-NEXT:    Name: foo
322; SYM-NEXT:    Value (RelocatableAddress): 0xC0
323; SYM-NEXT:    Section: .data
324; SYM-NEXT:    Type: 0x0
325; SYM-NEXT:    StorageClass: C_HIDEXT (0x6B)
326; SYM-NEXT:    NumberOfAuxEntries: 1
327; SYM-NEXT:    CSECT Auxiliary Entry {
328; SYM-NEXT:      Index: [[#TOC_INDX+15]]
329; SYM-NEXT:      SectionLen: 4
330; SYM-NEXT:      ParameterHashIndex: 0x0
331; SYM-NEXT:      TypeChkSectNum: 0x0
332; SYM-NEXT:      SymbolAlignmentLog2: 2
333; SYM-NEXT:      SymbolType: XTY_SD (0x1)
334; SYM-NEXT:      StorageMappingClass: XMC_TC (0x3)
335; SYM-NEXT:      StabInfoIndex: 0x0
336; SYM-NEXT:      StabSectNum: 0x0
337; SYM-NEXT:    }
338; SYM-NEXT:  }
339; SYM-NEXT:  Symbol {
340; SYM-NEXT:    Index: [[#TOC_INDX+16]]
341; SYM-NEXT:    Name: foobar
342; SYM-NEXT:    Value (RelocatableAddress): 0xC4
343; SYM-NEXT:    Section: .data
344; SYM-NEXT:    Type: 0x0
345; SYM-NEXT:    StorageClass: C_HIDEXT (0x6B)
346; SYM-NEXT:    NumberOfAuxEntries: 1
347; SYM-NEXT:    CSECT Auxiliary Entry {
348; SYM-NEXT:      Index: [[#TOC_INDX+17]]
349; SYM-NEXT:      SectionLen: 4
350; SYM-NEXT:      ParameterHashIndex: 0x0
351; SYM-NEXT:      TypeChkSectNum: 0x0
352; SYM-NEXT:      SymbolAlignmentLog2: 2
353; SYM-NEXT:      SymbolType: XTY_SD (0x1)
354; SYM-NEXT:      StorageMappingClass: XMC_TC (0x3)
355; SYM-NEXT:      StabInfoIndex: 0x0
356; SYM-NEXT:      StabSectNum: 0x0
357; SYM-NEXT:    }
358; SYM-NEXT:  }
359