From b8976a3ec5c10d4b50e1a007f743bc48cc34fae1 Mon Sep 17 00:00:00 2001 From: Nate Chandler Date: Wed, 19 Aug 2020 17:53:58 -0700 Subject: [PATCH] [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. --- include/swift/AST/Types.h | 4 ++-- lib/AST/ASTContext.cpp | 6 ++++-- test/SIL/Parser/async.sil | 16 ++++++++++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/include/swift/AST/Types.h b/include/swift/AST/Types.h index e3fbbd4e742c2..e55c8bf7be3d5 100644 --- a/include/swift/AST/Types.h +++ b/include/swift/AST/Types.h @@ -4577,14 +4577,14 @@ class SILFunctionType final void Profile(llvm::FoldingSetNodeID &ID) { Profile(ID, getInvocationGenericSignature(), - getExtInfo(), getCoroutineKind(), getCalleeConvention(), + getExtInfo(), isAsync(), getCoroutineKind(), getCalleeConvention(), getParameters(), getYields(), getResults(), getOptionalErrorResult(), getWitnessMethodConformanceOrInvalid(), getPatternSubstitutions(), getInvocationSubstitutions()); } static void Profile(llvm::FoldingSetNodeID &ID, GenericSignature genericSig, ExtInfo info, - SILCoroutineKind coroutineKind, ParameterConvention calleeConvention, + bool isAsync, SILCoroutineKind coroutineKind, ParameterConvention calleeConvention, ArrayRef params, ArrayRef yields, ArrayRef results, Optional errorResult, ProtocolConformanceRef conformance, diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index ef19cd4d46b31..e75c5185cc13b 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -3245,6 +3245,7 @@ void SILFunctionType::Profile( llvm::FoldingSetNodeID &id, GenericSignature genericParams, ExtInfo info, + bool isAsync, SILCoroutineKind coroutineKind, ParameterConvention calleeConvention, ArrayRef params, @@ -3258,6 +3259,7 @@ void SILFunctionType::Profile( auto infoKey = info.getFuncAttrKey(); id.AddInteger(infoKey.first); id.AddPointer(infoKey.second); + id.AddBoolean(isAsync); id.AddInteger(unsigned(coroutineKind)); id.AddInteger(unsigned(calleeConvention)); id.AddInteger(params.size()); @@ -3471,8 +3473,8 @@ CanSILFunctionType SILFunctionType::get( invocationSubs = invocationSubs.getCanonical(); llvm::FoldingSetNodeID id; - SILFunctionType::Profile(id, genericSig, ext, coroutineKind, callee, params, - yields, normalResults, errorResult, + SILFunctionType::Profile(id, genericSig, ext, isAsync, coroutineKind, callee, + params, yields, normalResults, errorResult, witnessMethodConformance, patternSubs, invocationSubs); diff --git a/test/SIL/Parser/async.sil b/test/SIL/Parser/async.sil index 374572412f494..32cfdebb32c0f 100644 --- a/test/SIL/Parser/async.sil +++ b/test/SIL/Parser/async.sil @@ -1,5 +1,21 @@ // RUN: %target-sil-opt -enable-sil-verify-all=true %s | %target-sil-opt -enable-sil-verify-all=true | %FileCheck %s +import Builtin + +// CHECK: sil @not_async_test : $@convention(thin) () -> () { +sil @not_async_test : $() -> () { +bb0: + %0 = tuple () + return %0 : $() +} + +// CHECK: sil @not_async_test2 : $@convention(thin) (Builtin.Int32) -> () { +sil @not_async_test2 : $(Builtin.Int32) -> () { +bb0(%int : $Builtin.Int32): + %0 = tuple () + return %0 : $() +} + // CHECK: sil @async_test : $@async sil @async_test : $@async () -> () { bb0: