From 3a3488e4e172461fa787afc170c4bf61ddaba98c Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Wed, 21 Nov 2012 11:12:57 +0000 Subject: [PATCH] [Sanitizer] replace while with internal_memset to make sure compiler won't replace it with library memset llvm-svn: 168422 --- compiler-rt/lib/sanitizer_common/sanitizer_printf.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_printf.cc b/compiler-rt/lib/sanitizer_common/sanitizer_printf.cc index 9383848..7c2705f 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]; -- 2.7.4