Skip to content

Allow normal function results of @yield_once coroutines #69843

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 2 commits into from
Feb 7, 2024
Merged

Conversation

asl
Copy link
Contributor

@asl asl commented Nov 14, 2023

This adds SIL-level support and LLVM codegen for normal results of a coroutine.

The main user of this will be autodiff as VJP of a coroutine must be a coroutine itself (in order to produce the yielded result) and return a pullback closure as a normal result.

The LLVM IR codegen depends on the following patch from LLVM mainline: swiftlang/llvm-project@51d5d7b (that is already a part of apple/llvm-project/next)

For now only direct results are supported, but this seems to be enough for autodiff purposes.

@asl asl requested a review from rjmccall November 14, 2023 08:03
@asl
Copy link
Contributor Author

asl commented Nov 14, 2023

Tagging @rxwei @BradLarson

@asl asl force-pushed the end-apply-result branch from 414f7ee to 848f223 Compare November 15, 2023 17:17
@asl
Copy link
Contributor Author

asl commented Nov 15, 2023

@rjmccall @hborla @slavapestov @xedin Note that we cannot run the tests as we need to have the corresponding LLVM change in stable branch first. However, then we'd also need to make a corresponding IRgen change (as LLVM API changes are not backward compatible), so we're having mutual interdependence between changes.

Let me know how this is usually resolved in swift repo.

@rxwei
Copy link
Contributor

rxwei commented Nov 15, 2023

What's the corresponding LLVM branch this should be tested against? I think you can do cross-PR testing, for example:

apple/llvm-project#<PR number>
@ swift-ci please test

@asl
Copy link
Contributor Author

asl commented Nov 15, 2023

What's the corresponding LLVM branch this should be tested against? I think you can do cross-PR testing, for example:

apple/llvm-project#<PR number>
@ swift-ci please test

Ah, ok. Let me try this! Thanks.

@asl
Copy link
Contributor Author

asl commented Nov 15, 2023

Please test with swiftlang/llvm-project#7797
@swift-ci please test

@asl asl force-pushed the end-apply-result branch from 848f223 to 06ba7b3 Compare November 15, 2023 21:43
@asl
Copy link
Contributor Author

asl commented Nov 15, 2023

Please test with swiftlang/llvm-project#7797
@swift-ci please test

@asl asl force-pushed the end-apply-result branch 2 times, most recently from 9153998 to 650b0bb Compare November 17, 2023 01:43
@asl
Copy link
Contributor Author

asl commented Nov 17, 2023

Please test with swiftlang/llvm-project#7797
@swift-ci please test

@asl
Copy link
Contributor Author

asl commented Nov 17, 2023

@rxwei @rjmccall @hborla @slavapestov @xedin
Tests passed (cross-repo), please check when you will have a chance

@asl
Copy link
Contributor Author

asl commented Nov 28, 2023

@hborla
Copy link
Member

hborla commented Nov 30, 2023

Hey @asl, apologies for the delay, many folks have been out of office the last few weeks. I'm not the right person to review this change (and I suspect Pavel isn't either; we were only automatically tagged because of the minor change in AST/Types.h). @rjmccall or @jckarter are probably the right reviewers, and they are both OOO this week.

@asl
Copy link
Contributor Author

asl commented Nov 30, 2023

Hey @asl, apologies for the delay, many folks have been out of office the last few weeks. I'm not the right person to review this change (and I suspect Pavel isn't either; we were only automatically tagged because of the minor change in AST/Types.h). @rjmccall or @jckarter are probably the right reviewers, and they are both OOO this week.

Thanks! Yeah, waiting mostly for @rjmccall – we discussed this during the last US LLVM Dev Meeting.

@tbkka
Copy link
Contributor

tbkka commented Nov 30, 2023

CC: @nate-chandler and @atrick

@xedin xedin removed their request for review December 5, 2023 01:18
@asl asl force-pushed the end-apply-result branch 2 times, most recently from c037b2d to 2ea10a6 Compare December 7, 2023 00:13
@asl
Copy link
Contributor Author

asl commented Dec 7, 2023

Please test with swiftlang/llvm-project#7797
@swift-ci please test

@asl
Copy link
Contributor Author

asl commented Dec 7, 2023

Please test with swiftlang/llvm-project#7797
@swift-ci please test macos platform

@asl
Copy link
Contributor Author

asl commented Dec 7, 2023

@rjmccall ping

@asl asl force-pushed the end-apply-result branch from 2ea10a6 to 4c28e9f Compare December 7, 2023 06:23
@asl
Copy link
Contributor Author

asl commented Dec 7, 2023

Please test with swiftlang/llvm-project#7797
@swift-ci please test

Copy link
Contributor

@rjmccall rjmccall left a comment

Choose a reason for hiding this comment

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

I'm not sure I get the LLVM IR pattern that we're emitting here. There's a coro.end.results instruction that may or may not be tied to the coro.end with the token? What do we do to register the direct results on the unwind path?

@asl
Copy link
Contributor Author

asl commented Jan 5, 2024

Please test with swiftlang/llvm-project#7797
@swift-ci please test

@asl asl force-pushed the end-apply-result branch from 82744aa to 11ddcf7 Compare January 5, 2024 19:50
@asl
Copy link
Contributor Author

asl commented Jan 5, 2024

Please test with swiftlang/llvm-project#7797
@swift-ci please test

@asl
Copy link
Contributor Author

asl commented Jan 15, 2024

@rxwei @rjmccall @hborla @jckarter

Is there something that could be done to move this PR forward? It's in the review for ~2 months and is currently blocking submission of several other PRs. And it is required to be rebased each time module format is changed...

Thanks!

@asl
Copy link
Contributor Author

asl commented Jan 22, 2024

@rjmccall Friendly weekly ping. Thanks!

@asl
Copy link
Contributor Author

asl commented Jan 29, 2024

@rjmccall @rxwei @hborla Another ping, thanks!

@asl asl force-pushed the end-apply-result branch from 11ddcf7 to 9efc2ac Compare February 6, 2024 18:49
@asl asl requested a review from kavon as a code owner February 6, 2024 18:49
@asl
Copy link
Contributor Author

asl commented Feb 6, 2024

Please test with swiftlang/llvm-project#7797
@swift-ci please test

Copy link
Contributor

@rjmccall rjmccall left a comment

Choose a reason for hiding this comment

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

Alright, let's move forward here.

@asl
Copy link
Contributor Author

asl commented Feb 6, 2024

Alright, let's move forward here.

Thanks a lot! Much appreciated

@asl asl force-pushed the end-apply-result branch from 9efc2ac to b06b0db Compare February 6, 2024 21:27
@asl
Copy link
Contributor Author

asl commented Feb 6, 2024

Please test with swiftlang/llvm-project#7797
@swift-ci please test

@asl asl force-pushed the end-apply-result branch from b06b0db to 11fc0d9 Compare February 7, 2024 00:27
@asl
Copy link
Contributor Author

asl commented Feb 7, 2024

Please test with swiftlang/llvm-project#7797
@swift-ci please test

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.

5 participants