Some backends, like WebAssembly, use virtual registers instead of physical registers. This crashes the DbgValueHistoryCalculator pass, which assumes that all registers are physical. Instead, skip virtual registers when iterating aliases, and assume that they are clobbered.
I think this surely isn't the final solution for debug info on virtual targets like wasm (that will probably require some more design work in the medium term), but not crashing is certainly a good start.
So, I think this code is fine. But the first part of the commit description isn't quite right, because it doesn't actually ignore virtual registers; it does track the clobbers (it just knows they don't have aliases and doesn't try to put them into the set of changing registers).
Yeah, it would have to be a MIR testcase; I wasn't sure if those were ready for prime time (and in particular we don't have any in the wasm backend). I can look into that; FWIW the test cases in D21808 do cover this (although they are obviously less well-targeted since they are traditional ll->asm codegen test cases.
OK I looked a little more wrt tests. The problem with MIR in this case is that DbgValueHistoryCalculator isn't a pass, it's just part of the AsmPrinter pass, which isn't really set up for MIR testing (e.g. for use with llc -run-pass etc). Maybe we should just add a regular wasm codegen test? It's not quite ideal since this is target-independent code, but it would cover this, and it could still be pretty simple.
Ouch, I think https://llvm.org/bugs/show_bug.cgi?id=24261 is probably a showstopper for MIR tests in wasm. Basically all the interesting things we'd want to test are target passes, and some of those passes need to be run in order to do anything interesting at all. I'm guessing the problem for this particular test is that you'd need to start after WebAssemblyRegNumbering in order to feed this into the asmprinter?
I think we should land this with a regular test, because that's better than no test. We should also fix the llc pass runner because I would really like to have some more targeted tests for the wasm backend passes, but I don't want to block you on that.