Skip to content

Requestify LifetimeDependenceInfo #72916

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 8 commits into from
Apr 9, 2024
Merged

Conversation

meg-gupta
Copy link
Contributor

@meg-gupta meg-gupta commented Apr 8, 2024

Use the request evaluator method to query LifetimeDependenceInfo

With this change, LifetimeDependenceInfo is serialized in both explicit and inferred cases. And on deserialization, LifetimeDependenceInfo is cached on the decl, so that InterfaceTypeRequest does not have to recompute this info.

Also piggybacking some minor changes.

Query and cache lifetime dependence info via evaluator requests
@meg-gupta
Copy link
Contributor Author

@swift-ci test

@meg-gupta
Copy link
Contributor Author

@swift-ci build toolchain

@meg-gupta
Copy link
Contributor Author

@swift-ci smoke test

}

std::optional<LifetimeDependenceInfo>
LifetimeDependenceInfo::infer(AbstractFunctionDecl *afd, Type resultType) {
LifetimeDependenceInfo::infer(AbstractFunctionDecl *afd) {
Copy link
Contributor

Choose a reason for hiding this comment

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

In a subsequent PR, please refactor this logic so that LifetimeDependence methods are implemented in AST. Perhaps these functions can just be static, if they're only used in the implementation of the request evaluate() method?

Copy link
Contributor Author

@meg-gupta meg-gupta Apr 9, 2024

Choose a reason for hiding this comment

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

Will do.

@@ -3098,3 +3097,9 @@ ImplicitKnownProtocolConformanceRequest::evaluate(Evaluator &evaluator,
llvm_unreachable("non-implicitly derived KnownProtocol");
}
}

std::optional<LifetimeDependenceInfo>
LifetimeDependenceInfoRequest::evaluate(Evaluator &evaluator,
Copy link
Contributor

Choose a reason for hiding this comment

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

You can move this into lib/Sema/LifetimeDependence.cpp, and turn LifetimeDependence::get() into a static method

@meg-gupta meg-gupta merged commit 4b440a1 into swiftlang:main Apr 9, 2024
@tbkka
Copy link
Contributor

tbkka commented Apr 15, 2024

Should this be cherry-picked to 6.0? Or is it too intrusive a change?

@meg-gupta
Copy link
Contributor Author

@tbkka created cherry pick here - #73004
Was waiting for some other PRs to merge to avoid merge conflict.

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.

3 participants