This enables LiveDebugValues analysis for Wasm. DBG_VALUEs expire at
the end of a BB, and this is the analysis extends their lifetime when
possible, greatly increasing the coverage of variable debug info.
Specifically, this removes the current constraint that this analysis is
only used with physical registers, which was first introduced in D18421,
because Wasm uses only virtual registers. I don't think there's anything
inherent in this analysis that only applies to physical registers; it
was just because all targets using this analysis ran this at the end of
their compiliation pipeline, at which point all their vregs had been
allocated, and Wasm's debug info infrastructure was not really set up
yet, so it was not using it.
This adds supports to Wasm-specific target-index operands, defined in
https://github.com/llvm/llvm-project/blob/2166d9529a60d1cdedb733d2e4134c971f0969ec/llvm/lib/Target/WebAssembly/WebAssembly.h#L87-L100.
Among these, TI_LOCAL, TI_LOCAL_INDIRECT, and TI_OPERAND_STACK are
used by Wasm DBG_VALUE instructions.
This does not yet handle mutable target indices, i.e., this does not
terminate a DBG_VALUE for a local index when we encounter a new
local.set or local.tee. It will be implemented as a follow-up.
(I had posted some stats but removed them because they are inaccurate at
this point, because this is not fully implemented yet)
Doing this makes sense for WASM, but check that there are no virtual registers remains an important sanity check for other targets -- mixing vregs and physregs would definitely generate broken results. Would you be able to add an assertion somewhere else for everything but WASM? (I don't think this method can know what the target arch is).