This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Add NullifyDebugValueLists pass
ClosedPublic

Authored by aheejin on May 23 2021, 8:31 PM.

Details

Summary

WebAssemblyDebugValueManager does not currently handle
DBG_VALUE_LIST, which is a recent addition to LLVM. We tried to
nullify them within the constructor of WebAssemblyDebugValueManager in
D102589, but it made the class error-prone to use because it deletes
instructions within the constructor and thus invalidates existing
iterators within the BB, so the user of the class should take special
care not to use invalidated iterators. This actually caused a bug in
ExplicitLocals pass.

Instead of trying to fix ExplicitLocals pass to make the iterator usage
correct, which is possible but error-prone, this adds
NullifyDebugValueLists pass that nullifies all DBG_VALUE_LIST
instructions before we run WebAssembly specific passes in the backend.
We can remove this pass after we implement handlers for
DBG_VALUE_LISTs in WebAssemblyDebugValueManager and elsewhere.

Fixes https://github.com/emscripten-core/emscripten/issues/14255.

Diff Detail

Event Timeline

aheejin created this revision.May 23 2021, 8:31 PM
aheejin requested review of this revision.May 23 2021, 8:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 23 2021, 8:31 PM
dschuff accepted this revision.May 24 2021, 9:06 AM
dschuff added inline comments.
llvm/test/DebugInfo/WebAssembly/dbg-value-list.ll
12

Would it be possible to check that there actually are DBG_VALUE_LISTs in the input to the MIR pipeline (perhaps using -stop-after or something)? It's not obvious (to me) how the IR below leads to DBG_VALUE_LIST being created and it seems unlikely to be guaranteed.

This revision is now accepted and ready to land.May 24 2021, 9:06 AM

This also contains a revert of D102589.

aheejin updated this revision to Diff 347452.May 24 2021, 11:07 AM
aheejin marked an inline comment as done.

Add BEFORE and AFTER tests

llvm/test/DebugInfo/WebAssembly/dbg-value-list.ll
12

The presence of DIArgList in the first operand of llvm.dbg.value generates DBG_VALUE_LISTs. I added BEFORE and AFTER checking in the test.

aheejin updated this revision to Diff 347453.May 24 2021, 11:08 AM

Add comment for DIArgList

llvm/test/DebugInfo/WebAssembly/dbg-value-list.ll
12

Also added a comment explaining DIArgList creates DBG_VALUE_LIST

aheejin updated this revision to Diff 347455.May 24 2021, 11:09 AM

Better comment

This revision was landed with ongoing or failed builds.May 24 2021, 11:36 AM
This revision was automatically updated to reflect the committed changes.
llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp