Skip to content
Snippets Groups Projects
Commit 4594d41f authored by Taddeus Kroes's avatar Taddeus Kroes
Browse files

Added debug option to dead code elimination.

parent 555624cb
No related branches found
No related tags found
No related merge requests found
......@@ -217,8 +217,6 @@ def fold_constants(block):
rd, rs, rt = s
rs_known = rs in register
rt_known = rt in register
print 'rs:', rs, type(rs)
print 'rt:', rt, type(rt)
if (rs_known or isinstance(rs, int)) and \
(rt_known or isinstance(rt, int)):
......@@ -399,14 +397,19 @@ def eliminate_dead_code(block):
for reg in s.get_def():
if reg in unused:
# Statement is redefined later, so this statement is useless
s.remove = True
#print 'reg %s is in %s, remove:' % (reg, unused), \
# block.pointer - 1, s
if block.debug:
s.stype = 'comment'
s.options['block'] = False
s.name = ' Dead code: %s %s' \
% (s.name, ', '.join(map(str, s)))
else:
s.remove = True
else:
unused.add(reg)
unused -= set(s.get_use())
block.apply_filter(lambda s: not hasattr(s, 'remove'))
if not block.debug:
block.apply_filter(lambda s: not hasattr(s, 'remove'))
return changed
......@@ -25,7 +25,7 @@ def write_statements(statements):
indent_level = 1
elif s.is_comment():
line = '\t' * indent_level + '#' + s.name
current_comment = True
current_comment = s.options.get('block', True)
elif s.is_directive():
line = '\t' + s.name
elif s.is_command():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment