1 ; RUN: llc < %s -mtriple=i686-pc-linux | FileCheck %s -check-prefix=LINUX -check-prefix=CHECK
2 ; RUN: llc < %s -mtriple=i686-apple-darwin | FileCheck %s -check-prefix=DARWIN -check-prefix=CHECK
4 declare i32 @__gxx_personality_v0(...)
5 declare void @good(i32 %a, i32 %b, i32 %c, i32 %d)
6 declare void @large(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f)
9 ; When we use an invoke, we expect a .cfi_escape GNU_ARGS_SIZE
10 ; with size 16 before the invocation. Without FP, we also expect
11 ; .cfi_adjust_cfa_offset after each push.
12 ; Darwin should not generate pushes in either circumstance.
13 ; CHECK-LABEL: test1_nofp:
14 ; LINUX: .cfi_escape 0x2e, 0x10
15 ; LINUX-NEXT: pushl $4
16 ; LINUX-NEXT: .cfi_adjust_cfa_offset 4
17 ; LINUX-NEXT: pushl $3
18 ; LINUX-NEXT: .cfi_adjust_cfa_offset 4
19 ; LINUX-NEXT: pushl $2
20 ; LINUX-NEXT: .cfi_adjust_cfa_offset 4
21 ; LINUX-NEXT: pushl $1
22 ; LINUX-NEXT: .cfi_adjust_cfa_offset 4
24 ; LINUX-NEXT: addl $16, %esp
25 ; LINUX: .cfi_adjust_cfa_offset -16
26 ; DARWIN-NOT: .cfi_escape
28 define void @test1_nofp() #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
30 invoke void @good(i32 1, i32 2, i32 3, i32 4)
31 to label %continue unwind label %cleanup
35 landingpad { i8*, i32 }
40 ; CHECK-LABEL: test1_fp:
41 ; LINUX: .cfi_escape 0x2e, 0x10
42 ; LINUX-NEXT: pushl $4
43 ; LINUX-NEXT: pushl $3
44 ; LINUX-NEXT: pushl $2
45 ; LINUX-NEXT: pushl $1
47 ; LINUX-NEXT: addl $16, %esp
49 ; DARWIN-NOT: .cfi_escape
51 define void @test1_fp() #1 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
53 invoke void @good(i32 1, i32 2, i32 3, i32 4)
54 to label %continue unwind label %cleanup
58 landingpad { i8*, i32 }
63 ; If the function has no handlers, we don't need to generate GNU_ARGS_SIZE,
64 ; even if it has an unwind table. Without FP, we still need cfi_adjust_cfa_offset,
65 ; so darwin should not generate pushes.
66 ; CHECK-LABEL: test2_nofp:
67 ; LINUX-NOT: .cfi_escape
69 ; LINUX-NEXT: .cfi_adjust_cfa_offset 4
70 ; LINUX-NEXT: pushl $3
71 ; LINUX-NEXT: .cfi_adjust_cfa_offset 4
72 ; LINUX-NEXT: pushl $2
73 ; LINUX-NEXT: .cfi_adjust_cfa_offset 4
74 ; LINUX-NEXT: pushl $1
75 ; LINUX-NEXT: .cfi_adjust_cfa_offset 4
77 ; LINUX-NEXT: addl $28, %esp
78 ; LINUX: .cfi_adjust_cfa_offset -28
79 ; DARWIN-NOT: .cfi_escape
81 define void @test2_nofp() #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
83 call void @good(i32 1, i32 2, i32 3, i32 4)
87 ; CHECK-LABEL: test2_fp:
88 ; CHECK-NOT: .cfi_escape
89 ; CHECK-NOT: .cfi_adjust_cfa_offset
91 ; CHECK-NEXT: pushl $3
92 ; CHECK-NEXT: pushl $2
93 ; CHECK-NEXT: pushl $1
95 ; CHECK-NEXT: addl $24, %esp
96 define void @test2_fp() #1 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
98 call void @good(i32 1, i32 2, i32 3, i32 4)
102 ; If we did not end up using any pushes, no need for GNU_ARGS_SIZE or
103 ; cfi_adjust_cfa_offset.
104 ; CHECK-LABEL: test3_nofp:
105 ; LINUX-NOT: .cfi_escape
106 ; LINUX-NOT: .cfi_adjust_cfa_offset
109 define void @test3_nofp() #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
112 to label %continue unwind label %cleanup
116 landingpad { i8*, i32 }
121 ; If we did not end up using any pushes, no need for GNU_ARGS_SIZE or
122 ; cfi_adjust_cfa_offset.
123 ; CHECK-LABEL: test3_fp:
125 ; LINUX-NOT: .cfi_escape
126 ; LINUX-NOT: .cfi_adjust_cfa_offset
129 define void @test3_fp() #1 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
132 to label %continue unwind label %cleanup
136 landingpad { i8*, i32 }
141 ; Different sized stacks need different GNU_ARGS_SIZEs
142 ; CHECK-LABEL: test4:
143 ; LINUX: .cfi_escape 0x2e, 0x10
144 ; LINUX-NEXT: pushl $4
145 ; LINUX-NEXT: pushl $3
146 ; LINUX-NEXT: pushl $2
147 ; LINUX-NEXT: pushl $1
149 ; LINUX-NEXT: addl $16, %esp
150 ; LINUX: .cfi_escape 0x2e, 0x20
151 ; LINUX: subl $8, %esp
152 ; LINUX-NEXT: pushl $11
153 ; LINUX-NEXT: pushl $10
154 ; LINUX-NEXT: pushl $9
155 ; LINUX-NEXT: pushl $8
156 ; LINUX-NEXT: pushl $7
157 ; LINUX-NEXT: pushl $6
158 ; LINUX-NEXT: calll large
159 ; LINUX-NEXT: addl $32, %esp
160 define void @test4() #1 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
162 invoke void @good(i32 1, i32 2, i32 3, i32 4)
163 to label %continue1 unwind label %cleanup
165 invoke void @large(i32 6, i32 7, i32 8, i32 9, i32 10, i32 11)
166 to label %continue2 unwind label %cleanup
170 landingpad { i8*, i32 }
175 ; If we did use pushes, we need to reset GNU_ARGS_SIZE before a call
176 ; without parameters, but don't need to adjust the cfa offset
177 ; CHECK-LABEL: test5_nofp:
178 ; LINUX: .cfi_escape 0x2e, 0x10
179 ; LINUX-NEXT: pushl $4
180 ; LINUX-NEXT: .cfi_adjust_cfa_offset 4
181 ; LINUX-NEXT: pushl $3
182 ; LINUX-NEXT: .cfi_adjust_cfa_offset 4
183 ; LINUX-NEXT: pushl $2
184 ; LINUX-NEXT: .cfi_adjust_cfa_offset 4
185 ; LINUX-NEXT: pushl $1
186 ; LINUX-NEXT: .cfi_adjust_cfa_offset 4
188 ; LINUX-NEXT: addl $16, %esp
189 ; LINUX: .cfi_adjust_cfa_offset -16
190 ; LINUX-NOT: .cfi_adjust_cfa_offset
191 ; LINUX: .cfi_escape 0x2e, 0x00
192 ; LINUX-NOT: .cfi_adjust_cfa_offset
194 define void @test5_nofp() #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
196 invoke void @good(i32 1, i32 2, i32 3, i32 4)
197 to label %continue1 unwind label %cleanup
200 to label %continue2 unwind label %cleanup
204 landingpad { i8*, i32 }
209 ; CHECK-LABEL: test5_fp:
210 ; LINUX: .cfi_escape 0x2e, 0x10
211 ; LINUX-NEXT: pushl $4
212 ; LINUX-NEXT: pushl $3
213 ; LINUX-NEXT: pushl $2
214 ; LINUX-NEXT: pushl $1
216 ; LINUX-NEXT: addl $16, %esp
217 ; LINUX: .cfi_escape 0x2e, 0x00
218 ; LINUX-NOT: .cfi_adjust_cfa_offset
220 define void @test5_fp() #1 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
222 invoke void @good(i32 1, i32 2, i32 3, i32 4)
223 to label %continue1 unwind label %cleanup
226 to label %continue2 unwind label %cleanup
230 landingpad { i8*, i32 }
235 ; FIXME: This is actually inefficient - we don't need to repeat the .cfi_escape twice.
236 ; CHECK-LABEL: test6:
237 ; LINUX: .cfi_escape 0x2e, 0x10
239 ; LINUX: .cfi_escape 0x2e, 0x10
241 define void @test6() #1 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
243 invoke void @good(i32 1, i32 2, i32 3, i32 4)
244 to label %continue1 unwind label %cleanup
246 invoke void @good(i32 5, i32 6, i32 7, i32 8)
247 to label %continue2 unwind label %cleanup
251 landingpad { i8*, i32 }
256 ; Darwin should generate pushes in the presense of FP and an unwind table,
257 ; but not FP and invoke.
258 ; CHECK-LABEL: test7:
260 ; DARWIN: movl %esp, %ebp
261 ; DARWIN: .cfi_def_cfa_register %ebp
262 ; DARWIN-NOT: .cfi_adjust_cfa_offset
264 ; DARWIN-NEXT: pushl $3
265 ; DARWIN-NEXT: pushl $2
266 ; DARWIN-NEXT: pushl $1
268 define void @test7() #1 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
270 call void @good(i32 1, i32 2, i32 3, i32 4)
274 ; CHECK-LABEL: test8:
276 ; DARWIN: movl %esp, %ebp
277 ; DARWIN-NOT: .cfi_adjust_cfa_offset
279 define void @test8() #1 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
281 invoke void @good(i32 1, i32 2, i32 3, i32 4)
282 to label %continue unwind label %cleanup
286 landingpad { i8*, i32 }
291 attributes #0 = { optsize }
292 attributes #1 = { optsize "no-frame-pointer-elim"="true" }