[pypy-svn] r7394 - pypy/trunk/src/pypy/translator
arigo at codespeak.net
arigo at codespeak.net
Thu Nov 18 18:01:59 CET 2004
Author: arigo
Date: Thu Nov 18 18:01:58 2004
New Revision: 7394
Modified:
pypy/trunk/src/pypy/translator/annrpython.py
pypy/trunk/src/pypy/translator/transform.py
Log:
Fix for removing dead code. Actually we need to remove dead links, and not
just links going to dead blocks, because the blocks in question could be
reachable from somewhere else too.
Modified: pypy/trunk/src/pypy/translator/annrpython.py
==============================================================================
--- pypy/trunk/src/pypy/translator/annrpython.py (original)
+++ pypy/trunk/src/pypy/translator/annrpython.py Thu Nov 18 18:01:58 2004
@@ -23,6 +23,7 @@
self.pendingblocks = [] # list of (fn, block, list-of-SomeValues-args)
self.bindings = {} # map Variables to SomeValues
self.annotated = {} # set of blocks already seen
+ self.links_followed = {} # set of links that have ever been followed
self.why_not_annotated = {} # {block: (exc_type, exc_value, traceback)}
# records the location of BlockedInference
# exceptions that blocked some blocks.
@@ -317,6 +318,7 @@
knownvar, knownvarvalue = getattr(self.bindings.get(block.exitswitch),
"knowntypedata", (None, None))
for link in exits:
+ self.links_followed[link] = True
cells = []
for a in link.args:
if link.exitcase is True and a is knownvar \
Modified: pypy/trunk/src/pypy/translator/transform.py
==============================================================================
--- pypy/trunk/src/pypy/translator/transform.py (original)
+++ pypy/trunk/src/pypy/translator/transform.py Thu Nov 18 18:01:58 2004
@@ -306,7 +306,7 @@
them."""
for block in self.annotated:
for link in block.exits:
- if link.target not in self.annotated:
+ if link not in self.links_followed:
lst = list(block.exits)
lst.remove(link)
block.exits = tuple(lst)
More information about the Pypy-commit
mailing list