Fix crash during llvm_shutdown due to init order fiasco

Use the constexpr constructor for _MSC_VER >= 1925, otherwise
ManagedStatic will have a dynamic initializer, which depending on init
order, results in the Ptr field being overwritten with 0. This
eventually leads to multiple instances of the same ManagedStatic
instance in the StaticList, and asserts when double destroying during

I reported this bug [here](,
and learned that this bug had already been fixed in upstream LLVM.

Note that llvm_subzero already has a similar change, though for _MSC_VER
>= 1920. According to the LLVM comment, the VC++ compiler up until 1925
may still emit a dynamic initializer for a constexpr constructor, but I
suppose we never ran into that for Subzero, so I'll leave this as is.

Bug: b/175782868
Change-Id: Ice3944f67e496aa94f1a7ed7502b49e763d702b4
Kokoro-Result: kokoro <>
Reviewed-by: Alexis H├ętu <>
Tested-by: Antonio Maiorano <>
Commit-Queue: Antonio Maiorano <>
diff --git a/third_party/llvm-10.0/llvm/include/llvm/Support/ManagedStatic.h b/third_party/llvm-10.0/llvm/include/llvm/Support/ManagedStatic.h
index bbd0d04..f2b4142 100644
--- a/third_party/llvm-10.0/llvm/include/llvm/Support/ManagedStatic.h
+++ b/third_party/llvm-10.0/llvm/include/llvm/Support/ManagedStatic.h
@@ -40,8 +40,8 @@
 // constexpr, a dynamic initializer may be emitted depending on optimization
 // settings. For the affected versions of MSVC, use the old linker
 // initialization pattern of not providing a constructor and leaving the fields
-// uninitialized.
-#if !defined(_MSC_VER) || defined(__clang__)
+// uninitialized. See for details.
+#if !defined(_MSC_VER) || (_MSC_VER >= 1925) || defined(__clang__)