This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Update basic EH instructions for the new spec
ClosedPublic

Authored by aheejin on Jan 4 2021, 3:40 PM.

Details

Summary

This implements basic instructions for the new spec.

  • Adds new versions of instructions: catch, catch_all, and rethrow
  • Adds support for instruction selection for the new instructions
    • catch needs a custom routine for the same reason throw needs one, to encode __cpp_exception tag symbol.
  • Updates WebAssembly::isCatch utility function to include catch_all and Change code that compares an instruction's opcode with catch to use that function.
  • LateEHPrepare
    • Previously in LateEHPrepare we added catch instruction to both catchpads (for user catches) and cleanuppads (for destructors). In the new version catch is generated from llvm.catch intrinsic in instruction selection phase, so we only need to add catch_all to the beginning of cleanup pads.
    • catch is generated from instruction selection, but we need to hoist the catch instruction to the beginning of every EH pad, because catch can be in the middle of the EH pad or even in a split BB from it after various code transformations.
    • Removes addExceptionExtraction function, which was used to generate br_on_exn before.
  • CFGStackfiy: Deletes fixUnwindMismatches function. Running this function on the new instruction causes crashes, and the new version will be added in a later CL, whose contents will be completely different. So deleting the whole function will make the diff easier to read.
  • Reenables all disabled tests in exception.ll and eh-lsda.ll and a single basic test in cfg-stackify-eh.ll.
  • Updates existing tests to use the new assembly format. And deletes br_on_exn instructions from the tests and FileCheck lines.

Diff Detail

Event Timeline

aheejin created this revision.Jan 4 2021, 3:40 PM
aheejin requested review of this revision.Jan 4 2021, 3:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 4 2021, 3:40 PM
tlively accepted this revision.Jan 5 2021, 11:16 AM
tlively added inline comments.
llvm/lib/Target/WebAssembly/WebAssemblyInstrControl.td
154

This isn't totally related to this diff, but do you remember why WebAssemblywrapper exists? I don't think I ever had a good grasp on why we need it.

llvm/test/CodeGen/WebAssembly/eh-labels.mir
37
This revision is now accepted and ready to land.Jan 5 2021, 11:16 AM
dschuff accepted this revision.Jan 6 2021, 4:34 PM
aheejin updated this revision to Diff 315579.Jan 9 2021, 1:07 AM
aheejin marked an inline comment as done.

CATCH -> CATCH_ALL in comment

llvm/lib/Target/WebAssembly/WebAssemblyInstrControl.td
154

I don't know well either. I think it was added before I started working on the codebase. I thought it was supposed to serve as a wrapper for a symbol or an address, but I'm not sure if we can use those symbol or global address nodes directly.

This revision was landed with ongoing or failed builds.Jan 9 2021, 1:48 AM
This revision was automatically updated to reflect the committed changes.