Shorten IMMEDIATE_CRASH() code size on win clang

[email protected], [email protected]
BUG=664209,694670

Review-Url: https://codereview.chromium.org/2710703003
Cr-Commit-Position: refs/heads/master@{#451857}
diff --git a/base/logging.h b/base/logging.h
index 8e448aba..e1982eb6 100644
--- a/base/logging.h
+++ b/base/logging.h
@@ -556,14 +556,16 @@
 // instruction following the __debugbreak() to have it emit distinct locations
 // for CHECKs rather than collapsing them all together. It would be nice to use
 // a short intrinsic to do this (and perhaps have only one implementation for
-// both clang and MSVC), however clang-cl currently does not support intrinsics
-// here. Adding the nullptr store to the MSVC path adds unnecessary bloat.
+// both clang and MSVC), however clang-cl currently does not support intrinsics.
+// On the flip side, MSVC x64 doesn't support inline asm. So, we have to have
+// two implementations. Normally clang-cl's version will be 5 bytes (1 for
+// `int3`, 2 for `ud2`, 2 for `push byte imm`, however, TODO(scottmg):
+// https://crbug.com/694670 clang-cl doesn't currently support %'ing
+// __COUNTER__, so eventually it will emit the dword form of push.
 // TODO(scottmg): Reinvestigate a short sequence that will work on both
 // compilers once clang supports more intrinsics. See https://crbug.com/693713.
 #if defined(__clang__)
-#define IMMEDIATE_CRASH()                                                 \
-  (__debugbreak(), (void)(*reinterpret_cast<volatile unsigned char*>(0) = \
-                              static_cast<unsigned char>(__COUNTER__)))
+#define IMMEDIATE_CRASH() ({__asm int 3 __asm ud2 __asm push __COUNTER__})
 #else
 #define IMMEDIATE_CRASH() __debugbreak()
 #endif  // __clang__