[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