File tree Expand file tree Collapse file tree 1 file changed +22
-2
lines changed
Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -1613,8 +1613,28 @@ void Target::SetExecutableModule(ModuleSP &executable_sp,
16131613 added_modules.AppendIfNeeded (image_module_sp, false );
16141614 ObjectFile *objfile = image_module_sp->GetObjectFile ();
16151615 if (objfile) {
1616- std::lock_guard<std::mutex> guard (dependent_files_mutex);
1617- objfile->GetDependentModules (dependent_files);
1616+ // Create a local copy of the dependent file list so we don't have
1617+ // to lock for the whole duration of GetDependentModules.
1618+ FileSpecList dependent_files_copy;
1619+ {
1620+ std::lock_guard<std::mutex> guard (dependent_files_mutex);
1621+ dependent_files_copy = dependent_files;
1622+ }
1623+
1624+ // Remember the size of the local copy so we can append only the
1625+ // modules that have been added by GetDependentModules.
1626+ const size_t previous_dependent_files =
1627+ dependent_files_copy.GetSize ();
1628+
1629+ objfile->GetDependentModules (dependent_files_copy);
1630+
1631+ {
1632+ std::lock_guard<std::mutex> guard (dependent_files_mutex);
1633+ for (size_t i = previous_dependent_files;
1634+ i < dependent_files_copy.GetSize (); ++i)
1635+ dependent_files.AppendIfUnique (
1636+ dependent_files_copy.GetFileSpecAtIndex (i));
1637+ }
16181638 }
16191639 }
16201640 };
You can’t perform that action at this time.
0 commit comments