This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Handle indirect uses of longjmp
ClosedPublic

Authored by aheejin on Oct 8 2020, 3:25 AM.

Details

Summary

In LowerEmscriptenEHSjLj, longjmp used to be replaced with
emscripten_longjmp_jmpbuf(jmp_buf*, i32), which will eventually be
lowered to emscripten_longjmp(i32, i32). The reason we used two
different names was because they had different signatures in the IR
pass.

D88697 fixed this by only using emscripten_longjmp(i32, i32) and
adding a ptrtoint cast to its first argument, so

longjmp(buf, 0)

becomes

emscripten_longjmp((i32)buf, 0)

But this assumed all uses of longjmp was a direct call to it, which
was not the case. This patch handles indirect uses of longjmp by
replacing

longjmp

with

(i32(*)(jmp_buf*, i32))emscripten_longjmp

Diff Detail

Event Timeline

aheejin created this revision.Oct 8 2020, 3:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 8 2020, 3:25 AM
aheejin requested review of this revision.Oct 8 2020, 3:25 AM
aheejin edited the summary of this revision. (Show Details)Oct 8 2020, 3:26 AM
tlively accepted this revision.Oct 8 2020, 8:40 AM

Nice!

This revision is now accepted and ready to land.Oct 8 2020, 8:40 AM
aheejin edited the summary of this revision. (Show Details)Oct 8 2020, 11:37 AM
This revision was automatically updated to reflect the committed changes.