Remove zero initialization of Triangle and Primitive
These structures were zero-initialized to work around MSan false-
positives. Now that Reactor routines can be instrumented, we can omit
the initialization and detect whether they are properly set by the
normal code paths.
Bug: b/155148722
Change-Id: Ic1136f08b5203531ffc2eda15e7d64d7c2a0d8c5
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/49890
Presubmit-Ready: Nicolas Capens <nicolascapens@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Device/Primitive.hpp b/src/Device/Primitive.hpp
index 595a2f2..8a6672d 100644
--- a/src/Device/Primitive.hpp
+++ b/src/Device/Primitive.hpp
@@ -15,25 +15,13 @@
#ifndef sw_Primitive_hpp
#define sw_Primitive_hpp
-#include "Memset.hpp"
#include "Vertex.hpp"
#include "Device/Config.hpp"
-#include "System/Build.hpp"
namespace sw {
-struct Triangle MEMORY_SANITIZER_ONLY(
- : Memset<Triangle>)
+struct Triangle
{
-#if MEMORY_SANITIZER_ENABLED
- // Memory sanitizer cannot 'see' writes from JIT'd code, and can raise
- // false-positives when read. By clearing the struct in the constructor,
- // we can avoid triggering these false-positives.
- inline Triangle()
- : Memset<Triangle>(this, 0)
- {}
-#endif // MEMORY_SANITIZER_ENABLED
-
Vertex v0;
Vertex v1;
Vertex v2;
@@ -46,18 +34,8 @@
float4 C;
};
-struct Primitive MEMORY_SANITIZER_ONLY(
- : Memset<Primitive>)
+struct Primitive
{
-#if MEMORY_SANITIZER_ENABLED
- // Memory sanitizer cannot 'see' writes from JIT'd code, and can raise
- // false-positives when read. By clearing the struct in the constructor,
- // we can avoid triggering these false-positives.
- inline Primitive()
- : Memset<Primitive>(this, 0)
- {}
-#endif // MEMORY_SANITIZER_ENABLED
-
int yMin;
int yMax;
diff --git a/src/System/Build.hpp b/src/System/Build.hpp
index 788ece7..170a238 100644
--- a/src/System/Build.hpp
+++ b/src/System/Build.hpp
@@ -15,25 +15,12 @@
#ifndef Build_hpp
#define Build_hpp
-// Define MEMORY_SANITIZER_ENABLED to 1 if the project was build with the memory
+// Define MEMORY_SANITIZER to 1 if the project was build with the memory
// sanitizer enabled (-fsanitize=memory).
-#if defined(__SANITIZE_MEMORY__)
-# define MEMORY_SANITIZER_ENABLED 1
-#else // defined(__SANITIZE_MEMORY__)
-# if defined(__clang__)
-# if __has_feature(memory_sanitizer)
-# define MEMORY_SANITIZER_ENABLED 1
-# endif // __has_feature(memory_sanitizer)
-# endif // defined(__clang__)
-#endif // defined(__SANITIZE_MEMORY__)
-
-// MEMORY_SANITIZER_ONLY(X) resolves to X if MEMORY_SANITIZER_ENABLED is defined
-// to a non-zero value, otherwise MEMORY_SANITIZER_ONLY() is stripped by the
-// preprocessor.
-#if MEMORY_SANITIZER_ENABLED
-# define MEMORY_SANITIZER_ONLY(x) x
+#if defined(__clang__) && __has_feature(memory_sanitizer)
+# define MEMORY_SANITIZER 1
#else
-# define MEMORY_SANITIZER_ONLY(x)
-#endif // MEMORY_SANITIZER_ENABLED
+# define MEMORY_SANITIZER 0
+#endif
#endif // Build_hpp