[PATCH] D107087: Fix SectionMemoryManager deconstruction error with MSVC
Justice Adams via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 2 17:19:10 PDT 2021
justice_adams updated this revision to Diff 376726.
justice_adams added a comment.
use shared_ptrs
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D107087/new/
https://reviews.llvm.org/D107087
Files:
llvm/include/llvm/ExecutionEngine/SectionMemoryManager.h
llvm/lib/ExecutionEngine/SectionMemoryManager.cpp
Index: llvm/lib/ExecutionEngine/SectionMemoryManager.cpp
===================================================================
--- llvm/lib/ExecutionEngine/SectionMemoryManager.cpp
+++ 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"
@@ -101,7 +102,7 @@
// FIXME: Initialize the Near member for each memory group to avoid
// interleaving.
std::error_code ec;
- sys::MemoryBlock MB = MMapper.allocateMappedMemory(
+ sys::MemoryBlock MB = MMapper->allocateMappedMemory(
Purpose, RequiredSize, &MemGroup.Near,
sys::Memory::MF_READ | sys::Memory::MF_WRITE, ec);
if (ec) {
@@ -204,7 +205,7 @@
SectionMemoryManager::applyMemoryGroupPermissions(MemoryGroup &MemGroup,
unsigned Permissions) {
for (sys::MemoryBlock &MB : MemGroup.PendingMem)
- if (std::error_code EC = MMapper.protectMappedMemory(MB, Permissions))
+ if (std::error_code EC = MMapper->protectMappedMemory(MB, Permissions))
return EC;
MemGroup.PendingMem.clear();
@@ -234,7 +235,7 @@
SectionMemoryManager::~SectionMemoryManager() {
for (MemoryGroup *Group : {&CodeMem, &RWDataMem, &RODataMem}) {
for (sys::MemoryBlock &Block : Group->AllocatedMem)
- MMapper.releaseMappedMemory(Block);
+ MMapper->releaseMappedMemory(Block);
}
}
@@ -263,11 +264,9 @@
return sys::Memory::releaseMappedMemory(M);
}
};
-
-DefaultMMapper DefaultMMapperInstance;
} // namespace
-SectionMemoryManager::SectionMemoryManager(MemoryMapper *MM)
- : MMapper(MM ? *MM : DefaultMMapperInstance) {}
+SectionMemoryManager::SectionMemoryManager(std::shared_ptr<MemoryMapper> MM)
+ : MMapper(MM ? MM : std::make_shared<DefaultMMapper>()) {}
} // namespace llvm
Index: llvm/include/llvm/ExecutionEngine/SectionMemoryManager.h
===================================================================
--- llvm/include/llvm/ExecutionEngine/SectionMemoryManager.h
+++ llvm/include/llvm/ExecutionEngine/SectionMemoryManager.h
@@ -104,7 +104,7 @@
/// Creates a SectionMemoryManager instance with \p MM as the associated
/// memory mapper. If \p MM is nullptr then a default memory mapper is used
/// that directly calls into the operating system.
- SectionMemoryManager(MemoryMapper *MM = nullptr);
+ SectionMemoryManager(std::shared_ptr<MemoryMapper> = nullptr);
SectionMemoryManager(const SectionMemoryManager &) = delete;
void operator=(const SectionMemoryManager &) = delete;
~SectionMemoryManager() override;
@@ -185,7 +185,7 @@
MemoryGroup CodeMem;
MemoryGroup RWDataMem;
MemoryGroup RODataMem;
- MemoryMapper &MMapper;
+ std::shared_ptr<MemoryMapper> MMapper;
};
} // end namespace llvm
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107087.376726.patch
Type: text/x-patch
Size: 2912 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211003/a2bda06c/attachment.bin>
More information about the llvm-commits
mailing list