82 lines · plain
1; RUN: llc -mtriple x86_64-pc-windows-msvc < %s | FileCheck %s2 3declare void @maybe_throw()4 5@_ZTIi = external constant ptr6@g = external global i327 8declare i32 @__C_specific_handler(...)9declare i32 @__gxx_personality_seh0(...)10declare i32 @llvm.eh.typeid.for(ptr) readnone nounwind11 12define i32 @use_seh() personality ptr @__C_specific_handler {13entry:14 invoke void @maybe_throw()15 to label %cont unwind label %lpad16 17cont:18 ret i32 019 20lpad:21 %cs = catchswitch within none [label %catch] unwind to caller22catch:23 %p = catchpad within %cs [ptr @filt_g]24 catchret from %p to label %ret125 26ret1:27 ret i32 128}29 30define internal i32 @filt_g(ptr, ptr) {31 %g = load i32, ptr @g32 ret i32 %g33}34 35; CHECK-LABEL: use_seh:36; CHECK: callq maybe_throw37; CHECK: xorl %eax, %eax38; CHECK: .LBB0_[[epilogue:[0-9]+]]39; CHECK: retq40; CHECK: # %catch{{$}}41; CHECK: movl $1, %eax42; CHECK: jmp .LBB0_[[epilogue]]43 44; A MinGW64-ish EH style. It could happen if a binary uses both MSVC CRT and45; mingw CRT and is linked with LTO.46define i32 @use_gcc() personality ptr @__gxx_personality_seh0 {47entry:48 invoke void @maybe_throw()49 to label %cont unwind label %lpad50 51cont:52 ret i32 053 54lpad:55 %ehvals = landingpad { ptr, i32 }56 cleanup57 catch ptr @_ZTIi58 %ehsel = extractvalue { ptr, i32 } %ehvals, 159 %filt_g_sel = call i32 @llvm.eh.typeid.for(ptr @filt_g)60 %matches = icmp eq i32 %ehsel, %filt_g_sel61 br i1 %matches, label %ret1, label %eh.resume62 63ret1:64 ret i32 165 66eh.resume:67 resume { ptr, i32 } %ehvals68}69 70; CHECK-LABEL: use_gcc:71; CHECK: callq maybe_throw72; CHECK: xorl %eax, %eax73;74; CHECK: # %lpad75; CHECK: cmpl $2, %edx76; CHECK: jne77;78; CHECK: # %ret179; CHECK: movl $1, %eax80;81; CHECK: callq _Unwind_Resume82