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