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.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
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).
LGTM for a start; we'll wait a bit and see if there are other opinions before landing.
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.
What about a test that uses MIR as *input* (so isn't affected by future codegen changes) and then checks DWARF output?
I added a regular codegen test. I tried the MIR route, but ran into multiple bugs, including broken branch probability parsing, and no support for target passes.
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?
Also, looking at the branch probability parsing code, it looks like https://llvm.org/bugs/show_bug.cgi?id=28751 has been broken since December D:
Yes, without running the target passes for WebAssembly, llc will just crash later due to the virtual registers. Is this patch OK to land as is with the regular test?
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.
I'm planning to simplify DbgValueHistoryCalculator in the near future so I'll need all the test coverage I can get :-)
lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp | ||
---|---|---|
249 ↗ | (On Diff #66197) | I can comment out this condition and the test still passes. |