Skip to content

Commit

Permalink
Merge pull request #42097 from kateinoigakukun/katei/workaround-retur…
Browse files Browse the repository at this point in the history
…naddress-wasm

[Wasm] Disable use of `returnaddress` in exclusivity diagnostics
  • Loading branch information
kateinoigakukun committed Apr 2, 2022
2 parents ed23f4f + d99b84e commit ecf8a35
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/IRGen/IRGenSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5765,7 +5765,9 @@ void IRGenSILFunction::visitBeginUnpairedAccessInst(
// in which case we should use the caller, which is generally ok because
// materializeForSet can't usually be thunked.
llvm::Value *pc;
if (hasBeenInlined(access)) {
// Wasm doesn't have returnaddress because it can't access call frame
// for security purposes
if (IGM.Triple.isWasm() || hasBeenInlined(access)) {
pc = llvm::ConstantPointerNull::get(IGM.Int8PtrTy);
} else {
auto retAddrFn =
Expand Down
3 changes: 3 additions & 0 deletions stdlib/public/runtime/Exclusivity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
#elif _MSC_VER
#include <intrin.h>
#define get_return_address() _ReturnAddress()
#elif defined(__wasm__)
// Wasm can't access call frame for security purposes
#define get_return_address() ((void*) 0)
#else
#error missing implementation for get_return_address
#define get_return_address() ((void*) 0)
Expand Down

0 comments on commit ecf8a35

Please sign in to comment.