@samitouri / QOS-React-1 / commits / cbb815e907

[rust] Port EliminateRedundantPhi fix

Joe Savona committed Aug 10, 2023 at 10:59 UTC cbb815e90739c788a9d9309e6dec9c93d74453a0
2 files changed +7 -7
compiler/forget/crates/forget_fixtures/tests/snapshots/fixtures_test__fixtures@function-expressions.js.snap
+1 -1
@@ -58,7 +58,7 @@ bb0 (block)
58 [14] #16 = Binary unknown #14 + unknown #15
59 [15] #17 = 8
60 [16] #18 = Binary unknown #16 + unknown #17
61 - [17] #19 = Function @deps[] @context[unknown x$17, unknown y$18, unknown a$19, unknown b$20]:
61 + [17] #19 = Function @deps[] @context[unknown x$11, unknown y$12, unknown a$13, unknown b$15]:
62 function bar(
63 unknown z$21,
64 )
compiler/forget/crates/forget_ssa/src/eliminate_redundant_phis.rs
+6 -6
@@ -24,7 +24,6 @@ pub fn eliminate_redundant_phis(env: &Environment, fun: &mut Function) {
24
25 let mut len;
26 loop {
27 - let is_first_iteration = !has_back_edge;
27 len = rewrites.len();
28
29 for block in hir.blocks.iter_mut() {
@@ -75,12 +74,13 @@ pub fn eliminate_redundant_phis(env: &Environment, fun: &mut Function) {
74 rewrite(&rewrites, &mut store.identifier.identifier)
75 });
76 instr.each_identifier_load(|load| rewrite(&rewrites, &mut load.identifier));
78 - // Visit function expressions on first iteration of each block to
79 - // recursively eliminate any of their redundant phis
80 - if is_first_iteration {
81 - if let InstructionValue::Function(fun) = &mut instr.value {
82 - eliminate_redundant_phis(env, &mut fun.lowered_function);
77 +
78 + if let InstructionValue::Function(fun) = &mut instr.value {
79 + for context_identifier in &mut fun.lowered_function.context {
80 + rewrite(&rewrites, &mut context_identifier.identifier);
81 }
82 +
83 + eliminate_redundant_phis(env, &mut fun.lowered_function);
84 }
85 }
86 }