1 ; RUN: opt -S -winehprepare -mtriple=x86_64-pc-windows-msvc < %s | FileCheck %s
2 ; RUN: opt -S -winehprepare -mtriple=x86_64-pc-windows-coreclr < %s | FileCheck %s
4 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
6 @str.__except = internal unnamed_addr constant [9 x i8] c"__except\00", align 1
8 ; Function Attrs: uwtable
10 declare i32 @puts(i8*)
12 define void @may_crash() {
14 store volatile i32 42, i32* null, align 4
18 declare i32 @__C_specific_handler(...)
20 ; Function Attrs: nounwind readnone
21 declare i8* @llvm.frameaddress(i32)
23 ; Function Attrs: uwtable
24 define void @seh_catch_all() personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) {
26 %exn.slot = alloca i8*
27 %ehselector.slot = alloca i32
28 invoke void @may_crash()
29 to label %invoke.cont unwind label %lpad
31 invoke.cont: ; preds = %entry
34 lpad: ; preds = %entry
35 %0 = landingpad { i8*, i32 }
37 %1 = extractvalue { i8*, i32 } %0, 0
38 store i8* %1, i8** %exn.slot
39 %2 = extractvalue { i8*, i32 } %0, 1
40 store i32 %2, i32* %ehselector.slot
43 __except: ; preds = %lpad
44 %call = call i32 @puts(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str.__except, i32 0, i32 0))
47 __try.cont: ; preds = %__except, %invoke.cont
51 ; CHECK-LABEL: define void @seh_catch_all()
53 ; CHECK-NEXT: catch i8* null
54 ; CHECK-NEXT: call i8* (...) @llvm.eh.actions(i32 1, i8* null, i32 -1, i8* blockaddress(@seh_catch_all, %lpad.split))
55 ; CHECK-NEXT: indirectbr
58 ; CHECK-NOT: extractvalue
59 ; CHECK: call i32 @puts