[compiler-rt] r193098 - Use internal_memset to initialize this variable.

David Blaikie dblaikie at gmail.com
Mon Oct 21 11:19:15 PDT 2013


On Mon, Oct 21, 2013 at 11:11 AM, Peter Collingbourne <peter at pcc.me.uk>wrote:

> Author: pcc
> Date: Mon Oct 21 13:11:57 2013
> New Revision: 193098
>
> URL: http://llvm.org/viewvc/llvm-project?rev=193098&view=rev
> Log:
> Use internal_memset to initialize this variable.
>
> Otherwise, the compiler may use memset in non-optimized builds, which is
> forbidden in the nolibc part of the runtime.
>

Are there no flags you can pass to the compiler to just ensure that doesn't
happen?

Do we need a comment on this code to explain why it shouldn't be
transformed into the prior form? And/or a build check to ensure that
anything with memsets, etc, fails the build?


>
> Modified:
>     compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
>
> Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc?rev=193098&r1=193097&r2=193098&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc (original)
> +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc Mon Oct 21
> 13:11:57 2013
> @@ -218,7 +218,8 @@ uptr GetTid() {
>  }
>
>  u64 NanoTime() {
> -  kernel_timeval tv = {};
> +  kernel_timeval tv;
> +  internal_memset(&tv, 0, sizeof(tv));
>    internal_syscall(__NR_gettimeofday, &tv, 0);
>    return (u64)tv.tv_sec * 1000*1000*1000 + tv.tv_usec * 1000;
>  }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131021/77f2f51d/attachment.html>


More information about the llvm-commits mailing list