One more -regalloc=fast test
[oota-llvm.git] / test / CodeGen / X86 / 2010-04-30-LocalAlloc-LandingPad.ll
1 ; RUN: llc < %s -O0 -regalloc=local -relocation-model=pic -disable-fp-elim | FileCheck %s
2 ; RUN: llc < %s -O0 -regalloc=fast -relocation-model=pic -disable-fp-elim | FileCheck %s
3 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32"
4 target triple = "i386-apple-darwin10.0.0"
5
6 %struct.S = type { [2 x i8*] }
7
8 @_ZTIi = external constant i8*                    ; <i8**> [#uses=1]
9 @.str = internal constant [4 x i8] c"%p\0A\00"    ; <[4 x i8]*> [#uses=1]
10 @llvm.used = appending global [1 x i8*] [i8* bitcast (i8* (%struct.S*, i32, %struct.S*)* @_Z4test1SiS_ to i8*)], section "llvm.metadata" ; <[1 x i8*]*> [#uses=0]
11
12 ; Verify that %esi gets spilled before the call.
13 ; CHECK: Z4test1SiS
14 ; CHECK: movl %esi,{{.*}}(%ebp) 
15 ; CHECK: call __Z6throwsv
16
17 define i8* @_Z4test1SiS_(%struct.S* byval %s1, i32 %n, %struct.S* byval %s2) ssp {
18 entry:
19   %retval = alloca i8*, align 4                   ; <i8**> [#uses=2]
20   %n.addr = alloca i32, align 4                   ; <i32*> [#uses=1]
21   %_rethrow = alloca i8*                          ; <i8**> [#uses=4]
22   %0 = alloca i32, align 4                        ; <i32*> [#uses=1]
23   %cleanup.dst = alloca i32                       ; <i32*> [#uses=3]
24   %cleanup.dst7 = alloca i32                      ; <i32*> [#uses=6]
25   store i32 %n, i32* %n.addr
26   invoke void @_Z6throwsv()
27           to label %invoke.cont unwind label %try.handler
28
29 invoke.cont:                                      ; preds = %entry
30   store i32 1, i32* %cleanup.dst7
31   br label %finally
32
33 terminate.handler:                                ; preds = %match.end
34   %exc = call i8* @llvm.eh.exception()            ; <i8*> [#uses=1]
35   %1 = call i32 (i8*, i8*, ...)* @llvm.eh.selector(i8* %exc, i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*), i32 1) ; <i32> [#uses=0]
36   call void @_ZSt9terminatev() noreturn nounwind
37   unreachable
38
39 try.handler:                                      ; preds = %entry
40   %exc1 = call i8* @llvm.eh.exception()           ; <i8*> [#uses=3]
41   %selector = call i32 (i8*, i8*, ...)* @llvm.eh.selector(i8* %exc1, i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*), i8* bitcast (i8** @_ZTIi to i8*), i8* null) ; <i32> [#uses=1]
42   %2 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) ; <i32> [#uses=1]
43   %3 = icmp eq i32 %selector, %2                  ; <i1> [#uses=1]
44   br i1 %3, label %match, label %catch.next
45
46 match:                                            ; preds = %try.handler
47   %4 = call i8* @__cxa_begin_catch(i8* %exc1)     ; <i8*> [#uses=1]
48   %5 = bitcast i8* %4 to i32*                     ; <i32*> [#uses=1]
49   %6 = load i32* %5                               ; <i32> [#uses=1]
50   store i32 %6, i32* %0
51   %call = invoke i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), %struct.S* %s2)
52           to label %invoke.cont2 unwind label %match.handler ; <i32> [#uses=0]
53
54 invoke.cont2:                                     ; preds = %match
55   store i32 1, i32* %cleanup.dst
56   br label %match.end
57
58 match.handler:                                    ; preds = %match
59   %exc3 = call i8* @llvm.eh.exception()           ; <i8*> [#uses=2]
60   %7 = call i32 (i8*, i8*, ...)* @llvm.eh.selector(i8* %exc3, i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*), i32 0) ; <i32> [#uses=0]
61   store i8* %exc3, i8** %_rethrow
62   store i32 2, i32* %cleanup.dst
63   br label %match.end
64
65 cleanup.pad:                                      ; preds = %cleanup.switch
66   store i32 1, i32* %cleanup.dst7
67   br label %finally
68
69 cleanup.pad4:                                     ; preds = %cleanup.switch
70   store i32 2, i32* %cleanup.dst7
71   br label %finally
72
73 match.end:                                        ; preds = %match.handler, %invoke.cont2
74   invoke void @__cxa_end_catch()
75           to label %invoke.cont5 unwind label %terminate.handler
76
77 invoke.cont5:                                     ; preds = %match.end
78   br label %cleanup.switch
79
80 cleanup.switch:                                   ; preds = %invoke.cont5
81   %tmp = load i32* %cleanup.dst                   ; <i32> [#uses=1]
82   switch i32 %tmp, label %cleanup.end [
83     i32 1, label %cleanup.pad
84     i32 2, label %cleanup.pad4
85   ]
86
87 cleanup.end:                                      ; preds = %cleanup.switch
88   %exc6 = call i8* @llvm.eh.exception()           ; <i8*> [#uses=1]
89   store i8* %exc6, i8** %_rethrow
90   store i32 2, i32* %cleanup.dst7
91   br label %finally
92
93 catch.next:                                       ; preds = %try.handler
94   store i8* %exc1, i8** %_rethrow
95   store i32 2, i32* %cleanup.dst7
96   br label %finally
97
98 finally:                                          ; preds = %catch.next, %cleanup.end, %cleanup.pad4, %cleanup.pad, %invoke.cont
99   br label %cleanup.switch9
100
101 cleanup.switch9:                                  ; preds = %finally
102   %tmp8 = load i32* %cleanup.dst7                 ; <i32> [#uses=1]
103   switch i32 %tmp8, label %cleanup.end10 [
104     i32 1, label %finally.end
105     i32 2, label %finally.throw
106   ]
107
108 cleanup.end10:                                    ; preds = %cleanup.switch9
109   br label %finally.end
110
111 finally.throw:                                    ; preds = %cleanup.switch9
112   %8 = load i8** %_rethrow                        ; <i8*> [#uses=1]
113   call void @_Unwind_Resume_or_Rethrow(i8* %8)
114   unreachable
115
116 finally.end:                                      ; preds = %cleanup.end10, %cleanup.switch9
117   %tmp11 = getelementptr inbounds %struct.S* %s1, i32 0, i32 0 ; <[2 x i8*]*> [#uses=1]
118   %arraydecay = getelementptr inbounds [2 x i8*]* %tmp11, i32 0, i32 0 ; <i8**> [#uses=1]
119   %arrayidx = getelementptr inbounds i8** %arraydecay, i32 1 ; <i8**> [#uses=1]
120   %tmp12 = load i8** %arrayidx                    ; <i8*> [#uses=1]
121   store i8* %tmp12, i8** %retval
122   %9 = load i8** %retval                          ; <i8*> [#uses=1]
123   ret i8* %9
124 }
125
126 declare void @_Z6throwsv() ssp
127
128 declare i32 @__gxx_personality_v0(...)
129
130 declare i8* @llvm.eh.exception() nounwind readonly
131
132 declare i32 @llvm.eh.selector(i8*, i8*, ...) nounwind
133
134 declare void @_ZSt9terminatev()
135
136 declare void @_Unwind_Resume_or_Rethrow(i8*)
137
138 declare i32 @llvm.eh.typeid.for(i8*) nounwind
139
140 declare i8* @__cxa_begin_catch(i8*)
141
142 declare i32 @printf(i8*, ...)
143
144 declare void @__cxa_end_catch()