llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-driver Author: Yuta Saito (kateinoigakukun) <details> <summary>Changes</summary> I'm working on porting ASan to Wasm/WASI targets, and this is the first part of the change sets. I'll post runtime changes separately. This change makes `-fsanitize=address` available for WASI target by replicating what we do for Emscripten because they share the same memory model. --- Full diff: https://github.com/llvm/llvm-project/pull/139014.diff 2 Files Affected: - (modified) clang/lib/Driver/ToolChains/WebAssembly.cpp (+6-1) - (modified) llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp (+4-4) ``````````diff diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp b/clang/lib/Driver/ToolChains/WebAssembly.cpp index cd12f2ae5a6de..9fcc33728c1ad 100644 --- a/clang/lib/Driver/ToolChains/WebAssembly.cpp +++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp @@ -545,8 +545,13 @@ void WebAssembly::AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args, SanitizerMask WebAssembly::getSupportedSanitizers() const { SanitizerMask Res = ToolChain::getSupportedSanitizers(); if (getTriple().isOSEmscripten()) { - Res |= SanitizerKind::Vptr | SanitizerKind::Leak | SanitizerKind::Address; + Res |= SanitizerKind::Vptr | SanitizerKind::Leak; } + + if (getTriple().isOSEmscripten() || getTriple().isOSWASI()) { + Res |= SanitizerKind::Address; + } + // -fsanitize=function places two words before the function label, which are // -unsupported. Res &= ~SanitizerKind::Function; diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index c1dba77c3532b..840a5e3f31dfd 100644 --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -118,7 +118,7 @@ static const uint64_t kNetBSD_ShadowOffset64 = 1ULL << 46; static const uint64_t kNetBSDKasan_ShadowOffset64 = 0xdfff900000000000; static const uint64_t kPS_ShadowOffset64 = 1ULL << 40; static const uint64_t kWindowsShadowOffset32 = 3ULL << 28; -static const uint64_t kEmscriptenShadowOffset = 0; +static const uint64_t kWebAssemblyShadowOffset = 0; // The shadow memory space is dynamically allocated. static const uint64_t kWindowsShadowOffset64 = kDynamicShadowSentinel; @@ -499,9 +499,9 @@ static ShadowMapping getShadowMapping(const Triple &TargetTriple, int LongSize, bool IsRISCV64 = TargetTriple.getArch() == Triple::riscv64; bool IsWindows = TargetTriple.isOSWindows(); bool IsFuchsia = TargetTriple.isOSFuchsia(); - bool IsEmscripten = TargetTriple.isOSEmscripten(); bool IsAMDGPU = TargetTriple.isAMDGPU(); bool IsHaiku = TargetTriple.isOSHaiku(); + bool IsWasm = TargetTriple.isWasm(); ShadowMapping Mapping; @@ -525,8 +525,8 @@ static ShadowMapping getShadowMapping(const Triple &TargetTriple, int LongSize, Mapping.Offset = kDynamicShadowSentinel; else if (IsWindows) Mapping.Offset = kWindowsShadowOffset32; - else if (IsEmscripten) - Mapping.Offset = kEmscriptenShadowOffset; + else if (IsWasm) + Mapping.Offset = kWebAssemblyShadowOffset; else Mapping.Offset = kDefaultShadowOffset32; } else { // LongSize == 64 `````````` </details> https://github.com/llvm/llvm-project/pull/139014 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits