[PATCH] ubsan: Port runtime library to (32- and 64-bit) Windows.

Alexey Samsonov vonosmas at gmail.com
Tue Jun 30 18:21:25 PDT 2015


================
Comment at: lib/sanitizer_common/sanitizer_atomic_msvc.h:157
@@ -147,9 +156,3 @@
   DCHECK(!((uptr)a % sizeof(*a)));
-  __asm {
-    mov eax, a
-    mov cl, v
-    xchg [eax], cl  // NOLINT
-    mov v, cl
-  }
-  return v;
+  return (u8)_InterlockedExchange8((volatile char*)&a->val_dont_use, v);
 }
----------------
IIRC this is only available since Visual Studio 2013. I'm not aware of the minimum version we support, adding Reid.

================
Comment at: lib/ubsan/ubsan_diag.cc:189
@@ -188,1 +188,3 @@
         char Buffer[32];
+#if defined(_WIN32)
+        sprintf_s(Buffer, sizeof(Buffer), "%Lg", (long double)A.Float);
----------------
SANITIZER_WINDOWS

================
Comment at: lib/ubsan/ubsan_flags.cc:75
@@ +74,3 @@
+#if SANITIZER_WINDOWS
+const char *__ubsan_default_default_options() { return ""; }
+#pragma comment(linker, "/alternatename:__ubsan_default_options=__ubsan_default_default_options")
----------------
What does this function mean?

================
Comment at: lib/ubsan/ubsan_platform.h:20
@@ -20,1 +19,3 @@
+     defined(__aarch64__) || defined(__mips__) || defined(__powerpc64__)) || \
+     defined(_WIN32)
 # define CAN_SANITIZE_UB 1
----------------
Group OS together. Also, consider #including `sanitizer_platform.h` and using SANITIZER_LINUX, SANITIZER_WINDOWS etc.

http://reviews.llvm.org/D10856

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list