[PATCH] D140373: [WebAssembly][LiveDebugValues] Handle target index defs

Heejin Ahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 20 00:59:08 PST 2022


aheejin created this revision.
aheejin added reviewers: dschuff, jmorse.
Herald added subscribers: pmatos, asb, wingo, ecnelises, arphaman, sunfish, hiraditya, jgravelle-google, sbc100.
Herald added a project: All.
aheejin requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This adds the missing handling for defs for target index operands, as is
already done for registers.

There are two kinds of target indices: local indices and stack operands.

- Locals are something similar to registers in Wasm-land. For local indices, we can check for local-defining instructions (`local.set` or `local.tee`).

- Wasm is a stack machine, so we have values in certain Wasm value stack location, which change when Wasm instructions produce or consume values. So basically any value-producing instrucion, i.e., instruction with defs, can change values in the Wasm stack. But I think we don't need to worry about this here, because `WebAssemblyDebugFixup`, which runs right before this analysis, makes sure to insert terminating `DBG_VALUE $noreg` instructions whenever a stack value gets popped. After `WebAssemblyDebugFixup`, there shouldn't be any `DBG_VALUE`s for stack operands that don't have a terminating `DBG_VALUE $noreg` within the same BB.

So this CL only works on `DBG_VALUE`s for locals. When we encounter a
`local.set` or `local.tee` instructions, we delete `DBG_VALUE`s for
those target index locations from the open range set, so they will not
be availble in `OutLocs`. For example,

  bb.0:
    successors: %bb.1
    DBG_VALUE target-index(wasm-local) + 2, $noreg, "var", ...
    ...
    local.set 2 ...
  
  bb.1:
  ; predecessors: %bb.0
    ; We shouldn't add `DBG_VALUE target (wasm-local) + 2 here because
    ; it was killed by 'local.set' in bb.0

After disabling register coalescing at -O1, the average PC ranges
covered for Emscripten core benchmarks is currently 20.6% in the LLVM
tot. After applying D138943 <https://reviews.llvm.org/D138943> and this CL, the coverage goes up to 57%.
This also enables LiveDebugValues analysis in the Wasm pipeline by
default.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140373

Files:
  llvm/include/llvm/CodeGen/TargetInstrInfo.h
  llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
  llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h
  llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.h
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/test/DebugInfo/WebAssembly/live-debug-values.mir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140373.484177.patch
Type: text/x-patch
Size: 14044 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221220/c6bc78a3/attachment.bin>


More information about the llvm-commits mailing list