forked from OSchip/llvm-project
[ORC] Add a mutex to guard EHFrameRegistrationPlugin data structures.
These may be accessed from multiple threads if concurrent materialization is enabled in ORC. Testcase coming in a follow-up patch that enables eh-frame registration for LLJIT.
This commit is contained in:
parent
2411f56bfd
commit
214a9f0dd4
|
@ -184,6 +184,7 @@ private:
|
|||
size_t Size;
|
||||
};
|
||||
|
||||
std::mutex EHFramePluginMutex;
|
||||
jitlink::EHFrameRegistrar &Registrar;
|
||||
DenseMap<MaterializationResponsibility *, EHFrameRange> InProcessLinks;
|
||||
DenseMap<VModuleKey, EHFrameRange> TrackedEHFrameRanges;
|
||||
|
|
|
@ -529,18 +529,21 @@ EHFrameRegistrationPlugin::EHFrameRegistrationPlugin(
|
|||
void EHFrameRegistrationPlugin::modifyPassConfig(
|
||||
MaterializationResponsibility &MR, const Triple &TT,
|
||||
PassConfiguration &PassConfig) {
|
||||
assert(!InProcessLinks.count(&MR) && "Link for MR already being tracked?");
|
||||
|
||||
PassConfig.PostFixupPasses.push_back(
|
||||
createEHFrameRecorderPass(TT, [this, &MR](JITTargetAddress Addr,
|
||||
size_t Size) {
|
||||
if (Addr)
|
||||
InProcessLinks[&MR] = { Addr, Size };
|
||||
PassConfig.PostFixupPasses.push_back(createEHFrameRecorderPass(
|
||||
TT, [this, &MR](JITTargetAddress Addr, size_t Size) {
|
||||
if (Addr) {
|
||||
std::lock_guard<std::mutex> Lock(EHFramePluginMutex);
|
||||
assert(!InProcessLinks.count(&MR) &&
|
||||
"Link for MR already being tracked?");
|
||||
InProcessLinks[&MR] = {Addr, Size};
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
Error EHFrameRegistrationPlugin::notifyEmitted(
|
||||
MaterializationResponsibility &MR) {
|
||||
std::lock_guard<std::mutex> Lock(EHFramePluginMutex);
|
||||
|
||||
auto EHFrameRangeItr = InProcessLinks.find(&MR);
|
||||
if (EHFrameRangeItr == InProcessLinks.end())
|
||||
|
@ -560,6 +563,8 @@ Error EHFrameRegistrationPlugin::notifyEmitted(
|
|||
}
|
||||
|
||||
Error EHFrameRegistrationPlugin::notifyRemovingModule(VModuleKey K) {
|
||||
std::lock_guard<std::mutex> Lock(EHFramePluginMutex);
|
||||
|
||||
auto EHFrameRangeItr = TrackedEHFrameRanges.find(K);
|
||||
if (EHFrameRangeItr == TrackedEHFrameRanges.end())
|
||||
return Error::success();
|
||||
|
@ -573,6 +578,7 @@ Error EHFrameRegistrationPlugin::notifyRemovingModule(VModuleKey K) {
|
|||
}
|
||||
|
||||
Error EHFrameRegistrationPlugin::notifyRemovingAllModules() {
|
||||
std::lock_guard<std::mutex> Lock(EHFramePluginMutex);
|
||||
|
||||
std::vector<EHFrameRange> EHFrameRanges =
|
||||
std::move(UntrackedEHFrameRanges);
|
||||
|
|
Loading…
Reference in New Issue