This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Fix WasmEHInfo updating in LateEHPrepare
AbandonedPublic

Authored by aheejin on Feb 20 2019, 1:36 PM.

Details

Reviewers
dschuff
Summary

When adding a 'br_on_exn' instruction, we transform code as follows:

  • Before:

ehpad:

%exnref:except_ref = catch
%exn:i32 = extract_exception
...
call @foo()  // can throw
  • After:

ehpad:

%exnref:except_ref = catch
br_on_exn %thenbb, $__cpp_exception, %exnref
br %elsebb

elsebb:

rethrow

thenbb:

%exn:i32 = extract_exception
...
call @foo()  // can throw

So if an ehpad ends with an instruction that can throw, there is a
ThrowUnwindDest mapping of <ehpad, otherbb>, which means if an
instruction in 'ehpad' throws it should go to 'otherbb'. In that case,
we should've updated it to <thenbb, otherbb>. This fixes the bug, and
also adds member functions to erase mappings in WasmEHFuncInfo.

It's hard to add a test for this because target-specific
MachineFunctionInfo is not serialized at the moment.

Diff Detail

Event Timeline

aheejin created this revision.Feb 20 2019, 1:36 PM
aheejin abandoned this revision.Feb 20 2019, 1:48 PM

I think we don't need the map of <throwbb, ehpad> after all now each bb can have at most one EH pad successor. This was not true in the first proposal implementation, but is in the new proposal.