1 ; RUN: llc -verify-machineinstrs < %s | FileCheck %s
\r
3 ; CHECK-LABEL: "?fin$0@0@main@@"
\r
4 ; CHECK: .seh_handlerdata
\r
5 ; CHECK: .set ".L?fin$0@0@main@@$parent_frame_offset", 48
\r
6 ; CHECK-NEXT: .long (.Llsda_end1-.Llsda_begin1)/16
\r
7 ; CHECK-NEXT: .Llsda_begin1:
\r
8 ; CHECK-NEXT: .long .Ltmp
\r
9 ; CHECK-NEXT: .long .Ltmp
\r
10 ; CHECK-NEXT: .long "?dtor$
\r
11 ; CHECK-NEXT: .long 0
\r
12 ; CHECK-NEXT: .Llsda_end1:
\r
14 ; ModuleID = 'windows-seh-EHa-TryInFinally.cpp'
\r
15 source_filename = "windows-seh-EHa-TryInFinally.cpp"
\r
16 target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
\r
17 target triple = "x86_64-unknown-windows-msvc"
\r
19 $"??_C@_0CI@MDFPIOJJ@?5?9?9?9?5Test?5_Try?5in?5_finally?5?9?9?9?5i@" = comdat any
\r
21 $"??_C@_0BN@HHKJHLBE@?5?5In?5Inner?5_finally?5i?5?$DN?5?$CFd?5?6?$AA@" = comdat any
\r
23 $"??_C@_0BN@HAIIIOKI@?5?5In?5outer?5_finally?5i?5?$DN?5?$CFd?5?6?$AA@" = comdat any
\r
25 $"??_C@_0BJ@OJMMAGCD@?5?5In?5outer?5_try?5i?5?$DN?5?$CFd?5?6?$AA@" = comdat any
\r
27 $"??_C@_0CG@ENDJHCGA@?5?9?9?9?5In?5outer?5except?5handler?5i?5?$DN@" = comdat any
\r
29 @"??_C@_0CI@MDFPIOJJ@?5?9?9?9?5Test?5_Try?5in?5_finally?5?9?9?9?5i@" = linkonce_odr dso_local unnamed_addr constant [40 x i8] c" --- Test _Try in _finally --- i = %d \0A\00", comdat, align 1
\r
30 @"??_C@_0BN@HHKJHLBE@?5?5In?5Inner?5_finally?5i?5?$DN?5?$CFd?5?6?$AA@" = linkonce_odr dso_local unnamed_addr constant [29 x i8] c" In Inner _finally i = %d \0A\00", comdat, align 1
\r
31 @"??_C@_0BN@HAIIIOKI@?5?5In?5outer?5_finally?5i?5?$DN?5?$CFd?5?6?$AA@" = linkonce_odr dso_local unnamed_addr constant [29 x i8] c" In outer _finally i = %d \0A\00", comdat, align 1
\r
32 @"??_C@_0BJ@OJMMAGCD@?5?5In?5outer?5_try?5i?5?$DN?5?$CFd?5?6?$AA@" = linkonce_odr dso_local unnamed_addr constant [25 x i8] c" In outer _try i = %d \0A\00", comdat, align 1
\r
33 @"??_C@_0CG@ENDJHCGA@?5?9?9?9?5In?5outer?5except?5handler?5i?5?$DN@" = linkonce_odr dso_local unnamed_addr constant [38 x i8] c" --- In outer except handler i = %d \0A\00", comdat, align 1
\r
35 ; Function Attrs: noinline norecurse optnone
\r
36 define dso_local i32 @main() #0 personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) {
\r
38 %retval = alloca i32, align 4
\r
39 %i = alloca i32, align 4
\r
40 %__exception_code = alloca i32, align 4
\r
41 call void (...) @llvm.localescape(i32* %i)
\r
42 store i32 0, i32* %retval, align 4
\r
43 store i32 0, i32* %i, align 4
\r
46 for.cond: ; preds = %for.inc, %entry
\r
47 %0 = load i32, i32* %i, align 4
\r
48 %cmp = icmp slt i32 %0, 3
\r
49 br i1 %cmp, label %for.body, label %for.end
\r
51 for.body: ; preds = %for.cond
\r
52 %1 = load i32, i32* %i, align 4
\r
53 call void (...) @"?printf@@YAXZZ"(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @"??_C@_0CI@MDFPIOJJ@?5?9?9?9?5Test?5_Try?5in?5_finally?5?9?9?9?5i@", i64 0, i64 0), i32 %1)
\r
54 invoke void @llvm.seh.try.begin()
\r
55 to label %invoke.cont unwind label %catch.dispatch
\r
57 invoke.cont: ; preds = %for.body
\r
58 invoke void @llvm.seh.try.begin()
\r
59 to label %invoke.cont1 unwind label %ehcleanup
\r
61 invoke.cont1: ; preds = %invoke.cont
\r
62 %2 = load volatile i32, i32* %i, align 4
\r
63 invoke void (...) @"?printf@@YAXZZ"(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @"??_C@_0BJ@OJMMAGCD@?5?5In?5outer?5_try?5i?5?$DN?5?$CFd?5?6?$AA@", i64 0, i64 0), i32 %2) #6
\r
64 to label %invoke.cont2 unwind label %ehcleanup
\r
66 invoke.cont2: ; preds = %invoke.cont1
\r
67 %3 = load volatile i32, i32* %i, align 4
\r
68 %cmp3 = icmp eq i32 %3, 0
\r
69 br i1 %cmp3, label %if.then, label %if.end
\r
71 if.then: ; preds = %invoke.cont2
\r
72 store volatile i32 0, i32* inttoptr (i64 17 to i32*), align 4
\r
75 if.end: ; preds = %if.then, %invoke.cont2
\r
76 invoke void @llvm.seh.try.end()
\r
77 to label %invoke.cont4 unwind label %ehcleanup
\r
79 invoke.cont4: ; preds = %if.end
\r
80 %4 = call i8* @llvm.localaddress()
\r
81 invoke void @"?fin$0@0@main@@"(i8 0, i8* %4) #6
\r
82 to label %invoke.cont5 unwind label %catch.dispatch
\r
84 invoke.cont5: ; preds = %invoke.cont4
\r
85 invoke void @llvm.seh.try.end()
\r
86 to label %invoke.cont7 unwind label %catch.dispatch
\r
88 catch.dispatch: ; preds = %invoke.cont5, %invoke.cont6, %ehcleanup, %invoke.cont4, %for.body
\r
89 %5 = catchswitch within none [label %__except] unwind to caller
\r
91 __except: ; preds = %catch.dispatch
\r
92 %6 = catchpad within %5 [i8* null]
\r
93 catchret from %6 to label %__except8
\r
95 __except8: ; preds = %__except
\r
96 %7 = call i32 @llvm.eh.exceptioncode(token %6)
\r
97 store i32 %7, i32* %__exception_code, align 4
\r
98 %8 = load i32, i32* %i, align 4
\r
99 call void (...) @"?printf@@YAXZZ"(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @"??_C@_0CG@ENDJHCGA@?5?9?9?9?5In?5outer?5except?5handler?5i?5?$DN@", i64 0, i64 0), i32 %8)
\r
100 br label %__try.cont
\r
102 __try.cont: ; preds = %__except8, %invoke.cont7
\r
105 for.inc: ; preds = %__try.cont
\r
106 %9 = load i32, i32* %i, align 4
\r
107 %inc = add nsw i32 %9, 1
\r
108 store i32 %inc, i32* %i, align 4
\r
111 invoke.cont7: ; preds = %invoke.cont5
\r
112 br label %__try.cont
\r
114 ehcleanup: ; preds = %if.end, %invoke.cont1, %invoke.cont
\r
115 %10 = cleanuppad within none []
\r
116 %11 = call i8* @llvm.localaddress()
\r
117 invoke void @"?fin$0@0@main@@"(i8 1, i8* %11) #6 [ "funclet"(token %10) ]
\r
118 to label %invoke.cont6 unwind label %catch.dispatch
\r
120 invoke.cont6: ; preds = %ehcleanup
\r
121 cleanupret from %10 unwind label %catch.dispatch
\r
123 for.end: ; preds = %for.cond
\r
127 declare dso_local void @"?printf@@YAXZZ"(...) #1
\r
129 ; Function Attrs: nounwind willreturn
\r
130 declare dso_local void @llvm.seh.try.begin() #2
\r
132 declare dso_local i32 @__C_specific_handler(...)
\r
134 ; Function Attrs: noinline
\r
135 define internal void @"?fin$0@0@main@@"(i8 %abnormal_termination, i8* %frame_pointer) #3 personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) {
\r
137 %frame_pointer.addr = alloca i8*, align 8
\r
138 %abnormal_termination.addr = alloca i8, align 1
\r
139 %0 = call i8* @llvm.localrecover(i8* bitcast (i32 ()* @main to i8*), i8* %frame_pointer, i32 0)
\r
140 %i = bitcast i8* %0 to i32*
\r
141 store i8* %frame_pointer, i8** %frame_pointer.addr, align 8
\r
142 store i8 %abnormal_termination, i8* %abnormal_termination.addr, align 1
\r
143 invoke void @llvm.seh.try.begin()
\r
144 to label %invoke.cont unwind label %ehcleanup
\r
146 invoke.cont: ; preds = %entry
\r
147 %1 = load volatile i32, i32* %i, align 4
\r
148 invoke void (...) @"?printf@@YAXZZ"(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @"??_C@_0BN@HAIIIOKI@?5?5In?5outer?5_finally?5i?5?$DN?5?$CFd?5?6?$AA@", i64 0, i64 0), i32 %1) #6
\r
149 to label %invoke.cont1 unwind label %ehcleanup
\r
151 invoke.cont1: ; preds = %invoke.cont
\r
152 %2 = load volatile i32, i32* %i, align 4
\r
153 %cmp = icmp eq i32 %2, 1
\r
154 br i1 %cmp, label %if.then, label %if.end
\r
156 if.then: ; preds = %invoke.cont1
\r
157 store volatile i32 0, i32* inttoptr (i64 17 to i32*), align 4
\r
160 if.end: ; preds = %if.then, %invoke.cont1
\r
161 invoke void @llvm.seh.try.end()
\r
162 to label %invoke.cont2 unwind label %ehcleanup
\r
164 invoke.cont2: ; preds = %if.end
\r
165 call void @"?fin$1@0@main@@"(i8 0, i8* %frame_pointer)
\r
168 ehcleanup: ; preds = %if.end, %invoke.cont, %entry
\r
169 %3 = cleanuppad within none []
\r
170 call void @"?fin$1@0@main@@"(i8 1, i8* %frame_pointer) [ "funclet"(token %3) ]
\r
171 cleanupret from %3 unwind to caller
\r
174 ; Function Attrs: nounwind readnone
\r
175 declare i8* @llvm.localrecover(i8*, i8*, i32 immarg) #4
\r
177 ; Function Attrs: noinline
\r
178 define internal void @"?fin$1@0@main@@"(i8 %abnormal_termination, i8* %frame_pointer) #3 {
\r
180 %frame_pointer.addr = alloca i8*, align 8
\r
181 %abnormal_termination.addr = alloca i8, align 1
\r
182 %0 = call i8* @llvm.localrecover(i8* bitcast (i32 ()* @main to i8*), i8* %frame_pointer, i32 0)
\r
183 %i = bitcast i8* %0 to i32*
\r
184 store i8* %frame_pointer, i8** %frame_pointer.addr, align 8
\r
185 store i8 %abnormal_termination, i8* %abnormal_termination.addr, align 1
\r
186 %1 = load i32, i32* %i, align 4
\r
187 call void (...) @"?printf@@YAXZZ"(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @"??_C@_0BN@HHKJHLBE@?5?5In?5Inner?5_finally?5i?5?$DN?5?$CFd?5?6?$AA@", i64 0, i64 0), i32 %1)
\r
188 %2 = load i32, i32* %i, align 4
\r
189 %cmp = icmp eq i32 %2, 2
\r
190 br i1 %cmp, label %if.then, label %if.end
\r
192 if.then: ; preds = %entry
\r
193 store volatile i32 0, i32* inttoptr (i64 17 to i32*), align 4
\r
196 if.end: ; preds = %if.then, %entry
\r
200 ; Function Attrs: nounwind willreturn
\r
201 declare dso_local void @llvm.seh.try.end() #2
\r
203 ; Function Attrs: nounwind readnone
\r
204 declare i8* @llvm.localaddress() #4
\r
206 ; Function Attrs: nounwind readnone
\r
207 declare i32 @llvm.eh.exceptioncode(token) #4
\r
209 ; Function Attrs: nounwind
\r
210 declare void @llvm.localescape(...) #5
\r
212 attributes #0 = { 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
213 attributes #1 = { "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
214 attributes #2 = { nounwind willreturn }
\r
215 attributes #3 = { noinline "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-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
216 attributes #4 = { nounwind readnone }
\r
217 attributes #5 = { nounwind }
\r
218 attributes #6 = { noinline }
\r
220 !llvm.module.flags = !{!0, !1}
\r
222 !0 = !{i32 1, !"wchar_size", i32 2}
\r
223 !1 = !{i32 2, !"eh-asynch", i32 1}
\r