[WinEH] Verify unwind edges against EH pad tree
[oota-llvm.git] / test / Feature / exception.ll
1 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
2 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
3 ; RUN: diff %t1.ll %t2.ll
4
5 @_ZTIc = external constant i8*
6 @_ZTId = external constant i8*
7 @_ZTIPKc = external constant i8*
8
9 define void @_Z3barv() uwtable optsize ssp personality i32 (...)* @__gxx_personality_v0 {
10 entry:
11   invoke void @_Z3quxv() optsize
12           to label %try.cont unwind label %lpad
13
14 try.cont:                                         ; preds = %entry, %invoke.cont4
15   ret void
16
17 lpad:                                             ; preds = %entry
18   %exn = landingpad {i8*, i32}
19             cleanup
20             catch i8** @_ZTIc
21             filter [2 x i8**] [i8** @_ZTIPKc, i8** @_ZTId]
22   resume { i8*, i32 } %exn
23 }
24
25 declare void @_Z3quxv() optsize
26
27 declare i32 @__gxx_personality_v0(...)
28
29 define void @cleanupret0() personality i32 (...)* @__gxx_personality_v0 {
30 entry:
31   invoke void @_Z3quxv() optsize
32           to label %exit unwind label %pad
33 pad:
34   %cp = cleanuppad within none [i7 4]
35   cleanupret from %cp unwind to caller
36 exit:
37   ret void
38 }
39
40 ; forward ref by name
41 define void @cleanupret1() personality i32 (...)* @__gxx_personality_v0 {
42 entry:
43   invoke void @_Z3quxv() optsize
44           to label %exit unwind label %pad
45 cleanup:
46   cleanupret from %cp unwind to caller
47 pad:
48   %cp = cleanuppad within none []
49   br label %cleanup
50 exit:
51   ret void
52 }
53
54 ; forward ref by ID
55 define void @cleanupret2() personality i32 (...)* @__gxx_personality_v0 {
56 entry:
57   invoke void @_Z3quxv() optsize
58           to label %exit unwind label %pad
59 cleanup:
60   cleanupret from %0 unwind to caller
61 pad:
62   %0 = cleanuppad within none []
63   br label %cleanup
64 exit:
65   ret void
66 }
67
68 define void @catchret0() personality i32 (...)* @__gxx_personality_v0 {
69 entry:
70   invoke void @_Z3quxv() optsize
71           to label %exit unwind label %pad
72 pad:
73   %cs1 = catchswitch within none [label %catch] unwind to caller
74 catch:
75   %cp = catchpad within %cs1 [i7 4]
76   catchret from %cp to label %exit
77 exit:
78   ret void
79 }
80
81 ; forward ref by name
82 define void @catchret1() personality i32 (...)* @__gxx_personality_v0 {
83 entry:
84   invoke void @_Z3quxv() optsize
85           to label %exit unwind label %pad
86 catchret:
87   catchret from %cp to label %exit
88 pad:
89   %cs1 = catchswitch within none [label %catch] unwind to caller
90 catch:
91   %cp = catchpad within %cs1 [i7 4]
92   br label %catchret
93 exit:
94   ret void
95 }
96
97 ; forward ref by ID
98 define void @catchret2() personality i32 (...)* @__gxx_personality_v0 {
99 entry:
100   invoke void @_Z3quxv() optsize
101           to label %exit unwind label %pad
102 catchret:
103   catchret from %0 to label %exit
104 pad:
105   %cs1 = catchswitch within none [label %catch] unwind to caller
106 catch:
107   %0 = catchpad within %cs1 [i7 4]
108   br label %catchret
109 exit:
110   ret void
111 }
112
113 define i8 @catchpad() personality i32 (...)* @__gxx_personality_v0 {
114 entry:
115   invoke void @_Z3quxv() optsize
116           to label %exit unwind label %bb2
117 bb2:
118   %cs1 = catchswitch within none [label %catch] unwind to caller
119 catch:
120   catchpad within %cs1 [i7 4]
121   br label %exit
122 exit:
123   ret i8 0
124 }
125
126 define void @cleanuppad() personality i32 (...)* @__gxx_personality_v0 {
127 entry:
128   br label %try.cont
129
130 try.cont:
131   invoke void @_Z3quxv() optsize
132           to label %try.cont unwind label %bb
133 bb:
134   cleanuppad within none [i7 4]
135   ret void
136 }