mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
3a200fa4a1
This is an alternate take on phi elimination to the one we pursued over VC w @poteto driving. This version exploits the RPO ordering of blocks to do phi elimination in a single pass when there are no loops, and to minimize repeated visits when there are loops. The main difference is when redundant phis are removed. Rather than eagerly walking through the CFG for each pruned phi to rewrite its uses, we build up a mapping of rewritten identifiers. As we walk through subsequent instructions, we rewrite each place based on that mapping. We continue cycling through the blocks so long as a given iteration *both* added new rewrites (meaning there may be subsequent uses to rewrite) *and* there are back-edges. With no loops this results in a single visit of each block and of each instruction, but even with loops this is bounded.