Skip to content

[lldb] Make use of target triple in TypeSystemSwiftTypeRef #6692

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

Conversation

kastiglione
Copy link

@kastiglione kastiglione commented Apr 20, 2023

Update TypeSystemSwiftTypeRef::GetTriple to make use of an available target.

With this change, GetNameImporter can work in more cases, since it only needs a triple. And since GetNameImporter can be expected to return a ClangNameImporter instance, the fallback to using Swift ASTContexts can be removed.

This eliminates another case of unnecessarily loading Swift ASTContexts, which incurs a one time overhead that should only be paid when required.

Partial follow up to #6654

@kastiglione
Copy link
Author

@swift-ci test

Copy link

@adrian-prantl adrian-prantl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have only one minor, but important comment about the unreachable.

return module->GetArchitecture().GetTriple();
else if (auto target_sp = GetTargetWP().lock())
return target_sp->GetArchitecture().GetTriple();
llvm_unreachable("Expected module or target");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be reachable if you run type system queries without a target. There is nothing in the SBAPI that prevents someone from doing this, so we shouldn't crash. Maybe lldb_assert() or logging?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks. It's now changed to a log.

else
assert(false && "Expected module or target");

llvm::Triple triple = GetTriple();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This lgtm.

@kastiglione
Copy link
Author

@swift-ci test

@kastiglione
Copy link
Author

@swift-ci test windows

1 similar comment
@kastiglione
Copy link
Author

@swift-ci test windows

@kastiglione
Copy link
Author

@adrian-prantl after removing this assert, is this good?

@kastiglione kastiglione merged commit f097595 into swift/release/5.9 Apr 25, 2023
@kastiglione kastiglione deleted the dl/lldb-make-use-of-target-triple-in-typesystemswifttyperef branch April 25, 2023 22:45
kastiglione added a commit that referenced this pull request May 5, 2023
Update `TypeSystemSwiftTypeRef::GetTriple` to make use of an available target.

With this change, `GetNameImporter` can work in more cases, since it only needs a 
triple. And since `GetNameImporter` can be expected to return a `ClangNameImporter` 
instance, the fallback to using Swift ASTContexts can be removed.

This eliminates another case of unnecessarily loading Swift ASTContexts, which incurs a 
one time overhead that should only be paid when required.

Partial follow up to #6654

(cherry-picked from commit f097595)
kastiglione added a commit that referenced this pull request May 5, 2023
…6790)

Update `TypeSystemSwiftTypeRef::GetTriple` to make use of an available target.

With this change, `GetNameImporter` can work in more cases, since it only needs a 
triple. And since `GetNameImporter` can be expected to return a `ClangNameImporter` 
instance, the fallback to using Swift ASTContexts can be removed.

This eliminates another case of unnecessarily loading Swift ASTContexts, which incurs a 
one time overhead that should only be paid when required.

Partial follow up to #6654

(cherry-picked from commit f097595)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants