1 ; RUN: llc -mtriple=i686-pc-windows-msvc < %s | FileCheck %s
3 ; Based on this source:
4 ; extern "C" void may_throw(int);
18 %rtti.TypeDescriptor2 = type { i8**, i8*, [3 x i8] }
19 %eh.CatchHandlerType = type { i32, i8* }
21 declare void @may_throw(i32)
22 declare i32 @__CxxFrameHandler3(...)
23 declare void @llvm.eh.begincatch(i8*, i8*)
24 declare void @llvm.eh.endcatch()
25 declare i32 @llvm.eh.typeid.for(i8*)
27 $"\01??_R0H@8" = comdat any
29 @"\01??_7type_info@@6B@" = external constant i8*
30 @"\01??_R0H@8" = linkonce_odr global %rtti.TypeDescriptor2 { i8** @"\01??_7type_info@@6B@", i8* null, [3 x i8] c".H\00" }, comdat
31 @llvm.eh.handlertype.H.0 = private unnamed_addr constant %eh.CatchHandlerType { i32 0, i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i8*) }, section "llvm.metadata"
33 define void @f() #0 personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
35 invoke void @may_throw(i32 1)
36 to label %invoke.cont unwind label %lpad.1
38 invoke.cont: ; preds = %entry
39 invoke void @may_throw(i32 2)
40 to label %try.cont.9 unwind label %lpad
42 try.cont.9: ; preds = %invoke.cont.3, %invoke.cont, %catch.7
43 ; FIXME: Something about our CFG breaks TailDuplication. This empy asm blocks
44 ; it so we can focus on testing the state numbering.
45 call void asm sideeffect "", "~{dirflag},~{fpsr},~{flags}"()
48 lpad: ; preds = %catch, %entry
49 %p1 = catchpad [%rtti.TypeDescriptor2* @"\01??_R0H@8", i32 0, i8* null]
50 to label %catch unwind label %end.inner.catch
52 catch: ; preds = %lpad.1
53 invoke void @may_throw(i32 3)
54 to label %invoke.cont.3 unwind label %end.inner.catch
56 invoke.cont.3: ; preds = %catch
57 catchret %p1 to label %try.cont.9
61 catchendpad unwind label %lpad.1
63 lpad.1: ; preds = %invoke.cont
64 %p2 = catchpad [%rtti.TypeDescriptor2* @"\01??_R0H@8", i32 0, i8* null]
65 to label %catch.7 unwind label %eh.resume
68 invoke void @may_throw(i32 4)
69 to label %invoke.cont.10 unwind label %eh.resume
72 catchret %p2 to label %try.cont.9
74 eh.resume: ; preds = %catch.dispatch.4
75 catchendpad unwind to caller
79 ; CHECK: movl $-1, [[state:[-0-9]+]](%ebp)
80 ; CHECK: movl $___ehhandler$f, {{.*}}
82 ; CHECK: movl $0, [[state]](%ebp)
83 ; CHECK: movl $1, (%esp)
84 ; CHECK: calll _may_throw
86 ; CHECK: movl $1, [[state]](%ebp)
87 ; CHECK: movl $2, (%esp)
88 ; CHECK: calll _may_throw
90 ; CHECK: movl $2, [[state]](%ebp)
91 ; CHECK: movl $3, (%esp)
92 ; CHECK: calll _may_throw
94 ; CHECK: movl $3, [[state]](%ebp)
95 ; CHECK: movl $4, (%esp)
96 ; CHECK: calll _may_throw
98 ; CHECK: .safeseh ___ehhandler$f