dillon1000/react
Commit
Browse files LeaveSSA: handle phi as operand to subsequent phi
Fixes https://github.com/facebook/react-forget/pull/858#discussion_r1044626137.
The case is
```javascript
function foo() {
let x$1 = 1;
let y = 2;
if (y === 2) {
x$2 = 3;
}
x$3 = phi(x$1, x$2)
if (y === 3) {
x4 = 5;
}
x$5 = phi(x$3, x$4);
y = x$5;
}
```
What happens here is that there are two _sequential_ phis for `x`. Previously
when we encountered the second phi we would find that there is no `let`
declaration for the phi or any of its operands, and create a new one before the
second `if`. That's incorrect, these should all merge into a single `x`
declaration. We now look up the phi operands to see if they are part of a
previous phi, and merge them correctly.Changed paths6 files
First-parent comparisoncompiler/forget/src/HIR/LeaveSSA.ts ModifiedM compiler/forget/src/HIR/Pipeline.ts ModifiedA compiler/forget/src/HIR/logger.ts AddedM compiler/forget/src/__tests__/fixtures/hir/ssa-complex-multiple-if.expect.md ModifiedM compiler/forget/src/__tests__/hir-test.ts ModifiedM compiler/forget/src/__tests__/test-utils/generateTestsFromFixtures.ts ModifiedPatch
Files changed
Rendering syntax-highlighted changes…