Skip to content

Commit

Permalink
add some OrderedSet hygiene
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper committed Oct 28, 2023
1 parent 9cf815c commit 5b43039
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions vyper/ir/bb_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ def _reset_liveness(ctx: IRFunction) -> None:
inst.liveness = OrderedSet()


def _calculate_liveness(bb: IRBasicBlock, liveness_visited: set) -> None:
def _calculate_liveness(bb: IRBasicBlock, liveness_visited: OrderedSet) -> None:
assert isinstance(liveness_visited, OrderedSet)
for out_bb in bb.cfg_out:
# REVIEW: .get() already defaults to None
if liveness_visited.get(bb, None) == out_bb:
Expand All @@ -132,7 +133,7 @@ def _calculate_liveness(bb: IRBasicBlock, liveness_visited: set) -> None:

def calculate_liveness(ctx: IRFunction) -> None:
_reset_liveness(ctx)
_calculate_liveness(ctx.basic_blocks[0], {})
_calculate_liveness(ctx.basic_blocks[0], OrderedSet())


@ir_pass
Expand Down
3 changes: 2 additions & 1 deletion vyper/ir/ir_to_bb_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def generate_assembly_experimental(

def convert_ir_basicblock(ir: IRnode) -> IRFunction:
global_function = IRFunction(IRLabel("global"))
_convert_ir_basicblock(global_function, ir, {}, {}, {})
_convert_ir_basicblock(global_function, ir, {}, OrderedSet(), {})

for i, bb in enumerate(global_function.basic_blocks):
if bb.is_terminated is False and i < len(global_function.basic_blocks) - 1:
Expand Down Expand Up @@ -230,6 +230,7 @@ def _convert_ir_basicblock(
variables: OrderedSet,
allocated_variables: dict[str, IRVariable],
) -> Optional[IRVariable]:
assert isinstance(variables, OrderedSet)
global _break_target, _continue_target

frame_info = ir.passthrough_metadata.get("frame_info", None)
Expand Down

0 comments on commit 5b43039

Please sign in to comment.