aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/WebAssembly/WebAssemblyUtilities.cpp
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2019-03-30 11:04:48 +0000
committerHeejin Ahn <aheejin@gmail.com>2019-03-30 11:04:48 +0000
commitc4ac74fb4987c083fa8e7e10f0f978ecee9402c0 (patch)
treea92104e16ccb89b0690f7684845824756ea1f3aa /llvm/lib/Target/WebAssembly/WebAssemblyUtilities.cpp
parente9fd9073e4905eab7c0784cee804f0704a7020de (diff)
downloadllvm-c4ac74fb4987c083fa8e7e10f0f978ecee9402c0.zip
llvm-c4ac74fb4987c083fa8e7e10f0f978ecee9402c0.tar.gz
llvm-c4ac74fb4987c083fa8e7e10f0f978ecee9402c0.tar.bz2
[WebAssembly] Fix unwind destination mismatches in CFG stackify
Summary: Linearing the control flow by placing `try`/`end_try` markers can create mismatches in unwind destinations. This patch resolves these mismatches by wrapping those instructions with an incorrect unwind destination with a nested `try`/`catch`/`end_try` and branching to the right destination within the new catch block. Reviewers: dschuff Subscribers: sunfish, sbc100, jgravelle-google, chrib, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D48345 llvm-svn: 357343
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyUtilities.cpp')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyUtilities.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyUtilities.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyUtilities.cpp
index 4edd546..002246a 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyUtilities.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyUtilities.cpp
@@ -64,6 +64,8 @@ bool WebAssembly::isCopy(const MachineInstr &MI) {
case WebAssembly::COPY_F64_S:
case WebAssembly::COPY_V128:
case WebAssembly::COPY_V128_S:
+ case WebAssembly::COPY_EXCEPT_REF:
+ case WebAssembly::COPY_EXCEPT_REF_S:
return true;
default:
return false;
@@ -266,5 +268,8 @@ bool WebAssembly::mayThrow(const MachineInstr &MI) {
if (F->getName() == CxaBeginCatchFn || F->getName() == PersonalityWrapperFn ||
F->getName() == ClangCallTerminateFn || F->getName() == StdTerminateFn)
return false;
+
+ // TODO Can we exclude call instructions that are marked as 'nounwind' in the
+ // original LLVm IR? (Even when the callee may throw)
return true;
}