From 4554e6f7242c5da44a90ea3a3a6c1651cdf0453a Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Sat, 28 Oct 2023 12:42:49 -0400 Subject: [PATCH] fix stability of _get_symbols_common this affects liveness analysis downstream. --- vyper/ir/ir_to_bb_pass.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/vyper/ir/ir_to_bb_pass.py b/vyper/ir/ir_to_bb_pass.py index 8c1a1717e9..8c7c8f2442 100644 --- a/vyper/ir/ir_to_bb_pass.py +++ b/vyper/ir/ir_to_bb_pass.py @@ -45,7 +45,15 @@ def _get_symbols_common(a: dict, b: dict) -> dict: - return {k: [a[k], b[k]] for k in a.keys() & b.keys() if a[k] != b[k]} + ret = {} + # preserves the ordering in `a` + for k in a.keys(): + if k not in b: + continue + if a[k] == b[k]: + continue + ret[k] = a[k], b[k] + return ret def generate_assembly_experimental( @@ -413,7 +421,8 @@ def _convert_ir_basicblock( ) ) - for sym, val in _get_symbols_common(after_then_syms, after_else_syms).items(): + common_symbols = _get_symbols_common(after_then_syms, after_else_syms) + for sym, val in common_symbols.items(): ret = ctx.get_next_variable() old_var = symbols.get(sym, None) symbols[sym] = ret