Skip to content

Commit ecf8a35

Browse files
Merge pull request #42097 from kateinoigakukun/katei/workaround-returnaddress-wasm
[Wasm] Disable use of `returnaddress` in exclusivity diagnostics
2 parents ed23f4f + d99b84e commit ecf8a35

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/IRGen/IRGenSIL.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5765,7 +5765,9 @@ void IRGenSILFunction::visitBeginUnpairedAccessInst(
57655765
// in which case we should use the caller, which is generally ok because
57665766
// materializeForSet can't usually be thunked.
57675767
llvm::Value *pc;
5768-
if (hasBeenInlined(access)) {
5768+
// Wasm doesn't have returnaddress because it can't access call frame
5769+
// for security purposes
5770+
if (IGM.Triple.isWasm() || hasBeenInlined(access)) {
57695771
pc = llvm::ConstantPointerNull::get(IGM.Int8PtrTy);
57705772
} else {
57715773
auto retAddrFn =

stdlib/public/runtime/Exclusivity.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
#elif _MSC_VER
4343
#include <intrin.h>
4444
#define get_return_address() _ReturnAddress()
45+
#elif defined(__wasm__)
46+
// Wasm can't access call frame for security purposes
47+
#define get_return_address() ((void*) 0)
4548
#else
4649
#error missing implementation for get_return_address
4750
#define get_return_address() ((void*) 0)

0 commit comments

Comments
 (0)