1 ; RUN: llc < %s -O0 -regalloc=fast -relocation-model=pic -frame-pointer=all | 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"
5 %struct.S = type { [2 x ptr] }
7 @_ZTIi = external constant ptr ; <ptr> [#uses=1]
8 @.str = internal constant [4 x i8] c"%p\0A\00" ; <ptr> [#uses=1]
9 @llvm.used = appending global [1 x ptr] [ptr @_Z4test1SiS_], section "llvm.metadata" ; <ptr> [#uses=0]
11 ; Verify that %s1 gets spilled before the call.
13 ; CHECK: leal 8(%ebp), %[[reg:[^ ]*]]
14 ; CHECK: movl %[[reg]],{{.*}}(%ebp) ## 4-byte Spill
15 ; CHECK: calll __Z6throwsv
17 define ptr @_Z4test1SiS_(ptr byval(%struct.S) %s1, i32 %n, ptr byval(%struct.S) %s2) ssp personality ptr @__gxx_personality_v0 {
19 %retval = alloca ptr, align 4 ; <ptr> [#uses=2]
20 %n.addr = alloca i32, align 4 ; <ptr> [#uses=1]
21 %_rethrow = alloca ptr ; <ptr> [#uses=4]
22 %0 = alloca i32, align 4 ; <ptr> [#uses=1]
23 %cleanup.dst = alloca i32 ; <ptr> [#uses=3]
24 %cleanup.dst7 = alloca i32 ; <ptr> [#uses=6]
25 store i32 %n, ptr %n.addr
26 invoke void @_Z6throwsv()
27 to label %invoke.cont unwind label %try.handler
29 invoke.cont: ; preds = %entry
30 store i32 1, ptr %cleanup.dst7
33 terminate.handler: ; preds = %match.end
34 %1 = landingpad { ptr, i32 }
36 call void @_ZSt9terminatev() noreturn nounwind
39 try.handler: ; preds = %entry
40 %exc1.ptr = landingpad { ptr, i32 }
42 %exc1 = extractvalue { ptr, i32 } %exc1.ptr, 0
43 %selector = extractvalue { ptr, i32 } %exc1.ptr, 1
44 %2 = call i32 @llvm.eh.typeid.for(ptr @_ZTIi) ; <i32> [#uses=1]
45 %3 = icmp eq i32 %selector, %2 ; <i1> [#uses=1]
46 br i1 %3, label %match, label %catch.next
48 match: ; preds = %try.handler
49 %4 = call ptr @__cxa_begin_catch(ptr %exc1) ; <ptr> [#uses=1]
50 %5 = load i32, ptr %4 ; <i32> [#uses=1]
52 %call = invoke i32 (ptr, ...) @printf(ptr @.str, ptr %s2)
53 to label %invoke.cont2 unwind label %match.handler ; <i32> [#uses=0]
55 invoke.cont2: ; preds = %match
56 store i32 1, ptr %cleanup.dst
59 match.handler: ; preds = %match
60 %exc3 = landingpad { ptr, i32 }
62 %6 = extractvalue { ptr, i32 } %exc3, 0
63 store ptr %6, ptr %_rethrow
64 store i32 2, ptr %cleanup.dst
67 cleanup.pad: ; preds = %cleanup.switch
68 store i32 1, ptr %cleanup.dst7
71 cleanup.pad4: ; preds = %cleanup.switch
72 store i32 2, ptr %cleanup.dst7
75 match.end: ; preds = %match.handler, %invoke.cont2
76 invoke void @__cxa_end_catch()
77 to label %invoke.cont5 unwind label %terminate.handler
79 invoke.cont5: ; preds = %match.end
80 br label %cleanup.switch
82 cleanup.switch: ; preds = %invoke.cont5
83 %tmp = load i32, ptr %cleanup.dst ; <i32> [#uses=1]
84 switch i32 %tmp, label %cleanup.end [
85 i32 1, label %cleanup.pad
86 i32 2, label %cleanup.pad4
89 cleanup.end: ; preds = %cleanup.switch
90 store i32 2, ptr %cleanup.dst7
93 catch.next: ; preds = %try.handler
94 store ptr %exc1, ptr %_rethrow
95 store i32 2, ptr %cleanup.dst7
98 finally: ; preds = %catch.next, %cleanup.end, %cleanup.pad4, %cleanup.pad, %invoke.cont
99 br label %cleanup.switch9
101 cleanup.switch9: ; preds = %finally
102 %tmp8 = load i32, ptr %cleanup.dst7 ; <i32> [#uses=1]
103 switch i32 %tmp8, label %cleanup.end10 [
104 i32 1, label %finally.end
105 i32 2, label %finally.throw
108 cleanup.end10: ; preds = %cleanup.switch9
109 br label %finally.end
111 finally.throw: ; preds = %cleanup.switch9
112 %7 = load ptr, ptr %_rethrow ; <ptr> [#uses=1]
113 call void @_Unwind_Resume_or_Rethrow(ptr %7)
116 finally.end: ; preds = %cleanup.end10, %cleanup.switch9
117 %tmp11 = getelementptr inbounds %struct.S, ptr %s1, i32 0, i32 0 ; <ptr> [#uses=1]
118 %arraydecay = getelementptr inbounds [2 x ptr], ptr %tmp11, i32 0, i32 0 ; <ptr> [#uses=1]
119 %arrayidx = getelementptr inbounds ptr, ptr %arraydecay, i32 1 ; <ptr> [#uses=1]
120 %tmp12 = load ptr, ptr %arrayidx ; <ptr> [#uses=1]
121 store ptr %tmp12, ptr %retval
122 %8 = load ptr, ptr %retval ; <ptr> [#uses=1]
126 declare void @_Z6throwsv() ssp
128 declare i32 @__gxx_personality_v0(...)
130 declare void @_ZSt9terminatev()
132 declare void @_Unwind_Resume_or_Rethrow(ptr)
134 declare i32 @llvm.eh.typeid.for(ptr) nounwind
136 declare ptr @__cxa_begin_catch(ptr)
138 declare i32 @printf(ptr, ...)
140 declare void @__cxa_end_catch()