This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Fix __clang_call_termiante's argument for foreign exceptions
ClosedPublic

Authored by aheejin on Jul 30 2019, 1:12 PM.

Details

Summary

When exceptions are repeatedly thrown in the middle of handling another
exception, we call __clang_call_terminate with the exception pointer
(i32) as an argument. But in case of foreign exceptions, we don't have
the pointer, so we call the function with 0. (This requires
__clang_call_terminate can deal with 0 argument, which will be done
later)

But previously the 0 argument was not added as a i32.const 0 but an
immediate by mistake, causing the call instruction to take not an i32
but rather an exnref, because an exnref is left on top of the value
stack if br_on_exn is not taken.

block i32
  br_on_exn 0, __cpp_exception
                               ;; exnref is on top of stack now
  i32.const 0                  ;; This was missing!
  call __clang_call_terminate
  unreachable
end
call __clang_call_terminate    ;; This takes i32 extracted by br_on_exn

Diff Detail

Repository
rL LLVM

Event Timeline

aheejin created this revision.Jul 30 2019, 1:12 PM
dschuff accepted this revision.Aug 7 2019, 1:03 PM
This revision is now accepted and ready to land.Aug 7 2019, 1:03 PM
This revision was automatically updated to reflect the committed changes.
aheejin retitled this revision from Fix __clang_call_termiante's argument for foreign exceptions to [WebAssembly] Fix __clang_call_termiante's argument for foreign exceptions.Aug 26 2019, 1:41 AM