This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Free setjmpTable before exiting calls in EmSjLj
ClosedPublic

Authored by aheejin on Aug 30 2021, 4:16 PM.

Details

Summary

This is an improvement over D107852. We don't need to enumerate specific
function names; we can just check for noreturn attribute. This also
requires us to make sure __resumeExeption and emscripten_longjmp
have noreturn attribute too; one of them is a JS function and the
other calls a JS function so Clang does not have a way to deduce they
don't return.

This is effectively NFC, because I'm not sure if there is an additional
case this case covers; if we add a custom function call that has
noreturn attribute, it will be processed within the SjLj handling and
turned into __invoke call. So this really applies to some special
functions like emscripten_longjmp.

Diff Detail

Event Timeline

aheejin created this revision.Aug 30 2021, 4:16 PM
aheejin requested review of this revision.Aug 30 2021, 4:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 30 2021, 4:16 PM
aheejin added inline comments.Aug 30 2021, 4:37 PM
llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
437–444

This removes noreturn attribute from emscripten_longjmp, which makes this CL incorrect. Also, I'm not sure why this code was there in the first place. We don't call those noreturn functions within the LLVM IR anymore; we call invokes instead, which call the noreturn function via indirection, so it doesn't violate the noreturn property.

I traced the origin and found fastcomp's Emscripten EH handling code has the same snippet. I guess then I conservatively pasted that out of concerns something might break without that. But all emscripten tests pass without this fine.

dschuff accepted this revision.Aug 30 2021, 4:57 PM
This revision is now accepted and ready to land.Aug 30 2021, 4:57 PM
This revision was landed with ongoing or failed builds.Aug 30 2021, 9:46 PM
This revision was automatically updated to reflect the committed changes.