1 ; RUN: llc < %s | FileCheck %s
4 ; extern "C" int puts(const char *);
5 ; extern "C" int printf(const char *, ...);
6 ; extern "C" int do_div(int a, int b) { return a / b; }
7 ; extern "C" int filt();
19 ; } __except (filt()) {
26 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
27 target triple = "x86_64-pc-windows-msvc"
29 $"\01??_C@_07MKBLAIAL@finally?$AA@" = comdat any
31 $"\01??_C@_06IBDBCMGJ@caught?$AA@" = comdat any
33 @"\01??_C@_07MKBLAIAL@finally?$AA@" = linkonce_odr unnamed_addr constant [8 x i8] c"finally\00", comdat, align 1
34 @"\01??_C@_06IBDBCMGJ@caught?$AA@" = linkonce_odr unnamed_addr constant [7 x i8] c"caught\00", comdat, align 1
36 ; Function Attrs: nounwind readnone
37 define i32 @do_div(i32 %a, i32 %b) #0 {
39 %div = sdiv i32 %a, %b
43 define i32 @main() #1 personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) {
45 %call = invoke i32 @do_div(i32 1, i32 0) #4
46 to label %__try.cont.12 unwind label %catch.dispatch
48 catch.dispatch: ; preds = %entry
49 %0 = catchpad [i8* null]
50 to label %__except unwind label %catchendblock
52 __except: ; preds = %catch.dispatch
53 catchret %0 to label %__except.2
55 __except.2: ; preds = %__except
56 %call4 = invoke i32 @do_div(i32 1, i32 0) #4
57 to label %invoke.cont.3 unwind label %ehcleanup
59 invoke.cont.3: ; preds = %__except.2
60 invoke fastcc void @"\01?fin$0@0@main@@"() #4
61 to label %__try.cont.12 unwind label %catch.dispatch.7
63 catchendblock: ; preds = %catch.dispatch
64 catchendpad unwind label %catch.dispatch.7
66 ehcleanup: ; preds = %__except.2
68 invoke fastcc void @"\01?fin$0@0@main@@"() #4
69 to label %invoke.cont.6 unwind label %ehcleanup.end
71 invoke.cont.6: ; preds = %ehcleanup
72 cleanupret %1 unwind label %catch.dispatch.7
74 catch.dispatch.7: ; preds = %invoke.cont.3, %invoke.cont.6, %ehcleanup.end, %catchendblock
75 %2 = catchpad [i8* bitcast (i32 (i8*, i8*)* @"\01?filt$0@0@main@@" to i8*)]
76 to label %__except.ret unwind label %catchendblock.8
78 __except.ret: ; preds = %catch.dispatch.7
79 catchret %2 to label %__except.9
81 __except.9: ; preds = %__except.ret
82 %call11 = tail call i32 @puts(i8* nonnull getelementptr inbounds ([7 x i8], [7 x i8]* @"\01??_C@_06IBDBCMGJ@caught?$AA@", i64 0, i64 0))
83 br label %__try.cont.12
85 __try.cont.12: ; preds = %invoke.cont.3, %entry, %__except.9
88 catchendblock.8: ; preds = %catch.dispatch.7
89 catchendpad unwind to caller
91 ehcleanup.end: ; preds = %ehcleanup
92 cleanupendpad %1 unwind label %catch.dispatch.7
95 ; CHECK: main: # @main
96 ; CHECK: .seh_proc main
97 ; CHECK: .seh_handler __C_specific_handler, @unwind, @except
99 ; CHECK: .seh_pushreg 5
100 ; CHECK: subq $48, %rsp
101 ; CHECK: .seh_stackalloc 48
102 ; CHECK: leaq 48(%rsp), %rbp
103 ; CHECK: .seh_setframe 5, 48
104 ; CHECK: .seh_endprologue
106 ; CHECK: movl $1, %ecx
107 ; CHECK: xorl %edx, %edx
108 ; CHECK: callq do_div
110 ; CHECK: .LBB1_[[epilogue:[0-9]+]]: # %__try.cont.12
111 ; CHECK: xorl %eax, %eax
112 ; CHECK: addq $48, %rsp
115 ; CHECK: .LBB1_[[except1bb:[0-9]+]]: # %catch.dispatch
117 ; CHECK: movl $1, %ecx
118 ; CHECK: xorl %edx, %edx
119 ; CHECK: callq do_div
121 ; CHECK: callq "?fin$0@0@main@@"
122 ; CHECK: jmp .LBB1_[[epilogue]]
123 ; CHECK: .LBB1_[[except2bb:[0-9]+]]: # %catch.dispatch.7
125 ; CHECK: # %__except.9
126 ; CHECK: leaq "??_C@_06IBDBCMGJ@caught?$AA@"(%rip), %rcx
128 ; CHECK: jmp .LBB1_[[epilogue]]
130 ; CHECK: .seh_handlerdata
131 ; CHECK-NEXT: .long (.Llsda_end0-.Llsda_begin0)/16
132 ; CHECK-NEXT: .Llsda_begin0:
133 ; CHECK-NEXT: .long .Ltmp0@IMGREL+1
134 ; CHECK-NEXT: .long .Ltmp1@IMGREL+1
135 ; CHECK-NEXT: .long 1
136 ; CHECK-NEXT: .long .LBB1_[[except1bb]]@IMGREL
137 ; CHECK-NEXT: .long .Ltmp0@IMGREL+1
138 ; CHECK-NEXT: .long .Ltmp1@IMGREL+1
139 ; CHECK-NEXT: .long "?filt$0@0@main@@"@IMGREL
140 ; CHECK-NEXT: .long .LBB1_[[except2bb]]@IMGREL
141 ; CHECK-NEXT: .long .Ltmp2@IMGREL+1
142 ; CHECK-NEXT: .long .Ltmp3@IMGREL+1
143 ; CHECK-NEXT: .long "?dtor$[[finbb:[0-9]+]]@?0?main@4HA"@IMGREL
144 ; CHECK-NEXT: .long 0
145 ; CHECK-NEXT: .long .Ltmp2@IMGREL+1
146 ; CHECK-NEXT: .long .Ltmp3@IMGREL+1
147 ; CHECK-NEXT: .long "?filt$0@0@main@@"@IMGREL
148 ; CHECK-NEXT: .long .LBB1_6@IMGREL
149 ; CHECK-NEXT: .long .Ltmp6@IMGREL+1
150 ; CHECK-NEXT: .long .Ltmp7@IMGREL+1
151 ; CHECK-NEXT: .long "?filt$0@0@main@@"@IMGREL
152 ; CHECK-NEXT: .long .LBB1_6@IMGREL
153 ; CHECK-NEXT: .Llsda_end0:
156 ; CHECK: .seh_endproc
158 ; CHECK: "?dtor$4@?0?main@4HA":
159 ; CHECK: .seh_proc "?dtor$4@?0?main@4HA"
160 ; CHECK: .seh_handler __C_specific_handler, @unwind, @except
161 ; CHECK: .LBB1_[[finbb]]: # %ehcleanup
162 ; CHECK: movq %rdx, 16(%rsp)
164 ; CHECK: .seh_pushreg 5
165 ; CHECK: subq $32, %rsp
166 ; CHECK: .seh_stackalloc 32
167 ; CHECK: leaq 48(%rdx), %rbp
168 ; CHECK: .seh_endprologue
169 ; CHECK: callq "?fin$0@0@main@@"
171 ; CHECK: addq $32, %rsp
174 ; CHECK: .seh_handlerdata
175 ; CHECK: .seh_endproc
177 define internal i32 @"\01?filt$0@0@main@@"(i8* nocapture readnone %exception_pointers, i8* nocapture readnone %frame_pointer) #1 {
179 %call = tail call i32 @filt()
183 ; CHECK: "?filt$0@0@main@@": # @"\01?filt$0@0@main@@"
184 ; CHECK: .seh_proc "?filt$0@0@main@@"
185 ; CHECK: .seh_endprologue
186 ; CHECK: rex64 jmp filt # TAILCALL
187 ; CHECK: .seh_handlerdata
189 declare i32 @filt() #1
191 declare i32 @__C_specific_handler(...)
193 ; Function Attrs: noinline nounwind
194 define internal fastcc void @"\01?fin$0@0@main@@"() #2 {
196 %call = tail call i32 @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @"\01??_C@_07MKBLAIAL@finally?$AA@", i64 0, i64 0)) #5
200 ; Function Attrs: nounwind
201 declare i32 @puts(i8* nocapture readonly) #3
203 attributes #0 = { nounwind readnone "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-features"="+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
204 attributes #1 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-features"="+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
205 attributes #2 = { noinline nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-features"="+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
206 attributes #3 = { nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-features"="+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
207 attributes #4 = { noinline }
208 attributes #5 = { nounwind }