• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -lint -disable-output < %s
2
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.
5
6target triple = "x86_64-pc-windows-msvc"
7
8declare void @llvm.eh.begincatch(i8*, i8*)
9
10declare void @llvm.eh.endcatch()
11
12@_ZTIi = external constant i8*
13
14; Function Attrs: uwtable
15define void @test_ref_clean() personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
16entry:
17  invoke void @_Z9may_throwv()
18          to label %try.cont unwind label %lpad
19
20lpad:                                             ; 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
28
29catch:                                            ; preds = %lpad
30  call void @llvm.eh.begincatch(i8* %exn, i8* null)
31  call void @_Z10handle_intv()
32  br label %invoke.cont2
33
34invoke.cont2:                                     ; preds = %catch
35  call void @llvm.eh.endcatch()
36  br label %try.cont
37
38try.cont:                                         ; preds = %invoke.cont2, %entry
39  ret void
40
41eh.resume:                                        ; preds = %catch.dispatch
42  resume { i8*, i32 } %0
43}
44
45; Function Attrs: uwtable
46define void @test_ref_clean_multibranch() personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
47entry:
48  invoke void @_Z9may_throwv()
49          to label %invoke.cont unwind label %lpad
50
51invoke.cont:
52  invoke void @_Z9may_throwv()
53          to label %invoke.cont unwind label %lpad1
54
55lpad:                                             ; 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
63
64  invoke void @_Z9may_throwv()
65          to label %try.cont unwind label %lpad
66
67lpad1:                                            ; preds = %entry
68  %l1.0 = landingpad { i8*, i32 }
69		  cleanup
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
76
77catch:                                            ; 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
84
85invoke.cont2:                                     ; preds = %catch
86  call void @llvm.eh.endcatch()
87  br label %try.cont
88
89invoke.cont3:                                     ; preds = %catch
90  call void @llvm.eh.endcatch()
91  br label %eh.resume
92
93try.cont:                                         ; preds = %invoke.cont2, %entry
94  ret void
95
96eh.resume:                                        ; preds = %catch.dispatch
97  %lpad.val = insertvalue { i8*, i32 } undef, i32 0, 1
98  resume { i8*, i32 } %lpad.val
99}
100
101declare void @_Z9may_throwv()
102
103declare i32 @__CxxFrameHandler3(...)
104
105; Function Attrs: nounwind readnone
106declare i32 @llvm.eh.typeid.for(i8*)
107
108declare void @_Z10handle_intv()
109
110