summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorGuanzhong Chen <gzchen@google.com>2019-07-03 00:37:49 +0000
committerGuanzhong Chen <gzchen@google.com>2019-07-03 00:37:49 +0000
commitb88ebe8cc9a8585647fdbff14b92841582be50a9 (patch)
treee20550bd8be91c6bf2d8afc5d34b3c249129d309 /llvm/lib
parent4f3472deb28b772c82323a849eddd9b67f1cdc31 (diff)
downloadbcm5719-llvm-b88ebe8cc9a8585647fdbff14b92841582be50a9.tar.gz
bcm5719-llvm-b88ebe8cc9a8585647fdbff14b92841582be50a9.zip
[WebAssembly] Prevent inline assembly from being mangled by SjLj
Summary: Before, inline assembly gets mangled by the SjLj transformation. For example, in a function with setjmp/longjmp, this LLVM IR code call void asm sideeffect "", ""() would be transformed into call void @__invoke_void(void ()* asm sideeffect "", "") This is invalid, and results in the error: Cannot take the address of an inline asm! In this diff, we skip the transformation for inline assembly. Reviewers: aheejin, tlively Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64115 llvm-svn: 364985
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
index 7ab8e361a8b..960d5134f6e 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
@@ -485,6 +485,13 @@ bool WebAssemblyLowerEmscriptenEHSjLj::canLongjmp(Module &M,
if (CalleeF->isIntrinsic())
return false;
+ // Attempting to transform inline assembly will result in something like:
+ // call void @__invoke_void(void ()* asm ...)
+ // which is invalid because inline assembly blocks do not have addresses
+ // and can't be passed by pointer. The result is a crash with illegal IR.
+ if (isa<InlineAsm>(Callee))
+ return false;
+
// The reason we include malloc/free here is to exclude the malloc/free
// calls generated in setjmp prep / cleanup routines.
Function *SetjmpF = M.getFunction("setjmp");
OpenPOWER on IntegriCloud