@@ -2131,29 +2131,32 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(lldb::LanguageType language,
2131
2131
handled_sdk_path = true ;
2132
2132
}
2133
2133
2134
- if (target.GetSwiftCreateModuleContextsInParallel ()) {
2135
- // The first call to GetTypeSystemForLanguage() on a module will
2136
- // trigger the import (and thus most likely the rebuild) of all
2137
- // the Clang modules that were imported in this module. This can
2138
- // be a lot of work (potentially ten seconds per module), but it
2139
- // can be performed in parallel.
2140
- const unsigned threads =
2141
- repro::Reproducer::Instance ().IsReplaying () ? 1 : 0 ;
2142
- llvm::ThreadPool pool (llvm::hardware_concurrency (threads));
2143
- for (size_t mi = 0 ; mi != num_images; ++mi) {
2144
- auto module_sp = target.GetImages ().GetModuleAtIndex (mi);
2145
- pool.async ([=] {
2146
- auto val_or_err =
2147
- module_sp->GetTypeSystemForLanguage (lldb::eLanguageTypeSwift);
2148
- if (!val_or_err) {
2149
- llvm::consumeError (val_or_err.takeError ());
2150
- }
2151
- });
2134
+ auto warmup_astcontexts = [&]() {
2135
+ if (target.GetSwiftCreateModuleContextsInParallel ()) {
2136
+ // The first call to GetTypeSystemForLanguage() on a module will
2137
+ // trigger the import (and thus most likely the rebuild) of all
2138
+ // the Clang modules that were imported in this module. This can
2139
+ // be a lot of work (potentially ten seconds per module), but it
2140
+ // can be performed in parallel.
2141
+ const unsigned threads =
2142
+ repro::Reproducer::Instance ().IsReplaying () ? 1 : 0 ;
2143
+ llvm::ThreadPool pool (llvm::hardware_concurrency (threads));
2144
+ for (size_t mi = 0 ; mi != num_images; ++mi) {
2145
+ auto module_sp = target.GetImages ().GetModuleAtIndex (mi);
2146
+ pool.async ([=] {
2147
+ auto val_or_err =
2148
+ module_sp->GetTypeSystemForLanguage (lldb::eLanguageTypeSwift);
2149
+ if (!val_or_err) {
2150
+ llvm::consumeError (val_or_err.takeError ());
2151
+ }
2152
+ });
2153
+ }
2154
+ pool.wait ();
2152
2155
}
2153
- pool.wait ();
2154
- }
2156
+ };
2155
2157
2156
2158
if (!handled_sdk_path) {
2159
+ warmup_astcontexts ();
2157
2160
for (size_t mi = 0 ; mi != num_images; ++mi) {
2158
2161
ModuleSP module_sp = target.GetImages ().GetModuleAtIndex (mi);
2159
2162
if (!HasSwiftModules (*module_sp))
@@ -2268,6 +2271,7 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(lldb::LanguageType language,
2268
2271
const bool use_all_compiler_flags =
2269
2272
!got_serialized_options || target.GetUseAllCompilerFlags ();
2270
2273
2274
+ warmup_astcontexts ();
2271
2275
for (size_t mi = 0 ; mi != num_images; ++mi) {
2272
2276
std::vector<std::string> extra_clang_args;
2273
2277
ProcessModule (target.GetImages ().GetModuleAtIndex (mi), m_description,
0 commit comments