summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2012-11-21 11:12:57 +0000
committerAlexey Samsonov <samsonov@google.com>2012-11-21 11:12:57 +0000
commit3a3488e4e172461fa787afc170c4bf61ddaba98c (patch)
tree12bdd88cc4ee7a55e56ec37abd0e233b022e3fcb
parent9ca2afd3a114c93b58f0826c69eb3a370b5a3d6a (diff)
downloadbcm5719-llvm-3a3488e4e172461fa787afc170c4bf61ddaba98c.tar.gz
bcm5719-llvm-3a3488e4e172461fa787afc170c4bf61ddaba98c.zip
[Sanitizer] replace while with internal_memset to make sure compiler won't replace it with library memset
llvm-svn: 168422
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_printf.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_printf.cc b/compiler-rt/lib/sanitizer_common/sanitizer_printf.cc
index 93838487173..7c2705f5995 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_printf.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_printf.cc
@@ -45,7 +45,12 @@ static int AppendUnsigned(char **buff, const char *buff_end, u64 num,
num_buffer[pos++] = num % base;
num /= base;
} while (num > 0);
- while (pos < minimal_num_length) num_buffer[pos++] = 0;
+ if (pos < minimal_num_length) {
+ // Make sure compiler doesn't insert call to memset here.
+ internal_memset(&num_buffer[pos], 0,
+ sizeof(num_buffer[0]) * (minimal_num_length - pos));
+ pos = minimal_num_length;
+ }
int result = 0;
while (pos-- > 0) {
uptr digit = num_buffer[pos];
OpenPOWER on IntegriCloud