blob: 21c7818e5195f43393fe205d216aadcbb77a0724 [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:
22 catchpad [i8* null, i32 8, i8* null]
23 to label %catch unwind label %catch.dispatch.2
24
25catch:
26 invoke void @throw() noreturn
27 to label %unreachable unwind label %catchendblock
28
29catch.dispatch.2:
30 catchpad [i8* null, i32 64, i8* null]
31 to label %catch.2 unwind label %catchendblock
32
33catch.2:
34 store i8 1, i8* %b
35 invoke void @throw() noreturn
36 to label %unreachable unwind label %catchendblock
37
38catchendblock:
39 catchendpad unwind to caller
40
41cleanup:
42 %retval = phi i16 [ %call1, %if.then ], [ %call2, %if.else ]
43 ret i16 %retval
44
45unreachable:
46 unreachable
47}
48
49; This test verifies the case where two funclet blocks meet the old criteria
50; to be placed at the end. The order of the blocks is not important for the
51; purposes of this test. The failure mode is an infinite loop during
52; compilation.
53;
54; CHECK-LABEL: .def test1;
55
56define i16 @test2(i16 %a, i8* %b) personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
57entry:
58 %cmp = icmp eq i16 %a, 10
59 br i1 %cmp, label %if.then, label %if.else
60
61if.then:
62 %call1 = invoke i16 @f()
63 to label %cleanup unwind label %catch.dispatch
64
65if.else:
66 %call2 = invoke i16 @f()
67 to label %cleanup unwind label %catch.dispatch
68
69catch.dispatch:
70 catchpad [i8* null, i32 8, i8* null]
71 to label %catch unwind label %catch.dispatch.2
72
73catch:
74 invoke void @throw() noreturn
75 to label %unreachable unwind label %catchendblock
76
77catch.dispatch.2:
78 %c2 = catchpad [i8* null, i32 32, i8* null]
79 to label %catch.2 unwind label %catch.dispatch.3
80
81catch.2:
82 store i8 1, i8* %b
83 catchret %c2 to label %cleanup
84
85catch.dispatch.3:
86 %c3 = catchpad [i8* null, i32 64, i8* null]
87 to label %catch.3 unwind label %catchendblock
88
89catch.3:
90 store i8 2, i8* %b
91 catchret %c3 to label %cleanup
92
93catchendblock:
94 catchendpad unwind to caller
95
96cleanup:
97 %retval = phi i16 [ %call1, %if.then ], [ %call2, %if.else ], [ -1, %catch.2 ], [ -1, %catch.3 ]
98 ret i16 %retval
99
100unreachable:
101 unreachable
102}
103
104; This test verifies the case where three funclet blocks all meet the old
105; criteria to be placed at the end. The order of the blocks is not important
106; for the purposes of this test. The failure mode is an infinite loop during
107; compilation.
108;
109; CHECK-LABEL: .def test2;
110