mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-05 13:26:55 +00:00
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
This commit is contained in:
@@ -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.
|
||||
|
Reference in New Issue
Block a user