Disable MSan in Swiftshader JIT
There are a number of tests that are (silently) failing with errors in
Swiftshader's JIT, e.g.
==218683==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x7f0d6b006d68 in ?? ??:0
SUMMARY: MemorySanitizer: use-of-uninitialized-value
(/memfd:swiftshader_jit (deleted)+0xd68)
ORIGIN: invalid (0). Might be a bug in MemorySanitizer origin tracking.
This could still be a bug in your code, too!
In an ideal world, there would be an investigation and a fix for these
reports. In practice, this is not happening as Swiftshader is no longer
actively maintained; in fact, Swiftshader is being removed as a fallback
for WebGL (crbug.com/40277080).
Per the LLVM documentation, omitting the llvm::Attribute::SanitizeMemory
annotation for a JIT function has the same effect as applying
` __attribute__((no_sanitize("memory")))` to C++ functions. This should
suppress the errors and unblock enabling more accurate MSan error
detection in tests.
Bug: 40267022
Change-Id: I3c201fcbae9b7563d327eb5ca358ebcbd242ea8a
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/73568
Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
Commit-Queue: Yuly Novikov <ynovikov@chromium.org>
Presubmit-Ready: Shahbaz Youssefi <syoussefi@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Shahbaz Youssefi <syoussefi@google.com>
Tested-by: Shahbaz Youssefi <syoussefi@google.com>
diff --git a/src/Reactor/LLVMReactor.cpp b/src/Reactor/LLVMReactor.cpp
index aa4aaaa..dda6d91 100644
--- a/src/Reactor/LLVMReactor.cpp
+++ b/src/Reactor/LLVMReactor.cpp
@@ -494,21 +494,6 @@
func->setDoesNotThrow();
func->setCallingConv(llvm::CallingConv::C);
- if(__has_feature(memory_sanitizer))
- {
- func->addFnAttr(llvm::Attribute::SanitizeMemory);
-
- // Assume that when using recent versions of LLVM, MemorySanitizer enabled builds
- // use -fsanitize-memory-param-retval, which makes the caller not update the shadow
- // of function parameters. NoUndef skips generating checks for uninitialized values.
-#if LLVM_VERSION_MAJOR >= 13
- for(unsigned int i = 0; i < params.size(); i++)
- {
- func->addParamAttr(i, llvm::Attribute::NoUndef);
- }
-#endif
- }
-
if(__has_feature(address_sanitizer))
{
func->addFnAttr(llvm::Attribute::SanitizeAddress);