diff options
author | Nate Begeman <natebegeman@mac.com> | 2008-05-21 16:34:48 +0000 |
---|---|---|
committer | Nate Begeman <natebegeman@mac.com> | 2008-05-21 16:34:48 +0000 |
commit | f049e07eb8930214941c72f8e4409df394de1567 (patch) | |
tree | 2b341c3d5caa02213a284f8f01296fa2aa115897 /lib/ExecutionEngine/ExecutionEngine.cpp | |
parent | a3f334362f86a70fd11196dd49358662579c21a3 (diff) |
Fix a couple issues with the JIT and multiple modules:
1. The "JITState" object creates a PassManager with the ModuleProvider that the
jit is created with. If the ModuleProvider is removed and deleted, the
PassManager is invalid.
2. The Global maps in the JIT were not invalidated with a ModuleProvider was
removed. This could lead to a case where the Module would be freed, and a
new Module with Globals at the same addresses could return invalid results.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51384 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/ExecutionEngine.cpp')
-rw-r--r-- | lib/ExecutionEngine/ExecutionEngine.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp index 535f4ac90f..8b94ad0284 100644 --- a/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/lib/ExecutionEngine/ExecutionEngine.cpp @@ -59,6 +59,7 @@ Module* ExecutionEngine::removeModuleProvider(ModuleProvider *P, ModuleProvider *MP = *I; if (MP == P) { Modules.erase(I); + clearGlobalMappingsFromModule(MP->getModule()); return MP->releaseModule(ErrInfo); } } @@ -106,6 +107,22 @@ void ExecutionEngine::clearAllGlobalMappings() { state.getGlobalAddressReverseMap(locked).clear(); } +/// clearGlobalMappingsFromModule - Clear all global mappings that came from a +/// particular module, because it has been removed from the JIT. +void ExecutionEngine::clearGlobalMappingsFromModule(Module *M) { + MutexGuard locked(lock); + + for (Module::iterator FI = M->begin(), FE = M->end(); FI != FE; ++FI) { + state.getGlobalAddressMap(locked).erase(FI); + state.getGlobalAddressReverseMap(locked).erase(FI); + } + for (Module::global_iterator GI = M->global_begin(), GE = M->global_end(); + GI != GE; ++GI) { + state.getGlobalAddressMap(locked).erase(GI); + state.getGlobalAddressReverseMap(locked).erase(GI); + } +} + /// updateGlobalMapping - Replace an existing mapping for GV with a new /// address. This updates both maps as required. If "Addr" is null, the /// entry for the global is removed from the mappings. |