[IR] Reformulate LLVM's EH funclet IR
[oota-llvm.git] / test / Transforms / Sink / catchswitch.ll
1 ; RUN: opt -sink -S < %s | FileCheck %s
2
3 target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
4 target triple = "i686-pc-windows-msvc"
5
6 define void @h() personality i32 (...)* @__CxxFrameHandler3 {
7 entry:
8   %call = call i32 @g(i32 1) readnone
9   invoke void @_CxxThrowException(i8* null, i8* null) noreturn
10           to label %unreachable unwind label %catch.dispatch
11
12 catch.dispatch:                                   ; preds = %entry
13   %cs = catchswitch within none [label %catch] unwind to caller
14
15 catch:                                            ; preds = %catch.dispatch
16   %cp = catchpad within %cs [i8* null, i32 64, i8* null]
17   catchret from %cp to label %try.cont
18
19 try.cont:                                         ; preds = %catch
20   call void @k(i32 %call)
21   ret void
22
23 unreachable:                                      ; preds = %entry
24   unreachable
25 }
26
27 declare x86_stdcallcc void @_CxxThrowException(i8*, i8*)
28
29 declare i32 @__CxxFrameHandler3(...)
30
31 declare i32 @g(i32) readnone
32
33 declare void @k(i32)
34
35 ; CHECK-LABEL: define void @h(
36 ; CHECK: call i32 @g(i32 1)
37 ; CHECK-NEXT: invoke void @_CxxThrowException(