[all-commits] [llvm/llvm-project] 71fbfb: [WebAssembly] Omit DBG_VALUE after terminator

Heejin Ahn via All-commits all-commits at lists.llvm.org
Fri May 14 03:48:58 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 71fbfb499aaaefbb2b24e5652df5525684766bfc
      https://github.com/llvm/llvm-project/commit/71fbfb499aaaefbb2b24e5652df5525684766bfc
  Author: Heejin Ahn <aheejin at gmail.com>
  Date:   2021-05-14 (Fri, 14 May 2021)

  Changed paths:
    M llvm/lib/Target/WebAssembly/WebAssemblyDebugFixup.cpp
    M llvm/test/CodeGen/WebAssembly/stackified-debug.ll

  Log Message:
  -----------
  [WebAssembly] Omit DBG_VALUE after terminator

When a stackified variable has an associated `DBG_VALUE` instruction,
DebugFixup pass adds a `DBG_VALUE` instruction after the stackified
value's last use to clear the variable's debug range info. But when the
last use instruction is a terminator, it can cause a verification
failure (when run with `-verify-machineinstrs`) because there are no
instructions allowed after a terminator.

For example:
```
%myvar = ...
DBG_VALUE target-index(wasm-operand-stack), $noreg, !"myvar", ...
BR_IF 0, %myvar, ...
DBG_VALUE $noreg, $noreg, !"myvar", ...
```
In this test, `%myvar` is stackified, so the first `DBG_VALUE`
instruction's first operand has changed to `wasm-operand-stack` to
denote it. And an additional `DBG_VALUE` instruction is added after its
last use, `BR_IF`, to signal variable `myvar` is not in the operand
stack anymore. But because the `DBG_VALUE` instruction is added after
the `BR_IF`, a terminator, it fails MachineVerifier.

`DBG_VALUE` instructions are used in `DbgEntityHistoryCalculator` to
compute value ranges to emit DWARF info, and it turns out the
`DbgEntityHistoryCalculator` terminates ranges at the end of a BB, so we
don't need to emit `DBG_VALUE` after a terminator.

Fixes https://bugs.llvm.org/show_bug.cgi?id=50175.

Reviewed By: dschuff

Differential Revision: https://reviews.llvm.org/D102309




More information about the All-commits mailing list