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"
35 invoke void @may_throw(i32 1)
36 to label %invoke.cont unwind label %lpad
38 invoke.cont: ; preds = %entry
39 invoke void @may_throw(i32 2)
40 to label %try.cont.9 unwind label %lpad.1
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 %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
50 catch %eh.CatchHandlerType* @llvm.eh.handlertype.H.0
51 %1 = extractvalue { i8*, i32 } %0, 0
52 %2 = extractvalue { i8*, i32 } %0, 1
53 br label %catch.dispatch.4
55 lpad.1: ; preds = %invoke.cont
56 %3 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
57 catch i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.H.0 to i8*)
58 %4 = extractvalue { i8*, i32 } %3, 0
59 %5 = extractvalue { i8*, i32 } %3, 1
60 %6 = tail call i32 @llvm.eh.typeid.for(i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.H.0 to i8*)) #3
61 %matches = icmp eq i32 %5, %6
62 br i1 %matches, label %catch, label %catch.dispatch.4
64 catch.dispatch.4: ; preds = %lpad.1, %lpad
65 %exn.slot.0 = phi i8* [ %4, %lpad.1 ], [ %1, %lpad ]
66 %ehselector.slot.0 = phi i32 [ %5, %lpad.1 ], [ %2, %lpad ]
67 %.pre = tail call i32 @llvm.eh.typeid.for(i8* bitcast (%eh.CatchHandlerType* @llvm.eh.handlertype.H.0 to i8*)) #3
68 %matches6 = icmp eq i32 %ehselector.slot.0, %.pre
69 br i1 %matches6, label %catch.7, label %eh.resume
71 catch.7: ; preds = %catch.dispatch.4
72 tail call void @llvm.eh.begincatch(i8* %exn.slot.0, i8* null) #3
73 tail call void @may_throw(i32 4)
74 tail call void @llvm.eh.endcatch() #3
77 catch: ; preds = %lpad.1
78 tail call void @llvm.eh.begincatch(i8* %4, i8* null) #3
79 invoke void @may_throw(i32 3)
80 to label %invoke.cont.3 unwind label %lpad
82 invoke.cont.3: ; preds = %catch
83 tail call void @llvm.eh.endcatch() #3
86 eh.resume: ; preds = %catch.dispatch.4
87 %lpad.val = insertvalue { i8*, i32 } undef, i8* %exn.slot.0, 0
88 %lpad.val.12 = insertvalue { i8*, i32 } %lpad.val, i32 %ehselector.slot.0, 1
89 resume { i8*, i32 } %lpad.val.12
93 ; CHECK: movl $-1, [[state:[-0-9]+]](%ebp)
94 ; CHECK: movl $___ehhandler$f, {{.*}}
96 ; CHECK: movl $0, [[state]](%ebp)
97 ; CHECK: movl $1, (%esp)
98 ; CHECK: calll _may_throw
100 ; CHECK: movl $1, [[state]](%ebp)
101 ; CHECK: movl $2, (%esp)
102 ; CHECK: calll _may_throw
104 ; CHECK-LABEL: _f.catch:
105 ; CHECK: movl $4, Lf$frame_escape_{{[0-9]+.*}}
106 ; CHECK: movl $4, (%esp)
107 ; CHECK: calll _may_throw
109 ; CHECK-LABEL: _f.catch.1:
110 ; CHECK: movl $3, Lf$frame_escape_{{[0-9]+.*}}
111 ; CHECK: movl $3, (%esp)
112 ; CHECK: calll _may_throw
114 ; CHECK: .safeseh ___ehhandler$f