[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 04:40:12 PST 2021
aheejin added inline comments.
================
Comment at: llvm/test/CodeGen/WebAssembly/exception.ll:224
+; CHECK: catch $[[EXN:[0-9]+]]=, __cpp_exception
+; CHECK-NEXT: global.set __stack_pointer
+; CHECK-NEXT: call __clang_call_terminate, $[[EXN]]
----------------
tlively wrote:
> Where does this `global.set` come from? If I understand the code correctly, the `call __clang_call_terminate` should have been directly after the `catch`.
It is added in [[ https://github.com/llvm/llvm-project/blob/4e4df1e38d6b66083b3badb78e56b8b0f6045fd1/llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp#L291 | restoreStackPointer ]] in LateEHPrepare. When [[ https://github.com/llvm/llvm-project/blob/4e4df1e38d6b66083b3badb78e56b8b0f6045fd1/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp#L92 | WebAssemblyFrameLowering::needsPrologForEH ]] returns true, i.e., a function has calls, `__stack_pointer` has to be saved in the function prolog and restored after each `catch`.
================
Comment at: llvm/test/CodeGen/WebAssembly/exception.ll:238
+terminate.split2:
+ unreachable
+}
----------------
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;
```
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