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

[patch] Gate EliminatePhi fix behind feature flag

Mofei Zhang committed Aug 7, 2023 at 17:41 UTC ff2f2e068540a29d82b5ba7a970444621007f5a5
1 file changed +10 -9
compiler/forget/packages/babel-plugin-react-forget/src/SSA/EliminateRedundantPhi.ts
+10 -9
@@ -106,19 +106,20 @@ export function eliminateRedundantPhi(
106 for (const place of eachInstructionOperand(instr)) {
107 rewritePlace(place, rewrites);
108 }
109 - if (instr.value.kind === "FunctionExpression") {
110 - const { context } = instr.value.loweredFunc;
111 - for (const place of context) {
112 - rewritePlace(place, rewrites);
113 - }
114 - }
115 - // visit function expressions on first iteration of each block
109 +
110 if (
117 - isFirstIteration &&
111 instr.value.kind === "FunctionExpression" &&
112 fn.env.enableOptimizeFunctionExpressions
113 ) {
121 - eliminateRedundantPhi(instr.value.loweredFunc, rewrites);
114 + const { context } = instr.value.loweredFunc;
115 + for (const place of context) {
116 + rewritePlace(place, rewrites);
117 + }
118 +
119 + // visit function expressions on first iteration of each block
120 + if (isFirstIteration) {
121 + eliminateRedundantPhi(instr.value.loweredFunc, rewrites);
122 + }
123 }
124 }
125