Commit 22ec8037 authored by Taddeus Kroes's avatar Taddeus Kroes

Fixed liveness in- and out set generation.

parent 1120fc8f
...@@ -66,29 +66,30 @@ def create_in_out(blocks): ...@@ -66,29 +66,30 @@ def create_in_out(blocks):
for b in blocks: for b in blocks:
create_use_def(b) create_use_def(b)
b.live_in = b.use_set b.live_in = set()
b.live_out = set() b.live_out = set()
change = True # Start by analyzing the exit points
work_list = set()
while change: for b in blocks:
change = False if b.edges_from and not b.edges_to:
work_list.add(b)
for b in blocks: while len(work_list):
# in[B] = use[B] | (out[B] - def[B]) b = work_list.pop()
new_in = b.use_set | (b.live_out - b.def_set)
# out[B] = union of in[S] for S in succ(B) # in[B] = use[B] | (out[B] - def[B])
new_out = set() new_in = b.use_set | (b.live_out - b.def_set)
for s in succ(b): # out[B] = union of in[S] for S in succ(B)
new_out |= s.live_in b.live_out = set()
# Check if either `in' or `out' changed for s in succ(b):
if new_in != b.live_in: b.live_out |= s.live_in
b.live_in = new_in
change = True
if new_out != b.live_out: # Check if the out set has changed. If so, add all predecessors to the
b.live_out = new_out # work list
change = True if new_in != b.live_in:
b.live_in = new_in
work_list |= set(b.edges_from)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment