Skip to content

Commit 9a713f9

Browse files
committed
Get SwiftASTContextForExpression's SDK path straight from debug info.
This mostly-NFC patch cuts out the middle-person and directly parses the SDK info from the debug info in SwiftASTContextForExpression, rhus avoiding the costly need to iterate over all SwiftASTContext and the last call to warmup_contexts().
1 parent cfc58ce commit 9a713f9

File tree

4 files changed

+3
-43
lines changed

4 files changed

+3
-43
lines changed

lldb/include/lldb/Target/Target.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,6 @@ class TargetProperties : public Properties {
169169

170170
llvm::StringRef GetSwiftExtraClangFlags() const;
171171

172-
bool GetSwiftCreateModuleContextsInParallel() const;
173-
174172
bool GetSwiftReadMetadataFromFileCache() const;
175173

176174
bool GetSwiftUseReflectionSymbols() const;

lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2136,42 +2136,19 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(lldb::LanguageType language,
21362136
handled_sdk_path = true;
21372137
}
21382138

2139-
auto warmup_astcontexts = [&]() {
2140-
if (target.GetSwiftCreateModuleContextsInParallel()) {
2141-
// The first call to GetTypeSystemForLanguage() on a module will
2142-
// trigger the import (and thus most likely the rebuild) of all
2143-
// the Clang modules that were imported in this module. This can
2144-
// be a lot of work (potentially ten seconds per module), but it
2145-
// can be performed in parallel.
2146-
llvm::ThreadPool pool(llvm::hardware_concurrency());
2147-
for (size_t mi = 0; mi != num_images; ++mi) {
2148-
auto module_sp = target.GetImages().GetModuleAtIndex(mi);
2149-
pool.async([=] {
2150-
GetModuleSwiftASTContext(*module_sp);
2151-
});
2152-
}
2153-
pool.wait();
2154-
}
2155-
};
2156-
21572139
if (!handled_sdk_path) {
2158-
warmup_astcontexts();
21592140
for (size_t mi = 0; mi != num_images; ++mi) {
21602141
ModuleSP module_sp = target.GetImages().GetModuleAtIndex(mi);
21612142
if (!HasSwiftModules(*module_sp))
21622143
continue;
21632144

2164-
SwiftASTContext *module_swift_ast = GetModuleSwiftASTContext(*module_sp);
2165-
if (!module_swift_ast || module_swift_ast->HasFatalErrors() ||
2166-
!module_swift_ast->GetClangImporter())
2167-
continue;
2145+
std::string sdk_path = GetSDKPathFromDebugInfo(m_description, *module_sp);
21682146

2169-
StringRef platform_sdk_path = module_swift_ast->GetPlatformSDKPath();
2170-
if (platform_sdk_path.empty())
2147+
if (sdk_path.empty())
21712148
continue;
21722149

21732150
handled_sdk_path = true;
2174-
swift_ast_sp->SetPlatformSDKPath(platform_sdk_path);
2151+
swift_ast_sp->SetPlatformSDKPath(sdk_path);
21752152
break;
21762153
}
21772154
}

lldb/source/Target/Target.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4146,18 +4146,6 @@ void TargetProperties::SetInjectLocalVariables(ExecutionContext *exe_ctx,
41464146
true);
41474147
}
41484148

4149-
bool TargetProperties::GetSwiftCreateModuleContextsInParallel() const {
4150-
const Property *exp_property = m_collection_sp->GetPropertyAtIndex(
4151-
nullptr, false, ePropertyExperimental);
4152-
OptionValueProperties *exp_values =
4153-
exp_property->GetValue()->GetAsProperties();
4154-
if (exp_values)
4155-
return exp_values->GetPropertyAtIndexAsBoolean(
4156-
nullptr, ePropertySwiftCreateModuleContextsInParallel, true);
4157-
else
4158-
return true;
4159-
}
4160-
41614149
bool TargetProperties::GetSwiftReadMetadataFromFileCache() const {
41624150
const Property *exp_property = m_collection_sp->GetPropertyAtIndex(
41634151
nullptr, false, ePropertyExperimental);

lldb/source/Target/TargetProperties.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ let Definition = "target_experimental" in {
44
def InjectLocalVars : Property<"inject-local-vars", "Boolean">,
55
Global, DefaultTrue,
66
Desc<"If true, inject local variables explicitly into the expression text. This will fix symbol resolution when there are name collisions between ivars and local variables. But it can make expressions run much more slowly.">;
7-
def SwiftCreateModuleContextsInParallel : Property<"swift-create-module-contexts-in-parallel", "Boolean">,
8-
DefaultTrue,
9-
Desc<"Create the per-module Swift AST contexts in parallel.">;
107
def SwiftReadMetadataFromFileCache: Property<"swift-read-metadata-from-file-cache", "Boolean">,
118
DefaultTrue,
129
Desc<"Read Swift reflection metadata from the file cache instead of the process when possible">;

0 commit comments

Comments
 (0)