This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Handle EH terminate pads for cleanup
ClosedPublic

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

Details

Summary

Terminate pads, cleanup pads with __clang_call_terminate call, have
catch instruction in them because __clang_call_terminate takes an
exception pointer. But these terminate pads should be reached also in
case of foreign exception. So this pass attaches an additional
catch_all BB after every terminate pad BB, with a call to
std::terminate.

Diff Detail

Event Timeline

aheejin created this revision.Jan 4 2021, 3:56 PM
aheejin requested review of this revision.Jan 4 2021, 3:56 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 4 2021, 3:56 PM
tlively accepted this revision.Jan 28 2021, 2:12 PM

LGTM besides that one comment!

llvm/lib/Target/WebAssembly/WebAssemblyHandleEHTerminatePads.cpp
126

Is it possible for one BB to contain multiple calls to __clang_call_terminate? If so, that BB would end up with multiple catch_alls in the current code. Would it be worth asserting that this doesn't happen?

This revision is now accepted and ready to land.Jan 28 2021, 2:12 PM
aheejin added inline comments.Jan 29 2021, 9:00 AM
llvm/lib/Target/WebAssembly/WebAssemblyHandleEHTerminatePads.cpp
126

We ensure that doesn't happen in LateEHPrepare, thanks to you.

If we want to put some assert here it wouldn't be a single line assert, but we need to keep a set of something to see if there is no __clang_call_terminate calls with an EH pad that has already been added, which we are doing in LateEHPrepare anyway. I guess we don't need to duplicate that logic just for assertion..?

tlively added inline comments.Jan 29 2021, 11:02 AM
llvm/lib/Target/WebAssembly/WebAssemblyHandleEHTerminatePads.cpp
126

Oh, heh, I forgot about that. No need to duplicate that check here, then :)

This revision was automatically updated to reflect the committed changes.