OLD | NEW |
---|---|
(Empty) | |
1 ; Tests if we handle global variables with relocation initializers. | |
2 | |
3 ; Test that we handle it in the ICE converter. | |
4 ; RUN: %lc2i -i %s --args -verbose inst | FileCheck %s | |
5 | |
6 ; Test that we handle it using Subzero's bitcode reader. | |
7 ; RUN: %p2i -i %s --args -verbose inst | FileCheck %s | |
8 | |
9 @bytes = internal global [7 x i8] c"abcdefg" | |
10 ; CHECK: @bytes = internal global [7 x i8] c"abcdefg" | |
11 ; CHECK: .type bytes,@object | |
12 ; CHECK: .section .data,"aw",@progbits | |
13 ; CHECK:bytes: | |
14 ; CHECK: .byte 97 | |
15 ; CHECK: .byte 98 | |
16 ; CHECK: .byte 99 | |
17 ; CHECK: .byte 100 | |
18 ; CHECK: .byte 101 | |
19 ; CHECK: .byte 102 | |
20 ; CHECK: .byte 103 | |
21 ; CHECK: .size bytes, 7 | |
22 | |
23 @const_bytes = internal constant [7 x i8] c"abcdefg" | |
24 ; CHECK: @const_bytes = internal constant [7 x i8] c"abcdefg" | |
25 ; CHECK: .type const_bytes,@object | |
26 ; CHECK: .section .rodata,"a",@progbits | |
27 ; CHECK:const_bytes: | |
28 ; CHECK: .byte 97 | |
29 ; CHECK: .byte 98 | |
30 ; CHECK: .byte 99 | |
31 ; CHECK: .byte 100 | |
32 ; CHECK: .byte 101 | |
33 ; CHECK: .byte 102 | |
34 ; CHECK: .byte 103 | |
35 ; CHECK: .size const_bytes, 7 | |
36 | |
37 @ptr_to_ptr = internal global i32 ptrtoint (i32* @ptr to i32) | |
38 ; CHECK: @ptr_to_ptr = internal global i32 ptrtoint (i32* @ptr to i32) | |
39 ; CHECK: .type ptr_to_ptr,@object | |
40 ; CHECK: .section .data,"aw",@progbits | |
41 ; CHECK:ptr_to_ptr: | |
42 ; CHECK: .long ptr | |
43 ; CHECK: .size ptr_to_ptr, 4 | |
44 | |
45 @const_ptr_to_ptr = internal constant i32 ptrtoint (i32* @ptr to i32) | |
46 ; CHECK: @const_ptr_to_ptr = internal constant i32 ptrtoint (i32* @ptr to i32) | |
47 ; CHECK: .type const_ptr_to_ptr,@object | |
48 ; CHECK: .section .rodata,"a",@progbits | |
49 ; CHECK:const_ptr_to_ptr: | |
50 ; CHECK: .long ptr | |
51 ; CHECK: .size const_ptr_to_ptr, 4 | |
52 | |
53 @ptr_to_func = internal global i32 ptrtoint (void ()* @func to i32) | |
54 ; CHECK: @ptr_to_func = internal global i32 ptrtoint (void ()* @func to i32) | |
55 ; CHECK: .type ptr_to_func,@object | |
56 ; CHECK: .section .data,"aw",@progbits | |
57 ; CHECK:ptr_to_func: | |
58 ; CHECK: .long func | |
59 ; CHECK: .size ptr_to_func, 4 | |
60 | |
61 @const_ptr_to_func = internal constant i32 ptrtoint (void ()* @func to i32) | |
62 ; CHECK: @const_ptr_to_func = internal constant i32 ptrtoint (void ()* @func to i32) | |
63 ; CHECK: .type const_ptr_to_func,@object | |
64 ; CHECK: .section .rodata,"a",@progbits | |
65 ; CHECK:const_ptr_to_func: | |
66 ; CHECK: .long func | |
67 ; CHECK: .size const_ptr_to_func, 4 | |
68 | |
69 @compound = internal global <{ [3 x i8], i32 }> <{ [3 x i8] c"foo", i32 ptrtoint (void ()* @func to i32) }> | |
70 ; CHECK: @compound = internal global <{ [3 x i8], i32 }> <{ [3 x i8] c"foo", i32 ptrtoint (void ()* @func to i32) }> | |
71 ; CHECK: .type compound,@object | |
72 ; CHECK: .section .data,"aw",@progbits | |
73 ; CHECK:compound: | |
74 ; CHECK: .byte 102 | |
75 ; CHECK: .byte 111 | |
76 ; CHECK: .byte 111 | |
77 ; CHECK: .long func | |
78 ; CHECK: .size compound, 7 | |
79 | |
80 @const_compound = internal constant <{ [3 x i8], i32 }> <{ [3 x i8] c"foo", i32 ptrtoint (void ()* @func to i32) }> | |
81 ; CHECK: @const_compound = internal constant <{ [3 x i8], i32 }> <{ [3 x i8] c"f oo", i32 ptrtoint (void ()* @func to i32) }> | |
82 ; CHECK: .type const_compound,@object | |
83 ; CHECK: .section .rodata,"a",@progbits | |
84 ; CHECK:const_compound: | |
85 ; CHECK: .byte 102 | |
86 ; CHECK: .byte 111 | |
87 ; CHECK: .byte 111 | |
88 ; CHECK: .long func | |
89 ; CHECK: .size const_compound, 7 | |
90 | |
91 @ptr = internal global i32 ptrtoint ([7 x i8]* @bytes to i32) | |
92 ; CHECK: @ptr = internal global i32 ptrtoint ([7 x i8]* @bytes to i32) | |
93 ; CHECK: .type ptr,@object | |
94 ; CHECK: .section .data,"aw",@progbits | |
95 ; CHECK:ptr: | |
96 ; CHECK: .long bytes | |
97 ; CHECK: .size ptr, 4 | |
98 | |
99 @const_ptr = internal constant i32 ptrtoint ([7 x i8]* @bytes to i32) | |
100 ; CHECK: @const_ptr = internal constant i32 ptrtoint ([7 x i8]* @bytes to i32) | |
101 ; CHECK: .type const_ptr,@object | |
102 ; CHECK: .section .rodata,"a",@progbits | |
103 ; CHECK:const_ptr: | |
104 ; CHECK: .long bytes | |
105 ; CHECK: .size const_ptr, 4 | |
106 | |
107 @addend_ptr = internal global i32 add (i32 ptrtoint (i32* @ptr to i32), i32 1) | |
108 ; CHECK: @addend_ptr = internal global i32 add (i32 ptrtoint (i32* @ptr to i32), i32 1) | |
109 ; CHECK: .type addend_ptr,@object | |
110 ; CHECK: .section .data,"aw",@progbits | |
111 ; CHECK:addend_ptr: | |
112 ; CHECK: .long ptr + 1 | |
113 ; CHECK: .size addend_ptr, 4 | |
114 | |
115 @const_addend_ptr = internal constant i32 add (i32 ptrtoint (i32* @ptr to i32), i32 1) | |
116 ; CHECK: @const_addend_ptr = internal constant i32 add (i32 ptrtoint (i32* @ptr to i32), i32 1) | |
117 ; CHECK: .type const_addend_ptr,@object | |
118 ; CHECK: .section .rodata,"a",@progbits | |
119 ; CHECK:const_addend_ptr: | |
120 ; CHECK: .long ptr + 1 | |
121 ; CHECK: .size const_addend_ptr, 4 | |
122 | |
123 @addend_negative = internal global i32 add (i32 ptrtoint (i32* @ptr to i32), i32 -1) | |
124 ; CHECK: @addend_negative = internal global i32 add (i32 ptrtoint (i32* @ptr to i32), i32 -1) | |
125 ; CHECK: .type addend_negative,@object | |
126 ; CHECK: .section .data,"aw",@progbits | |
127 ; CHECK:addend_negative: | |
128 ; CHECK: .long ptr + -1 | |
Jim Stichnoth
2014/10/10 13:15:00
Maybe the emit code could make this a little prett
Karl
2014/10/10 20:17:31
Done. Note that "ptr + INT32_MIN" will not be pret
| |
129 ; CHECK: .size addend_negative, 4 | |
130 | |
131 @const_addend_negative = internal constant i32 add (i32 ptrtoint (i32* @ptr to i 32), i32 -1) | |
132 ; CHECK: @const_addend_negative = internal constant i32 add (i32 ptrtoint (i32* @ptr to i32), i32 -1) | |
133 ; CHECK: .type const_addend_negative,@object | |
134 ; CHECK: .section .rodata,"a",@progbits | |
135 ; CHECK:const_addend_negative: | |
136 ; CHECK: .long ptr + -1 | |
137 ; CHECK: .size const_addend_negative, 4 | |
138 | |
139 @addend_array1 = internal global i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32) , i32 1) | |
140 ; CHECK: @addend_array1 = internal global i32 add (i32 ptrtoint ([7 x i8]* @byte s to i32), i32 1) | |
141 ; CHECK: .type addend_array1,@object | |
142 ; CHECK: .section .data,"aw",@progbits | |
143 ; CHECK:addend_array1: | |
144 ; CHECK: .long bytes + 1 | |
145 ; CHECK: .size addend_array1, 4 | |
146 | |
147 @const_addend_array1 = internal constant i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 1) | |
148 ; CHECK: @const_addend_array1 = internal constant i32 add (i32 ptrtoint ([7 x i8 ]* @bytes to i32), i32 1) | |
149 ; CHECK: .type const_addend_array1,@object | |
150 ; CHECK: .section .rodata,"a",@progbits | |
151 ; CHECK:const_addend_array1: | |
152 ; CHECK: .long bytes + 1 | |
153 ; CHECK: .size const_addend_array1, 4 | |
154 | |
155 @addend_array2 = internal global i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32) , i32 7) | |
156 ; CHECK: @addend_array2 = internal global i32 add (i32 ptrtoint ([7 x i8]* @byte s to i32), i32 7) | |
157 ; CHECK: .type addend_array2,@object | |
158 ; CHECK: .section .data,"aw",@progbits | |
159 ; CHECK:addend_array2: | |
160 ; CHECK: .long bytes + 7 | |
161 ; CHECK: .size addend_array2, 4 | |
162 | |
163 @const_addend_array2 = internal constant i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 7) | |
164 ; CHECK: @const_addend_array2 = internal constant i32 add (i32 ptrtoint ([7 x i8 ]* @bytes to i32), i32 7) | |
165 ; CHECK: .type const_addend_array2,@object | |
166 ; CHECK: .section .rodata,"a",@progbits | |
167 ; CHECK:const_addend_array2: | |
168 ; CHECK: .long bytes + 7 | |
169 ; CHECK: .size const_addend_array2, 4 | |
170 | |
171 @addend_array3 = internal global i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32) , i32 9) | |
172 ; CHECK: @addend_array3 = internal global i32 add (i32 ptrtoint ([7 x i8]* @byte s to i32), i32 9) | |
173 ; CHECK: .type addend_array3,@object | |
174 ; CHECK: .section .data,"aw",@progbits | |
175 ; CHECK:addend_array3: | |
176 ; CHECK: .long bytes + 9 | |
177 ; CHECK: .size addend_array3, 4 | |
178 | |
179 @const_addend_array3 = internal constant i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 9) | |
180 ; CHECK: @const_addend_array3 = internal constant i32 add (i32 ptrtoint ([7 x i8 ]* @bytes to i32), i32 9) | |
181 ; CHECK: .type const_addend_array3,@object | |
182 ; CHECK: .section .rodata,"a",@progbits | |
183 ; CHECK:const_addend_array3: | |
184 ; CHECK: .long bytes + 9 | |
185 ; CHECK: .size const_addend_array3, 4 | |
186 | |
187 @addend_struct1 = internal global i32 add (i32 ptrtoint (<{ [3 x i8], i32 }>* @c ompound to i32), i32 1) | |
188 ; CHECK: @addend_struct1 = internal global i32 add (i32 ptrtoint (<{ [3 x i8], i 32 }>* @compound to i32), i32 1) | |
189 ; CHECK: .type addend_struct1,@object | |
190 ; CHECK: .section .data,"aw",@progbits | |
191 ; CHECK:addend_struct1: | |
192 ; CHECK: .long compound + 1 | |
193 ; CHECK: .size addend_struct1, 4 | |
194 | |
195 @const_addend_struct1 = internal constant i32 add (i32 ptrtoint (<{ [3 x i8], i3 2 }>* @compound to i32), i32 1) | |
196 ; CHECK: @const_addend_struct1 = internal constant i32 add (i32 ptrtoint (<{ [3 x i8], i32 }>* @compound to i32), i32 1) | |
197 ; CHECK: .type const_addend_struct1,@object | |
198 ; CHECK: .section .rodata,"a",@progbits | |
199 ; CHECK:const_addend_struct1: | |
200 ; CHECK: .long compound + 1 | |
201 ; CHECK: .size const_addend_struct1, 4 | |
202 | |
203 @addend_struct2 = internal global i32 add (i32 ptrtoint (<{ [3 x i8], i32 }>* @c ompound to i32), i32 4) | |
204 ; CHECK: @addend_struct2 = internal global i32 add (i32 ptrtoint (<{ [3 x i8], i 32 }>* @compound to i32), i32 4) | |
205 ; CHECK: .type addend_struct2,@object | |
206 ; CHECK: .section .data,"aw",@progbits | |
207 ; CHECK:addend_struct2: | |
208 ; CHECK: .long compound + 4 | |
209 ; CHECK: .size addend_struct2, 4 | |
210 | |
211 @const_addend_struct2 = internal constant i32 add (i32 ptrtoint (<{ [3 x i8], i3 2 }>* @compound to i32), i32 4) | |
212 ; CHECK: @const_addend_struct2 = internal constant i32 add (i32 ptrtoint (<{ [3 x i8], i32 }>* @compound to i32), i32 4) | |
213 ; CHECK: .type const_addend_struct2,@object | |
214 ; CHECK: .section .rodata,"a",@progbits | |
215 ; CHECK:const_addend_struct2: | |
216 ; CHECK: .long compound + 4 | |
217 ; CHECK: .size const_addend_struct2, 4 | |
218 | |
219 @ptr_to_func_align = internal global i32 ptrtoint (void ()* @func to i32), align 8 | |
220 ; CHECK: @ptr_to_func_align = internal global i32 ptrtoint (void ()* @func to i3 2), align 8 | |
221 ; CHECK: .type ptr_to_func_align,@object | |
222 ; CHECK: .section .data,"aw",@progbits | |
223 ; CHECK: .align 8 | |
224 ; CHECK:ptr_to_func_align: | |
225 ; CHECK: .long func | |
226 ; CHECK: .size ptr_to_func_align, 4 | |
227 | |
228 @const_ptr_to_func_align = internal constant i32 ptrtoint (void ()* @func to i32 ), align 8 | |
229 ; CHECK: @const_ptr_to_func_align = internal constant i32 ptrtoint (void ()* @fu nc to i32), align 8 | |
230 ; CHECK: .type const_ptr_to_func_align,@object | |
231 ; CHECK: .section .rodata,"a",@progbits | |
232 ; CHECK: .align 8 | |
233 ; CHECK:const_ptr_to_func_align: | |
234 ; CHECK: .long func | |
235 ; CHECK: .size const_ptr_to_func_align, 4 | |
236 | |
237 @char = internal constant [1 x i8] c"0" | |
238 ; CHECK: @char = internal constant [1 x i8] c"0" | |
239 ; CHECK: .type char,@object | |
240 ; CHECK: .section .rodata,"a",@progbits | |
241 ; CHECK:char: | |
242 ; CHECK: .byte 48 | |
243 ; CHECK: .size char, 1 | |
244 | |
245 @short = internal constant [2 x i8] zeroinitializer | |
246 ; CHECK: @short = internal constant [2 x i8] zeroinitializer | |
247 ; CHECK: .type short,@object | |
248 ; CHECK: .section .rodata,"a",@progbits | |
249 ; CHECK:short: | |
250 ; CHECK: .zero 2 | |
251 ; CHECK: .size short, 2 | |
252 | |
253 define void @func() { | |
254 ret void | |
255 } | |
256 | |
257 ; CHECK: define void @func() { | |
258 | |
OLD | NEW |