Skip to content

Commit b8976a3

Browse files
committed
[SIL] Add flag to SILFunctionType::Profile for async.
Previously, the flag was omitted, causing function types which were otherwise the same to have the same id, leading to caching woes. Here, the issue is fixed by adding the boolean flag to the id, ensuring that types which differ only in that flag are still understood to be different.
1 parent e2a1862 commit b8976a3

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

include/swift/AST/Types.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4577,14 +4577,14 @@ class SILFunctionType final
45774577

45784578
void Profile(llvm::FoldingSetNodeID &ID) {
45794579
Profile(ID, getInvocationGenericSignature(),
4580-
getExtInfo(), getCoroutineKind(), getCalleeConvention(),
4580+
getExtInfo(), isAsync(), getCoroutineKind(), getCalleeConvention(),
45814581
getParameters(), getYields(), getResults(),
45824582
getOptionalErrorResult(), getWitnessMethodConformanceOrInvalid(),
45834583
getPatternSubstitutions(), getInvocationSubstitutions());
45844584
}
45854585
static void
45864586
Profile(llvm::FoldingSetNodeID &ID, GenericSignature genericSig, ExtInfo info,
4587-
SILCoroutineKind coroutineKind, ParameterConvention calleeConvention,
4587+
bool isAsync, SILCoroutineKind coroutineKind, ParameterConvention calleeConvention,
45884588
ArrayRef<SILParameterInfo> params, ArrayRef<SILYieldInfo> yields,
45894589
ArrayRef<SILResultInfo> results, Optional<SILResultInfo> errorResult,
45904590
ProtocolConformanceRef conformance,

lib/AST/ASTContext.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3245,6 +3245,7 @@ void SILFunctionType::Profile(
32453245
llvm::FoldingSetNodeID &id,
32463246
GenericSignature genericParams,
32473247
ExtInfo info,
3248+
bool isAsync,
32483249
SILCoroutineKind coroutineKind,
32493250
ParameterConvention calleeConvention,
32503251
ArrayRef<SILParameterInfo> params,
@@ -3258,6 +3259,7 @@ void SILFunctionType::Profile(
32583259
auto infoKey = info.getFuncAttrKey();
32593260
id.AddInteger(infoKey.first);
32603261
id.AddPointer(infoKey.second);
3262+
id.AddBoolean(isAsync);
32613263
id.AddInteger(unsigned(coroutineKind));
32623264
id.AddInteger(unsigned(calleeConvention));
32633265
id.AddInteger(params.size());
@@ -3471,8 +3473,8 @@ CanSILFunctionType SILFunctionType::get(
34713473
invocationSubs = invocationSubs.getCanonical();
34723474

34733475
llvm::FoldingSetNodeID id;
3474-
SILFunctionType::Profile(id, genericSig, ext, coroutineKind, callee, params,
3475-
yields, normalResults, errorResult,
3476+
SILFunctionType::Profile(id, genericSig, ext, isAsync, coroutineKind, callee,
3477+
params, yields, normalResults, errorResult,
34763478
witnessMethodConformance,
34773479
patternSubs, invocationSubs);
34783480

test/SIL/Parser/async.sil

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
// RUN: %target-sil-opt -enable-sil-verify-all=true %s | %target-sil-opt -enable-sil-verify-all=true | %FileCheck %s
22

3+
import Builtin
4+
5+
// CHECK: sil @not_async_test : $@convention(thin) () -> () {
6+
sil @not_async_test : $() -> () {
7+
bb0:
8+
%0 = tuple ()
9+
return %0 : $()
10+
}
11+
12+
// CHECK: sil @not_async_test2 : $@convention(thin) (Builtin.Int32) -> () {
13+
sil @not_async_test2 : $(Builtin.Int32) -> () {
14+
bb0(%int : $Builtin.Int32):
15+
%0 = tuple ()
16+
return %0 : $()
17+
}
18+
319
// CHECK: sil @async_test : $@async
420
sil @async_test : $@async () -> () {
521
bb0:

0 commit comments

Comments
 (0)