Page MenuHomePhabricator

[MSAN RT] Use __sanitizer::mem_is_zero in __msan_test_shadow
ClosedPublic

Authored by guiand on Jul 30 2020, 11:26 AM.

Details

Summary
The former function is particularly optimized for exactly the
use case we're interested in: an all-zero buffer.

This reduces the overhead of calling this function some 80% or
more. This is particularly for instrumenting code heavy with
string processing functions, like grep. An invocation of grep
with the pattern '[aeiou]k[aeiou]' has its runtime reduced by
~75% with this patch

Diff Detail

Event Timeline

guiand created this revision.Jul 30 2020, 11:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 30 2020, 11:26 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
guiand requested review of this revision.Jul 30 2020, 11:26 AM
eugenis added a reviewer: kcc.Jul 30 2020, 3:07 PM
vitalybuka added inline comments.Aug 6 2020, 4:03 PM
compiler-rt/lib/msan/msan.cpp
560

__builtin_clzll can do the trick, however you will need to check little/big endian
same for non-aligned parts
shadow is alligned, so you can read as 64bit

but I don't know if it will make a difference
if not, as is good enough

guiand updated this revision to Diff 283782.Aug 6 2020, 6:20 PM
guiand retitled this revision from [MSAN] Unroll and aggregate loops for __msan_test_shadow to [MSAN RT] Use __sanitizer::mem_is_zero in __msan_test_shadow.
guiand edited the summary of this revision. (Show Details)

Modified to just use __sanitizer::mem_is_zero

eugenis added inline comments.Aug 10 2020, 11:46 AM
compiler-rt/lib/msan/msan.cpp
535

use early exit

guiand updated this revision to Diff 284468.Aug 10 2020, 12:05 PM

Addressed comments

This revision is now accepted and ready to land.Aug 10 2020, 12:08 PM
This revision was landed with ongoing or failed builds.Aug 10 2020, 12:23 PM
This revision was automatically updated to reflect the committed changes.