Skip to content

[Async CC] Test: Mark functions that call async functions async. #34402

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

Conversation

nate-chandler
Copy link
Contributor

To unblock the SIL verification that async functions are called only from async functions, update the tests to meet this invariant. To enable this, in particular, @main had to be marked @async until Task.runDetached is available. To allow that, a couple of small workaround were commited in their own commit. Reverting that commit when possible is tracked by rdar://problem/70597390.

This process revealed an issue with AsyncContextLayout's usage of NecessaryBindings. Specifically, if an async function happens to use the same generic parameter twice, space was only made in the layout for one usage. That can't work for async callees which actually have two distinct generic parameters since they will need to bind the two distinct generic parameters separately since in general they will not be the same type even though at a particular call site they happened to be the same. To address this, make NecessaryBindings use a vector rather than a set to collection generic requirements.

@nate-chandler nate-chandler marked this pull request as draft October 23, 2020 01:13
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@nate-chandler nate-chandler force-pushed the concurrency/irgen/tests-all-async branch 2 times, most recently from c532dd0 to 22dbea9 Compare October 23, 2020 18:05
…indings.

Previously, NecessaryBindings used a SetVector to store the
GenericRequirements that it accumulates.  That was a problem for the
layout of async contexts where it is possible for the same generic
argument to be repeated.  Meanwhile, that is correct for partial
application forwarders where there is a single thunk for every partial
apply and consequently the bindings can be packed in without
duplication.

Here, a SetVector is used only when the NecessaryBindings are for
partial apply forwarders.  When the NecessaryBindings are instead for
async functions, a SmallVector is used.
Previously the execution tests for the async calling convention ignored
the rule that callers of async functions must themselves be async.
Failing to obey that rule prevented landing of the SIL verification
change that enforces that rule.  Here, the tests are modified to satisfy
that rule so that the SIL verification change can be landed.
@nate-chandler nate-chandler force-pushed the concurrency/irgen/tests-all-async branch from 22dbea9 to a963d0a Compare October 23, 2020 18:10
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@nate-chandler nate-chandler marked this pull request as ready for review October 23, 2020 18:13
@nate-chandler
Copy link
Contributor Author

@swift-ci please test windows platform

@nate-chandler nate-chandler merged commit d1bfe02 into swiftlang:main Oct 26, 2020
@nate-chandler nate-chandler deleted the concurrency/irgen/tests-all-async branch October 26, 2020 16:59
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.

1 participant