[PATCH] D97677: [WebAssembly] Fix more ExceptionInfo grouping bugs
Heejin Ahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 1 03:56:33 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 fixes two bugs in `WebAssemblyExceptionInfo` grouping, created by
D97247 <https://reviews.llvm.org/D97247>:
- In D97247 <https://reviews.llvm.org/D97247>, when fixing `ExceptionInfo` grouping by taking out the unwind destination' exception from the unwind src's exception, we just iterated the BBs in the function order, but this was incorrect; this changes it to dominator tree preorder. Please refer to the comments in the code for the reason and an example.
- After this subexception-taking-out fix, there still can be remaining BBs we have to take out. When Exception B is taken out of Exception A (because EHPad B is the unwind destination of EHPad A), there can still be BBs within Exception A that are reachable from Exception B, which also should be taken out. Please refer to the comments in the code for more detailed explanation on why this can happen. To make this possible, this splits `WebAssemblyException::addBlock` into two parts: adding to a set and adding to a vector. We need to iterate on BBs within a `WebAssemblyException` to fix this, so we add BBs to sets first. But we add BBs to vectors later after we fix all incorrectness because deleting BBs from vectors is expensive. I considered removing the vector from `WebAssemblyException`, but it was not easy because this class has to maintain a similar interface with `MachineLoop` to be wrapped into a single interface `SortRegion`, which is used in CFGSort.
Other misc. drive-by fixes:
- Make `WebAssemblyExceptionInfo` do not even run when wasm EH is not used or the function doesn't have any EH pads, not to waste time
- Add `LLVM_DEBUG` lines for easy debugging
- Fix `preds` comments in cfg-stackify-eh.ll
- Fix `__cxa_throw`'s signature in cfg-stackify-eh.ll
Fixes https://github.com/emscripten-core/emscripten/issues/13554.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D97677
Files:
llvm/lib/Target/WebAssembly/WebAssemblyExceptionInfo.cpp
llvm/lib/Target/WebAssembly/WebAssemblyExceptionInfo.h
llvm/test/CodeGen/WebAssembly/cfg-stackify-eh.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97677.327075.patch
Type: text/x-patch
Size: 21246 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210301/1e0fa269/attachment.bin>
More information about the llvm-commits
mailing list