In SelectionDAG, DBG_PHI instructions are created to "read" physreg values and give them an instruction number, when they can't be traced back to a defining instruction. The most common scenario is arguments to a function. Unfortunately, if you have 100 inlined methods, each of which has the same "this" pointer, then the 100 dbg.value instructions become 100 DBG_INSTR_REFs and 100 DBG_PHIs, where only one DBG_PHI would suffice.
This patch adds a vreg cache for MachineFunction::salvageCopySSA, if we've already traced a value back to the start of a block and create a DBG_PHI then it allows us to re-use the DBG_PHI, as well as reducing work.
I've added a test with an implicit check-not for DBG_PHIs, which I think is the best way of making sure they aren't over-created in the future, and deserves its own test file.
I think something like DbgPHICache might be clearer, but this is not a very strong opinion.