[PATCH] D50562: [sanitizer] Remove st(X) from the clobber list in 32-bit x86 atomics

Kostya Kortchinsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 10 08:34:45 PDT 2018


cryptoad created this revision.
cryptoad added reviewers: eugenis, vitalybuka.
Herald added subscribers: Sanitizers, jfb, delcypher, kubamracek.

When compiling with `WERROR=ON` & a recent clang, having the `st(?)` registers
in the clobber list produces a fatal error (except `st(7)` for some reason):

  .../sanitizer_common/sanitizer_atomic_clang_x86.h:98:9: error: inline asm clobber list contains reserved registers: ST0, ST1, ST2, ST3, ST4, ST5, ST6 [-Werror,-Winline-asm]
          "movq %1, %%mm0;"  // Use mmx reg for 64-bit atomic moves
          ^
  <inline asm>:1:1: note: instantiated into assembly here
          movq 8(%esp), %mm0;movq %mm0, (%esi);emms;
  ^
  .../sanitizer_common/sanitizer_atomic_clang_x86.h:98:9: note: Reserved registers on the clobber list may not be preserved across the asm statement, and clobbering them may lead to undefined behaviour.
          "movq %1, %%mm0;"  // Use mmx reg for 64-bit atomic moves
          ^
  <inline asm>:1:1: note: instantiated into assembly here
          movq 8(%esp), %mm0;movq %mm0, (%esi);emms;
  ^

As far as I can tell, they were in there due to the use of the `emms`
instruction, but removing the clobber doesn't appear to have a functional
impact. I am unsure if there is a better way to address this.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D50562

Files:
  lib/sanitizer_common/sanitizer_atomic_clang_x86.h


Index: lib/sanitizer_common/sanitizer_atomic_clang_x86.h
===================================================================
--- lib/sanitizer_common/sanitizer_atomic_clang_x86.h
+++ lib/sanitizer_common/sanitizer_atomic_clang_x86.h
@@ -61,8 +61,7 @@
         "emms;"            // Empty mmx state/Reset FP regs
         : "=m" (v)
         : "m" (a->val_dont_use)
-        : // mark the FP stack and mmx registers as clobbered
-          "st", "st(1)", "st(2)", "st(3)", "st(4)", "st(5)", "st(6)", "st(7)",
+        : // mark the mmx registers as clobbered
 #ifdef __MMX__
           "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7",
 #endif  // #ifdef __MMX__
@@ -100,8 +99,7 @@
         "emms;"            // Empty mmx state/Reset FP regs
         : "=m" (a->val_dont_use)
         : "m" (v)
-        : // mark the FP stack and mmx registers as clobbered
-          "st", "st(1)", "st(2)", "st(3)", "st(4)", "st(5)", "st(6)", "st(7)",
+        : // mark the mmx registers as clobbered
 #ifdef __MMX__
           "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7",
 #endif  // #ifdef __MMX__


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50562.160114.patch
Type: text/x-patch
Size: 1104 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180810/cd365a59/attachment-0001.bin>


More information about the llvm-commits mailing list