dillon1000/react

Commit

[compiler] Maintain RPO and unique instruction ids when constructing scope terminals

Later passes may rely on HIR invariants such as blocks being in RPO or instructions having unique, ascending InstructionIds. However, BuildReactiveScopeTerminalsHIR doesn't currently gurantee this.

This PR updates that pass to first restore RPO, fixup predecessors (the previous logic tried to do this but failed on unreachable blocks, where `markPredecessors()` handles that case), and renumber instructions. Then it walks instructions and scopes to update identifier and scope ranges given the new instruction ids.

ghstack-source-id: 2a99df02ac9d125b202cae369e2dc4dccefb0625
Pull Request resolved: https://github.com/facebook/react/pull/30399
Browse files
Changed paths2 files
First-parent comparison
M compiler/packages/babel-plugin-react-compiler/src/HIR/AssertTerminalBlocksExist.ts ModifiedM compiler/packages/babel-plugin-react-compiler/src/HIR/BuildReactiveScopeTerminalsHIR.ts Modified
Patch

Files changed

Rendering syntax-highlighted changes…