1 ; RUN: opt -S -winehprepare -dwarfehprepare -mtriple x86_64-pc-windows-msvc < %s | FileCheck %s
3 ; FIXME: Add and test outlining here.
5 declare void @maybe_throw()
7 @_ZTIi = external constant i8*
8 @g = external global i32
10 declare i32 @__C_specific_handler(...)
11 declare i32 @__gxx_personality_seh0(...)
12 declare i32 @llvm.eh.typeid.for(i8*) readnone nounwind
14 define i32 @use_seh() personality i32 (...)* @__C_specific_handler {
16 invoke void @maybe_throw()
17 to label %cont unwind label %lpad
23 %ehvals = landingpad { i8*, i32 }
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
35 resume { i8*, i32 } %ehvals
38 define internal i32 @filt_g(i8*, i8*) {
39 %g = load i32, i32* @g
43 ; CHECK-LABEL: define i32 @use_seh()
44 ; CHECK: invoke void @maybe_throw()
45 ; CHECK-NEXT: to label %cont unwind label %lpad
49 ; CHECK-NEXT: call i8* (...) @llvm.eh.actions({{.*}})
52 ; A MinGW64-ish EH style. It could happen if a binary uses both MSVC CRT and
53 ; mingw CRT and is linked with LTO.
54 define i32 @use_gcc() personality i32 (...)* @__gxx_personality_seh0 {
56 invoke void @maybe_throw()
57 to label %cont unwind label %lpad
63 %ehvals = landingpad { i8*, i32 }
65 catch i8* bitcast (i8** @_ZTIi to i8*)
66 %ehsel = extractvalue { i8*, i32 } %ehvals, 1
67 %filt_g_sel = call i32 @llvm.eh.typeid.for(i8* bitcast (i32 (i8*, i8*)* @filt_g to i8*))
68 %matches = icmp eq i32 %ehsel, %filt_g_sel
69 br i1 %matches, label %ret1, label %eh.resume
75 resume { i8*, i32 } %ehvals
78 ; CHECK-LABEL: define i32 @use_gcc()
79 ; CHECK: invoke void @maybe_throw()
80 ; CHECK-NEXT: to label %cont unwind label %lpad
82 ; CHECK: call void @_Unwind_Resume(i8* %exn.obj)