[llvm] r359505 - [WebAssembly] Define the signature for __stack_chk_fail
Dan Gohman via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 29 14:09:45 PDT 2019
Author: djg
Date: Mon Apr 29 14:09:44 2019
New Revision: 359505
URL: http://llvm.org/viewvc/llvm-project?rev=359505&view=rev
Log:
[WebAssembly] Define the signature for __stack_chk_fail
The WebAssembly backend needs to know the signatures of all runtime
libcall functions. This adds the signature for __stack_chk_fail which was
previously missing.
Also, make the error message for a missing libcall include the name of
the function.
Differential Revision: https://reviews.llvm.org/D59521
Reviewed By: sbc100
Added:
llvm/trunk/test/CodeGen/WebAssembly/stack-protector.ll
- copied, changed from r359436, llvm/trunk/test/CodeGen/PowerPC/stack-protector.ll
Modified:
llvm/trunk/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp?rev=359505&r1=359504&r2=359505&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp Mon Apr 29 14:09:44 2019
@@ -309,6 +309,9 @@ struct RuntimeLibcallSignatureTable {
Table[RTLIB::MEMSET] = iPTR_func_iPTR_i32_iPTR;
Table[RTLIB::MEMMOVE] = iPTR_func_iPTR_iPTR_iPTR;
+ // __stack_chk_fail
+ Table[RTLIB::STACKPROTECTOR_CHECK_FAIL] = func;
+
// Element-wise Atomic memory
// TODO: Fix these when we implement atomic support
Table[RTLIB::MEMCPY_ELEMENT_UNORDERED_ATOMIC_1] = unsupported;
@@ -837,6 +840,11 @@ void llvm::getLibcallSignature(const Web
SmallVectorImpl<wasm::ValType> &Params) {
auto &Map = LibcallNameMap->Map;
auto Val = Map.find(Name);
- assert(Val != Map.end() && "unexpected runtime library name");
+#ifndef NDEBUG
+ if (Val == Map.end()) {
+ errs() << "runtime library name: " << Name << "\n";
+ llvm_unreachable("unexpected runtime library name");
+ }
+#endif
return getLibcallSignature(Subtarget, Val->second, Rets, Params);
}
Copied: llvm/trunk/test/CodeGen/WebAssembly/stack-protector.ll (from r359436, llvm/trunk/test/CodeGen/PowerPC/stack-protector.ll)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/stack-protector.ll?p2=llvm/trunk/test/CodeGen/WebAssembly/stack-protector.ll&p1=llvm/trunk/test/CodeGen/PowerPC/stack-protector.ll&r1=359436&r2=359505&rev=359505&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/PowerPC/stack-protector.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/stack-protector.ll Mon Apr 29 14:09:44 2019
@@ -1,12 +1,10 @@
-; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-linux < %s | FileCheck -check-prefix=LINUX32 %s
-; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux < %s | FileCheck -check-prefix=LINUX64 %s
-; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux < %s | FileCheck -check-prefix=LINUX64 %s
+; RUN: llc -verify-machineinstrs -mtriple=wasm32-unknown-unknown < %s | FileCheck -check-prefix=WASM32 %s
-; LINUX32: lwz {{[0-9]+}}, -28680(2)
-; LINUX64: ld {{[0-9]+}}, -28688(13)
+; WASM32: i32.load 28
+; WASM32-NEXT: i32.sub
+; WASM32-NEXT: br_if 0
-; LINUX32: __stack_chk_fail
-; LINUX64: __stack_chk_fail
+; WASM32: __stack_chk_fail
@"\01LC" = internal constant [11 x i8] c"buf == %s\0A\00" ; <[11 x i8]*> [#uses=1]
More information about the llvm-commits
mailing list