[PATCH] D94045: [WebAssembly] Ensure terminate pads are a single BB
Heejin Ahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 9 22:27:00 PST 2021
aheejin marked an inline comment as done.
aheejin added inline comments.
================
Comment at: llvm/test/CodeGen/WebAssembly/exception.ll:238
+terminate.split2:
+ unreachable
+}
----------------
aheejin wrote:
> tlively wrote:
> > Is it possible for `call __clang_call_terminate` to have been duplicated as well so that it could appear in this basic block as well? If so, I don't think the code in this diff would handle deduplicating it.
> Wouldn't the second `__clang_call_terminate` within the same EH pad be caught in this code and just skipped?
> ```
> // If it is already the form we want, skip it
> if (Call->getParent() == EHPad &&
> Call->getNextNode()->getOpcode() == WebAssembly::UNREACHABLE)
> continue;
> ```
Sorry, the current code turns out to have a problem. Because `eraseDeadBBsAndChildren` deletes all child BBs and instructions in there, when we encounter the second `__clang_call_terminate` call within the terminate pad, it is possible that instruction has been already deleted and its pointer is stale, and accessing it causes a segmentation fault. I fixed the code to only count one `__clang_call_terminate` per terminate pad. Also added a second `__clang_call_terminate` call in this BB to test the duplicated calls case you pointed out. PTAL.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D94045/new/
https://reviews.llvm.org/D94045
More information about the llvm-commits
mailing list