This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Implement ReplaceNodeResults to fix a SIMD crash
ClosedPublic

Authored by tlively on Apr 23 2019, 1:35 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

tlively created this revision.Apr 23 2019, 1:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 23 2019, 1:35 PM

We talked offline and it's maybe better to have a bit more picture on how ReplaceNodeResults is working before committing this.

llvm/test/CodeGen/WebAssembly/simd-illegal-signext.ll
8 ↗(On Diff #196315)

Nit: Can we make it wrap to 80 cols bit more? It currently looks kinda random

15 ↗(On Diff #196315)

Nit: we can remove #0

tlively marked 2 inline comments as done.May 2 2019, 6:08 PM

DAGTypeLegalizer calls ReplaceNodeResults whenever CustomLowerNode is called and its parameter LegalizeResult is true or when CustomWidenLowerNode is called. So basically it is the same as LowerOperation except that it is meant to focus on legalizing the result type rather than simply transforming the operation. There is even a TODO on LowerOperationWrapper, /// TODO: Consider merging with ReplaceNodeResults..

llvm/test/CodeGen/WebAssembly/simd-illegal-signext.ll
8 ↗(On Diff #196315)

I would have to break up the very long WebAssemblyTargetLowering::ReplaceNodeResults to make the wrapping prettier. I think it's more valuable to keep the name so the reader knows exactly what was fixed.

tlively updated this revision to Diff 197906.May 2 2019, 6:16 PM
  • Remove hanging metadata tag in test
aheejin accepted this revision.May 2 2019, 7:56 PM

Thanks for investigating this! This is getting kind of hard to understand without knowing the context that why signext_inreg is custom lowered for SIMD but actually not custom lowered....

llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
898 ↗(On Diff #197906)

Can we guarantee this function is only executed in case of SIGN_EXTEND_INREG? How about checking its opcode here and if not do llvm_unreachable or something, with some comments why we need this for SIGN_EXTEND_INREG?

This revision is now accepted and ready to land.May 2 2019, 7:56 PM
tlively updated this revision to Diff 201014.May 23 2019, 10:50 AM
  • Fail if trying to run ReplaceNode on an unexpected op
This revision was automatically updated to reflect the committed changes.