1 ; RUN: opt -lint -disable-output < %s
3 ; This test is meant to prove that the verifier does not report errors for correct
4 ; use of the llvm.eh.begincatch and llvm.eh.endcatch intrinsics.
6 target triple = "x86_64-pc-windows-msvc"
8 declare void @llvm.eh.begincatch(i8*, i8*)
10 declare void @llvm.eh.endcatch()
12 @_ZTIi = external constant i8*
14 ; Function Attrs: uwtable
15 define void @test_ref_clean() personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
17 invoke void @_Z9may_throwv()
18 to label %try.cont unwind label %lpad
20 lpad: ; preds = %entry
21 %0 = landingpad { i8*, i32 }
22 catch i8* bitcast (i8** @_ZTIi to i8*)
23 %exn = extractvalue { i8*, i32 } %0, 0
24 %sel = extractvalue { i8*, i32 } %0, 1
25 %1 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*))
26 %matches = icmp eq i32 %sel, %1
27 br i1 %matches, label %catch, label %eh.resume
29 catch: ; preds = %lpad
30 call void @llvm.eh.begincatch(i8* %exn, i8* null)
31 call void @_Z10handle_intv()
32 br label %invoke.cont2
34 invoke.cont2: ; preds = %catch
35 call void @llvm.eh.endcatch()
38 try.cont: ; preds = %invoke.cont2, %entry
41 eh.resume: ; preds = %catch.dispatch
42 resume { i8*, i32 } %0
45 ; Function Attrs: uwtable
46 define void @test_ref_clean_multibranch() personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
48 invoke void @_Z9may_throwv()
49 to label %invoke.cont unwind label %lpad
52 invoke void @_Z9may_throwv()
53 to label %invoke.cont unwind label %lpad1
55 lpad: ; preds = %entry
56 %0 = landingpad { i8*, i32 }
57 catch i8* bitcast (i8** @_ZTIi to i8*)
58 %exn = extractvalue { i8*, i32 } %0, 0
59 %sel = extractvalue { i8*, i32 } %0, 1
60 %1 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*))
61 %matches = icmp eq i32 %sel, %1
62 br i1 %matches, label %catch, label %eh.resume
64 invoke void @_Z9may_throwv()
65 to label %try.cont unwind label %lpad
67 lpad1: ; preds = %entry
68 %l1.0 = landingpad { i8*, i32 }
70 catch i8* bitcast (i8** @_ZTIi to i8*)
71 %exn1 = extractvalue { i8*, i32 } %l1.0, 0
72 %sel1 = extractvalue { i8*, i32 } %l1.0, 1
73 %l1.1 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*))
74 %matchesl1 = icmp eq i32 %sel1, %l1.1
75 br i1 %matchesl1, label %catch, label %eh.resume
77 catch: ; preds = %lpad, %lpad1
78 %exn2 = phi i8* [%exn, %lpad], [%exn1, %lpad1]
79 %sel2 = phi i32 [%sel, %lpad], [%sel1, %lpad1]
80 call void @llvm.eh.begincatch(i8* %exn2, i8* null)
81 call void @_Z10handle_intv()
82 %matches1 = icmp eq i32 %sel2, 0
83 br i1 %matches1, label %invoke.cont2, label %invoke.cont3
85 invoke.cont2: ; preds = %catch
86 call void @llvm.eh.endcatch()
89 invoke.cont3: ; preds = %catch
90 call void @llvm.eh.endcatch()
93 try.cont: ; preds = %invoke.cont2, %entry
96 eh.resume: ; preds = %catch.dispatch
97 %lpad.val = insertvalue { i8*, i32 } undef, i32 0, 1
98 resume { i8*, i32 } %lpad.val
101 declare void @_Z9may_throwv()
103 declare i32 @__CxxFrameHandler3(...)
105 ; Function Attrs: nounwind readnone
106 declare i32 @llvm.eh.typeid.for(i8*)
108 declare void @_Z10handle_intv()