4bcd8c2b8c
Only insert Phi at JoinEntry and Parameter at CatchBlockEntry if corresponding variable is alive into the block. This keeps insertion consistent with environment pruning logic employed by RenameRecursive: which prunes dead variables out environments when entering the block based on contents of the live_in set. Previously we would insert Parameter instructions for dead variables which lead to an incorrect (unsound) set of catch entry moves generated by the backend due to an inconsistency between Parameter insertion and environment pruning logic and the fact that catch entry moves generator would simply ignore all moves if the source of the move was an optimized_out (aka constant_dead) marker. The following situation was possible: if the variable was assigned inside the try and partially alive inside of it (e.g. we had blocks where it was alive and blocks where it was not) then we would end up inserting Parameter for it, but some of the exceptional edges (corresponding to blocks where the variable was dead) would carry optimized_out value into that Parameter. However `CatchEntryMoveFor` would not record these moves leading to uninitialized garbage arriving on those exceptional edges instead. Note that Phis were not susceptible to the same issue as Parameters because regalloc / backend would not treat optimized_out value specially. This change converts silent treatment of optimized_out in the catch entry moves generation into a release assert instead. Reviewing other uses of constant_dead in the compiler revealed a bug in canonicalization rule for `o.runtimeType` which did not take exceptional edges into account. We add a regression test for that and fix that issue as well. Fixes https://github.com/dart-lang/sdk/issues/59822 TEST=vm/dart/regress_59822,vm/dart/regress_runtime_type_in_trycatch Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-linux-product-x64-try,vm-aot-linux-release-arm64-try,vm-aot-linux-release-simarm_x64-try,vm-aot-linux-release-x64-try Change-Id: I8dc397cb98d84048a1791b9dd6baa7586a2688c6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403583 Reviewed-by: Alexander Aprelev <aam@google.com> Commit-Queue: Slava Egorov <vegorov@google.com>