[compiler-rt] r212715 - [msan] Fix performance issue in fast_memset.
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Thu Jul 10 05:45:57 PDT 2014
Author: eugenis
Date: Thu Jul 10 07:45:56 2014
New Revision: 212715
URL: http://llvm.org/viewvc/llvm-project?rev=212715&view=rev
Log:
[msan] Fix performance issue in fast_memset.
Fast path was never triggered when called from __msan_poison.
Modified:
compiler-rt/trunk/lib/msan/msan_interceptors.cc
Modified: compiler-rt/trunk/lib/msan/msan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_interceptors.cc?rev=212715&r1=212714&r2=212715&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/msan/msan_interceptors.cc Thu Jul 10 07:45:56 2014
@@ -1264,13 +1264,14 @@ void *fast_memset(void *ptr, int c, SIZE
// hack until we have a really fast internal_memset
if (sizeof(uptr) == 8 &&
(n % 8) == 0 &&
- ((uptr)ptr % 8) == 0 &&
- (c == 0 || c == -1)) {
- // Printf("memset %p %zd %x\n", ptr, n, c);
- uptr to_store = c ? -1L : 0L;
+ ((uptr)ptr % 8) == 0) {
+ uptr c8 = (unsigned)c & 0xFF;
+ c8 = (c8 << 8) | c8;
+ c8 = (c8 << 16) | c8;
+ c8 = (c8 << 32) | c8;
uptr *p = (uptr*)ptr;
for (SIZE_T i = 0; i < n / 8; i++)
- p[i] = to_store;
+ p[i] = c8;
return ptr;
}
return internal_memset(ptr, c, n);
More information about the llvm-commits
mailing list