1 ; RUN: llc -verify-machineinstrs < %s | FileCheck %s
\r
3 ; CHECK-LABEL: "$cppxdata$?crash@@YAXH@Z":
\r
4 ; CHECK: .long ("$stateUnwindMap$?crash@@YAXH@Z")
\r
5 ; CHECK: .long ("$ip2state$?crash@@YAXH@Z")
\r
7 ; CHECK-LABEL: "$stateUnwindMap$?crash@@YAXH@Z":
\r
9 ; CHECK: .long "?dtor$
\r
11 ; CHECK: .long "?dtor$
\r
13 ; CHECK: .long "?dtor$
\r
15 ; CHECK-LABEL: "$ip2state$?crash@@YAXH@Z":
\r
16 ; CHECK-NEXT: .long .Lfunc_begin0@IMGREL
\r
17 ; CHECK-NEXT: .long -1
\r
18 ; CHECK-NEXT: .long .Ltmp
\r
19 ; CHECK-NEXT: .long 0
\r
20 ; CHECK-NEXT: .long .Ltmp
\r
21 ; CHECK-NEXT: .long 1
\r
22 ; CHECK-NEXT: .long .Ltmp
\r
23 ; CHECK-NEXT: .long 2
\r
24 ; CHECK-NEXT: .long .Ltmp
\r
25 ; CHECK-NEXT: .long 1
\r
26 ; CHECK-NEXT: .long .Ltmp
\r
27 ; CHECK-NEXT: .long 0
\r
28 ; CHECK-NEXT: .long .Ltmp
\r
29 ; CHECK-NEXT: .long -1
\r
31 ; ModuleID = 'windows-seh-EHa-CppDtors01.cpp'
\r
32 source_filename = "windows-seh-EHa-CppDtors01.cpp"
\r
33 target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
\r
34 target triple = "x86_64-unknown-windows-msvc"
\r
36 %struct.A = type { i8 }
\r
37 %struct.B = type { i8 }
\r
38 %struct.C = type { i8 }
\r
40 $"??_C@_0CM@KAOHJHDK@?5Test?5CPP?5unwind?3?5in?5catch?5handl@" = comdat any
\r
42 $"??_C@_0N@FCCEEGKL@?5in?5C?5dtor?5?6?$AA@" = comdat any
\r
44 $"??_C@_0N@EFFPFCOI@?5in?5B?5dtor?5?6?$AA@" = comdat any
\r
46 $"??_C@_0N@HMNCGOCN@?5in?5A?5dtor?5?6?$AA@" = comdat any
\r
48 @"?g@@3HA" = dso_local global i32 0, align 4
\r
49 @"??_C@_0CM@KAOHJHDK@?5Test?5CPP?5unwind?3?5in?5catch?5handl@" = linkonce_odr dso_local unnamed_addr constant [44 x i8] c" Test CPP unwind: in catch handler i = %d \0A\00", comdat, align 1
\r
50 @"??_C@_0N@FCCEEGKL@?5in?5C?5dtor?5?6?$AA@" = linkonce_odr dso_local unnamed_addr constant [13 x i8] c" in C dtor \0A\00", comdat, align 1
\r
51 @"??_C@_0N@EFFPFCOI@?5in?5B?5dtor?5?6?$AA@" = linkonce_odr dso_local unnamed_addr constant [13 x i8] c" in B dtor \0A\00", comdat, align 1
\r
52 @"??_C@_0N@HMNCGOCN@?5in?5A?5dtor?5?6?$AA@" = linkonce_odr dso_local unnamed_addr constant [13 x i8] c" in A dtor \0A\00", comdat, align 1
\r
54 ; Function Attrs: noinline optnone
\r
55 define dso_local void @"?crash@@YAXH@Z"(i32 %i) #0 personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
\r
57 %i.addr = alloca i32, align 4
\r
58 %ObjA = alloca %struct.A, align 1
\r
59 %ObjB = alloca %struct.B, align 1
\r
60 %ObjC = alloca %struct.C, align 1
\r
61 store i32 %i, i32* %i.addr, align 4
\r
62 invoke void @llvm.seh.scope.begin()
\r
63 to label %invoke.cont unwind label %ehcleanup13
\r
65 invoke.cont: ; preds = %entry
\r
66 %0 = load i32, i32* %i.addr, align 4
\r
67 %cmp = icmp eq i32 %0, 0
\r
68 br i1 %cmp, label %if.then, label %if.end
\r
70 if.then: ; preds = %invoke.cont
\r
71 store volatile i32 0, i32* inttoptr (i64 17 to i32*), align 4
\r
74 if.end: ; preds = %if.then, %invoke.cont
\r
75 invoke void @llvm.seh.scope.begin()
\r
76 to label %invoke.cont1 unwind label %ehcleanup11
\r
78 invoke.cont1: ; preds = %if.end
\r
79 %1 = load i32, i32* %i.addr, align 4
\r
80 %cmp2 = icmp eq i32 %1, 1
\r
81 br i1 %cmp2, label %if.then3, label %if.end4
\r
83 if.then3: ; preds = %invoke.cont1
\r
84 store volatile i32 0, i32* inttoptr (i64 17 to i32*), align 4
\r
87 if.end4: ; preds = %if.then3, %invoke.cont1
\r
88 invoke void @llvm.seh.scope.begin()
\r
89 to label %invoke.cont5 unwind label %ehcleanup
\r
91 invoke.cont5: ; preds = %if.end4
\r
92 %2 = load i32, i32* %i.addr, align 4
\r
93 %cmp6 = icmp eq i32 %2, 2
\r
94 br i1 %cmp6, label %if.then7, label %if.end8
\r
96 if.then7: ; preds = %invoke.cont5
\r
97 store volatile i32 0, i32* inttoptr (i64 17 to i32*), align 4
\r
100 if.end8: ; preds = %if.then7, %invoke.cont5
\r
101 invoke void @llvm.seh.scope.end()
\r
102 to label %invoke.cont9 unwind label %ehcleanup
\r
104 invoke.cont9: ; preds = %if.end8
\r
105 call void @"??1C@?1??crash@@YAXH@Z@QEAA@XZ"(%struct.C* %ObjC) #6
\r
106 invoke void @llvm.seh.scope.end()
\r
107 to label %invoke.cont10 unwind label %ehcleanup11
\r
109 invoke.cont10: ; preds = %invoke.cont9
\r
110 call void @"??1B@?1??crash@@YAXH@Z@QEAA@XZ"(%struct.B* %ObjB) #6
\r
111 invoke void @llvm.seh.scope.end()
\r
112 to label %invoke.cont12 unwind label %ehcleanup13
\r
114 invoke.cont12: ; preds = %invoke.cont10
\r
115 call void @"??1A@?1??crash@@YAXH@Z@QEAA@XZ"(%struct.A* %ObjA) #6
\r
118 ehcleanup: ; preds = %if.end8, %if.end4
\r
119 %3 = cleanuppad within none []
\r
120 call void @"??1C@?1??crash@@YAXH@Z@QEAA@XZ"(%struct.C* %ObjC) #6 [ "funclet"(token %3) ]
\r
121 cleanupret from %3 unwind label %ehcleanup11
\r
123 ehcleanup11: ; preds = %invoke.cont9, %ehcleanup, %if.end
\r
124 %4 = cleanuppad within none []
\r
125 call void @"??1B@?1??crash@@YAXH@Z@QEAA@XZ"(%struct.B* %ObjB) #6 [ "funclet"(token %4) ]
\r
126 cleanupret from %4 unwind label %ehcleanup13
\r
128 ehcleanup13: ; preds = %invoke.cont10, %ehcleanup11, %entry
\r
129 %5 = cleanuppad within none []
\r
130 call void @"??1A@?1??crash@@YAXH@Z@QEAA@XZ"(%struct.A* %ObjA) #6 [ "funclet"(token %5) ]
\r
131 cleanupret from %5 unwind to caller
\r
134 ; Function Attrs: nounwind readnone
\r
135 declare dso_local void @llvm.seh.scope.begin() #1
\r
137 declare dso_local i32 @__CxxFrameHandler3(...)
\r
139 ; Function Attrs: nounwind readnone
\r
140 declare dso_local void @llvm.seh.scope.end() #1
\r
142 ; Function Attrs: noinline nounwind optnone
\r
143 define internal void @"??1C@?1??crash@@YAXH@Z@QEAA@XZ"(%struct.C* %this) unnamed_addr #2 align 2 {
\r
145 %this.addr = alloca %struct.C*, align 8
\r
146 store %struct.C* %this, %struct.C** %this.addr, align 8
\r
147 %this1 = load %struct.C*, %struct.C** %this.addr, align 8
\r
148 call void (...) @"?printf@@YAXZZ"(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @"??_C@_0N@FCCEEGKL@?5in?5C?5dtor?5?6?$AA@", i64 0, i64 0))
\r
152 ; Function Attrs: noinline nounwind optnone
\r
153 define internal void @"??1B@?1??crash@@YAXH@Z@QEAA@XZ"(%struct.B* %this) unnamed_addr #2 align 2 {
\r
155 %this.addr = alloca %struct.B*, align 8
\r
156 store %struct.B* %this, %struct.B** %this.addr, align 8
\r
157 %this1 = load %struct.B*, %struct.B** %this.addr, align 8
\r
158 call void (...) @"?printf@@YAXZZ"(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @"??_C@_0N@EFFPFCOI@?5in?5B?5dtor?5?6?$AA@", i64 0, i64 0))
\r
162 ; Function Attrs: noinline nounwind optnone
\r
163 define internal void @"??1A@?1??crash@@YAXH@Z@QEAA@XZ"(%struct.A* %this) unnamed_addr #2 align 2 {
\r
165 %this.addr = alloca %struct.A*, align 8
\r
166 store %struct.A* %this, %struct.A** %this.addr, align 8
\r
167 %this1 = load %struct.A*, %struct.A** %this.addr, align 8
\r
168 call void (...) @"?printf@@YAXZZ"(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @"??_C@_0N@HMNCGOCN@?5in?5A?5dtor?5?6?$AA@", i64 0, i64 0))
\r
172 ; Function Attrs: noinline norecurse optnone
\r
173 define dso_local i32 @main() #3 personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) {
\r
175 %retval = alloca i32, align 4
\r
176 %i = alloca i32, align 4
\r
177 %__exception_code = alloca i32, align 4
\r
178 store i32 0, i32* %retval, align 4
\r
179 store i32 0, i32* %i, align 4
\r
182 for.cond: ; preds = %for.inc, %entry
\r
183 %0 = load i32, i32* %i, align 4
\r
184 %cmp = icmp slt i32 %0, 3
\r
185 br i1 %cmp, label %for.body, label %for.end
\r
187 for.body: ; preds = %for.cond
\r
188 invoke void @llvm.seh.try.begin()
\r
189 to label %invoke.cont unwind label %catch.dispatch
\r
191 invoke.cont: ; preds = %for.body
\r
192 %1 = load volatile i32, i32* %i, align 4
\r
193 invoke void @"?crash@@YAXH@Z"(i32 %1) #7
\r
194 to label %invoke.cont1 unwind label %catch.dispatch
\r
196 invoke.cont1: ; preds = %invoke.cont
\r
197 invoke void @llvm.seh.try.end()
\r
198 to label %invoke.cont2 unwind label %catch.dispatch
\r
200 catch.dispatch: ; preds = %invoke.cont1, %invoke.cont, %for.body
\r
201 %2 = catchswitch within none [label %__except] unwind to caller
\r
203 __except: ; preds = %catch.dispatch
\r
204 %3 = catchpad within %2 [i8* null]
\r
205 catchret from %3 to label %__except3
\r
207 __except3: ; preds = %__except
\r
208 %4 = call i32 @llvm.eh.exceptioncode(token %3)
\r
209 store i32 %4, i32* %__exception_code, align 4
\r
210 %5 = load i32, i32* %i, align 4
\r
211 call void (...) @"?printf@@YAXZZ"(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @"??_C@_0CM@KAOHJHDK@?5Test?5CPP?5unwind?3?5in?5catch?5handl@", i64 0, i64 0), i32 %5)
\r
212 br label %__try.cont
\r
214 __try.cont: ; preds = %__except3, %invoke.cont2
\r
217 for.inc: ; preds = %__try.cont
\r
218 %6 = load i32, i32* %i, align 4
\r
219 %inc = add nsw i32 %6, 1
\r
220 store i32 %inc, i32* %i, align 4
\r
223 invoke.cont2: ; preds = %invoke.cont1
\r
224 br label %__try.cont
\r
226 for.end: ; preds = %for.cond
\r
230 ; Function Attrs: nounwind willreturn
\r
231 declare dso_local void @llvm.seh.try.begin() #4
\r
233 declare dso_local i32 @__C_specific_handler(...)
\r
235 ; Function Attrs: nounwind willreturn
\r
236 declare dso_local void @llvm.seh.try.end() #4
\r
238 ; Function Attrs: nounwind readnone
\r
239 declare i32 @llvm.eh.exceptioncode(token) #1
\r
241 declare dso_local void @"?printf@@YAXZZ"(...) #5
\r
243 attributes #0 = { noinline optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
\r
244 attributes #1 = { nounwind readnone }
\r
245 attributes #2 = { noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
\r
246 attributes #3 = { noinline norecurse optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
\r
247 attributes #4 = { nounwind willreturn }
\r
248 attributes #5 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
\r
249 attributes #6 = { nounwind }
\r
250 attributes #7 = { noinline }
\r
252 !llvm.module.flags = !{!0, !1}
\r
254 !0 = !{i32 1, !"wchar_size", i32 2}
\r
255 !1 = !{i32 2, !"eh-asynch", i32 1}
\r