Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1119)

Side by Side Diff: tests_lit/llvm2ice_tests/alloc.ll

Issue 1387963002: Make sure that all globals are internal, except for "start" functions. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix new tests. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests_lit/llvm2ice_tests/align-spill-locations.ll ('k') | tests_lit/llvm2ice_tests/arith.ll » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 ; This is a basic test of the alloca instruction. 1 ; This is a basic test of the alloca instruction.
2 2
3 ; RUN: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \ 3 ; RUN: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \
4 ; RUN: --target x8632 -i %s --args -O2 \ 4 ; RUN: --target x8632 -i %s --args -O2 -allow-externally-defined-symbols \
5 ; RUN: | %if --need=target_X8632 --command FileCheck %s 5 ; RUN: | %if --need=target_X8632 --command FileCheck %s
6 6
7 ; RUN: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \ 7 ; RUN: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \
8 ; RUN: --target x8632 -i %s --args -Om1 \ 8 ; RUN: --target x8632 -i %s --args -Om1 -allow-externally-defined-symbols \
9 ; RUN: | %if --need=target_X8632 --command FileCheck %s 9 ; RUN: | %if --need=target_X8632 --command FileCheck %s
10 10
11 ; TODO(jvoung): Stop skipping unimplemented parts (via --skip-unimplemented) 11 ; TODO(jvoung): Stop skipping unimplemented parts (via --skip-unimplemented)
12 ; once enough infrastructure is in. Also, switch to --filetype=obj 12 ; once enough infrastructure is in. Also, switch to --filetype=obj
13 ; when possible. 13 ; when possible.
14 ; RUN: %if --need=target_ARM32 --need=allow_dump \ 14 ; RUN: %if --need=target_ARM32 --need=allow_dump \
15 ; RUN: --command %p2i --filetype=asm --assemble \ 15 ; RUN: --command %p2i --filetype=asm --assemble \
16 ; RUN: --disassemble --target arm32 -i %s --args -O2 --skip-unimplemented \ 16 ; RUN: --disassemble --target arm32 -i %s --args -O2 --skip-unimplemented \
17 ; RUN: -allow-externally-defined-symbols \
17 ; RUN: | %if --need=target_ARM32 --need=allow_dump \ 18 ; RUN: | %if --need=target_ARM32 --need=allow_dump \
18 ; RUN: --command FileCheck --check-prefix ARM32 %s 19 ; RUN: --command FileCheck --check-prefix ARM32 %s
19 20
20 ; RUN: %if --need=target_ARM32 --need=allow_dump \ 21 ; RUN: %if --need=target_ARM32 --need=allow_dump \
21 ; RUN: --command %p2i --filetype=asm --assemble \ 22 ; RUN: --command %p2i --filetype=asm --assemble \
22 ; RUN: --disassemble --target arm32 -i %s --args -Om1 --skip-unimplemented \ 23 ; RUN: --disassemble --target arm32 -i %s --args -Om1 --skip-unimplemented \
24 ; RUN: -allow-externally-defined-symbols \
23 ; RUN: | %if --need=target_ARM32 --need=allow_dump \ 25 ; RUN: | %if --need=target_ARM32 --need=allow_dump \
24 ; RUN: --command FileCheck --check-prefix ARM32 %s 26 ; RUN: --command FileCheck --check-prefix ARM32 %s
25 27
26 define void @fixed_416_align_16(i32 %n) { 28 define internal void @fixed_416_align_16(i32 %n) {
27 entry: 29 entry:
28 %array = alloca i8, i32 416, align 16 30 %array = alloca i8, i32 416, align 16
29 %__2 = ptrtoint i8* %array to i32 31 %__2 = ptrtoint i8* %array to i32
30 call void @f1(i32 %__2) 32 call void @f1(i32 %__2)
31 ret void 33 ret void
32 } 34 }
33 ; CHECK-LABEL: fixed_416_align_16 35 ; CHECK-LABEL: fixed_416_align_16
34 ; CHECK: sub esp,0x1a0 36 ; CHECK: sub esp,0x1a0
35 ; CHECK: sub esp,0x10 37 ; CHECK: sub esp,0x10
36 ; CHECK: mov DWORD PTR [esp],eax 38 ; CHECK: mov DWORD PTR [esp],eax
37 ; CHECK: call {{.*}} R_{{.*}} f1 39 ; CHECK: call {{.*}} R_{{.*}} f1
38 40
39 ; ARM32-LABEL: fixed_416_align_16 41 ; ARM32-LABEL: fixed_416_align_16
40 ; ARM32: sub sp, sp, #416 42 ; ARM32: sub sp, sp, #416
41 ; ARM32: bl {{.*}} R_{{.*}} f1 43 ; ARM32: bl {{.*}} R_{{.*}} f1
42 44
43 define void @fixed_416_align_32(i32 %n) { 45 define internal void @fixed_416_align_32(i32 %n) {
44 entry: 46 entry:
45 %array = alloca i8, i32 400, align 32 47 %array = alloca i8, i32 400, align 32
46 %__2 = ptrtoint i8* %array to i32 48 %__2 = ptrtoint i8* %array to i32
47 call void @f1(i32 %__2) 49 call void @f1(i32 %__2)
48 ret void 50 ret void
49 } 51 }
50 ; CHECK-LABEL: fixed_416_align_32 52 ; CHECK-LABEL: fixed_416_align_32
51 ; CHECK: and esp,0xffffffe0 53 ; CHECK: and esp,0xffffffe0
52 ; CHECK: sub esp,0x1a0 54 ; CHECK: sub esp,0x1a0
53 ; CHECK: sub esp,0x10 55 ; CHECK: sub esp,0x10
54 ; CHECK: mov DWORD PTR [esp],eax 56 ; CHECK: mov DWORD PTR [esp],eax
55 ; CHECK: call {{.*}} R_{{.*}} f1 57 ; CHECK: call {{.*}} R_{{.*}} f1
56 58
57 ; ARM32-LABEL: fixed_416_align_32 59 ; ARM32-LABEL: fixed_416_align_32
58 ; ARM32: bic sp, sp, #31 60 ; ARM32: bic sp, sp, #31
59 ; ARM32: sub sp, sp, #416 61 ; ARM32: sub sp, sp, #416
60 ; ARM32: bl {{.*}} R_{{.*}} f1 62 ; ARM32: bl {{.*}} R_{{.*}} f1
61 63
62 ; Show that the amount to allocate will be rounded up. 64 ; Show that the amount to allocate will be rounded up.
63 define void @fixed_351_align_16(i32 %n) { 65 define internal void @fixed_351_align_16(i32 %n) {
64 entry: 66 entry:
65 %array = alloca i8, i32 351, align 16 67 %array = alloca i8, i32 351, align 16
66 %__2 = ptrtoint i8* %array to i32 68 %__2 = ptrtoint i8* %array to i32
67 call void @f1(i32 %__2) 69 call void @f1(i32 %__2)
68 ret void 70 ret void
69 } 71 }
70 ; CHECK-LABEL: fixed_351_align_16 72 ; CHECK-LABEL: fixed_351_align_16
71 ; CHECK: sub esp,0x160 73 ; CHECK: sub esp,0x160
72 ; CHECK: sub esp,0x10 74 ; CHECK: sub esp,0x10
73 ; CHECK: mov DWORD PTR [esp],eax 75 ; CHECK: mov DWORD PTR [esp],eax
74 ; CHECK: call {{.*}} R_{{.*}} f1 76 ; CHECK: call {{.*}} R_{{.*}} f1
75 77
76 ; ARM32-LABEL: fixed_351_align_16 78 ; ARM32-LABEL: fixed_351_align_16
77 ; ARM32: sub sp, sp, #352 79 ; ARM32: sub sp, sp, #352
78 ; ARM32: bl {{.*}} R_{{.*}} f1 80 ; ARM32: bl {{.*}} R_{{.*}} f1
79 81
80 define void @fixed_351_align_32(i32 %n) { 82 define internal void @fixed_351_align_32(i32 %n) {
81 entry: 83 entry:
82 %array = alloca i8, i32 351, align 32 84 %array = alloca i8, i32 351, align 32
83 %__2 = ptrtoint i8* %array to i32 85 %__2 = ptrtoint i8* %array to i32
84 call void @f1(i32 %__2) 86 call void @f1(i32 %__2)
85 ret void 87 ret void
86 } 88 }
87 ; CHECK-LABEL: fixed_351_align_32 89 ; CHECK-LABEL: fixed_351_align_32
88 ; CHECK: and esp,0xffffffe0 90 ; CHECK: and esp,0xffffffe0
89 ; CHECK: sub esp,0x160 91 ; CHECK: sub esp,0x160
90 ; CHECK: sub esp,0x10 92 ; CHECK: sub esp,0x10
91 ; CHECK: mov DWORD PTR [esp],eax 93 ; CHECK: mov DWORD PTR [esp],eax
92 ; CHECK: call {{.*}} R_{{.*}} f1 94 ; CHECK: call {{.*}} R_{{.*}} f1
93 95
94 ; ARM32-LABEL: fixed_351_align_32 96 ; ARM32-LABEL: fixed_351_align_32
95 ; ARM32: bic sp, sp, #31 97 ; ARM32: bic sp, sp, #31
96 ; ARM32: sub sp, sp, #352 98 ; ARM32: sub sp, sp, #352
97 ; ARM32: bl {{.*}} R_{{.*}} f1 99 ; ARM32: bl {{.*}} R_{{.*}} f1
98 100
99 declare void @f1(i32 %ignored) 101 declare void @f1(i32 %ignored)
100 102
101 declare void @f2(i32 %ignored) 103 declare void @f2(i32 %ignored)
102 104
103 define void @variable_n_align_16(i32 %n) { 105 define internal void @variable_n_align_16(i32 %n) {
104 entry: 106 entry:
105 %array = alloca i8, i32 %n, align 16 107 %array = alloca i8, i32 %n, align 16
106 %__2 = ptrtoint i8* %array to i32 108 %__2 = ptrtoint i8* %array to i32
107 call void @f2(i32 %__2) 109 call void @f2(i32 %__2)
108 ret void 110 ret void
109 } 111 }
110 ; CHECK-LABEL: variable_n_align_16 112 ; CHECK-LABEL: variable_n_align_16
111 ; CHECK: mov eax,DWORD PTR [ebp+0x8] 113 ; CHECK: mov eax,DWORD PTR [ebp+0x8]
112 ; CHECK: add eax,0xf 114 ; CHECK: add eax,0xf
113 ; CHECK: and eax,0xfffffff0 115 ; CHECK: and eax,0xfffffff0
114 ; CHECK: sub esp,eax 116 ; CHECK: sub esp,eax
115 ; CHECK: sub esp,0x10 117 ; CHECK: sub esp,0x10
116 ; CHECK: mov DWORD PTR [esp],eax 118 ; CHECK: mov DWORD PTR [esp],eax
117 ; CHECK: call {{.*}} R_{{.*}} f2 119 ; CHECK: call {{.*}} R_{{.*}} f2
118 120
119 ; ARM32-LABEL: variable_n_align_16 121 ; ARM32-LABEL: variable_n_align_16
120 ; ARM32: add r0, r0, #15 122 ; ARM32: add r0, r0, #15
121 ; ARM32: bic r0, r0, #15 123 ; ARM32: bic r0, r0, #15
122 ; ARM32: sub sp, sp, r0 124 ; ARM32: sub sp, sp, r0
123 ; ARM32: bl {{.*}} R_{{.*}} f2 125 ; ARM32: bl {{.*}} R_{{.*}} f2
124 126
125 define void @variable_n_align_32(i32 %n) { 127 define internal void @variable_n_align_32(i32 %n) {
126 entry: 128 entry:
127 %array = alloca i8, i32 %n, align 32 129 %array = alloca i8, i32 %n, align 32
128 %__2 = ptrtoint i8* %array to i32 130 %__2 = ptrtoint i8* %array to i32
129 call void @f2(i32 %__2) 131 call void @f2(i32 %__2)
130 ret void 132 ret void
131 } 133 }
132 ; In -O2, the order of the CHECK-DAG lines in the output is switched. 134 ; In -O2, the order of the CHECK-DAG lines in the output is switched.
133 ; CHECK-LABEL: variable_n_align_32 135 ; CHECK-LABEL: variable_n_align_32
134 ; CHECK: push ebp 136 ; CHECK: push ebp
135 ; CHECK: mov ebp,esp 137 ; CHECK: mov ebp,esp
(...skipping 13 matching lines...) Expand all
149 ; ARM32: mov fp, sp 151 ; ARM32: mov fp, sp
150 ; ARM32: bic sp, sp, #31 152 ; ARM32: bic sp, sp, #31
151 ; ARM32: add r0, r0, #31 153 ; ARM32: add r0, r0, #31
152 ; ARM32: bic r0, r0, #31 154 ; ARM32: bic r0, r0, #31
153 ; ARM32: sub sp, sp, r0 155 ; ARM32: sub sp, sp, r0
154 ; ARM32: bl {{.*}} R_{{.*}} f2 156 ; ARM32: bl {{.*}} R_{{.*}} f2
155 ; ARM32: mov sp, fp 157 ; ARM32: mov sp, fp
156 ; ARM32: pop {fp, lr} 158 ; ARM32: pop {fp, lr}
157 159
158 ; Test alloca with default (0) alignment. 160 ; Test alloca with default (0) alignment.
159 define void @align0(i32 %n) { 161 define internal void @align0(i32 %n) {
160 entry: 162 entry:
161 %array = alloca i8, i32 %n 163 %array = alloca i8, i32 %n
162 %__2 = ptrtoint i8* %array to i32 164 %__2 = ptrtoint i8* %array to i32
163 call void @f2(i32 %__2) 165 call void @f2(i32 %__2)
164 ret void 166 ret void
165 } 167 }
166 ; CHECK-LABEL: align0 168 ; CHECK-LABEL: align0
167 ; CHECK: add [[REG:.*]],0xf 169 ; CHECK: add [[REG:.*]],0xf
168 ; CHECK: and [[REG]],0xfffffff0 170 ; CHECK: and [[REG]],0xfffffff0
169 ; CHECK: sub esp,[[REG]] 171 ; CHECK: sub esp,[[REG]]
170 172
171 ; ARM32-LABEL: align0 173 ; ARM32-LABEL: align0
172 ; ARM32: add r0, r0, #15 174 ; ARM32: add r0, r0, #15
173 ; ARM32: bic r0, r0, #15 175 ; ARM32: bic r0, r0, #15
174 ; ARM32: sub sp, sp, r0 176 ; ARM32: sub sp, sp, r0
175 177
176 ; Test a large alignment where a mask might not fit in an immediate 178 ; Test a large alignment where a mask might not fit in an immediate
177 ; field of an instruction for some architectures. 179 ; field of an instruction for some architectures.
178 define void @align1MB(i32 %n) { 180 define internal void @align1MB(i32 %n) {
179 entry: 181 entry:
180 %array = alloca i8, i32 %n, align 1048576 182 %array = alloca i8, i32 %n, align 1048576
181 %__2 = ptrtoint i8* %array to i32 183 %__2 = ptrtoint i8* %array to i32
182 call void @f2(i32 %__2) 184 call void @f2(i32 %__2)
183 ret void 185 ret void
184 } 186 }
185 ; CHECK-LABEL: align1MB 187 ; CHECK-LABEL: align1MB
186 ; CHECK: and esp,0xfff00000 188 ; CHECK: and esp,0xfff00000
187 ; CHECK: add [[REG:.*]],0xfffff 189 ; CHECK: add [[REG:.*]],0xfffff
188 ; CHECK: and [[REG]],0xfff00000 190 ; CHECK: and [[REG]],0xfff00000
189 ; CHECK: sub esp,[[REG]] 191 ; CHECK: sub esp,[[REG]]
190 192
191 ; ARM32-LABEL: align1MB 193 ; ARM32-LABEL: align1MB
192 ; ARM32: movw [[REG:.*]], #0 194 ; ARM32: movw [[REG:.*]], #0
193 ; ARM32: movt [[REG]], #65520 ; 0xfff0 195 ; ARM32: movt [[REG]], #65520 ; 0xfff0
194 ; ARM32: and sp, sp, [[REG]] 196 ; ARM32: and sp, sp, [[REG]]
195 ; ARM32: movw [[REG2:.*]], #65535 ; 0xffff 197 ; ARM32: movw [[REG2:.*]], #65535 ; 0xffff
196 ; ARM32: movt [[REG2]], #15 198 ; ARM32: movt [[REG2]], #15
197 ; ARM32: add r0, r0, [[REG2]] 199 ; ARM32: add r0, r0, [[REG2]]
198 ; ARM32: movw [[REG3:.*]], #0 200 ; ARM32: movw [[REG3:.*]], #0
199 ; ARM32: movt [[REG3]], #65520 ; 0xfff0 201 ; ARM32: movt [[REG3]], #65520 ; 0xfff0
200 ; ARM32: and r0, r0, [[REG3]] 202 ; ARM32: and r0, r0, [[REG3]]
201 ; ARM32: sub sp, sp, r0 203 ; ARM32: sub sp, sp, r0
202 204
203 ; Test a large alignment where a mask might still fit in an immediate 205 ; Test a large alignment where a mask might still fit in an immediate
204 ; field of an instruction for some architectures. 206 ; field of an instruction for some architectures.
205 define void @align512MB(i32 %n) { 207 define internal void @align512MB(i32 %n) {
206 entry: 208 entry:
207 %array = alloca i8, i32 %n, align 536870912 209 %array = alloca i8, i32 %n, align 536870912
208 %__2 = ptrtoint i8* %array to i32 210 %__2 = ptrtoint i8* %array to i32
209 call void @f2(i32 %__2) 211 call void @f2(i32 %__2)
210 ret void 212 ret void
211 } 213 }
212 ; CHECK-LABEL: align512MB 214 ; CHECK-LABEL: align512MB
213 ; CHECK: and esp,0xe0000000 215 ; CHECK: and esp,0xe0000000
214 ; CHECK: add [[REG:.*]],0x1fffffff 216 ; CHECK: add [[REG:.*]],0x1fffffff
215 ; CHECK: and [[REG]],0xe0000000 217 ; CHECK: and [[REG]],0xe0000000
216 ; CHECK: sub esp,[[REG]] 218 ; CHECK: sub esp,[[REG]]
217 219
218 ; ARM32-LABEL: align512MB 220 ; ARM32-LABEL: align512MB
219 ; ARM32: and sp, sp, #-536870912 ; 0xe0000000 221 ; ARM32: and sp, sp, #-536870912 ; 0xe0000000
220 ; ARM32: mvn [[REG:.*]], #-536870912 ; 0xe0000000 222 ; ARM32: mvn [[REG:.*]], #-536870912 ; 0xe0000000
221 ; ARM32: add r0, r0, [[REG]] 223 ; ARM32: add r0, r0, [[REG]]
222 ; ARM32: and r0, r0, #-536870912 ; 0xe0000000 224 ; ARM32: and r0, r0, #-536870912 ; 0xe0000000
223 ; ARM32: sub sp, sp, r0 225 ; ARM32: sub sp, sp, r0
224 226
225 ; Test that a simple alloca sequence doesn't trigger a frame pointer. 227 ; Test that a simple alloca sequence doesn't trigger a frame pointer.
226 define void @fixed_no_frameptr(i32 %arg) { 228 define internal void @fixed_no_frameptr(i32 %arg) {
227 entry: 229 entry:
228 %a1 = alloca i8, i32 8, align 4 230 %a1 = alloca i8, i32 8, align 4
229 %a2 = alloca i8, i32 12, align 4 231 %a2 = alloca i8, i32 12, align 4
230 %a3 = alloca i8, i32 16, align 4 232 %a3 = alloca i8, i32 16, align 4
231 %p1 = bitcast i8* %a1 to i32* 233 %p1 = bitcast i8* %a1 to i32*
232 %p2 = bitcast i8* %a2 to i32* 234 %p2 = bitcast i8* %a2 to i32*
233 %p3 = bitcast i8* %a3 to i32* 235 %p3 = bitcast i8* %a3 to i32*
234 store i32 %arg, i32* %p1, align 1 236 store i32 %arg, i32* %p1, align 1
235 store i32 %arg, i32* %p2, align 1 237 store i32 %arg, i32* %p2, align 1
236 store i32 %arg, i32* %p3, align 1 238 store i32 %arg, i32* %p3, align 1
237 ret void 239 ret void
238 } 240 }
239 ; CHECK-LABEL: fixed_no_frameptr 241 ; CHECK-LABEL: fixed_no_frameptr
240 ; CHECK-NOT: mov ebp,esp 242 ; CHECK-NOT: mov ebp,esp
241 243
242 ; Test that a more complex alloca sequence does trigger a frame pointer. 244 ; Test that a more complex alloca sequence does trigger a frame pointer.
243 define void @var_with_frameptr(i32 %arg) { 245 define internal void @var_with_frameptr(i32 %arg) {
244 entry: 246 entry:
245 %a1 = alloca i8, i32 8, align 4 247 %a1 = alloca i8, i32 8, align 4
246 %a2 = alloca i8, i32 12, align 4 248 %a2 = alloca i8, i32 12, align 4
247 %a3 = alloca i8, i32 %arg, align 4 249 %a3 = alloca i8, i32 %arg, align 4
248 %p1 = bitcast i8* %a1 to i32* 250 %p1 = bitcast i8* %a1 to i32*
249 %p2 = bitcast i8* %a2 to i32* 251 %p2 = bitcast i8* %a2 to i32*
250 %p3 = bitcast i8* %a3 to i32* 252 %p3 = bitcast i8* %a3 to i32*
251 store i32 %arg, i32* %p1, align 1 253 store i32 %arg, i32* %p1, align 1
252 store i32 %arg, i32* %p2, align 1 254 store i32 %arg, i32* %p2, align 1
253 store i32 %arg, i32* %p3, align 1 255 store i32 %arg, i32* %p3, align 1
254 ret void 256 ret void
255 } 257 }
256 ; CHECK-LABEL: var_with_frameptr 258 ; CHECK-LABEL: var_with_frameptr
257 ; CHECK: mov ebp,esp 259 ; CHECK: mov ebp,esp
OLDNEW
« no previous file with comments | « tests_lit/llvm2ice_tests/align-spill-locations.ll ('k') | tests_lit/llvm2ice_tests/arith.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698