diff options
author | Lang Hames <lhames@gmail.com> | 2021-09-17 16:18:19 +1000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2021-09-17 16:58:23 +1000 |
commit | 63838d88145feaeb839efff8f40ab1e98597e423 (patch) | |
tree | ea17c81fac88f98ef6cb345436386f224fdcf34a /llvm/lib/ExecutionEngine/SectionMemoryManager.cpp | |
parent | fc08cfb8884db2f0a871479f7fc640e364a9ffe9 (diff) | |
download | llvm-63838d88145feaeb839efff8f40ab1e98597e423.zip llvm-63838d88145feaeb839efff8f40ab1e98597e423.tar.gz llvm-63838d88145feaeb839efff8f40ab1e98597e423.tar.bz2 |
[examples] Fix SectionMemoryManager deconstruction error with MSVC.
This commit fixes an order-of-initialization issue: If the default mmapper
object is destroyed while some global SectionMemoryManager is still using it
then calls to the mapper from ~SectionMemoryManager will fail. This issue was
causing failures when running the LLVM Kaleidoscope examples on windows.
Switching to a ManagedStatic solves the initialization order issue.
Patch by Justice Adams. Thanks Justice!
Reviewed By: lhames
Differential Revision: https://reviews.llvm.org/D107087
Diffstat (limited to 'llvm/lib/ExecutionEngine/SectionMemoryManager.cpp')
-rw-r--r-- | llvm/lib/ExecutionEngine/SectionMemoryManager.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/ExecutionEngine/SectionMemoryManager.cpp b/llvm/lib/ExecutionEngine/SectionMemoryManager.cpp index 6690dd0..9a1fb31 100644 --- a/llvm/lib/ExecutionEngine/SectionMemoryManager.cpp +++ b/llvm/lib/ExecutionEngine/SectionMemoryManager.cpp @@ -13,6 +13,7 @@ #include "llvm/ExecutionEngine/SectionMemoryManager.h" #include "llvm/Config/config.h" +#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/Process.h" @@ -264,10 +265,10 @@ public: } }; -DefaultMMapper DefaultMMapperInstance; +ManagedStatic<DefaultMMapper> DefaultMMapperInstance; } // namespace SectionMemoryManager::SectionMemoryManager(MemoryMapper *MM) - : MMapper(MM ? *MM : DefaultMMapperInstance) {} + : MMapper(MM ? *MM : *DefaultMMapperInstance) {} } // namespace llvm |