[IR] Reformulate LLVM's EH funclet IR
[oota-llvm.git] / test / Transforms / Inline / PR25155.ll
1 ; RUN: opt < %s -inline -S | FileCheck %s
2 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
3 target triple = "x86_64-pc-windows-msvc18.0.0"
4
5 define void @f() personality i32 (...)* @__CxxFrameHandler3 {
6 entry:
7   invoke void @g()
8           to label %try.cont unwind label %catch.dispatch
9
10 catch.dispatch:                                   ; preds = %entry
11   %cs1 = catchswitch within none [label %catch] unwind to caller
12
13 catch:                                            ; preds = %catch.dispatch
14   %0 = catchpad within %cs1 [i8* null, i32 64, i8* null]
15   invoke void @dtor()
16           to label %invoke.cont.1 unwind label %ehcleanup
17
18 invoke.cont.1:                                    ; preds = %catch
19   catchret from %0 to label %try.cont
20
21 try.cont:                                         ; preds = %entry, %invoke.cont.1
22   ret void
23
24 ehcleanup:
25   %cp2 = cleanuppad within none []
26   call void @g()
27   cleanupret from %cp2 unwind to caller
28 }
29
30 ; CHECK-LABEL:  define void @f(
31
32 ; CHECK:         invoke void @g()
33 ; CHECK:                 to label %dtor.exit unwind label %terminate.i
34
35 ; CHECK:       terminate.i:
36 ; CHECK-NEXT:    terminatepad within %0 [void ()* @terminate] unwind label %ehcleanup
37
38 declare i32 @__CxxFrameHandler3(...)
39
40 define internal void @dtor() personality i32 (...)* @__CxxFrameHandler3 {
41 entry:
42   invoke void @g()
43           to label %invoke.cont unwind label %terminate
44
45 invoke.cont:                                      ; preds = %entry
46   ret void
47
48 terminate:                                        ; preds = %entry
49   terminatepad within none [void ()* @terminate] unwind to caller
50 }
51
52 declare void @g()
53 declare void @terminate()