This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Handle cleanuppad with no parent in Wasm SjLj
ClosedPublic

Authored by aheejin on Jan 27 2022, 1:34 PM.

Details

Summary

Wasm SjLj converts longjmpable calls into invokes that unwind to
%catch.longjmp.dispatch BB, from where we check if the thrown
exception is a longjmp. But in case a call already has a funclet
attribute, i.e., it is within a catch scope, we have to unwind to its
unwind destination first to preserve the scoping structure. That will
eventually unwind to %catch.longjmp.dispatch, because all
catchswitch and cleanupret that unwind to caller are redirected to
%catch.dispatch.longjmp during Wasm SjLj transformation.

But the prevous code assumed cleanuppad's parent pad was always an
instruction, and didn't handle when a cleanuppad's parent is none.
This CL handles this case, and makes the while loop more intuitive by
removing FromPad condition and explicitly inserting breaks.

Diff Detail

Event Timeline

aheejin created this revision.Jan 27 2022, 1:34 PM
aheejin requested review of this revision.Jan 27 2022, 1:34 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 27 2022, 1:34 PM
aheejin updated this revision to Diff 403785.Jan 27 2022, 1:37 PM

Test comment

aheejin updated this revision to Diff 403789.Jan 27 2022, 1:43 PM

clang-tidy

dschuff added inline comments.Jan 27 2022, 2:02 PM
llvm/test/CodeGen/WebAssembly/lower-wasm-ehsjlj.ll
270

is it catch.longjmp.dispatch or catch.dispatch.longjmp?

aheejin marked an inline comment as done.Jan 27 2022, 2:28 PM
aheejin added inline comments.
dschuff accepted this revision.Jan 27 2022, 2:37 PM
This revision is now accepted and ready to land.Jan 27 2022, 2:37 PM
aheejin marked an inline comment as done.Jan 27 2022, 6:03 PM
aheejin added inline comments.
llvm/test/CodeGen/WebAssembly/lower-wasm-ehsjlj.ll
270

Oh, I fixed this in D118408 by mistake... Will move the fix here.

aheejin updated this revision to Diff 403852.Jan 27 2022, 6:04 PM

catch.longjmp.dispatch -> catch.dispatch.longjmp