EliminateRedundantPhi traverses function expressions
Joe Savona committed
Jun 8, 2023 at 14:02 UTC
e39855d2519662406bf02243036ed85b8931abf0
2 files changed
+5
-2
compiler/forget/packages/babel-plugin-react-forget/src/Inference/AnalyseFunctions.ts
-2
@@ -17,7 +17,6 @@ import {
17
ReactiveScopeDependency,
18
} from "../HIR";
19
import { constantPropagation } from "../Optimization";
20
-import { eliminateRedundantPhi } from "../SSA";
20
import { inferTypes } from "../TypeInference";
21
import { logHIRFunction } from "../Utils/logger";
22
import { inferMutableRanges } from "./InferMutableRanges";
@@ -89,7 +88,6 @@ export default function analyseFunctions(func: HIRFunction): void {
88
}
89
90
function lower(func: HIRFunction): void {
92
- eliminateRedundantPhi(func);
91
constantPropagation(func);
92
inferTypes(func);
93
analyseFunctions(func);
compiler/forget/packages/babel-plugin-react-forget/src/SSA/EliminateRedundantPhi.ts
+5
@@ -97,6 +97,11 @@ export function eliminateRedundantPhi(fn: HIRFunction): void {
97
rewritePlace(place, rewrites);
98
}
99
rewritePlace(instr.lvalue, rewrites);
100
+
101
+ // visit function expressions on first iteration of each block
102
+ if (!hasBackEdge && instr.value.kind === "FunctionExpression") {
103
+ eliminateRedundantPhi(instr.value.loweredFunc);
104
+ }
105
}
106
107
// Rewrite all terminal operands