blob: 0468b3c314f6166c7379e62de08492d2783e4fdd [file] [log] [blame]
Andrew Kaylor9efb2332015-12-03 18:55:28 +00001; RUN: llc -mtriple=x86_64-pc-windows-msvc < %s | FileCheck %s
Andrew Kaylor9efb2332015-12-03 18:55:28 +00002
3declare i32 @__CxxFrameHandler3(...)
4
5declare void @throw()
6declare i16 @f()
7
8define i16 @test1(i16 %a, i8* %b) personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
9entry:
10 %cmp = icmp eq i16 %a, 10
11 br i1 %cmp, label %if.then, label %if.else
12
13if.then:
14 %call1 = invoke i16 @f()
15 to label %cleanup unwind label %catch.dispatch
16
17if.else:
18 %call2 = invoke i16 @f()
19 to label %cleanup unwind label %catch.dispatch
20
21catch.dispatch:
David Majnemer8a1c45d2015-12-12 05:38:55 +000022 %cs = catchswitch within none [ label %catch, label %catch.2 ] unwind to caller
Andrew Kaylor9efb2332015-12-03 18:55:28 +000023
24catch:
David Majnemer8a1c45d2015-12-12 05:38:55 +000025 catchpad within %cs [i8* null, i32 8, i8* null]
26 call void @throw() noreturn
27 br label %unreachable
Andrew Kaylor9efb2332015-12-03 18:55:28 +000028
29catch.2:
David Majnemer8a1c45d2015-12-12 05:38:55 +000030 catchpad within %cs [i8* null, i32 64, i8* null]
Andrew Kaylor9efb2332015-12-03 18:55:28 +000031 store i8 1, i8* %b
David Majnemer8a1c45d2015-12-12 05:38:55 +000032 call void @throw() noreturn
33 br label %unreachable
Andrew Kaylor9efb2332015-12-03 18:55:28 +000034
35cleanup:
36 %retval = phi i16 [ %call1, %if.then ], [ %call2, %if.else ]
37 ret i16 %retval
38
39unreachable:
40 unreachable
41}
42
43; This test verifies the case where two funclet blocks meet the old criteria
44; to be placed at the end. The order of the blocks is not important for the
45; purposes of this test. The failure mode is an infinite loop during
46; compilation.
47;
48; CHECK-LABEL: .def test1;
49
50define i16 @test2(i16 %a, i8* %b) personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
51entry:
52 %cmp = icmp eq i16 %a, 10
53 br i1 %cmp, label %if.then, label %if.else
54
55if.then:
56 %call1 = invoke i16 @f()
57 to label %cleanup unwind label %catch.dispatch
58
59if.else:
60 %call2 = invoke i16 @f()
61 to label %cleanup unwind label %catch.dispatch
62
63catch.dispatch:
David Majnemer8a1c45d2015-12-12 05:38:55 +000064 %cs = catchswitch within none [ label %catch, label %catch.2, label %catch.3 ] unwind to caller
Andrew Kaylor9efb2332015-12-03 18:55:28 +000065
66catch:
David Majnemer8a1c45d2015-12-12 05:38:55 +000067 catchpad within %cs [i8* null, i32 8, i8* null]
68 call void @throw() noreturn
69 br label %unreachable
Andrew Kaylor9efb2332015-12-03 18:55:28 +000070
71catch.2:
David Majnemer8a1c45d2015-12-12 05:38:55 +000072 %c2 = catchpad within %cs [i8* null, i32 32, i8* null]
Andrew Kaylor9efb2332015-12-03 18:55:28 +000073 store i8 1, i8* %b
David Majnemer8a1c45d2015-12-12 05:38:55 +000074 catchret from %c2 to label %cleanup
Andrew Kaylor9efb2332015-12-03 18:55:28 +000075
76catch.3:
David Majnemer8a1c45d2015-12-12 05:38:55 +000077 %c3 = catchpad within %cs [i8* null, i32 64, i8* null]
Andrew Kaylor9efb2332015-12-03 18:55:28 +000078 store i8 2, i8* %b
David Majnemer8a1c45d2015-12-12 05:38:55 +000079 catchret from %c3 to label %cleanup
Andrew Kaylor9efb2332015-12-03 18:55:28 +000080
81cleanup:
82 %retval = phi i16 [ %call1, %if.then ], [ %call2, %if.else ], [ -1, %catch.2 ], [ -1, %catch.3 ]
83 ret i16 %retval
84
85unreachable:
86 unreachable
87}
88
89; This test verifies the case where three funclet blocks all meet the old
90; criteria to be placed at the end. The order of the blocks is not important
91; for the purposes of this test. The failure mode is an infinite loop during
92; compilation.
93;
94; CHECK-LABEL: .def test2;
95