Fix SROA miscompile in large functions (#46819)
* Fix SROA miscompile in large functions
During the development of #46775, we saw a miscompile in the compiler,
specifically, we saw SROA failing to provide a proper PHI nest. The
root cause of this turned out to be an incorrect dominance query.
In particular, during incremental compaction, the non-compacted
portion of the IncrementalCompact cfg is allocated, but not valid,
so we must not query it for basic block information.
Unfortunately, I don't really have a good test case for this.
This code has grown mostly organically for a few years, and I
think it's probably overdue for an overhaul.
* optimizer: address TODO for computing `joint_effects` more efficiently
Co-authored-by: Shuhei Kadowaki <aviatesk@gmail.com>