Skip to content

[embedded] Implement non-allocating embedded Swift mode, under -no-allocations flag #70314

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 5 commits into from
Dec 12, 2023

Conversation

kubamracek
Copy link
Contributor

This PR:

  • adds a -no-allocations compiler flag
  • only allows the flag to be used when embedded Swift is used
  • changes PerformanceDiagnostics to explicitly flag allocations if the new flag is used
  • changes PerformanceDiagnostics to walk the function bodies in a caller-callee way (like the other non-embedded PerformanceDiagnostics do) so that we get better diagnostics (parent locs)
  • add a test

@kubamracek
Copy link
Contributor Author

@swift-ci please test

@kubamracek kubamracek added the embedded Embedded Swift label Dec 9, 2023
@kubamracek
Copy link
Contributor Author

@swift-ci please test

1 similar comment
@kubamracek
Copy link
Contributor Author

@swift-ci please test

if (getModule()->getOptions().EmbeddedSwift) {
for (SILFunction &function : *module) {
// Don't check constructors and destructors directly, they will be
// checked if called from other functions, with better source loc info.
Copy link
Contributor

Choose a reason for hiding this comment

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

Not all constructors and destructors are directly called. For example, class destructors are implicitly called from destroy_value instructions.
Excluding them here means that they are potentially not checked at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, good point. What if instead of not checking them, I only changed the order in which we go over the SILFunctions, so that it's something like (1) public/external functions first, (2) vtable members without constructors/destructors, (3) constructors/destructors?

The motivation is strictly to get better diagnostics with better "called from here" information, I don't want to skip any checks.

Copy link
Contributor

Choose a reason for hiding this comment

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

I only changed the order in which we go over the SILFunctions

Sounds good!

…gnostics when diagnosing embedded Swift restrictions
@kubamracek
Copy link
Contributor Author

@swift-ci please test

Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

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

lgtm!

@kubamracek
Copy link
Contributor Author

@swift-ci please test

@kubamracek kubamracek merged commit 91956a1 into swiftlang:main Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
embedded Embedded Swift
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants