• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; Test whether we don't mangle external, undefined, global names. This
2; feature is needed for cross tests on global initializer relocations.
3;
4; Note: This code was generated by compiling subzero/crosstest/test_global.cpp
5
6; We use lc2i (rather than p2i) because PNaCl bitcode files do not
7; allow externally defined global variables. Hence, this test can only
8; work if we read LLVM IR source, and convert to to ICE.
9
10; REQUIRES: allow_llvm_ir_as_input
11; RUN: %lc2i -i %s --insts --args --allow-uninitialized-globals \
12; RUN:       -allow-externally-defined-symbols | FileCheck %s
13; RUN: %lc2i -i %s --insts --args --allow-uninitialized-globals \
14; RUN:       -allow-externally-defined-symbols \
15; RUN:       -prefix Subzero_ | FileCheck --check-prefix=CROSS %s
16
17@ArrayInitPartial = internal global [40 x i8] c"<\00\00\00F\00\00\00P\00\00\00Z\00\00\00d\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", align 4
18
19; CHECK: @ArrayInitPartial = internal global [40 x i8] c"<\00\00\00F\00\00\00P\00\00\00Z\00\00\00d\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", align 4
20; CROSS: @Subzero_ArrayInitPartial = internal global [40 x i8] c"<\00\00\00F\00\00\00P\00\00\00Z\00\00\00d\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", align 4
21
22@ArrayInitFull = internal global [20 x i8] c"\0A\00\00\00\14\00\00\00\1E\00\00\00(\00\00\002\00\00\00", align 4
23
24; CHECK: @ArrayInitFull = internal global [20 x i8] c"\0A\00\00\00\14\00\00\00\1E\00\00\00(\00\00\002\00\00\00", align 4
25; CROSS: @Subzero_ArrayInitFull = internal global [20 x i8] c"\0A\00\00\00\14\00\00\00\1E\00\00\00(\00\00\002\00\00\00", align 4
26
27@NumArraysElements = internal global [4 x i8] c"\06\00\00\00", align 4
28
29; CHECK: @NumArraysElements = internal global [4 x i8] c"\06\00\00\00", align 4
30; CROSS: @Subzero_NumArraysElements = internal global [4 x i8] c"\06\00\00\00", align 4
31
32@Arrays = internal constant <{ i32, [4 x i8], i32, [4 x i8], i32, [4 x i8], i32, [4 x i8], i32, [4 x i8], i32, [4 x i8] }> <{ i32 ptrtoint ([40 x i8]* @ArrayInitPartial to i32), [4 x i8] c"(\00\00\00", i32 ptrtoint ([20 x i8]* @ArrayInitFull to i32), [4 x i8] c"\14\00\00\00", i32 ptrtoint ([12 x i8]* @_ZL10ArrayConst to i32), [4 x i8] c"\0C\00\00\00", i32 ptrtoint ([80 x i8]* @_ZL11ArrayDouble to i32), [4 x i8] c"P\00\00\00", i32 add (i32 ptrtoint ([40 x i8]* @ArrayInitPartial to i32), i32 8), [4 x i8] c" \00\00\00", i32 ptrtoint ([80 x i8]* @_ZL8StructEx to i32), [4 x i8] c"P\00\00\00" }>, align 4
33
34; CHECK: @Arrays = internal constant <{ i32, [4 x i8], i32, [4 x i8], i32, [4 x i8], i32, [4 x i8], i32, [4 x i8], i32, [4 x i8] }> <{ i32 ptrtoint ([40 x i8]* @ArrayInitPartial to i32), [4 x i8] c"(\00\00\00", i32 ptrtoint ([20 x i8]* @ArrayInitFull to i32), [4 x i8] c"\14\00\00\00", i32 ptrtoint ([12 x i8]* @_ZL10ArrayConst to i32), [4 x i8] c"\0C\00\00\00", i32 ptrtoint ([80 x i8]* @_ZL11ArrayDouble to i32), [4 x i8] c"P\00\00\00", i32 add (i32 ptrtoint ([40 x i8]* @ArrayInitPartial to i32), i32 8), [4 x i8] c" \00\00\00", i32 ptrtoint ([80 x i8]* @_ZL8StructEx to i32), [4 x i8] c"P\00\00\00" }>, align 4
35; CROSS: @Subzero_Arrays = internal constant <{ i32, [4 x i8], i32, [4 x i8], i32, [4 x i8], i32, [4 x i8], i32, [4 x i8], i32, [4 x i8] }> <{ i32 ptrtoint ([40 x i8]* @Subzero_ArrayInitPartial to i32), [4 x i8] c"(\00\00\00", i32 ptrtoint ([20 x i8]* @Subzero_ArrayInitFull to i32), [4 x i8] c"\14\00\00\00", i32 ptrtoint ([12 x i8]* @Subzero__ZL10ArrayConst to i32), [4 x i8] c"\0C\00\00\00", i32 ptrtoint ([80 x i8]* @Subzero__ZL11ArrayDouble to i32), [4 x i8] c"P\00\00\00", i32 add (i32 ptrtoint ([40 x i8]* @Subzero_ArrayInitPartial to i32), i32 8), [4 x i8] c" \00\00\00", i32 ptrtoint ([80 x i8]* @Subzero__ZL8StructEx to i32), [4 x i8] c"P\00\00\00" }>, align 4
36
37
38@_ZL10ArrayConst = internal constant [12 x i8] c"\F6\FF\FF\FF\EC\FF\FF\FF\E2\FF\FF\FF", align 4
39
40; CHECK: @_ZL10ArrayConst = internal constant [12 x i8] c"\F6\FF\FF\FF\EC\FF\FF\FF\E2\FF\FF\FF", align 4
41; CROSS: @Subzero__ZL10ArrayConst = internal constant [12 x i8] c"\F6\FF\FF\FF\EC\FF\FF\FF\E2\FF\FF\FF", align 4
42
43@_ZL11ArrayDouble = internal global [80 x i8] c"\00\00\00\00\00\00\E0?\00\00\00\00\00\00\F8?\00\00\00\00\00\00\04@\00\00\00\00\00\00\0C@\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", align 8
44
45; CHECK: @_ZL11ArrayDouble = internal global [80 x i8] c"\00\00\00\00\00\00\E0?\00\00\00\00\00\00\F8?\00\00\00\00\00\00\04@\00\00\00\00\00\00\0C@\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", align 8
46; CROSS: @Subzero__ZL11ArrayDouble = internal global [80 x i8] c"\00\00\00\00\00\00\E0?\00\00\00\00\00\00\F8?\00\00\00\00\00\00\04@\00\00\00\00\00\00\0C@\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", align 8
47
48@_ZL8StructEx = internal global [80 x i8] zeroinitializer, align 8
49
50; CHECK: @_ZL8StructEx = internal global [80 x i8] zeroinitializer, align 8
51; CROSS: @Subzero__ZL8StructEx = internal global [80 x i8] zeroinitializer, align 8
52
53@ExternName1 = external global [4 x i8], align 4
54
55; CHECK: @ExternName1 = external global <{  }> <{  }>, align 4
56; CROSS: @ExternName1 = external global <{  }> <{  }>, align 4
57
58@ExternName4 = external global [4 x i8], align 4
59
60; CHECK: @ExternName4 = external global <{  }> <{  }>, align 4
61; CROSS: @ExternName4 = external global <{  }> <{  }>, align 4
62
63@ExternName3 = external global [4 x i8], align 4
64
65; CHECK: @ExternName3 = external global <{  }> <{  }>, align 4
66; CROSS: @ExternName3 = external global <{  }> <{  }>, align 4
67
68@ExternName2 = external global [4 x i8], align 4
69
70; CHECK: @ExternName2 = external global <{  }> <{  }>, align 4
71; CROSS: @ExternName2 = external global <{  }> <{  }>, align 4
72
73@ExternName5 = external global [4 x i8], align 4
74
75; CHECK: @ExternName5 = external global <{  }> <{  }>, align 4
76; CROSS: @ExternName5 = external global <{  }> <{  }>, align 4
77
78define i32 @_Z12getNumArraysv() {
79; CHECK: define i32 @_Z12getNumArraysv() {
80; CROSS: define i32 @_ZN8Subzero_12getNumArraysEv() {
81entry:
82  %NumArraysElements.bc = bitcast [4 x i8]* @NumArraysElements to i32*
83; CHECK:   %NumArraysElements.bc = bitcast i32 @NumArraysElements to i32
84; CROSS:   %NumArraysElements.bc = bitcast i32 @Subzero_NumArraysElements to i32
85  %0 = load i32, i32* %NumArraysElements.bc, align 1
86  ret i32 %0
87}
88
89define i32 @_Z8getArrayjRj(i32 %WhichArray, i32 %Len) {
90; CHECK: define i32 @_Z8getArrayjRj(i32 %WhichArray, i32 %Len) {
91; CROSS: define i32 @_ZN8Subzero_8getArrayEjRj(i32 %WhichArray, i32 %Len) {
92entry:
93  %NumArraysElements.bc = bitcast [4 x i8]* @NumArraysElements to i32*
94; CHECK:   %NumArraysElements.bc = bitcast i32 @NumArraysElements to i32
95; CROSS:   %NumArraysElements.bc = bitcast i32 @Subzero_NumArraysElements to i32
96  %0 = load i32, i32* %NumArraysElements.bc, align 1
97  %cmp = icmp ugt i32 %0, %WhichArray
98; CHECK:   %cmp = icmp ugt i32 %__3, %WhichArray
99; CROSS:   %cmp = icmp ugt i32 %__3, %WhichArray
100  br i1 %cmp, label %if.end, label %if.then
101
102if.then:                                          ; preds = %entry
103  %Len.asptr = inttoptr i32 %Len to i32*
104; CHECK:   %Len.asptr = i32 %Len
105; CROSS:   %Len.asptr = i32 %Len
106  store i32 -1, i32* %Len.asptr, align 1
107  br label %return
108
109if.end:                                           ; preds = %entry
110  %gep_array = mul i32 %WhichArray, 8
111; CHECK:   %gep_array = mul i32 %WhichArray, 8
112; CROSS:   %gep_array = mul i32 %WhichArray, 8
113  %expanded1 = ptrtoint <{ i32, [4 x i8], i32, [4 x i8], i32, [4 x i8], i32, [4 x i8], i32, [4 x i8], i32, [4 x i8] }>* @Arrays to i32
114; CHECK:   %expanded1 = i32 @Arrays
115; CROSS:   %expanded1 = i32 @Subzero_Arrays
116  %gep = add i32 %expanded1, %gep_array
117  %gep1 = add i32 %gep, 4
118  %gep1.asptr = inttoptr i32 %gep1 to i32*
119  %1 = load i32, i32* %gep1.asptr, align 1
120  %Len.asptr3 = inttoptr i32 %Len to i32*
121; CHECK:   %Len.asptr3 = i32 %Len
122; CROSS:   %Len.asptr3 = i32 %Len
123  store i32 %1, i32* %Len.asptr3, align 1
124  %gep_array3 = mul i32 %WhichArray, 8
125; CHECK:   %gep_array3 = mul i32 %WhichArray, 8
126; CROSS:   %gep_array3 = mul i32 %WhichArray, 8
127  %expanded2 = ptrtoint <{ i32, [4 x i8], i32, [4 x i8], i32, [4 x i8], i32, [4 x i8], i32, [4 x i8], i32, [4 x i8] }>* @Arrays to i32
128; CHECK:   %expanded2 = i32 @Arrays
129; CROSS:   %expanded2 = i32 @Subzero_Arrays
130  %gep4 = add i32 %expanded2, %gep_array3
131  %gep4.asptr = inttoptr i32 %gep4 to i32*
132  %2 = load i32, i32* %gep4.asptr, align 1
133  br label %return
134
135return:                                           ; preds = %if.end, %if.then
136  %retval.0 = phi i32 [ 0, %if.then ], [ %2, %if.end ]
137  ret i32 %retval.0
138}
139
140define void @_GLOBAL__I_a() {
141; CHECK: define void @_GLOBAL__I_a() {
142; CROSS: define void @Subzero__GLOBAL__I_a() {
143entry:
144  %_ZL8StructEx.bc = bitcast [80 x i8]* @_ZL8StructEx to i32*
145; CHECK:   %_ZL8StructEx.bc = bitcast i32 @_ZL8StructEx to i32
146; CROSS:   %_ZL8StructEx.bc = bitcast i32 @Subzero__ZL8StructEx to i32
147  store i32 10, i32* %_ZL8StructEx.bc, align 1
148  %expanded1 = ptrtoint [80 x i8]* @_ZL8StructEx to i32
149; CHECK:   %expanded1 = i32 @_ZL8StructEx
150; CROSS:   %expanded1 = i32 @Subzero__ZL8StructEx
151  %gep = add i32 %expanded1, 4
152  %gep.asptr = inttoptr i32 %gep to i32*
153  store i32 20, i32* %gep.asptr, align 1
154  %expanded2 = ptrtoint [80 x i8]* @_ZL8StructEx to i32
155; CHECK:   %expanded2 = i32 @_ZL8StructEx
156; CROSS:   %expanded2 = i32 @Subzero__ZL8StructEx
157  %gep18 = add i32 %expanded2, 8
158  %gep18.asptr = inttoptr i32 %gep18 to i32*
159  store i32 30, i32* %gep18.asptr, align 1
160  %expanded3 = ptrtoint [80 x i8]* @_ZL8StructEx to i32
161; CHECK:   %expanded3 = i32 @_ZL8StructEx
162; CROSS:   %expanded3 = i32 @Subzero__ZL8StructEx
163  %gep20 = add i32 %expanded3, 12
164  %gep20.asptr = inttoptr i32 %gep20 to i32*
165  store i32 40, i32* %gep20.asptr, align 1
166  %expanded4 = ptrtoint [80 x i8]* @_ZL8StructEx to i32
167; CHECK:   %expanded4 = i32 @_ZL8StructEx
168; CROSS:   %expanded4 = i32 @Subzero__ZL8StructEx
169  %gep22 = add i32 %expanded4, 16
170  %gep22.asptr = inttoptr i32 %gep22 to i32*
171  store i32 50, i32* %gep22.asptr, align 1
172  %ExternName1.bc = bitcast [4 x i8]* @ExternName1 to i32*
173; CHECK:   %ExternName1.bc = bitcast i32 @ExternName1 to i32
174; CROSS:   %ExternName1.bc = bitcast i32 @ExternName1 to i32
175  %0 = load i32, i32* %ExternName1.bc, align 1
176  %expanded6 = ptrtoint [80 x i8]* @_ZL8StructEx to i32
177; CHECK:   %expanded6 = i32 @_ZL8StructEx
178; CROSS:   %expanded6 = i32 @Subzero__ZL8StructEx
179  %gep24 = add i32 %expanded6, 20
180  %gep24.asptr = inttoptr i32 %gep24 to i32*
181  store i32 %0, i32* %gep24.asptr, align 1
182  %expanded7 = ptrtoint [80 x i8]* @_ZL8StructEx to i32
183; CHECK:   %expanded7 = i32 @_ZL8StructEx
184; CROSS:   %expanded7 = i32 @Subzero__ZL8StructEx
185  %gep26 = add i32 %expanded7, 24
186  %gep26.asptr = inttoptr i32 %gep26 to double*
187  store double 5.000000e-01, double* %gep26.asptr, align 8
188  %expanded8 = ptrtoint [80 x i8]* @_ZL8StructEx to i32
189; CHECK:   %expanded8 = i32 @_ZL8StructEx
190; CROSS:   %expanded8 = i32 @Subzero__ZL8StructEx
191  %gep28 = add i32 %expanded8, 32
192  %gep28.asptr = inttoptr i32 %gep28 to double*
193  store double 1.500000e+00, double* %gep28.asptr, align 8
194  %expanded9 = ptrtoint [80 x i8]* @_ZL8StructEx to i32
195; CHECK:   %expanded9 = i32 @_ZL8StructEx
196; CROSS:   %expanded9 = i32 @Subzero__ZL8StructEx
197  %gep30 = add i32 %expanded9, 40
198  %gep30.asptr = inttoptr i32 %gep30 to double*
199  store double 2.500000e+00, double* %gep30.asptr, align 8
200  %ExternName4.bc = bitcast [4 x i8]* @ExternName4 to i32*
201; CHECK:   %ExternName4.bc = bitcast i32 @ExternName4 to i32
202; CROSS:   %ExternName4.bc = bitcast i32 @ExternName4 to i32
203  %1 = load i32, i32* %ExternName4.bc, align 1
204  %expanded11 = ptrtoint [80 x i8]* @_ZL8StructEx to i32
205; CHECK:   %expanded11 = i32 @_ZL8StructEx
206; CROSS:   %expanded11 = i32 @Subzero__ZL8StructEx
207  %gep32 = add i32 %expanded11, 48
208  %gep32.asptr = inttoptr i32 %gep32 to i32*
209  store i32 %1, i32* %gep32.asptr, align 1
210  %ExternName3.bc = bitcast [4 x i8]* @ExternName3 to i32*
211; CHECK:   %ExternName3.bc = bitcast i32 @ExternName3 to i32
212; CROSS:   %ExternName3.bc = bitcast i32 @ExternName3 to i32
213  %2 = load i32, i32* %ExternName3.bc, align 1
214  %expanded13 = ptrtoint [80 x i8]* @_ZL8StructEx to i32
215; CHECK:   %expanded13 = i32 @_ZL8StructEx
216; CROSS:   %expanded13 = i32 @Subzero__ZL8StructEx
217  %gep34 = add i32 %expanded13, 52
218  %gep34.asptr = inttoptr i32 %gep34 to i32*
219  store i32 %2, i32* %gep34.asptr, align 1
220  %expanded14 = ptrtoint [80 x i8]* @_ZL8StructEx to i32
221; CHECK:   %expanded14 = i32 @_ZL8StructEx
222; CROSS:   %expanded14 = i32 @Subzero__ZL8StructEx
223  %gep36 = add i32 %expanded14, 56
224  %gep36.asptr = inttoptr i32 %gep36 to i32*
225  store i32 1000, i32* %gep36.asptr, align 1
226  %expanded15 = ptrtoint [80 x i8]* @_ZL8StructEx to i32
227; CHECK:   %expanded15 = i32 @_ZL8StructEx
228; CROSS:   %expanded15 = i32 @Subzero__ZL8StructEx
229  %gep38 = add i32 %expanded15, 60
230  %gep38.asptr = inttoptr i32 %gep38 to i32*
231  store i32 1010, i32* %gep38.asptr, align 1
232  %expanded16 = ptrtoint [80 x i8]* @_ZL8StructEx to i32
233; CHECK:   %expanded16 = i32 @_ZL8StructEx
234; CROSS:   %expanded16 = i32 @Subzero__ZL8StructEx
235  %gep40 = add i32 %expanded16, 64
236  %gep40.asptr = inttoptr i32 %gep40 to i32*
237  store i32 1020, i32* %gep40.asptr, align 1
238  %ExternName2.bc = bitcast [4 x i8]* @ExternName2 to i32*
239; CHECK:   %ExternName2.bc = bitcast i32 @ExternName2 to i32
240; CROSS:   %ExternName2.bc = bitcast i32 @ExternName2 to i32
241  %3 = load i32, i32* %ExternName2.bc, align 1
242  %expanded18 = ptrtoint [80 x i8]* @_ZL8StructEx to i32
243; CHECK:   %expanded18 = i32 @_ZL8StructEx
244; CROSS:   %expanded18 = i32 @Subzero__ZL8StructEx
245  %gep42 = add i32 %expanded18, 68
246  %gep42.asptr = inttoptr i32 %gep42 to i32*
247  store i32 %3, i32* %gep42.asptr, align 1
248  %ExternName5.bc = bitcast [4 x i8]* @ExternName5 to i32*
249; CHECK:   %ExternName5.bc = bitcast i32 @ExternName5 to i32
250; CROSS:   %ExternName5.bc = bitcast i32 @ExternName5 to i32
251  %4 = load i32, i32* %ExternName5.bc, align 1
252  %expanded20 = ptrtoint [80 x i8]* @_ZL8StructEx to i32
253; CHECK:   %expanded20 = i32 @_ZL8StructEx
254; CROSS:   %expanded20 = i32 @Subzero__ZL8StructEx
255  %gep44 = add i32 %expanded20, 72
256  %gep44.asptr = inttoptr i32 %gep44 to i32*
257  store i32 %4, i32* %gep44.asptr, align 1
258  ret void
259}
260
261define i32 @nacl_tp_tdb_offset(i32) {
262entry:
263  ret i32 0
264}
265
266define i32 @nacl_tp_tls_offset(i32 %size) {
267entry:
268  %result = sub i32 0, %size
269  ret i32 %result
270}
271