Skip to content

Commit 0f7e368

Browse files
committed
[Async CC] Put extra sources before unfulfilled requirements.
EmitPolymorphicArguments puts the extra sources before the unfulfilled requirements into the explosion. The NecessaryBindings instance must have the type parameters in the same order. Previously, though, they were added after enumerating unfulfilled requirements. Here, they are added _before_ enumerating, matching the ordering of EmitPolymorphicArguments. rdar://73742483
1 parent 50f55c1 commit 0f7e368

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
@@ -3058,20 +3058,6 @@ NecessaryBindings NecessaryBindings::computeBindings(
30583058
// Figure out what we're actually required to pass:
30593059
PolymorphicConvention convention(IGM, origType, considerParameterSources);
30603060

3061-
// - unfulfilled requirements
3062-
convention.enumerateUnfulfilledRequirements(
3063-
[&](GenericRequirement requirement) {
3064-
CanType type = requirement.TypeParameter.subst(subs)->getCanonicalType();
3065-
3066-
if (requirement.Protocol) {
3067-
auto conf = subs.lookupConformance(requirement.TypeParameter,
3068-
requirement.Protocol);
3069-
bindings.addProtocolConformance(type, conf);
3070-
} else {
3071-
bindings.addTypeMetadata(type);
3072-
}
3073-
});
3074-
30753061
// - extra sources
30763062
for (auto &source : convention.getSources()) {
30773063
switch (source.getKind()) {
@@ -3098,6 +3084,20 @@ NecessaryBindings NecessaryBindings::computeBindings(
30983084
llvm_unreachable("bad source kind");
30993085
}
31003086

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

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)