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, and have FP, we expect a .cfi_escape GNU_ARGS_SIZE
10 ; with size 16 before the invocation. Without FP, we expect.cfi_adjust_cfa_offset
12 ; Darwin should not generate pushes in neither circumstance.
13 ; CHECK-LABEL: test1_nofp:
14 ; LINUX: .cfi_escape 0x2e, 0x10
15 ; LINUX: .cfi_adjust_cfa_offset 16
16 ; LINUX-NEXT: pushl $4
17 ; LINUX-NEXT: pushl $3
18 ; LINUX-NEXT: pushl $2
19 ; LINUX-NEXT: pushl $1
21 ; LINUX-NEXT: addl $16, %esp
22 ; LINUX: .cfi_adjust_cfa_offset -16
23 ; DARWIN-NOT: .cfi_escape
25 define void @test1_nofp() #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
27 invoke void @good(i32 1, i32 2, i32 3, i32 4)
28 to label %continue unwind label %cleanup
32 landingpad { i8*, i32 }
37 ; CHECK-LABEL: test1_fp:
38 ; LINUX: .cfi_escape 0x2e, 0x10
39 ; LINUX-NEXT: pushl $4
40 ; LINUX-NEXT: pushl $3
41 ; LINUX-NEXT: pushl $2
42 ; LINUX-NEXT: pushl $1
44 ; LINUX-NEXT: addl $16, %esp
46 ; DARWIN-NOT: .cfi_escape
48 define void @test1_fp() #1 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
50 invoke void @good(i32 1, i32 2, i32 3, i32 4)
51 to label %continue unwind label %cleanup
55 landingpad { i8*, i32 }
60 ; If the function has no handlers, we don't need to generate GNU_ARGS_SIZE,
61 ; even if it has an unwind table. Without FP, we still need cfi_adjust_cfa_offset,
62 ; so darwin should not generate pushes.
63 ; CHECK-LABEL: test2_nofp:
64 ; LINUX-NOT: .cfi_escape
65 ; LINUX: .cfi_adjust_cfa_offset 16
66 ; LINUX-NEXT: pushl $4
67 ; LINUX-NEXT: pushl $3
68 ; LINUX-NEXT: pushl $2
69 ; LINUX-NEXT: pushl $1
71 ; LINUX-NEXT: addl $16, %esp
72 ; LINUX: .cfi_adjust_cfa_offset -16
73 ; DARWIN-NOT: .cfi_escape
75 define void @test2_nofp() #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
77 call void @good(i32 1, i32 2, i32 3, i32 4)
81 ; CHECK-LABEL: test2_fp:
82 ; CHECK-NOT: .cfi_escape
83 ; CHECK-NOT: .cfi_adjust_cfa_offset
85 ; CHECK-NEXT: pushl $3
86 ; CHECK-NEXT: pushl $2
87 ; CHECK-NEXT: pushl $1
89 ; CHECK-NEXT: addl $24, %esp
90 define void @test2_fp() #1 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
92 call void @good(i32 1, i32 2, i32 3, i32 4)
96 ; If we did not end up using any pushes, no need for GNU_ARGS_SIZE or
97 ; cfi_adjust_cfa_offset.
98 ; CHECK-LABEL: test3_nofp:
99 ; LINUX-NOT: .cfi_escape
100 ; LINUX-NOT: .cfi_adjust_cfa_offset
103 define void @test3_nofp() #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
106 to label %continue unwind label %cleanup
110 landingpad { i8*, i32 }
115 ; If we did not end up using any pushes, no need for GNU_ARGS_SIZE or
116 ; cfi_adjust_cfa_offset.
117 ; CHECK-LABEL: test3_fp:
119 ; LINUX-NOT: .cfi_escape
120 ; LINUX-NOT: .cfi_adjust_cfa_offset
123 define void @test3_fp() #1 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
126 to label %continue unwind label %cleanup
130 landingpad { i8*, i32 }
135 ; Different sized stacks need different GNU_ARGS_SIZEs
136 ; CHECK-LABEL: test4:
137 ; LINUX: .cfi_escape 0x2e, 0x10
138 ; LINUX-NEXT: pushl $4
139 ; LINUX-NEXT: pushl $3
140 ; LINUX-NEXT: pushl $2
141 ; LINUX-NEXT: pushl $1
143 ; LINUX-NEXT: addl $16, %esp
144 ; LINUX: .cfi_escape 0x2e, 0x20
145 ; LINUX: subl $8, %esp
146 ; LINUX-NEXT: pushl $11
147 ; LINUX-NEXT: pushl $10
148 ; LINUX-NEXT: pushl $9
149 ; LINUX-NEXT: pushl $8
150 ; LINUX-NEXT: pushl $7
151 ; LINUX-NEXT: pushl $6
152 ; LINUX-NEXT: calll large
153 ; LINUX-NEXT: addl $32, %esp
154 define void @test4() #1 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
156 invoke void @good(i32 1, i32 2, i32 3, i32 4)
157 to label %continue1 unwind label %cleanup
159 invoke void @large(i32 6, i32 7, i32 8, i32 9, i32 10, i32 11)
160 to label %continue2 unwind label %cleanup
164 landingpad { i8*, i32 }
169 ; If we did use pushes, we need to reset GNU_ARGS_SIZE before a call
170 ; without parameters, but don't need to adjust the cfa offset
171 ; CHECK-LABEL: test5_nofp:
172 ; LINUX: .cfi_escape 0x2e, 0x10
173 ; LINUX: .cfi_adjust_cfa_offset 16
174 ; LINUX-NEXT: pushl $4
175 ; LINUX-NEXT: pushl $3
176 ; LINUX-NEXT: pushl $2
177 ; LINUX-NEXT: pushl $1
179 ; LINUX-NEXT: addl $16, %esp
180 ; LINUX: .cfi_adjust_cfa_offset -16
181 ; LINUX-NOT: .cfi_adjust_cfa_offset
182 ; LINUX: .cfi_escape 0x2e, 0x00
183 ; LINUX-NOT: .cfi_adjust_cfa_offset
185 define void @test5_nofp() #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
187 invoke void @good(i32 1, i32 2, i32 3, i32 4)
188 to label %continue1 unwind label %cleanup
191 to label %continue2 unwind label %cleanup
195 landingpad { i8*, i32 }
200 ; CHECK-LABEL: test5_fp:
201 ; LINUX: .cfi_escape 0x2e, 0x10
202 ; LINUX-NEXT: pushl $4
203 ; LINUX-NEXT: pushl $3
204 ; LINUX-NEXT: pushl $2
205 ; LINUX-NEXT: pushl $1
207 ; LINUX-NEXT: addl $16, %esp
208 ; LINUX: .cfi_escape 0x2e, 0x00
209 ; LINUX-NOT: .cfi_adjust_cfa_offset
211 define void @test5_fp() #1 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
213 invoke void @good(i32 1, i32 2, i32 3, i32 4)
214 to label %continue1 unwind label %cleanup
217 to label %continue2 unwind label %cleanup
221 landingpad { i8*, i32 }
226 ; FIXME: This is actually inefficient - we don't need to repeat the .cfi_escape twice.
227 ; CHECK-LABEL: test6:
228 ; LINUX: .cfi_escape 0x2e, 0x10
230 ; LINUX: .cfi_escape 0x2e, 0x10
232 define void @test6() #1 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
234 invoke void @good(i32 1, i32 2, i32 3, i32 4)
235 to label %continue1 unwind label %cleanup
237 invoke void @good(i32 5, i32 6, i32 7, i32 8)
238 to label %continue2 unwind label %cleanup
242 landingpad { i8*, i32 }
247 ; Darwin should generate pushes in the presense of FP and an unwind table,
248 ; but not FP and invoke.
249 ; CHECK-LABEL: test7:
251 ; DARWIN: movl %esp, %ebp
252 ; DARWIN: .cfi_def_cfa_register %ebp
253 ; DARWIN-NOT: .cfi_adjust_cfa_offset
255 ; DARWIN-NEXT: pushl $3
256 ; DARWIN-NEXT: pushl $2
257 ; DARWIN-NEXT: pushl $1
259 define void @test7() #1 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
261 call void @good(i32 1, i32 2, i32 3, i32 4)
265 ; CHECK-LABEL: test8:
267 ; DARWIN: movl %esp, %ebp
268 ; DARWIN-NOT: .cfi_adjust_cfa_offset
270 define void @test8() #1 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
272 invoke void @good(i32 1, i32 2, i32 3, i32 4)
273 to label %continue unwind label %cleanup
277 landingpad { i8*, i32 }
282 attributes #0 = { optsize }
283 attributes #1 = { optsize "no-frame-pointer-elim"="true" }