[WebAssembly] Use LiveDebugValues analysis
authorHeejin Ahn <aheejin@gmail.com>
Wed, 21 Sep 2022 21:48:34 +0000 (14:48 -0700)
committerHeejin Ahn <aheejin@gmail.com>
Tue, 10 Jan 2023 17:54:59 +0000 (09:54 -0800)
commite9ea7a0e20c27dc080dc16dc4b7c5c104801fe69
treee7c0d3b404ca116eccae575a45c92b0818b7bf55
parentbc21af6a43db45bf0d0192afab0a079ecf400aa2
[WebAssembly] Use LiveDebugValues analysis

This enables `LiveDebugValues` analysis for Wasm. `DBG_VALUE`s 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.

Reviewed By: dschuff, jmorse

Differential Revision: https://reviews.llvm.org/D138943
llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp
llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
llvm/test/DebugInfo/WebAssembly/live-debug-values.mir [new file with mode: 0644]