Emulate gather/scatter for MSan builds
MemorySanitizer doesn't support instrumenting masked_gather and
masked_scatter LLVM intrinsics. Its visitIntrinsicInst() method ends up
calling handleUnknownIntrinsic(), which silently doesn't handle it and
subsequently visitInstruction() checks all operands for poisoned bits.
In the case of a scatter, a 0 bit in the mask means the corresponding
element doesn't get written, so it doesn't matter if it's uninitialized
data. The current implementation leads to false positives.
Work around it by emulating gather and scatter as element-wise loads and
stores. This can be correctly instrumented by MemorySanitizer.
Note this change has no effect currently since we don't support MSan
instrumentation for Reactor yet. We just unpoison all stores. Previously
we did that in element-wise manner after the intrinsic executes. Now
it's done as part of the element stores.
Bug: b/155148722
Change-Id: I9058cd926667fb6df5d9626bc87fb2d0a596771b
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/49809Tested-by:
Nicolas Capens <nicolascapens@google.com>
Reviewed-by:
Antonio Maiorano <amaiorano@google.com>
Showing
This diff is collapsed.
Click to expand it.
Please
register
or
sign in
to comment