From 19fcef1222eb7aeba37414b6af48f02f65378241 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Mon, 23 Aug 2021 16:59:29 -0400 Subject: [PATCH] Fix stack restoration in to_ssa This is similar to the functional stack passing fix in #119 but has a smaller fix (just clobber the stacks altogether before restoring the old values; previously we just overwrote the new variables). --- examples/test/to_ssa/if-const.out | 2 +- examples/test/to_ssa/if-ssa.out | 2 +- examples/to_ssa.py | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/test/to_ssa/if-const.out b/examples/test/to_ssa/if-const.out index 84b19da84..d3578a70b 100644 --- a/examples/test/to_ssa/if-const.out +++ b/examples/test/to_ssa/if-const.out @@ -9,7 +9,7 @@ b.0: int = const 1; jmp .zexit; .zexit: - b.1: int = phi b.0 b.0 .false .true; + b.1: int = phi b.0 __undefined .false .true; a.1: int = phi __undefined a.0 .false .true; print a.1; ret; diff --git a/examples/test/to_ssa/if-ssa.out b/examples/test/to_ssa/if-ssa.out index c9d635ace..e8fee00e7 100644 --- a/examples/test/to_ssa/if-ssa.out +++ b/examples/test/to_ssa/if-ssa.out @@ -10,7 +10,7 @@ jmp .zexit; .zexit: a.3.1: int = phi __undefined a.3.0 .left .right; - a.2.1: int = phi a.2.0 a.2.0 .left .right; + a.2.1: int = phi a.2.0 __undefined .left .right; a.4.0: int = phi a.2.1 a.3.1 .left .right; print a.4.0; ret; diff --git a/examples/to_ssa.py b/examples/to_ssa.py index b716ac217..62de7b3be 100644 --- a/examples/to_ssa.py +++ b/examples/to_ssa.py @@ -83,6 +83,7 @@ def _rename(block): _rename(b) # Restore stacks. + stack.clear() stack.update(old_stack) entry = list(blocks.keys())[0]