[PATCH] D97929: [WebAssembly] Fix ExceptionInfo grouping again

Heejin Ahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 4 03:49:02 PST 2021


aheejin created this revision.
aheejin added reviewers: dschuff, tlively.
Herald added subscribers: wingo, ecnelises, sunfish, hiraditya, jgravelle-google, sbc100.
aheejin requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This is a case D97677 <https://reviews.llvm.org/D97677> missed. When taking out remaining BBs that are
reachable from already-taken-out exceptions (because they are not
subexcptions but unwind destinations), I assumed the remaining BBs are
not EH pads, but they can be. For example,

  try {
    try {
      throw 0;
    } catch (int) { // (a)
    }
  } catch (int) {   // (b)
  }
  try {
    foo();
  } catch (int) {   // (c)
  }

In this code, (b) is the unwind destination of (a) so its exception is
taken out of (a)'s exception, But even though the next try-catch is not
inside the first two-level try-catches, because the first try always
throws, its continuation BB is unreachable and the whole rest of the
function is dominated by EH pad (a), including EH pad (c). So after we
take out of (b)'s exception out of (a)'s, we also need to take out (c)'s
exception out of (a)'s, because (c) is reachable from (b).

This adds one more step before what we did for remaining BBs in D97677 <https://reviews.llvm.org/D97677>;
it traverses EH pads first to take subexceptions out of their incorrect
parent exception. It's the same thing as D97677 <https://reviews.llvm.org/D97677>, but because we can do
this before we add BBs to exceptions' sets, we don't need to fix sets
and only need to fix parent exception pointers.

Other changes are variable name changes (I changed `WE` -> `SrcWE`,
`UnwindWE` -> `DstWE` for clarity), some comment changes, and a drive-by
fix in a bug in a `LLVM_DEBUG` print statement.

Fixes https://github.com/emscripten-core/emscripten/issues/13588.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97929

Files:
  llvm/lib/Target/WebAssembly/WebAssemblyExceptionInfo.cpp
  llvm/test/CodeGen/WebAssembly/cfg-stackify-eh.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97929.328114.patch
Type: text/x-patch
Size: 13113 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210304/0e33dd68/attachment-0001.bin>


More information about the llvm-commits mailing list