Skip to content

Commit e82544c

Browse files
Merge pull request swiftlang#35695 from nate-chandler/rdar73742483
[Async CC] Put extra sources before unfulfilled requirements.
2 parents 5210c3b + 0f7e368 commit e82544c

File tree

2 files changed

+47
-14
lines changed

2 files changed

+47
-14
lines changed

lib/IRGen/GenProto.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3061,20 +3061,6 @@ NecessaryBindings NecessaryBindings::computeBindings(
30613061
// Figure out what we're actually required to pass:
30623062
PolymorphicConvention convention(IGM, origType, considerParameterSources);
30633063

3064-
// - unfulfilled requirements
3065-
convention.enumerateUnfulfilledRequirements(
3066-
[&](GenericRequirement requirement) {
3067-
CanType type = requirement.TypeParameter.subst(subs)->getCanonicalType();
3068-
3069-
if (requirement.Protocol) {
3070-
auto conf = subs.lookupConformance(requirement.TypeParameter,
3071-
requirement.Protocol);
3072-
bindings.addProtocolConformance(type, conf);
3073-
} else {
3074-
bindings.addTypeMetadata(type);
3075-
}
3076-
});
3077-
30783064
// - extra sources
30793065
for (auto &source : convention.getSources()) {
30803066
switch (source.getKind()) {
@@ -3101,6 +3087,20 @@ NecessaryBindings NecessaryBindings::computeBindings(
31013087
llvm_unreachable("bad source kind");
31023088
}
31033089

3090+
// - unfulfilled requirements
3091+
convention.enumerateUnfulfilledRequirements(
3092+
[&](GenericRequirement requirement) {
3093+
CanType type = requirement.TypeParameter.subst(subs)->getCanonicalType();
3094+
3095+
if (requirement.Protocol) {
3096+
auto conf = subs.lookupConformance(requirement.TypeParameter,
3097+
requirement.Protocol);
3098+
bindings.addProtocolConformance(type, conf);
3099+
} else {
3100+
bindings.addTypeMetadata(type);
3101+
}
3102+
});
3103+
31043104
return bindings;
31053105
}
31063106

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency %s -emit-ir -parse-as-library -module-name main | %FileCheck %s --check-prefix=CHECK-LL
3+
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency %s -parse-as-library -module-name main -o %t/main %target-rpath(%t)
4+
// RUN: %target-codesign %t/main
5+
// RUN: %target-run %t/main | %FileCheck %s
6+
7+
// REQUIRES: executable_test
8+
// REQUIRES: swift_test_mode_optimize_none
9+
// REQUIRES: concurrency
10+
// UNSUPPORTED: use_os_stdlib
11+
12+
import _Concurrency
13+
14+
struct G<T> {
15+
// CHECK-LL: @"$s4main1GV19theMutatingFunctionyqd__qd__YlFTu" = hidden global %swift.async_func_pointer
16+
// CHECK-LL: define hidden swiftcc void @"$s4main1GV19theMutatingFunctionyqd__qd__YlF"(%swift.task* {{%[0-9]+}}, %swift.executor* {{%[0-9]+}}, %swift.context* swiftasync {{%[0-9]+}}) {{#[0-9]*}} {
17+
mutating func theMutatingFunction<U>(_ u: U) async -> U {
18+
return u
19+
}
20+
}
21+
22+
func theMutatingCaller<T, U>(_ g: inout G<T>, _ u: U) async -> U {
23+
return await g.theMutatingFunction(u)
24+
}
25+
26+
@main struct Main {
27+
static func main() async {
28+
var g = G<Int>()
29+
let i = await theMutatingCaller(&g, 3)
30+
// CHECK: 3
31+
print(i)
32+
}
33+
}

0 commit comments

Comments
 (0)