1; RUN: opt -S -winehprepare -dwarfehprepare -mtriple x86_64-pc-windows-msvc < %s | FileCheck %s 2 3; FIXME: Add and test outlining here. 4 5declare void @maybe_throw() 6 7@_ZTIi = external constant i8* 8@g = external global i32 9 10declare i32 @__C_specific_handler(...) 11declare i32 @__gxx_personality_seh0(...) 12declare i32 @llvm.eh.typeid.for(i8*) readnone nounwind 13 14define i32 @use_seh() { 15entry: 16 invoke void @maybe_throw() 17 to label %cont unwind label %lpad 18 19cont: 20 ret i32 0 21 22lpad: 23 %ehvals = landingpad { i8*, i32 } personality i32 (...)* @__C_specific_handler 24 cleanup 25 catch i8* bitcast (i32 (i8*, i8*)* @filt_g to i8*) 26 %ehsel = extractvalue { i8*, i32 } %ehvals, 1 27 %filt_g_sel = call i32 @llvm.eh.typeid.for(i8* bitcast (i32 (i8*, i8*)* @filt_g to i8*)) 28 %matches = icmp eq i32 %ehsel, %filt_g_sel 29 br i1 %matches, label %ret1, label %eh.resume 30 31ret1: 32 ret i32 1 33 34eh.resume: 35 resume { i8*, i32 } %ehvals 36} 37 38define internal i32 @filt_g(i8*, i8*) { 39 %g = load i32, i32* @g 40 ret i32 %g 41} 42 43; CHECK-LABEL: define i32 @use_seh() 44; CHECK: invoke void @maybe_throw() 45; CHECK-NEXT: to label %cont unwind label %lpad 46; CHECK: eh.resume: 47; CHECK-NEXT: unreachable 48 49 50; A MinGW64-ish EH style. It could happen if a binary uses both MSVC CRT and 51; mingw CRT and is linked with LTO. 52define i32 @use_gcc() { 53entry: 54 invoke void @maybe_throw() 55 to label %cont unwind label %lpad 56 57cont: 58 ret i32 0 59 60lpad: 61 %ehvals = landingpad { i8*, i32 } personality i32 (...)* @__gxx_personality_seh0 62 cleanup 63 catch i8* bitcast (i8** @_ZTIi to i8*) 64 %ehsel = extractvalue { i8*, i32 } %ehvals, 1 65 %filt_g_sel = call i32 @llvm.eh.typeid.for(i8* bitcast (i32 (i8*, i8*)* @filt_g to i8*)) 66 %matches = icmp eq i32 %ehsel, %filt_g_sel 67 br i1 %matches, label %ret1, label %eh.resume 68 69ret1: 70 ret i32 1 71 72eh.resume: 73 resume { i8*, i32 } %ehvals 74} 75 76; CHECK-LABEL: define i32 @use_gcc() 77; CHECK: invoke void @maybe_throw() 78; CHECK-NEXT: to label %cont unwind label %lpad 79; CHECK: eh.resume: 80; CHECK: call void @_Unwind_Resume(i8* %exn.obj) 81