forked from OSchip/llvm-project
[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
This commit is contained in:
parent
fc08cfb888
commit
63838d8814
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue