OLD | NEW |
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 -allow-externally-defined-symbols \ | 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 -allow-externally-defined-symbols \ | 8 ; RUN: --target x8632 -i %s --args -Om1 -allow-externally-defined-symbols \ |
9 ; RUN: | %if --need=target_X8632 --command FileCheck \ | 9 ; RUN: | %if --need=target_X8632 --command FileCheck \ |
10 ; RUN: --check-prefix CHECK-OPTM1 %s | 10 ; RUN: --check-prefix CHECK-OPTM1 %s |
11 | 11 |
| 12 ; TODO(jvoung): Stop skipping unimplemented parts (via --skip-unimplemented) |
| 13 ; once enough infrastructure is in. Also, switch to --filetype=obj |
| 14 ; when possible. |
12 ; RUN: %if --need=target_ARM32 --need=allow_dump \ | 15 ; RUN: %if --need=target_ARM32 --need=allow_dump \ |
13 ; RUN: --command %p2i --filetype=obj --assemble \ | 16 ; RUN: --command %p2i --filetype=asm --assemble \ |
14 ; RUN: --disassemble --target arm32 -i %s --args -O2 \ | 17 ; RUN: --disassemble --target arm32 -i %s --args -O2 --skip-unimplemented \ |
15 ; RUN: -allow-externally-defined-symbols \ | 18 ; RUN: -allow-externally-defined-symbols \ |
16 ; RUN: | %if --need=target_ARM32 --need=allow_dump \ | 19 ; RUN: | %if --need=target_ARM32 --need=allow_dump \ |
17 ; RUN: --command FileCheck --check-prefix ARM32 --check-prefix=ARM-OPT2 %s | 20 ; RUN: --command FileCheck --check-prefix ARM32 --check-prefix=ARM-OPT2 %s |
18 | 21 |
19 ; RUN: %if --need=target_ARM32 --need=allow_dump \ | 22 ; RUN: %if --need=target_ARM32 --need=allow_dump \ |
20 ; RUN: --command %p2i --filetype=obj --assemble \ | 23 ; RUN: --command %p2i --filetype=asm --assemble \ |
21 ; RUN: --disassemble --target arm32 -i %s --args -Om1 \ | 24 ; RUN: --disassemble --target arm32 -i %s --args -Om1 --skip-unimplemented \ |
22 ; RUN: -allow-externally-defined-symbols \ | 25 ; RUN: -allow-externally-defined-symbols \ |
23 ; RUN: | %if --need=target_ARM32 --need=allow_dump \ | 26 ; RUN: | %if --need=target_ARM32 --need=allow_dump \ |
24 ; RUN: --command FileCheck --check-prefix ARM32 --check-prefix=ARM-OPTM1 %s | 27 ; RUN: --command FileCheck --check-prefix ARM32 --check-prefix=ARM-OPTM1 %s |
25 | 28 |
26 define internal void @fixed_416_align_16(i32 %n) { | 29 define internal void @fixed_416_align_16(i32 %n) { |
27 entry: | 30 entry: |
28 %array = alloca i8, i32 416, align 16 | 31 %array = alloca i8, i32 416, align 16 |
29 %__2 = ptrtoint i8* %array to i32 | 32 %__2 = ptrtoint i8* %array to i32 |
30 call void @f1(i32 %__2) | 33 call void @f1(i32 %__2) |
31 ret void | 34 ret void |
32 } | 35 } |
33 ; CHECK-LABEL: fixed_416_align_16 | 36 ; CHECK-LABEL: fixed_416_align_16 |
34 ; CHECK: sub esp,0x1bc | 37 ; CHECK: sub esp,0x1bc |
35 ; CHECK: lea eax,[esp+0x10] | 38 ; CHECK: lea eax,[esp+0x10] |
36 ; CHECK: mov DWORD PTR [esp],eax | 39 ; CHECK: mov DWORD PTR [esp],eax |
37 ; CHECK: call {{.*}} R_{{.*}} f1 | 40 ; CHECK: call {{.*}} R_{{.*}} f1 |
38 | 41 |
39 ; CHECK-OPTM1-LABEL: fixed_416_align_16 | 42 ; CHECK-OPTM1-LABEL: fixed_416_align_16 |
40 ; CHECK-OPTM1: sub esp,0x18 | 43 ; CHECK-OPTM1: sub esp,0x18 |
41 ; CHECK-OPTM1: sub esp,0x1a0 | 44 ; CHECK-OPTM1: sub esp,0x1a0 |
42 ; CHECK-OPTM1: mov DWORD PTR [esp],eax | 45 ; CHECK-OPTM1: mov DWORD PTR [esp],eax |
43 ; CHECK-OPTM1: call {{.*}} R_{{.*}} f1 | 46 ; CHECK-OPTM1: call {{.*}} R_{{.*}} f1 |
44 | 47 |
45 ; ARM32-LABEL: fixed_416_align_16 | 48 ; ARM32-LABEL: fixed_416_align_16 |
46 ; ARM32-OPT2: sub sp, sp, #428 | 49 ; ARM32-OPT2: sub sp, sp, #428 |
47 ; ARM32-OPTM1: sub sp, sp, #416 | 50 ; ARM32-OPTM1: sub sp, sp, #416 |
48 ; ARM32: movw [[CALL:r[0-9]]], {{.+}} f1 | 51 ; ARM32: bl {{.*}} R_{{.*}} f1 |
49 ; ARM32: movt [[CALL]], {{.+}} f1 | |
50 ; ARM32: blx [[CALL]] | |
51 | 52 |
52 define internal void @fixed_416_align_32(i32 %n) { | 53 define internal void @fixed_416_align_32(i32 %n) { |
53 entry: | 54 entry: |
54 %array = alloca i8, i32 400, align 32 | 55 %array = alloca i8, i32 400, align 32 |
55 %__2 = ptrtoint i8* %array to i32 | 56 %__2 = ptrtoint i8* %array to i32 |
56 call void @f1(i32 %__2) | 57 call void @f1(i32 %__2) |
57 ret void | 58 ret void |
58 } | 59 } |
59 ; CHECK-LABEL: fixed_416_align_32 | 60 ; CHECK-LABEL: fixed_416_align_32 |
60 ; CHECK: push ebp | 61 ; CHECK: push ebp |
61 ; CHECK-NEXT: mov ebp,esp | 62 ; CHECK-NEXT: mov ebp,esp |
62 ; CHECK: sub esp,0x1b8 | 63 ; CHECK: sub esp,0x1b8 |
63 ; CHECK: and esp,0xffffffe0 | 64 ; CHECK: and esp,0xffffffe0 |
64 ; CHECK: lea eax,[esp+0x10] | 65 ; CHECK: lea eax,[esp+0x10] |
65 ; CHECK: mov DWORD PTR [esp],eax | 66 ; CHECK: mov DWORD PTR [esp],eax |
66 ; CHECK: call {{.*}} R_{{.*}} f1 | 67 ; CHECK: call {{.*}} R_{{.*}} f1 |
67 | 68 |
68 ; ARM32-LABEL: fixed_416_align_32 | 69 ; ARM32-LABEL: fixed_416_align_32 |
69 ; ARM32-OPT2: sub sp, sp, #424 | 70 ; ARM32-OPT2: sub sp, sp, #424 |
70 ; ARM32-OPTM1: sub sp, sp, #416 | 71 ; ARM32-OPTM1: sub sp, sp, #416 |
71 ; ARM32: bic sp, sp, #31 | 72 ; ARM32: bic sp, sp, #31 |
72 ; ARM32: movw [[CALL:r[0-9]]], {{.+}} f1 | 73 ; ARM32: bl {{.*}} R_{{.*}} f1 |
73 ; ARM32: movt [[CALL]], {{.+}} f1 | |
74 ; ARM32: blx [[CALL]] | |
75 | 74 |
76 ; Show that the amount to allocate will be rounded up. | 75 ; Show that the amount to allocate will be rounded up. |
77 define internal void @fixed_351_align_16(i32 %n) { | 76 define internal void @fixed_351_align_16(i32 %n) { |
78 entry: | 77 entry: |
79 %array = alloca i8, i32 351, align 16 | 78 %array = alloca i8, i32 351, align 16 |
80 %__2 = ptrtoint i8* %array to i32 | 79 %__2 = ptrtoint i8* %array to i32 |
81 call void @f1(i32 %__2) | 80 call void @f1(i32 %__2) |
82 ret void | 81 ret void |
83 } | 82 } |
84 ; CHECK-LABEL: fixed_351_align_16 | 83 ; CHECK-LABEL: fixed_351_align_16 |
85 ; CHECK: sub esp,0x17c | 84 ; CHECK: sub esp,0x17c |
86 ; CHECK: lea eax,[esp+0x10] | 85 ; CHECK: lea eax,[esp+0x10] |
87 ; CHECK: mov DWORD PTR [esp],eax | 86 ; CHECK: mov DWORD PTR [esp],eax |
88 ; CHECK: call {{.*}} R_{{.*}} f1 | 87 ; CHECK: call {{.*}} R_{{.*}} f1 |
89 | 88 |
90 ; CHECK-OPTM1-LABEL: fixed_351_align_16 | 89 ; CHECK-OPTM1-LABEL: fixed_351_align_16 |
91 ; CHECK-OPTM1: sub esp,0x18 | 90 ; CHECK-OPTM1: sub esp,0x18 |
92 ; CHECK-OPTM1: sub esp,0x160 | 91 ; CHECK-OPTM1: sub esp,0x160 |
93 ; CHECK-OPTM1: mov DWORD PTR [esp],eax | 92 ; CHECK-OPTM1: mov DWORD PTR [esp],eax |
94 ; CHECK-OPTM1: call {{.*}} R_{{.*}} f1 | 93 ; CHECK-OPTM1: call {{.*}} R_{{.*}} f1 |
95 | 94 |
96 ; ARM32-LABEL: fixed_351_align_16 | 95 ; ARM32-LABEL: fixed_351_align_16 |
97 ; ARM32-OPT2: sub sp, sp, #364 | 96 ; ARM32-OPT2: sub sp, sp, #364 |
98 ; ARM32-OPTM1: sub sp, sp, #352 | 97 ; ARM32-OPTM1: sub sp, sp, #352 |
99 ; ARM32: movw [[CALL:r[0-9]]], {{.+}} f1 | 98 ; ARM32: bl {{.*}} R_{{.*}} f1 |
100 ; ARM32: movt [[CALL]], {{.+}} f1 | |
101 ; ARM32: blx [[CALL]] | |
102 | 99 |
103 define internal void @fixed_351_align_32(i32 %n) { | 100 define internal void @fixed_351_align_32(i32 %n) { |
104 entry: | 101 entry: |
105 %array = alloca i8, i32 351, align 32 | 102 %array = alloca i8, i32 351, align 32 |
106 %__2 = ptrtoint i8* %array to i32 | 103 %__2 = ptrtoint i8* %array to i32 |
107 call void @f1(i32 %__2) | 104 call void @f1(i32 %__2) |
108 ret void | 105 ret void |
109 } | 106 } |
110 ; CHECK-LABEL: fixed_351_align_32 | 107 ; CHECK-LABEL: fixed_351_align_32 |
111 ; CHECK: push ebp | 108 ; CHECK: push ebp |
112 ; CHECK-NEXT: mov ebp,esp | 109 ; CHECK-NEXT: mov ebp,esp |
113 ; CHECK: sub esp,0x178 | 110 ; CHECK: sub esp,0x178 |
114 ; CHECK: and esp,0xffffffe0 | 111 ; CHECK: and esp,0xffffffe0 |
115 ; CHECK: lea eax,[esp+0x10] | 112 ; CHECK: lea eax,[esp+0x10] |
116 ; CHECK: mov DWORD PTR [esp],eax | 113 ; CHECK: mov DWORD PTR [esp],eax |
117 ; CHECK: call {{.*}} R_{{.*}} f1 | 114 ; CHECK: call {{.*}} R_{{.*}} f1 |
118 | 115 |
119 ; ARM32-LABEL: fixed_351_align_32 | 116 ; ARM32-LABEL: fixed_351_align_32 |
120 ; ARM32-OPT2: sub sp, sp, #360 | 117 ; ARM32-OPT2: sub sp, sp, #360 |
121 ; ARM32-OPTM1: sub sp, sp, #352 | 118 ; ARM32-OPTM1: sub sp, sp, #352 |
122 ; ARM32: bic sp, sp, #31 | 119 ; ARM32: bic sp, sp, #31 |
123 ; ARM32: movw [[CALL:r[0-9]]], {{.+}} f1 | 120 ; ARM32: bl {{.*}} R_{{.*}} f1 |
124 ; ARM32: movt [[CALL]], {{.+}} f1 | |
125 ; ARM32: blx [[CALL]] | |
126 | 121 |
127 declare void @f1(i32 %ignored) | 122 declare void @f1(i32 %ignored) |
128 | 123 |
129 declare void @f2(i32 %ignored) | 124 declare void @f2(i32 %ignored) |
130 | 125 |
131 define internal void @variable_n_align_16(i32 %n) { | 126 define internal void @variable_n_align_16(i32 %n) { |
132 entry: | 127 entry: |
133 %array = alloca i8, i32 %n, align 16 | 128 %array = alloca i8, i32 %n, align 16 |
134 %__2 = ptrtoint i8* %array to i32 | 129 %__2 = ptrtoint i8* %array to i32 |
135 call void @f2(i32 %__2) | 130 call void @f2(i32 %__2) |
136 ret void | 131 ret void |
137 } | 132 } |
138 ; CHECK-LABEL: variable_n_align_16 | 133 ; CHECK-LABEL: variable_n_align_16 |
139 ; CHECK: sub esp,0x18 | 134 ; CHECK: sub esp,0x18 |
140 ; CHECK: mov eax,DWORD PTR [ebp+0x8] | 135 ; CHECK: mov eax,DWORD PTR [ebp+0x8] |
141 ; CHECK: add eax,0xf | 136 ; CHECK: add eax,0xf |
142 ; CHECK: and eax,0xfffffff0 | 137 ; CHECK: and eax,0xfffffff0 |
143 ; CHECK: sub esp,eax | 138 ; CHECK: sub esp,eax |
144 ; CHECK: lea eax,[esp+0x10] | 139 ; CHECK: lea eax,[esp+0x10] |
145 ; CHECK: mov DWORD PTR [esp],eax | 140 ; CHECK: mov DWORD PTR [esp],eax |
146 ; CHECK: call {{.*}} R_{{.*}} f2 | 141 ; CHECK: call {{.*}} R_{{.*}} f2 |
147 | 142 |
148 ; ARM32-LABEL: variable_n_align_16 | 143 ; ARM32-LABEL: variable_n_align_16 |
149 ; ARM32: add r0, r0, #15 | 144 ; ARM32: add r0, r0, #15 |
150 ; ARM32: bic r0, r0, #15 | 145 ; ARM32: bic r0, r0, #15 |
151 ; ARM32: sub sp, sp, r0 | 146 ; ARM32: sub sp, sp, r0 |
152 ; ARM32: movw [[CALL:r[0-9]]], {{.+}} f2 | 147 ; ARM32: bl {{.*}} R_{{.*}} f2 |
153 ; ARM32: movt [[CALL]], {{.+}} f2 | |
154 ; ARM32: blx [[CALL]] | |
155 | 148 |
156 define internal void @variable_n_align_32(i32 %n) { | 149 define internal void @variable_n_align_32(i32 %n) { |
157 entry: | 150 entry: |
158 %array = alloca i8, i32 %n, align 32 | 151 %array = alloca i8, i32 %n, align 32 |
159 %__2 = ptrtoint i8* %array to i32 | 152 %__2 = ptrtoint i8* %array to i32 |
160 call void @f2(i32 %__2) | 153 call void @f2(i32 %__2) |
161 ret void | 154 ret void |
162 } | 155 } |
163 ; In -O2, the order of the CHECK-DAG lines in the output is switched. | 156 ; In -O2, the order of the CHECK-DAG lines in the output is switched. |
164 ; CHECK-LABEL: variable_n_align_32 | 157 ; CHECK-LABEL: variable_n_align_32 |
(...skipping 11 matching lines...) Expand all Loading... |
176 ; CHECK: mov esp,ebp | 169 ; CHECK: mov esp,ebp |
177 ; CHECK: pop ebp | 170 ; CHECK: pop ebp |
178 | 171 |
179 ; ARM32-LABEL: variable_n_align_32 | 172 ; ARM32-LABEL: variable_n_align_32 |
180 ; ARM32: push {fp, lr} | 173 ; ARM32: push {fp, lr} |
181 ; ARM32: mov fp, sp | 174 ; ARM32: mov fp, sp |
182 ; ARM32: bic sp, sp, #31 | 175 ; ARM32: bic sp, sp, #31 |
183 ; ARM32: add r0, r0, #31 | 176 ; ARM32: add r0, r0, #31 |
184 ; ARM32: bic r0, r0, #31 | 177 ; ARM32: bic r0, r0, #31 |
185 ; ARM32: sub sp, sp, r0 | 178 ; ARM32: sub sp, sp, r0 |
186 ; ARM32: movw [[CALL:r[0-9]]], {{.+}} f2 | 179 ; ARM32: bl {{.*}} R_{{.*}} f2 |
187 ; ARM32: movt [[CALL]], {{.+}} f2 | |
188 ; ARM32: blx [[CALL]] | |
189 ; ARM32: mov sp, fp | 180 ; ARM32: mov sp, fp |
190 ; ARM32: pop {fp, lr} | 181 ; ARM32: pop {fp, lr} |
191 | 182 |
192 ; Test alloca with default (0) alignment. | 183 ; Test alloca with default (0) alignment. |
193 define internal void @align0(i32 %n) { | 184 define internal void @align0(i32 %n) { |
194 entry: | 185 entry: |
195 %array = alloca i8, i32 %n | 186 %array = alloca i8, i32 %n |
196 %__2 = ptrtoint i8* %array to i32 | 187 %__2 = ptrtoint i8* %array to i32 |
197 call void @f2(i32 %__2) | 188 call void @f2(i32 %__2) |
198 ret void | 189 ret void |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 %p1 = bitcast i8* %a1 to i32* | 295 %p1 = bitcast i8* %a1 to i32* |
305 %p2 = bitcast i8* %a2 to i32* | 296 %p2 = bitcast i8* %a2 to i32* |
306 %p3 = bitcast i8* %a3 to i32* | 297 %p3 = bitcast i8* %a3 to i32* |
307 store i32 %arg, i32* %p1, align 1 | 298 store i32 %arg, i32* %p1, align 1 |
308 store i32 %arg, i32* %p2, align 1 | 299 store i32 %arg, i32* %p2, align 1 |
309 store i32 %arg, i32* %p3, align 1 | 300 store i32 %arg, i32* %p3, align 1 |
310 ret void | 301 ret void |
311 } | 302 } |
312 ; CHECK-LABEL: var_with_frameptr | 303 ; CHECK-LABEL: var_with_frameptr |
313 ; CHECK: mov ebp,esp | 304 ; CHECK: mov ebp,esp |
OLD | NEW |