aboutsummaryrefslogtreecommitdiff
path: root/llvm/test/Transforms/SimplifyCFG/wineh-unreachable.ll
blob: 8b261910d682a66d58f34db3c40d9419f020b9dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals
; RUN: opt -S -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 < %s | FileCheck %s

declare void @Personality()
declare void @f()

define void @test1() personality ptr @Personality {
; CHECK-LABEL: @test1(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    call void @f() #[[ATTR0:[0-9]+]]
; CHECK-NEXT:    ret void
;
entry:
  invoke void @f()
  to label %exit unwind label %unreachable.unwind
exit:
  ret void
unreachable.unwind:
  cleanuppad within none []
  unreachable
}

define void @test2() personality ptr @Personality {
; CHECK-LABEL: @test2(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    invoke void @f()
; CHECK-NEXT:            to label [[EXIT:%.*]] unwind label [[CATCH_PAD:%.*]]
; CHECK:       catch.pad:
; CHECK-NEXT:    [[CS1:%.*]] = catchswitch within none [label %catch.body] unwind to caller
; CHECK:       catch.body:
; CHECK-NEXT:    [[CATCH:%.*]] = catchpad within [[CS1]] []
; CHECK-NEXT:    call void @f()
; CHECK-NEXT:    catchret from [[CATCH]] to label [[UNREACHABLE:%.*]]
; CHECK:       exit:
; CHECK-NEXT:    ret void
; CHECK:       unreachable:
; CHECK-NEXT:    unreachable
;
entry:
  invoke void @f()
  to label %exit unwind label %catch.pad
catch.pad:
  %cs1 = catchswitch within none [label %catch.body] unwind label %unreachable.unwind
catch.body:
  %catch = catchpad within %cs1 []
  call void @f()
  catchret from %catch to label %unreachable
exit:
  ret void
unreachable.unwind:
  cleanuppad within none []
  unreachable
unreachable:
  unreachable
}

define void @test3() personality ptr @Personality {
; CHECK-LABEL: @test3(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    invoke void @f()
; CHECK-NEXT:            to label [[EXIT:%.*]] unwind label [[CLEANUP_PAD:%.*]]
; CHECK:       cleanup.pad:
; CHECK-NEXT:    [[CLEANUP:%.*]] = cleanuppad within none []
; CHECK-NEXT:    call void @f() #[[ATTR0]]
; CHECK-NEXT:    unreachable
; CHECK:       exit:
; CHECK-NEXT:    ret void
;
entry:
  invoke void @f()
  to label %exit unwind label %cleanup.pad
cleanup.pad:
  %cleanup = cleanuppad within none []
  invoke void @f()
  to label %cleanup.ret unwind label %unreachable.unwind
cleanup.ret:
  ; This cleanupret should be rewritten to unreachable,
  ; and merged into the pred block.
  cleanupret from %cleanup unwind label %unreachable.unwind
exit:
  ret void
unreachable.unwind:
  cleanuppad within none []
  unreachable
}

define void @test5() personality ptr @Personality {
; CHECK-LABEL: @test5(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    invoke void @f()
; CHECK-NEXT:            to label [[EXIT:%.*]] unwind label [[CATCH_PAD:%.*]]
; CHECK:       catch.pad:
; CHECK-NEXT:    [[CS1:%.*]] = catchswitch within none [label %catch.body] unwind to caller
; CHECK:       catch.body:
; CHECK-NEXT:    [[CATCH:%.*]] = catchpad within [[CS1]] []
; CHECK-NEXT:    catchret from [[CATCH]] to label [[EXIT]]
; CHECK:       exit:
; CHECK-NEXT:    unreachable
;
entry:
  invoke void @f()
  to label %exit unwind label %catch.pad

catch.pad:
  %cs1 = catchswitch within none [label %catch.body] unwind to caller

catch.body:
  %catch = catchpad within %cs1 []
  catchret from %catch to label %exit

exit:
  unreachable
}

define void @test6() personality ptr @Personality {
; CHECK-LABEL: @test6(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    invoke void @f()
; CHECK-NEXT:            to label [[EXIT:%.*]] unwind label [[CATCH_PAD:%.*]]
; CHECK:       catch.pad:
; CHECK-NEXT:    [[CS1:%.*]] = catchswitch within none [label %catch.body] unwind to caller
; CHECK:       catch.body:
; CHECK-NEXT:    [[CATCH:%.*]] = catchpad within [[CS1]] [ptr null, i32 0, ptr null]
; CHECK-NEXT:    catchret from [[CATCH]] to label [[EXIT]]
; CHECK:       exit:
; CHECK-NEXT:    ret void
;
entry:
  invoke void @f()
  to label %exit unwind label %catch.pad

catch.pad:
  %cs1 = catchswitch within none [label %catch.body, label %catch.body] unwind to caller

catch.body:
  %catch = catchpad within %cs1 [ptr null, i32 0, ptr null]
  catchret from %catch to label %exit

exit:
  ret void
}

define void @test7() personality ptr @Personality {
; CHECK-LABEL: @test7(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    invoke void @f()
; CHECK-NEXT:            to label [[EXIT:%.*]] unwind label [[CATCH_PAD:%.*]]
; CHECK:       catch.pad:
; CHECK-NEXT:    [[CS1:%.*]] = catchswitch within none [label %catch.body] unwind to caller
; CHECK:       catch.body:
; CHECK-NEXT:    [[CATCH:%.*]] = catchpad within [[CS1]] [ptr null, i32 0, ptr null]
; CHECK-NEXT:    catchret from [[CATCH]] to label [[EXIT]]
; CHECK:       exit:
; CHECK-NEXT:    ret void
;
entry:
  invoke void @f()
  to label %exit unwind label %catch.pad

catch.pad:
  %cs1 = catchswitch within none [label %catch.body, label %catch.body2] unwind to caller

catch.body:
  %catch = catchpad within %cs1 [ptr null, i32 0, ptr null]
  catchret from %catch to label %exit

catch.body2:
  %catch2 = catchpad within %cs1 [ptr null, i32 0, ptr null]
  catchret from %catch2 to label %exit

exit:
  ret void
}

define void @test8() personality ptr @Personality {
; CHECK-LABEL: @test8(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    invoke void @f()
; CHECK-NEXT:            to label [[EXIT:%.*]] unwind label [[CATCH_PAD:%.*]]
; CHECK:       catch.pad:
; CHECK-NEXT:    [[CS1:%.*]] = catchswitch within none [label %catch.body] unwind to caller
; CHECK:       catch.body:
; CHECK-NEXT:    [[CATCH:%.*]] = catchpad within [[CS1]] [ptr null, i32 0, ptr null]
; CHECK-NEXT:    catchret from [[CATCH]] to label [[EXIT]]
; CHECK:       exit:
; CHECK-NEXT:    ret void
;
entry:
  invoke void @f()
  to label %exit unwind label %catch.pad

catch.pad:
  %cs1 = catchswitch within none [label %catch.body, label %catch.body2] unwind to caller

catch.body2:
  %catch2 = catchpad within %cs1 [ptr null, i32 0, ptr null]
  catchret from %catch2 to label %exit

catch.body:
  %catch = catchpad within %cs1 [ptr null, i32 0, ptr null]
  catchret from %catch to label %exit

exit:
  ret void
}

define void @test9() personality ptr @Personality {
; CHECK-LABEL: @test9(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    invoke void @f()
; CHECK-NEXT:            to label [[EXIT:%.*]] unwind label [[CATCH_PAD:%.*]]
; CHECK:       catch.pad:
; CHECK-NEXT:    [[CS1:%.*]] = catchswitch within none [label [[CATCH_BODY:%.*]], label %catch.body2] unwind to caller
; CHECK:       catch.body:
; CHECK-NEXT:    [[CATCH:%.*]] = catchpad within [[CS1]] [ptr null, i32 0, ptr null]
; CHECK-NEXT:    catchret from [[CATCH]] to label [[EXIT]]
; CHECK:       catch.body2:
; CHECK-NEXT:    [[CATCH2:%.*]] = catchpad within [[CS1]] [ptr null, i32 64, ptr null]
; CHECK-NEXT:    catchret from [[CATCH2]] to label [[EXIT]]
; CHECK:       exit:
; CHECK-NEXT:    ret void
;
entry:
  invoke void @f()
  to label %exit unwind label %catch.pad

catch.pad:
  %cs1 = catchswitch within none [label %catch.body, label %catch.body2] unwind to caller

catch.body:
  %catch = catchpad within %cs1 [ptr null, i32 0, ptr null]
  catchret from %catch to label %exit

catch.body2:
  %catch2 = catchpad within %cs1 [ptr null, i32 64, ptr null]
  catchret from %catch2 to label %exit

exit:
  ret void
}
;.
; CHECK: attributes #[[ATTR0]] = { nounwind }
;.