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