Skip to content

[mypyc] Fix to_lines to show same type registers on the same line #9300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions mypyc/ir/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,18 +243,13 @@ def to_lines(self, const_regs: Optional[Dict[str, int]] = None) -> List[str]:
regs = list(self.regs())
if const_regs is None:
const_regs = {}
regs = [reg for reg in regs if reg.name not in const_regs]
while i < len(regs):
i0 = i
if regs[i0].name not in const_regs:
group = [regs[i0].name]
else:
group = []
i += 1
continue
group = [regs[i0].name]
while i + 1 < len(regs) and regs[i + 1].type == regs[i0].type:
i += 1
if regs[i].name not in const_regs:
group.append(regs[i].name)
group.append(regs[i].name)
i += 1
result.append('%s :: %s' % (', '.join(group), regs[i0].type))
return result
Expand Down
32 changes: 10 additions & 22 deletions mypyc/test-data/analysis.test
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ def f(a: int) -> None:
z = 1
[out]
def f(a):
a :: int
x :: int
a, x :: int
r0 :: bool
r1 :: native_int
r2, r3, r4 :: bool
y :: int
z :: int
y, z :: int
L0:
x = 2
r1 = x & 1
Expand Down Expand Up @@ -69,8 +67,7 @@ def f(a: int) -> int:
return x
[out]
def f(a):
a :: int
x :: int
a, x :: int
r0 :: bool
r1 :: native_int
r2, r3, r4 :: bool
Expand Down Expand Up @@ -121,8 +118,7 @@ def f() -> int:
return x
[out]
def f():
x :: int
y :: int
x, y :: int
L0:
x = 2
y = 2
Expand Down Expand Up @@ -171,8 +167,7 @@ def f(a):
r0 :: bool
r1 :: native_int
r2, r3, r4 :: bool
y :: int
x :: int
y, x :: int
L0:
r1 = a & 1
r2 = r1 == 0
Expand Down Expand Up @@ -304,15 +299,12 @@ def f(n: int) -> None:
n = x
[out]
def f(n):
n :: int
x :: int
y :: int
n, x, y :: int
r0 :: bool
r1 :: native_int
r2 :: bool
r3 :: native_int
r4, r5, r6, r7 :: bool
r8 :: bool
r4, r5, r6, r7, r8 :: bool
r9 :: native_int
r10 :: bool
r11 :: native_int
Expand Down Expand Up @@ -419,8 +411,7 @@ def f(x: int) -> int:
return f(a) + a
[out]
def f(x):
x :: int
r0, a, r1, r2, r3 :: int
x, r0, a, r1, r2, r3 :: int
L0:
r0 = f(2)
if is_error(r0) goto L3 (error at f:2) else goto L1
Expand Down Expand Up @@ -644,16 +635,13 @@ def f(a: int) -> int:
return sum
[out]
def f(a):
a :: int
sum :: int
i :: int
a, sum, i :: int
r0 :: bool
r1 :: native_int
r2 :: bool
r3 :: native_int
r4, r5, r6, r7, r8 :: bool
r9 :: int
r10 :: int
r9, r10 :: int
L0:
sum = 0
i = 0
Expand Down
7 changes: 2 additions & 5 deletions mypyc/test-data/exceptions.test
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,14 @@ def sum(a: List[int], l: int) -> int:
[out]
def sum(a, l):
a :: list
l :: int
sum :: int
i :: int
l, sum, i :: int
r0 :: bool
r1 :: native_int
r2 :: bool
r3 :: native_int
r4, r5, r6, r7 :: bool
r8 :: object
r9, r10 :: int
r11, r12 :: int
r9, r10, r11, r12 :: int
L0:
sum = 0
i = 0
Expand Down
61 changes: 20 additions & 41 deletions mypyc/test-data/irbuild-basic.test
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ def f(x: int) -> None:
return
[out]
def f(x):
x :: int
y :: int
x, y :: int
L0:
y = 2
y = x
Expand All @@ -63,8 +62,7 @@ def f(x: int, y: int) -> int:
return x * (y + 1)
[out]
def f(x, y):
x, y :: int
r0, r1 :: int
x, y, r0, r1 :: int
L0:
r0 = CPyTagged_Add(y, 2)
r1 = CPyTagged_Multiply(x, r0)
Expand Down Expand Up @@ -541,8 +539,7 @@ def f(n):
r2 :: bool
r3 :: native_int
r4, r5, r6, r7, r8 :: bool
r9, r10 :: int
r11, r12, r13 :: int
r9, r10, r11, r12, r13 :: int
L0:
r1 = n & 1
r2 = r1 == 0
Expand Down Expand Up @@ -651,8 +648,7 @@ def f(n: int) -> int:
return -1
[out]
def f(n):
n :: int
r0 :: int
n, r0 :: int
L0:
r0 = CPyTagged_Negate(2)
return r0
Expand Down Expand Up @@ -695,8 +691,7 @@ def f() -> int:
return x
[out]
def f():
x :: int
r0 :: int
x, r0 :: int
L0:
x = 0
r0 = CPyTagged_Add(x, 2)
Expand Down Expand Up @@ -796,8 +791,7 @@ def f(x):
x :: int
r0 :: object
r1 :: str
r2 :: object
r3, r4 :: object
r2, r3, r4 :: object
L0:
r0 = builtins :: module
r1 = unicode_1 :: static ('print')
Expand Down Expand Up @@ -906,14 +900,12 @@ def g(y: object) -> object:
return 3
[out]
def g(y):
y :: object
r0, r1 :: object
y, r0, r1 :: object
r2, a :: list
r3 :: tuple[int, int]
r4 :: object
r5 :: bool
r6 :: object
r7 :: object
r6, r7 :: object
L0:
r0 = box(short_int, 2)
r1 = g(r0)
Expand All @@ -937,8 +929,7 @@ def f(a: A, o: object) -> None:
[out]
def f(a, o):
a :: __main__.A
o :: object
r0 :: object
o, r0 :: object
r1 :: bool
r2 :: int
r3 :: object
Expand Down Expand Up @@ -1122,8 +1113,7 @@ def big_int() -> None:
max_31_bit = 1073741823
[out]
def big_int():
r0, a_62_bit, r1, max_62_bit, r2, b_63_bit, r3, c_63_bit, r4, max_63_bit, r5, d_64_bit, r6, max_32_bit :: int
max_31_bit :: int
r0, a_62_bit, r1, max_62_bit, r2, b_63_bit, r3, c_63_bit, r4, max_63_bit, r5, d_64_bit, r6, max_32_bit, max_31_bit :: int
L0:
r0 = int_1 :: static (4611686018427387902)
a_62_bit = r0
Expand Down Expand Up @@ -1580,8 +1570,7 @@ def f(x: str) -> int: ...
def f():
r0 :: object
r1 :: str
r2 :: object
r3, r4 :: object
r2, r3, r4 :: object
r5 :: str
L0:
r0 = m :: module
Expand Down Expand Up @@ -1805,9 +1794,7 @@ L0:
r0 = (a, b, c)
return r0
def g():
r0 :: str
r1 :: str
r2 :: str
r0, r1, r2 :: str
r3, r4, r5 :: object
r6, r7 :: dict
r8 :: str
Expand Down Expand Up @@ -1835,13 +1822,11 @@ L0:
r14 = unbox(tuple[int, int, int], r13)
return r14
def h():
r0 :: str
r1 :: str
r0, r1 :: str
r2, r3 :: object
r4, r5 :: dict
r6 :: str
r7 :: object
r8 :: object
r7, r8 :: object
r9 :: tuple
r10 :: dict
r11 :: int32
Expand Down Expand Up @@ -1874,8 +1859,7 @@ def g() -> None:
[out]
def f(x, y, z):
x, y :: int
z :: str
r0 :: str
z, r0 :: str
L0:
if is_error(y) goto L1 else goto L2
L1:
Expand Down Expand Up @@ -1914,8 +1898,7 @@ def g() -> None:
def A.f(self, x, y, z):
self :: __main__.A
x, y :: int
z :: str
r0 :: str
z, r0 :: str
L0:
if is_error(y) goto L1 else goto L2
L1:
Expand Down Expand Up @@ -1963,8 +1946,7 @@ def f():
x, r11 :: int
r12 :: bool
r13 :: native_int
r14, r15, r16, r17 :: bool
r18 :: bool
r14, r15, r16, r17, r18 :: bool
r19 :: native_int
r20, r21, r22, r23 :: bool
r24 :: int
Expand Down Expand Up @@ -2048,8 +2030,7 @@ def f():
x, r11 :: int
r12 :: bool
r13 :: native_int
r14, r15, r16, r17 :: bool
r18 :: bool
r14, r15, r16, r17, r18 :: bool
r19 :: native_int
r20, r21, r22, r23 :: bool
r24 :: int
Expand Down Expand Up @@ -2310,8 +2291,7 @@ L0:
return r1
def BaseProperty.next(self):
self :: __main__.BaseProperty
r0 :: int
r1 :: int
r0, r1 :: int
r2 :: __main__.BaseProperty
L0:
r0 = self._incrementer
Expand Down Expand Up @@ -3354,8 +3334,7 @@ def f(a: bool) -> int:
[out]
def C.__mypyc_defaults_setup(__mypyc_self__):
__mypyc_self__ :: __main__.C
r0 :: bool
r1 :: bool
r0, r1 :: bool
L0:
__mypyc_self__.x = 2; r0 = is_error
__mypyc_self__.y = 4; r1 = is_error
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy