Commit aa46953c by Nicolas Capens Committed by Nicolas Capens

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: 's avatarAlexis Hétu <sugoi@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent b3177eb4
...@@ -15,25 +15,13 @@ ...@@ -15,25 +15,13 @@
#ifndef sw_Primitive_hpp #ifndef sw_Primitive_hpp
#define sw_Primitive_hpp #define sw_Primitive_hpp
#include "Memset.hpp"
#include "Vertex.hpp" #include "Vertex.hpp"
#include "Device/Config.hpp" #include "Device/Config.hpp"
#include "System/Build.hpp"
namespace sw { namespace sw {
struct Triangle MEMORY_SANITIZER_ONLY( struct Triangle
: Memset<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 v0;
Vertex v1; Vertex v1;
Vertex v2; Vertex v2;
...@@ -46,18 +34,8 @@ struct PlaneEquation // z = A * x + B * y + C ...@@ -46,18 +34,8 @@ struct PlaneEquation // z = A * x + B * y + C
float4 C; float4 C;
}; };
struct Primitive MEMORY_SANITIZER_ONLY( struct Primitive
: Memset<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 yMin;
int yMax; int yMax;
......
...@@ -15,25 +15,12 @@ ...@@ -15,25 +15,12 @@
#ifndef Build_hpp #ifndef Build_hpp
#define 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). // sanitizer enabled (-fsanitize=memory).
#if defined(__SANITIZE_MEMORY__) #if defined(__clang__) && __has_feature(memory_sanitizer)
# define MEMORY_SANITIZER_ENABLED 1 # define MEMORY_SANITIZER 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
#else #else
# define MEMORY_SANITIZER_ONLY(x) # define MEMORY_SANITIZER 0
#endif // MEMORY_SANITIZER_ENABLED #endif
#endif // Build_hpp #endif // Build_hpp
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment