1 ; RUN: llc -mtriple x86_64-pc-windows-msvc < %s | FileCheck %s
3 declare void @maybe_throw()
5 @_ZTIi = external constant ptr
6 @g = external global i32
8 declare i32 @__C_specific_handler(...)
9 declare i32 @__gxx_personality_seh0(...)
10 declare i32 @llvm.eh.typeid.for(ptr) readnone nounwind
12 define i32 @use_seh() personality ptr @__C_specific_handler {
14 invoke void @maybe_throw()
15 to label %cont unwind label %lpad
21 %cs = catchswitch within none [label %catch] unwind to caller
23 %p = catchpad within %cs [ptr @filt_g]
24 catchret from %p to label %ret1
30 define internal i32 @filt_g(ptr, ptr) {
35 ; CHECK-LABEL: use_seh:
36 ; CHECK: callq maybe_throw
37 ; CHECK: xorl %eax, %eax
38 ; CHECK: .LBB0_[[epilogue:[0-9]+]]
40 ; CHECK: # %catch{{$}}
41 ; CHECK: movl $1, %eax
42 ; CHECK: jmp .LBB0_[[epilogue]]
44 ; A MinGW64-ish EH style. It could happen if a binary uses both MSVC CRT and
45 ; mingw CRT and is linked with LTO.
46 define i32 @use_gcc() personality ptr @__gxx_personality_seh0 {
48 invoke void @maybe_throw()
49 to label %cont unwind label %lpad
55 %ehvals = landingpad { ptr, i32 }
58 %ehsel = extractvalue { ptr, i32 } %ehvals, 1
59 %filt_g_sel = call i32 @llvm.eh.typeid.for(ptr @filt_g)
60 %matches = icmp eq i32 %ehsel, %filt_g_sel
61 br i1 %matches, label %ret1, label %eh.resume
67 resume { ptr, i32 } %ehvals
70 ; CHECK-LABEL: use_gcc:
71 ; CHECK: callq maybe_throw
72 ; CHECK: xorl %eax, %eax
75 ; CHECK: cmpl $2, %edx
79 ; CHECK: movl $1, %eax
81 ; CHECK: callq _Unwind_Resume