From ff2f2e068540a29d82b5ba7a970444621007f5a5 Mon Sep 17 00:00:00 2001 From: Mofei Zhang Date: Mon, 7 Aug 2023 17:41:34 -0400 Subject: [PATCH] [patch] Gate EliminatePhi fix behind feature flag --- .../src/SSA/EliminateRedundantPhi.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/compiler/forget/packages/babel-plugin-react-forget/src/SSA/EliminateRedundantPhi.ts b/compiler/forget/packages/babel-plugin-react-forget/src/SSA/EliminateRedundantPhi.ts index 9da0bba5d9..0cffa408c7 100644 --- a/compiler/forget/packages/babel-plugin-react-forget/src/SSA/EliminateRedundantPhi.ts +++ b/compiler/forget/packages/babel-plugin-react-forget/src/SSA/EliminateRedundantPhi.ts @@ -106,19 +106,20 @@ export function eliminateRedundantPhi( for (const place of eachInstructionOperand(instr)) { rewritePlace(place, rewrites); } - if (instr.value.kind === "FunctionExpression") { + + if ( + instr.value.kind === "FunctionExpression" && + fn.env.enableOptimizeFunctionExpressions + ) { const { context } = instr.value.loweredFunc; for (const place of context) { rewritePlace(place, rewrites); } - } - // visit function expressions on first iteration of each block - if ( - isFirstIteration && - instr.value.kind === "FunctionExpression" && - fn.env.enableOptimizeFunctionExpressions - ) { - eliminateRedundantPhi(instr.value.loweredFunc, rewrites); + + // visit function expressions on first iteration of each block + if (isFirstIteration) { + eliminateRedundantPhi(instr.value.loweredFunc, rewrites); + } } }