@@ -1290,7 +1290,7 @@ class SharedModuleList {
12901290 to_remove.ForEach ([&](auto &m) {
12911291 auto it = m_module_configs.find (m.get ());
12921292 if (it != m_module_configs.end ()) {
1293- m_cas_cache.erase (it->second . get () );
1293+ m_cas_cache.erase (it->second );
12941294 m_module_configs.erase (it);
12951295 }
12961296 return IterationAction::Continue;
@@ -1314,13 +1314,10 @@ class SharedModuleList {
13141314public:
13151315 // / Each module may have a CAS config associated with it.
13161316 // / Often many modules share the same CAS.
1317- llvm::DenseMap<const Module *, std::shared_ptr<llvm::cas::CASConfiguration>>
1318- m_module_configs;
1319-
1320- llvm::StringMap<std::weak_ptr<llvm::cas::CASConfiguration>> m_cas_configs;
1317+ llvm::DenseMap<const Module *, llvm::cas::CASConfiguration> m_module_configs;
13211318
13221319 // / Each CAS config has a CAS associated with it.
1323- llvm::DenseMap<const llvm::cas::CASConfiguration * ,
1320+ llvm::DenseMap<llvm::cas::CASConfiguration,
13241321 std::pair<std::shared_ptr<llvm::cas::ObjectStore>,
13251322 std::shared_ptr<llvm::cas::ActionCache>>>
13261323 m_cas_cache;
@@ -1357,22 +1354,19 @@ static SharedModuleList &GetSharedModuleList() {
13571354 return GetSharedModuleListInfo ().module_list ;
13581355}
13591356
1360- static std::shared_ptr< llvm::cas::CASConfiguration>
1357+ static llvm::cas::CASConfiguration
13611358GetCASConfiguration (FileSpec CandidateConfigSearchPath) {
13621359 // Config CAS from properties.
13631360 auto &props = ModuleList::GetGlobalModuleListProperties ();
13641361 auto path = props.GetCASOnDiskPath ().GetPath ();
13651362 if (!path.empty ()) {
1366- auto config = std::make_shared<llvm::cas::CASConfiguration>();
1367- config->CASPath = props.GetCASOnDiskPath ().GetPath ();
1368- config->PluginPath = props.GetCASPluginPath ().GetPath ();
1369- config->PluginOptions = props.GetCASPluginOptions ();
1370- return config;
1363+ return {props.GetCASOnDiskPath ().GetPath (),
1364+ props.GetCASPluginPath ().GetPath (), props.GetCASPluginOptions ()};
13711365 }
13721366 auto search_config = llvm::cas::CASConfiguration::createFromSearchConfigFile (
13731367 CandidateConfigSearchPath.GetPath ());
13741368 if (search_config)
1375- return std::make_shared<llvm::cas::CASConfiguration>( search_config->second ) ;
1369+ return search_config->second ;
13761370
13771371 return {};
13781372}
@@ -1679,7 +1673,7 @@ static llvm::Expected<bool> loadModuleFromCASImpl(llvm::StringRef cas_id,
16791673
16801674 // Swap out the module_spec with the one loaded via CAS.
16811675 FileSpec cas_spec;
1682- cas_spec.SetDirectory (ConstString (maybe_cas->configuration -> CASPath ));
1676+ cas_spec.SetDirectory (ConstString (maybe_cas->configuration . CASPath ));
16831677 cas_spec.SetFilename (ConstString (cas_id));
16841678 ModuleSpec loaded (cas_spec, module_spec.GetUUID (), std::move (file_buffer));
16851679 loaded.GetArchitecture () = module_spec.GetArchitecture ();
@@ -1707,7 +1701,7 @@ static llvm::Expected<bool> loadModuleFromCAS(llvm::StringRef cas_id,
17071701 return result;
17081702}
17091703
1710- static std::shared_ptr< llvm::cas::CASConfiguration>
1704+ static llvm::cas::CASConfiguration
17111705FindCASConfiguration (const ModuleSP &module_sp) {
17121706 auto get_dir = [](FileSpec path) {
17131707 path.ClearFilename ();
@@ -1716,7 +1710,7 @@ FindCASConfiguration(const ModuleSP &module_sp) {
17161710
17171711 // Look near the binary / dSYM.
17181712 std::set<FileSpec> unique_paths;
1719- std::shared_ptr< llvm::cas::CASConfiguration> cas_config =
1713+ llvm::cas::CASConfiguration cas_config =
17201714 GetCASConfiguration (module_sp->GetFileSpec ());
17211715
17221716 if (!cas_config) {
@@ -1762,10 +1756,9 @@ ModuleList::GetOrCreateCAS(const ModuleSP &module_sp) {
17621756 auto &shared_module_list = GetSharedModuleListInfo ();
17631757 std::scoped_lock<std::mutex> lock (shared_module_list.shared_lock );
17641758 auto &module_configs = shared_module_list.module_list .m_module_configs ;
1765- auto &cas_configs = shared_module_list.module_list .m_cas_configs ;
17661759 auto &cas_cache = shared_module_list.module_list .m_cas_cache ;
17671760
1768- std::shared_ptr< llvm::cas::CASConfiguration> cas_config;
1761+ llvm::cas::CASConfiguration cas_config;
17691762 {
17701763 auto cached_config = module_configs.find (module_sp.get ());
17711764 if (cached_config != module_configs.end ()) {
@@ -1777,15 +1770,6 @@ ModuleList::GetOrCreateCAS(const ModuleSP &module_sp) {
17771770
17781771 if (!cas_config) {
17791772 cas_config = FindCASConfiguration (module_sp);
1780- if (cas_config) {
1781- // Unique the configuration. This assumes that no two configs
1782- // with different plugins share the same path.
1783- auto it = cas_configs.find (cas_config->CASPath );
1784- if (it != cas_configs.end ())
1785- if (auto unique_config = it->second .lock ())
1786- cas_config = unique_config;
1787- cas_configs.insert ({cas_config->CASPath , cas_config});
1788- }
17891773 // Cache the config or lack thereof.
17901774 module_configs.insert ({module_sp.get (), cas_config});
17911775 }
@@ -1795,7 +1779,7 @@ ModuleList::GetOrCreateCAS(const ModuleSP &module_sp) {
17951779
17961780 // Look in the cache.
17971781 {
1798- auto cached = cas_cache.find (cas_config. get () );
1782+ auto cached = cas_cache.find (cas_config);
17991783 if (cached != cas_cache.end ()) {
18001784 if (!cached->second .first )
18011785 return llvm::createStringError (
@@ -1806,15 +1790,16 @@ ModuleList::GetOrCreateCAS(const ModuleSP &module_sp) {
18061790 }
18071791
18081792 // Create the CAS.
1809- auto cas = cas_config-> createDatabases ();
1793+ auto cas = cas_config. createDatabases ();
18101794 if (!cas) {
1811- cas_cache.insert ({cas_config. get () , {}});
1795+ cas_cache.insert ({cas_config, {}});
18121796 return cas.takeError ();
18131797 }
18141798
18151799 LLDB_LOG (GetLog (LLDBLog::Modules | LLDBLog::Symbols),
1816- " Initialized CAS at {0}" , cas_config->CASPath );
1817- cas_cache.insert ({cas_config.get (), {cas->first , cas->second }});
1800+ " Initialized CAS at {0}" , cas_config.CASPath );
1801+ assert (cas_config);
1802+ cas_cache.insert ({cas_config, {cas->first , cas->second }});
18181803 return ModuleList::CAS{cas_config, cas->first , cas->second };
18191804}
18201805
0 commit comments