1; RUN: opt -S -inline -inline-threshold=100 -inline-cold-callsite-threshold=100 < %s | FileCheck %s
2; RUN: opt -S -passes='cgscc(inline)' -inline-threshold=100 -inline-cold-callsite-threshold=100 < %s | FileCheck %s
3target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
4target triple = "i686-pc-windows-msvc18.0.0"
5
6declare void @g(i32)
7
8define void @f() personality i32 (...)* @__CxxFrameHandler3 {
9entry:
10  invoke void @g(i32 0)
11          to label %invoke.cont unwind label %cs.bb
12
13invoke.cont:
14  ret void
15
16cs.bb:
17  %cs = catchswitch within none [label %cp.bb] unwind label %cleanup.bb
18
19cp.bb:
20  %cpouter1 = catchpad within %cs [i8* null, i32 0, i8* null]
21  call void @dtor() #1 [ "funclet"(token %cpouter1) ]
22  catchret from %cpouter1 to label %invoke.cont
23
24cleanup.bb:
25  %cpouter2 = cleanuppad within none []
26  call void @g(i32 1) [ "funclet"(token %cpouter2) ]
27  cleanupret from %cpouter2 unwind to caller
28}
29
30declare i32 @__CxxFrameHandler3(...)
31
32; Function Attrs: nounwind
33define internal void @dtor() #1 personality i32 (...)* @__CxxFrameHandler3 {
34entry:
35  invoke void @g(i32 2)
36          to label %invoke.cont unwind label %ehcleanup1
37
38invoke.cont:
39  ret void
40
41ehcleanup1:
42  %cpinner1 = cleanuppad within none []
43  invoke void @g(i32 3) [ "funclet" (token %cpinner1) ]
44          to label %done unwind label %ehcleanup2
45done:
46  unreachable
47
48ehcleanup2:
49  %cpinner2 = cleanuppad within %cpinner1 []
50  call void @g(i32 4) [ "funclet" (token %cpinner2) ]
51  cleanupret from %cpinner2 unwind to caller
52}
53
54; CHECK-LABEL: define void @f(
55
56; CHECK:      %[[cs:.*]] = catchswitch within none
57
58; CHECK:      %[[cpouter1:.*]] = catchpad within %[[cs]]
59
60; CHECK:      %[[cpinner1:.*]] = cleanuppad within %[[cpouter1]]
61
62; CHECK:      %[[cpinner2:.*]] = cleanuppad within %[[cpinner1]]
63; CHECK-NEXT: call void @g(i32 4) #0 [ "funclet"(token %[[cpinner2]]) ]
64; CHECK-NEXT: unreachable
65
66attributes #1 = { nounwind }
67