JIT: add pass to merge common throw helper calls by AndyAyersMS · Pull Request #27113 · dotnet/coreclr (original) (raw)
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
Look for blocks with single statement noreturn calls, and try to reroute flow so there's just one block call that all predecessors target.
Resolves #14770.
Note this impairs debuggability of optimized code a bit, as it can change which line of code apparently invokes a throw helper in a backtrace. But since we're already commoning jit-inserted throw helpers (like array index OOB) this is not breaking any new ground.
We could also handle commoning BBJ_THROW blocks, with some extra effort, but prototyping indicates duplicate throws are pretty rare.
- Unify helper classes
- Stack allocate map headers
- Phasify
- Implement an earlyout scheme
Revise this phase to run just before optOptimizeFlow
, so that we can leverage
the ref counts and predecessor lists to ensure we make correct flow updates.
Don't bother trying to clean out IR, let that happen naturally from as blocks become unreferenced.
Suppress tail calling noreturn methods if there is more than one such call site in the method, hoping that instead we can merge the calls.