]> Savannah Git Hosting - gnulib.git/commitdiff
explicit_bzero: Add support for clang.
authorBastien Roucariès <rouca@debian.org>
Sat, 23 Jan 2021 11:22:10 +0000 (11:22 +0000)
committerBruno Haible <bruno@clisp.org>
Sat, 23 Jan 2021 13:22:18 +0000 (14:22 +0100)
* lib/explicit_bzero.c (explicit_bzero): Add a compiler barrier for
clang.

ChangeLog
lib/explicit_bzero.c

index 8fa2e1535f7e3fb000f750e6e57154d0c50b7e9c..e7101e1bf19fe191258de37591b1cd07b289f754 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2021-01-23  Bastien Roucariès  <rouca@debian.org>
+
+       explicit_bzero: Add support for clang.
+       * lib/explicit_bzero.c (explicit_bzero): Add a compiler barrier for
+       clang.
+
 2021-01-21  Paul Eggert  <eggert@cs.ucla.edu>
 
        Port FALLTHROUGH to clang 3.4 and earlier
index 87fadba81ac66e8dab000c7d2587837fa47906fe..4eb057462bf7995c447dfb205b099a1b64cb3fde 100644 (file)
@@ -59,6 +59,12 @@ explicit_bzero (void *s, size_t len)
 # if defined __GNUC__ && !defined __clang__
   /* Compiler barrier.  */
   asm volatile ("" ::: "memory");
+# elif defined __clang__
+  /* Compiler barrier.  */
+  /* With asm ("" ::: "memory") LLVM analyzes uses of 's' and finds that the
+     whole thing is dead and eliminates it.  Use 'g' to work around this
+     problem.  See <https://bugs.llvm.org/show_bug.cgi?id=15495#c11>.  */
+  __asm__ volatile ("" : : "g"(s) : "memory");
 # endif
 #endif
 }