68
68
69
69
#include " llvm/ADT/ScopeExit.h"
70
70
#include " llvm/ADT/SetVector.h"
71
- #include " llvm/Support/ThreadPool.h"
72
71
73
72
#include < memory>
74
73
#include < mutex>
@@ -1576,6 +1575,7 @@ void Target::SetExecutableModule(ModuleSP &executable_sp,
1576
1575
m_arch.GetSpec ().GetTriple ().getTriple ());
1577
1576
}
1578
1577
1578
+ FileSpecList dependent_files;
1579
1579
ObjectFile *executable_objfile = executable_sp->GetObjectFile ();
1580
1580
bool load_dependents = true ;
1581
1581
switch (load_dependent_files) {
@@ -1591,14 +1591,10 @@ void Target::SetExecutableModule(ModuleSP &executable_sp,
1591
1591
}
1592
1592
1593
1593
if (executable_objfile && load_dependents) {
1594
- // FileSpecList is not thread safe and needs to be synchronized.
1595
- FileSpecList dependent_files;
1596
- std::mutex dependent_files_mutex;
1597
-
1598
- // ModuleList is thread safe.
1599
1594
ModuleList added_modules;
1600
-
1601
- auto GetDependentModules = [&](FileSpec dependent_file_spec) {
1595
+ executable_objfile->GetDependentModules (dependent_files);
1596
+ for (uint32_t i = 0 ; i < dependent_files.GetSize (); i++) {
1597
+ FileSpec dependent_file_spec (dependent_files.GetFileSpecAtIndex (i));
1602
1598
FileSpec platform_dependent_file_spec;
1603
1599
if (m_platform_sp)
1604
1600
m_platform_sp->GetFileWithUUID (dependent_file_spec, nullptr ,
@@ -1612,48 +1608,9 @@ void Target::SetExecutableModule(ModuleSP &executable_sp,
1612
1608
if (image_module_sp) {
1613
1609
added_modules.AppendIfNeeded (image_module_sp, false );
1614
1610
ObjectFile *objfile = image_module_sp->GetObjectFile ();
1615
- if (objfile) {
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
- }
1638
- }
1639
- }
1640
- };
1641
-
1642
- executable_objfile->GetDependentModules (dependent_files);
1643
-
1644
- llvm::ThreadPoolTaskGroup task_group (Debugger ::GetThreadPool ());
1645
- for (uint32_t i = 0 ; i < dependent_files.GetSize (); i++) {
1646
- // Process all currently known dependencies in parallel in the innermost
1647
- // loop. This may create newly discovered dependencies to be appended to
1648
- // dependent_files. We'll deal with these files during the next
1649
- // iteration of the outermost loop.
1650
- {
1651
- std::lock_guard<std::mutex> guard (dependent_files_mutex);
1652
- for (; i < dependent_files.GetSize (); i++)
1653
- task_group.async (GetDependentModules,
1654
- dependent_files.GetFileSpecAtIndex (i));
1611
+ if (objfile)
1612
+ objfile->GetDependentModules (dependent_files);
1655
1613
}
1656
- task_group.wait ();
1657
1614
}
1658
1615
ModulesDidLoad (added_modules);
1659
1616
}
0 commit comments