RS4GC needs to rewrite the IR to ensure that every relocated pointer has an associated base pointer. The existing code isn't particularly smart about avoiding duplication of existing IR when it turns out the original pointer we were asked to materialize a base pointer for is itself a base pointer.
This patch adds a stage to the algorithm which prunes nodes proven (with a simple forward dataflow fixed point) to be base pointers from the list of nodes considered for duplication. This does require changing some of the later invariants slightly, that's probably the riskiest part of the change.
Note: The version posted is slightly WIP. I need to confirm I can back out the recent deopt value change, and add more targeted testing of cornercases in the new inference. I'm posting it now to get feedback in the context of the ongoing discussion on D97837. Planning to rebase with mentioned changes Monday.
why not
do {} while(!ToRemove.empty());
?