1; RUN: sed -e s/.Cxx:// %s | opt -mtriple=x86-pc-windows-msvc -S -x86-winehstate | FileCheck %s
2; RUN: sed -e s/.SEH:// %s | opt -mtriple=x86-pc-windows-msvc -S -x86-winehstate | FileCheck %s
3
4declare i32 @__CxxFrameHandler3(...)
5declare i32 @_except_handler3(...)
6declare void @dummy_filter()
7
8declare void @f(i32)
9
10; CHECK-LABEL: define void @test2(
11;Cxx: define void @test2(i1 %b) personality i32 (...)* @__CxxFrameHandler3 {
12;SEH: define void @test2(i1 %b) personality i32 (...)* @_except_handler3 {
13entry:
14  ; CHECK: entry:
15  ; CHECK:   store i32 1
16  ; CHECK:   invoke void @f(i32 1)
17  invoke void @f(i32 1)
18    to label %exit unwind label %cleanup.pad
19cleanup.pad:
20  %cleanup = cleanuppad within none []
21  br i1 %b, label %left, label %right
22left:
23  cleanupret from %cleanup unwind label %catch.pad
24right:
25  cleanupret from %cleanup unwind label %catch.pad
26catch.pad:
27  %cs1 = catchswitch within none [label %catch.body] unwind to caller
28catch.body:
29;Cxx: %catch = catchpad within %cs1 [i8* null, i32 u0x40, i8* null]
30;SEH: %catch = catchpad within %cs1 [void ()* @dummy_filter]
31  catchret from %catch to label %exit
32exit:
33  ret void
34}
35
36; CHECK-LABEL: define void @test3(
37;Cxx: define void @test3() personality i32 (...)* @__CxxFrameHandler3 {
38;SEH: define void @test3() personality i32 (...)* @_except_handler3 {
39entry:
40  ; CHECK: entry:
41  ; CHECK:   store i32 0
42  ; CHECK:   invoke void @f(i32 1)
43  invoke void @f(i32 1)
44    to label %exit unwind label %cleanup.pad
45cleanup.pad:
46  ; CHECK: cleanup.pad:
47  ; CHECK:   store i32 1
48  ; CHECK:   invoke void @f(i32 0)
49  %cleanup = cleanuppad within none []
50  invoke void @f(i32 0)
51    to label %unreachable unwind label %catch.pad
52unreachable:
53  unreachable
54catch.pad:
55  %cs1 = catchswitch within none [label %catch.body] unwind to caller
56catch.body:
57;Cxx: %catch = catchpad within %cs1 [i8* null, i32 u0x40, i8* null]
58;SEH: %catch = catchpad within %cs1 [void ()* @dummy_filter]
59  catchret from %catch to label %exit
60exit:
61  ret void
62}
63