-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Expand file tree
/
Copy pathirbuild-unreachable.test
More file actions
238 lines (224 loc) · 3.91 KB
/
irbuild-unreachable.test
File metadata and controls
238 lines (224 loc) · 3.91 KB
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
# Test cases for unreachable expressions and statements
[case testUnreachableMemberExpr]
import sys
def f() -> None:
y = sys.platform == "x" and sys.version_info > (3, 5)
[out]
def f():
r0 :: object
r1 :: str
r2 :: object
r3, r4 :: str
r5, r6, r7 :: bool
r8 :: object
r9, y :: bool
L0:
r0 = sys :: module
r1 = 'platform'
r2 = CPyObject_GetAttr(r0, r1)
r3 = cast(str, r2)
r4 = 'x'
r5 = CPyStr_EqualLiteral(r3, r4, 1)
if r5 goto L2 else goto L1 :: bool
L1:
r6 = r5
goto L3
L2:
r7 = raise RuntimeError('mypyc internal error: should be unreachable')
r8 = box(None, 1)
r9 = unbox(bool, r8)
r6 = r9
L3:
y = r6
return 1
[case testUnreachableNameExpr]
import sys
def f() -> None:
y = sys.platform == 'x' and foobar
[out]
def f():
r0 :: object
r1 :: str
r2 :: object
r3, r4 :: str
r5, r6, r7 :: bool
r8 :: object
r9, y :: bool
L0:
r0 = sys :: module
r1 = 'platform'
r2 = CPyObject_GetAttr(r0, r1)
r3 = cast(str, r2)
r4 = 'x'
r5 = CPyStr_EqualLiteral(r3, r4, 1)
if r5 goto L2 else goto L1 :: bool
L1:
r6 = r5
goto L3
L2:
r7 = raise RuntimeError('mypyc internal error: should be unreachable')
r8 = box(None, 1)
r9 = unbox(bool, r8)
r6 = r9
L3:
y = r6
return 1
[case testUnreachableFinalNameExpr]
from typing import Final
ZERO: Final = 0
def f(x: int) -> int:
if x is None:
return ZERO
return ZERO
[out]
def f(x):
x :: int
r0, r1 :: object
r2 :: bit
r3 :: object
r4 :: int
L0:
r0 = load_address _Py_NoneStruct
r1 = box(int, x)
r2 = r1 == r0
if r2 goto L1 else goto L2 :: bool
L1:
r3 = object 0
r4 = unbox(int, r3)
return r4
L2:
return 0
[case testUnreachableStatementAfterReturn]
def f(x: bool) -> int:
if x:
return 1
f(False)
return 2
[out]
def f(x):
x :: bool
L0:
if x goto L1 else goto L2 :: bool
L1:
return 2
L2:
return 4
[case testUnreachableStatementAfterContinue]
def c() -> bool:
return False
def f() -> None:
n = True
while n:
if c():
continue
if int():
f()
n = False
[out]
def c():
L0:
return 0
def f():
n, r0 :: bool
L0:
n = 1
L1:
if n goto L2 else goto L5 :: bool
L2:
r0 = c()
if r0 goto L3 else goto L4 :: bool
L3:
goto L1
L4:
n = 0
goto L1
L5:
return 1
[case testUnreachableStatementAfterBreak]
def c() -> bool:
return False
def f() -> None:
n = True
while n:
if c():
break
if int():
f()
n = False
[out]
def c():
L0:
return 0
def f():
n, r0 :: bool
L0:
n = 1
L1:
if n goto L2 else goto L5 :: bool
L2:
r0 = c()
if r0 goto L3 else goto L4 :: bool
L3:
goto L5
L4:
n = 0
goto L1
L5:
return 1
[case testUnreachableStatementAfterRaise]
def f(x: bool) -> int:
if x:
raise ValueError()
print('hello')
return 2
[out]
def f(x):
x :: bool
r0 :: object
r1 :: str
r2, r3 :: object
L0:
if x goto L1 else goto L2 :: bool
L1:
r0 = builtins :: module
r1 = 'ValueError'
r2 = CPyObject_GetAttr(r0, r1)
r3 = PyObject_Vectorcall(r2, 0, 0, 0)
CPy_Raise(r3)
unreachable
L2:
return 4
[case testUnreachableStatementAfterAssertFalse]
def f(x: bool) -> int:
if x:
assert False
print('hello')
return 2
[out]
def f(x):
x, r0 :: bool
r1 :: str
r2 :: object
r3 :: str
r4 :: object
r5 :: object[1]
r6 :: object_ptr
r7 :: object
L0:
if x goto L1 else goto L4 :: bool
L1:
if 0 goto L3 else goto L2 :: bool
L2:
r0 = raise AssertionError
unreachable
L3:
r1 = 'hello'
r2 = builtins :: module
r3 = 'print'
r4 = CPyObject_GetAttr(r2, r3)
r5 = [r1]
r6 = load_address r5
r7 = PyObject_Vectorcall(r4, r6, 1, 0)
keep_alive r1
L4:
return 4