1 ; RUN: opt -S -winehprepare -sehprepare < %s | FileCheck %s
3 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-pc-windows-msvc"
6 declare void @might_crash(i8* %ehptr)
8 declare void @cleanup()
9 declare i32 @__C_specific_handler(...)
10 declare i32 @llvm.eh.typeid.for(i8*)
12 define void @resume_phi() {
14 invoke void @might_crash(i8* null)
15 to label %return unwind label %lpad1
18 %ehvals1 = landingpad { i8*, i32 } personality i32 (...)* @__C_specific_handler
20 %ehptr1 = extractvalue { i8*, i32 } %ehvals1, 0
21 %ehsel1 = extractvalue { i8*, i32 } %ehvals1, 1
22 %filt_sel = tail call i32 @llvm.eh.typeid.for(i8* bitcast (i32 ()* @filt to i8*))
23 %matches = icmp eq i32 %ehsel1, %filt_sel
24 br i1 %matches, label %__except, label %eh.resume
27 invoke void @might_crash(i8* %ehptr1)
28 to label %return unwind label %lpad2
31 %ehvals2 = landingpad { i8*, i32 } personality i32 (...)* @__C_specific_handler
33 %ehptr2 = extractvalue { i8*, i32 } %ehvals2, 0
34 %ehsel2 = extractvalue { i8*, i32 } %ehvals2, 1
42 %ehptr.phi = phi i8* [ %ehptr1, %lpad1 ], [ %ehptr2, %lpad2 ]
43 %ehsel.phi = phi i32 [ %ehsel1, %lpad1 ], [ %ehsel2, %lpad2 ]
44 %ehval.phi1 = insertvalue { i8*, i32 } undef, i8* %ehptr.phi, 0
45 %ehval.phi2 = insertvalue { i8*, i32 } %ehval.phi1, i32 %ehsel.phi, 1
46 resume { i8*, i32 } %ehval.phi2
49 ; CHECK-LABEL: define void @resume_phi()
50 ; CHECK: invoke void @might_crash(i8* null)
51 ; CHECK: landingpad { i8*, i32 }
52 ; CHECK-NEXT: catch i32 ()* @filt
53 ; CHECK-NEXT: call i8* (...) @llvm.eh.actions(
54 ; CHECK-SAME: i32 1, i8* bitcast (i32 ()* @filt to i8*), i32 -1, i8* blockaddress(@resume_phi, %__except))
55 ; CHECK-NEXT: indirectbr {{.*}} [label %__except]
58 ; FIXME: This should not be undef, it should be the new landingpad value, which
59 ; should ultimately lower down to eax.
60 ; CHECK: invoke void @might_crash(i8* undef)
61 ; CHECK: landingpad { i8*, i32 }
63 ; CHECK-NEXT: call i8* (...) @llvm.eh.actions(i32 0, void (i8*, i8*)* @resume_phi.cleanup)
64 ; CHECK-NEXT: indirectbr {{.*}} []
66 ; CHECK-LABEL: define internal void @resume_phi.cleanup(i8*, i8*)
67 ; CHECK: call void @cleanup()