WebAssembly use of collectDebugValues

Hi Dan, Yury, llvm-dev,

The WebAssembly backend has recently started using MachineInstr::collectDebugValues in r351216 [0] for debuginfo manipulation. FYI, there are some debuginfo changes coming that might invalidate your use of collectDebugValues, so I thought I’d let you know.

LLVM currently places DBG_VALUE machine pseudo-instructions immediately after the instruction that defines the DBG_VALUEs operand. collectDebugValues relies on this behaviour: it only collects DBG_VALUEs that immediately follow the defining instruction. However, sometime soon LLVM will instead place DBG_VALUE instructions where variable assignments in the source program occurred (ish) [1], removing the behaviour collectDebugValues relies on.

I have zero knowledge of WebAssembly, so my question is “Does the target code rely on this behaviour?”. No WebAssembly tests fail when the behaviour changes, but I figured I’d ask anyway.

[0] https://reviews.llvm.org/rL351216
[1] https://reviews.llvm.org/D58453


Thank you for heads up. Yes, it does. The WebAssembly backend relies
on the collectDebugValues though it does not rely on idea of "machine
pseudo-instructions immediately after the instruction". I don't have a
good answer yet, but if collectDebugValues continues returning
DBG_VALUE connected with the defining instruction it will be fine. The
examples of operations it is used in: replace virtual register in a
defining instruction, instructions moving or cloning inside and
between BBs. So I guess we just need to see and follow up with future
changes in the behaviour of the collectDebugValues.