[PATCH] D101736: [WebAssembly] Allow DBG_VALUE after terminator in MachineVerifier
Jeremy Morse via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 4 11:39:33 PDT 2021
jmorse added a comment.
Hi,
I'm not familiar with WebAssembly, but thought I'd describe how this would works in other backends -- it might inspire you to take a different route. Sorry if it doesn't apply to WebAssembly.
For the problem of:
But wasm is special in this way, because uses, not defs, can change the
value stack location's contents. Our terminator instructions, such as
BR_IF don't write to registers but uses registers, which can be
stackified, changing the value stack and thus possibly invalidating some
variables' value in previous DBG_VALUEs, so they have to be cleared by
additional DBG_VALUEs after the terminator in that case.
There's a function / class, DbgEntityHistoryCalculator, that would handle this for other architectures. It translates DBG_VALUE instructions into location lists described using MCSymbols. It starts a location range at the point where a DBG_VALUE occurs, and then terminates that range at:
- Another DBG_VALUE for the same variable,
- The end of the block,
- When the relevant machine register is clobbered.
It seems to me that if the WebAssembly value stack can be tracked within a block in a similar way, then when a value is no longer present, DbgEntityHistoryCalculator could terminate the location range as if a register had been clobbered. X86 tail-calls are an example: they clobber registers, but we don't insert DBG_VALUE $noregs after them, because DbgEntityHistoryCalculator observes the clobber and terminates the range.
If WebAssembly can't use DbgEntityHistoryCalculator for some reason, then yes, something like this patch would be needed.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D101736/new/
https://reviews.llvm.org/D101736
More information about the llvm-commits
mailing list