Skip to content

[lldb] Disable conformance loading by default #9915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lldb/include/lldb/Core/ModuleList.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class ModuleListProperties : public Properties {
bool GetUseSwiftDWARFImporter() const;
bool SetUseSwiftDWARFImporter(bool new_value);
bool GetSwiftValidateTypeSystem() const;
bool GetSwiftLoadConformances() const;
SwiftModuleLoadingMode GetSwiftModuleLoadingMode() const;
bool SetSwiftModuleLoadingMode(SwiftModuleLoadingMode);

Expand Down
3 changes: 3 additions & 0 deletions lldb/source/Core/CoreProperties.td
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ let Definition = "modulelist" in {
def SwiftValidateTypeSystem: Property<"swift-validate-typesystem", "Boolean">,
DefaultFalse,
Desc<"Validate all Swift typesystem queries. Used for testing an asserts-enabled LLDB only.">;
def SwiftLoadConformances: Property<"swift-load-conformances", "Boolean">,
DefaultFalse,
Desc<"Resolve type alias via the conformance section. Disabled for performance reasons">;
def SwiftModuleLoadingMode: Property<"swift-module-loading-mode", "Enum">,
DefaultEnumValue<"eSwiftModuleLoadingModePreferSerialized">,
EnumValues<"OptionEnumValues(g_swift_module_loading_mode_enums)">,
Expand Down
6 changes: 6 additions & 0 deletions lldb/source/Core/ModuleList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,12 @@ bool ModuleListProperties::GetSwiftValidateTypeSystem() const {
idx, g_modulelist_properties[idx].default_uint_value != 0);
}

bool ModuleListProperties::GetSwiftLoadConformances() const {
const uint32_t idx = ePropertySwiftLoadConformances;
return GetPropertyAtIndexAs<bool>(
idx, g_modulelist_properties[idx].default_uint_value != 0);
}

SwiftModuleLoadingMode ModuleListProperties::GetSwiftModuleLoadingMode() const {
const uint32_t idx = ePropertySwiftModuleLoadingMode;
return GetPropertyAtIndexAs<SwiftModuleLoadingMode>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3102,13 +3102,11 @@ SwiftLanguageRuntime::ResolveTypeAlias(CompilerType alias) {
return llvm::createStringError("no reflection context");

// FIXME: The current implementation that loads all conformances
// up-front creates too much small memory traffic. As a stop-gap,
// disable the feature on remote devices.
auto &triple = GetProcess().GetTarget().GetArchitecture().GetTriple();
if (triple.isOSDarwin() && !triple.isTargetMachineMac())
return llvm::createStringError("conformance loading disabled on remote "
"devices for performance reasons");

// up-front creates too much small memory traffic during the
// LookupTypeWitness step.
if (!ModuleList::GetGlobalModuleListProperties().GetSwiftLoadConformances())
return llvm::createStringError("conformance loading disabled in settings");

for (const std::string &protocol : GetConformances(in_type)) {
auto *type_ref =
reflection_ctx->LookupTypeWitness(in_type, member, protocol);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def test(self):
"""Test that type aliases can be imported from reflection metadata"""
arch = self.getArchitecture()
self.build()
self.expect('settings set symbols.swift-load-conformances true')
log = self.getBuildArtifact("types.log")
self.runCmd('log enable lldb expr types -f "%s"' % log)
lldbutil.run_to_source_breakpoint(
Expand Down