[Kaleidoscope] Fix race condition in order-of-destruction between SectionMemoryManage...
authorStefan Gränitz <stefan.graenitz@gmail.com>
Wed, 5 Jul 2023 12:28:47 +0000 (14:28 +0200)
committerStefan Gränitz <stefan.graenitz@gmail.com>
Wed, 5 Jul 2023 12:48:03 +0000 (14:48 +0200)
commit9ce06411994e9bcaa98c219c7dc34c2824353a81
tree0f99c98ef290fb0743ea62ff7486b8036e9d3eff
parent5f1ba3a5020acdac4a7368f19b074577b5a6da8c
[Kaleidoscope] Fix race condition in order-of-destruction between SectionMemoryManager and its MemoryMapper

SectionMemoryManager's default memory mapper used to be a global static
object. If the SectionMemoryManager itself is a global static
object, it might be destroyed after its memory mapper and thus couldn't
use it from the destructor.

The Kaleidoscope tutorial reproduced this situation with MSVC for a long time.
Since 47f5c54f997a59bb2c65 it's triggered with GCC as well. The solution from
this patch was proposed in the existing review https://reviews.llvm.org/D107087
before, but it didn't move forward.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D154338
llvm/include/llvm/ExecutionEngine/SectionMemoryManager.h
llvm/lib/ExecutionEngine/SectionMemoryManager.cpp