blob: d31ae2312c2c098ddadbb191d33cd4d7c0535e0e [file] [log] [blame]
David Majnemer97890232015-09-17 20:45:18 +00001; RUN: llc -mtriple=x86_64-windows-msvc < %s | FileCheck %s
2
3target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
4target triple = "x86_64-pc-windows-msvc"
5
David Majnemerf828a0c2015-10-01 18:44:59 +00006%eh.ThrowInfo = type { i32, i32, i32, i32 }
David Majnemer4600c062015-10-01 21:04:13 +00007%rtti.TypeDescriptor2 = type { i8**, i8*, [3 x i8] }
8
9@"\01??_7type_info@@6B@" = external constant i8*
10@"\01??_R0H@8" = internal global %rtti.TypeDescriptor2 { i8** @"\01??_7type_info@@6B@", i8* null, [3 x i8] c".H\00" }
David Majnemerf828a0c2015-10-01 18:44:59 +000011
12define void @test1(i1 %B) personality i32 (...)* @__CxxFrameHandler3 {
David Majnemer97890232015-09-17 20:45:18 +000013entry:
14 invoke void @g()
15 to label %unreachable unwind label %catch.dispatch
16
17catch.dispatch:
18 %cp = catchpad [i8* null, i32 64, i8* null]
19 to label %catch unwind label %catchendblock
20
21catch:
22 br i1 %B, label %catchret, label %catch
23
24catchret:
25 catchret %cp to label %try.cont
26
27try.cont:
28 ret void
29
30catchendblock:
31 catchendpad unwind to caller
32
33unreachable:
34 unreachable
35}
36
David Majnemerf828a0c2015-10-01 18:44:59 +000037; CHECK-LABEL: test1:
David Majnemer97890232015-09-17 20:45:18 +000038
39; The entry funclet contains %entry and %try.cont
40; CHECK: # %entry
41; CHECK: # %try.cont
42; CHECK: retq
43
44; The catch funclet contains %catch and %catchret
David Majnemer4600c062015-10-01 21:04:13 +000045; CHECK: # %catch{{$}}
David Majnemer97890232015-09-17 20:45:18 +000046; CHECK: # %catchret
47; CHECK: retq
48
49declare void @g()
50
David Majnemerf828a0c2015-10-01 18:44:59 +000051
52define i32 @test2(i1 %B) personality i32 (...)* @__CxxFrameHandler3 {
53entry:
54 invoke void @_CxxThrowException(i8* null, %eh.ThrowInfo* null) #1
55 to label %unreachable unwind label %catch.dispatch
56
57catch.dispatch: ; preds = %entry
58 %0 = catchpad [i8* null, i32 64, i8* null]
59 to label %catch unwind label %catchendblock
60
61catch: ; preds = %catch.dispatch
62 invoke void @_CxxThrowException(i8* null, %eh.ThrowInfo* null) #1
63 to label %unreachable unwind label %catch.dispatch.1
64
65catch.dispatch.1: ; preds = %catch
66 %1 = catchpad [i8* null, i32 64, i8* null]
67 to label %catch.3 unwind label %catchendblock.2
68
69catch.3: ; preds = %catch.dispatch.1
70 catchret %1 to label %try.cont
71
72try.cont: ; preds = %catch.3
73 catchret %0 to label %try.cont.5
74
75try.cont.5: ; preds = %try.cont
76 ret i32 0
77
78catchendblock.2: ; preds = %catch.dispatch.1
79 catchendpad unwind label %catchendblock
80
81catchendblock: ; preds = %catchendblock.2, %catch.dispatch
82 catchendpad unwind to caller
83
84unreachable: ; preds = %catch, %entry
85 unreachable
86
87}
88
89; CHECK-LABEL: test2:
90
91; The entry funclet contains %entry and %try.cont.5
92; CHECK: # %entry
93; CHECK: # %try.cont.5
94; CHECK: retq
95
96; The inner catch funclet contains %catch.3
97; CHECK: # %catch.3
98; CHECK: retq
99
100; The outer catch funclet contains %catch and %try.cont
David Majnemer4600c062015-10-01 21:04:13 +0000101; CHECK: # %catch{{$}}
102; CHECK: # %try.cont{{$}}
103; CHECK: retq
104
105
106define void @test3() #0 personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
107entry:
108 invoke void @g()
109 to label %try.cont unwind label %catch.dispatch
110
111catch.dispatch: ; preds = %entry
112 %0 = catchpad [%rtti.TypeDescriptor2* @"\01??_R0H@8", i32 0, i8* null]
113 to label %catch.2 unwind label %catch.dispatch.1
114
115catch.2: ; preds = %catch.dispatch
116 tail call void @exit(i32 0) #2
117 unreachable
118
119catch.dispatch.1: ; preds = %catch.dispatch
120 %1 = catchpad [i8* null, i32 64, i8* null]
121 to label %catch unwind label %catchendblock
122
123catch: ; preds = %catch.dispatch.1
124 tail call void @exit(i32 0) #2
125 unreachable
126
127catchendblock: ; preds = %catch.dispatch.1
128 catchendpad unwind to caller
129
130try.cont: ; preds = %entry
131 ret void
132}
133
134; CHECK-LABEL: test3:
135
136; The entry funclet contains %entry and %try.cont
137; CHECK: # %entry
David Majnemerf828a0c2015-10-01 18:44:59 +0000138; CHECK: # %try.cont
139; CHECK: retq
140
David Majnemer4600c062015-10-01 21:04:13 +0000141; The catch(int) funclet contains %catch.2
142; CHECK: # %catch.2
143; CHECK: callq exit
144
145; The catch(...) funclet contains %catch
146; CHECK: # %catch{{$}}
147; CHECK: callq exit
148
149declare void @exit(i32) noreturn nounwind
David Majnemerf828a0c2015-10-01 18:44:59 +0000150declare void @_CxxThrowException(i8*, %eh.ThrowInfo*)
David Majnemer97890232015-09-17 20:45:18 +0000151declare i32 @__CxxFrameHandler3(...)