This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Omit DBG_VALUE after terminator
ClosedPublic

Authored by aheejin on May 11 2021, 11:27 PM.

Details

Summary

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.

Diff Detail

Event Timeline

aheejin created this revision.May 11 2021, 11:27 PM
aheejin requested review of this revision.May 11 2021, 11:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 11 2021, 11:27 PM

This is a second attempt after D101736, which was a hacky take to make MachineVerifier pass. It looks that was not necessary after all; thanks @jmorse.

dschuff accepted this revision.May 12 2021, 11:35 AM
This revision is now accepted and ready to land.May 12 2021, 11:35 AM
This revision was automatically updated to reflect the committed changes.