1; RUN: llc < %s -mtriple=i686-pc-win32 | FileCheck %s
2
3%Iter = type { i32, i32, i32 }
4
5%frame.reverse = type { %Iter, %Iter }
6
7declare i32 @pers(...)
8declare void @llvm.stackrestore(i8*)
9declare i8* @llvm.stacksave()
10declare void @begin(%Iter* sret(%Iter))
11declare void @plus(%Iter* sret(%Iter), %Iter*, i32)
12declare void @reverse(%frame.reverse* inalloca align 4)
13
14define i32 @main() personality i32 (...)* @pers {
15  %temp.lvalue = alloca %Iter
16  br label %blah
17
18blah:
19  %inalloca.save = call i8* @llvm.stacksave()
20  %rev_args = alloca inalloca %frame.reverse, align 4
21  %beg = getelementptr %frame.reverse, %frame.reverse* %rev_args, i32 0, i32 0
22  %end = getelementptr %frame.reverse, %frame.reverse* %rev_args, i32 0, i32 1
23
24; CHECK:  pushl   %eax
25; CHECK:  subl    $20, %esp
26; CHECK:  movl %esp, %[[beg:[^ ]*]]
27; CHECK:  leal 12(%[[beg]]), %[[end:[^ ]*]]
28
29  call void @begin(%Iter* sret(%Iter) %temp.lvalue)
30; CHECK:  calll _begin
31
32  invoke void @plus(%Iter* sret(%Iter) %end, %Iter* %temp.lvalue, i32 4)
33          to label %invoke.cont unwind label %lpad
34
35;  Uses end as sret param.
36; CHECK:  pushl %[[end]]
37; CHECK:  calll _plus
38
39invoke.cont:
40  call void @begin(%Iter* sret(%Iter) %beg)
41
42; CHECK:  pushl %[[beg]]
43; CHECK:  calll _begin
44
45  invoke void @reverse(%frame.reverse* inalloca align 4 %rev_args)
46          to label %invoke.cont5 unwind label %lpad
47
48invoke.cont5:                                     ; preds = %invoke.cont
49  call void @llvm.stackrestore(i8* %inalloca.save)
50  ret i32 0
51
52lpad:                                             ; preds = %invoke.cont, %entry
53  %lp = landingpad { i8*, i32 }
54          cleanup
55  unreachable
56}
57