aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/opts/SkBlitRow_opts_SSE2.cpp
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2016-02-03 07:25:02 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-02-03 07:25:02 -0800
commit1059b1fc9f8711592a81836512850d123d75146d (patch)
tree51559252569c0ade9b5b83129ee02fe55e0fbe76 /src/opts/SkBlitRow_opts_SSE2.cpp
parent69d160326659dcf64e1584018b713631ddbc061c (diff)
Add SkMSAN.h
This lets us tag up pieces of code as requiring initialized inputs. Almost all code requires initialized inputs, of course. This is for code that works correctly with uninitialized data but triggers false positive warnings in MSAN. E.g., imagine MSAN's found use of uninitialized data in this max function: static uint8_t max(uint8_t x, uint8_t y) { return x > y ? x : y; } There's no bug in here... if there's uninitialized data being branched upon here for the first time, it's sure not max's fault, it's its caller's fault. So we might do this: static uint8_t max(uint8_t x, uint8_t y) { // This function uses branching, so if MSAN finds a problem here, // we can assert x and y are initialized. This will remind us the // problem somewhere in the caller or above, not here. sk_msan_assert_initialized(&x, &x+1); sk_masn_assert_initialized(&y, &y+1); return x > y ? x : y; } By allowing code to assert its inputs must be initialized, we can make the blame for use of uninitialized data more clear. (Sometimes we have another option, to rewrite the code to avoid branching: static uint8_t max(uint8_t x, uint8_t y) { // This function is branchfree, so MSAN won't complain here. // No real need to assert anything as requiring initialization. int diff = x - y; int negative = diff >> (sizeof(int)*8 - 1); return (y & negative) | (x & ~negative); } These approaches to fixing MSAN false positives are orthogonal.) BUG=chromium:574114 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1658913005 CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot Review URL: https://codereview.chromium.org/1658913005
Diffstat (limited to 'src/opts/SkBlitRow_opts_SSE2.cpp')
-rw-r--r--src/opts/SkBlitRow_opts_SSE2.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/opts/SkBlitRow_opts_SSE2.cpp b/src/opts/SkBlitRow_opts_SSE2.cpp
index c017f7e4b3..3ca9a957f6 100644
--- a/src/opts/SkBlitRow_opts_SSE2.cpp
+++ b/src/opts/SkBlitRow_opts_SSE2.cpp
@@ -11,6 +11,7 @@
#include "SkColorPriv.h"
#include "SkColor_opts_SSE2.h"
#include "SkDither.h"
+#include "SkMSAN.h"
#include "SkUtils.h"
/* SSE2 version of S32_Blend_BlitRow32()
@@ -69,6 +70,8 @@ void S32_Blend_BlitRow32_SSE2(SkPMColor* SK_RESTRICT dst,
void S32A_Opaque_BlitRow32_SSE2(SkPMColor* SK_RESTRICT dst,
const SkPMColor* SK_RESTRICT src,
int count, U8CPU alpha) {
+ sk_msan_assert_initialized(src, src+count);
+
SkASSERT(alpha == 255);
if (count <= 0) {
return;