diff --git a/SwiftCompilerSources/Sources/SIL/ForwardingInstruction.swift b/SwiftCompilerSources/Sources/SIL/ForwardingInstruction.swift index 276bef4a9ff..5221e3215c1 100644 --- a/SwiftCompilerSources/Sources/SIL/ForwardingInstruction.swift +++ b/SwiftCompilerSources/Sources/SIL/ForwardingInstruction.swift @@ -467,6 +467,12 @@ extension BorrowedFromInst: ForwardingInstruction { public var canForwardOwnedValues: Bool { false } } +extension ImplicitActorToOpaqueIsolationCastInst: ConversionInstruction { + public var preservesRepresentation: Bool { true } + public var canForwardGuaranteedValues: Bool { true } + public var canForwardOwnedValues: Bool { false } +} + // ----------------------------------------------------------------------------- // ownership transition instructions diff --git a/SwiftCompilerSources/Sources/SIL/Instruction.swift b/SwiftCompilerSources/Sources/SIL/Instruction.swift index d979f467e92..b7b52753244 100644 --- a/SwiftCompilerSources/Sources/SIL/Instruction.swift +++ b/SwiftCompilerSources/Sources/SIL/Instruction.swift @@ -2060,3 +2060,6 @@ final public class MergeIsolationRegionInst : Instruction { final public class IgnoredUseInst : Instruction, UnaryInstruction { } + +final public class ImplicitActorToOpaqueIsolationCastInst + : SingleValueInstruction, UnaryInstruction {} diff --git a/SwiftCompilerSources/Sources/SIL/Registration.swift b/SwiftCompilerSources/Sources/SIL/Registration.swift index 25cdfcab100..868fac00336 100644 --- a/SwiftCompilerSources/Sources/SIL/Registration.swift +++ b/SwiftCompilerSources/Sources/SIL/Registration.swift @@ -265,6 +265,7 @@ private func registerSILClasses() { register(ThunkInst.self) register(MergeIsolationRegionInst.self) register(IgnoredUseInst.self) + register(ImplicitActorToOpaqueIsolationCastInst.self) } private func registerUtilities() { diff --git a/docs/ABI/Mangling.rst b/docs/ABI/Mangling.rst index c4beec306e9..28ecf6cc852 100644 --- a/docs/ABI/Mangling.rst +++ b/docs/ABI/Mangling.rst @@ -705,6 +705,9 @@ Types type ::= type 'Bv' NATURAL '_' // Builtin.Vecx type ::= type type 'BV' // Builtin.FixedArray type ::= 'Bw' // Builtin.Word +#if SWIFT_RUNTIME_VERSION >= 6.2 + type ::= 'BA' // Builtin.ImplicitActor +#endif type ::= function-signature 'c' // function type (escaping) type ::= function-signature 'X' FUNCTION-KIND // special function type type ::= bound-generic-type diff --git a/docs/SIL/Instructions.md b/docs/SIL/Instructions.md index e4bbe28a3b0..f70c4eb704b 100644 --- a/docs/SIL/Instructions.md +++ b/docs/SIL/Instructions.md @@ -4555,6 +4555,9 @@ copy. The resulting value must meet the usual ownership requirements; for example, a trivial type must have '.none' ownership. +NOTE: A guaranteed result value is assumed to be a non-dependent guaranteed +value like a function argument. + ### ref_to_raw_pointer ``` @@ -4871,6 +4874,27 @@ TODO TODO +### cast_implicitactor_to_opaqueisolation + +``` +sil-instruction ::= 'cast_implicitactor_to_opaqueisolation' sil-operand + +%1 = cast_implicitactor_to_opaqueisolation %0 : $Builtin.ImplicitActor +// %0 must have guaranteed ownership +// %1 must have guaranteed ownership +// %1 will have type $Optional +``` + +Convert a `$Builtin.ImplicitActor` to a `$Optional` masking out any +bits that we have stolen from the witness table pointer. + +At IRGen time, we lower this to the relevant masking operations, allowing us to +avoid exposing these low level details to the SIL optimizer. On platforms where +we support TBI, IRGen uses a mask that is the bottom 2 bits of the top nibble of +the pointer. On 64 bit platforms this is bit 60,61. If the platform does not +support TBI, then IRGen uses the bottom two tagged pointer bits of the pointer +(bits 0,1). + ## Checked Conversions Some user-level cast operations can fail and thus require runtime diff --git a/include/swift/AST/DiagnosticsParse.def b/include/swift/AST/DiagnosticsParse.def index d6379e0fe37..cf453502772 100644 --- a/include/swift/AST/DiagnosticsParse.def +++ b/include/swift/AST/DiagnosticsParse.def @@ -621,6 +621,12 @@ ERROR(sil_operand_has_incorrect_moveonlywrapped,none, ERROR(sil_operand_not_ref_storage_address,none, "%0 operand of '%1' must have address of %2 type", (StringRef, StringRef, ReferenceOwnership)) +ERROR(sil_operand_has_wrong_ownership_kind,none, + "operand has ownership kind %0 but ownership kind %1 was expected", + (StringRef, StringRef)) +ERROR(sil_operand_has_incompatible_ownership_kind,none, + "operand has ownership kind %0 but ownership kind compatible with %1 was expected", + (StringRef, StringRef)) ERROR(sil_integer_literal_not_integer_type,none, "integer_literal instruction requires a 'Builtin.Int' type", ()) ERROR(sil_integer_literal_not_well_formed,none, diff --git a/include/swift/AST/TypeNodes.def b/include/swift/AST/TypeNodes.def index 869a7cc7e99..a43d7d1642a 100644 --- a/include/swift/AST/TypeNodes.def +++ b/include/swift/AST/TypeNodes.def @@ -143,7 +143,8 @@ ABSTRACT_TYPE(Builtin, Type) BUILTIN_CONCRETE_TYPE(BuiltinVector, BuiltinType) BUILTIN_GENERIC_TYPE(BuiltinFixedArray, BuiltinType) BUILTIN_CONCRETE_TYPE(BuiltinUnboundGeneric, BuiltinType) - TYPE_RANGE(Builtin, BuiltinInteger, BuiltinUnboundGeneric) + BUILTIN_CONCRETE_TYPE(BuiltinImplicitActor, BuiltinType) + TYPE_RANGE(Builtin, BuiltinInteger, BuiltinImplicitActor) TYPE(Tuple, Type) ABSTRACT_TYPE(ReferenceStorage, Type) #define REF_STORAGE(Name, ...) \ @@ -233,6 +234,7 @@ SINGLETON_TYPE(RawPointer, BuiltinRawPointer) SINGLETON_TYPE(RawUnsafeContinuation, BuiltinRawUnsafeContinuation) SINGLETON_TYPE(NativeObject, BuiltinNativeObject) SINGLETON_TYPE(BridgeObject, BuiltinBridgeObject) +SINGLETON_TYPE(ImplicitActor, BuiltinImplicitActor) SINGLETON_TYPE(UnsafeValueBuffer, BuiltinUnsafeValueBuffer) SINGLETON_TYPE(DefaultActorStorage, BuiltinDefaultActorStorage) SINGLETON_TYPE(NonDefaultDistributedActorStorage, BuiltinNonDefaultDistributedActorStorage) diff --git a/include/swift/AST/Types.h b/include/swift/AST/Types.h index 48427618f87..8d6496dfe8c 100644 --- a/include/swift/AST/Types.h +++ b/include/swift/AST/Types.h @@ -1003,6 +1003,13 @@ public: /// Determines whether this type is an any actor type. bool isAnyActorType(); + /// Is this a type whose value is a value that a function can use in an + /// isolated parameter position. This could be a type that actually conforms + /// to AnyActor or it could be a type like any Actor, Optional or + /// Builtin.ImplicitActor that do not conform to Actor but from which we can + /// derive a value that conforms to the Actor protocol. + bool canBeIsolatedTo(); + /// Returns true if this type conforms to Sendable, or if its a function type /// that is @Sendable. bool isSendableType(); @@ -2019,6 +2026,19 @@ BEGIN_CAN_TYPE_WRAPPER(BuiltinVectorType, BuiltinType) PROXY_CAN_TYPE_SIMPLE_GETTER(getElementType) END_CAN_TYPE_WRAPPER(BuiltinVectorType, BuiltinType) +class BuiltinImplicitActorType : public BuiltinType { + friend class ASTContext; + + BuiltinImplicitActorType(const ASTContext &context) + : BuiltinType(TypeKind::BuiltinImplicitActor, context) {} + +public: + static bool classof(const TypeBase *T) { + return T->getKind() == TypeKind::BuiltinImplicitActor; + } +}; +DEFINE_EMPTY_CAN_TYPE_WRAPPER(BuiltinImplicitActorType, BuiltinType) + /// Size descriptor for a builtin integer type. This is either a fixed bit /// width or an abstract target-dependent value such as "size of a pointer". class BuiltinIntegerWidth { diff --git a/include/swift/SIL/InstWrappers.h b/include/swift/SIL/InstWrappers.h index 6e64698069a..28a81e4c4ef 100644 --- a/include/swift/SIL/InstWrappers.h +++ b/include/swift/SIL/InstWrappers.h @@ -301,6 +301,8 @@ public: return &forwardingInst->getOperandRef(TuplePackExtractInst::TupleOperand); case SILInstructionKind::BorrowedFromInst: return &forwardingInst->getOperandRef(0); + case SILInstructionKind::ImplicitActorToOpaqueIsolationCastInst: + return &forwardingInst->getOperandRef(0); default: int numRealOperands = forwardingInst->getNumRealOperands(); if (numRealOperands == 0) { @@ -344,6 +346,7 @@ public: case SILInstructionKind::StructExtractInst: case SILInstructionKind::DifferentiableFunctionExtractInst: case SILInstructionKind::LinearFunctionExtractInst: + case SILInstructionKind::ImplicitActorToOpaqueIsolationCastInst: return true; default: return false; @@ -352,6 +355,8 @@ public: /// Return true if the forwarded value has the same representation. If true, /// then the result can be mapped to the same storage without a move or copy. + /// + /// See ForwardingInstruction.swift preservesRepresentation(). bool hasSameRepresentation() const; /// Return true if the forwarded value is address-only either before or after diff --git a/include/swift/SIL/SILBuilder.h b/include/swift/SIL/SILBuilder.h index aa928be7301..2b45e1d852f 100644 --- a/include/swift/SIL/SILBuilder.h +++ b/include/swift/SIL/SILBuilder.h @@ -1330,6 +1330,17 @@ public: forwardingOwnershipKind)); } + /// Create an unchecked_value_cast when Ownership SSA is enabled and + /// unchecked_bitwise_cast otherwise. + /// + /// Intended to be used in utility code that needs to support both Ownership + /// SSA and non-Ownership SSA code. + SILValue emitUncheckedValueCast(SILLocation loc, SILValue op, SILType ty) { + if (hasOwnership()) + return createUncheckedValueCast(loc, op, ty); + return createUncheckedBitwiseCast(loc, op, ty); + } + RefToBridgeObjectInst *createRefToBridgeObject(SILLocation Loc, SILValue Ref, SILValue Bits) { return createRefToBridgeObject(Loc, Ref, Bits, Ref->getOwnershipKind()); @@ -2334,6 +2345,19 @@ public: getSILDebugLocation(Loc), Operand, Kind)); } + SILValue emitUncheckedOwnershipConversion(SILLocation Loc, SILValue Operand, + ValueOwnershipKind Kind) { + if (!hasOwnership()) + return Operand; + return createUncheckedOwnershipConversion(Loc, Operand, Kind); + } + + ImplicitActorToOpaqueIsolationCastInst * + createImplicitActorToOpaqueIsolationCast(SILLocation Loc, SILValue Value) { + return insert(new (getModule()) ImplicitActorToOpaqueIsolationCastInst( + getSILDebugLocation(Loc), Value)); + } + FixLifetimeInst *createFixLifetime(SILLocation Loc, SILValue Operand) { return insert(new (getModule()) FixLifetimeInst(getSILDebugLocation(Loc), Operand)); @@ -2353,6 +2377,18 @@ public: dependenceKind); } + /// Emit a mark_dependence instruction placing the kind only if ownership is + /// set in the current function. + /// + /// This is intended to be used in code that is generic over Ownership SSA and + /// non-Ownership SSA code. + SILValue emitMarkDependence(SILLocation Loc, SILValue value, SILValue base, + MarkDependenceKind dependenceKind) { + return createMarkDependence(Loc, value, base, value->getOwnershipKind(), + hasOwnership() ? dependenceKind + : MarkDependenceKind::Escaping); + } + MarkDependenceInst * createMarkDependence(SILLocation Loc, SILValue value, SILValue base, ValueOwnershipKind forwardingOwnershipKind, diff --git a/include/swift/SIL/SILCloner.h b/include/swift/SIL/SILCloner.h index 8efd611a50e..0ac7bcea8a3 100644 --- a/include/swift/SIL/SILCloner.h +++ b/include/swift/SIL/SILCloner.h @@ -3153,6 +3153,16 @@ void SILCloner::visitUncheckedOwnershipConversionInst( getOpValue(Inst->getOperand()), Kind)); } +template +void SILCloner::visitImplicitActorToOpaqueIsolationCastInst( + ImplicitActorToOpaqueIsolationCastInst *Inst) { + getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope())); + + recordClonedInstruction( + Inst, getBuilder().createImplicitActorToOpaqueIsolationCast( + getOpLocation(Inst->getLoc()), getOpValue(Inst->getValue()))); +} + template void SILCloner::visitMarkDependenceInst(MarkDependenceInst *Inst) { getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope())); diff --git a/include/swift/SIL/SILInstruction.h b/include/swift/SIL/SILInstruction.h index 78d1115b52d..8ba9aa578b2 100644 --- a/include/swift/SIL/SILInstruction.h +++ b/include/swift/SIL/SILInstruction.h @@ -8789,6 +8789,18 @@ public: } }; +class ImplicitActorToOpaqueIsolationCastInst final + : public UnaryInstructionBase< + SILInstructionKind::ImplicitActorToOpaqueIsolationCastInst, + OwnershipForwardingSingleValueInstruction> { + friend SILBuilder; + + ImplicitActorToOpaqueIsolationCastInst(SILDebugLocation loc, SILValue value); + +public: + SILValue getValue() const { return getOperand(); } +}; + enum class MarkDependenceKind { Unresolved, Escaping, NonEscaping }; @@ -11653,6 +11665,7 @@ OwnershipForwardingSingleValueInstruction::classof(SILInstructionKind kind) { case SILInstructionKind::FunctionExtractIsolationInst: case SILInstructionKind::DropDeinitInst: case SILInstructionKind::BorrowedFromInst: + case SILInstructionKind::ImplicitActorToOpaqueIsolationCastInst: return true; default: return false; diff --git a/include/swift/SIL/SILNodes.def b/include/swift/SIL/SILNodes.def index ec872de0255..23c4279c00c 100644 --- a/include/swift/SIL/SILNodes.def +++ b/include/swift/SIL/SILNodes.def @@ -423,6 +423,8 @@ ABSTRACT_VALUE_AND_INST(SingleValueInstruction, ValueBase, SILInstruction) SingleValueInstruction, None, DoesNotRelease) SINGLE_VALUE_INST(ObjCExistentialMetatypeToObjectInst, objc_existential_metatype_to_object, SingleValueInstruction, None, DoesNotRelease) + SINGLE_VALUE_INST(ImplicitActorToOpaqueIsolationCastInst, implicitactor_to_opaqueisolation_cast, + SingleValueInstruction, None, DoesNotRelease) // unconditional_checked_cast_inst is only MayRead to prevent a subsequent // release of the cast's source from being hoisted above the cast: // retain X diff --git a/include/swift/SIL/SILType.h b/include/swift/SIL/SILType.h index de96a052699..25d5bf60e1c 100644 --- a/include/swift/SIL/SILType.h +++ b/include/swift/SIL/SILType.h @@ -267,6 +267,8 @@ public: bool isBuiltinBridgeObject() const { return is(); } + bool isBuiltinImplicitActor() const { return is(); } + SILType getBuiltinVectorElementType() const { auto vector = castTo(); return getPrimitiveObjectType(vector.getElementType()); @@ -961,6 +963,13 @@ public: /// Returns true if this type is an actor or a distributed actor. bool isAnyActor() const { return getASTType()->isAnyActorType(); } + /// Is this a type whose value is a value that a function can use in an + /// isolated parameter position. This could be a type that actually conforms + /// to AnyActor or it could be a type like any Actor, Optional or + /// Builtin.ImplicitActor that do not conform to Actor but from which we can + /// derive a value that conforms to the Actor protocol. + bool canBeIsolatedTo() const { return getASTType()->canBeIsolatedTo(); } + /// Returns true if this function conforms to the Sendable protocol. /// /// NOTE: For diagnostics this is not always the correct thing to check since @@ -1026,9 +1035,29 @@ public: /// Return '()' static SILType getEmptyTupleType(const ASTContext &C); + /// Return (elementTypes) with control of category. + static SILType getTupleType(const ASTContext &ctx, + ArrayRef elementTypes, + SILValueCategory category); + + /// Return $(elementTypes) + static SILType getTupleObjectType(const ASTContext &ctx, + ArrayRef elementTypes) { + return getTupleType(ctx, elementTypes, SILValueCategory::Object); + } + + /// Return $*(elementTypes) + static SILType getTupleAddressType(const ASTContext &ctx, + ArrayRef elementTypes) { + return getTupleType(ctx, elementTypes, SILValueCategory::Address); + } + /// Get the type for opaque actor isolation values. static SILType getOpaqueIsolationType(const ASTContext &C); + /// Return Builtin.ImplicitActor. + static SILType getBuiltinImplicitActorType(const ASTContext &ctx); + // // Utilities for treating SILType as a pointer-like type. // diff --git a/include/swift/Strings.h b/include/swift/Strings.h index f1c2dba3461..91a18da8c8e 100644 --- a/include/swift/Strings.h +++ b/include/swift/Strings.h @@ -144,6 +144,8 @@ constexpr static BuiltinNameStringLiteral BUILTIN_TYPE_NAME_NATIVEOBJECT = { /// The name of the Builtin type for BridgeObject constexpr static BuiltinNameStringLiteral BUILTIN_TYPE_NAME_BRIDGEOBJECT = { "Builtin.BridgeObject"}; +constexpr static BuiltinNameStringLiteral BUILTIN_TYPE_NAME_IMPLICITACTOR = { + "Builtin.ImplicitActor"}; /// The name of the Builtin type for RawPointer constexpr static BuiltinNameStringLiteral BUILTIN_TYPE_NAME_RAWPOINTER = { "Builtin.RawPointer"}; diff --git a/lib/AST/ASTDumper.cpp b/lib/AST/ASTDumper.cpp index b5a130bccbf..f09f04c6ca7 100644 --- a/lib/AST/ASTDumper.cpp +++ b/lib/AST/ASTDumper.cpp @@ -6114,6 +6114,7 @@ namespace { TRIVIAL_TYPE_PRINTER(BuiltinRawUnsafeContinuation, builtin_raw_unsafe_continuation) TRIVIAL_TYPE_PRINTER(BuiltinNativeObject, builtin_native_object) TRIVIAL_TYPE_PRINTER(BuiltinBridgeObject, builtin_bridge_object) + TRIVIAL_TYPE_PRINTER(BuiltinImplicitActor, builtin_implicit_isolated_actor) TRIVIAL_TYPE_PRINTER(BuiltinUnsafeValueBuffer, builtin_unsafe_value_buffer) TRIVIAL_TYPE_PRINTER(SILToken, sil_token) diff --git a/lib/AST/ASTMangler.cpp b/lib/AST/ASTMangler.cpp index 6c029cdfadc..46482dec145 100644 --- a/lib/AST/ASTMangler.cpp +++ b/lib/AST/ASTMangler.cpp @@ -1471,6 +1471,8 @@ void ASTMangler::appendType(Type type, GenericSignature sig, auto loc = cast(tybase); return appendType(loc->getSinglyDesugaredType(), sig, forDecl); } + case TypeKind::BuiltinImplicitActor: + return appendOperator("BA"); case TypeKind::BuiltinFixedArray: { auto bfa = cast(tybase); appendType(bfa->getSize(), sig, forDecl); diff --git a/lib/AST/ASTPrinter.cpp b/lib/AST/ASTPrinter.cpp index d944dbfb5e2..213ddb34080 100644 --- a/lib/AST/ASTPrinter.cpp +++ b/lib/AST/ASTPrinter.cpp @@ -6266,6 +6266,7 @@ public: ASTPRINTER_PRINT_BUILTINTYPE(BuiltinIntegerType) ASTPRINTER_PRINT_BUILTINTYPE(BuiltinFloatType) ASTPRINTER_PRINT_BUILTINTYPE(BuiltinUnboundGenericType) + ASTPRINTER_PRINT_BUILTINTYPE(BuiltinImplicitActorType) #undef ASTPRINTER_PRINT_BUILTINTYPE void visitBuiltinFixedArrayType(BuiltinFixedArrayType *T, diff --git a/lib/AST/Builtins.cpp b/lib/AST/Builtins.cpp index 69e43b88062..b6d4da3f073 100644 --- a/lib/AST/Builtins.cpp +++ b/lib/AST/Builtins.cpp @@ -83,6 +83,7 @@ Type swift::getBuiltinType(ASTContext &Context, StringRef Name) { .Case("Word", BuiltinTypeKind::BuiltinInteger) .Case("IntLiteral", BuiltinTypeKind::BuiltinIntegerLiteral) .StartsWith("Int", BuiltinTypeKind::BuiltinInteger) + .Case("ImplicitActor", BuiltinTypeKind::BuiltinImplicitActor) .Default({}); // Handle types that are not BuiltinTypeKinds. @@ -175,6 +176,8 @@ Type swift::getBuiltinType(ASTContext &Context, StringRef Name) { return Context.TheIntegerLiteralType; case BuiltinTypeKind::BuiltinUnboundGeneric: return Type(); + case BuiltinTypeKind::BuiltinImplicitActor: + return Context.TheImplicitActorType; } return Type(); @@ -3489,6 +3492,7 @@ bool BuiltinType::isBitwiseCopyable() const { return true; case BuiltinTypeKind::BuiltinNativeObject: case BuiltinTypeKind::BuiltinBridgeObject: + case BuiltinTypeKind::BuiltinImplicitActor: case BuiltinTypeKind::BuiltinUnsafeValueBuffer: case BuiltinTypeKind::BuiltinDefaultActorStorage: case BuiltinTypeKind::BuiltinNonDefaultDistributedActorStorage: @@ -3544,6 +3548,9 @@ StringRef BuiltinType::getTypeName(SmallVectorImpl &result, case BuiltinTypeKind::BuiltinBridgeObject: printer << MAYBE_GET_NAMESPACED_BUILTIN(BUILTIN_TYPE_NAME_BRIDGEOBJECT); break; + case BuiltinTypeKind::BuiltinImplicitActor: + printer << MAYBE_GET_NAMESPACED_BUILTIN(BUILTIN_TYPE_NAME_IMPLICITACTOR); + break; case BuiltinTypeKind::BuiltinUnsafeValueBuffer: printer << MAYBE_GET_NAMESPACED_BUILTIN( BUILTIN_TYPE_NAME_UNSAFEVALUEBUFFER); diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index fb2ad378cf8..a9bc44a7abe 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -194,6 +194,7 @@ bool CanType::isReferenceTypeImpl(CanType type, const GenericSignatureImpl *sig, // These types are always class references. case TypeKind::BuiltinNativeObject: case TypeKind::BuiltinBridgeObject: + case TypeKind::BuiltinImplicitActor: case TypeKind::Class: case TypeKind::BoundGenericClass: case TypeKind::SILBox: @@ -518,6 +519,16 @@ bool TypeBase::isAnyActorType() { return false; } +bool TypeBase::canBeIsolatedTo() { + if (getCanonicalType() == getASTContext().TheImplicitActorType) + return true; + // Look through an optional if we have one. We do not want to recognize + // Optional since we shouldn't ever see that. + if (auto ty = getOptionalObjectType()) + return ty->isAnyActorType(); + return isAnyActorType(); +} + bool TypeBase::isDistributedActor() { if (auto actor = getAnyActor()) return actor->isDistributedActor(); @@ -4548,6 +4559,7 @@ ReferenceCounting TypeBase::getReferenceCounting() { llvm_unreachable("sugared canonical type?"); case TypeKind::BuiltinNativeObject: + case TypeKind::BuiltinImplicitActor: case TypeKind::SILBox: return ReferenceCounting::Native; diff --git a/lib/Demangling/Demangler.cpp b/lib/Demangling/Demangler.cpp index 062b0ee82bb..71fa037467a 100644 --- a/lib/Demangling/Demangler.cpp +++ b/lib/Demangling/Demangler.cpp @@ -1441,6 +1441,10 @@ NodePointer Demangler::demangleBuiltinType() { NodePointer Ty = nullptr; const int maxTypeSize = 4096; // a very conservative upper bound switch (nextChar()) { + case 'A': + Ty = createNode(Node::Kind::BuiltinTypeName, + BUILTIN_TYPE_NAME_IMPLICITACTOR); + break; case 'b': Ty = createNode(Node::Kind::BuiltinTypeName, BUILTIN_TYPE_NAME_BRIDGEOBJECT); diff --git a/lib/Demangling/Remangler.cpp b/lib/Demangling/Remangler.cpp index f9a339eee25..56dc7a9138e 100644 --- a/lib/Demangling/Remangler.cpp +++ b/lib/Demangling/Remangler.cpp @@ -910,7 +910,9 @@ ManglingError Remangler::mangleBuiltinTypeName(Node *node, unsigned depth) { Buffer << 'B'; StringRef text = node->getText(); - if (text == BUILTIN_TYPE_NAME_BRIDGEOBJECT) { + if (text == BUILTIN_TYPE_NAME_IMPLICITACTOR) { + Buffer << 'A'; + } else if (text == BUILTIN_TYPE_NAME_BRIDGEOBJECT) { Buffer << 'b'; } else if (text == BUILTIN_TYPE_NAME_UNSAFEVALUEBUFFER) { Buffer << 'B'; diff --git a/lib/IRGen/GenConcurrency.cpp b/lib/IRGen/GenConcurrency.cpp index 10f4aac0d29..34d3f046d77 100644 --- a/lib/IRGen/GenConcurrency.cpp +++ b/lib/IRGen/GenConcurrency.cpp @@ -879,3 +879,139 @@ irgen::emitTaskCreate(IRGenFunction &IGF, llvm::Value *flags, newContext = IGF.Builder.CreateBitCast(newContext, IGF.IGM.Int8PtrTy); return { newTask, newContext }; } + +namespace { + +/// A TypeInfo implementation for Builtin.ImplicitActor. +class ImplicitActorTypeInfo final + : public ScalarPairTypeInfo { + +public: + ImplicitActorTypeInfo(llvm::StructType *storageType, Size size, + Alignment align, SpareBitVector &&spareBits) + : ScalarPairTypeInfo(storageType, size, std::move(spareBits), align, + IsNotTriviallyDestroyable, IsCopyable, IsFixedSize, + IsABIAccessible) {} + + TypeLayoutEntry *buildTypeLayoutEntry(IRGenModule &IGM, SILType T, + bool useStructLayouts) const override { + if (!useStructLayouts) { + return IGM.typeLayoutCache.getOrCreateTypeInfoBasedEntry(*this, T); + } + return IGM.typeLayoutCache.getOrCreateScalarEntry( + *this, T, ScalarKind::NativeStrongReference); + } + + static Size getFirstElementSize(IRGenModule &IGM) { + return IGM.getPointerSize(); + } + + static StringRef getFirstElementLabel() { return ".actor"; } + + static bool isFirstElementTrivial() { return false; } + + void emitRetainFirstElement( + IRGenFunction &IGF, llvm::Value *data, + std::optional atomicity = std::nullopt) const { + if (!atomicity) + atomicity = IGF.getDefaultAtomicity(); + IGF.emitNativeStrongRetain(data, *atomicity); + } + + void emitReleaseFirstElement( + IRGenFunction &IGF, llvm::Value *data, + std::optional atomicity = std::nullopt) const { + if (!atomicity) + atomicity = IGF.getDefaultAtomicity(); + IGF.emitNativeStrongRelease(data, *atomicity); + } + + void emitAssignFirstElement(IRGenFunction &IGF, llvm::Value *data, + Address address) const { + IGF.emitNativeStrongAssign(data, address); + } + + static Size getSecondElementOffset(IRGenModule &IGM) { + return IGM.getPointerSize(); + } + static Size getSecondElementSize(IRGenModule &IGM) { + return IGM.getPointerSize(); + } + static StringRef getSecondElementLabel() { return ".witness_table_pointer"; } + bool isSecondElementTrivial() const { return true; } + + void emitRetainSecondElement( + IRGenFunction &IGF, llvm::Value *data, + std::optional atomicity = std::nullopt) const {} + void emitReleaseSecondElement( + IRGenFunction &IGF, llvm::Value *data, + std::optional atomicity = std::nullopt) const {} + void emitAssignSecondElement(IRGenFunction &IGF, llvm::Value *context, + Address dataAddr) const { + IGF.Builder.CreateStore(context, dataAddr); + } + + bool mayHaveExtraInhabitants(IRGenModule &IGM) const override { + return false; + } + PointerInfo getPointerInfo(IRGenModule &IGM) const { + return PointerInfo::forHeapObject(IGM); + } + unsigned getFixedExtraInhabitantCount(IRGenModule &IGM) const override { + return 0; + } + APInt getFixedExtraInhabitantValue(IRGenModule &IGM, unsigned bits, + unsigned index) const override { + + llvm_unreachable("no extra inhabitants"); + } + llvm::Value *getExtraInhabitantIndex(IRGenFunction &IGF, Address src, + SILType T, + bool isOutlined) const override { + llvm_unreachable("no extra inhabitants"); + } + void storeExtraInhabitant(IRGenFunction &IGF, llvm::Value *index, + Address dest, SILType T, + bool isOutlined) const override { + llvm_unreachable("no extra inhabitants"); + } +}; + +} // end anonymous namespace + +const LoadableTypeInfo &IRGenModule::getImplicitActorTypeInfo() { + return Types.getImplicitActorTypeInfo(); +} + +const LoadableTypeInfo &TypeConverter::getImplicitActorTypeInfo() { + if (ImplicitActorTI) + return *ImplicitActorTI; + + auto ty = IGM.SwiftImplicitActorType; + + // No spare bits + SpareBitVector spareBits; + spareBits.appendClearBits(IGM.getPointerSize().getValueInBits()); + spareBits.appendClearBits(IGM.getPointerSize().getValueInBits()); + + ImplicitActorTI = new ImplicitActorTypeInfo(ty, IGM.getPointerSize() * 2, + IGM.getPointerAlignment(), + std::move(spareBits)); + ImplicitActorTI->NextConverted = FirstType; + FirstType = ImplicitActorTI; + return *ImplicitActorTI; +} + +llvm::Value *irgen::clearImplicitIsolatedActorBits(IRGenFunction &IGF, + llvm::Value *value) { + auto *cast = IGF.Builder.CreateBitOrPointerCast(value, IGF.IGM.IntPtrTy); + // When TBI is enabled, we use the bottom two bits of the upper nibble of the + // TBI bit, implying a mask of 0xCFFFFFFFFFFFFFFF. If TBI is disabled, then we + // mask the bottom two tagged pointer bits. + auto *bitMask = + IGF.getOptions().HasAArch64TBI + ? llvm::ConstantInt::get(IGF.IGM.IntPtrTy, 0xCFFFFFFFFFFFFFFFull) + : llvm::ConstantInt::get(IGF.IGM.IntPtrTy, -4); + auto *result = IGF.Builder.CreateAnd(cast, bitMask); + return IGF.Builder.CreateBitOrPointerCast(result, value->getType()); +} diff --git a/lib/IRGen/GenConcurrency.h b/lib/IRGen/GenConcurrency.h index 509e948c4c5..4663bf1b05c 100644 --- a/lib/IRGen/GenConcurrency.h +++ b/lib/IRGen/GenConcurrency.h @@ -110,6 +110,9 @@ emitTaskCreate(IRGenFunction &IGF, llvm::Value *flags, Explosion &taskFunction, SubstitutionMap subs); +llvm::Value *clearImplicitIsolatedActorBits(IRGenFunction &IGF, + llvm::Value *value); + } // end namespace irgen } // end namespace swift diff --git a/lib/IRGen/GenType.cpp b/lib/IRGen/GenType.cpp index d5cb390955f..51767c71566 100644 --- a/lib/IRGen/GenType.cpp +++ b/lib/IRGen/GenType.cpp @@ -2255,6 +2255,8 @@ const TypeInfo *TypeConverter::convertType(CanType ty) { } case TypeKind::BuiltinNativeObject: return &getNativeObjectTypeInfo(); + case TypeKind::BuiltinImplicitActor: + return &getImplicitActorTypeInfo(); case TypeKind::BuiltinBridgeObject: return &getBridgeObjectTypeInfo(); case TypeKind::BuiltinUnsafeValueBuffer: diff --git a/lib/IRGen/GenType.h b/lib/IRGen/GenType.h index 19d8eb5a5b9..bbd80bde26a 100644 --- a/lib/IRGen/GenType.h +++ b/lib/IRGen/GenType.h @@ -112,6 +112,7 @@ private: const LoadableTypeInfo *JobTI = nullptr; const LoadableTypeInfo *ExecutorTI = nullptr; const LoadableTypeInfo *WitnessTablePtrTI = nullptr; + const LoadableTypeInfo *ImplicitActorTI = nullptr; const TypeInfo *TypeMetadataPtrTI = nullptr; const TypeInfo *SwiftContextPtrTI = nullptr; const TypeInfo *TaskContinuationFunctionPtrTI = nullptr; @@ -202,6 +203,7 @@ public: const LoadableTypeInfo &getNativeObjectTypeInfo(); const LoadableTypeInfo &getUnknownObjectTypeInfo(); const LoadableTypeInfo &getBridgeObjectTypeInfo(); + const LoadableTypeInfo &getImplicitActorTypeInfo(); const LoadableTypeInfo &getRawPointerTypeInfo(); const LoadableTypeInfo &getRawUnsafeContinuationTypeInfo(); const LoadableTypeInfo &getJobTypeInfo(); diff --git a/lib/IRGen/IRGenDebugInfo.cpp b/lib/IRGen/IRGenDebugInfo.cpp index 8ec5f2ffa47..aa48bdea6b9 100644 --- a/lib/IRGen/IRGenDebugInfo.cpp +++ b/lib/IRGen/IRGenDebugInfo.cpp @@ -1977,6 +1977,12 @@ private: llvm::DINode::FlagArtificial, MangledName); } + case TypeKind::BuiltinImplicitActor: { + return createDoublePointerSizedStruct( + Scope, "Builtin.ImplicitActor", nullptr, MainFile, 0, + llvm::DINode::FlagArtificial, MangledName); + } + case TypeKind::DynamicSelf: { // Self. We don't have a way to represent instancetype in DWARF, // so we emit the static type instead. This is similar to what we diff --git a/lib/IRGen/IRGenModule.cpp b/lib/IRGen/IRGenModule.cpp index 9ba09c542f9..260162660fd 100644 --- a/lib/IRGen/IRGenModule.cpp +++ b/lib/IRGen/IRGenModule.cpp @@ -784,6 +784,12 @@ IRGenModule::IRGenModule(IRGenerator &irgen, PtrTy, PtrTy, }); + SwiftImplicitActorType = + createStructType(*this, "swift.implicit_isolated_actor_type", + { + IntPtrTy, // ref counted pointer + IntPtrTy, // witness table pointer + }); } IRGenModule::~IRGenModule() { diff --git a/lib/IRGen/IRGenModule.h b/lib/IRGen/IRGenModule.h index 6b64264bc93..736b66bdbd6 100644 --- a/lib/IRGen/IRGenModule.h +++ b/lib/IRGen/IRGenModule.h @@ -888,6 +888,8 @@ public: llvm::IntegerType *CoroAllocatorFlagsTy; llvm::StructType *CoroAllocatorTy; + llvm::StructType *SwiftImplicitActorType; // { %swift.refcounted, i8* } + llvm::GlobalVariable *TheTrivialPropertyDescriptor = nullptr; llvm::Constant *swiftImmortalRefCount = nullptr; @@ -1131,6 +1133,7 @@ public: const LoadableTypeInfo & getReferenceObjectTypeInfo(ReferenceCounting refcounting); const LoadableTypeInfo &getNativeObjectTypeInfo(); + const LoadableTypeInfo &getImplicitActorTypeInfo(); const LoadableTypeInfo &getUnknownObjectTypeInfo(); const LoadableTypeInfo &getBridgeObjectTypeInfo(); const LoadableTypeInfo &getRawPointerTypeInfo(); diff --git a/lib/IRGen/IRGenSIL.cpp b/lib/IRGen/IRGenSIL.cpp index a26668c5f22..1df7deabddd 100644 --- a/lib/IRGen/IRGenSIL.cpp +++ b/lib/IRGen/IRGenSIL.cpp @@ -312,7 +312,9 @@ public: bool isBoxWithAddress() const { return kind == Kind::OwnedAddress; } - + + bool isExplosionVector() const { return kind == Kind::ExplosionVector; } + const StackAddress &getStackAddress() const { return Storage.get(kind); } @@ -1422,6 +1424,8 @@ public: void visitCopyBlockWithoutEscapingInst(CopyBlockWithoutEscapingInst *i) { llvm_unreachable("not valid in canonical SIL"); } + void visitImplicitActorToOpaqueIsolationCastInst( + ImplicitActorToOpaqueIsolationCastInst *i); void visitStrongRetainInst(StrongRetainInst *i); void visitStrongReleaseInst(StrongReleaseInst *i); void visitIsUniqueInst(IsUniqueInst *i); @@ -3375,12 +3379,10 @@ void IRGenSILFunction::visitExistentialMetatypeInst( setLoweredExplosion(i, result); } -static void emitApplyArgument(IRGenSILFunction &IGF, - SILValue arg, - SILType paramType, - Explosion &out, - SILInstruction *apply = nullptr, - unsigned idx = 0) { +static void emitApplyArgument(IRGenSILFunction &IGF, SILValue arg, + SILType paramType, Explosion &out, + SILInstruction *apply = nullptr, unsigned idx = 0, + bool isImplicitIsolatedParameter = false) { bool isSubstituted = (arg->getType() != paramType); // For indirect arguments, we just need to pass a pointer. @@ -3422,7 +3424,20 @@ static void emitApplyArgument(IRGenSILFunction &IGF, } canForwardLoadToIndirect = true; }(); - IGF.getLoweredExplosion(arg, out); + + // If we are emitting a parameter for an implicit isolated parameter, then + // we need to clear the implicit isolated actor bits. + if (isImplicitIsolatedParameter) { + auto &loweredValue = IGF.getLoweredValue(arg); + assert(loweredValue.isExplosionVector() && + "Should be an explosion of two pointers"); + auto explosionVector = loweredValue.getKnownExplosionVector(); + assert(explosionVector.size() == 2 && "We should have two values"); + out.add(explosionVector[0]); + out.add(clearImplicitIsolatedActorBits(IGF, explosionVector[1])); + } else { + IGF.getLoweredExplosion(arg, out); + } if (canForwardLoadToIndirect) { IGF.setForwardableArgument(idx); } @@ -3840,6 +3855,20 @@ void IRGenSILFunction::visitFullApplySite(FullApplySite site) { } } + // Extract the implicit isolated parameter so that we can mask it as + // appropriate. + // + // NOTE: We cannot just drop_front since we could be between the indirect + // results and the parameters. + std::optional implicitIsolatedParameterIndex; + if (auto actorIsolation = site.getFunction()->getActorIsolation(); + actorIsolation && actorIsolation->isCallerIsolationInheriting() && + site.isCallerIsolationInheriting()) { + auto *iso = site.getIsolatedArgumentOperandOrNullPtr(); + assert(iso); + implicitIsolatedParameterIndex = site.getAppliedArgIndex(*iso); + } + // Lower the arguments and return value in the callee's generic context. GenericContextScope scope(IGM, origCalleeType->getInvocationGenericSignature()); @@ -3900,8 +3929,11 @@ void IRGenSILFunction::visitFullApplySite(FullApplySite site) { emission->setIndirectTypedErrorResultSlot(addr.getAddress()); continue; } + emitApplyArgument(*this, args[index], emission->getParameterType(index), - llArgs, site.getInstruction(), index); + llArgs, site.getInstruction(), index, + implicitIsolatedParameterIndex && + *implicitIsolatedParameterIndex == index); } // Pass the generic arguments. @@ -6153,6 +6185,17 @@ void IRGenSILFunction::visitCopyBlockInst(CopyBlockInst *i) { setLoweredExplosion(i, result); } +void IRGenSILFunction::visitImplicitActorToOpaqueIsolationCastInst( + ImplicitActorToOpaqueIsolationCastInst *i) { + auto lowered = getLoweredExplosion(i->getOperand()); + Explosion result; + result.add(Builder.CreateBitOrPointerCast(lowered.claimNext(), IGM.IntPtrTy)); + result.add(Builder.CreateBitOrPointerCast( + clearImplicitIsolatedActorBits(*this, lowered.claimNext()), + IGM.IntPtrTy)); + setLoweredExplosion(i, result); +} + void IRGenSILFunction::visitStrongRetainInst(swift::StrongRetainInst *i) { Explosion lowered = getLoweredExplosion(i->getOperand()); auto &ti = cast(getTypeInfo(i->getOperand()->getType())); @@ -6303,10 +6346,10 @@ static bool hasReferenceSemantics(IRGenSILFunction &IGF, auto operType = silType.getASTType(); auto valueType = operType->getOptionalObjectType(); auto objType = valueType ? valueType : operType; - return (objType->mayHaveSuperclass() - || objType->isClassExistentialType() - || objType->is() - || objType->is()); + return (objType->mayHaveSuperclass() || objType->isClassExistentialType() || + objType->is() || + objType->is() || + objType->is()); } static llvm::Value *emitIsUnique(IRGenSILFunction &IGF, SILValue operand, diff --git a/lib/IRGen/MetadataRequest.cpp b/lib/IRGen/MetadataRequest.cpp index e814067daf1..3ef16b323c0 100644 --- a/lib/IRGen/MetadataRequest.cpp +++ b/lib/IRGen/MetadataRequest.cpp @@ -1799,6 +1799,11 @@ namespace { return emitDirectMetadataRef(type); } + MetadataResponse visitBuiltinImplicitActor(CanBuiltinImplicitActorType type, + DynamicMetadataRequest request) { + return emitDirectMetadataRef(type); + } + MetadataResponse visitBuiltinBridgeObjectType(CanBuiltinBridgeObjectType type, DynamicMetadataRequest request) { @@ -1835,6 +1840,12 @@ namespace { return emitDirectMetadataRef(type); } + MetadataResponse + visitBuiltinImplicitActorType(CanBuiltinImplicitActorType type, + DynamicMetadataRequest request) { + return emitDirectMetadataRef(type); + } + MetadataResponse visitBuiltinPackIndexType(CanBuiltinPackIndexType type, DynamicMetadataRequest request) { diff --git a/lib/SIL/IR/OperandOwnership.cpp b/lib/SIL/IR/OperandOwnership.cpp index 2d85b8a9107..39f6d163720 100644 --- a/lib/SIL/IR/OperandOwnership.cpp +++ b/lib/SIL/IR/OperandOwnership.cpp @@ -332,6 +332,7 @@ OPERAND_OWNERSHIP(GuaranteedForwarding, LinearFunctionExtract) OPERAND_OWNERSHIP(GuaranteedForwarding, OpenExistentialValue) OPERAND_OWNERSHIP(GuaranteedForwarding, OpenExistentialBoxValue) OPERAND_OWNERSHIP(GuaranteedForwarding, FunctionExtractIsolation) +OPERAND_OWNERSHIP(GuaranteedForwarding, ImplicitActorToOpaqueIsolationCast) OPERAND_OWNERSHIP(EndBorrow, EndBorrow) diff --git a/lib/SIL/IR/SILFunctionType.cpp b/lib/SIL/IR/SILFunctionType.cpp index f945630fd9c..c3fdf1298e9 100644 --- a/lib/SIL/IR/SILFunctionType.cpp +++ b/lib/SIL/IR/SILFunctionType.cpp @@ -1763,11 +1763,7 @@ private: // implicit isolation parameter. if (IsolationInfo && IsolationInfo->isCallerIsolationInheriting() && Convs.hasCallerIsolationParameter()) { - auto actorProtocol = TC.Context.getProtocol(KnownProtocolKind::Actor); - auto actorType = - ExistentialType::get(actorProtocol->getDeclaredInterfaceType()); - addParameter(-1, - CanType(actorType).wrapInOptionalType(), + addParameter(-1, CanType(TC.Context.TheImplicitActorType), ParameterConvention::Direct_Guaranteed, ParameterTypeFlags().withIsolated(true), true /*implicit leading parameter*/); diff --git a/lib/SIL/IR/SILInstructions.cpp b/lib/SIL/IR/SILInstructions.cpp index 06c61cc97af..48b65e1dc9d 100644 --- a/lib/SIL/IR/SILInstructions.cpp +++ b/lib/SIL/IR/SILInstructions.cpp @@ -3524,3 +3524,10 @@ MergeIsolationRegionInst::create(SILDebugLocation loc, ArrayRef args, auto buffer = mod.allocateInst(size, alignof(MergeIsolationRegionInst)); return ::new (buffer) MergeIsolationRegionInst(loc, args); } + +ImplicitActorToOpaqueIsolationCastInst::ImplicitActorToOpaqueIsolationCastInst( + SILDebugLocation loc, SILValue value) + : UnaryInstructionBase(loc, value, + SILType::getOpaqueIsolationType( + value->getFunction()->getASTContext()), + OwnershipKind::Guaranteed) {} diff --git a/lib/SIL/IR/SILPrinter.cpp b/lib/SIL/IR/SILPrinter.cpp index d2c6062c4c9..d286e37a38e 100644 --- a/lib/SIL/IR/SILPrinter.cpp +++ b/lib/SIL/IR/SILPrinter.cpp @@ -2160,6 +2160,11 @@ public: << "@" << UOCI->getConversionOwnershipKind(); } + void visitImplicitActorToOpaqueIsolationCastInst( + ImplicitActorToOpaqueIsolationCastInst *inst) { + *this << getIDAndType(inst->getValue()); + } + void visitConvertFunctionInst(ConvertFunctionInst *CI) { *this << getIDAndType(CI->getOperand()) << " to "; if (CI->withoutActuallyEscaping()) diff --git a/lib/SIL/IR/SILType.cpp b/lib/SIL/IR/SILType.cpp index ba246a0e6b5..64d02ccfb17 100644 --- a/lib/SIL/IR/SILType.cpp +++ b/lib/SIL/IR/SILType.cpp @@ -103,6 +103,21 @@ SILType SILType::getEmptyTupleType(const ASTContext &C) { return getPrimitiveObjectType(C.TheEmptyTupleType); } +SILType SILType::getTupleType(const ASTContext &ctx, + ArrayRef elementTypes, + SILValueCategory category) { + if (elementTypes.empty()) + return SILType::getEmptyTupleType(ctx); + + SmallVector tupleTypeElts; + for (auto type : elementTypes) { + assert(type.getCategory() == category && "Mismatched tuple elt categories"); + tupleTypeElts.push_back(TupleTypeElt(type.getRawASTType())); + } + auto tupleType = TupleType::get(tupleTypeElts, ctx); + return SILType::getPrimitiveType(tupleType->getCanonicalType(), category); +} + SILType SILType::getSILTokenType(const ASTContext &C) { return getPrimitiveObjectType(C.TheSILTokenType); } @@ -117,6 +132,10 @@ SILType SILType::getOpaqueIsolationType(const ASTContext &C) { return getPrimitiveObjectType(CanType(actorType).wrapInOptionalType()); } +SILType SILType::getBuiltinImplicitActorType(const ASTContext &ctx) { + return getPrimitiveObjectType(ctx.TheImplicitActorType->getCanonicalType()); +} + bool SILType::isTrivial(const SILFunction &F) const { auto contextType = hasTypeParameter() ? F.mapTypeIntoContext(*this) : *this; diff --git a/lib/SIL/IR/TypeLowering.cpp b/lib/SIL/IR/TypeLowering.cpp index d90e5d8b357..7d14993c50a 100644 --- a/lib/SIL/IR/TypeLowering.cpp +++ b/lib/SIL/IR/TypeLowering.cpp @@ -354,6 +354,7 @@ namespace { IMPL(BuiltinPackIndex, Trivial) IMPL(BuiltinNativeObject, Reference) IMPL(BuiltinBridgeObject, Reference) + IMPL(BuiltinImplicitActor, Reference) IMPL(BuiltinVector, Trivial) IMPL(SILToken, Trivial) IMPL(AnyMetatype, Trivial) @@ -2390,6 +2391,19 @@ namespace { UnsafeValueBufferTypeLowering(silType, Expansion, isSensitive); } + TypeLowering * + visitBuiltinImplicitActorType(CanBuiltinImplicitActorType type, + AbstractionPattern origType, + IsTypeExpansionSensitive_t isSensitive) { + auto silType = SILType::getPrimitiveObjectType(type); + auto properties = SILTypeProperties(); + properties.setTypeExpansionSensitive(isSensitive); + properties.setNonTrivial(); + properties.setLexical(IsLexical); + return new (TC) + MiscNontrivialTypeLowering(silType, properties, Expansion); + } + TypeLowering *visitPackType(CanPackType packType, AbstractionPattern origType, IsTypeExpansionSensitive_t isSensitive) { diff --git a/lib/SIL/IR/ValueOwnership.cpp b/lib/SIL/IR/ValueOwnership.cpp index 90429b649cd..d6f8f710c84 100644 --- a/lib/SIL/IR/ValueOwnership.cpp +++ b/lib/SIL/IR/ValueOwnership.cpp @@ -76,6 +76,7 @@ CONSTANT_OWNERSHIP_INST(Guaranteed, BeginBorrow) CONSTANT_OWNERSHIP_INST(Guaranteed, BorrowedFrom) CONSTANT_OWNERSHIP_INST(Guaranteed, LoadBorrow) CONSTANT_OWNERSHIP_INST(Guaranteed, FunctionExtractIsolation) +CONSTANT_OWNERSHIP_INST(Guaranteed, ImplicitActorToOpaqueIsolationCast) CONSTANT_OWNERSHIP_INST(None, GlobalValue) CONSTANT_OWNERSHIP_INST(Owned, AllocBox) CONSTANT_OWNERSHIP_INST(Owned, AllocExistentialBox) diff --git a/lib/SIL/Parser/ParseSIL.cpp b/lib/SIL/Parser/ParseSIL.cpp index e17ea880bda..7a542149e69 100644 --- a/lib/SIL/Parser/ParseSIL.cpp +++ b/lib/SIL/Parser/ParseSIL.cpp @@ -3617,6 +3617,28 @@ bool SILParser::parseSpecificSILInstruction(SILBuilder &B, break; } + case SILInstructionKind::ImplicitActorToOpaqueIsolationCastInst: { + SourceLoc ValueLoc; + SILValue Value; + + if (parseTypedValueRef(Value, ValueLoc, B) || + parseSILDebugLocation(InstLoc, B)) { + return true; + } + + if (B.getFunction().hasOwnership()) { + if (Value->getOwnershipKind() != OwnershipKind::Guaranteed) { + P.diagnose(ValueLoc, diag::sil_operand_has_wrong_ownership_kind, + Value->getOwnershipKind().asString(), + OwnershipKind(OwnershipKind::Guaranteed).asString()); + return true; + } + } + + ResultVal = B.createImplicitActorToOpaqueIsolationCast(InstLoc, Value); + break; + } + case SILInstructionKind::MoveValueInst: { bool allowsDiagnostics = false; auto isLexical = IsNotLexical; diff --git a/lib/SIL/Utils/InstWrappers.cpp b/lib/SIL/Utils/InstWrappers.cpp index 6d54e3d66a1..43721530ae2 100644 --- a/lib/SIL/Utils/InstWrappers.cpp +++ b/lib/SIL/Utils/InstWrappers.cpp @@ -58,6 +58,7 @@ bool ForwardingOperation::hasSameRepresentation() const { case SILInstructionKind::StructExtractInst: case SILInstructionKind::TupleExtractInst: case SILInstructionKind::TuplePackExtractInst: + case SILInstructionKind::ImplicitActorToOpaqueIsolationCastInst: return true; } } @@ -108,4 +109,4 @@ bool swift::isFixedStorageSemanticsCallKind(SILFunction *function) { } } return false; -} \ No newline at end of file +} diff --git a/lib/SIL/Utils/InstructionUtils.cpp b/lib/SIL/Utils/InstructionUtils.cpp index e07ff4fc2e8..813e7c91bdd 100644 --- a/lib/SIL/Utils/InstructionUtils.cpp +++ b/lib/SIL/Utils/InstructionUtils.cpp @@ -640,6 +640,7 @@ RuntimeEffect swift::getRuntimeEffect(SILInstruction *inst, SILType &impactType) case SILInstructionKind::FunctionExtractIsolationInst: case SILInstructionKind::TypeValueInst: case SILInstructionKind::IgnoredUseInst: + case SILInstructionKind::ImplicitActorToOpaqueIsolationCastInst: return RuntimeEffect::NoEffect; case SILInstructionKind::LoadInst: { diff --git a/lib/SIL/Verifier/SILVerifier.cpp b/lib/SIL/Verifier/SILVerifier.cpp index e08f02c68e9..10bfceda860 100644 --- a/lib/SIL/Verifier/SILVerifier.cpp +++ b/lib/SIL/Verifier/SILVerifier.cpp @@ -1091,10 +1091,10 @@ public: what + " must be Optional"); } - /// Require the operand to be an object of some type that conforms to - /// Actor or DistributedActor. - void requireAnyActorType(SILValue value, bool allowOptional, - bool allowExecutor, const Twine &what) { + /// Require the operand to be an object of some type that can be used to hop + /// since we can extract an executor from it. + void canExtractExecutorFrom(SILValue value, bool allowOptional, + bool allowExecutor, const Twine &what) { auto type = value->getType(); require(type.isObject(), what + " must be an object type"); @@ -1105,7 +1105,7 @@ public: } if (allowExecutor && isa(actorType)) return; - require(actorType->isAnyActorType(), + require(actorType->canBeIsolatedTo(), what + " must be some kind of actor type"); } @@ -2849,6 +2849,25 @@ public: "converting ownership does not affect the type"); } + void checkImplicitActorToOpaqueIsolationCastInst( + ImplicitActorToOpaqueIsolationCastInst *igi) { + if (F.hasOwnership()) { + require(igi->getValue()->getOwnershipKind() == OwnershipKind::Guaranteed, + "implicitactor_to_optionalactor_cast's operand should have " + "guaranteed ownership"); + require(igi->getOwnershipKind() == OwnershipKind::Guaranteed, + "result value should have guaranteed ownership"); + } + + require(igi->getValue()->getType() == + SILType::getBuiltinImplicitActorType( + igi->getFunction()->getASTContext()), + "operand should be an implicit actor type"); + require(igi->getType() == SILType::getOpaqueIsolationType( + igi->getFunction()->getASTContext()), + "result must be Optional"); + } + template void checkAccessEnforcement(AI *AccessInst) { if (AccessInst->getModule().getStage() != SILStage::Raw) { @@ -5810,20 +5829,20 @@ public: requireOptionalExecutorType(executor, "hop_to_executor operand in lowered SIL"); } else { - requireAnyActorType(executor, - /*allow optional*/ true, - /*allow executor*/ true, - "hop_to_executor operand"); + canExtractExecutorFrom(executor, + /*allow optional*/ true, + /*allow executor*/ true, + "hop_to_executor operand"); } } void checkExtractExecutorInst(ExtractExecutorInst *EEI) { requireObjectType(BuiltinExecutorType, EEI, "extract_executor result"); - requireAnyActorType(EEI->getExpectedExecutor(), - /*allow optional*/ false, - /*allow executor*/ false, - "extract_executor operand"); + canExtractExecutorFrom(EEI->getExpectedExecutor(), + /*allow optional*/ false, + /*allow executor*/ false, + "extract_executor operand"); if (EEI->getModule().getStage() == SILStage::Lowered) { require(false, "extract_executor instruction should have been lowered away"); @@ -7459,7 +7478,7 @@ public: auto *actorProtocol = ctx.getProtocol(KnownProtocolKind::Actor); auto *distributedProtocol = ctx.getProtocol(KnownProtocolKind::DistributedActor); - require(argType->isAnyActorType() || + require(argType->canBeIsolatedTo() || genericSig->requiresProtocol(argType, actorProtocol) || genericSig->requiresProtocol(argType, distributedProtocol), "Only any actor types can be isolated"); diff --git a/lib/SILGen/SILGenApply.cpp b/lib/SILGen/SILGenApply.cpp index 85fc2289e9e..a90f8747e2b 100644 --- a/lib/SILGen/SILGenApply.cpp +++ b/lib/SILGen/SILGenApply.cpp @@ -5845,8 +5845,12 @@ ApplyOptions CallEmission::emitArgumentsForNormalApply( args.push_back({}); // NOTE: Even though this calls emitActorInstanceIsolation, this also // handles glboal actor isolated cases. - args.back().push_back(SGF.emitActorInstanceIsolation( - callSite->Loc, executor, executor.getType().getASTType())); + auto erasedActor = + SGF.emitActorInstanceIsolation(callSite->Loc, executor, + executor.getType().getASTType()) + .borrow(SGF, callSite->Loc); + args.back().push_back( + SGF.B.convertToImplicitActor(callSite->Loc, erasedActor)); } uncurriedLoc = callSite->Loc; diff --git a/lib/SILGen/SILGenBridging.cpp b/lib/SILGen/SILGenBridging.cpp index ea0c664284f..5cbc6322de7 100644 --- a/lib/SILGen/SILGenBridging.cpp +++ b/lib/SILGen/SILGenBridging.cpp @@ -1674,23 +1674,22 @@ void SILGenFunction::emitNativeToForeignThunk(SILDeclRef thunk) { isolatedParameter && isolatedParameter->hasOption(SILParameterInfo::ImplicitLeading)) { assert(F.isAsync() && "Can only be async"); assert(isolation && "No isolation?!"); - switch (isolation->getKind()) { - case ActorIsolation::Unspecified: - case ActorIsolation::Nonisolated: - case ActorIsolation::NonisolatedUnsafe: - case ActorIsolation::CallerIsolationInheriting: - args.push_back(emitNonIsolatedIsolation(loc).getValue()); - break; - case ActorIsolation::ActorInstance: - llvm::report_fatal_error("Should never see this"); - break; - case ActorIsolation::GlobalActor: - args.push_back(emitLoadGlobalActorExecutor(isolation->getGlobalActor())); - break; - case ActorIsolation::Erased: - llvm::report_fatal_error("Should never see this"); - break; - } + auto value = [&]() -> SILValue { + switch (isolation->getKind()) { + case ActorIsolation::Unspecified: + case ActorIsolation::Nonisolated: + case ActorIsolation::NonisolatedUnsafe: + case ActorIsolation::CallerIsolationInheriting: + return emitNonIsolatedIsolation(loc).getValue(); + case ActorIsolation::ActorInstance: + llvm::report_fatal_error("Should never see this"); + case ActorIsolation::GlobalActor: + return emitLoadGlobalActorExecutor(isolation->getGlobalActor()); + case ActorIsolation::Erased: + llvm::report_fatal_error("Should never see this"); + } + }(); + args.push_back(B.convertToImplicitActor(loc, value)); } // Bridge the arguments. diff --git a/lib/SILGen/SILGenBuilder.cpp b/lib/SILGen/SILGenBuilder.cpp index ac7e831c0bc..57d19e604f8 100644 --- a/lib/SILGen/SILGenBuilder.cpp +++ b/lib/SILGen/SILGenBuilder.cpp @@ -1248,3 +1248,16 @@ ManagedValue SILGenBuilder::borrowObjectRValue(SILGenFunction &SGF, } return SGF.emitFormalEvaluationManagedBeginBorrow(loc, value); } + +SILValue SILGenBuilder::convertToImplicitActor(SILLocation loc, + SILValue value) { + auto type = SILType::getBuiltinImplicitActorType(getASTContext()); + if (value->getType() == type) + return value; + assert(value->getType() == SILType::getOpaqueIsolationType(getASTContext()) && + "Can only convert Optional to " + "Builtin.ImplicitActor"); + if (value->getOwnershipKind() != OwnershipKind::Guaranteed) + value = SGF.emitManagedBeginBorrow(loc, value).getValue(); + return createUncheckedValueCast(loc, value, type); +} diff --git a/lib/SILGen/SILGenBuilder.h b/lib/SILGen/SILGenBuilder.h index 2a296a82a33..40a5d64ba8e 100644 --- a/lib/SILGen/SILGenBuilder.h +++ b/lib/SILGen/SILGenBuilder.h @@ -551,6 +551,24 @@ public: createTupleAddrConstructor(loc, destAddr, values, isInitOfDest); } + + SILValue convertToImplicitActor(SILLocation loc, SILValue value); + + ManagedValue convertToImplicitActor(SILLocation loc, ManagedValue value) { + auto type = SILType::getBuiltinImplicitActorType(getASTContext()); + if (value.getType() == type) + return value; + SILValue result = + convertToImplicitActor(loc, value.borrow(SGF, loc).getValue()); + return ManagedValue::forBorrowedRValue(result); + } + + using SILBuilder::createImplicitActorToOpaqueIsolationCast; + ManagedValue createImplicitActorToOpaqueIsolationCast(SILLocation loc, + ManagedValue mv) { + return ManagedValue::forBorrowedRValue( + createImplicitActorToOpaqueIsolationCast(loc, mv.getUnmanagedValue())); + } }; } // namespace Lowering diff --git a/lib/SILGen/SILGenConcurrency.cpp b/lib/SILGen/SILGenConcurrency.cpp index 64455af5763..2a4eef22fba 100644 --- a/lib/SILGen/SILGenConcurrency.cpp +++ b/lib/SILGen/SILGenConcurrency.cpp @@ -27,7 +27,7 @@ using namespace Lowering; static void setExpectedExecutorForGeneric(SILGenFunction &SGF) { auto loc = RegularLocation::getAutoGeneratedLocation(SGF.F.getLocation()); - SGF.ExpectedExecutor.set(SGF.emitGenericExecutor(loc)); + SGF.ExpectedExecutor.set(SGF.emitNonIsolatedIsolation(loc).getValue()); } static void setExpectedExecutorForGlobalActor(SILGenFunction &SGF, @@ -284,8 +284,9 @@ void SILGenFunction::emitConstructorExpectedExecutorProlog() { loc.markAsPrologue(); loc = loc.asAutoGenerated(); - auto initialExecutor = emitGenericExecutor(loc); - B.createHopToExecutor(loc, initialExecutor, /*mandatory*/ false); + auto initialExecutor = emitNonIsolatedIsolation(loc); + B.createHopToExecutor(loc, initialExecutor.getValue(), + /*mandatory*/ false); return; } } @@ -424,6 +425,10 @@ emitNonOptionalActorInstanceIsolation(SILGenFunction &SGF, SILLocation loc, if (actor.getType() == anyActorTy) return actor; + if (actor.getType() == + SILType::getBuiltinImplicitActorType(SGF.getASTContext())) + return actor; + CanType anyActorType = anyActorTy.getASTType(); // If the actor is a distributed actor, (1) it had better be local @@ -448,6 +453,10 @@ SILGenFunction::emitActorInstanceIsolation(SILLocation loc, ManagedValue actor, return actor; } + // If we started with a Builtin.ImplicitActor, we're done. + if (actorType == getASTContext().TheImplicitActorType->getCanonicalType()) + return actor; + // Otherwise, if we have an optional value, we need to transform the payload. auto actorObjectType = actorType.getOptionalObjectType(); if (actorObjectType) { diff --git a/lib/SILGen/SILGenConstructor.cpp b/lib/SILGen/SILGenConstructor.cpp index 87fcaf8160e..7268ea79891 100644 --- a/lib/SILGen/SILGenConstructor.cpp +++ b/lib/SILGen/SILGenConstructor.cpp @@ -958,7 +958,7 @@ void SILGenFunction::emitClassConstructorAllocator(ConstructorDecl *ctor) { if (F.isNonisolatedNonsending()) { auto paramTy = F.mapTypeIntoContext( - SILType::getOpaqueIsolationType(F.getASTContext())); + SILType::getBuiltinImplicitActorType(F.getASTContext())); auto inContextParamTy = F.getLoweredType(paramTy.getASTType()) .getCategoryType(paramTy.getCategory()); SILArgument *arg = F.begin()->createFunctionArgument(inContextParamTy); diff --git a/lib/SILGen/SILGenExpr.cpp b/lib/SILGen/SILGenExpr.cpp index b5a287f5f49..3bdc21b1549 100644 --- a/lib/SILGen/SILGenExpr.cpp +++ b/lib/SILGen/SILGenExpr.cpp @@ -7492,13 +7492,9 @@ RValue RValueEmitter::visitCurrentContextIsolationExpr( auto *isolatedArg = SGF.F.maybeGetIsolatedArgument(); assert(isolatedArg && "Caller Isolation Inheriting without isolated parameter"); - ManagedValue isolatedMV; - if (isolatedArg->getOwnershipKind() == OwnershipKind::Guaranteed) { - isolatedMV = ManagedValue::forBorrowedRValue(isolatedArg); - } else { - isolatedMV = ManagedValue::forUnmanagedOwnedValue(isolatedArg); - } - return RValue(SGF, E, isolatedMV); + auto isolatedMV = ManagedValue::forBorrowedRValue(isolatedArg); + return RValue( + SGF, E, SGF.B.createImplicitActorToOpaqueIsolationCast(E, isolatedMV)); } if (isolation == ActorIsolation::ActorInstance) { diff --git a/lib/SILGen/SILGenPoly.cpp b/lib/SILGen/SILGenPoly.cpp index b2cfdcf8667..9863738abd2 100644 --- a/lib/SILGen/SILGenPoly.cpp +++ b/lib/SILGen/SILGenPoly.cpp @@ -5671,7 +5671,8 @@ static void buildThunkBody(SILGenFunction &SGF, SILLocation loc, assert(forwardedIsolationValue); SGF.B.createHopToExecutor(loc, forwardedIsolationValue, false); - argValues.push_back(forwardedIsolationValue); + argValues.push_back( + SGF.B.convertToImplicitActor(loc, forwardedIsolationValue)); } // Add the rest of the arguments. @@ -7130,49 +7131,47 @@ SILGenFunction::emitVTableThunk(SILDeclRef base, return *derivedIsolationCache; }; - switch (baseIsolation) { - case ActorIsolation::Unspecified: - case ActorIsolation::Nonisolated: - case ActorIsolation::NonisolatedUnsafe: - args.push_back(emitNonIsolatedIsolation(loc).getValue()); - break; - case ActorIsolation::Erased: - llvm::report_fatal_error("Found erased actor isolation?!"); - break; - case ActorIsolation::GlobalActor: { - auto globalActor = baseIsolation.getGlobalActor()->getCanonicalType(); - args.push_back(emitGlobalActorIsolation(loc, globalActor).getValue()); - break; - } - case ActorIsolation::ActorInstance: - case ActorIsolation::CallerIsolationInheriting: { - auto derivedIsolation = getDerivedIsolation(); - switch (derivedIsolation) { + auto arg = [&]() -> SILValue { + switch (baseIsolation) { case ActorIsolation::Unspecified: case ActorIsolation::Nonisolated: case ActorIsolation::NonisolatedUnsafe: - args.push_back(emitNonIsolatedIsolation(loc).getValue()); - break; + return emitNonIsolatedIsolation(loc).getValue(); case ActorIsolation::Erased: llvm::report_fatal_error("Found erased actor isolation?!"); - break; + return SILValue(); case ActorIsolation::GlobalActor: { - auto globalActor = - derivedIsolation.getGlobalActor()->getCanonicalType(); - args.push_back(emitGlobalActorIsolation(loc, globalActor).getValue()); - break; + auto globalActor = baseIsolation.getGlobalActor()->getCanonicalType(); + return emitGlobalActorIsolation(loc, globalActor).getValue(); } case ActorIsolation::ActorInstance: case ActorIsolation::CallerIsolationInheriting: { - auto isolatedArg = F.maybeGetIsolatedArgument(); - assert(isolatedArg); - args.push_back(isolatedArg); - break; + auto derivedIsolation = getDerivedIsolation(); + switch (derivedIsolation) { + case ActorIsolation::Unspecified: + case ActorIsolation::Nonisolated: + case ActorIsolation::NonisolatedUnsafe: + return emitNonIsolatedIsolation(loc).getValue(); + case ActorIsolation::Erased: + llvm::report_fatal_error("Found erased actor isolation?!"); + return SILValue(); + case ActorIsolation::GlobalActor: { + auto globalActor = + derivedIsolation.getGlobalActor()->getCanonicalType(); + return emitGlobalActorIsolation(loc, globalActor).getValue(); + } + case ActorIsolation::ActorInstance: + case ActorIsolation::CallerIsolationInheriting: { + auto isolatedArg = F.maybeGetIsolatedArgument(); + assert(isolatedArg); + return isolatedArg; + } + } } } - break; - } - } + }(); + + args.push_back(B.convertToImplicitActor(loc, arg)); // If our derived isolation is caller isolation inheriting and our base // isn't, we need to insert a hop so that derived can assume that it does @@ -7634,49 +7633,47 @@ void SILGenFunction::emitProtocolWitness( } return *witnessIsolationCache; }; - switch (reqtIsolation) { - case ActorIsolation::Unspecified: - case ActorIsolation::Nonisolated: - case ActorIsolation::NonisolatedUnsafe: - args.push_back(emitNonIsolatedIsolation(loc).getValue()); - break; - case ActorIsolation::Erased: - llvm::report_fatal_error("Found erased actor isolation?!"); - break; - case ActorIsolation::GlobalActor: { - auto globalActor = reqtIsolation.getGlobalActor()->getCanonicalType(); - args.push_back(emitGlobalActorIsolation(loc, globalActor).getValue()); - break; - } - case ActorIsolation::ActorInstance: - case ActorIsolation::CallerIsolationInheriting: { - auto witnessIsolation = getWitnessIsolation(); - switch (witnessIsolation) { + auto arg = [&]() -> SILValue { + switch (reqtIsolation) { case ActorIsolation::Unspecified: case ActorIsolation::Nonisolated: case ActorIsolation::NonisolatedUnsafe: - args.push_back(emitNonIsolatedIsolation(loc).getValue()); - break; + return emitNonIsolatedIsolation(loc).getValue(); case ActorIsolation::Erased: llvm::report_fatal_error("Found erased actor isolation?!"); - break; + return SILValue(); case ActorIsolation::GlobalActor: { - auto globalActor = - witnessIsolation.getGlobalActor()->getCanonicalType(); - args.push_back(emitGlobalActorIsolation(loc, globalActor).getValue()); - break; + auto globalActor = reqtIsolation.getGlobalActor()->getCanonicalType(); + return emitGlobalActorIsolation(loc, globalActor).getValue(); } case ActorIsolation::ActorInstance: case ActorIsolation::CallerIsolationInheriting: { - auto isolatedArg = F.maybeGetIsolatedArgument(); - assert(isolatedArg); - args.push_back(isolatedArg); - break; + auto witnessIsolation = getWitnessIsolation(); + switch (witnessIsolation) { + case ActorIsolation::Unspecified: + case ActorIsolation::Nonisolated: + case ActorIsolation::NonisolatedUnsafe: + return emitNonIsolatedIsolation(loc).getValue(); + case ActorIsolation::Erased: + llvm::report_fatal_error("Found erased actor isolation?!"); + return SILValue(); + case ActorIsolation::GlobalActor: { + auto globalActor = + witnessIsolation.getGlobalActor()->getCanonicalType(); + return emitGlobalActorIsolation(loc, globalActor).getValue(); + } + case ActorIsolation::ActorInstance: + case ActorIsolation::CallerIsolationInheriting: { + auto isolatedArg = F.maybeGetIsolatedArgument(); + assert(isolatedArg); + return isolatedArg; + } + } } } - break; - } - } + }(); + + args.push_back(B.convertToImplicitActor(loc, arg)); // If our reqtIsolation was not caller isolation inheriting, but our witness // isolation is caller isolation inheriting, hop onto the reqtIsolation so diff --git a/lib/SILOptimizer/Analysis/RegionAnalysis.cpp b/lib/SILOptimizer/Analysis/RegionAnalysis.cpp index c430f56bcbb..da7f3c7053e 100644 --- a/lib/SILOptimizer/Analysis/RegionAnalysis.cpp +++ b/lib/SILOptimizer/Analysis/RegionAnalysis.cpp @@ -3438,6 +3438,7 @@ CONSTANT_TRANSLATION(UncheckedAddrCastInst, Assign) CONSTANT_TRANSLATION(UncheckedOwnershipConversionInst, Assign) CONSTANT_TRANSLATION(IndexRawPointerInst, Assign) CONSTANT_TRANSLATION(MarkDependenceAddrInst, Assign) +CONSTANT_TRANSLATION(ImplicitActorToOpaqueIsolationCastInst, Assign) CONSTANT_TRANSLATION(InitExistentialMetatypeInst, Assign) CONSTANT_TRANSLATION(OpenExistentialMetatypeInst, Assign) diff --git a/lib/SILOptimizer/Mandatory/LowerHopToActor.cpp b/lib/SILOptimizer/Mandatory/LowerHopToActor.cpp index 53f6d01110e..504a0464b16 100644 --- a/lib/SILOptimizer/Mandatory/LowerHopToActor.cpp +++ b/lib/SILOptimizer/Mandatory/LowerHopToActor.cpp @@ -11,15 +11,16 @@ //===----------------------------------------------------------------------===// #define DEBUG_TYPE "insert-hop-to-executor" + #include "swift/AST/ConformanceLookup.h" #include "swift/Basic/Assertions.h" #include "swift/Basic/FrozenMultiMap.h" +#include "swift/SIL/Dominance.h" #include "swift/SIL/SILBuilder.h" #include "swift/SIL/SILFunction.h" -#include "swift/SIL/Dominance.h" #include "swift/SILOptimizer/Analysis/DominanceAnalysis.h" -#include "swift/SILOptimizer/Utils/SILOptFunctionBuilder.h" #include "swift/SILOptimizer/PassManager/Transforms.h" +#include "swift/SILOptimizer/Utils/SILOptFunctionBuilder.h" #include "llvm/ADT/ScopedHashTable.h" using namespace swift; @@ -52,6 +53,7 @@ namespace { /// IRGen expects hops to be to executors before it runs. class LowerHopToActor { DominanceInfo *Dominance; + SILOptFunctionBuilder &FuncBuilder; /// A map from an actor value to the dominating instruction that /// will derive the executor. @@ -71,7 +73,8 @@ class LowerHopToActor { SILValue actor, bool makeOptional); public: - LowerHopToActor(DominanceInfo *dominance) : Dominance(dominance) {} + LowerHopToActor(DominanceInfo *dominance, SILOptFunctionBuilder &funcBuilder) + : Dominance(dominance), FuncBuilder(funcBuilder) {} /// The entry point to the transformation. bool run(); @@ -301,6 +304,65 @@ static SILValue getExecutorForOptionalActor(SILBuilder &B, SILLocation loc, return result; } +static SILValue getExecutorForImplicitActor(SILOptFunctionBuilder &funcBuilder, + SILBuilderWithScope &parentBuilder, + SILLocation loc, SILValue actor) { + auto &ctx = parentBuilder.getASTContext(); + + // First create our parameter infos. Our params are @guaranteed @isolated + // @leading Builtin.ImplicitActor. + auto implicitIsolatedActorType = SILType::getBuiltinImplicitActorType(ctx); + SmallVector parameterInfo; + parameterInfo.push_back(SILParameterInfo( + implicitIsolatedActorType.getASTType(), + ParameterConvention::Direct_Guaranteed, + {SILParameterInfo::ImplicitLeading, SILParameterInfo::Isolated})); + + // Then create our result types. Our result is Optional. + auto executorType = SILType::getPrimitiveObjectType(ctx.TheExecutorType); + auto optionalExecutorType = SILType::getOptionalType(executorType); + SmallVector resultInfo; + resultInfo.push_back(SILResultInfo(optionalExecutorType.getASTType(), + ResultConvention::Unowned)); + + // Then use that to create our function type and SILFunction. We purposely use + // a shared function so we can take advantage of linkonce_odr. + auto autoGenLoc = RegularLocation::getAutoGeneratedLocation(); + CanSILFunctionType funcType = SILFunctionType::get( + nullptr, SILFunctionType::ExtInfo::getThin(), SILCoroutineKind::None, + ParameterConvention::Direct_Unowned, parameterInfo, {}, resultInfo, {}, + {}, {}, ctx); + auto *newFunc = funcBuilder.getOrCreateSharedFunction( + autoGenLoc, "_swift_implicitisolationactor_to_executor_cast", funcType, + IsNotBare, IsNotTransparent, IsNotSerialized, ProfileCounter(), + IsNotThunk, IsNotDynamic, IsNotDistributed, IsNotRuntimeAccessible); + + // If our function does not yet have a body... create that body. + // + // Our body is just a concatenation of clearing the implicit isolated actor + // bits + cast to Optional + getExecutorForOptionalActor. + if (newFunc->empty()) { + // First turn off ownership. + newFunc->setOwnershipEliminated(); + // Turn off inlining. This is a helper function to reduce code-size. We are + // too late for SIL to inline... but we want to also prevent LLVM from + // inlining as well. + newFunc->setInlineStrategy(Inline_t::NoInline); + + auto *front = newFunc->createBasicBlock(); + SILBuilder builder(front); + auto *fArg = front->createFunctionArgument(implicitIsolatedActorType); + auto value = SILValue( + builder.createImplicitActorToOpaqueIsolationCast(autoGenLoc, fArg)); + value = getExecutorForOptionalActor(builder, autoGenLoc, value); + builder.createReturn(autoGenLoc, value); + } + + // Then create the apply that calls our helper. + auto *funcRef = parentBuilder.createFunctionRef(loc, newFunc); + return parentBuilder.createApply(loc, funcRef, SubstitutionMap(), {actor}); +} + SILValue LowerHopToActor::emitGetExecutor(SILBuilderWithScope &B, SILLocation loc, SILValue actor, bool makeOptional) { @@ -317,7 +379,9 @@ SILValue LowerHopToActor::emitGetExecutor(SILBuilderWithScope &B, bool needEndBorrow = false; SILValue unmarkedExecutor; - if (auto wrappedActor = actorType->getOptionalObjectType()) { + if (actorType == B.getASTContext().TheImplicitActorType) { + unmarkedExecutor = getExecutorForImplicitActor(FuncBuilder, B, loc, actor); + } else if (auto wrappedActor = actorType->getOptionalObjectType()) { assert(makeOptional); if (B.hasOwnership() && actor->getOwnershipKind() != OwnershipKind::Guaranteed) { @@ -355,7 +419,8 @@ class LowerHopToActorPass : public SILFunctionTransform { void run() override { auto fn = getFunction(); auto domTree = getAnalysis()->get(fn); - LowerHopToActor pass(domTree); + SILOptFunctionBuilder funcBuilder(*this); + LowerHopToActor pass(domTree, funcBuilder); if (pass.run()) invalidateAnalysis(SILAnalysis::InvalidationKind::BranchesAndInstructions); } diff --git a/lib/SILOptimizer/Mandatory/OwnershipModelEliminator.cpp b/lib/SILOptimizer/Mandatory/OwnershipModelEliminator.cpp index 1339507d3fe..7174e21a020 100644 --- a/lib/SILOptimizer/Mandatory/OwnershipModelEliminator.cpp +++ b/lib/SILOptimizer/Mandatory/OwnershipModelEliminator.cpp @@ -252,6 +252,7 @@ struct OwnershipModelEliminatorVisitor HANDLE_FORWARDING_INST(DifferentiableFunctionExtract) HANDLE_FORWARDING_INST(MarkUninitialized) HANDLE_FORWARDING_INST(FunctionExtractIsolation) + HANDLE_FORWARDING_INST(ImplicitActorToOpaqueIsolationCast) #undef HANDLE_FORWARDING_INST }; diff --git a/lib/SILOptimizer/UtilityPasses/SerializeSILPass.cpp b/lib/SILOptimizer/UtilityPasses/SerializeSILPass.cpp index db266c8085b..3cee22cc13a 100644 --- a/lib/SILOptimizer/UtilityPasses/SerializeSILPass.cpp +++ b/lib/SILOptimizer/UtilityPasses/SerializeSILPass.cpp @@ -335,6 +335,7 @@ static bool hasOpaqueArchetype(TypeExpansionContext context, case SILInstructionKind::TuplePackElementAddrInst: case SILInstructionKind::TypeValueInst: case SILInstructionKind::IgnoredUseInst: + case SILInstructionKind::ImplicitActorToOpaqueIsolationCastInst: // Handle by operand and result check. break; diff --git a/lib/SILOptimizer/Utils/SILInliner.cpp b/lib/SILOptimizer/Utils/SILInliner.cpp index 87223592a10..d0e52f49567 100644 --- a/lib/SILOptimizer/Utils/SILInliner.cpp +++ b/lib/SILOptimizer/Utils/SILInliner.cpp @@ -940,6 +940,7 @@ InlineCost swift::instructionInlineCost(SILInstruction &I) { case SILInstructionKind::CopyableToMoveOnlyWrapperAddrInst: case SILInstructionKind::MoveOnlyWrapperToCopyableBoxInst: case SILInstructionKind::IgnoredUseInst: + case SILInstructionKind::ImplicitActorToOpaqueIsolationCastInst: return InlineCost::Free; // Typed GEPs are free. diff --git a/lib/Serialization/DeserializeSIL.cpp b/lib/Serialization/DeserializeSIL.cpp index 7ca5179c831..214f2b6aa4c 100644 --- a/lib/Serialization/DeserializeSIL.cpp +++ b/lib/Serialization/DeserializeSIL.cpp @@ -2779,6 +2779,14 @@ bool SILDeserializer::readSILInstruction(SILFunction *Fn, ResultInst = Builder.createDestructureStruct(Loc, Operand); break; } + case SILInstructionKind::ImplicitActorToOpaqueIsolationCastInst: { + assert(RecordKind == SIL_ONE_OPERAND); + auto Ty = MF->getType(TyID); + ResultInst = Builder.createImplicitActorToOpaqueIsolationCast( + Loc, getLocalValue(Builder.maybeGetFunction(), ValID, + getSILType(Ty, (SILValueCategory)TyCategory, Fn))); + break; + } case SILInstructionKind::UncheckedOwnershipConversionInst: { auto Ty = MF->getType(TyID); auto ResultKind = decodeValueOwnership(Attr); diff --git a/lib/Serialization/ModuleFormat.h b/lib/Serialization/ModuleFormat.h index 5fcf46693e0..3e6e56a70f7 100644 --- a/lib/Serialization/ModuleFormat.h +++ b/lib/Serialization/ModuleFormat.h @@ -58,7 +58,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0; /// describe what change you made. The content of this comment isn't important; /// it just ensures a conflict if two people change the module format. /// Don't worry about adhering to the 80-column limit for this line. -const uint16_t SWIFTMODULE_VERSION_MINOR = 966; // SIL asmname/section +const uint16_t SWIFTMODULE_VERSION_MINOR = 967; // implicitactor cast /// A standard hash seed used for all string hashes in a serialized module. /// diff --git a/lib/Serialization/SerializeSIL.cpp b/lib/Serialization/SerializeSIL.cpp index 478a5cd8404..894a679dca0 100644 --- a/lib/Serialization/SerializeSIL.cpp +++ b/lib/Serialization/SerializeSIL.cpp @@ -2371,6 +2371,16 @@ void SILSerializer::writeSILInstruction(const SILInstruction &SI) { addValueRef(operand)); break; } + case SILInstructionKind::ImplicitActorToOpaqueIsolationCastInst: { + unsigned abbrCode = SILAbbrCodes[SILOneOperandLayout::Code]; + auto operand = + cast(&SI)->getOperand(); + SILOneOperandLayout::emitRecord( + Out, ScratchRecord, abbrCode, (unsigned)SI.getKind(), 0 /*attr*/, + S.addTypeRef(operand->getType().getRawASTType()), + (unsigned)operand->getType().getCategory(), addValueRef(operand)); + break; + } case SILInstructionKind::BeginUnpairedAccessInst: { unsigned abbrCode = SILAbbrCodes[SILTwoOperandsExtraAttributeLayout::Code]; diff --git a/test/Concurrency/attr_execution/attr_execution.swift b/test/Concurrency/attr_execution/attr_execution.swift index be472c673eb..fd8fc637c0b 100644 --- a/test/Concurrency/attr_execution/attr_execution.swift +++ b/test/Concurrency/attr_execution/attr_execution.swift @@ -11,24 +11,24 @@ func concurrentTest() async {} // CHECK-LABEL: // callerTest() // CHECK: // Isolation: caller_isolation_inheriting -// CHECK: sil hidden [ossa] @$s14attr_execution10callerTestyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () { +// CHECK: sil hidden [ossa] @$s14attr_execution10callerTestyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () { nonisolated(nonsending) func callerTest() async {} struct Test { // CHECK-LABEL: // closure #1 in variable initialization expression of Test.x // CHECK: // Isolation: caller_isolation_inheriting - // CHECK: sil private [ossa] @$s14attr_execution4TestV1xyyYaYCcvpfiyyYaYCcfU_ : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () + // CHECK: sil private [ossa] @$s14attr_execution4TestV1xyyYaYCcvpfiyyYaYCcfU_ : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () var x: () async -> Void = {} // CHECK-LABEL: // Test.test() // CHECK: // Isolation: caller_isolation_inheriting - // CHECK: sil hidden [ossa] @$s14attr_execution4TestV4testyyYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed Test) -> () - // CHECK: bb0([[ISOLATION:%.*]] : @guaranteed $Optional, [[SELF:%.*]] : @guaranteed $Test) + // CHECK: sil hidden [ossa] @$s14attr_execution4TestV4testyyYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed Test) -> () + // CHECK: bb0([[ISOLATION:%.*]] : @guaranteed $Builtin.ImplicitActor, [[SELF:%.*]] : @guaranteed $Test) // CHECK: [[X_REF:%.*]] = struct_extract %1, #Test.x // CHECK: [[X_REF_COPY:%.]] = copy_value [[X_REF]] // CHECK: [[BORROWED_X:%.*]] = begin_borrow [[X_REF_COPY]] - // CHECK: apply [[BORROWED_X]]([[ISOLATION]]) : $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () + // CHECK: apply [[BORROWED_X]]([[ISOLATION]]) : $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () // CHECK: } // end sil function '$s14attr_execution4TestV4testyyYaF' func test() async { await x() @@ -36,11 +36,11 @@ struct Test { // CHECK-LABEL: // Test.testParam(fn:) // CHECK: // Isolation: caller_isolation_inheriting - // CHECK: sil hidden [ossa] @$s14attr_execution4TestV9testParam2fnyyyYaYCcSg_tYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed Optional<@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> ()>, @guaranteed Test) -> () - // CHECK: bb0([[ISOLATION:%.*]] : @guaranteed $Optional, [[OPT_FN:%.*]] : @guaranteed $Optional<@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> ()>, [[SELF:%.*]] : @guaranteed $Test) - // CHECK: bb1([[FN:%.*]] : @owned $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> ()) + // CHECK: sil hidden [ossa] @$s14attr_execution4TestV9testParam2fnyyyYaYCcSg_tYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed Optional<@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()>, @guaranteed Test) -> () + // CHECK: bb0([[ISOLATION:%.*]] : @guaranteed $Builtin.ImplicitActor, [[OPT_FN:%.*]] : @guaranteed $Optional<@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()>, [[SELF:%.*]] : @guaranteed $Test) + // CHECK: bb1([[FN:%.*]] : @owned $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()) // CHECK: [[BORROWED_FN:%.*]] = begin_borrow [[FN]] - // CHECK: apply [[BORROWED_FN]]([[ISOLATION]]) : $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () + // CHECK: apply [[BORROWED_FN]]([[ISOLATION]]) : $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () // CHECK: } // end sil function '$s14attr_execution4TestV9testParam2fnyyyYaYCcSg_tYaF' func testParam(fn: (() async -> Void)?) async { await fn?() @@ -49,11 +49,11 @@ struct Test { // CHECK-LABEL: // testLocal() // CHECK: // Isolation: caller_isolation_inheriting -// CHECK: sil hidden [ossa] @$s14attr_execution9testLocalyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () { -// CHECK: bb0([[ISOLATION:%.*]] : @guaranteed $Optional) -// CHECK: bb1([[FN:%.*]] : @owned $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> ()) +// CHECK: sil hidden [ossa] @$s14attr_execution9testLocalyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () { +// CHECK: bb0([[ISOLATION:%.*]] : @guaranteed $Builtin.ImplicitActor) +// CHECK: bb1([[FN:%.*]] : @owned $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()) // CHECK: [[BORROWED_FN:%.*]] = begin_borrow [[FN]] -// CHECK: apply [[BORROWED_FN]]([[ISOLATION]]) : $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () +// CHECK: apply [[BORROWED_FN]]([[ISOLATION]]) : $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () // CHECK: } // end sil function '$s14attr_execution9testLocalyyYaF' func testLocal() async { let fn: (() async -> Void)? = nil @@ -62,20 +62,20 @@ func testLocal() async { // CHECK-LABEL: // takesClosure(fn:) // CHECK: // Isolation: unspecified -// CHECK: sil hidden [ossa] @$s14attr_execution12takesClosure2fnyyyYaYCXE_tF : $@convention(thin) (@guaranteed @noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> ()) -> () +// CHECK: sil hidden [ossa] @$s14attr_execution12takesClosure2fnyyyYaYCXE_tF : $@convention(thin) (@guaranteed @noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()) -> () func takesClosure(fn: () async -> Void) { } // CHECK-LABEL: sil hidden [ossa] @$s14attr_execution11testClosureyyF : $@convention(thin) () -> () -// CHECK: [[CLOSURE:%.*]] = function_ref @$s14attr_execution11testClosureyyFyyYaYCXEfU_ : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () -// CHECK: [[THUNKED_CLOSURE:%.*]] = thin_to_thick_function %0 to $@noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () -// CHECK: [[TAKES_CLOSURE:%.*]] = function_ref @$s14attr_execution12takesClosure2fnyyyYaYCXE_tF : $@convention(thin) (@guaranteed @noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> ()) -> () +// CHECK: [[CLOSURE:%.*]] = function_ref @$s14attr_execution11testClosureyyFyyYaYCXEfU_ : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () +// CHECK: [[THUNKED_CLOSURE:%.*]] = thin_to_thick_function %0 to $@noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () +// CHECK: [[TAKES_CLOSURE:%.*]] = function_ref @$s14attr_execution12takesClosure2fnyyyYaYCXE_tF : $@convention(thin) (@guaranteed @noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()) -> () // CHECK: apply [[TAKES_CLOSURE]]([[THUNKED_CLOSURE]]) // CHECK: } // end sil function '$s14attr_execution11testClosureyyF' // CHECK-LABEL: // closure #1 in testClosure() // CHECK: // Isolation: caller_isolation_inheriting -// CHECK: sil private [ossa] @$s14attr_execution11testClosureyyFyyYaYCXEfU_ : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () +// CHECK: sil private [ossa] @$s14attr_execution11testClosureyyFyyYaYCXEfU_ : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () func testClosure() { takesClosure { } @@ -86,8 +86,8 @@ protocol P { func open(_: T) async {} -// CHECK-LABEL: sil hidden [ossa] @$s14attr_execution19testOpenExistential11existentialyAA1P_p_tYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed any P) -> () -// CHECK: bb0([[ISOLATION:%.*]] : @guaranteed $Optional, [[EXISTENTIAL:%.*]] : $*any P): +// CHECK-LABEL: sil hidden [ossa] @$s14attr_execution19testOpenExistential11existentialyAA1P_p_tYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed any P) -> () +// CHECK: bb0([[ISOLATION:%.*]] : @guaranteed $Builtin.ImplicitActor, [[EXISTENTIAL:%.*]] : $*any P): // CHECK: [[OPEN_REF:%.*]] = function_ref @$s14attr_execution4openyyxYaAA1PRzlF // CHECK: apply [[OPEN_REF]]<@opened("{{.*}}", any P) Self>([[ISOLATION]], {{.*}}) // CHECK: } // end sil function '$s14attr_execution19testOpenExistential11existentialyAA1P_p_tYaF' diff --git a/test/Concurrency/attr_execution/classes_silgen.swift b/test/Concurrency/attr_execution/classes_silgen.swift index fe82210ff52..d9ca3bed022 100644 --- a/test/Concurrency/attr_execution/classes_silgen.swift +++ b/test/Concurrency/attr_execution/classes_silgen.swift @@ -26,8 +26,8 @@ class AllDefault : SuperKlass { class AllConcurrent : SuperKlass { // CHECK-LABEL: vtable thunk for SuperKlass.callerTest() dispatching to AllConcurrent.callerTest() - // CHECK-NEXT: sil private [thunk] [ossa] @$s21attr_execution_silgen13AllConcurrentC10callerTestyyYaFAA10SuperKlassCADyyYaFTV : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed AllConcurrent) -> () { - // CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Optional, [[PARAM:%.*]] : @guaranteed $AllConcurrent): + // CHECK-NEXT: sil private [thunk] [ossa] @$s21attr_execution_silgen13AllConcurrentC10callerTestyyYaFAA10SuperKlassCADyyYaFTV : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed AllConcurrent) -> () { + // CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, [[PARAM:%.*]] : @guaranteed $AllConcurrent): // CHECK: [[FUNC:%.*]] = function_ref @$s21attr_execution_silgen13AllConcurrentC10callerTestyyYaF : $@convention(method) @async (@guaranteed AllConcurrent) -> () // CHECK: apply [[FUNC]]([[PARAM]]) // CHECK: hop_to_executor [[ACTOR]] @@ -44,9 +44,10 @@ class AllNonIsolatedUnsafe : SuperKlass { // CHECK-NEXT: sil private [thunk] [ossa] @$s21attr_execution_silgen20AllNonIsolatedUnsafeC14concurrentTestyyYaFAA10SuperKlassCADyyYaFTV : $@convention(method) @async (@guaranteed AllNonIsolatedUnsafe) -> () { // CHECK: bb0([[ARG:%.*]] : @guaranteed // CHECK: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt - // CHECK: hop_to_executor [[ACTOR]] - // CHECK: [[FUNC:%.*]] = function_ref @$s21attr_execution_silgen20AllNonIsolatedUnsafeC14concurrentTestyyYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed AllNonIsolatedUnsafe) -> () - // CHECK: apply [[FUNC]]([[ACTOR]], [[ARG]]) + // CHECK: [[ACTOR_CAST:%.*]] = unchecked_value_cast [[ACTOR]] to $Builtin.ImplicitActor + // CHECK: hop_to_executor [[ACTOR_CAST]] + // CHECK: [[FUNC:%.*]] = function_ref @$s21attr_execution_silgen20AllNonIsolatedUnsafeC14concurrentTestyyYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed AllNonIsolatedUnsafe) -> () + // CHECK: apply [[FUNC]]([[ACTOR_CAST]], [[ARG]]) // CHECK: } // end sil function '$s21attr_execution_silgen20AllNonIsolatedUnsafeC14concurrentTestyyYaFAA10SuperKlassCADyyYaFTV' override nonisolated(nonsending) func concurrentTest() async {} @@ -56,9 +57,11 @@ class AllNonIsolatedUnsafe : SuperKlass { // CHECK: [[ACTOR:%.*]] = apply {{%.*}}({{%.*}}) : $@convention(method) (@thick MainActor.Type) -> @owned MainActor // CHECK: [[ACTOR_E:%.*]] = init_existential_ref [[ACTOR]] // CHECK: [[ACTOR_E_OPT:%.*]] = enum $Optional, #Optional.some!enumelt, [[ACTOR_E]] - // CHECK: hop_to_executor [[ACTOR_E_OPT]] - // CHECK: [[FUNC:%.*]] = function_ref @$s21attr_execution_silgen20AllNonIsolatedUnsafeC13mainActorTestyyYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed AllNonIsolatedUnsafe) -> () - // CHECK: apply [[FUNC]]([[ACTOR_E_OPT]], [[ARG]]) + // CHECK: [[ACTOR_E_OPT_B:%.*]] = begin_borrow [[ACTOR_E_OPT]] + // CHECK: [[ACTOR_E_OPT_B_CAST:%.*]] = unchecked_value_cast [[ACTOR_E_OPT_B]] to $Builtin.ImplicitActor + // CHECK: hop_to_executor [[ACTOR_E_OPT_B_CAST]] + // CHECK: [[FUNC:%.*]] = function_ref @$s21attr_execution_silgen20AllNonIsolatedUnsafeC13mainActorTestyyYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed AllNonIsolatedUnsafe) -> () + // CHECK: apply [[FUNC]]([[ACTOR_E_OPT_B_CAST]], [[ARG]]) // CHECK: } // end sil function '$s21attr_execution_silgen20AllNonIsolatedUnsafeC13mainActorTestyyYaFAA10SuperKlassCADyyYaFTV' override nonisolated(nonsending) func mainActorTest() async {} } diff --git a/test/Concurrency/attr_execution/conversions_silgen.swift b/test/Concurrency/attr_execution/conversions_silgen.swift index 048b7efefe3..8dc94ed8c4f 100644 --- a/test/Concurrency/attr_execution/conversions_silgen.swift +++ b/test/Concurrency/attr_execution/conversions_silgen.swift @@ -41,10 +41,10 @@ func globalConcurrentFuncSendableKlass(_ x: SendableKlass) async -> SendableKlas // MARK: Tests // ///////////////// -// CHECK-LABEL: sil [ossa] @$s21attr_execution_silgen33testCallerToConcurrentNonIsolatedyyyyYaYCcYaF : $@convention(thin) @async (@guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> ()) -> () { -// CHECK: bb0([[FUNC:%.*]] : @guaranteed $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> ()): +// CHECK-LABEL: sil [ossa] @$s21attr_execution_silgen33testCallerToConcurrentNonIsolatedyyyyYaYCcYaF : $@convention(thin) @async (@guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()) -> () { +// CHECK: bb0([[FUNC:%.*]] : @guaranteed $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()): // CHECK: [[FUNC_COPY:%.*]] = copy_value [[FUNC]] -// CHECK: [[THUNK:%.*]] = function_ref @$sScA_pSgIegHgIL_IegH_TR : $@convention(thin) @async (@guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> ()) -> () +// CHECK: [[THUNK:%.*]] = function_ref @$sBAIegHgIL_IegH_TR : $@convention(thin) @async (@guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()) -> () // CHECK: partial_apply [callee_guaranteed] [[THUNK]]([[FUNC_COPY]]) // CHECK: } // end sil function '$s21attr_execution_silgen33testCallerToConcurrentNonIsolatedyyyyYaYCcYaF' public func testCallerToConcurrentNonIsolated(_ x: nonisolated(nonsending) @escaping () async -> ()) async { @@ -55,17 +55,18 @@ public func testCallerToConcurrentNonIsolated(_ x: nonisolated(nonsending) @esca // This thunk is used to convert a caller to a concurrent function. So, we pass in .none as the // isolated parameter. // -// CHECK-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sScA_pSgIegHgIL_IegH_TR : $@convention(thin) @async (@guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> ()) -> () { -// CHECK: bb0([[FUNC:%.*]] : @guaranteed $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> ()): +// CHECK-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sBAIegHgIL_IegH_TR : $@convention(thin) @async (@guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()) -> () { +// CHECK: bb0([[FUNC:%.*]] : @guaranteed $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()): // CHECK: [[ENUM:%.*]] = enum $Optional, #Optional.none!enumelt // CHECK: hop_to_executor [[ENUM]] -// CHECK: apply [[FUNC]]([[ENUM]]) -// CHECK: } // end sil function '$sScA_pSgIegHgIL_IegH_TR' +// CHECK: [[CAST:%.*]] = unchecked_value_cast [[ENUM]] to $Builtin.ImplicitActor +// CHECK: apply [[FUNC]]([[CAST]]) +// CHECK: } // end sil function '$sBAIegHgIL_IegH_TR' -// CHECK-LABEL: sil [ossa] @$s21attr_execution_silgen31testCallerToConcurrentMainActoryyyyYaYCcYaF : $@convention(thin) @async (@guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> ()) -> () { -// CHECK: bb0([[FUNC:%.*]] : @guaranteed $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> ()): +// CHECK-LABEL: sil [ossa] @$s21attr_execution_silgen31testCallerToConcurrentMainActoryyyyYaYCcYaF : $@convention(thin) @async (@guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()) -> () { +// CHECK: bb0([[FUNC:%.*]] : @guaranteed $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()): // CHECK: [[FUNC_COPY:%.*]] = copy_value [[FUNC]] -// CHECK: [[THUNK:%.*]] = function_ref @$sScA_pSgIegHgIL_IegH_TR : $@convention(thin) @async (@guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> ()) -> () +// CHECK: [[THUNK:%.*]] = function_ref @$sBAIegHgIL_IegH_TR : $@convention(thin) @async (@guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()) -> () // CHECK: partial_apply [callee_guaranteed] [[THUNK]]([[FUNC_COPY]]) // CHECK: } // end sil function '$s21attr_execution_silgen31testCallerToConcurrentMainActoryyyyYaYCcYaF' @MainActor @@ -77,7 +78,7 @@ public func testCallerToConcurrentMainActor(_ x: nonisolated(nonsending) @escapi // CHECK-LABEL: sil [ossa] @$s21attr_execution_silgen33testConcurrentToCallerNonIsolatedyyyyYacYaF : $@convention(thin) @async (@guaranteed @async @callee_guaranteed () -> ()) -> () { // CHECK: bb0([[FUNC:%.*]] : @guaranteed $@async @callee_guaranteed () -> ()): // CHECK: [[FUNC_COPY:%.*]] = copy_value [[FUNC]] -// CHECK: [[THUNK:%.*]] = function_ref @$sIegH_ScA_pSgIegHgIL_TR : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed @async @callee_guaranteed () -> ()) -> () +// CHECK: [[THUNK:%.*]] = function_ref @$sIegH_BAIegHgIL_TR : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed @async @callee_guaranteed () -> ()) -> () // CHECK: partial_apply [callee_guaranteed] [[THUNK]]([[FUNC_COPY]]) // CHECK: } // end sil function '$s21attr_execution_silgen33testConcurrentToCallerNonIsolatedyyyyYacYaF' public func testConcurrentToCallerNonIsolated(_ x: @escaping @concurrent () async -> ()) async { @@ -88,16 +89,16 @@ public func testConcurrentToCallerNonIsolated(_ x: @escaping @concurrent () asyn // This thunk has the "surface" of an @caller function, but just ignores the // isolated parameter and calls the concurrent funciton. // -// CHECK-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sIegH_ScA_pSgIegHgIL_TR : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed @async @callee_guaranteed () -> ()) -> () { -// CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Optional, [[FUNC:%.*]] : @guaranteed $@async @callee_guaranteed () -> ()): +// CHECK-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sIegH_BAIegHgIL_TR : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed @async @callee_guaranteed () -> ()) -> () { +// CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, [[FUNC:%.*]] : @guaranteed $@async @callee_guaranteed () -> ()): // CHECK: apply [[FUNC]] // CHECK: hop_to_executor [[ACTOR]] -// CHECK: } // end sil function '$sIegH_ScA_pSgIegHgIL_TR' +// CHECK: } // end sil function '$sIegH_BAIegHgIL_TR' // CHECK-LABEL: sil [ossa] @$s21attr_execution_silgen42testConcurrentToCallerNonIsolatedMainActoryyyyYacYaF : $@convention(thin) @async (@guaranteed @async @callee_guaranteed () -> ()) -> () { // CHECK: bb0([[FUNC:%.*]] : // CHECK: [[FUNC_COPY:%.*]] = copy_value [[FUNC]] -// CHECK: [[THUNK:%.*]] = function_ref @$sIegH_ScA_pSgIegHgIL_TR : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed @async @callee_guaranteed () -> ()) -> () +// CHECK: [[THUNK:%.*]] = function_ref @$sIegH_BAIegHgIL_TR : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed @async @callee_guaranteed () -> ()) -> () // CHECK: partial_apply [callee_guaranteed] [[THUNK]]([[FUNC_COPY]]) // CHECK: } // end sil function '$s21attr_execution_silgen42testConcurrentToCallerNonIsolatedMainActoryyyyYacYaF' @MainActor @@ -132,8 +133,8 @@ public func testConcurrentToConcurrent(_ x: @escaping @concurrent () async -> () await z() } -// CHECK-LABEL: sil [ossa] @$s21attr_execution_silgen012testCallerToE0yyyyYaYCcYaF : $@convention(thin) @async (@guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> ()) -> () { -// CHECK: bb0([[FUNC:%.*]] : @guaranteed $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> ()): +// CHECK-LABEL: sil [ossa] @$s21attr_execution_silgen012testCallerToE0yyyyYaYCcYaF : $@convention(thin) @async (@guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()) -> () { +// CHECK: bb0([[FUNC:%.*]] : @guaranteed $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()): // CHECK: [[COPY:%.*]] = copy_value [[FUNC]] // CHECK: [[Y:%.*]] = move_value [lexical] [var_decl] [[COPY]] // CHECK: [[BORROW_Y:%.*]] = begin_borrow [[Y]] @@ -150,8 +151,10 @@ public func testCallerToCaller(_ x: nonisolated(nonsending) @escaping () async - await z() } -// CHECK-LABEL: sil [ossa] @$s21attr_execution_silgen24testCallerLocalVariablesyyyyYaYCcYaF : $@convention(thin) @async (@guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> ()) -> () { -// CHECK: bb0([[PARAM:%.*]] : @guaranteed $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> ()): +// CHECK-LABEL: sil [ossa] @$s21attr_execution_silgen24testCallerLocalVariablesyyyyYaYCcYaF : $@convention(thin) @async (@guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()) -> () { +// CHECK: bb0([[PARAM:%.*]] : @guaranteed $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()): +// CHECK: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt +// CHECK: hop_to_executor [[ACTOR]] // CHECK: [[PARAM_COPY:%.*]] = copy_value [[PARAM]] // CHECK: [[Y:%.*]] = move_value [lexical] [var_decl] [[PARAM_COPY]] // CHECK: [[Y_B:%.*]] = begin_borrow [[Y]] @@ -159,9 +162,9 @@ public func testCallerToCaller(_ x: nonisolated(nonsending) @escaping () async - // CHECK: [[Y2:%.*]] = move_value [lexical] [var_decl] [[Y_B_C]] // CHECK: [[Y2_B:%.*]] = begin_borrow [[Y2]] // CHECK: [[Y2_B_C:%.*]] = copy_value [[Y2_B]] -// CHECK: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt +// CHECK: [[ACTOR_CAST:%.*]] = unchecked_value_cast [[ACTOR]] to $Builtin.ImplicitActor // CHECK: [[Y2_B_C_B:%.*]] = begin_borrow [[Y2_B_C]] -// CHECK: apply [[Y2_B_C_B]]([[ACTOR]]) +// CHECK: apply [[Y2_B_C_B]]([[ACTOR_CAST]]) // CHECK: } // end sil function '$s21attr_execution_silgen24testCallerLocalVariablesyyyyYaYCcYaF' public func testCallerLocalVariables(_ x: nonisolated(nonsending) @escaping () async -> ()) async { let y: nonisolated(nonsending) () async -> () = x @@ -186,15 +189,15 @@ public func testConcurrentLocalVariables(_ x: @escaping @concurrent () async -> await y2() } -// CHECK-LABEL: sil [ossa] @$s21attr_execution_silgen34testCallerConcurrentLocalVariablesyyyyYaYCcYaF : $@convention(thin) @async (@guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> ()) -> () { -// CHECK: bb0([[PARAM:%.*]] : @guaranteed $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> ()): +// CHECK-LABEL: sil [ossa] @$s21attr_execution_silgen34testCallerConcurrentLocalVariablesyyyyYaYCcYaF : $@convention(thin) @async (@guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()) -> () { +// CHECK: bb0([[PARAM:%.*]] : @guaranteed $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()): // CHECK: [[PARAM_COPY:%.*]] = copy_value [[PARAM]] -// CHECK: [[THUNK_1:%.*]] = function_ref @$sScA_pSgIegHgIL_IegH_TR : $@convention(thin) @async (@guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> ()) -> () +// CHECK: [[THUNK_1:%.*]] = function_ref @$sBAIegHgIL_IegH_TR : $@convention(thin) @async (@guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()) -> () // CHECK: [[PA:%.*]] = partial_apply [callee_guaranteed] [[THUNK_1]]([[PARAM_COPY]]) // CHECK: [[Y:%.*]] = move_value [lexical] [var_decl] [[PA]] // CHECK: [[Y_B:%.*]] = begin_borrow [[Y]] // CHECK: [[Y_B_C:%.*]] = copy_value [[Y_B]] -// CHECK: [[THUNK_2:%.*]] = function_ref @$sIegH_ScA_pSgIegHgIL_TR : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed @async @callee_guaranteed () -> ()) -> () +// CHECK: [[THUNK_2:%.*]] = function_ref @$sIegH_BAIegHgIL_TR : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed @async @callee_guaranteed () -> ()) -> () // CHECK: [[PA_2:%.*]] = partial_apply [callee_guaranteed] [[THUNK_2]]([[Y_B_C]]) // CHECK: } // end sil function '$s21attr_execution_silgen34testCallerConcurrentLocalVariablesyyyyYaYCcYaF' public func testCallerConcurrentLocalVariables(_ x: nonisolated(nonsending) @escaping () async -> ()) async { @@ -206,12 +209,12 @@ public func testCallerConcurrentLocalVariables(_ x: nonisolated(nonsending) @esc // CHECK-LABEL: sil [ossa] @$s21attr_execution_silgen34testConcurrentCallerLocalVariablesyyyyYacYaF : $@convention(thin) @async (@guaranteed @async @callee_guaranteed () -> ()) -> () { // CHECK: bb0([[PARAM:%.*]] : @guaranteed $@async @callee_guaranteed () -> ()): // CHECK: [[PARAM_C:%.*]] = copy_value [[PARAM]] -// CHECK: [[THUNK_1:%.*]] = function_ref @$sIegH_ScA_pSgIegHgIL_TR : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed @async @callee_guaranteed () -> ()) -> () +// CHECK: [[THUNK_1:%.*]] = function_ref @$sIegH_BAIegHgIL_TR : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed @async @callee_guaranteed () -> ()) -> () // CHECK: [[PA:%.*]] = partial_apply [callee_guaranteed] [[THUNK_1]]([[PARAM_C]]) // CHECK: [[Y:%.*]] = move_value [lexical] [var_decl] [[PA]] // CHECK: [[Y_B:%.*]] = begin_borrow [[Y]] // CHECK: [[Y_B_C:%.*]] = copy_value [[Y_B]] -// CHECK: [[THUNK_2:%.*]] = function_ref @$sScA_pSgIegHgIL_IegH_TR : $@convention(thin) @async (@guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> ()) -> () +// CHECK: [[THUNK_2:%.*]] = function_ref @$sBAIegHgIL_IegH_TR : $@convention(thin) @async (@guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()) -> () // CHECK: [[PA_2:%.*]] = partial_apply [callee_guaranteed] [[THUNK_2]]([[Y_B_C]]) // CHECK: } // end sil function '$s21attr_execution_silgen34testConcurrentCallerLocalVariablesyyyyYacYaF' public func testConcurrentCallerLocalVariables(_ x: @escaping @concurrent () async -> ()) async { @@ -220,13 +223,13 @@ public func testConcurrentCallerLocalVariables(_ x: @escaping @concurrent () asy await y2() } -// CHECK-LABEL: sil hidden [ossa] @$s21attr_execution_silgen22globalActorConversionsyyyyYac_yyYaYCctYaF : $@convention(thin) @async (@guaranteed @async @callee_guaranteed () -> (), @guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> ()) -> () { -// CHECK: bb0([[X:%.*]] : @guaranteed $@async @callee_guaranteed () -> (), [[Y:%.*]] : @guaranteed $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> ()): -// CHECK: [[GLOBAL_CALLER_FUNC:%.*]] = function_ref @$s21attr_execution_silgen16globalCallerFuncyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () -// FIVE: [[TTFI:%.*]] = thin_to_thick_function [[GLOBAL_CALLER_FUNC]] to $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () -// FIVE: [[THUNK:%.*]] = function_ref @$sScA_pSgIegHgIL_IegH_TRScMTU : $@convention(thin) @async (@guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> ()) -> () +// CHECK-LABEL: sil hidden [ossa] @$s21attr_execution_silgen22globalActorConversionsyyyyYac_yyYaYCctYaF : $@convention(thin) @async (@guaranteed @async @callee_guaranteed () -> (), @guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()) -> () { +// CHECK: bb0([[X:%.*]] : @guaranteed $@async @callee_guaranteed () -> (), [[Y:%.*]] : @guaranteed $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()): +// CHECK: [[GLOBAL_CALLER_FUNC:%.*]] = function_ref @$s21attr_execution_silgen16globalCallerFuncyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () +// FIVE: [[TTFI:%.*]] = thin_to_thick_function [[GLOBAL_CALLER_FUNC]] to $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () +// FIVE: [[THUNK:%.*]] = function_ref @$sBAIegHgIL_IegH_TRScMTU : $@convention(thin) @async (@guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()) -> () // FIVE: [[PA:%.*]] = partial_apply [callee_guaranteed] [[THUNK]]([[TTFI]]) : -// SIX: [[THUNK:%.*]] = function_ref @$sScA_pSgIetHgIL_IeghH_TRScMTU : $@convention(thin) @Sendable @async (@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> ()) -> () +// SIX: [[THUNK:%.*]] = function_ref @$sBAIetHgIL_IeghH_TRScMTU : $@convention(thin) @Sendable @async (@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()) -> () // SIX: [[PA:%.*]] = partial_apply [callee_guaranteed] [[THUNK]]([[GLOBAL_CALLER_FUNC]]) : // CHECK: [[V1:%.*]] = move_value [lexical] [var_decl] [[PA]] // CHECK: [[V1_B:%.*]] = begin_borrow [[V1]] @@ -253,7 +256,7 @@ public func testConcurrentCallerLocalVariables(_ x: @escaping @concurrent () asy // FIVE: apply [[V3_B_C_B]]() // FIVE: [[Y_C:%.*]] = copy_value [[Y]] -// FIVE: [[THUNK:%.*]] = function_ref @$sScA_pSgIegHgIL_IegH_TRScMTU : $@convention(thin) @async (@guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> ()) -> () +// FIVE: [[THUNK:%.*]] = function_ref @$sBAIegHgIL_IegH_TRScMTU : $@convention(thin) @async (@guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()) -> () // FIVE: [[PA:%.*]] = partial_apply [callee_guaranteed] [[THUNK]]([[Y_C]]) // FIVE: [[V4:%.*]] = move_value [lexical] [var_decl] [[PA]] // FIVE: [[V4_B:%.*]] = begin_borrow [[V4]] @@ -263,14 +266,16 @@ public func testConcurrentCallerLocalVariables(_ x: @escaping @concurrent () asy // CHECK: } // end sil function '$s21attr_execution_silgen22globalActorConversionsyyyyYac_yyYaYCctYaF' -// SIX-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sScA_pSgIetHgIL_IeghH_TRScMTU : $@convention(thin) @Sendable @async (@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> ()) -> () { +// SIX-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sBAIetHgIL_IeghH_TRScMTU : $@convention(thin) @Sendable @async (@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()) -> () { // SIX: bb0([[FUNC:%.*]] : $@convention(thin) @async (@sil_isolated // SIX: [[ACTOR:%.*]] = apply {{%.*}}({{%.*}}) : $@convention(method) (@thick MainActor.Type) -> @owned MainActor // SIX: [[E:%.*]] = init_existential_ref [[ACTOR]] : $MainActor : $MainActor, $any Actor // SIX: [[E_OPT:%.*]] = enum $Optional, #Optional.some!enumelt, [[E]] // SIX: hop_to_executor [[E_OPT]] -// SIX: apply [[FUNC]]([[E_OPT]]) : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () -// SIX: } // end sil function '$sScA_pSgIetHgIL_IeghH_TRScMTU' +// SIX: [[E_OPT_B:%.*]] = begin_borrow [[E_OPT]] +// SIX: [[E_OPT_B_CAST:%.*]] = unchecked_value_cast [[E_OPT_B]] to $Builtin.ImplicitActor +// SIX: apply [[FUNC]]([[E_OPT_B_CAST]]) : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () +// SIX: } // end sil function '$sBAIetHgIL_IeghH_TRScMTU' func globalActorConversions(_ x: @escaping @concurrent () async -> (), _ y: nonisolated(nonsending) @escaping () async -> ()) async { @@ -289,13 +294,13 @@ func globalActorConversions(_ x: @escaping @concurrent () async -> (), #endif } -// CHECK-LABEL: sil hidden [ossa] @$s21attr_execution_silgen23globalActorConversions2yyyAA13SendableKlassCYac_yADYaYCctYaF : $@convention(thin) @async (@guaranteed @async @callee_guaranteed (@guaranteed SendableKlass) -> (), @guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SendableKlass) -> ()) -> () { -// CHECK: bb0([[X:%.*]] : @guaranteed $@async @callee_guaranteed (@guaranteed SendableKlass) -> (), [[Y:%.*]] : @guaranteed $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SendableKlass) -> ()): -// CHECK: [[GLOBAL_CALLER_FUNC:%.*]] = function_ref @$s21attr_execution_silgen29globalCallerFuncSendableKlassyyAA0gH0CYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SendableKlass) -> () -// FIVE: [[TTFI:%.*]] = thin_to_thick_function [[GLOBAL_CALLER_FUNC]] to $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SendableKlass) -> () -// FIVE: [[THUNK:%.*]] = function_ref @$sScA_pSg21attr_execution_silgen13SendableKlassCIegHgILg_ADIegHg_TRScMTU : $@convention(thin) @async (@guaranteed SendableKlass, @guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SendableKlass) -> ()) -> () +// CHECK-LABEL: sil hidden [ossa] @$s21attr_execution_silgen23globalActorConversions2yyyAA13SendableKlassCYac_yADYaYCctYaF : $@convention(thin) @async (@guaranteed @async @callee_guaranteed (@guaranteed SendableKlass) -> (), @guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SendableKlass) -> ()) -> () { +// CHECK: bb0([[X:%.*]] : @guaranteed $@async @callee_guaranteed (@guaranteed SendableKlass) -> (), [[Y:%.*]] : @guaranteed $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SendableKlass) -> ()): +// CHECK: [[GLOBAL_CALLER_FUNC:%.*]] = function_ref @$s21attr_execution_silgen29globalCallerFuncSendableKlassyyAA0gH0CYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SendableKlass) -> () +// FIVE: [[TTFI:%.*]] = thin_to_thick_function [[GLOBAL_CALLER_FUNC]] to $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SendableKlass) -> () +// FIVE: [[THUNK:%.*]] = function_ref @$sBA21attr_execution_silgen13SendableKlassCIegHgILg_ACIegHg_TRScMTU : $@convention(thin) @async (@guaranteed SendableKlass, @guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SendableKlass) -> ()) -> () // FIVE: [[PA:%.*]] = partial_apply [callee_guaranteed] [[THUNK]]([[TTFI]]) : -// SIX: [[THUNK:%.*]] = function_ref @$sScA_pSg21attr_execution_silgen13SendableKlassCIetHgILg_ADIeghHg_TRScMTU : $@convention(thin) @Sendable @async (@guaranteed SendableKlass, @convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SendableKlass) -> ()) -> () +// SIX: [[THUNK:%.*]] = function_ref @$sBA21attr_execution_silgen13SendableKlassCIetHgILg_ACIeghHg_TRScMTU : $@convention(thin) @Sendable @async (@guaranteed SendableKlass, @convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SendableKlass) -> ()) -> () // SIX: [[PA:%.*]] = partial_apply [callee_guaranteed] [[THUNK]]([[GLOBAL_CALLER_FUNC]]) : // CHECK: [[V1:%.*]] = move_value [lexical] [var_decl] [[PA]] // CHECK: [[V1_B:%.*]] = begin_borrow [[V1]] @@ -322,7 +327,7 @@ func globalActorConversions(_ x: @escaping @concurrent () async -> (), // FIVE: apply [[V3_B_C_B]]({{%.*}}) // FIVE: [[Y_C:%.*]] = copy_value [[Y]] -// FIVE: [[THUNK:%.*]] = function_ref @$sScA_pSg21attr_execution_silgen13SendableKlassCIegHgILg_ADIegHg_TRScMTU : $@convention(thin) @async (@guaranteed SendableKlass, @guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SendableKlass) -> ()) -> () +// FIVE: [[THUNK:%.*]] = function_ref @$sBA21attr_execution_silgen13SendableKlassCIegHgILg_ACIegHg_TRScMTU : $@convention(thin) @async (@guaranteed SendableKlass, @guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SendableKlass) -> ()) -> () // FIVE: [[PA:%.*]] = partial_apply [callee_guaranteed] [[THUNK]]([[Y_C]]) // FIVE: [[V4:%.*]] = move_value [lexical] [var_decl] [[PA]] // FIVE: [[V4_B:%.*]] = begin_borrow [[V4]] @@ -332,30 +337,35 @@ func globalActorConversions(_ x: @escaping @concurrent () async -> (), // CHECK: } // end sil function '$s21attr_execution_silgen23globalActorConversions2yyyAA13SendableKlassCYac_yADYaYCctYaF' -// FIVE-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sScA_pSg21attr_execution_silgen13SendableKlassCIegHgILg_ADIegHg_TRScMTU : $@convention(thin) @async (@guaranteed SendableKlass, @guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SendableKlass) -> ()) -> () { +// FIVE-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sBA21attr_execution_silgen13SendableKlassCIegHgILg_ACIegHg_TRScMTU : $@convention(thin) @async (@guaranteed SendableKlass, @guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SendableKlass) -> ()) -> () { // FIVE: bb0([[ARG:%.*]] : @guaranteed $SendableKlass, [[FUNC:%.*]] : @guaranteed // FIVE: [[ACTOR:%.*]] = apply {{%.*}}({{%.*}}) : $@convention(method) (@thick MainActor.Type) -> @owned MainActor // FIVE: [[E:%.*]] = init_existential_ref [[ACTOR]] : $MainActor : $MainActor, $any Actor // FIVE: [[E_OPT:%.*]] = enum $Optional, #Optional.some!enumelt, [[E]] // FIVE: hop_to_executor [[E_OPT]] -// FIVE: apply [[FUNC]]([[E_OPT]], [[ARG]]) -// FIVE: } // end sil function '$sScA_pSg21attr_execution_silgen13SendableKlassCIegHgILg_ADIegHg_TRScMTU +// FIVE: [[E_OPT_B:%.*]] = begin_borrow [[E_OPT]] +// FIVE: [[E_OPT_B_CAST:%.*]] = unchecked_value_cast [[E_OPT_B]] to $Builtin.ImplicitActor +// FIVE: apply [[FUNC]]([[E_OPT_B_CAST]], [[ARG]]) +// FIVE: } // end sil function '$sBA21attr_execution_silgen13SendableKlassCIegHgILg_ACIegHg_TRScMTU' -// SIX-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sScA_pSg21attr_execution_silgen13SendableKlassCIetHgILg_ADIeghHg_TRScMTU : $@convention(thin) @Sendable @async (@guaranteed SendableKlass, @convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SendableKlass) -> ()) -> () { -// SIX: bb0([[ARG:%.*]] : @guaranteed $SendableKlass, [[FUNC:%.*]] : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SendableKlass) -> ()): +// SIX-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sBA21attr_execution_silgen13SendableKlassCIetHgILg_ACIeghHg_TRScMTU : $@convention(thin) @Sendable @async (@guaranteed SendableKlass, @convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SendableKlass) -> ()) -> () { +// SIX: bb0([[ARG:%.*]] : @guaranteed $SendableKlass, [[FUNC:%.*]] : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SendableKlass) -> ()): // SIX: [[ACTOR:%.*]] = apply {{%.*}}({{%.*}}) : $@convention(method) (@thick MainActor.Type) -> @owned MainActor // SIX: [[E:%.*]] = init_existential_ref [[ACTOR]] : $MainActor : $MainActor, $any Actor // SIX: [[E_OPT:%.*]] = enum $Optional, #Optional.some!enumelt, [[E]] // SIX: hop_to_executor [[E_OPT]] -// SIX: apply [[FUNC]]([[E_OPT]], [[ARG]]) -// SIX: // end sil function '$sScA_pSg21attr_execution_silgen13SendableKlassCIetHgILg_ADIeghHg_TRScMTU' +// SIX: [[E_OPT_B:%.*]] = begin_borrow [[E_OPT]] +// SIX: [[E_OPT_B_CAST:%.*]] = unchecked_value_cast [[E_OPT_B]] to $Builtin.ImplicitActor +// SIX: apply [[FUNC]]([[E_OPT_B_CAST]], [[ARG]]) +// SIX: } // end sil function '$sBA21attr_execution_silgen13SendableKlassCIetHgILg_ACIeghHg_TRScMTU' -// CHECK-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sScA_pSg21attr_execution_silgen13SendableKlassCIegHgILg_ADIegHg_TR : $@convention(thin) @async (@guaranteed SendableKlass, @guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SendableKlass) -> ()) -> () { +// CHECK-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sBA21attr_execution_silgen13SendableKlassCIegHgILg_ACIegHg_TR : $@convention(thin) @async (@guaranteed SendableKlass, @guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SendableKlass) -> ()) -> () { // CHECK: bb0([[ARG:%.*]] : @guaranteed $SendableKlass, [[FUNC:%.*]] : @guaranteed // CHECK: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt // CHECK: hop_to_executor [[ACTOR]] -// CHECK: apply [[FUNC]]([[ACTOR]], [[ARG]]) -// CHECK: } // end sil function '$sScA_pSg21attr_execution_silgen13SendableKlassCIegHgILg_ADIegHg_TR' +// CHECK: [[ACTOR_CAST:%.*]] = unchecked_value_cast [[ACTOR]] to $Builtin.ImplicitActor +// CHECK: apply [[FUNC]]([[ACTOR_CAST]], [[ARG]]) +// CHECK: } // end sil function '$sBA21attr_execution_silgen13SendableKlassCIegHgILg_ACIegHg_TR' func globalActorConversions2(_ x: @escaping @concurrent (SendableKlass) async -> (), _ y: nonisolated(nonsending) @escaping (SendableKlass) async -> ()) async { let v1: @MainActor (SendableKlass) async -> Void = globalCallerFuncSendableKlass @@ -372,13 +382,13 @@ func globalActorConversions2(_ x: @escaping @concurrent (SendableKlass) async -> await v5(SendableKlass()) } -// CHECK-LABEL: sil hidden [ossa] @$s21attr_execution_silgen23globalActorConversions3yyAA13SendableKlassCADYac_A2DYaYCctYaF : $@convention(thin) @async (@guaranteed @async @callee_guaranteed (@guaranteed SendableKlass) -> @owned SendableKlass, @guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SendableKlass) -> @owned SendableKlass) -> () { -// CHECK: bb0([[X:%.*]] : @guaranteed $@async @callee_guaranteed (@guaranteed SendableKlass) -> @owned SendableKlass, [[Y:%.*]] : @guaranteed $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SendableKlass) -> @owned SendableKlass): -// CHECK: [[GLOBAL_CALLER_FUNC:%.*]] = function_ref @$s21attr_execution_silgen29globalCallerFuncSendableKlassyAA0gH0CADYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SendableKlass) -> @owned SendableKlass -// FIVE: [[TTFI:%.*]] = thin_to_thick_function [[GLOBAL_CALLER_FUNC]] to $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SendableKlass) -> @owned SendableKlass -// FIVE: [[THUNK:%.*]] = function_ref @$sScA_pSg21attr_execution_silgen13SendableKlassCADIegHgILgo_A2DIegHgo_TRScMTU : $@convention(thin) @async (@guaranteed SendableKlass, @guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SendableKlass) -> @owned SendableKlass) -> @owned SendableKlass +// CHECK-LABEL: sil hidden [ossa] @$s21attr_execution_silgen23globalActorConversions3yyAA13SendableKlassCADYac_A2DYaYCctYaF : $@convention(thin) @async (@guaranteed @async @callee_guaranteed (@guaranteed SendableKlass) -> @owned SendableKlass, @guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SendableKlass) -> @owned SendableKlass) -> () { +// CHECK: bb0([[X:%.*]] : @guaranteed $@async @callee_guaranteed (@guaranteed SendableKlass) -> @owned SendableKlass, [[Y:%.*]] : @guaranteed $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SendableKlass) -> @owned SendableKlass): +// CHECK: [[GLOBAL_CALLER_FUNC:%.*]] = function_ref @$s21attr_execution_silgen29globalCallerFuncSendableKlassyAA0gH0CADYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SendableKlass) -> @owned SendableKlass +// FIVE: [[TTFI:%.*]] = thin_to_thick_function [[GLOBAL_CALLER_FUNC]] to $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SendableKlass) -> @owned SendableKlass +// FIVE: [[THUNK:%.*]] = function_ref @$sBA21attr_execution_silgen13SendableKlassCACIegHgILgo_A2CIegHgo_TRScMTU : $@convention(thin) @async (@guaranteed SendableKlass, @guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SendableKlass) -> @owned SendableKlass) -> @owned SendableKlass // FIVE: [[PA:%.*]] = partial_apply [callee_guaranteed] [[THUNK]]([[TTFI]]) -// SIX: [[THUNK:%.*]] = function_ref @$sScA_pSg21attr_execution_silgen13SendableKlassCADIetHgILgo_A2DIeghHgo_TRScMTU : $@convention(thin) @Sendable @async (@guaranteed SendableKlass, @convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SendableKlass) -> @owned SendableKlass) -> @owned SendableKlass +// SIX: [[THUNK:%.*]] = function_ref @$sBA21attr_execution_silgen13SendableKlassCACIetHgILgo_A2CIeghHgo_TRScMTU : $@convention(thin) @Sendable @async (@guaranteed SendableKlass, @convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SendableKlass) -> @owned SendableKlass) -> @owned SendableKlass // SIX: [[PA:%.*]] = partial_apply [callee_guaranteed] [[THUNK]]([[GLOBAL_CALLER_FUNC]]) // CHECK: [[V1:%.*]] = move_value [lexical] [var_decl] [[PA]] // CHECK: [[V1_B:%.*]] = begin_borrow [[V1]] @@ -404,7 +414,7 @@ func globalActorConversions2(_ x: @escaping @concurrent (SendableKlass) async -> // FIVE: apply [[V3_B_C_B]]({{%.*}}) // FIVE: [[Y_C:%.*]] = copy_value [[Y]] -// FIVE: [[THUNK:%.*]] = function_ref @$sScA_pSg21attr_execution_silgen13SendableKlassCADIegHgILgo_A2DIegHgo_TRScMTU : $@convention(thin) @async (@guaranteed SendableKlass, @guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SendableKlass) -> @owned SendableKlass) -> @owned SendableKlass +// FIVE: [[THUNK:%.*]] = function_ref @$sBA21attr_execution_silgen13SendableKlassCACIegHgILgo_A2CIegHgo_TRScMTU : $@convention(thin) @async (@guaranteed SendableKlass, @guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SendableKlass) -> @owned SendableKlass) -> @owned SendableKlass // FIVE: [[PA:%.*]] = partial_apply [callee_guaranteed] [[THUNK]]([[Y_C]]) // FIVE: [[V4:%.*]] = move_value [lexical] [var_decl] [[PA]] // FIVE: [[V4_B:%.*]] = begin_borrow [[V4]] @@ -413,34 +423,38 @@ func globalActorConversions2(_ x: @escaping @concurrent (SendableKlass) async -> // FIVE: apply [[V4_B_C_B]]({{%.*}}) // CHECK: [[Y_C:%.*]] = copy_value [[Y]] -// CHECK: [[THUNK:%.*]] = function_ref @$sScA_pSg21attr_execution_silgen13SendableKlassCADIegHgILgo_A2DIegHgo_TR : $@convention(thin) @async (@guaranteed SendableKlass, @guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SendableKlass) -> @owned SendableKlass) -> @owned SendableKlass +// CHECK: [[THUNK:%.*]] = function_ref @$sBA21attr_execution_silgen13SendableKlassCACIegHgILgo_A2CIegHgo_TR : $@convention(thin) @async (@guaranteed SendableKlass, @guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SendableKlass) -> @owned SendableKlass) -> @owned SendableKlass // CHECK: [[PA:%.*]] = partial_apply [callee_guaranteed] [[THUNK]]([[Y_C]]) // CHECK: [[V5:%.*]] = move_value [lexical] [var_decl] [[PA]] // CHECK: } // end sil function '$s21attr_execution_silgen23globalActorConversions3yyAA13SendableKlassCADYac_A2DYaYCctYaF' -// FIVE-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sScA_pSg21attr_execution_silgen13SendableKlassCADIegHgILgo_A2DIegHgo_TRScMTU : $@convention(thin) @async (@guaranteed SendableKlass, @guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SendableKlass) -> @owned SendableKlass) -> @owned SendableKlass { +// FIVE-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sBA21attr_execution_silgen13SendableKlassCACIegHgILgo_A2CIegHgo_TRScMTU : $@convention(thin) @async (@guaranteed SendableKlass, @guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SendableKlass) -> @owned SendableKlass) -> @owned SendableKlass { // FIVE: bb0([[ARG:%.*]] : @guaranteed $SendableKlass, [[FUNC:%.*]] : @guaranteed // FIVE: [[ACTOR:%.*]] = apply {{%.*}}({{%.*}}) : $@convention(method) (@thick MainActor.Type) -> @owned MainActor // FIVE: [[E:%.*]] = init_existential_ref [[ACTOR]] : $MainActor : $MainActor, $any Actor // FIVE: [[E_OPT:%.*]] = enum $Optional, #Optional.some!enumelt, [[E]] // FIVE: hop_to_executor [[E_OPT]] -// FIVE: apply [[FUNC]]([[E_OPT]], [[ARG]]) -// FIVE: } // end sil function '$sScA_pSg21attr_execution_silgen13SendableKlassCADIegHgILgo_A2DIegHgo_TRScMTU' +// FIVE: [[E_OPT_B:%.*]] = begin_borrow [[E_OPT]] +// FIVE: [[E_OPT_B_CAST:%.*]] = unchecked_value_cast [[E_OPT_B]] to $Builtin.ImplicitActor +// FIVE: apply [[FUNC]]([[E_OPT_B_CAST]], [[ARG]]) +// FIVE: } // end sil function '$sBA21attr_execution_silgen13SendableKlassCACIegHgILgo_A2CIegHgo_TRScMTU' -// SIX-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sScA_pSg21attr_execution_silgen13SendableKlassCADIetHgILgo_A2DIeghHgo_TRScMTU : $@convention(thin) @Sendable @async (@guaranteed SendableKlass, @convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SendableKlass) -> @owned SendableKlass) -> @owned SendableKlass { -// SIX: bb0([[ARG:%.*]] : @guaranteed $SendableKlass, [[FUNC:%.*]] : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SendableKlass) -> @owned SendableKlass): +// SIX-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sBA21attr_execution_silgen13SendableKlassCACIetHgILgo_A2CIeghHgo_TRScMTU : $@convention(thin) @Sendable @async (@guaranteed SendableKlass, @convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SendableKlass) -> @owned SendableKlass) -> @owned SendableKlass { +// SIX: bb0([[ARG:%.*]] : @guaranteed $SendableKlass, [[FUNC:%.*]] : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SendableKlass) -> @owned SendableKlass): // SIX: [[ACTOR:%.*]] = apply {{%.*}}({{%.*}}) : $@convention(method) (@thick MainActor.Type) -> @owned MainActor // SIX: [[E:%.*]] = init_existential_ref [[ACTOR]] : $MainActor : $MainActor, $any Actor // SIX: [[E_OPT:%.*]] = enum $Optional, #Optional.some!enumelt, [[E]] // SIX: hop_to_executor [[E_OPT]] -// SIX: apply [[FUNC]]([[E_OPT]], [[ARG]]) -// SIX: } // end sil function '$sScA_pSg21attr_execution_silgen13SendableKlassCADIetHgILgo_A2DIeghHgo_TRScMTU' +// SIX: [[E_OPT_B:%.*]] = begin_borrow [[E_OPT]] +// SIX: [[E_OPT_B_CAST:%.*]] = unchecked_value_cast [[E_OPT_B]] to $Builtin.ImplicitActor +// SIX: apply [[FUNC]]([[E_OPT_B_CAST]], [[ARG]]) +// SIX: } // end sil function '$sBA21attr_execution_silgen13SendableKlassCACIetHgILgo_A2CIeghHgo_TRScMTU' -// CHECK-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sScA_pSg21attr_execution_silgen13SendableKlassCADIegHgILgo_A2DIegHgo_TR : $@convention(thin) @async (@guaranteed SendableKlass, @guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SendableKlass) -> @owned SendableKlass) -> @owned SendableKlass { +// CHECK-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sBA21attr_execution_silgen13SendableKlassCACIegHgILgo_A2CIegHgo_TR : $@convention(thin) @async (@guaranteed SendableKlass, @guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SendableKlass) -> @owned SendableKlass) -> @owned SendableKlass { // CHECK: bb0([[ARG:%.*]] : @guaranteed $SendableKlass, [[FUNC:%.*]] : @guarantee // CHECK: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt // CHECK: hop_to_executor [[ACTOR]] -// CHECK: } // end sil function '$sScA_pSg21attr_execution_silgen13SendableKlassCADIegHgILgo_A2DIegHgo_TR' +// CHECK: } // end sil function '$sBA21attr_execution_silgen13SendableKlassCACIegHgILgo_A2CIegHgo_TR' func globalActorConversions3(_ x: @escaping @concurrent (SendableKlass) async -> SendableKlass, _ y: nonisolated(nonsending) @escaping (SendableKlass) async -> SendableKlass) async { let v1: @MainActor (SendableKlass) async -> SendableKlass = globalCallerFuncSendableKlass @@ -461,11 +475,11 @@ func globalActorConversions3(_ x: @escaping @concurrent (SendableKlass) async -> // CHECK: bb0([[X:%.*]] : @guaranteed $@Sendable @callee_guaranteed (@guaranteed NonSendableKlass) -> (), [[Y:%.*]] : @guaranteed $@Sendable @callee_guaranteed (@guaranteed SendableKlass) -> ()): // CHECK: [[X_C:%.*]] = copy_value [[X]] -// CHECK: [[THUNK:%.*]] = function_ref @$s21attr_execution_silgen16NonSendableKlassCIeghg_ScA_pSgACIegHgILg_TR : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed NonSendableKlass, @guaranteed @Sendable @callee_guaranteed (@guaranteed NonSendableKlass) -> ()) -> () +// CHECK: [[THUNK:%.*]] = function_ref @$s21attr_execution_silgen16NonSendableKlassCIeghg_BAACIegHgILg_TR : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed NonSendableKlass, @guaranteed @Sendable @callee_guaranteed (@guaranteed NonSendableKlass) -> ()) -> () // CHECK: [[PAI:%.*]] = partial_apply [callee_guaranteed] [[THUNK]]([[X_C]]) // CHECK: [[Y_C:%.*]] = copy_value [[Y]] -// CHECK: [[THUNK:%.*]] = function_ref @$s21attr_execution_silgen13SendableKlassCIeghg_ScA_pSgACIegHgILg_TRScMTU : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SendableKlass, @guaranteed @Sendable @callee_guaranteed (@guaranteed SendableKlass) -> ()) -> () +// CHECK: [[THUNK:%.*]] = function_ref @$s21attr_execution_silgen13SendableKlassCIeghg_BAACIegHgILg_TRScMTU : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SendableKlass, @guaranteed @Sendable @callee_guaranteed (@guaranteed SendableKlass) -> ()) -> () // CHECK: [[PAI:%.*]] = partial_apply [callee_guaranteed] [[THUNK]]([[Y_C]]) // CHECK: [[Y_C:%.*]] = copy_value [[Y]] @@ -474,20 +488,20 @@ func globalActorConversions3(_ x: @escaping @concurrent (SendableKlass) async -> // CHECK: } // end sil function '$s21attr_execution_silgen26conversionsFromSyncToAsyncyyyAA16NonSendableKlassCYbc_yAA0jK0CYbScMYcctYaF' -// CHECK-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$s21attr_execution_silgen16NonSendableKlassCIeghg_ScA_pSgACIegHgILg_TR : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed NonSendableKlass, @guaranteed @Sendable @callee_guaranteed (@guaranteed NonSendableKlass) -> ()) -> () { -// CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Optional +// CHECK-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$s21attr_execution_silgen16NonSendableKlassCIeghg_BAACIegHgILg_TR : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed NonSendableKlass, @guaranteed @Sendable @callee_guaranteed (@guaranteed NonSendableKlass) -> ()) -> () { +// CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor // CHECK: apply {{%.*}}({{%.*}}) : $@Sendable @callee_guaranteed (@guaranteed NonSendableKlass) -> () // CHECK: hop_to_executor [[ACTOR]] -// CHECK: } // end sil function '$s21attr_execution_silgen16NonSendableKlassCIeghg_ScA_pSgACIegHgILg_TR' +// CHECK: } // end sil function '$s21attr_execution_silgen16NonSendableKlassCIeghg_BAACIegHgILg_TR' -// CHECK-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$s21attr_execution_silgen13SendableKlassCIeghg_ScA_pSgACIegHgILg_TRScMTU : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SendableKlass, @guaranteed @Sendable @callee_guaranteed (@guaranteed SendableKlass) -> ()) -> () { -// CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Optional, [[ARG:%.*]] : @guaranteed $SendableKlass, [[FUNC:%.*]] : @guaranteed $@Sendable @callee_guaranteed +// CHECK-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$s21attr_execution_silgen13SendableKlassCIeghg_BAACIegHgILg_TRScMTU : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SendableKlass, @guaranteed @Sendable @callee_guaranteed (@guaranteed SendableKlass) -> ()) -> () { +// CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, [[ARG:%.*]] : @guaranteed $SendableKlass, [[FUNC:%.*]] : @guaranteed $@Sendable @callee_guaranteed // CHECK: [[MAIN_ACTOR:%.*]] = apply {{%.*}}({{%.*}}) : $@convention(method) (@thick MainActor.Type) -> @owned MainActor // CHECK: [[MAIN_ACTOR_B:%.*]] = begin_borrow [[MAIN_ACTOR]] // CHECK: hop_to_executor [[MAIN_ACTOR_B]] // CHECK: apply [[FUNC]]([[ARG]]) // CHECK: hop_to_executor [[ACTOR]] -// CHECK: } // end sil function '$s21attr_execution_silgen13SendableKlassCIeghg_ScA_pSgACIegHgILg_TRScMTU' +// CHECK: } // end sil function '$s21attr_execution_silgen13SendableKlassCIeghg_BAACIegHgILg_TRScMTU' // CHECK-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$s21attr_execution_silgen13SendableKlassCIeghg_ACIegHg_TRScMTU : $@convention(thin) @async (@guaranteed SendableKlass, @guaranteed @Sendable @callee_guaranteed (@guaranteed SendableKlass) -> ()) -> () { // CHECK: bb0([[ARG:%.*]] : @guaranteed $SendableKlass, [[FUNC:%.*]] : @guaranteed $@Sendable @callee_guaranteed (@guaranteed SendableKlass) -> ()): @@ -506,47 +520,48 @@ func conversionsFromSyncToAsync(_ x: @escaping @Sendable (NonSendableKlass) -> V } func testThatClosuresAssumeIsolation(fn: inout nonisolated(nonsending) (Int) async -> Void) { - // CHECK-LABEL: sil private [ossa] @$s21attr_execution_silgen31testThatClosuresAssumeIsolation2fnyySiYaYCcz_tFyyYaYCcfU_ : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () { - // CHECK: bb0([[EXECUTOR:%.*]] : @guaranteed $Optional): + // CHECK-LABEL: sil private [ossa] @$s21attr_execution_silgen31testThatClosuresAssumeIsolation2fnyySiYaYCcz_tFyyYaYCcfU_ : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () { + // CHECK: bb0([[EXECUTOR:%.*]] : @guaranteed $Builtin.ImplicitActor): // CHECK: hop_to_executor [[EXECUTOR]] let _: nonisolated(nonsending) () async -> Void = { - 42 + _ = 42 } func testParam(_: nonisolated(nonsending) () async throws -> Void) {} - // CHECK-LABEL: sil private [ossa] @$s21attr_execution_silgen31testThatClosuresAssumeIsolation2fnyySiYaYCcz_tFyyYaYCXEfU0_ : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> @error any Error { - // CHECK: bb0([[EXECUTOR:%.*]] : @guaranteed $Optional): + // CHECK-LABEL: sil private [ossa] @$s21attr_execution_silgen31testThatClosuresAssumeIsolation2fnyySiYaYCcz_tFyyYaYCXEfU0_ : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> @error any Error { + // CHECK: bb0([[EXECUTOR:%.*]] : @guaranteed $Builtin.ImplicitActor): // CHECK: hop_to_executor [[EXECUTOR]] // CHECK: } // end sil function '$s21attr_execution_silgen31testThatClosuresAssumeIsolation2fnyySiYaYCcz_tFyyYaYCXEfU0_' - testParam { 42 } + testParam { _ = 42 } // CHECK-LABEL: sil private [ossa] @$s21attr_execution_silgen31testThatClosuresAssumeIsolation2fnyySiYaYCcz_tFyyYaXEfU1_ : $@convention(thin) @async () -> () - // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none!enumelt + // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none!enumelt // CHECK: hop_to_executor [[GENERIC_EXECUTOR]] - testParam { @concurrent in 42 } + // CHECK: } // end sil function '$s21attr_execution_silgen31testThatClosuresAssumeIsolation2fnyySiYaYCcz_tFyyYaXEfU1_' + testParam { @concurrent in _ = 42 } - // CHECK-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sIgH_ScA_pSgs5Error_pIegHgILzo_TR : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed @noescape @async @callee_guaranteed () -> ()) -> @error any Error { - // CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Optional, [[FUNC:%.*]] : @guaranteed $@noescape @async @callee_guaranteed () -> ()): + // CHECK-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sIgH_BAs5Error_pIegHgILzo_TR : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed @noescape @async @callee_guaranteed () -> ()) -> @error any Error { + // CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, [[FUNC:%.*]] : @guaranteed $@noescape @async @callee_guaranteed () -> ()): // CHECK: apply [[FUNC]]() // CHECK: hop_to_executor [[ACTOR]] - // CHECK: } // end sil function '$sIgH_ScA_pSgs5Error_pIegHgILzo_TR' + // CHECK: } // end sil function '$sIgH_BAs5Error_pIegHgILzo_TR' - // CHECK-LABEL: sil private [ossa] @$s21attr_execution_silgen31testThatClosuresAssumeIsolation2fnyySiYaYCcz_tFySiYaYCcfU2_ : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, Int) -> () { - // CHECK: bb0([[EXECUTOR:%.*]] : @guaranteed $Optional, %1 : $Int): + // CHECK-LABEL: sil private [ossa] @$s21attr_execution_silgen31testThatClosuresAssumeIsolation2fnyySiYaYCcz_tFySiYaYCcfU2_ : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, Int) -> () { + // CHECK: bb0([[EXECUTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, %1 : $Int): // CHECK: hop_to_executor [[EXECUTOR]] fn = { _ in } // CHECK-LABEL: sil private [ossa] @$s21attr_execution_silgen31testThatClosuresAssumeIsolation2fnyySiYaYCcz_tFySiYacfU3_ : $@convention(thin) @async (Int) -> () - // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none!enumelt + // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none!enumelt // CHECK: hop_to_executor [[GENERIC_EXECUTOR]] // CHECK: } // end sil function '$s21attr_execution_silgen31testThatClosuresAssumeIsolation2fnyySiYaYCcz_tFySiYacfU3_' - // CHECK-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sSiIegHy_ScA_pSgSiIegHgILy_TR : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, Int, @guaranteed @async @callee_guaranteed (Int) -> ()) -> () { - // CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Optional, [[ARG:%.*]] : $Int, [[FUNC:%.*]] : @guaranteed $@async @callee_guaranteed (Int) -> ()): + // CHECK-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sSiIegHy_BASiIegHgILy_TR : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, Int, @guaranteed @async @callee_guaranteed (Int) -> ()) -> () { + // CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, [[ARG:%.*]] : $Int, [[FUNC:%.*]] : @guaranteed $@async @callee_guaranteed (Int) -> ()): // CHECK: apply [[FUNC]]([[ARG]]) // CHECK: hop_to_executor [[ACTOR]] - // CHECK: } // end sil function '$sSiIegHy_ScA_pSgSiIegHgILy_TR' + // CHECK: } // end sil function '$sSiIegHy_BASiIegHgILy_TR' fn = { @concurrent _ in } } @@ -556,8 +571,8 @@ func testNoIsolationTransfer() { // CHECK-LABEL: sil private [ossa] @$s21attr_execution_silgen23testNoIsolationTransferyyF0D7ErasureL_yyyyYaYAcF : $@convention(thin) (@guaranteed @isolated(any) @async @callee_guaranteed () -> ()) -> () func testErasure(@_inheritActorContext _: @escaping @isolated(any) () async -> Void) {} - // CHECK-LABEL: sil private [ossa] @$s21attr_execution_silgen23testNoIsolationTransferyyFyyYacfU_ : $@convention(thin) @async (@guaranteed Optional) -> () - // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none!enumelt + // CHECK-LABEL: sil private [ossa] @$s21attr_execution_silgen23testNoIsolationTransferyyFyyYacfU_ : $@convention(thin) @async (@guaranteed Optional) -> () { + // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none!enumelt // CHECK: hop_to_executor [[GENERIC_EXECUTOR]] testErasure { @concurrent in } } @@ -566,7 +581,7 @@ func testClosuresDontAssumeGlobalActorWithMarkedAsConcurrent() { func test(_ fn: @MainActor () async -> Void) {} // CHECK-LABEL: sil private [ossa] @$s21attr_execution_silgen55testClosuresDontAssumeGlobalActorWithMarkedAsConcurrentyyFyyYaYbXEfU_ - // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none!enumelt + // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none!enumelt // CHECK-NEXT: hop_to_executor [[GENERIC_EXECUTOR]] // CHECK: } // end sil function '$s21attr_execution_silgen55testClosuresDontAssumeGlobalActorWithMarkedAsConcurrentyyFyyYaYbXEfU_' test { @Sendable @concurrent in @@ -591,15 +606,16 @@ func testConvertToThrowing(isolation: isolated (any Actor)? = #isolation) async // CHECK-NEXT: hop_to_executor [[ACTOR_BORROW]] // CHECK: [[CLOSURE:%.*]] = function_ref @$s21attr_execution_silgen21testConvertToThrowing9isolationyScA_pSgYi_tYaFyyYaYCXEfU_ : // CHECK-NEXT: [[CLOSURE_VALUE:%.*]] = thin_to_thick_function [[CLOSURE]] to + // CHECK-NEXT: [[ACTOR_BORROW_CAST:%.*]] = unchecked_value_cast [[ACTOR_BORROW]] // CHECK-NEXT: // function_ref // CHECK-NEXT: [[FN:%.*]] = function_ref - // CHECK-NEXT: try_apply [[FN]]<()>({{%.*}}, {{%.*}}, [[CLOSURE_VALUE]]) {{.*}}, normal bb1, error bb2 + // CHECK-NEXT: try_apply [[FN]]<()>({{%.*}}, [[ACTOR_BORROW_CAST]], [[CLOSURE_VALUE]]) {{.*}}, normal bb1, error bb2 // CHECK: bb1( // This hop is unnecessary because nonisolated(nonsending) should // preserve isolation on return. // CHECK-NEXT: hop_to_executor [[ACTOR_BORROW]] - // CHECK-LABEL: sil private [ossa] @$s21attr_execution_silgen21testConvertToThrowing9isolationyScA_pSgYi_tYaFyyYaYCXEfU_ : $@convention(thin) @async @substituted <τ_0_0> (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> (@out τ_0_0, @error any Error) for <()> + // CHECK-LABEL: sil private [ossa] @$s21attr_execution_silgen21testConvertToThrowing9isolationyScA_pSgYi_tYaFyyYaYCXEfU_ : $@convention(thin) @async @substituted <τ_0_0> (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> (@out τ_0_0, @error any Error) for <()> // CHECK: bb0( // CHECK-NEXT: debug_value // This hop is unnecessary because nonisolated(nonsending) should @@ -615,14 +631,14 @@ func testConvertToThrowing(isolation: isolated (any Actor)? = #isolation) async } func testSendableClosureNonisolatedNonSendingInference() { - // CHECK-LABEL: sil private [ossa] @$s21attr_execution_silgen49testSendableClosureNonisolatedNonSendingInferenceyyFySiYaYbYCcfU_ : $@convention(thin) @Sendable @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, Int) -> () - // CHECK: bb0([[EXECUTOR:%.*]] : @guaranteed $Optional, %1 : $Int): + // CHECK-LABEL: sil private [ossa] @$s21attr_execution_silgen49testSendableClosureNonisolatedNonSendingInferenceyyFySiYaYbYCcfU_ : $@convention(thin) @Sendable @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, Int) -> () + // CHECK: bb0([[EXECUTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, %1 : $Int): // CHECK: hop_to_executor [[EXECUTOR]] // CHECK: // end sil function '$s21attr_execution_silgen49testSendableClosureNonisolatedNonSendingInferenceyyFySiYaYbYCcfU_' let _: nonisolated(nonsending) @Sendable (Int) async -> Void = { _ in } - // CHECK-LABEL: sil private [ossa] @$s21attr_execution_silgen49testSendableClosureNonisolatedNonSendingInferenceyyFyS2SYaKYCcYaYbYCcfU0_ : $@convention(thin) @Sendable @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String) -> (@owned String, @error any Error)) -> @error any Error - // CHECK: bb0([[EXECUTOR:%.*]] : @guaranteed $Optional, %1 : @guaranteed $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String) -> (@owned String, @error any Error)): + // CHECK-LABEL: sil private [ossa] @$s21attr_execution_silgen49testSendableClosureNonisolatedNonSendingInferenceyyFyS2SYaKYCcYaYbYCcfU0_ : $@convention(thin) @Sendable @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String) -> (@owned String, @error any Error)) -> @error any Error + // CHECK: bb0([[EXECUTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, %1 : @guaranteed $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String) -> (@owned String, @error any Error)): // CHECK: hop_to_executor [[EXECUTOR]] // CHECK: // end sil function '$s21attr_execution_silgen49testSendableClosureNonisolatedNonSendingInferenceyyFyS2SYaKYCcYaYbYCcfU0_' let _: nonisolated(nonsending) @Sendable ( @@ -631,7 +647,7 @@ func testSendableClosureNonisolatedNonSendingInference() { } // CHECK-LABEL: sil hidden [ossa] @$s21attr_execution_silgen014testSendableToE35ConversionWithNonisilatedNonsendingyyF : $@convention(thin) () -> () -// CHECK: [[TEST_REF:%.*]] = function_ref @$s21attr_execution_silgen014testSendableToE35ConversionWithNonisilatedNonsendingyyF0D0L_7closureyS2SYaKYCc_tYaYbKF : $@convention(thin) @Sendable @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String) -> (@owned String, @error any Error)) -> @error any Error +// CHECK: [[TEST_REF:%.*]] = function_ref @$s21attr_execution_silgen014testSendableToE35ConversionWithNonisilatedNonsendingyyF0D0L_7closureyS2SYaKYCc_tYaYbKF : $@convention(thin) @Sendable @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String) -> (@owned String, @error any Error)) -> @error any Error // CHECK: // end sil function '$s21attr_execution_silgen014testSendableToE35ConversionWithNonisilatedNonsendingyyF' func testSendableToSendableConversionWithNonisilatedNonsending() { @Sendable nonisolated(nonsending) func test( diff --git a/test/Concurrency/attr_execution/initializer.swift b/test/Concurrency/attr_execution/initializer.swift index 274492c95d4..61e8cd1ad6c 100644 --- a/test/Concurrency/attr_execution/initializer.swift +++ b/test/Concurrency/attr_execution/initializer.swift @@ -7,8 +7,8 @@ // include type checker errors so we can test the SIL part of the pipeline. Put type checker errors into // async_initializer.swift. -// CHECK-LABEL: sil hidden [ossa] @$s11initializer1fyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () { -// CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Optional): +// CHECK-LABEL: sil hidden [ossa] @$s11initializer1fyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () { +// CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor): // CHECK: hop_to_executor [[ACTOR]] // CHECK: } // end sil function '$s11initializer1fyyYaF' func f() async {} @@ -17,15 +17,15 @@ func g() {} class Fruit { // Fruit.__allocating_init() // Isolation: caller_isolation_inheriting - // CHECK-LABEL: sil hidden [exact_self_class] [ossa] @$s11initializer5FruitCACyYacfC : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @thick Fruit.Type) -> @owned Fruit { - // CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Optional + // CHECK-LABEL: sil hidden [exact_self_class] [ossa] @$s11initializer5FruitCACyYacfC : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @thick Fruit.Type) -> @owned Fruit { + // CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor // CHECK: hop_to_executor [[ACTOR]] // CHECK: } // end sil function '$s11initializer5FruitCACyYacfC' // Fruit.init() // Isolation: caller_isolation_inheriting - // CHECK-LABEL: sil hidden [ossa] @$s11initializer5FruitCACyYacfc : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @owned Fruit) -> @owned Fruit { - // CHECK: bb0([[ARG:%.*]] : @guaranteed $Optional, + // CHECK-LABEL: sil hidden [ossa] @$s11initializer5FruitCACyYacfc : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @owned Fruit) -> @owned Fruit { + // CHECK: bb0([[ARG:%.*]] : @guaranteed $Builtin.ImplicitActor, // CHECK: hop_to_executor [[ARG]] // CHECK: } // end sil function '$s11initializer5FruitCACyYacfc' init() async {} @@ -60,15 +60,15 @@ class Banana: Fruit { // Banana.__allocating_init() // Isolation: caller_isolation_inheriting - // CHECK-LABEL: sil hidden [exact_self_class] [ossa] @$s11initializer6BananaCACyYacfC : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @thick Banana.Type) -> @owned Banana { - // CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Optional, + // CHECK-LABEL: sil hidden [exact_self_class] [ossa] @$s11initializer6BananaCACyYacfC : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @thick Banana.Type) -> @owned Banana { + // CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, // CHECK: hop_to_executor [[ACTOR]] // CHECK: } // end sil function '$s11initializer6BananaCACyYacfC' // Banana.init() // Isolation: caller_isolation_inheriting - // CHECK-LABEL: sil hidden [ossa] @$s11initializer6BananaCACyYacfc : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @owned Banana) -> @owned Banana { - // CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Optional, + // CHECK-LABEL: sil hidden [ossa] @$s11initializer6BananaCACyYacfc : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @owned Banana) -> @owned Banana { + // CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, // CHECK: hop_to_executor [[ACTOR]] // CHECK: } // end sil function '$s11initializer6BananaCACyYacfc' override init() async { @@ -80,17 +80,17 @@ class MyType { // MyType.__allocating_init(_:) // Isolation: caller_isolation_inheriting // - // CHECK-LABEL: sil hidden [exact_self_class] [ossa] @$s11initializer6MyTypeCyACyyYaYCXEYacfC : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed @noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> (), @thick MyType.Type) -> @owned MyType { - // CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Optional, [[ARG:%.*]] : @guaranteed $@noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () + // CHECK-LABEL: sil hidden [exact_self_class] [ossa] @$s11initializer6MyTypeCyACyyYaYCXEYacfC : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed @noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> (), @thick MyType.Type) -> @owned MyType { + // CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, [[ARG:%.*]] : @guaranteed $@noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () // CHECK: hop_to_executor [[ACTOR]] - // CHECK: [[FUNC:%.*]] = function_ref @$s11initializer6MyTypeCyACyyYaYCXEYacfc : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed @noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> (), @owned MyType) -> @owned MyType + // CHECK: [[FUNC:%.*]] = function_ref @$s11initializer6MyTypeCyACyyYaYCXEYacfc : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed @noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> (), @owned MyType) -> @owned MyType // CHECK: apply [[FUNC]]([[ACTOR]], [[ARG]], {{%.*}}) : // CHECK: } // end sil function '$s11initializer6MyTypeCyACyyYaYCXEYacfC' // MyType.init(_:) // Isolation: caller_isolation_inheriting - // CHECK-LABEL: sil hidden [ossa] @$s11initializer6MyTypeCyACyyYaYCXEYacfc : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed @noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> (), @owned MyType) -> @owned MyType { - // CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Optional, [[ARG:%.*]] : @guaranteed $@noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> (), [[SELF:%.*]] : @owned $MyType): + // CHECK-LABEL: sil hidden [ossa] @$s11initializer6MyTypeCyACyyYaYCXEYacfc : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed @noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> (), @owned MyType) -> @owned MyType { + // CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, [[ARG:%.*]] : @guaranteed $@noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> (), [[SELF:%.*]] : @owned $MyType): // CHECK: hop_to_executor [[ACTOR]] // CHECK: [[ARG_C:%.*]] = copy_value [[ARG]] // CHECK: [[ARG_B:%.*]] = begin_borrow [[ARG_C]] @@ -102,10 +102,10 @@ class MyType { } } -// CHECK-LABEL: sil hidden [ossa] @$s11initializer4beepyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () { -// CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Optional): +// CHECK-LABEL: sil hidden [ossa] @$s11initializer4beepyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () { +// CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor): // CHECK: hop_to_executor [[ACTOR]] -// CHECK: [[FUNC:%.*]] = function_ref @$s11initializer6MyTypeCyACyyYaYCXEYacfC : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed @noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> (), @thick MyType.Type) -> @owned MyType +// CHECK: [[FUNC:%.*]] = function_ref @$s11initializer6MyTypeCyACyyYaYCXEYacfC : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed @noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> (), @thick MyType.Type) -> @owned MyType // CHECK: apply [[FUNC]]([[ACTOR]], {{%.*}}, {{%.*}}) // CHECK: hop_to_executor [[ACTOR]] // CHECK: hop_to_executor [[ACTOR]] @@ -116,9 +116,9 @@ func beep() async { } // thunk for @escaping @callee_guaranteed () -> () -// CHECK-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sIeg_ScA_pSgIegHgIL_TR : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed @callee_guaranteed () -> ()) -> () { +// CHECK-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sIeg_BAIegHgIL_TR : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed @callee_guaranteed () -> ()) -> () { // CHECK: hop_to_executor -// CHECK: } // end sil function '$sIeg_ScA_pSgIegHgIL_TR' +// CHECK: } // end sil function '$sIeg_BAIegHgIL_TR' actor A { // CHECK-LABEL: sil hidden [ossa] @$s11initializer1ACACyYacfc : $@convention(method) @async (@sil_isolated @owned A) -> @owned A { @@ -140,8 +140,8 @@ protocol AsyncDefaultConstructable { struct Location { var x : Int var y : Int - // CHECK-LABEL: sil hidden [ossa] @$s11initializer8LocationVACyYacfC : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @thin Location.Type) -> Location { - // CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Optional, + // CHECK-LABEL: sil hidden [ossa] @$s11initializer8LocationVACyYacfC : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @thin Location.Type) -> Location { + // CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, // CHECK: hop_to_executor [[ACTOR]] // CHECK: } // end sil function '$s11initializer8LocationVACyYacfC' init() async { @@ -152,22 +152,22 @@ struct Location { extension Location: AsyncDefaultConstructable {} -// CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s11initializer8LocationVAA25AsyncDefaultConstructableA2aDPxyYacfCTW : $@convention(witness_method: AsyncDefaultConstructable) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @thick Location.Type) -> @out Location { -// CHECK: bb0([[INDIRECT_RESULT:%.*]] : $*Location, [[ACTOR:%.*]] : @guaranteed $Optional, -// CHECK: [[FUNC:%.*]] = function_ref @$s11initializer8LocationVACyYacfC : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @thin Location.Type) -> Location +// CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s11initializer8LocationVAA25AsyncDefaultConstructableA2aDPxyYacfCTW : $@convention(witness_method: AsyncDefaultConstructable) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @thick Location.Type) -> @out Location { +// CHECK: bb0([[INDIRECT_RESULT:%.*]] : $*Location, [[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, +// CHECK: [[FUNC:%.*]] = function_ref @$s11initializer8LocationVACyYacfC : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @thin Location.Type) -> Location // CHECK: apply [[FUNC]]([[ACTOR]], // CHECK: hop_to_executor [[ACTOR]] // CHECK: } // end sil function '$s11initializer8LocationVAA25AsyncDefaultConstructableA2aDPxyYacfCTW' -// CHECK-LABEL: sil hidden [exact_self_class] [ossa] @$s11initializer12ExplicitTestCACyYaKcfC : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @thick ExplicitTest.Type) -> (@owned ExplicitTest, @error any Error) { -// CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Optional, +// CHECK-LABEL: sil hidden [exact_self_class] [ossa] @$s11initializer12ExplicitTestCACyYaKcfC : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @thick ExplicitTest.Type) -> (@owned ExplicitTest, @error any Error) { +// CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, // CHECK: hop_to_executor [[ACTOR]] -// CHECK: [[FUNC:%.*]] = function_ref @$s11initializer12ExplicitTestCACyYaKcfc : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @owned ExplicitTest) -> (@owned ExplicitTest, @error any Error) +// CHECK: [[FUNC:%.*]] = function_ref @$s11initializer12ExplicitTestCACyYaKcfc : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @owned ExplicitTest) -> (@owned ExplicitTest, @error any Error) // CHECK: try_apply [[FUNC]]([[ACTOR]], {{%.*}}) // CHECK: } // end sil function '$s11initializer12ExplicitTestCACyYaKcfC' -// CHECK-LABEL: sil hidden [ossa] @$s11initializer12ExplicitTestCACyYaKcfc : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @owned ExplicitTest) -> (@owned ExplicitTest, @error any Error) { -// CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Optional, +// CHECK-LABEL: sil hidden [ossa] @$s11initializer12ExplicitTestCACyYaKcfc : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @owned ExplicitTest) -> (@owned ExplicitTest, @error any Error) { +// CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, // CHECK: hop_to_executor [[ACTOR]] // CHECK: } // end sil function '$s11initializer12ExplicitTestCACyYaKcfc' class ExplicitTest { diff --git a/test/Concurrency/attr_execution/nonisolated_cross_module_with_flag_enabled.swift b/test/Concurrency/attr_execution/nonisolated_cross_module_with_flag_enabled.swift index a9420fb751e..958a6d76acf 100644 --- a/test/Concurrency/attr_execution/nonisolated_cross_module_with_flag_enabled.swift +++ b/test/Concurrency/attr_execution/nonisolated_cross_module_with_flag_enabled.swift @@ -34,8 +34,9 @@ import A // CHECK: bb0([[SELF:%.*]] : $Test): // CHECK: [[MAIN_ACTOR_EXISTENTIAL:%.*]] = init_existential_ref %4 : $MainActor : $MainActor, $any Actor // CHECK: [[ANY_ACTOR:%.*]] = enum $Optional, #Optional.some!enumelt, [[MAIN_ACTOR_EXISTENTIAL]] -// CHECK: [[TEST_METHOD:%.*]] = function_ref @$s1A4TestC4testyyYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed Test) -> () -// CHECK: apply [[TEST_METHOD]]([[ANY_ACTOR]], [[SELF]]) +// CHECK: [[ANY_ACTOR_CAST:%.*]] = unchecked_bitwise_cast [[ANY_ACTOR]] to $Builtin.ImplicitActor +// CHECK: [[TEST_METHOD:%.*]] = function_ref @$s1A4TestC4testyyYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed Test) -> () +// CHECK: apply [[TEST_METHOD]]([[ANY_ACTOR_CAST]], [[SELF]]) // CHECK: } // end sil function '$s6Client4test1ty1A4TestC_tYaF' @MainActor func test(t: Test) async { diff --git a/test/Concurrency/attr_execution/protocols_silgen.swift b/test/Concurrency/attr_execution/protocols_silgen.swift index e5c2dd440e7..13843786472 100644 --- a/test/Concurrency/attr_execution/protocols_silgen.swift +++ b/test/Concurrency/attr_execution/protocols_silgen.swift @@ -19,10 +19,10 @@ protocol Q { } struct AllDefault : P { - // CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s21attr_execution_silgen10AllDefaultVAA1PA2aDP10callerTestyyYaFTW : $@convention(witness_method: P) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed AllDefault) -> () { - // CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Optional, [[SELF:%.*]] : $*AllDefault): + // CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s21attr_execution_silgen10AllDefaultVAA1PA2aDP10callerTestyyYaFTW : $@convention(witness_method: P) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed AllDefault) -> () { + // CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, [[SELF:%.*]] : $*AllDefault): // CHECK: [[LOAD:%.*]] = load [trivial] [[SELF]] - // CHECK: [[FUNC:%.*]] = function_ref @$s21attr_execution_silgen10AllDefaultV10callerTestyyYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, AllDefault) -> () + // CHECK: [[FUNC:%.*]] = function_ref @$s21attr_execution_silgen10AllDefaultV10callerTestyyYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, AllDefault) -> () // CHECK: apply [[FUNC]]([[ACTOR]], [[LOAD]]) // CHECK: hop_to_executor [[ACTOR]] // CHECK: } // end sil function '$s21attr_execution_silgen10AllDefaultVAA1PA2aDP10callerTestyyYaFTW' @@ -46,10 +46,10 @@ struct AllDefault : P { } struct AllCaller : P { - // CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s21attr_execution_silgen9AllCallerVAA1PA2aDP10callerTestyyYaFTW : $@convention(witness_method: P) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed AllCaller) -> () { - // CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Optional, [[SELF:%.*]] : $*AllCaller): + // CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s21attr_execution_silgen9AllCallerVAA1PA2aDP10callerTestyyYaFTW : $@convention(witness_method: P) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed AllCaller) -> () { + // CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, [[SELF:%.*]] : $*AllCaller): // CHECK: [[LOAD:%.*]] = load [trivial] [[SELF]] - // CHECK: [[FUNC:%.*]] = function_ref @$s21attr_execution_silgen9AllCallerV10callerTestyyYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, AllCaller) -> () + // CHECK: [[FUNC:%.*]] = function_ref @$s21attr_execution_silgen9AllCallerV10callerTestyyYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, AllCaller) -> () // CHECK: apply [[FUNC]]([[ACTOR]], [[LOAD]]) // CHECK: hop_to_executor [[ACTOR]] // CHECK: } // end sil function '$s21attr_execution_silgen9AllCallerVAA1PA2aDP10callerTestyyYaFTW' @@ -58,29 +58,32 @@ struct AllCaller : P { // CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s21attr_execution_silgen9AllCallerVAA1PA2aDP14concurrentTestyyYaFTW : $@convention(witness_method: P) @async (@in_guaranteed AllCaller) -> () { // CHECK: bb0([[SELF:%.*]] : $*AllCaller): // CHECK: [[LOAD:%.*]] = load [trivial] [[SELF]] - // CHECK: [[FUNC:%.*]] = function_ref @$s21attr_execution_silgen9AllCallerV14concurrentTestyyYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, AllCaller) -> () + // CHECK: [[FUNC:%.*]] = function_ref @$s21attr_execution_silgen9AllCallerV14concurrentTestyyYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, AllCaller) -> () // CHECK: [[NIL:%.*]] = enum $Optional, #Optional.none!enumelt - // CHECK: hop_to_executor [[NIL]] - // CHECK: apply [[FUNC]]([[NIL]], [[LOAD]]) + // CHECK: [[NIL_CAST:%.*]] = unchecked_value_cast [[NIL]] to $Builtin.ImplicitActor + // CHECK: hop_to_executor [[NIL_CAST]] + // CHECK: apply [[FUNC]]([[NIL_CAST]], [[LOAD]]) // CHECK: } // end sil function '$s21attr_execution_silgen9AllCallerVAA1PA2aDP14concurrentTestyyYaFTW' nonisolated(nonsending) func concurrentTest() async {} // CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s21attr_execution_silgen9AllCallerVAA1PA2aDP13mainActorTestyyYaFTW : $@convention(witness_method: P) @async (@in_guaranteed AllCaller) -> () { // CHECK: bb0([[SELF:%.*]] : $*AllCaller): // CHECK: [[LOAD:%.*]] = load [trivial] [[SELF]] - // CHECK: [[FUNC:%.*]] = function_ref @$s21attr_execution_silgen9AllCallerV13mainActorTestyyYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, AllCaller) -> () + // CHECK: [[FUNC:%.*]] = function_ref @$s21attr_execution_silgen9AllCallerV13mainActorTestyyYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, AllCaller) -> () // CHECK: [[MAIN_ACTOR:%.*]] = apply {{%.*}}({{%.*}}) : $@convention(method) (@thick MainActor.Type) -> @owned MainActor // CHECK: [[EXIS_MAIN_ACTOR:%.*]] = init_existential_ref [[MAIN_ACTOR]] // CHECK: [[OPT_MAIN_ACTOR:%.*]] = enum $Optional, #Optional.some!enumelt, [[EXIS_MAIN_ACTOR]] - // CHECK: hop_to_executor [[OPT_MAIN_ACTOR]] - // CHECK: apply [[FUNC]]([[OPT_MAIN_ACTOR]], [[LOAD]]) + // CHECK: [[OPT_MAIN_ACTOR_B:%.*]] = begin_borrow [[OPT_MAIN_ACTOR]] + // CHECK: [[OPT_MAIN_ACTOR_B_CAST:%.*]] = unchecked_value_cast [[OPT_MAIN_ACTOR_B]] to $Builtin.ImplicitActor + // CHECK: hop_to_executor [[OPT_MAIN_ACTOR_B_CAST]] + // CHECK: apply [[FUNC]]([[OPT_MAIN_ACTOR_B_CAST]], [[LOAD]]) // CHECK: } // end sil function '$s21attr_execution_silgen9AllCallerVAA1PA2aDP13mainActorTestyyYaFTW' nonisolated(nonsending) func mainActorTest() async {} } struct AllConcurrent : P { - // CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s21attr_execution_silgen13AllConcurrentVAA1PA2aDP10callerTestyyYaFTW : $@convention(witness_method: P) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed AllConcurrent) -> () { - // CHECK: bb0([[ACTOR]] : @guaranteed $Optional, [[SELF:%.*]] : + // CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s21attr_execution_silgen13AllConcurrentVAA1PA2aDP10callerTestyyYaFTW : $@convention(witness_method: P) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed AllConcurrent) -> () { + // CHECK: bb0([[ACTOR]] : @guaranteed $Builtin.ImplicitActor, [[SELF:%.*]] : // CHECK: [[LOAD:%.*]] = load [trivial] [[SELF]] // CHECK: [[FUNC:%.*]] = function_ref @$s21attr_execution_silgen13AllConcurrentV10callerTestyyYaF : $@convention(method) @async (AllConcurrent) -> () // CHECK: apply [[FUNC]]([[LOAD]]) @@ -106,8 +109,8 @@ struct AllConcurrent : P { } struct AllMainActor : P { - // CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s21attr_execution_silgen12AllMainActorVAA1PA2aDP10callerTestyyYaFTW : $@convention(witness_method: P) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed AllMainActor) -> () { - // CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Optional, [[SELF:%.*]] : + // CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s21attr_execution_silgen12AllMainActorVAA1PA2aDP10callerTestyyYaFTW : $@convention(witness_method: P) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed AllMainActor) -> () { + // CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, [[SELF:%.*]] : // CHECK: [[LOAD:%.*]] = load [trivial] [[SELF]] // CHECK: [[FUNC:%.*]] = function_ref @$s21attr_execution_silgen12AllMainActorV10callerTestyyYaF : $@convention(method) @async (AllMainActor) -> () // CHECK: apply [[FUNC]]([[LOAD]]) @@ -142,8 +145,8 @@ struct TestWitnessWithStorage: Q { // CHECK-LABEL: sil hidden [ossa] @$s21attr_execution_silgen22TestWitnessWithStorageV02fnD0yyF : $@convention(method) (@guaranteed TestWitnessWithStorage) -> () func fnTest() {} - // CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s21attr_execution_silgen22TestWitnessWithStorageVAA1QA2aDP4testSSvgTW : $@convention(witness_method: Q) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed TestWitnessWithStorage) -> (@owned String, @error any Error) - // CHECK: bb0([[ISOLATION:%.*]] : @guaranteed $Optional, [[SELF:%.*]] : $*TestWitnessWithStorage): + // CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s21attr_execution_silgen22TestWitnessWithStorageVAA1QA2aDP4testSSvgTW : $@convention(witness_method: Q) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed TestWitnessWithStorage) -> (@owned String, @error any Error) + // CHECK: bb0([[ISOLATION:%.*]] : @guaranteed $Builtin.ImplicitActor, [[SELF:%.*]] : $*TestWitnessWithStorage): // CHECK-NEXT: [[BORROWED_SELF:%.*]] = load_borrow [[SELF]] // CHECK: [[WITNESS:%.*]] = function_ref @$s21attr_execution_silgen22TestWitnessWithStorageV4testSSvg : $@convention(method) (@guaranteed TestWitnessWithStorage) -> @owned String // CHECK-NEXT: [[RESULT:%.*]] = apply [[WITNESS]]([[BORROWED_SELF]]) : $@convention(method) (@guaranteed TestWitnessWithStorage) -> @owned String @@ -152,8 +155,8 @@ struct TestWitnessWithStorage: Q { // CHECK-NEXT: return [[RESULT]] // CHECK-NEXT: } // end sil function '$s21attr_execution_silgen22TestWitnessWithStorageVAA1QA2aDP4testSSvgTW' - // CHECK: sil private [transparent] [thunk] [ossa] @$s21attr_execution_silgen22TestWitnessWithStorageVAA1QA2aDP02fnD0yyYaFTW : $@convention(witness_method: Q) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed TestWitnessWithStorage) -> () - // CHECK: bb0([[ISOLATION:%.*]] : @guaranteed $Optional, [[SELF:%.*]] : $*TestWitnessWithStorage): + // CHECK: sil private [transparent] [thunk] [ossa] @$s21attr_execution_silgen22TestWitnessWithStorageVAA1QA2aDP02fnD0yyYaFTW : $@convention(witness_method: Q) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed TestWitnessWithStorage) -> () + // CHECK: bb0([[ISOLATION:%.*]] : @guaranteed $Builtin.ImplicitActor, [[SELF:%.*]] : $*TestWitnessWithStorage): // CHECK-NEXT: [[BORROWED_SELF]] = load_borrow [[SELF]] // CHECK: [[WITNESS:%.*]] = function_ref @$s21attr_execution_silgen22TestWitnessWithStorageV02fnD0yyF : $@convention(method) (@guaranteed TestWitnessWithStorage) -> () // CHECK-NEXT: {{.*}} = apply [[WITNESS]]([[BORROWED_SELF]]) : $@convention(method) (@guaranteed TestWitnessWithStorage) -> () @@ -168,8 +171,8 @@ struct TestSyncWitness: Q { // CHECK-LABEL: sil hidden [ossa] @$s21attr_execution_silgen15TestSyncWitnessV4testSSvg : $@convention(method) (TestSyncWitness) -> @owned String var test: String { "" } - // CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s21attr_execution_silgen15TestSyncWitnessVAA1QA2aDP4testSSvgTW : $@convention(witness_method: Q) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed TestSyncWitness) -> (@owned String, @error any Error) - // CHECK: bb0([[ISOLATION:%.*]] : @guaranteed $Optional, [[SELF:%.*]] : $*TestSyncWitness): + // CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s21attr_execution_silgen15TestSyncWitnessVAA1QA2aDP4testSSvgTW : $@convention(witness_method: Q) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed TestSyncWitness) -> (@owned String, @error any Error) + // CHECK: bb0([[ISOLATION:%.*]] : @guaranteed $Builtin.ImplicitActor, [[SELF:%.*]] : $*TestSyncWitness): // CHECK-NEXT: [[BORROWED_SELF:%.*]] = load [trivial] [[SELF]] // CHECK: [[WITNESS:%.*]] = function_ref @$s21attr_execution_silgen15TestSyncWitnessV4testSSvg : $@convention(method) (TestSyncWitness) -> @owned String // CHECK-NEXT: [[RESULT:%.*]] = apply [[WITNESS]]([[BORROWED_SELF]]) : $@convention(method) (TestSyncWitness) -> @owned String diff --git a/test/Concurrency/attr_execution/witnesses.swift b/test/Concurrency/attr_execution/witnesses.swift index 6b649f09ed8..2c3ac348e98 100644 --- a/test/Concurrency/attr_execution/witnesses.swift +++ b/test/Concurrency/attr_execution/witnesses.swift @@ -25,14 +25,18 @@ struct S: P { // CHECK-NEXT: [[MAIN_ACTOR_COPY:%.*]] = copy_value [[BORROWED_MAIN_ACTOR]] // CHECK-NEXT: [[ERASED_TO_ACTOR:%.*]] = init_existential_ref [[MAIN_ACTOR_COPY]] : $MainActor : $MainActor, $any Actor // CHECK-NEXT: [[CONTEXT_ISOLATION:%.*]] = enum $Optional, #Optional.some!enumelt, [[ERASED_TO_ACTOR]] -// CHECK-NEXT: [[PROP_WITNESS:%.*]] = witness_method $T, #P.prop!getter : (Self) -> () async -> String : $@convention(witness_method: P) @async <τ_0_0 where τ_0_0 : P> (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed τ_0_0) -> @owned String -// CHECK-NEXT: {{.*}} = apply [[PROP_WITNESS]]([[CONTEXT_ISOLATION]], %0) : $@convention(witness_method: P) @async <τ_0_0 where τ_0_0 : P> (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed τ_0_0) -> @owned String +// CHECK-NEXT: [[CONTEXT_ISOLATION_B:%.*]] = begin_borrow [[CONTEXT_ISOLATION]] +// CHECK-NEXT: [[CONTEXT_ISOLATION_B_CAST:%.*]] = unchecked_value_cast [[CONTEXT_ISOLATION_B]] to $Builtin.ImplicitActor +// CHECK-NEXT: [[PROP_WITNESS:%.*]] = witness_method $T, #P.prop!getter : (Self) -> () async -> String : $@convention(witness_method: P) @async <τ_0_0 where τ_0_0 : P> (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed τ_0_0) -> @owned String +// CHECK-NEXT: {{.*}} = apply [[PROP_WITNESS]]([[CONTEXT_ISOLATION_B_CAST]], %0) : $@convention(witness_method: P) @async <τ_0_0 where τ_0_0 : P> (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed τ_0_0) -> @owned String // CHECK: hop_to_executor [[BORROWED_MAIN_ACTOR]] // CHECK: [[MAIN_ACTOR_COPY:%.*]] = copy_value [[BORROWED_MAIN_ACTOR]] // CHECK-NEXT: [[ERASED_TO_ACTOR:%.*]] = init_existential_ref [[MAIN_ACTOR_COPY]] : $MainActor : $MainActor, $any Actor // CHECK-NEXT: [[CONTEXT_ISOLATION:%.*]] = enum $Optional, #Optional.some!enumelt, [[ERASED_TO_ACTOR]] -// CHECK-NEXT: [[FN_WITNESS:%.*]] = witness_method $T, #P.fn : (Self) -> () async -> () : $@convention(witness_method: P) @async <τ_0_0 where τ_0_0 : P> (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed τ_0_0) -> () -// CHECK-NEXT: {{.*}} = apply [[FN_WITNESS]]([[CONTEXT_ISOLATION]], %0) : $@convention(witness_method: P) @async <τ_0_0 where τ_0_0 : P> (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed τ_0_0) -> () +// CHECK-NEXT: [[CONTEXT_ISOLATION_B:%.*]] = begin_borrow [[CONTEXT_ISOLATION]] +// CHECK-NEXT: [[CONTEXT_ISOLATION_B_CAST:%.*]] = unchecked_value_cast [[CONTEXT_ISOLATION_B]] to $Builtin.ImplicitActor +// CHECK-NEXT: [[FN_WITNESS:%.*]] = witness_method $T, #P.fn : (Self) -> () async -> () : $@convention(witness_method: P) @async <τ_0_0 where τ_0_0 : P> (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed τ_0_0) -> () +// CHECK-NEXT: {{.*}} = apply [[FN_WITNESS]]([[CONTEXT_ISOLATION_B_CAST]], %0) : $@convention(witness_method: P) @async <τ_0_0 where τ_0_0 : P> (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed τ_0_0) -> () // CHECK: } // end sil function '$s9witnesses21testMainActorDispatch1tyx_tYaAA1PRzlF' @MainActor func testMainActorDispatch(t: T) async { @@ -41,15 +45,15 @@ func testMainActorDispatch(t: T) async { } // CHECK-LABEL: sil hidden [ossa] @$s9witnesses19testGenericExecutor1tyx_tYaAA1PRzlF : $@convention(thin) @async (@in_guaranteed T) -> () -// CHECK: [[CONTEXT_ISOLATION:%.*]] = enum $Optional, #Optional.none!enumelt +// CHECK: [[CONTEXT_ISOLATION:%.*]] = enum $Optional, #Optional.none!enumelt // CHECK-NEXT: hop_to_executor [[CONTEXT_ISOLATION]] -// CHECK-NEXT: [[ISOLATION_ERASED_TO_ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt -// CHECK-NEXT: [[PROP_WITNESS:%.*]] = witness_method $T, #P.prop!getter : (Self) -> () async -> String : $@convention(witness_method: P) @async <τ_0_0 where τ_0_0 : P> (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed τ_0_0) -> @owned String -// CHECK-NEXT: {{.*}} = apply [[PROP_WITNESS]]([[ISOLATION_ERASED_TO_ACTOR]], %0) : $@convention(witness_method: P) @async <τ_0_0 where τ_0_0 : P> (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed τ_0_0) -> @owned String +// CHECK-NEXT: [[CONTEXT_ISOLATION_CAST:%.*]] = unchecked_value_cast [[CONTEXT_ISOLATION]] to $Builtin.ImplicitActor +// CHECK-NEXT: [[PROP_WITNESS:%.*]] = witness_method $T, #P.prop!getter : (Self) -> () async -> String : $@convention(witness_method: P) @async <τ_0_0 where τ_0_0 : P> (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed τ_0_0) -> @owned String +// CHECK-NEXT: {{.*}} = apply [[PROP_WITNESS]]([[CONTEXT_ISOLATION_CAST]], %0) : $@convention(witness_method: P) @async <τ_0_0 where τ_0_0 : P> (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed τ_0_0) -> @owned String // CHECK-NEXT: hop_to_executor [[CONTEXT_ISOLATION]] -// CHECK: [[ISOLATION_ERASED_TO_ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt -// CHECK-NEXT: [[FN_WITNESS:%.*]] = witness_method $T, #P.fn : (Self) -> () async -> () : $@convention(witness_method: P) @async <τ_0_0 where τ_0_0 : P> (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed τ_0_0) -> () -// CHECK-NEXT: {{.*}} = apply [[FN_WITNESS]]([[ISOLATION_ERASED_TO_ACTOR]], %0) : $@convention(witness_method: P) @async <τ_0_0 where τ_0_0 : P> (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed τ_0_0) -> () +// CHECK: [[CONTEXT_ISOLATION_CAST:%.*]] = unchecked_value_cast [[CONTEXT_ISOLATION]] to $Builtin.ImplicitActor +// CHECK-NEXT: [[FN_WITNESS:%.*]] = witness_method $T, #P.fn : (Self) -> () async -> () : $@convention(witness_method: P) @async <τ_0_0 where τ_0_0 : P> (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed τ_0_0) -> () +// CHECK-NEXT: {{.*}} = apply [[FN_WITNESS]]([[CONTEXT_ISOLATION_CAST]], %0) : $@convention(witness_method: P) @async <τ_0_0 where τ_0_0 : P> (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed τ_0_0) -> () // CHECK: } // end sil function '$s9witnesses19testGenericExecutor1tyx_tYaAA1PRzlF' func testGenericExecutor(t: T) async { _ = await t.prop @@ -63,14 +67,18 @@ actor Test { // CHECK-NEXT: [[ACTOR_COPY:%.*]] = copy_value [[ACTOR]] // CHECK-NEXT: [[ERASED_TO_ACTOR:%.*]] = init_existential_ref [[ACTOR_COPY]] : $Test : $Test, $any Actor // CHECK-NEXT: [[CONTEXT_ISOLATION:%.*]] = enum $Optional, #Optional.some!enumelt, [[ERASED_TO_ACTOR]] - // CHECK-NEXT: [[PROP_WITNESS:%.*]] = witness_method $T, #P.prop!getter : (Self) -> () async -> String : $@convention(witness_method: P) @async <τ_0_0 where τ_0_0 : P> (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed τ_0_0) -> @owned String - // CHECK-NEXT: {{.*}} = apply [[PROP_WITNESS]]([[CONTEXT_ISOLATION]], %0) : $@convention(witness_method: P) @async <τ_0_0 where τ_0_0 : P> (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed τ_0_0) -> @owned String + // CHECK-NEXT: [[CONTEXT_ISOLATION_B:%.*]] = begin_borrow [[CONTEXT_ISOLATION]] + // CHECK-NEXT: [[CONTEXT_ISOLATION_B_CAST:%.*]] = unchecked_value_cast [[CONTEXT_ISOLATION_B]] to $Builtin.ImplicitActor + // CHECK-NEXT: [[PROP_WITNESS:%.*]] = witness_method $T, #P.prop!getter : (Self) -> () async -> String : $@convention(witness_method: P) @async <τ_0_0 where τ_0_0 : P> (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed τ_0_0) -> @owned String + // CHECK-NEXT: {{.*}} = apply [[PROP_WITNESS]]([[CONTEXT_ISOLATION_B_CAST]], %0) : $@convention(witness_method: P) @async <τ_0_0 where τ_0_0 : P> (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed τ_0_0) -> @owned String // CHECK: hop_to_executor [[ACTOR]] // CHECK: [[ACTOR_COPY:%.*]] = copy_value [[ACTOR]] // CHECK-NEXT: [[ERASED_TO_ACTOR:%.*]] = init_existential_ref [[ACTOR_COPY]] : $Test : $Test, $any Actor // CHECK-NEXT: [[CONTEXT_ISOLATION:%.*]] = enum $Optional, #Optional.some!enumelt, [[ERASED_TO_ACTOR]] - // CHECK-NEXT: [[FN_WITNESS:%.*]] = witness_method $T, #P.fn : (Self) -> () async -> () : $@convention(witness_method: P) @async <τ_0_0 where τ_0_0 : P> (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed τ_0_0) -> () - // CHECK-NEXT: {{.*}} = apply [[FN_WITNESS]]([[CONTEXT_ISOLATION]], %0) : $@convention(witness_method: P) @async <τ_0_0 where τ_0_0 : P> (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed τ_0_0) -> () + // CHECK-NEXT: [[CONTEXT_ISOLATION_B:%.*]] = begin_borrow [[CONTEXT_ISOLATION]] + // CHECK-NEXT: [[CONTEXT_ISOLATION_B_CAST:%.*]] = unchecked_value_cast [[CONTEXT_ISOLATION_B]] to $Builtin.ImplicitActor + // CHECK-NEXT: [[FN_WITNESS:%.*]] = witness_method $T, #P.fn : (Self) -> () async -> () : $@convention(witness_method: P) @async <τ_0_0 where τ_0_0 : P> (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed τ_0_0) -> () + // CHECK-NEXT: {{.*}} = apply [[FN_WITNESS]]([[CONTEXT_ISOLATION_B_CAST]], %0) : $@convention(witness_method: P) @async <τ_0_0 where τ_0_0 : P> (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed τ_0_0) -> () // CHECK: } // end sil function '$s9witnesses4TestC4test1tyx_tYaAA1PRzlF' func test(t: T) async { _ = await t.prop @@ -86,14 +94,18 @@ actor Test { // CHECK-NEXT: [[MAIN_ACTOR_COPY:%.*]] = copy_value [[BORROWED_MAIN_ACTOR]] // CHECK-NEXT: [[ERASED_TO_ACTOR:%.*]] = init_existential_ref [[MAIN_ACTOR_COPY]] : $MainActor : $MainActor, $any Actor // CHECK-NEXT: [[CONTEXT_ISOLATION:%.*]] = enum $Optional, #Optional.some!enumelt, [[ERASED_TO_ACTOR]] -// CHECK: [[PROP_REF:%.*]] = function_ref @$s9witnesses1SV4propSSvg : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, S) -> @owned String -// CHECK-NEXT: {{.*}} = apply [[PROP_REF]]([[CONTEXT_ISOLATION]], %0) : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, S) -> @owned String +// CHECK-NEXT: [[CONTEXT_ISOLATION_B:%.*]] = begin_borrow [[CONTEXT_ISOLATION]] +// CHECK-NEXT: [[CONTEXT_ISOLATION_B_CAST:%.*]] = unchecked_value_cast [[CONTEXT_ISOLATION_B]] to $Builtin.ImplicitActor +// CHECK: [[PROP_REF:%.*]] = function_ref @$s9witnesses1SV4propSSvg : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, S) -> @owned String +// CHECK-NEXT: {{.*}} = apply [[PROP_REF]]([[CONTEXT_ISOLATION_B_CAST]], %0) : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, S) -> @owned String // CHECK: hop_to_executor [[BORROWED_MAIN_ACTOR]] // CHECK: [[MAIN_ACTOR_COPY:%.*]] = copy_value [[BORROWED_MAIN_ACTOR]] // CHECK-NEXT: [[ERASED_TO_ACTOR:%.*]] = init_existential_ref [[MAIN_ACTOR_COPY]] : $MainActor : $MainActor, $any Actor // CHECK-NEXT: [[CONTEXT_ISOLATION:%.*]] = enum $Optional, #Optional.some!enumelt, [[ERASED_TO_ACTOR]] -// CHECK: [[FN_REF:%.*]] = function_ref @$s9witnesses1SV2fnyyYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, S) -> () -// CHECK-NEXT: {{.*}} = apply [[FN_REF]]([[CONTEXT_ISOLATION]], %0) : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, S) -> () +// CHECK-NEXT: [[CONTEXT_ISOLATION_B:%.*]] = begin_borrow [[CONTEXT_ISOLATION]] +// CHECK-NEXT: [[CONTEXT_ISOLATION_B_CAST:%.*]] = unchecked_value_cast [[CONTEXT_ISOLATION_B]] to $Builtin.ImplicitActor +// CHECK: [[FN_REF:%.*]] = function_ref @$s9witnesses1SV2fnyyYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, S) -> () +// CHECK-NEXT: {{.*}} = apply [[FN_REF]]([[CONTEXT_ISOLATION_B_CAST]], %0) : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, S) -> () // CHECK: } // end sil function '$s9witnesses14testDirectCall1syAA1SV_tYaF' @MainActor func testDirectCall(s: S) async { diff --git a/test/Concurrency/cross_module_let_sil.swift b/test/Concurrency/cross_module_let_sil.swift index 216d1939a8d..22cf8b4a6af 100644 --- a/test/Concurrency/cross_module_let_sil.swift +++ b/test/Concurrency/cross_module_let_sil.swift @@ -7,12 +7,12 @@ import OtherActors // CHECK-LABEL: sil hidden [ossa] @$s4test6check1ySi11OtherActors0C11ModuleActorCYaF : $@convention(thin) @async (@guaranteed OtherModuleActor) -> Int { // CHECK: bb0([[SELF:%[0-9]+]] : @guaranteed $OtherModuleActor): -// CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none -// CHECK-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional +// CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none +// CHECK-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional // CHECK: [[REF:%[0-9]+]] = ref_element_addr [[SELF]] : $OtherModuleActor, #OtherModuleActor.a // CHECK: hop_to_executor [[SELF]] : $OtherModuleActor // CHECK-NEXT: load [trivial] [[REF]] -// CHECK-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional +// CHECK-NEXT: hop_to_executor [[GENERIC_EXEC]] // CHECK: } // end sil function '$s4test6check1ySi11OtherActors0C11ModuleActorCYaF' func check1(_ actor: OtherModuleActor) async -> Int { return await actor.a @@ -24,23 +24,23 @@ func check2(_ actor: isolated OtherModuleActor) -> Int { // CHECK-LABEL: sil hidden [ossa] @$s4test6check3ySi11OtherActors0C11ModuleActorCYaF : $@convention(thin) @async (@guaranteed OtherModuleActor) -> Int { // CHECK: bb0([[SELF:%[0-9]+]] : @guaranteed $OtherModuleActor): -// CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none -// CHECK-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional +// CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none +// CHECK-NEXT: hop_to_executor [[GENERIC_EXEC]] func check3(_ actor: OtherModuleActor) async -> Int { return actor.b } // CHECK-LABEL: sil hidden [ossa] @$s4test6check4y11OtherActors17SomeSendableClassCSgAC0C11ModuleActorCSgYaF : $@convention(thin) @async (@guaranteed Optional) -> @owned Optional { // CHECK: bb0({{%[0-9]+}} : @guaranteed $Optional): -// CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none -// CHECK-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional +// CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none +// CHECK-NEXT: hop_to_executor [[GENERIC_EXEC]] // CHECK: switch_enum {{%[0-9]+}} : $Optional, case #Optional.some!enumelt: [[SOME:bb[0-9]+]], case #Optional.none!enumelt: {{bb[0-9]+}} // CHECK: [[SOME]]({{%[0-9]+}} : @owned $OtherModuleActor): // CHECK: [[REF:%[0-9]+]] = ref_element_addr {{%[0-9]+}} : $OtherModuleActor, #OtherModuleActor.d // CHECK: hop_to_executor {{%[0-9]+}} : $OtherModuleActor // CHECK-NEXT: load [copy] [[REF]] -// CHECK: hop_to_executor [[GENERIC_EXEC]] : $Optional +// CHECK: hop_to_executor [[GENERIC_EXEC]] // CHECK: } // end sil function '$s4test6check4y11OtherActors17SomeSendableClassCSgAC0C11ModuleActorCSgYaF' func check4(_ actor: OtherModuleActor?) async -> SomeSendableClass? { return await actor?.d diff --git a/test/Concurrency/isolated_default_argument_eval.swift b/test/Concurrency/isolated_default_argument_eval.swift index fa7debb2215..2d2e1d0c7b8 100644 --- a/test/Concurrency/isolated_default_argument_eval.swift +++ b/test/Concurrency/isolated_default_argument_eval.swift @@ -27,11 +27,11 @@ func mainActorMultiDefaultArg(x: Int = requiresMainActor(), // CHECK-LABEL: sil hidden [ossa] @$s30isolated_default_argument_eval22nonisolatedAsyncCalleryyYaF func nonisolatedAsyncCaller() async { - // CHECK: hop_to_executor {{.*}} : $Optional + // CHECK: hop_to_executor {{.*}} // CHECK: hop_to_executor {{.*}} : $MainActor // CHECK: [[GET_VALUE:%[0-9]+]] = function_ref @$s30isolated_default_argument_eval19mainActorDefaultArg5valueS2i_tFfA_ // CHECK-NEXT: apply [[GET_VALUE]]() - // CHECK: hop_to_executor {{.*}} : $Optional + // CHECK: hop_to_executor {{.*}} await mainActorDefaultArg() // CHECK: hop_to_executor {{.*}} : $MainActor @@ -46,7 +46,7 @@ func nonisolatedAsyncCaller() async { // CHECK-NOT: hop_to_executor // CHECK: [[GET_Z:%[0-9]+]] = function_ref @$s30isolated_default_argument_eval24mainActorMultiDefaultArg1x1y5tuple1zySi_S2i_SitSitFfA2_ // CHECK-NEXT: apply [[GET_Z]]() - // CHECK: hop_to_executor {{.*}} : $Optional + // CHECK: hop_to_executor {{.*}} await mainActorMultiDefaultArg() } @@ -57,7 +57,7 @@ var argValue: Int { 0 } // CHECK-LABEL: sil hidden [ossa] @$s30isolated_default_argument_eval20passInoutWithDefaultyyYaF func passInoutWithDefault() async { - // CHECK: hop_to_executor {{.*}} : $Optional + // CHECK: hop_to_executor {{.*}} var x = 0 @@ -69,7 +69,7 @@ func passInoutWithDefault() async { // CHECK-NEXT: [[Z:%[0-9]+]] = apply [[GET_Z]]() // CHECK: [[FN:%[0-9]+]] = function_ref @$s30isolated_default_argument_eval0A15DefaultInoutMix1x1y1zySiz_S2itF : $@convention(thin) (@inout Int, Int, Int) -> () // CHECK: apply [[FN]]([[INOUT_X]], [[ARG_VALUE]], [[Z]]) - // CHECK: hop_to_executor {{.*}} : $Optional + // CHECK: hop_to_executor {{.*}} await isolatedDefaultInoutMix(x: &x, y: argValue) } diff --git a/test/Concurrency/isolation_macro_ir.swift b/test/Concurrency/isolation_macro_ir.swift new file mode 100644 index 00000000000..d2cca692844 --- /dev/null +++ b/test/Concurrency/isolation_macro_ir.swift @@ -0,0 +1,65 @@ +// RUN: %target-swift-frontend -parse-as-library -emit-ir -disable-llvm-merge-functions-pass %s | %FileCheck --check-prefix=NO-TBI %s +// RUN: %target-swift-frontend -parse-as-library -Xllvm -aarch64-use-tbi -emit-ir -disable-llvm-merge-functions-pass %s | %FileCheck --check-prefix=TBI %s + +// This test makes sure that we can properly fold the mask for the witness table +// when we have a #isolation. + +// REQUIRES: concurrency +// REQUIRES: CODEGENERATOR=AArch64 +// REQUIRES: PTRSIZE=64 +// REQUIRES: OS=macosx || OS=ios +// REQUIRES: CPU=arm64 + +@inline(never) +func useActor(iso: (any Actor)?) { + print(iso!.unownedExecutor) +} + +@inline(never) +func implicitParam(_ x: (any Actor)? = #isolation) { + print(x!.unownedExecutor) +} + +// #isolation via direct usage +// +// TBI: define swifttailcc void @"$s18isolation_macro_ir46nonisolatedNonsendingUsePoundIsolationDirectlyyyYaF"(ptr swiftasync %0, i64 %1, i64 [[SECOND_WORD:%.*]]) +// TBI: [[MASKED_SECOND_WORD:%.*]] = and i64 [[SECOND_WORD]], -3458764513820540929 +// TBI: call swiftcc void @"$s18isolation_macro_ir8useActor3isoyScA_pSg_tF"(i64 %1, i64 [[MASKED_SECOND_WORD]]) + +// NO-TBI: define swifttailcc void @"$s18isolation_macro_ir46nonisolatedNonsendingUsePoundIsolationDirectlyyyYaF"(ptr swiftasync %0, i64 [[FIRST_WORD:%.*]], i64 [[SECOND_WORD:%.*]]) +// NO-TBI: [[MASKED_SECOND_WORD:%.*]] = and i64 [[SECOND_WORD]], -4 +// NO-TBI: call swiftcc void @"$s18isolation_macro_ir8useActor3isoyScA_pSg_tF"(i64 [[FIRST_WORD]], i64 [[MASKED_SECOND_WORD]]) + +public nonisolated(nonsending) func nonisolatedNonsendingUsePoundIsolationDirectly() async { + let iso = #isolation + useActor(iso: iso) +} + +// #isolation via default arg +// +// TBI: define swifttailcc void @"$s18isolation_macro_ir45nonisolatedNonsendingPoundIsolationDefaultArgyyYaF"(ptr swiftasync {{%.*}}, i64 {{%.*}}, i64 [[WORD_2:%.*]]) +// TBI: [[MASKED_WORD_2:%.*]] = and i64 [[WORD_2]], -3458764513820540929 +// TBI: call swiftcc void @"$s18isolation_macro_ir13implicitParamyyScA_pSgF"(i64 {{%.*}}, i64 [[MASKED_WORD_2]]) + +// NO-TBI: define swifttailcc void @"$s18isolation_macro_ir45nonisolatedNonsendingPoundIsolationDefaultArgyyYaF"(ptr swiftasync %0, i64 [[WORD_1:%.*]], i64 [[WORD_2:%.*]]) +// NO-TBI: [[MASKED_WORD_2:%.*]] = and i64 [[WORD_2]], -4 +// NO-TBI: call swiftcc void @"$s18isolation_macro_ir13implicitParamyyScA_pSgF"(i64 {{%.*}}, i64 [[MASKED_WORD_2]]) +public nonisolated(nonsending) func nonisolatedNonsendingPoundIsolationDefaultArg() async { + implicitParam() +} + +@inline(never) +public nonisolated(nonsending) func calleeFunction() async { +} + +// TBI: define swifttailcc void @"$s18isolation_macro_ir14callerFunctionyyYaF"(ptr swiftasync %0, i64 %1, i64 [[WORD_2:%.*]]) +// TBI: [[MASKED_WORD_2:%.*]] = and i64 [[WORD_2]], -3458764513820540929 +// TBI: musttail call swifttailcc void @"$s18isolation_macro_ir14calleeFunctionyyYaF"(ptr swiftasync {{%.*}}, i64 {{%.*}}, i64 [[MASKED_WORD_2]]) + +// NO-TBI: define swifttailcc void @"$s18isolation_macro_ir14callerFunctionyyYaF"(ptr swiftasync %0, i64 %1, i64 [[WORD:%.*]]) +// NO-TBI: [[MASKED_WORD:%.*]] = and i64 [[WORD]], -4 +// NO-TBI: musttail call swifttailcc void @"$s18isolation_macro_ir14calleeFunctionyyYaF"(ptr swiftasync {{%.*}}, i64 {{%.*}}, i64 [[MASKED_WORD]]) +@inline(never) +public nonisolated(nonsending) func callerFunction() async { + await calleeFunction() +} diff --git a/test/Concurrency/isolation_macro_sil.swift b/test/Concurrency/isolation_macro_sil.swift index 0c0216cd871..2020c30cc56 100644 --- a/test/Concurrency/isolation_macro_sil.swift +++ b/test/Concurrency/isolation_macro_sil.swift @@ -13,8 +13,9 @@ func takeDefaulted(iso: isolated (any Actor)? = #isolation) {} // CHECK-LABEL: // nonisolatedNonsending() // CHECK-NEXT: // Isolation: caller_isolation_inheriting -// CHECK-NEXT: sil hidden @$s4test21nonisolatedNonsendingyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () { -// CHECK: bb0([[ACTOR:%.*]] : $Optional): +// CHECK-NEXT: sil hidden @$s4test21nonisolatedNonsendingyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () { +// CHECK: bb0([[IMPLICIT_ACTOR:%.*]] : $Builtin.ImplicitActor): +// CHECK: [[ACTOR:%.*]] = implicitactor_to_opaqueisolation_cast [[IMPLICIT_ACTOR]] // CHECK: retain_value [[ACTOR]] // CHECK: debug_value [[ACTOR]], let, name "iso" // CHECK: [[FUNC:%.*]] = function_ref @$s4test4take3isoyScA_pSg_tF : $@convention(thin) (@guaranteed Optional) -> () @@ -25,10 +26,13 @@ func takeDefaulted(iso: isolated (any Actor)? = #isolation) {} // Check that we emit #isolation correctly in closures. // CHECK-LABEL: // closure #1 in containsClosure() // CHECK-NEXT: // Isolation: caller_isolation_inheriting -// CHECK: bb0(%0 : $Optional): +// CHECK-LABEL: sil private @$s4test15containsClosureyyFyyYaYCcfU_ : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () { +// CHECK: bb0(%0 : $Builtin.ImplicitActor): +// CHECK: [[ACTOR:%.*]] = implicitactor_to_opaqueisolation_cast %0 // CHECK-NEXT: // function_ref take(iso:) // CHECK-NEXT: [[FN:%.*]] = function_ref @ -// CHECK-NEXT: apply [[FN]](%0) +// CHECK-NEXT: apply [[FN]]([[ACTOR]]) +// CHECK: } // end sil function '$s4test15containsClosureyyFyyYaYCcfU_' func containsClosure() { let closure: nonisolated(nonsending) () async -> Void = { take(iso: #isolation) @@ -47,12 +51,14 @@ func deferWithIsolatedParam(_ iso: isolated (any Actor)) { // CHECK: bb0(%0 : $any Actor) // CHECK: [[DEFER:%.*]] = function_ref @$s4test22deferWithIsolatedParamyyScA_pYiF6$deferL_yyF : // CHECK-NEXT: apply [[DEFER]](%0) +// CHECK: } // end sil function '$s4test22deferWithIsolatedParamyyScA_pYiF' // CHECK-LABEL: sil private @$s4test22deferWithIsolatedParamyyScA_pYiF6$deferL_yyF : // CHECK: bb0(%0 : @closureCapture $any Actor): // CHECK: [[T0:%.*]] = enum $Optional, #Optional.some!enumelt, %0 // CHECK: [[FN:%.*]] = function_ref @$s4test4take3isoyScA_pSg_tF : // CHECK-NEXT: apply [[FN]]([[T0]]) +// CHECK: } // end sil function '$s4test22deferWithIsolatedParamyyScA_pYiF6$deferL_yyF' // Check that that happens even with uses in caller-side default // arguments, which capture analysis was not previously walking into. @@ -67,12 +73,14 @@ func deferWithIsolatedParam_defaultedUse(_ iso: isolated (any Actor)) { // CHECK: bb0(%0 : $any Actor): // CHECK: [[DEFER:%.*]] = function_ref @$s4test35deferWithIsolatedParam_defaultedUseyyScA_pYiF6$deferL_yyF : // CHECK-NEXT: apply [[DEFER]](%0) +// CHECK: } // end sil function '$s4test35deferWithIsolatedParam_defaultedUseyyScA_pYiF' // CHECK-LABEL: sil private @$s4test35deferWithIsolatedParam_defaultedUseyyScA_pYiF6$deferL_yyF : // CHECK: bb0(%0 : @closureCapture $any Actor): // CHECK: [[T0:%.*]] = enum $Optional, #Optional.some!enumelt, %0 // CHECK: [[FN:%.*]] = function_ref @$s4test13takeDefaulted3isoyScA_pSgYi_tF : // CHECK-NEXT: apply [[FN]]([[T0]]) +// CHECK: } // end sil function '$s4test35deferWithIsolatedParam_defaultedUseyyScA_pYiF6$deferL_yyF' // TODO: we can't currently call nonisolated(nonsending) functions in // defer bodies because they have to be async, but that should be @@ -87,17 +95,19 @@ func hasDefer() async { do {} } // CHECK-LABEL: sil hidden @$s4test8hasDeferyyYaF : -// CHECK: bb0(%0 : $Optional): +// CHECK: bb0(%0 : $Builtin.ImplicitActor): // CHECK: // function_ref $defer // CHECK-NEXT: [[DEFER:%.*]] = function_ref // CHECK-NEXT: apply [[DEFER]](%0) +// CHECK: } // end sil function '$s4test8hasDeferyyYaF' // CHECK-LABEL: // $defer #1 () in hasDefer() // CHECK-NEXT: // Isolation: caller_isolation_inheriting -// CHECK: bb0(%0 : $Optional): +// CHECK: bb0(%0 : $Builtin.ImplicitActor): +// CHECK-NEXT: [[ACTOR:%.*]] = implicitactor_to_opaqueisolation_cast %0 // CHECK-NEXT: // function_ref take(iso:) // CHECK-NEXT: [[FN:%.*]] = function_ref @ -// CHECK-NEXT: apply [[FN]](%0) +// CHECK-NEXT: apply [[FN]]([[ACTOR]]) // Check that we emit #isolation correctly in nested defer bodies. nonisolated(nonsending) @@ -112,21 +122,26 @@ func hasNestedDefer() async { } // CHECK-LABEL: sil hidden @$s4test14hasNestedDeferyyYaF : -// CHECK: bb0(%0 : $Optional): +// CHECK: bb0(%0 : $Builtin.ImplicitActor): // CHECK: // function_ref $defer #1 () in hasNestedDefer() // CHECK-NEXT: [[DEFER:%.*]] = function_ref // CHECK-NEXT: apply [[DEFER]](%0) +// CHECK: } // end sil function '$s4test14hasNestedDeferyyYaF' // CHECK-LABEL: // $defer #1 () in hasNestedDefer() // CHECK-NEXT: // Isolation: caller_isolation_inheriting -// CHECK: bb0(%0 : $Optional): +// CHECK: bb0(%0 : $Builtin.ImplicitActor): // CHECK: // function_ref $defer #1 () in $defer #1 () in hasNestedDefer() // CHECK-NEXT: [[DEFER:%.*]] = function_ref // CHECK-NEXT: apply [[DEFER]](%0) +// CHECK: } // end sil function '$s4test14hasNestedDeferyyYaF6$deferL_yyF' // CHECK-LABEL: // $defer #1 () in $defer #1 () in hasNestedDefer() // CHECK-NEXT: // Isolation: caller_isolation_inheriting -// CHECK: bb0(%0 : $Optional): +// CHECK-NEXT: sil private @$s4test14hasNestedDeferyyYaF6$deferL_yyFACL_yyF : $@convention(thin) (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () { +// CHECK: bb0(%0 : $Builtin.ImplicitActor): +// CHECK-NEXT: [[ACTOR:%.*]] = implicitactor_to_opaqueisolation_cast %0 // CHECK-NEXT: // function_ref take(iso:) // CHECK-NEXT: [[FN:%.*]] = function_ref @ -// CHECK-NEXT: apply [[FN]](%0) +// CHECK-NEXT: apply [[FN]]([[ACTOR]]) +// CHECK: } // end sil function '$s4test14hasNestedDeferyyYaF6$deferL_yyFACL_yyF' diff --git a/test/Concurrency/nonisolated_nonsending.swift b/test/Concurrency/nonisolated_nonsending.swift index 869349eead4..bac0adc93c3 100644 --- a/test/Concurrency/nonisolated_nonsending.swift +++ b/test/Concurrency/nonisolated_nonsending.swift @@ -21,11 +21,11 @@ func testPartialApplication(p: [any P]) async { _ = p.map { $0.f } } // CHECK-LABEL: sil private @$s22nonisolated_nonsending22testPartialApplication1pySayAA1P_pG_tYaFyyYaYbYCcAaD_pXEfU_ : -// CHECK: function_ref @$sScA_pSgIeghHgIL_AAytIeghHgILr_TR : +// CHECK: function_ref @$sBAIeghHgIL_BAytIeghHgILr_TR : // Reabstraction thunk from caller-isolated () -> () to caller-isolated () -> T -// CHECK-LABEL: sil shared [transparent] [reabstraction_thunk] @$sScA_pSgIeghHgIL_AAytIeghHgILr_TR : -// CHECK: bb0(%0 : $*(), %1 : $Optional, %2 : $@Sendable @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> ()): +// CHECK-LABEL: sil shared [transparent] [reabstraction_thunk] @$sBAIeghHgIL_BAytIeghHgILr_TR : $@convention(thin) @Sendable @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed @Sendable @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()) -> @out () { +// CHECK: bb0(%0 : $*(), %1 : $Builtin.ImplicitActor, %2 : $@Sendable @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()): // CHECK-NEXT: apply %2(%1) : func takesGenericAsyncFunction(_ fn: nonisolated(nonsending) (T) async -> Void) {} @@ -38,11 +38,11 @@ func testReabstractionPreservingCallerIsolation(fn: nonisolated(nonsending) (Int takesGenericAsyncFunction(fn) } // CHECK-LABEL: sil hidden @$s22nonisolated_nonsending42testReabstractionPreservingCallerIsolation2fnyySiYaYCXE_tF : -// CHECK: bb0(%0 : $@noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, Int) -> ()): -// CHECK: [[THUNK:%.*]] = function_ref @$sScA_pSgSiIgHgILy_AASiIegHgILn_TR : +// CHECK: bb0(%0 : $@noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, Int) -> ()): +// CHECK: [[THUNK:%.*]] = function_ref @$sBASiIgHgILy_BASiIegHgILn_TR : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed Int, @guaranteed @noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, Int) -> ()) -> () -// CHECK-LABEL: sil shared [transparent] [reabstraction_thunk] @$sScA_pSgSiIgHgILy_AASiIegHgILn_TR : -// CHECK: bb0(%0 : $Optional, %1 : $*Int, %2 : $@noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, Int) -> ()): +// CHECK-LABEL: sil shared [transparent] [reabstraction_thunk] @$sBASiIgHgILy_BASiIegHgILn_TR : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed Int, @guaranteed @noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, Int) -> ()) -> () { +// CHECK: bb0(%0 : $Builtin.ImplicitActor, %1 : $*Int, %2 : $@noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, Int) -> ()): // CHECK-NEXT: %3 = load %1 // CHECK-NEXT: apply %2(%0, %3) diff --git a/test/Concurrency/nonisolated_nonsending_optimize_hoptoexecutor.swift b/test/Concurrency/nonisolated_nonsending_optimize_hoptoexecutor.swift index 83e001e3e87..ebb07b0f400 100644 --- a/test/Concurrency/nonisolated_nonsending_optimize_hoptoexecutor.swift +++ b/test/Concurrency/nonisolated_nonsending_optimize_hoptoexecutor.swift @@ -2,12 +2,12 @@ // REQUIRES: concurrency -// CHECK-LABEL: sil hidden [noinline] @$s4testAAyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () { +// CHECK-LABEL: sil hidden [noinline] @$s4testAAyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () { // CHECK: } // end sil function '$s4testAAyyYaF' @inline(never) nonisolated(nonsending) func test() async {} -// CHECK-LABEL: sil hidden [noinline] @$s4test5test2yyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () { +// CHECK-LABEL: sil hidden [noinline] @$s4test5test2yyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () { // CHECK: } // end sil function '$s4test5test2yyYaF' @inline(never) nonisolated(nonsending) func test2() async { @@ -20,8 +20,8 @@ func test3() async { // CHECK-LABEL: sil @$s4test6calleryyYaF : $@convention(thin) @async () -> () { // CHECK: hop_to_executor -// CHECK: function_ref @$s4testAAyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () -// CHECK: function_ref @$s4test5test2yyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () +// CHECK: function_ref @$s4testAAyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () +// CHECK: function_ref @$s4test5test2yyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () // CHECK: } // end sil function '$s4test6calleryyYaF' public func caller() async { await test() diff --git a/test/Demangle/Inputs/manglings.txt b/test/Demangle/Inputs/manglings.txt index 13f135910ee..f3575b65d21 100644 --- a/test/Demangle/Inputs/manglings.txt +++ b/test/Demangle/Inputs/manglings.txt @@ -504,3 +504,6 @@ _$s15raw_identifiers10FontWeightO009_100_FpEpdyyFZ ---> static raw_identifiers.F $s7Library1BC1iSivxTwd ---> default override of Library.B.i.modify2 : Swift.Int $s7Library1BC1iSivxTwdTwc ---> coro function pointer to default override of Library.B.i.modify2 : Swift.Int $s3use1xAA3OfPVy3lib1GVyAA1fQryFQOyQo_GAjE1PAAxAeKHD1_AIHO_HCg_Gvp ---> use.x : use.OfP some>>.0>> +$sBAIgHgIL_BAIegHgIL_TR ---> {T:} reabstraction thunk helper from @callee_guaranteed @async (@guaranteed Builtin.ImplicitActor) -> () to @escaping @callee_guaranteed @async (@guaranteed Builtin.ImplicitActor) -> () +$sBAD ---> Builtin.ImplicitActor +$sIeg_BAIegHgIL_TR ---> {T:} reabstraction thunk helper from @escaping @callee_guaranteed () -> () to @escaping @callee_guaranteed @async (@guaranteed Builtin.ImplicitActor) -> () diff --git a/test/Demangle/Inputs/simplified-manglings.txt b/test/Demangle/Inputs/simplified-manglings.txt index 40904c876e1..b7a943ce7c9 100644 --- a/test/Demangle/Inputs/simplified-manglings.txt +++ b/test/Demangle/Inputs/simplified-manglings.txt @@ -214,3 +214,4 @@ _TTSf2do___TTSf2s_d___TFVs17_LegacyStringCoreCfVs13_StringBufferS_ ---> speciali _TTSf2dos___TTSf2s_d___TFVs17_LegacyStringCoreCfVs13_StringBufferS_ ---> specialized _LegacyStringCore.init(_:) _$s4main1fSiyYaFTQ0_ ---> f() _$s4main1fSiyYaFTY0_ ---> f() +_$sBAIgHgIL_BAIegHgIL_TR ---> thunk for @callee_guaranteed @async (@guaranteed Builtin.ImplicitActor) -> () diff --git a/test/IRGen/implicitactor_to_opaqueisolation_cast.sil b/test/IRGen/implicitactor_to_opaqueisolation_cast.sil new file mode 100644 index 00000000000..842f49abef8 --- /dev/null +++ b/test/IRGen/implicitactor_to_opaqueisolation_cast.sil @@ -0,0 +1,29 @@ +// RUN: %sil-llvm-gen -target arm64-apple-macos12 -Xllvm -aarch64-use-tbi %s -output-kind=llvm-as -o - | %FileCheck -check-prefix=TBI %s +// RUN: %sil-llvm-gen -target arm64-apple-macos12 %s -output-kind=llvm-as -o - | %FileCheck -check-prefix=TAGGED_POINTER %s + +import Builtin +import Swift +import _Concurrency + +// REQUIRES: concurrency +// REQUIRES: CODEGENERATOR=AArch64 +// REQUIRES: OS=macosx + +// TAGGED_POINTER: define swiftcc { i64, i64 } @test_cast_implicitactor_to_opaqueisolation(i64 [[WORD1:%.*]], i64 [[WORD2:%.*]]) +// TAGGED_POINTER: [[MASKED_WORD:%.*]] = and i64 [[WORD2]], -4 +// TAGGED_POINTER: [[TUP1:%.*]] = insertvalue { i64, i64 } undef, i64 [[WORD1]], 0 +// TAGGED_POINTER: [[TUP2:%.*]] = insertvalue { i64, i64 } [[TUP1]], i64 [[MASKED_WORD]], 1 +// TAGGED_POINTER: ret { i64, i64 } [[TUP2]] +// TAGGED_POINTER-NEXT: } + +// TBI: define swiftcc { i64, i64 } @test_cast_implicitactor_to_opaqueisolation(i64 [[WORD1:%.*]], i64 [[WORD2:%.*]]) +// TBI: [[MASKED_WORD:%.*]] = and i64 [[WORD2]], -3458764513820540929 +// TBI: [[TUP1:%.*]] = insertvalue { i64, i64 } undef, i64 [[WORD1]], 0 +// TBI: [[TUP2:%.*]] = insertvalue { i64, i64 } [[TUP1]], i64 [[MASKED_WORD]], 1 +// TBI: ret { i64, i64 } [[TUP2]] +// TBI-NEXT: } +sil @test_cast_implicitactor_to_opaqueisolation : $@convention(thin) (@guaranteed Builtin.ImplicitActor) -> @owned Optional { +bb0(%0 : $Builtin.ImplicitActor): + %2 = implicitactor_to_opaqueisolation_cast %0 + return %2 +} diff --git a/test/IRGen/typed_throws_abi.swift b/test/IRGen/typed_throws_abi.swift index 78cad66d967..1637e2841d7 100644 --- a/test/IRGen/typed_throws_abi.swift +++ b/test/IRGen/typed_throws_abi.swift @@ -3107,7 +3107,7 @@ func callNonMatching_f1(_ b: Bool) -> (Int, Float, Bool, Float) { // CHECK: [[SUCCESS]]: // CHECK: call i1 (ptr, i1, ...) @llvm.coro.end.async(ptr {{%.*}}, i1 false, ptr @"$s16typed_throws_abi20nonMatching_f0_asyncySf_SftSbYaAA7OneWordVYKF{{.*}}", ptr {{%.*}}, ptr {{%.*}}, float 1.000000e+00, float 2.000000e+00, i64 undef, ptr null) // CHECK: unreachable -// CHECK: 18: +// CHECK: [[ERROR]]: // CHECK: [[ERROR_X:%.*]] = call swiftcc i64 @"$s16typed_throws_abi7OneWordVACycfC"() // CHECK: [[ERROR_RET:%.*]] = insertvalue { float, float, i64 } undef, i64 [[ERROR_X]], 2 // CHECK: [[ERROR_RET0:%.*]] = extractvalue { float, float, i64 } [[ERROR_RET]], 0 diff --git a/test/SIL/Parser/concurrency.sil b/test/SIL/Parser/concurrency.sil index 3689b4bc7dc..204450d23e9 100644 --- a/test/SIL/Parser/concurrency.sil +++ b/test/SIL/Parser/concurrency.sil @@ -5,16 +5,15 @@ sil_stage raw // CHECK: sil_stage raw import Builtin import Swift - -actor Actor { } +import _Concurrency // CHECK-LABEL: sil @test_hop_to_executor -sil @test_hop_to_executor : $@convention(thin) (@guaranteed Actor) -> () { -bb0(%0 : $Actor): - // CHECK: hop_to_executor %0 : $Actor - hop_to_executor %0 : $Actor - // CHECK: hop_to_executor [mandatory] %0 : $Actor - hop_to_executor [mandatory] %0 : $Actor +sil @test_hop_to_executor : $@convention(thin) (@guaranteed any Actor) -> () { +bb0(%0 : $any Actor): + // CHECK: hop_to_executor %0 : $any Actor + hop_to_executor %0 : $any Actor + // CHECK: hop_to_executor [mandatory] %0 : $any Actor + hop_to_executor [mandatory] %0 : $any Actor %2 = tuple () return %2 : $() } @@ -32,3 +31,12 @@ bb0: } +// CHECK-LABEL: sil [ossa] @test_cast_implicitactor_to_opaqueisolation : $@convention(thin) (@guaranteed Builtin.ImplicitActor) -> @owned Optional { +// CHECK: implicitactor_to_opaqueisolation_cast {{%.*}} : $Builtin.ImplicitActor +// CHECK: } // end sil function 'test_cast_implicitactor_to_opaqueisolation' +sil [ossa] @test_cast_implicitactor_to_opaqueisolation : $@convention(thin) (@guaranteed Builtin.ImplicitActor) -> @owned Optional { +bb0(%0 : @guaranteed $Builtin.ImplicitActor): + %1 = implicitactor_to_opaqueisolation_cast %0 : $Builtin.ImplicitActor + %2 = copy_value %1 : $Optional + return %2 : $Optional +} diff --git a/test/SIL/Serialization/basic2.sil b/test/SIL/Serialization/basic2.sil index 37e0218e314..53f13dfb6ec 100644 --- a/test/SIL/Serialization/basic2.sil +++ b/test/SIL/Serialization/basic2.sil @@ -389,4 +389,3 @@ bb0(%0 : $*Builtin.NativeObject, %1 : @owned $Builtin.NativeObject): %9999 = tuple () return %9999 : $() } - diff --git a/test/SIL/Serialization/concurrency.sil b/test/SIL/Serialization/concurrency.sil new file mode 100644 index 00000000000..2168dd87e6a --- /dev/null +++ b/test/SIL/Serialization/concurrency.sil @@ -0,0 +1,24 @@ +// First parse this and then emit a *.sib. Then read in the *.sib, then recreate +// RUN: %empty-directory(%t) +// RUN: %target-sil-opt -sil-print-types %s -emit-sib -o %t/tmp.sib -module-name basic2 +// RUN: %target-sil-opt -sil-print-types %t/tmp.sib -o - -module-name basic2 | %FileCheck %s + +// TODO: We need to make it so that we do another trip through serialization. We +// cannot do this today since when we serialize sib into another sib file, we +// seem to lose the import of _Concurrency. + +import Builtin +import Swift +import _Concurrency + +// REQUIRES: concurrency + +// CHECK-LABEL: sil [ossa] @test_cast_implicitactor_to_opaqueisolation : $@convention(thin) (@guaranteed Builtin.ImplicitActor) -> @owned Optional { +// CHECK: implicitactor_to_opaqueisolation_cast {{%.*}} : $Builtin.ImplicitActor +// CHECK: } // end sil function 'test_cast_implicitactor_to_opaqueisolation' +sil [ossa] @test_cast_implicitactor_to_opaqueisolation : $@convention(thin) (@guaranteed Builtin.ImplicitActor) -> @owned Optional { +bb0(%0 : @guaranteed $Builtin.ImplicitActor): + %1 = implicitactor_to_opaqueisolation_cast %0 : $Builtin.ImplicitActor + %2 = copy_value %1 : $Optional + return %2 : $Optional +} diff --git a/test/SILGen/async_builtins.swift b/test/SILGen/async_builtins.swift index b7358581eea..702a71e32f9 100644 --- a/test/SILGen/async_builtins.swift +++ b/test/SILGen/async_builtins.swift @@ -2,6 +2,7 @@ // REQUIRES: concurrency import Swift +import _Concurrency public struct X { // CHECK-LABEL: sil hidden [ossa] @$s4test1XV14getCurrentTaskBoyYaF diff --git a/test/SILGen/async_initializer.swift b/test/SILGen/async_initializer.swift index 56b96e9ee70..8694238842d 100644 --- a/test/SILGen/async_initializer.swift +++ b/test/SILGen/async_initializer.swift @@ -50,13 +50,13 @@ protocol Person { struct MyStruct { // NI-DAG: sil hidden [ossa] @$s12initializers8MyStructVACyYacfC : $@convention(method) @async (@thin MyStruct.Type) -> MyStruct - // NI-NS-DAG: sil hidden [ossa] @$s12initializers8MyStructVACyYacfC : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @thin MyStruct.Type) -> MyStruct { + // NI-NS-DAG: sil hidden [ossa] @$s12initializers8MyStructVACyYacfC : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @thin MyStruct.Type) -> MyStruct { init() async {} } enum MyEnum { // NI-DAG: sil hidden [ossa] @$s12initializers6MyEnumOACyYacfC : $@convention(method) @async (@thin MyEnum.Type) -> MyEnum - // NI-NS-DAG: sil hidden [ossa] @$s12initializers6MyEnumOACyYacfC : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @thin MyEnum.Type) -> MyEnum { + // NI-NS-DAG: sil hidden [ossa] @$s12initializers6MyEnumOACyYacfC : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @thin MyEnum.Type) -> MyEnum { init() async {} } @@ -64,7 +64,7 @@ actor MyActor { // CHECK-DAG: sil hidden [ossa] @$s12initializers7MyActorCACyYacfc : $@convention(method) @async (@sil_isolated @owned MyActor) -> @owned MyActor // CHECK: bb0(%0 : @owned $MyActor): // In the prologue, hop to the generic executor. - // CHECK-NEXT: [[NIL_EXECUTOR:%.*]] = enum $Optional, #Optional.none + // CHECK-NEXT: [[NIL_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK-NEXT: hop_to_executor [[NIL_EXECUTOR]] : // Later, when we return from an async call, hop to the // correct flow-sensitive value. @@ -73,9 +73,12 @@ actor MyActor { // NI-NEXT: apply [[FN]] // // NI-NS: [[ISOLATION_1:%.*]] = builtin "flowSensitiveSelfIsolation"({{%.*}}) + // NI-NS-NEXT: [[ISOLATION_1_B:%.*]] = begin_borrow [[ISOLATION_1]] + // NI-NS-NEXT: [[ISOLATION_1_B_CAST:%.*]] = unchecked_value_cast [[ISOLATION_1_B]] : $Optional to $Builtin.ImplicitActor // NI-NS-NEXT: // function_ref // NI-NS-NEXT: [[FN:%.*]] = function_ref @$s12initializers8MyStructVACyYacfC : - // NI-NS-NEXT: apply [[FN]]([[ISOLATION_1]] + // NI-NS-NEXT: apply [[FN]]([[ISOLATION_1_B_CAST]] + // NI-NS-NEXT: end_borrow [[ISOLATION_1_B]] // NI-NS-NEXT: destroy_value [[ISOLATION_1]] // CHECK-NEXT: [[ISOLATION_2:%.*]] = builtin "flowSensitiveSelfIsolation"({{%.*}}) // CHECK-NEXT: hop_to_executor [[ISOLATION_2]] @@ -86,32 +89,32 @@ actor MyActor { } class EarthPerson : Person { - // NI-NS-LABEL: sil hidden [exact_self_class] [ossa] @$s12initializers11EarthPersonCACyYacfC : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @thick EarthPerson.Type) -> @owned EarthPerson { - // NI-NS: bb0([[ACTOR:%.*]] : @guaranteed $Optional, + // NI-NS-LABEL: sil hidden [exact_self_class] [ossa] @$s12initializers11EarthPersonCACyYacfC : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @thick EarthPerson.Type) -> @owned EarthPerson { + // NI-NS: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, // NI-NS: hop_to_executor [[ACTOR]] // NI-NS: apply {{%.*}}([[ACTOR]], {{%.*}}) // NI-NS: } // end sil function '$s12initializers11EarthPersonCACyYacfC' // NI-DAG: sil hidden [ossa] @$s12initializers11EarthPersonCACyYacfc : $@convention(method) @async (@owned EarthPerson) -> @owned EarthPerson - // NI-NS-DAG: sil hidden [ossa] @$s12initializers11EarthPersonCACyYacfc : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @owned EarthPerson) -> @owned EarthPerson { + // NI-NS-DAG: sil hidden [ossa] @$s12initializers11EarthPersonCACyYacfc : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @owned EarthPerson) -> @owned EarthPerson { required init() async {} // NI-DAG: sil hidden [ossa] @$s12initializers11EarthPersonC4nameACSS_tYacfc : $@convention(method) @async (@owned String, @owned EarthPerson) -> @owned EarthPerson - // NI-NS-DAG: sil hidden [ossa] @$s12initializers11EarthPersonC4nameACSS_tYacfc : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @owned String, @owned EarthPerson) -> @owned EarthPerson { + // NI-NS-DAG: sil hidden [ossa] @$s12initializers11EarthPersonC4nameACSS_tYacfc : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @owned String, @owned EarthPerson) -> @owned EarthPerson { init(name: String) async {} // NI-DAG: sil private [transparent] [thunk] [ossa] @$s12initializers11EarthPersonCAA0C0A2aDPxyYacfCTW : $@convention( - // NI-NS-DAG: sil private [transparent] [thunk] [ossa] @$s12initializers11EarthPersonCAA0C0A2aDPxyYacfCTW : $@convention(witness_method: Person) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @thick EarthPerson.Type) -> @out EarthPerson { + // NI-NS-DAG: sil private [transparent] [thunk] [ossa] @$s12initializers11EarthPersonCAA0C0A2aDPxyYacfCTW : $@convention(witness_method: Person) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @thick EarthPerson.Type) -> @out EarthPerson { } class NorthAmericaPerson : EarthPerson { // NI-DAG: sil hidden [ossa] @$s12initializers18NorthAmericaPersonCACyYacfc : $@convention(method) @async (@owned NorthAmericaPerson) -> @owned NorthAmericaPerson - // NI-NS-DAG: sil hidden [ossa] @$s12initializers18NorthAmericaPersonCACyYacfc : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @owned NorthAmericaPerson) -> @owned NorthAmericaPerson { + // NI-NS-DAG: sil hidden [ossa] @$s12initializers18NorthAmericaPersonCACyYacfc : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @owned NorthAmericaPerson) -> @owned NorthAmericaPerson { required init() async { await super.init() } // NI-DAG: sil hidden [ossa] @$s12initializers18NorthAmericaPersonC4nameACSS_tYacfc : $@convention(method) @async (@owned String, @owned NorthAmericaPerson) -> @owned NorthAmericaPerson - // NI-NS-DAG: sil hidden [ossa] @$s12initializers18NorthAmericaPersonC4nameACSS_tYacfc : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @owned String, @owned NorthAmericaPerson) -> @owned NorthAmericaPerson { + // NI-NS-DAG: sil hidden [ossa] @$s12initializers18NorthAmericaPersonC4nameACSS_tYacfc : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @owned String, @owned NorthAmericaPerson) -> @owned NorthAmericaPerson { override init(name: String) async { await super.init(name: name) } } @@ -126,7 +129,8 @@ class Cat { // CHECK: hop_to_executor {{%[0-9]+}} : $MainActor // CHECK: {{%[0-9]+}} = function_ref @$s12initializers11someAsyncFnyyYaF : // NI: {{%[0-9]+}} = apply {{%[0-9]+}}() : $@convention(thin) @async () -> () - // NI-NS: {{%[0-9]+}} = apply {{%[0-9]+}}({{%.*}}) : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () + // NI-NS: {{%[0-9]+}} = apply {{%[0-9]+}}({{%.*}}) : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () + // NI-NS-NEXT: end_borrow // NI-NS-NEXT: destroy_value {{%.*}} // CHECK-NEXT: hop_to_executor {{%[0-9]+}} : $MainActor // CHECK: } // end sil function '$s12initializers3CatCACyYacfc' @@ -142,7 +146,8 @@ struct Dog { // CHECK: hop_to_executor {{%[0-9]+}} : $MainActor // CHECK: {{%[0-9]+}} = function_ref @$s12initializers11someAsyncFnyyYaF // NI: {{%[0-9]+}} = apply {{%[0-9]+}}() : $@convention(thin) @async () -> () - // NI-NS: {{%[0-9]+}} = apply {{%[0-9]+}}({{%.*}}) : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () + // NI-NS: {{%[0-9]+}} = apply {{%[0-9]+}}({{%.*}}) : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () + // NI-NS-NEXT: end_borrow // NI-NS-NEXT: destroy_value {{%.*}} // CHECK-NEXT: hop_to_executor {{%[0-9]+}} : $MainActor // CHECK: } // end sil function '$s12initializers3DogVACyYacfC' @@ -169,16 +174,16 @@ enum Birb { } // NI-LABEL: sil hidden [ossa] @$s12initializers7makeCatyyYaF : $@convention(thin) @async () -> () { -// NI: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none -// NI-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional +// NI: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none +// NI-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional // NI: hop_to_executor [[BORROWED_EXECUTOR:%[0-9]+]] // NI: end_borrow [[BORROWED_EXECUTOR]] // NI-NEXT: {{%[0-9]+}} = apply {{%[0-9]+}}({{%[0-9]+}}, {{%[0-9]+}}) : $@convention(method) (@owned String, @thick Cat.Type) -> @owned Cat -// NI: hop_to_executor [[GENERIC_EXEC]] : $Optional +// NI: hop_to_executor [[GENERIC_EXEC]] : $Optional // NI: } // end sil function '$s12initializers7makeCatyyYaF' -// NI-NS-LABEL: sil hidden [ossa] @$s12initializers7makeCatyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () { -// NI-NS: bb0([[ACTOR:%.*]] : @guaranteed $Optional): +// NI-NS-LABEL: sil hidden [ossa] @$s12initializers7makeCatyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () { +// NI-NS: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor): // NI-NS: hop_to_executor [[ACTOR]] // NI-NS: [[INIT:%.*]] = function_ref @$s12initializers3CatC4nameACSS_tcfC : $@convention(method) (@owned String, @thick Cat.Type) -> @owned Cat // NI-NS: [[MAIN_ACTOR:%.*]] = apply {{%.*}}({{%.*}}) : $@convention(method) (@thick MainActor.Type) -> @owned MainActor @@ -192,16 +197,16 @@ func makeCat() async { } // NI-LABEL: sil hidden [ossa] @$s12initializers7makeDogyyYaF : $@convention(thin) @async () -> () { -// NI: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none -// NI-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional +// NI: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none +// NI-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional // NI: hop_to_executor [[BORROWED_EXEC:%.*]] : // NI-NEXT: end_borrow [[BORROWED_EXEC]] // NI-NEXT: {{%[0-9]+}} = apply {{%[0-9]+}}({{%[0-9]+}}, {{%[0-9]+}}) : $@convention(method) (@owned String, @thin Dog.Type) -> Dog -// NI: hop_to_executor [[GENERIC_EXEC]] : $Optional +// NI: hop_to_executor [[GENERIC_EXEC]] : $Optional // NI: } // end sil function '$s12initializers7makeDogyyYaF' -// NI-NS-LABEL: sil hidden [ossa] @$s12initializers7makeDogyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () { -// NI-NS: bb0([[ACTOR:%.*]] : @guaranteed $Optional): +// NI-NS-LABEL: sil hidden [ossa] @$s12initializers7makeDogyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () { +// NI-NS: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor): // NI-NS: hop_to_executor [[ACTOR]] // NI-NS: hop_to_executor [[BORROWED_EXEC:%.*]] : // NI-NS-NEXT: end_borrow [[BORROWED_EXEC]] @@ -213,16 +218,16 @@ func makeDog() async { } // NI-LABEL: sil hidden [ossa] @$s12initializers8makeBirbyyYaF : $@convention(thin) @async () -> () { -// NI: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none -// NI-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional +// NI: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none +// NI-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional // NI: hop_to_executor [[BORROWED_EXEC:%.*]] : $MainActor // NI-NEXT: end_borrow [[BORROWED_EXEC]] // NI-NEXT: {{%[0-9]+}} = apply {{%[0-9]+}}({{%[0-9]+}}, {{%[0-9]+}}) : $@convention(method) (@owned String, @thin Birb.Type) -> Birb -// NI: hop_to_executor [[GENERIC_EXEC]] : $Optional +// NI: hop_to_executor [[GENERIC_EXEC]] : $Optional // NI: } // end sil function '$s12initializers8makeBirbyyYaF' -// NI-NS-LABEL: sil hidden [ossa] @$s12initializers8makeBirbyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () { -// NI-NS: bb0([[ACTOR:%.*]] : @guaranteed $Optional): +// NI-NS-LABEL: sil hidden [ossa] @$s12initializers8makeBirbyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () { +// NI-NS: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor): // NI-NS-NEXT: hop_to_executor [[ACTOR]] // NI-NS: hop_to_executor [[BORROWED_EXEC:%.*]] : $MainActor // NI-NS-NEXT: end_borrow [[BORROWED_EXEC]] @@ -238,7 +243,7 @@ actor SomeActor { // CHECK-LABEL: sil hidden [ossa] @$s12initializers9SomeActorCACyYacfc : $@convention(method) @async (@sil_isolated @owned SomeActor) -> @owned SomeActor { // CHECK: bb0(%0 : - // CHECK-NEXT: [[NIL_EXECUTOR:%.*]] = enum $Optional, #Optional.none + // CHECK-NEXT: [[NIL_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK-NEXT: hop_to_executor [[NIL_EXECUTOR]] init() async {} @@ -260,14 +265,14 @@ func makeActor() async -> SomeActor { } // NI-LABEL: sil hidden [ossa] @$s12initializers20makeActorFromGenericAA04SomeC0CyYaF : $@convention(thin) @async () -> @owned SomeActor { -// NI: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none -// NI-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional +// NI: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none +// NI-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional // NI: apply -// NI-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional +// NI-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional // NI: } // end sil function '$s12initializers20makeActorFromGenericAA04SomeC0CyYaF' -// NI-NS-LABEL: sil hidden [ossa] @$s12initializers20makeActorFromGenericAA04SomeC0CyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> @owned SomeActor { -// NI-NS: bb0([[ACTOR:%.*]] : @guaranteed $Optional): +// NI-NS-LABEL: sil hidden [ossa] @$s12initializers20makeActorFromGenericAA04SomeC0CyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> @owned SomeActor { +// NI-NS: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor): // NI-NS: hop_to_executor [[ACTOR]] // NI-NS: apply {{%.*}}({{%.*}}) // NI-NS-NEXT: hop_to_executor [[ACTOR]] @@ -277,14 +282,14 @@ func makeActorFromGeneric() async -> SomeActor { } // NI-LABEL: sil hidden [ossa] @$s12initializers26callActorMethodFromGeneric1ayAA04SomeC0C_tYaF : -// NI: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none -// NI-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional +// NI: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none +// NI-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional // NI: apply -// NI-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional +// NI-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional // NI: } // end sil function '$s12initializers26callActorMethodFromGeneric1ayAA04SomeC0C_tYaF' -// NI-NS-LABEL: sil hidden [ossa] @$s12initializers26callActorMethodFromGeneric1ayAA04SomeC0C_tYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SomeActor) -> () { -// NI-NS: bb0([[ACTOR:%.*]] : @guaranteed $Optional, [[ARG:%.*]] : @guaranteed $SomeActor): +// NI-NS-LABEL: sil hidden [ossa] @$s12initializers26callActorMethodFromGeneric1ayAA04SomeC0C_tYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SomeActor) -> () { +// NI-NS: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, [[ARG:%.*]] : @guaranteed $SomeActor): // NI-NS: hop_to_executor [[ACTOR]] // NI-NS: [[FUNC:%.*]] = class_method [[ARG]] // NI-NS: apply [[FUNC]]([[ARG]]) @@ -295,29 +300,29 @@ func callActorMethodFromGeneric(a: SomeActor) async { } // NI-LABEL: sil hidden {{.*}} @$s12initializers15makeActorInTaskyyYaF : $@convention(thin) @async () -> () { -// NI: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none -// NI-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional +// NI: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none +// NI-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional // NI: apply // NI: } // end sil function '$s12initializers15makeActorInTaskyyYaF' -// NI-NS-LABEL: sil hidden{{.*}} [ossa] @$s12initializers15makeActorInTaskyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () { -// NI-NS: bb0([[ACTOR:%.*]] : @guaranteed $Optional): +// NI-NS-LABEL: sil hidden{{.*}} [ossa] @$s12initializers15makeActorInTaskyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () { +// NI-NS: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor): // NI-NS: hop_to_executor [[ACTOR]] // NI-NS: apply // NI-NS: } // end sil function '$s12initializers15makeActorInTaskyyYaF' // NI-LABEL: sil private [ossa] @$s12initializers15makeActorInTaskyyYaFAA04SomeC0CyYacfU_ : $@convention(thin) @async @substituted <τ_0_0> (@guaranteed Optional) -> @out τ_0_0 for { -// NI: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none -// NI-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional +// NI: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none +// NI-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional // NI: apply -// NI-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional +// NI-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional // NI: } // end sil function '$s12initializers15makeActorInTaskyyYaFAA04SomeC0CyYacfU_' // NI-NS-LABEL: sil private [ossa] @$s12initializers15makeActorInTaskyyYaFAA04SomeC0CyYacfU_ : $@convention(thin) @async @substituted <τ_0_0> (@guaranteed Optional) -> @out τ_0_0 for { -// NI-NS: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none -// NI-NS-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional +// NI-NS: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none +// NI-NS-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional // NI-NS: apply -// NI-NS-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional +// NI-NS-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional // NI-NS: } // end sil function '$s12initializers15makeActorInTaskyyYaFAA04SomeC0CyYacfU_' @available(SwiftStdlib 5.1, *) func makeActorInTask() async { @@ -325,21 +330,21 @@ func makeActorInTask() async { } // NI-LABEL: sil hidden {{.*}} @$s12initializers21callActorMethodInTask1ayAA04SomeC0C_tYaF : $@convention(thin) @async (@guaranteed SomeActor) -> () { -// NI: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none -// NI-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional +// NI: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none +// NI-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional // NI: apply // NI: } // end sil function '$s12initializers21callActorMethodInTask1ayAA04SomeC0C_tYaF' -// NI-NS-LABEL: sil hidden{{.*}} [ossa] @$s12initializers21callActorMethodInTask1ayAA04SomeC0C_tYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SomeActor) -> () { -// NI-NS: bb0([[ACTOR:%.*]] : @guaranteed $Optional, [[ARG:%.*]] : @guaranteed $SomeActor): +// NI-NS-LABEL: sil hidden{{.*}} [ossa] @$s12initializers21callActorMethodInTask1ayAA04SomeC0C_tYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SomeActor) -> () { +// NI-NS: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, [[ARG:%.*]] : @guaranteed $SomeActor): // NI-NS: hop_to_executor [[ACTOR]] // NI-NS: } // end sil function '$s12initializers21callActorMethodInTask1ayAA04SomeC0C_tYaF' // CHECK-LABEL: sil private [ossa] @$s12initializers21callActorMethodInTask1ayAA04SomeC0C_tYaFyyYacfU_ : $@convention(thin) @async @substituted <τ_0_0> (@guaranteed Optional, @guaranteed SomeActor) -> @out τ_0_0 for <()> { -// CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none -// CHECK-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional +// CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none +// CHECK-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional // CHECK: apply -// CHECK-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional +// CHECK-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional @available(SwiftStdlib 5.1, *) func callActorMethodInTask(a: SomeActor) async { Task.detached { await a.someMethod() } diff --git a/test/SILGen/back_deployed_attr.swift b/test/SILGen/back_deployed_attr.swift index 928e5ea987e..946a74d4a0e 100644 --- a/test/SILGen/back_deployed_attr.swift +++ b/test/SILGen/back_deployed_attr.swift @@ -93,7 +93,7 @@ public func backDeployedCaller(_ s: inout S) { @backDeployed(before: macOS 10.52) nonisolated(nonsending) public func backDeployedNonisolatedNonsending() async -> Int { - // CHECK: bb0(%0 : @guaranteed $Optional): + // CHECK: bb0(%0 : @guaranteed $Builtin.ImplicitActor): // CHECK: [[FALLBACK_FN:%.*]] = function_ref @$s11back_deploy0A29DeployedNonisolatedNonsendingSiyYaFTwB : // CHECK: apply [[FALLBACK_FN]](%0) // CHECK: [[SHIPPING_FN:%.*]] = function_ref @$s11back_deploy0A29DeployedNonisolatedNonsendingSiyYaF : diff --git a/test/SILGen/execution_attr.swift b/test/SILGen/execution_attr.swift index 63dc3f0aac6..44dbc180838 100644 --- a/test/SILGen/execution_attr.swift +++ b/test/SILGen/execution_attr.swift @@ -9,7 +9,7 @@ // CHECK-LABEL: // executionCaller() // CHECK-NEXT: // Isolation: caller_isolation_inheriting -// CHECK-NEXT: sil hidden [ossa] @$s14execution_attr0A6CalleryyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () { +// CHECK-NEXT: sil hidden [ossa] @$s14execution_attr0A6CalleryyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () { nonisolated(nonsending) func executionCaller() async {} @@ -19,15 +19,15 @@ func executionCaller() async {} @concurrent func executionConcurrent() async {} -// DISABLED: sil hidden [ossa] @$s14execution_attr0A15CallerParameteryyyyYaYCXEYaF : $@convention(thin) @async (@guaranteed @noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> ()) -> () { -// ENABLED: sil hidden [ossa] @$s14execution_attr0A15CallerParameteryyyyYaYCXEYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed @noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> ()) -> () { +// DISABLED: sil hidden [ossa] @$s14execution_attr0A15CallerParameteryyyyYaYCXEYaF : $@convention(thin) @async (@guaranteed @noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()) -> () { +// ENABLED: sil hidden [ossa] @$s14execution_attr0A15CallerParameteryyyyYaYCXEYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed @noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> ()) -> () { // CHECK: } // end sil function '$s14execution_attr0A15CallerParameteryyyyYaYCXEYaF' func executionCallerParameter(_ x: nonisolated(nonsending) () async -> ()) async { await x() } // DISABLED-LABEL: sil hidden [ossa] @$s14execution_attr0A19ConcurrentParameteryyyyYaXEYaF : $@convention(thin) @async (@guaranteed @noescape @async @callee_guaranteed () -> ()) -> () { -// ENABLED-LABEL: sil hidden [ossa] @$s14execution_attr0A19ConcurrentParameteryyyyYaXEYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed @noescape @async @callee_guaranteed () -> ()) -> () { +// ENABLED-LABEL: sil hidden [ossa] @$s14execution_attr0A19ConcurrentParameteryyyyYaXEYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed @noescape @async @callee_guaranteed () -> ()) -> () { func executionConcurrentParameter(_ x: @concurrent () async -> ()) async { await x() } @@ -38,15 +38,17 @@ struct S { // DISABLED: sil hidden [ossa] @$s14execution_attr0A11CallerFieldyyAA1SVYaF : $@convention(thin) @async (@guaranteed S) -> () { // DISABLED: bb0([[ARG:%.*]] : @guaranteed $S): +// DISABLED: [[ACTOR_NONE:%.*]] = enum $Optional, #Optional.none!enumelt +// DISABLED: hop_to_executor [[ACTOR_NONE]] // DISABLED: [[FIELD:%.*]] = struct_extract [[ARG]] // DISABLED: [[FIELD_COPY:%.*]] = copy_value [[FIELD]] -// DISABLED: [[ACTOR_NONE:%.*]] = enum $Optional, #Optional.none!enumelt +// DISABLED: [[ACTOR_NONE_CAST:%.*]] = unchecked_value_cast [[ACTOR_NONE]] to $Builtin.ImplicitActor // DISABLED: [[BORROWED_FIELD:%.*]] = begin_borrow [[FIELD_COPY]] -// DISABLED: apply [[BORROWED_FIELD]]([[ACTOR_NONE]]) +// DISABLED: apply [[BORROWED_FIELD]]([[ACTOR_NONE_CAST]]) // DISABLED: } // end sil function '$s14execution_attr0A11CallerFieldyyAA1SVYaF' -// ENABLED: sil hidden [ossa] @$s14execution_attr0A11CallerFieldyyAA1SVYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed S) -> () { -// ENABLED: bb0([[ACTOR:%.*]] : @guaranteed $Optional, [[ARG:%.*]] : @guaranteed $S): +// ENABLED: sil hidden [ossa] @$s14execution_attr0A11CallerFieldyyAA1SVYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed S) -> () { +// ENABLED: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, [[ARG:%.*]] : @guaranteed $S): // ENABLED: [[FIELD:%.*]] = struct_extract [[ARG]] // ENABLED: [[FIELD_COPY:%.*]] = copy_value [[FIELD]] // ENABLED: [[BORROWED_FIELD:%.*]] = begin_borrow [[FIELD_COPY]] @@ -59,13 +61,13 @@ func executionCallerField(_ s: S) async { extension S { // CHECK-LABEL: // S.executionCallerFieldMethod(_:) // CHECK: // Isolation: unspecified - // CHECK: sil hidden [ossa] @$s14execution_attr1SV0A17CallerFieldMethodyyyyYaYCXEF : $@convention(method) (@guaranteed @noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> (), @guaranteed S) -> () { + // CHECK: sil hidden [ossa] @$s14execution_attr1SV0A17CallerFieldMethodyyyyYaYCXEF : $@convention(method) (@guaranteed @noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> (), @guaranteed S) -> () { func executionCallerFieldMethod(_ x: nonisolated(nonsending) () async -> ()) {} } // CHECK-LABEL: sil hidden [ossa] @$s14execution_attr24testWithDynamicIsolation2fnyyyYAXE_tYaF : $@convention(thin) @async (@guaranteed @isolated(any) @noescape @callee_guaranteed () -> ()) -> () { // CHECK: bb0([[PARAM_FN:%.*]] : @guaranteed $@isolated(any) @noescape @callee_guaranteed () -> ()): -// CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none!enumelt +// CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none!enumelt // CHECK-NEXT: hop_to_executor [[GENERIC_EXEC]] // CHECK-NEXT: [[FN:%.*]] = copy_value [[PARAM_FN]] // CHECK-NEXT: [[BORROWED_FN:%.*]] = begin_borrow [[FN]] @@ -80,8 +82,8 @@ func testWithDynamicIsolation(fn: @isolated(any) () -> Void) async { await fn() } -// CHECK-LABEL: sil hidden [ossa] @$s14execution_attr38testCallerIsolatedWithDynamicIsolation2fnyyyYAXE_tYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed @isolated(any) @noescape @callee_guaranteed () -> ()) -> () { -// CHECK: bb0([[ISOLATION:%.*]] : @guaranteed $Optional, [[PARAM_FN:%.*]] : @guaranteed $@isolated(any) @noescape @callee_guaranteed () -> ()): +// CHECK-LABEL: sil hidden [ossa] @$s14execution_attr38testCallerIsolatedWithDynamicIsolation2fnyyyYAXE_tYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed @isolated(any) @noescape @callee_guaranteed () -> ()) -> () { +// CHECK: bb0([[ISOLATION:%.*]] : @guaranteed $Builtin.ImplicitActor, [[PARAM_FN:%.*]] : @guaranteed $@isolated(any) @noescape @callee_guaranteed () -> ()): // CHECK: hop_to_executor [[ISOLATION]] // CHECK-NEXT: [[FN:%.*]] = copy_value [[PARAM_FN]] // CHECK-NEXT: [[BORROWED_FN:%.*]] = begin_borrow [[FN]] diff --git a/test/SILGen/hop_to_executor.swift b/test/SILGen/hop_to_executor.swift index a1daf20bed2..27399f366e6 100644 --- a/test/SILGen/hop_to_executor.swift +++ b/test/SILGen/hop_to_executor.swift @@ -3,7 +3,7 @@ // CHECK-LABEL: sil hidden [ossa] @$s4test16unspecifiedAsyncyyYaF : $@convention(thin) @async () -> () // CHECK: bb0: -// CHECK-NEXT: [[GENERIC:%[0-9]+]] = enum $Optional, #Optional.none!enumelt +// CHECK-NEXT: [[GENERIC:%[0-9]+]] = enum $Optional, #Optional.none!enumelt // CHECK-NEXT: hop_to_executor [[GENERIC]] // CHECK: } // end sil function '$s4test16unspecifiedAsyncyyYaF' func unspecifiedAsync() async {} @@ -13,7 +13,7 @@ actor MyActor { private var p: Int // CHECK-LABEL: sil hidden [ossa] @$s4test7MyActorC6calleeyySiYaF : $@convention(method) @async (Int, @guaranteed MyActor) -> () { - // CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none + // CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none // CHECK: hop_to_executor [[GENERIC_EXEC]] : // CHECK: } // end sil function '$s4test7MyActorC6calleeyySiYaF' nonisolated func callee(_ x: Int) async { @@ -21,7 +21,7 @@ actor MyActor { } // CHECK-LABEL: sil hidden [ossa] @$s4test7MyActorC14throwingCalleeyySiYaKF : $@convention(method) @async (Int, @guaranteed MyActor) -> @error any Error { - // CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none + // CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none // CHECK: hop_to_executor [[GENERIC_EXEC]] : // CHECK: } // end sil function '$s4test7MyActorC14throwingCalleeyySiYaKF' nonisolated func throwingCallee(_ x: Int) async throws { @@ -283,7 +283,7 @@ struct BlueActor { } // CHECK-LABEL: sil hidden [ossa] @$s4test20unspecifiedAsyncFuncyyYaF : $@convention(thin) @async () -> () { -// CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none +// CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none // CHECK-NEXT: hop_to_executor [[GENERIC_EXEC]] : // CHECK: [[BORROW:%[0-9]+]] = begin_borrow {{%[0-9]+}} : $RedActorImpl // CHECK-NEXT: hop_to_executor [[BORROW]] : $RedActorImpl @@ -298,7 +298,7 @@ func unspecifiedAsyncFunc() async { // CHECK-LABEL: sil hidden [ossa] @$s4test27anotherUnspecifiedAsyncFuncyyAA12RedActorImplCYaF : $@convention(thin) @async (@guaranteed RedActorImpl) -> () { // CHECK: bb0([[RED:%[0-9]+]] : @guaranteed $RedActorImpl): -// CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none +// CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none // CHECK-NEXT: hop_to_executor [[GENERIC_EXEC]] : // CHECK: [[INTARG:%[0-9]+]] = apply {{%[0-9]+}}({{%[0-9]+}}, {{%[0-9]+}}) : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int // CHECK: [[METH:%[0-9]+]] = class_method [[RED]] : $RedActorImpl, #RedActorImpl.hello : (isolated RedActorImpl) -> (Int) -> (), $@convention(method) (Int, @sil_isolated @guaranteed RedActorImpl) -> () @@ -311,14 +311,14 @@ func anotherUnspecifiedAsyncFunc(_ red : RedActorImpl) async { } // CHECK-LABEL: sil hidden [ossa] @$s4test0A20GlobalActorFuncValueyyyyAA03RedC0VYcXEYaF -// CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none +// CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none // CHECK: hop_to_executor [[GENERIC_EXEC]] : // CHECK: function_ref @$s4test8RedActorV6sharedAA0bC4ImplCvgZ // CHECK: hop_to_executor [[RED:%[0-9]+]] : $RedActorImpl // CHECK-NEXT: end_borrow [[RED]] // CHECK-NEXT: begin_borrow // CHECK-NEXT: apply -// CHECK: hop_to_executor [[GENERIC_EXEC:%[0-9]+]] : $Optional +// CHECK: hop_to_executor [[GENERIC_EXEC:%[0-9]+]] : $Optional func testGlobalActorFuncValue(_ fn: @RedActor () -> Void) async { await fn() } @@ -482,18 +482,18 @@ extension MyActor { func testImplicitAsyncIsolatedParam( i: Int, d: Double, actor: MyActor, otherActor: MyActor ) async { - // CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none + // CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none // CHECK-NEXT: hop_to_executor [[GENERIC_EXEC]] : // CHECK: [[FN1:%.*]] = function_ref @$s4test19acceptIsolatedParamyySi_AA7MyActorCYiSdtF // CHECK-NEXT: hop_to_executor [[ACTOR:%.*]] : $MyActor // CHECK-NEXT: apply [[FN1]](%0, %2, %1) : $@convention(thin) (Int, @sil_isolated @guaranteed MyActor, Double) -> () - // CHECK-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional + // CHECK-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional await acceptIsolatedParam(i, actor, d) // CHECK: [[FN2:%.*]] = function_ref @$s4test7MyActorC13otherIsolatedyySi_ACYiSdtF : $@convention(method) (Int, @sil_isolated @guaranteed MyActor, Double, @guaranteed MyActor) -> () // CHECK-NEXT: hop_to_executor [[ACTOR:%.*]] : $MyActor // CHECK-NEXT: apply [[FN2]](%0, %2, %1, %3) : $@convention(method) (Int, @sil_isolated @guaranteed MyActor, Double, @guaranteed MyActor) -> () - // CHECK-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional + // CHECK-NEXT: hop_to_executor [[GENERIC_EXEC]] : $Optional await otherActor.otherIsolated(i, actor, d) } diff --git a/test/SILGen/hop_to_executor_async_prop.swift b/test/SILGen/hop_to_executor_async_prop.swift index 979725b0769..b86bb550c1b 100644 --- a/test/SILGen/hop_to_executor_async_prop.swift +++ b/test/SILGen/hop_to_executor_async_prop.swift @@ -81,7 +81,7 @@ struct GlobalCat { // CHECK-LABEL: sil hidden [ossa] @$s4test015accessSweaterOfC03catAA0C0VAA3CatC_tYaF : $@convention(thin) @async (@guaranteed Cat) -> @owned Sweater { // CHECK: bb0([[CAT:%[0-9]+]] : @guaranteed $Cat): -// CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none +// CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none // CHECK: hop_to_executor [[GENERIC_EXEC]] : // CHECK: [[CAT_GETTER:%[0-9]+]] = class_method [[CAT]] : $Cat, #Cat.computedSweater!getter : (isolated Cat) -> () -> Sweater, $@convention(method) (@sil_isolated @guaranteed Cat) -> @owned Sweater // CHECK: hop_to_executor [[CAT]] : $Cat @@ -110,7 +110,7 @@ func accessSweaterOfSweater(cat : Cat) async -> Sweater { // CHECK-LABEL: sil hidden [ossa] @$s4test26accessGlobalIsolatedMember3catSSAA3CatC_tYaF : $@convention(thin) @async (@guaranteed Cat) -> @owned String { // CHECK: bb0([[CAT:%[0-9]+]] : @guaranteed $Cat): -// CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none +// CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none // CHECK: hop_to_executor [[GENERIC_EXEC]] : // CHECK: [[GETTER:%[0-9]+]] = class_method [[CAT]] : $Cat, #Cat.leader!getter : (Cat) -> () -> String, $@convention(method) (@guaranteed Cat) -> @owned String @@ -443,21 +443,21 @@ struct Container { @GlobalCat var isoRef: CatBox = CatBox() // CHECK-LABEL: sil hidden [ossa] @$s4test9ContainerV12accessTuple1SfyYaF : $@convention(method) @async (@guaranteed Container) -> Float { - // CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none + // CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none // CHECK: hop_to_executor [[GENERIC_EXEC]] : // CHECK: hop_to_executor {{%[0-9]+}} : $MainActor // CHECK: [[ACCESS:%[0-9]+]] = begin_access [read] [dynamic] {{%[0-9]+}} : $*(Optional<(Int, Int)>, Float) // CHECK: [[ADDR:%[0-9]+]] = tuple_element_addr [[ACCESS]] : $*(Optional<(Int, Int)>, Float), 1 // CHECK: {{%[0-9]+}} = load [trivial] [[ADDR]] : $*Float // CHECK: end_access [[ACCESS]] : $*(Optional<(Int, Int)>, Float) - // CHECK: hop_to_executor [[GENERIC_EXEC]] : $Optional + // CHECK: hop_to_executor [[GENERIC_EXEC]] : $Optional // CHECK: } // end sil function '$s4test9ContainerV12accessTuple1SfyYaF' func accessTuple1() async -> Float { return await globalCircle.1 } // CHECK-LABEL: sil hidden [ossa] @$s4test9ContainerV12accessTuple2SiSgyYaFZ : $@convention(method) @async (@thin Container.Type) -> Optional { - // CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none + // CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none // CHECK: hop_to_executor [[GENERIC_EXEC]] : // CHECK: hop_to_executor {{%[0-9]+}} : $MainActor // CHECK: [[ACCESS:%[0-9]+]] = begin_access [read] [dynamic] {{%[0-9]+}} : $*(Optional<(Int, Int)>, Float) @@ -473,37 +473,37 @@ struct Container { // CHECK: [[ELM_ADDR:%[0-9]+]] = tuple_element_addr [[TUPLE_ADDR]] : $*(Int, Int), 0 // CHECK: {{%[0-9]+}} = load [trivial] [[ELM_ADDR]] : $*Int // CHECK: end_access [[ACCESS]] : $*(Optional<(Int, Int)>, Float) - // CHECK: hop_to_executor [[GENERIC_EXEC]] : $Optional + // CHECK: hop_to_executor [[GENERIC_EXEC]] : $Optional // CHECK: } // end sil function '$s4test9ContainerV12accessTuple2SiSgyYaFZ' static func accessTuple2() async -> Int? { return await globalCircle.0!.0 } // CHECK-LABEL: sil hidden [ossa] @$s4test9ContainerV12accessTuple3SfyYaF : $@convention(method) @async (@guaranteed Container) -> Float { - // CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none + // CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none // CHECK: hop_to_executor [[GENERIC_EXEC]] : // CHECK: [[ADDRESS_ACCESSOR:%[0-9]+]] = function_ref @$s4test9ContainerV12staticCircleSi_SitSg_Sftvau : $@convention(thin) () -> Builtin.RawPointer // CHECK: hop_to_executor {{%[0-9]+}} : $MainActor // CHECK: = apply [[ADDRESS_ACCESSOR]]() : $@convention(thin) () -> Builtin.RawPointer - // CHECK: hop_to_executor [[GENERIC_EXEC]] : $Optional + // CHECK: hop_to_executor [[GENERIC_EXEC]] : $Optional // CHECK: hop_to_executor {{%[0-9]+}} : $MainActor // CHECK: [[ACCESS:%[0-9]+]] = begin_access [read] [dynamic] {{%[0-9]+}} : $*(Optional<(Int, Int)>, Float) // CHECK: [[ADDR:%[0-9]+]] = tuple_element_addr [[ACCESS]] : $*(Optional<(Int, Int)>, Float), 1 // CHECK: {{%[0-9]+}} = load [trivial] [[ADDR]] : $*Float // CHECK: end_access [[ACCESS]] : $*(Optional<(Int, Int)>, Float) - // CHECK: hop_to_executor [[GENERIC_EXEC]] : $Optional + // CHECK: hop_to_executor [[GENERIC_EXEC]] : $Optional // CHECK: } // end sil function '$s4test9ContainerV12accessTuple3SfyYaF' func accessTuple3() async -> Float { return await Container.staticCircle.1 } // CHECK-LABEL: sil hidden [ossa] @$s4test9ContainerV12accessTuple4SiSgyYaFZ : $@convention(method) @async (@thin Container.Type) -> Optional { - // CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none + // CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none // CHECK: hop_to_executor [[GENERIC_EXEC]] : // CHECK: [[ADDRESS_ACCESSOR:%[0-9]+]] = function_ref @$s4test9ContainerV12staticCircleSi_SitSg_Sftvau : $@convention(thin) () -> Builtin.RawPointer // CHECK: hop_to_executor {{%[0-9]+}} : $MainActor // CHECK: = apply [[ADDRESS_ACCESSOR]]() : $@convention(thin) () -> Builtin.RawPointer - // CHECK: hop_to_executor [[GENERIC_EXEC]] : $Optional + // CHECK: hop_to_executor [[GENERIC_EXEC]] : $Optional // CHECK: hop_to_executor {{%[0-9]+}} : $MainActor // CHECK: [[ACCESS:%[0-9]+]] = begin_access [read] [dynamic] {{%[0-9]+}} : $*(Optional<(Int, Int)>, Float) // CHECK: [[ADDR:%[0-9]+]] = tuple_element_addr [[ACCESS]] : $*(Optional<(Int, Int)>, Float), 0 @@ -518,7 +518,7 @@ struct Container { // CHECK: [[ELM_ADDR:%[0-9]+]] = tuple_element_addr [[TUPLE_ADDR]] : $*(Int, Int), 0 // CHECK: {{%[0-9]+}} = load [trivial] [[ELM_ADDR]] : $*Int // CHECK: end_access [[ACCESS]] : $*(Optional<(Int, Int)>, Float) - // CHECK: hop_to_executor [[GENERIC_EXEC]] : $Optional + // CHECK: hop_to_executor [[GENERIC_EXEC]] : $Optional // CHECK: } // end sil function '$s4test9ContainerV12accessTuple4SiSgyYaFZ' static func accessTuple4() async -> Int? { return await Container.staticCircle.0!.0 @@ -526,16 +526,16 @@ struct Container { // CHECK-LABEL: sil hidden [ossa] @$s4test9ContainerV8getCountSiyYaFZ : $@convention(method) @async (@thin Container.Type) -> Int { - // CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none + // CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none // CHECK: hop_to_executor [[GENERIC_EXEC]] : // CHECK: [[ADDRESS_ACCESSOR:%[0-9]+]] = function_ref @$s4test9ContainerV7counterSivau : $@convention(thin) () -> Builtin.RawPointer // CHECK: hop_to_executor {{%[0-9]+}} : $MainActor // CHECK: = apply [[ADDRESS_ACCESSOR]]() : $@convention(thin) () -> Builtin.RawPointer - // CHECK: hop_to_executor [[GENERIC_EXEC]] : $Optional + // CHECK: hop_to_executor [[GENERIC_EXEC]] : $Optional // CHECK: hop_to_executor {{%[0-9]+}} : $MainActor // CHECK: {{%[0-9]+}} = begin_access [read] [dynamic] {{%[0-9]+}} : $*Int // CHECK: {{%[0-9]+}} = load [trivial] {{%[0-9]+}} : $*Int - // CHECK: hop_to_executor [[GENERIC_EXEC]] : $Optional + // CHECK: hop_to_executor [[GENERIC_EXEC]] : $Optional // CHECK: } // end sil function '$s4test9ContainerV8getCountSiyYaFZ' static func getCount() async -> Int { return await counter @@ -544,12 +544,12 @@ struct Container { // CHECK-LABEL: sil hidden [ossa] @$s4test9ContainerV8getValueSiSgyYaFZ : $@convention(method) @async (@thin Container.Type) -> Optional { // CHECK: bb0(%0 : $@thin Container.Type): - // CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none + // CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none // CHECK: hop_to_executor [[GENERIC_EXEC]] : // CHECK: [[ADDRESS_ACCESSOR:%[0-9]+]] = function_ref @$s4test9ContainerV4thisACSgvau : $@convention(thin) () -> Builtin.RawPointer // CHECK: hop_to_executor {{%[0-9]+}} : $MainActor // CHECK: = apply [[ADDRESS_ACCESSOR]]() : $@convention(thin) () -> Builtin.RawPointer - // CHECK: hop_to_executor {{%[0-9]+}} : $Optional + // CHECK: hop_to_executor {{%[0-9]+}} : $Optional // CHECK: [[MAIN:%[0-9]+]] = begin_borrow {{%[0-9]+}} : $MainActor // CHECK: hop_to_executor [[MAIN]] : $MainActor // CHECK: [[ACCESS:%[0-9]+]] = begin_access [read] [dynamic] {{%[0-9]+}} : $*Optional @@ -558,11 +558,11 @@ struct Container { // CHECK: [[TRUE_BB]]: // CHECK: {{%[0-9]+}} = load [trivial] {{%[0-9]+}} : $*Int // CHECK: end_access [[ACCESS]] : $*Optional - // CHECK: hop_to_executor [[GENERIC_EXEC]] : $Optional + // CHECK: hop_to_executor [[GENERIC_EXEC]] : $Optional // // CHECK: [[FALSE_BB]]: // CHECK: end_access [[ACCESS]] : $*Optional - // CHECK: hop_to_executor [[GENERIC_EXEC]] : $Optional + // CHECK: hop_to_executor [[GENERIC_EXEC]] : $Optional // // CHECK: } // end sil function '$s4test9ContainerV8getValueSiSgyYaFZ' static func getValue() async -> Int? { @@ -571,12 +571,12 @@ struct Container { // CHECK-LABEL: sil hidden [ossa] @$s4test9ContainerV10getOrCrashSfyYaFZ : $@convention(method) @async (@thin Container.Type) -> Float { // CHECK: bb0({{%[0-9]+}} : $@thin Container.Type): - // CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none + // CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none // CHECK: hop_to_executor [[GENERIC_EXEC]] : // CHECK: [[ADDRESS_ACCESSOR:%[0-9]+]] = function_ref @$s4test9ContainerV4thisACSgvau : $@convention(thin) () -> Builtin.RawPointer // CHECK: hop_to_executor {{%[0-9]+}} : $MainActor // CHECK: = apply [[ADDRESS_ACCESSOR]]() : $@convention(thin) () -> Builtin.RawPointer - // CHECK: hop_to_executor [[GENERIC_EXEC]] : $Optional + // CHECK: hop_to_executor [[GENERIC_EXEC]] : $Optional // CHECK: hop_to_executor {{%.*}} : $MainActor // CHECK: [[ACCESS:%[0-9]+]] = begin_access [read] [dynamic] {{%[0-9]+}} : $*Optional // CHECK: switch_enum_addr [[ACCESS]] : $*Optional, case #Optional.some!enumelt: [[SOME_BB:bb[0-9]+]], case #Optional.none!enumelt: [[CRASH_BB:bb[0-9]+]] @@ -597,12 +597,12 @@ struct Container { // CHECK-LABEL: sil hidden [ossa] @$s4test9ContainerV13getRefOrCrashAA6CatBoxCyYaFZ : $@convention(method) @async (@thin Container.Type) -> @owned CatBox { // CHECK: bb0({{%[0-9]+}} : $@thin Container.Type): - // CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none + // CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none // CHECK: hop_to_executor [[GENERIC_EXEC]] : // CHECK: [[ADDRESS_ACCESSOR:%[0-9]+]] = function_ref @$s4test9ContainerV4thisACSgvau : $@convention(thin) () -> Builtin.RawPointer // CHECK: hop_to_executor {{%[0-9]+}} : $MainActor // CHECK: = apply [[ADDRESS_ACCESSOR]]() : $@convention(thin) () -> Builtin.RawPointer - // CHECK: hop_to_executor [[GENERIC_EXEC]] : $Optional + // CHECK: hop_to_executor [[GENERIC_EXEC]] : $Optional // CHECK: hop_to_executor {{%.*}} : $MainActor // CHECK: [[ACCESS:%[0-9]+]] = begin_access [read] [dynamic] {{%[0-9]+}} : $*Optional // CHECK: switch_enum_addr [[ACCESS]] : $*Optional, case #Optional.some!enumelt: [[SOME_BB:bb[0-9]+]], case #Optional.none!enumelt: [[CRASH_BB:bb[0-9]+]] @@ -642,18 +642,18 @@ struct Blah { // closure #1 in Blah.test() // CHECK-LABEL: sil private [ossa] @$s4test4BlahVAAyyFyyYacfU_ : $@convention(thin) @async @substituted <τ_0_0> (@guaranteed Optional, Blah) -> @out τ_0_0 for <()> { - // CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none + // CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none // CHECK: hop_to_executor [[GENERIC_EXEC]] : // CHECK: hop_to_executor {{%[0-9]+}} : $MainActor // CHECK: [[ACTOR_OBJ_RAW:%[0-9]+]] = apply {{%[0-9]+}}({{%[0-9]+}}) : $@convention(method) (Blah) -> @owned Coordinator - // CHECK: hop_to_executor {{%[0-9]+}} : $Optional + // CHECK: hop_to_executor {{%[0-9]+}} : $Optional // CHECK: [[ACTOR_OBJ:%[0-9]+]] = begin_borrow [[ACTOR_OBJ_RAW]] : $Coordinator // CHECK: [[VAL:%[0-9]+]] = ref_element_addr [[ACTOR_OBJ]] : $Coordinator, #Coordinator.someValue // CHECK: hop_to_executor [[ACTOR_OBJ]] // CHECK: [[VAL_ACCESS:%[0-9]+]] = begin_access [read] [dynamic] [[VAL]] : $*Optional // CHECK: {{%[0-9]+}} = load [trivial] [[VAL_ACCESS]] : $*Optional // CHECK: end_access [[VAL_ACCESS]] : $*Optional - // CHECK: hop_to_executor [[GENERIC_EXEC]] : $Optional + // CHECK: hop_to_executor [[GENERIC_EXEC]] : $Optional // CHECK: } // end sil function '$s4test4BlahVAAyyFyyYacfU_' @available(SwiftStdlib 5.1, *) func test() { @@ -677,16 +677,16 @@ class Polar { // CHECK-LABEL: sil hidden{{.*}} @$s4test20accessStaticIsolatedSiyYaF : $@convention(thin) @async () -> Int { -// CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none +// CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none // CHECK: hop_to_executor [[GENERIC_EXEC]] : // CHECK: [[ADDRESSOR:%[0-9]+]] = function_ref @$s4test5PolarC11temperatureSivau : $@convention(thin) () -> Builtin.RawPointer // CHECK: hop_to_executor {{%.*}} : $MainActor // CHECK-NEXT: [[RAW_ADDR:%[0-9]+]] = apply [[ADDRESSOR]]() : $@convention(thin) () -> Builtin.RawPointer -// CHECK-NEXT: hop_to_executor {{%.*}} : $Optional +// CHECK-NEXT: hop_to_executor {{%.*}} : $Optional // CHECK: [[ADDR:%[0-9]+]] = pointer_to_address [[RAW_ADDR]] : $Builtin.RawPointer to [strict] $*Int // CHECK: hop_to_executor {{%.*}} : $MainActor // CHECK: {{%.*}} = load [trivial] {{%.*}} : $*Int -// CHECK: hop_to_executor [[GENERIC_EXEC]] : $Optional +// CHECK: hop_to_executor [[GENERIC_EXEC]] : $Optional func accessStaticIsolated() async -> Int { return await Polar.temperature } diff --git a/test/SILGen/isolated_any.swift b/test/SILGen/isolated_any.swift index 5956b01db67..cf4d42ce1cf 100644 --- a/test/SILGen/isolated_any.swift +++ b/test/SILGen/isolated_any.swift @@ -3,7 +3,7 @@ // REQUIRES: asserts // CHECK-LABEL: sil hidden [ossa] @$s4test8callSync2fnyyyYbYAXE_tYaF -// CHECK: [[NIL_EXECUTOR:%.*]] = enum $Optional, #Optional.none +// CHECK: [[NIL_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK-NEXT: hop_to_executor [[NIL_EXECUTOR]] // CHECK-NEXT: [[FN_COPY:%.*]] = copy_value %0 : $@isolated(any) @noescape @Sendable @callee_guaranteed () -> () // CHECK-NEXT: [[FN_BORROW1:%.*]] = begin_borrow [[FN_COPY]] : @@ -19,7 +19,7 @@ func callSync(fn: @isolated(any) @Sendable () -> ()) async { } // CHECK-LABEL: sil hidden [ossa] @$s4test9callAsync2fnyyyYaYbYAXE_tYaF -// CHECK: [[NIL_EXECUTOR:%.*]] = enum $Optional, #Optional.none +// CHECK: [[NIL_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK-NEXT: hop_to_executor [[NIL_EXECUTOR]] // CHECK-NEXT: [[FN_COPY:%.*]] = copy_value %0 : $@isolated(any) @noescape @Sendable @async @callee_guaranteed () -> () // CHECK-NEXT: [[FN_BORROW2:%.*]] = begin_borrow [[FN_COPY]] : diff --git a/test/SILGen/nonisolated_inherits_isolation.swift b/test/SILGen/nonisolated_inherits_isolation.swift index bb4c0a25fd9..843fdd5a423 100644 --- a/test/SILGen/nonisolated_inherits_isolation.swift +++ b/test/SILGen/nonisolated_inherits_isolation.swift @@ -19,8 +19,8 @@ func unspecifiedAsyncUse(_ t: NonSendableKlass) async {} // CHECK-LABEL: // nonisolatedAsync() // CHECK-NEXT: Isolation: caller_isolation_inheriting -// CHECK-NEXT: sil hidden [ossa] @$s30nonisolated_inherits_isolation0A5AsyncyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () { -// CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Optional): +// CHECK-NEXT: sil hidden [ossa] @$s30nonisolated_inherits_isolation0A5AsyncyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () { +// CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor): // CHECK: hop_to_executor [[ACTOR]] // CHECK: } // end sil function '$s30nonisolated_inherits_isolation0A5AsyncyyYaF' nonisolated func nonisolatedAsync() async {} @@ -29,10 +29,10 @@ func unspecifiedAsyncCallee() async {} // CHECK-LABEL: // unspecifiedAsync() // CHECK-NEXT: Isolation: caller_isolation_inheriting -// CHECK-NEXT: sil hidden [ossa] @$s30nonisolated_inherits_isolation16unspecifiedAsyncyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () { -// CHECK: bb0([[ARG:%.*]] : @guaranteed $Optional): +// CHECK-NEXT: sil hidden [ossa] @$s30nonisolated_inherits_isolation16unspecifiedAsyncyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () { +// CHECK: bb0([[ARG:%.*]] : @guaranteed $Builtin.ImplicitActor): // CHECK: hop_to_executor [[ACTOR]] -// CHECK: [[FUNC_REF:%.*]] = function_ref @$s30nonisolated_inherits_isolation22unspecifiedAsyncCalleeyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () +// CHECK: [[FUNC_REF:%.*]] = function_ref @$s30nonisolated_inherits_isolation22unspecifiedAsyncCalleeyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () // CHECK: apply [[FUNC_REF]]([[ACTOR]]) // CHECK: hop_to_executor [[ACTOR]] // CHECK: } // end sil function '$s30nonisolated_inherits_isolation16unspecifiedAsyncyyYaF' @@ -53,7 +53,7 @@ struct NonisolatedStruct { // // CHECK-LABEL: // NonisolatedStruct.init(asynchronous:) // CHECK-NEXT: // Isolation: caller_isolation_inheriting - // CHECK-NEXT: sil hidden [ossa] @$s30nonisolated_inherits_isolation17NonisolatedStructV12asynchronousACyt_tYacfC : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @thin NonisolatedStruct.Type) -> NonisolatedStruct { + // CHECK-NEXT: sil hidden [ossa] @$s30nonisolated_inherits_isolation17NonisolatedStructV12asynchronousACyt_tYacfC : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @thin NonisolatedStruct.Type) -> NonisolatedStruct { // CHECK: } // end sil function '$s30nonisolated_inherits_isolation17NonisolatedStructV12asynchronousACyt_tYacfC' init(asynchronous: ()) async {} @@ -63,19 +63,19 @@ struct NonisolatedStruct { // But do apply it to async methods. // CHECK-LABEL: // NonisolatedStruct.asyncMethod() // CHECK-NEXT: // Isolation: caller_isolation_inheriting - // CHECK-NEXT: sil hidden [ossa] @$s30nonisolated_inherits_isolation17NonisolatedStructV11asyncMethodyyYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, NonisolatedStruct) -> () { + // CHECK-NEXT: sil hidden [ossa] @$s30nonisolated_inherits_isolation17NonisolatedStructV11asyncMethodyyYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, NonisolatedStruct) -> () { // CHECK: } // end sil function '$s30nonisolated_inherits_isolation17NonisolatedStructV11asyncMethodyyYaF' func asyncMethod() async {} } // CHECK-LABEL: // useNonisolatedStruct() // CHECK-NEXT: // Isolation: caller_isolation_inheriting -// CHECK-NEXT: sil hidden [ossa] @$s30nonisolated_inherits_isolation20useNonisolatedStructyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () { +// CHECK-NEXT: sil hidden [ossa] @$s30nonisolated_inherits_isolation20useNonisolatedStructyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () { // CHECK: bb0([[ACTOR:%.*]] : // CHECK: hop_to_executor [[ACTOR]] // CHECK: [[VALUE:%.*]] = apply {{%.*}}({{%.*}}) : $@convention(method) (@thin NonisolatedStruct.Type) -> NonisolatedStruct // CHECK: [[VAR_DECL:%.*]] = move_value [var_decl] [[VALUE]] -// CHECK: [[ASYNC_CALL:%.*]] = function_ref @$s30nonisolated_inherits_isolation17NonisolatedStructV11asyncMethodyyYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, NonisolatedStruct) -> () +// CHECK: [[ASYNC_CALL:%.*]] = function_ref @$s30nonisolated_inherits_isolation17NonisolatedStructV11asyncMethodyyYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, NonisolatedStruct) -> () // CHECK: apply [[ASYNC_CALL]]([[ACTOR]], [[VAR_DECL]]) // CHECK: hop_to_executor [[ACTOR]] // CHECK: extend_lifetime [[VAR_DECL]] @@ -90,13 +90,13 @@ func useNonisolatedStruct() async { // CHECK-LABEL: // useNonisolatedStruct2() // CHECK-NEXT: // Isolation: caller_isolation_inheriting -// CHECK-NEXT: sil hidden [ossa] @$s30nonisolated_inherits_isolation21useNonisolatedStruct2yyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () { +// CHECK-NEXT: sil hidden [ossa] @$s30nonisolated_inherits_isolation21useNonisolatedStruct2yyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () { // CHECK: bb0([[ACTOR:%.*]] : // CHECK: hop_to_executor [[ACTOR]] -// CHECK: [[VALUE:%.*]] = apply {{%.*}}([[ACTOR]], {{%.*}}) : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @thin NonisolatedStruct.Type) -> NonisolatedStruct +// CHECK: [[VALUE:%.*]] = apply {{%.*}}([[ACTOR]], {{%.*}}) : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @thin NonisolatedStruct.Type) -> NonisolatedStruct // CHECK: hop_to_executor [[ACTOR]] // CHECK: [[VAR_DECL:%.*]] = move_value [var_decl] [[VALUE]] -// CHECK: apply {{%.*}}([[ACTOR]], [[VAR_DECL]]) : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, NonisolatedStruct) -> () +// CHECK: apply {{%.*}}([[ACTOR]], [[VAR_DECL]]) : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, NonisolatedStruct) -> () // CHECK: hop_to_executor [[ACTOR]] // CHECK: extend_lifetime [[VAR_DECL]] // CHECK: } // end sil function '$s30nonisolated_inherits_isolation21useNonisolatedStruct2yyYaF' @@ -142,7 +142,9 @@ class MainActorKlass { // CHECK: [[B_ACTOR_COPY:%.*]] = copy_value [[B_ACTOR]] // CHECK: [[B_ACTOR_COPY_EX:%.*]] = init_existential_ref [[B_ACTOR_COPY]] : $MainActor // CHECK: [[B_ACTOR_COPY_EX_OPT:%.*]] = enum $Optional, #Optional.some!enumelt, [[B_ACTOR_COPY_EX]] - // CHECK: apply {{%.*}}([[B_ACTOR_COPY_EX_OPT]], [[B_VAR_DECL_2]]) : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed NonSendableKlass) -> () + // CHECK: [[B_ACTOR_COPY_EX_OPT_B:%.*]] = begin_borrow [[B_ACTOR_COPY_EX_OPT]] + // CHECK: [[B_ACTOR_COPY_EX_OPT_B_CAST:%.*]] = unchecked_value_cast [[B_ACTOR_COPY_EX_OPT_B]] to $Builtin.ImplicitActor + // CHECK: apply {{%.*}}([[B_ACTOR_COPY_EX_OPT_B_CAST]], [[B_VAR_DECL_2]]) : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed NonSendableKlass) -> () // CHECK: hop_to_executor [[B_ACTOR]] // CHECK: } // end sil function '$s30nonisolated_inherits_isolation14MainActorKlassC24callNonIsolatedWithParamyyYaF' func callNonIsolatedWithParam() async { @@ -154,16 +156,16 @@ class MainActorKlass { struct TestVarUse { var test: Int { - // CHECK-LABEL: sil hidden [ossa] @$s30nonisolated_inherits_isolation10TestVarUseV4testSivg : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, TestVarUse) -> Int + // CHECK-LABEL: sil hidden [ossa] @$s30nonisolated_inherits_isolation10TestVarUseV4testSivg : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, TestVarUse) -> Int get async { 42 } } } -// CHECK-LABEL: sil hidden [ossa] @$s30nonisolated_inherits_isolation12testUseOfVar1tyAA04TestgE0V_tYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, TestVarUse) -> () -// CHECK: bb0([[ISOLATION:%.*]] : @guaranteed $Optional, [[BASE:%.*]] : $TestVarUse) -// CHECK: [[GETTER:%.*]] = function_ref @$s30nonisolated_inherits_isolation10TestVarUseV4testSivg : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, TestVarUse) -> Int +// CHECK-LABEL: sil hidden [ossa] @$s30nonisolated_inherits_isolation12testUseOfVar1tyAA04TestgE0V_tYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, TestVarUse) -> () +// CHECK: bb0([[ISOLATION:%.*]] : @guaranteed $Builtin.ImplicitActor, [[BASE:%.*]] : $TestVarUse) +// CHECK: [[GETTER:%.*]] = function_ref @$s30nonisolated_inherits_isolation10TestVarUseV4testSivg : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, TestVarUse) -> Int // CHECK: {{.*}} = apply [[GETTER]]([[ISOLATION]], [[BASE]]) // CHECK: } // end sil function '$s30nonisolated_inherits_isolation12testUseOfVar1tyAA04TestgE0V_tYaF' func testUseOfVar(t: TestVarUse) async { diff --git a/test/SILGen/objc_async.swift b/test/SILGen/objc_async.swift index bf6eb7a0388..093aa80c646 100644 --- a/test/SILGen/objc_async.swift +++ b/test/SILGen/objc_async.swift @@ -255,7 +255,7 @@ func testThrowingMethodFromMain(slowServer: SlowServer) async -> String { // rdar://91502776 // CHECK-LABEL: sil hidden [ossa] @$s{{.*}}21checkCostcoMembershipSbyYaF : $@convention(thin) @async () -> Bool { // CHECK: bb0: -// CHECK: hop_to_executor {{%.*}} : $Optional +// CHECK: hop_to_executor {{%.*}} : $Optional // CHECK: [[FINAL_BUF:%.*]] = alloc_stack $Bool // CHECK: [[RESULT_BUF:%.*]] = alloc_stack $NSObject // CHECK: [[METH:%.*]] = objc_method {{%.*}} : $@objc_metatype Person.Type, #Person.asCustomer!foreign @@ -264,7 +264,7 @@ func testThrowingMethodFromMain(slowServer: SlowServer) async -> String { // CHECK: dealloc_stack {{%.*}} : $*@block_storage // CHECK: await_async_continuation {{%.*}} : $Builtin.RawUnsafeContinuation, resume bb1 // CHECK: bb1: -// CHECK: hop_to_executor {{%.*}} : $Optional +// CHECK: hop_to_executor {{%.*}} : $Optional // CHECK: [[RESULT:%.*]] = load [take] [[RESULT_BUF]] : $*NSObject // CHECK: objc_method {{%.*}} : $CostcoManager, #CostcoManager.isCustomerEnrolled!foreign // CHECK: get_async_continuation_addr Bool, [[FINAL_BUF]] : $*Bool @@ -275,7 +275,7 @@ func testThrowingMethodFromMain(slowServer: SlowServer) async -> String { // CHECK: dealloc_stack [[BLOCK_STORAGE]] : $*@block_storage // CHECK: await_async_continuation {{%.*}} : $Builtin.RawUnsafeContinuation, resume bb2 // CHECK: bb2: -// CHECK: hop_to_executor {{%.*}} : $Optional +// CHECK: hop_to_executor {{%.*}} : $Optional // CHECK: [[ANSWER:%.*]] = load [trivial] [[FINAL_BUF]] : $*Bool // CHECK: fix_lifetime [[EXTEND2]] : $CostcoManager // CHECK: destroy_value [[EXTEND2]] : $CostcoManager @@ -325,7 +325,7 @@ extension OptionalMemberLookups { // CHECK: destroy_value {{.*}} : $MainActor // CHECK: dealloc_stack {{.*}} : $*AutoreleasingUnsafeMutablePointer> // CHECK: dealloc_stack {{.*}} : $*@sil_unmanaged Optional -// CHECK: hop_to_executor {{.*}} : $Optional +// CHECK: hop_to_executor {{.*}} : $Optional // CHECK: switch_enum func checkHotdogs(_ v: some HotdogCompetitor, _ timeLimit: NSObject) async throws -> String? { return try await v.pileOfHotdogsToEat(withLimit: timeLimit) diff --git a/test/SILGen/objc_async_checked.swift b/test/SILGen/objc_async_checked.swift index d716256c1b9..ff491ef76f7 100644 --- a/test/SILGen/objc_async_checked.swift +++ b/test/SILGen/objc_async_checked.swift @@ -306,7 +306,7 @@ func testThrowingMethodFromMain(slowServer: SlowServer) async -> String { // rdar://91502776 // CHECK-LABEL: sil hidden [ossa] @$s{{.*}}21checkCostcoMembershipSbyYaF : $@convention(thin) @async () -> Bool { // CHECK: bb0: -// CHECK: hop_to_executor {{%.*}} : $Optional +// CHECK: hop_to_executor {{%.*}} : $Optional // CHECK: [[FINAL_BUF:%.*]] = alloc_stack $Bool // CHECK: [[RESULT_BUF:%.*]] = alloc_stack $NSObject // CHECK: [[METH:%.*]] = objc_method {{%.*}} : $@objc_metatype Person.Type, #Person.asCustomer!foreign @@ -317,7 +317,7 @@ func testThrowingMethodFromMain(slowServer: SlowServer) async -> String { // CHECK: dealloc_stack {{%.*}} : $*@block_storage // CHECK: await_async_continuation {{%.*}} : $Builtin.RawUnsafeContinuation, resume bb1 // CHECK: bb1: -// CHECK: hop_to_executor {{%.*}} : $Optional +// CHECK: hop_to_executor {{%.*}} : $Optional // CHECK: [[RESULT:%.*]] = load [take] [[RESULT_BUF]] : $*NSObject // CHECK: objc_method {{%.*}} : $CostcoManager, #CostcoManager.isCustomerEnrolled!foreign // CHECK: get_async_continuation_addr Bool, [[FINAL_BUF]] : $*Bool @@ -328,7 +328,7 @@ func testThrowingMethodFromMain(slowServer: SlowServer) async -> String { // CHECK: dealloc_stack [[BLOCK_STORAGE]] : $*@block_storage // CHECK: await_async_continuation {{%.*}} : $Builtin.RawUnsafeContinuation, resume bb2 // CHECK: bb2: -// CHECK: hop_to_executor {{%.*}} : $Optional +// CHECK: hop_to_executor {{%.*}} : $Optional // CHECK: [[ANSWER:%.*]] = load [trivial] [[FINAL_BUF]] : $*Bool // CHECK: fix_lifetime [[EXTEND2]] : $CostcoManager // CHECK: destroy_value [[EXTEND2]] : $CostcoManager diff --git a/test/SILGen/objc_async_from_swift.swift b/test/SILGen/objc_async_from_swift.swift index 6e8b2fc9b78..9d5a9e63b79 100644 --- a/test/SILGen/objc_async_from_swift.swift +++ b/test/SILGen/objc_async_from_swift.swift @@ -19,8 +19,8 @@ import ObjCConcurrency // CHECK-LABEL: sil {{.*}}@{{.*}}15testSlowServing func testSlowServing(p: SlowServing) async throws { - // CHECK-NN: bb0([[HOP_TARGET:%.*]] : @guaranteed $Optional, - // CHECK-C: [[HOP_TARGET:%.*]] = enum $Optional, #Optional.none + // CHECK-NN: bb0([[HOP_TARGET:%.*]] : @guaranteed $Builtin.ImplicitActor, + // CHECK-C: [[HOP_TARGET:%.*]] = enum $Optional, #Optional.none // CHECK: hop_to_executor [[HOP_TARGET]] : // CHECK: objc_method {{.*}} $@convention(objc_method) <τ_0_0 where τ_0_0 : SlowServing> (@convention(block) (Int) -> (), τ_0_0) -> () // CHECK: hop_to_executor [[HOP_TARGET]] : @@ -43,8 +43,8 @@ func testSlowServing(p: SlowServing) async throws { // CHECK-LABEL: sil {{.*}}@{{.*}}20testSlowServingAgain func testSlowServingAgain(p: SlowServing) async throws { - // CHECK-NN: bb0([[HOP_TARGET:%.*]] : @guaranteed $Optional, - // CHECK-C: [[HOP_TARGET:%.*]] = enum $Optional, #Optional.none + // CHECK-NN: bb0([[HOP_TARGET:%.*]] : @guaranteed $Builtin.ImplicitActor, + // CHECK-C: [[HOP_TARGET:%.*]] = enum $Optional, #Optional.none // CHECK: hop_to_executor [[HOP_TARGET]] : // CHECK: objc_method {{.*}} $@convention(objc_method) <τ_0_0 where τ_0_0 : SlowServing> (@convention(block) (Optional, Optional) -> (), τ_0_0) -> () // CHECK: hop_to_executor [[HOP_TARGET]] : @@ -55,8 +55,8 @@ func testSlowServingAgain(p: SlowServing) async throws { class SlowSwiftServer: NSObject, SlowServing { // CHECK-LABEL: sil {{.*}} @$s21objc_async_from_swift15SlowSwiftServerC10requestIntSiyYaF - // CHECK-NN: bb0([[HOP_TARGET:%.*]] : @guaranteed $Optional, - // CHECK-C: [[HOP_TARGET:%.*]] = enum $Optional, #Optional.none + // CHECK-NN: bb0([[HOP_TARGET:%.*]] : @guaranteed $Builtin.ImplicitActor, + // CHECK-C: [[HOP_TARGET:%.*]] = enum $Optional, #Optional.none // CHECK: hop_to_executor [[HOP_TARGET]] : // CHECK: } // end sil function '$s21objc_async_from_swift15SlowSwiftServerC10requestIntSiyYaF{{.*}}' // CHECK-LABEL: sil private {{.*}} @${{.*}}10requestInt{{.*}}To : @@ -74,12 +74,12 @@ class SlowSwiftServer: NSObject, SlowServing { func requestInt() async -> Int { return 0 } func requestString() async -> String { return "" } // CHECK-LABEL: sil {{.*}} @$s21objc_async_from_swift15SlowSwiftServerC13requestStringSSyYaF - // CHECK-NN: bb0([[HOP_TARGET:%.*]] : @guaranteed $Optional, - // CHECK-C: [[HOP_TARGET:%.*]] = enum $Optional, #Optional.none + // CHECK-NN: bb0([[HOP_TARGET:%.*]] : @guaranteed $Builtin.ImplicitActor, + // CHECK-C: [[HOP_TARGET:%.*]] = enum $Optional, #Optional.none // CHECK: hop_to_executor [[HOP_TARGET]] : // CHECK-LABEL: sil {{.*}} @$s21objc_async_from_swift15SlowSwiftServerC16tryRequestStringSSyYaKF - // CHECK-NN: bb0([[HOP_TARGET:%.*]] : @guaranteed $Optional, - // CHECK-C: [[HOP_TARGET:%.*]] = enum $Optional, #Optional.none + // CHECK-NN: bb0([[HOP_TARGET:%.*]] : @guaranteed $Builtin.ImplicitActor, + // CHECK-C: [[HOP_TARGET:%.*]] = enum $Optional, #Optional.none // CHECK: hop_to_executor [[HOP_TARGET]] : // CHECK-LABEL: sil shared {{.*}} @${{.*}}16tryRequestString{{.*}}U_To : // CHECK: [[BLOCK_COPY:%.*]] = copy_block %0 @@ -95,14 +95,14 @@ class SlowSwiftServer: NSObject, SlowServing { func tryRequestString() async throws -> String { return "" } // CHECK-LABEL: sil {{.*}} @$s21objc_async_from_swift15SlowSwiftServerC19requestIntAndStringSi_SStyYaF - // CHECK-NN: bb0([[HOP_TARGET:%.*]] : @guaranteed $Optional, - // CHECK-C: [[HOP_TARGET:%.*]] = enum $Optional, #Optional.none + // CHECK-NN: bb0([[HOP_TARGET:%.*]] : @guaranteed $Builtin.ImplicitActor, + // CHECK-C: [[HOP_TARGET:%.*]] = enum $Optional, #Optional.none // CHECK: hop_to_executor [[HOP_TARGET]] : func requestIntAndString() async -> (Int, String) { return (0, "") } // CHECK-LABEL: sil {{.*}} @$s21objc_async_from_swift15SlowSwiftServerC22tryRequestIntAndStringSi_SStyYaKF - // CHECK-NN: bb0([[HOP_TARGET:%.*]] : @guaranteed $Optional, - // CHECK-C: [[HOP_TARGET:%.*]] = enum $Optional, #Optional.none + // CHECK-NN: bb0([[HOP_TARGET:%.*]] : @guaranteed $Builtin.ImplicitActor, + // CHECK-C: [[HOP_TARGET:%.*]] = enum $Optional, #Optional.none // CHECK: hop_to_executor [[HOP_TARGET]] : func tryRequestIntAndString() async throws -> (Int, String) { return (0, "") } } @@ -122,16 +122,17 @@ extension SlowServer: NativelySlowServing {} // CHECK-C-LABEL: sil private [transparent] [thunk] [ossa] @$sSo10SlowServerC21objc_async_from_swift08NativelyA7ServingA2cDP011doSomethingA0ySiSSYaFTW : $@convention(witness_method: NativelySlowServing) @async (@guaranteed String, @in_guaranteed SlowServer) -> Int { // CHECK-C: bb0([[ARG:%.*]] : @guaranteed $String, [[SELF_ADDR:%.*]] : $*SlowServer): // CHECK-C: [[SELF:%.*]] = load_borrow [[SELF_ADDR]] -// CHECK-C: [[FUNC:%.*]] = function_ref @$sSo10SlowServerC011doSomethingA0ySiSSYaFTO : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String, @guaranteed SlowServer) -> Int +// CHECK-C: [[FUNC:%.*]] = function_ref @$sSo10SlowServerC011doSomethingA0ySiSSYaFTO : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String, @guaranteed SlowServer) -> Int // CHECK-C: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt -// CHECK-C: hop_to_executor [[ACTOR]] -// CHECK-C: apply [[FUNC]]([[ACTOR]], [[ARG]], [[SELF]]) +// CHECK-C: [[ACTOR_C:%.*]] = unchecked_value_cast [[ACTOR]] : $Optional to $Builtin.ImplicitActor +// CHECK-C: hop_to_executor [[ACTOR_C]] +// CHECK-C: apply [[FUNC]]([[ACTOR_C]], [[ARG]], [[SELF]]) // CHECK-C: } // end sil function '$sSo10SlowServerC21objc_async_from_swift08NativelyA7ServingA2cDP011doSomethingA0ySiSSYaFTW' -// CHECK-NN-LABEL: sil private [transparent] [thunk] [ossa] @$sSo10SlowServerC21objc_async_from_swift08NativelyA7ServingA2cDP011doSomethingA0ySiSSYaFTW : $@convention(witness_method: NativelySlowServing) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String, @in_guaranteed SlowServer) -> Int { -// CHECK-NN: bb0([[ACTOR:%.*]] : @guaranteed $Optional, [[ARG:%.*]] : @guaranteed $String, [[SELF_ADDR:%.*]] : $*SlowServer): +// CHECK-NN-LABEL: sil private [transparent] [thunk] [ossa] @$sSo10SlowServerC21objc_async_from_swift08NativelyA7ServingA2cDP011doSomethingA0ySiSSYaFTW : $@convention(witness_method: NativelySlowServing) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String, @in_guaranteed SlowServer) -> Int { +// CHECK-NN: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, [[ARG:%.*]] : @guaranteed $String, [[SELF_ADDR:%.*]] : $*SlowServer): // CHECK-NN: [[SELF:%.*]] = load_borrow [[SELF_ADDR]] -// CHECK-NN: [[FUNC:%.*]] = function_ref @$sSo10SlowServerC011doSomethingA0ySiSSYaFTO : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String, @guaranteed SlowServer) -> Int +// CHECK-NN: [[FUNC:%.*]] = function_ref @$sSo10SlowServerC011doSomethingA0ySiSSYaFTO : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String, @guaranteed SlowServer) -> Int // CHECK-NN: apply [[FUNC]]([[ACTOR]], [[ARG]], [[SELF]]) // CHECK-NN: hop_to_executor [[ACTOR]] // CHECK-NN: } // end sil function '$sSo10SlowServerC21objc_async_from_swift08NativelyA7ServingA2cDP011doSomethingA0ySiSSYaFTW' @@ -140,16 +141,17 @@ extension SlowServer: NativelySlowServing {} // CHECK-C-LABEL: sil private [transparent] [thunk] [ossa] @$sSo10SlowServerC21objc_async_from_swift08NativelyA7ServingA2cDP10findAnswerSSyYaKFTW : $@convention(witness_method: NativelySlowServing) @async (@in_guaranteed SlowServer) -> (@owned String, @error any Error) { // CHECK-C: bb0([[SELF_ADDR:%.*]] : $*SlowServer): // CHECK-C: [[SELF:%.*]] = load_borrow [[SELF_ADDR]] -// CHECK-C: [[FUNC:%.*]] = function_ref @$sSo10SlowServerC10findAnswerSSyYaKFTO : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SlowServer) -> (@owned String, @error any Error) +// CHECK-C: [[FUNC:%.*]] = function_ref @$sSo10SlowServerC10findAnswerSSyYaKFTO : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SlowServer) -> (@owned String, @error any Error) // CHECK-C: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt -// CHECK-C: hop_to_executor [[ACTOR]] -// CHECK-C: try_apply [[FUNC]]([[ACTOR]], [[SELF]]) +// CHECK-C: [[ACTOR_CAST:%.*]] = unchecked_value_cast [[ACTOR]] : $Optional to $Builtin.ImplicitActor +// CHECK-C: hop_to_executor [[ACTOR_CAST]] +// CHECK-C: try_apply [[FUNC]]([[ACTOR_CAST]], [[SELF]]) // CHECK-C: } // end sil function '$sSo10SlowServerC21objc_async_from_swift08NativelyA7ServingA2cDP10findAnswerSSyYaKFTW' -// CHECK-NN-LABEL: sil private [transparent] [thunk] [ossa] @$sSo10SlowServerC21objc_async_from_swift08NativelyA7ServingA2cDP10findAnswerSSyYaKFTW : $@convention(witness_method: NativelySlowServing) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed SlowServer) -> (@owned String, @error any Error) { -// CHECK-NN: bb0([[ACTOR:%.*]] : @guaranteed $Optional, [[SELF_ADDR:%.*]] : $*SlowServer): +// CHECK-NN-LABEL: sil private [transparent] [thunk] [ossa] @$sSo10SlowServerC21objc_async_from_swift08NativelyA7ServingA2cDP10findAnswerSSyYaKFTW : $@convention(witness_method: NativelySlowServing) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed SlowServer) -> (@owned String, @error any Error) { +// CHECK-NN: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, [[SELF_ADDR:%.*]] : $*SlowServer): // CHECK-NN: [[SELF:%.*]] = load_borrow [[SELF_ADDR]] -// CHECK-NN: [[FUNC:%.*]] = function_ref @$sSo10SlowServerC10findAnswerSSyYaKFTO : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SlowServer) -> (@owned String, @error any Error) +// CHECK-NN: [[FUNC:%.*]] = function_ref @$sSo10SlowServerC10findAnswerSSyYaKFTO : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SlowServer) -> (@owned String, @error any Error) // CHECK-NN: try_apply [[FUNC]]([[ACTOR]], [[SELF]]) // // CHECK-NN: bb1( @@ -163,16 +165,17 @@ extension SlowServer: NativelySlowServing {} // CHECK-C-LABEL: sil private [transparent] [thunk] [ossa] @$sSo10SlowServerC21objc_async_from_swift08NativelyA7ServingA2cDP13serverRestartyySSYaFTW : $@convention(witness_method: NativelySlowServing) @async (@guaranteed String, @in_guaranteed SlowServer) -> () { // CHECK-C: bb0([[ARG:%.*]] : @guaranteed $String, [[SELF_PTR:%.*]] : $*SlowServer): // CHECK-C: [[SELF:%.*]] = load_borrow [[SELF_PTR]] -// CHECK-C: [[FUNC:%.*]] = function_ref @$sSo10SlowServerC13serverRestartyySSYaFTO : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String, @guaranteed SlowServer) -> () +// CHECK-C: [[FUNC:%.*]] = function_ref @$sSo10SlowServerC13serverRestartyySSYaFTO : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String, @guaranteed SlowServer) -> () // CHECK-C: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt -// CHECK-C: hop_to_executor [[ACTOR]] -// CHECK-C: apply [[FUNC]]([[ACTOR]], [[ARG]], [[SELF]]) +// CHECK-C: [[ACTOR_CAST:%.*]] = unchecked_value_cast [[ACTOR]] : $Optional to $Builtin.ImplicitActor +// CHECK-C: hop_to_executor [[ACTOR_CAST]] +// CHECK-C: apply [[FUNC]]([[ACTOR_CAST]], [[ARG]], [[SELF]]) // CHECK-C: } // end sil function '$sSo10SlowServerC21objc_async_from_swift08NativelyA7ServingA2cDP13serverRestartyySSYaFTW' -// CHECK-NN-LABEL: sil private [transparent] [thunk] [ossa] @$sSo10SlowServerC21objc_async_from_swift08NativelyA7ServingA2cDP13serverRestartyySSYaFTW : $@convention(witness_method: NativelySlowServing) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String, @in_guaranteed SlowServer) -> () { -// CHECK-NN: bb0([[ACTOR:%.*]] : @guaranteed $Optional, [[ARG:%.*]] : @guaranteed $String, [[SELF_PTR:%.*]] : $*SlowServer): +// CHECK-NN-LABEL: sil private [transparent] [thunk] [ossa] @$sSo10SlowServerC21objc_async_from_swift08NativelyA7ServingA2cDP13serverRestartyySSYaFTW : $@convention(witness_method: NativelySlowServing) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String, @in_guaranteed SlowServer) -> () { +// CHECK-NN: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, [[ARG:%.*]] : @guaranteed $String, [[SELF_PTR:%.*]] : $*SlowServer): // CHECK-NN: [[SELF:%.*]] = load_borrow [[SELF_PTR]] -// CHECK-NN: [[FUNC:%.*]] = function_ref @$sSo10SlowServerC13serverRestartyySSYaFTO : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String, @guaranteed SlowServer) -> () +// CHECK-NN: [[FUNC:%.*]] = function_ref @$sSo10SlowServerC13serverRestartyySSYaFTO : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String, @guaranteed SlowServer) -> () // CHECK-NN: apply [[FUNC]]([[ACTOR]], [[ARG]], [[SELF]]) // CHECK-NN: hop_to_executor [[ACTOR]] // CHECK-NN: } // end sil function '$sSo10SlowServerC21objc_async_from_swift08NativelyA7ServingA2cDP13serverRestartyySSYaFTW' @@ -181,16 +184,17 @@ extension SlowServer: NativelySlowServing {} // CHECK-C-LABEL: sil private [transparent] [thunk] [ossa] @$sSo10SlowServerC21objc_async_from_swift08NativelyA7ServingA2cDP19findMultipleAnswersSS_SityYaKFTW : $@convention(witness_method: NativelySlowServing) @async (@in_guaranteed SlowServer) -> (@owned String, Int, @error any Error) { // CHECK-C: bb0([[SELF_ADDR:%.*]] : $*SlowServer): // CHECK-C: [[SELF:%.*]] = load_borrow [[SELF_ADDR]] -// CHECK-C: [[FUNC:%.*]] = function_ref @$sSo10SlowServerC19findMultipleAnswersSS_SityYaKFTO : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SlowServer) -> (@owned String, Int, @error any Error) +// CHECK-C: [[FUNC:%.*]] = function_ref @$sSo10SlowServerC19findMultipleAnswersSS_SityYaKFTO : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SlowServer) -> (@owned String, Int, @error any Error) // CHECK-C: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt -// CHECK-C: hop_to_executor [[ACTOR]] -// CHECK-C: try_apply [[FUNC]]([[ACTOR]], [[SELF]]) +// CHECK-C: [[ACTOR_CAST:%.*]] = unchecked_value_cast [[ACTOR]] : $Optional to $Builtin.ImplicitActor +// CHECK-C: hop_to_executor [[ACTOR_CAST]] +// CHECK-C: try_apply [[FUNC]]([[ACTOR_CAST]], [[SELF]]) // CHECK-C: } // end sil function '$sSo10SlowServerC21objc_async_from_swift08NativelyA7ServingA2cDP19findMultipleAnswersSS_SityYaKFTW' -// CHECK-NN-LABEL: sil private [transparent] [thunk] [ossa] @$sSo10SlowServerC21objc_async_from_swift08NativelyA7ServingA2cDP19findMultipleAnswersSS_SityYaKFTW : $@convention(witness_method: NativelySlowServing) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed SlowServer) -> (@owned String, Int, @error any Error) { -// CHECK-NN: bb0([[ACTOR:%.*]] : @guaranteed $Optional, [[SELF_ADDR:%.*]] : $*SlowServer): +// CHECK-NN-LABEL: sil private [transparent] [thunk] [ossa] @$sSo10SlowServerC21objc_async_from_swift08NativelyA7ServingA2cDP19findMultipleAnswersSS_SityYaKFTW : $@convention(witness_method: NativelySlowServing) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed SlowServer) -> (@owned String, Int, @error any Error) { +// CHECK-NN: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, [[SELF_ADDR:%.*]] : $*SlowServer): // CHECK-NN: [[SELF:%.*]] = load_borrow [[SELF_ADDR]] -// CHECK-NN: [[FUNC:%.*]] = function_ref @$sSo10SlowServerC19findMultipleAnswersSS_SityYaKFTO : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SlowServer) -> (@owned String, Int, @error any Error) +// CHECK-NN: [[FUNC:%.*]] = function_ref @$sSo10SlowServerC19findMultipleAnswersSS_SityYaKFTO : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SlowServer) -> (@owned String, Int, @error any Error) // CHECK-NN: try_apply [[FUNC]]([[ACTOR]], [[SELF]]) // // CHECK-NN: bb1( @@ -204,13 +208,13 @@ class SlowServerlet: SlowServer { // Native Function // // CHECK-C-LABEL: sil hidden [ossa] @$s21objc_async_from_swift13SlowServerletC011doSomethingE8NullablyySiSSYaF : $@convention(method) @async (@guaranteed String, @guaranteed SlowServerlet) -> Int - // CHECK-C-NOT: bb0([[ACTOR:%.*]] : @guaranteed $Optional - // CHECK-C: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt + // CHECK-C-NOT: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor + // CHECK-C: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt // CHECK-C: hop_to_executor [[ACTOR]] // CHECK-C: // end sil function '$s21objc_async_from_swift13SlowServerletC011doSomethingE8NullablyySiSSYaF' - // CHECK-NN-LABEL: sil hidden [ossa] @$s21objc_async_from_swift13SlowServerletC011doSomethingE8NullablyySiSSYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String, @guaranteed SlowServerlet) -> Int { - // CHECK-NN: bb0([[ACTOR:%.*]] : @guaranteed $Optional + // CHECK-NN-LABEL: sil hidden [ossa] @$s21objc_async_from_swift13SlowServerletC011doSomethingE8NullablyySiSSYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String, @guaranteed SlowServerlet) -> Int { + // CHECK-NN: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor // CHECK-NN: hop_to_executor [[ACTOR]] // CHECK-NN: } // end sil function '$s21objc_async_from_swift13SlowServerletC011doSomethingE8NullablyySiSSYaF' @@ -221,12 +225,13 @@ class SlowServerlet: SlowServer { // // CHECK-LABEL: sil shared [thunk] [ossa] @$s21objc_async_from_swift13SlowServerletC011doSomethingE8NullablyySiSSYaFyyYacfU_To : $@convention(thin) @Sendable @async (NSString, Optional<@convention(block) @Sendable (Int) -> ()>, SlowServerlet) -> () { // CHECK-NN: [[NONE:%.*]] = enum $Optional, #Optional.none!enumelt + // CHECK-NN: [[NONE_CAST:%.*]] = unchecked_value_cast [[NONE]] : $Optional to $Builtin.ImplicitActor // CHECK: [[STR_ARG:%.*]] = begin_borrow {{.*}} : $String // CHECK: [[SELF:%.*]] = begin_borrow {{.*}} : $SlowServerlet // CHECK-C: [[FUNC:%.*]] = function_ref @$s21objc_async_from_swift13SlowServerletC011doSomethingE8NullablyySiSSYaF : $@convention(method) @async (@guaranteed String, @guaranteed SlowServerlet) -> Int // CHECK-C: apply [[FUNC]]([[STR_ARG]], [[SELF]]) - // CHECK-NN: [[FUNC:%.*]] = function_ref @$s21objc_async_from_swift13SlowServerletC011doSomethingE8NullablyySiSSYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String, @guaranteed SlowServerlet) -> Int - // CHECK-NN: apply [[FUNC]]([[NONE]], [[STR_ARG]], [[SELF]]) + // CHECK-NN: [[FUNC:%.*]] = function_ref @$s21objc_async_from_swift13SlowServerletC011doSomethingE8NullablyySiSSYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String, @guaranteed SlowServerlet) -> Int + // CHECK-NN: apply [[FUNC]]([[NONE_CAST]], [[STR_ARG]], [[SELF]]) // CHECK: } // end sil function '$s21objc_async_from_swift13SlowServerletC011doSomethingE8NullablyySiSSYaFyyYacfU_To' override func doSomethingSlowNullably(_: String) async -> Int { return 0 @@ -235,25 +240,26 @@ class SlowServerlet: SlowServer { // Native function. // // CHECK-C-LABEL: sil hidden [ossa] @$s21objc_async_from_swift13SlowServerletC18findAnswerNullablyyS2SYaF : $@convention(method) @async (@guaranteed String, @guaranteed SlowServerlet) -> @owned String - // CHECK-C-NOT: bb0([[ACTOR:%.*]] : @guaranteed $Optional - // CHECK-C: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt + // CHECK-C-NOT: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor + // CHECK-C: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt // CHECK-C-NEXT: hop_to_executor [[ACTOR]] // CHECK-C: } // end sil function '$s21objc_async_from_swift13SlowServerletC18findAnswerNullablyyS2SYaF' - // CHECK-NN-LABEL: sil hidden [ossa] @$s21objc_async_from_swift13SlowServerletC18findAnswerNullablyyS2SYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String, @guaranteed SlowServerlet) -> @owned String { - // CHECK-NN: bb0([[ACTOR:%.*]] : @guaranteed $Optional, + // CHECK-NN-LABEL: sil hidden [ossa] @$s21objc_async_from_swift13SlowServerletC18findAnswerNullablyyS2SYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String, @guaranteed SlowServerlet) -> @owned String { + // CHECK-NN: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, // CHECK-NN: hop_to_executor [[ACTOR]] // CHECK-NN: } // end sil function '$s21objc_async_from_swift13SlowServerletC18findAnswerNullablyyS2SYaF' // @objc closure thunk // CHECK-LABEL: sil shared [thunk] [ossa] @$s21objc_async_from_swift13SlowServerletC18findAnswerNullablyyS2SYaFyyYacfU_To : $@convention(thin) @Sendable @async (NSString, Optional<@convention(block) @Sendable (NSString) -> ()>, SlowServerlet) -> () { // CHECK-NN: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt + // CHECK-NN: [[ACTOR_CAST:%.*]] = unchecked_value_cast [[ACTOR]] : $Optional to $Builtin.ImplicitActor // CHECK: [[STR_ARG:%.*]] = begin_borrow {{.*}} : $String // CHECK: [[SELF:%.*]] = begin_borrow {{.*}} : $SlowServerlet // CHECK-C: [[FUNC:%.*]] = function_ref @$s21objc_async_from_swift13SlowServerletC18findAnswerNullablyyS2SYaF : $@convention(method) @async (@guaranteed String, @guaranteed SlowServerlet) -> @owned String // CHECK-C: apply [[FUNC]]([[STR_ARG]], [[SELF]]) - // CHECK-NN: [[FUNC:%.*]] = function_ref @$s21objc_async_from_swift13SlowServerletC18findAnswerNullablyyS2SYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String, @guaranteed SlowServerlet) -> @owned String - // CHECK-NN: apply [[FUNC]]([[ACTOR]], [[STR_ARG]], [[SELF]]) + // CHECK-NN: [[FUNC:%.*]] = function_ref @$s21objc_async_from_swift13SlowServerletC18findAnswerNullablyyS2SYaF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String, @guaranteed SlowServerlet) -> @owned String + // CHECK-NN: apply [[FUNC]]([[ACTOR_CAST]], [[STR_ARG]], [[SELF]]) // CHECK: } // end sil function '$s21objc_async_from_swift13SlowServerletC18findAnswerNullablyyS2SYaFyyYacfU_To' override func findAnswerNullably(_ x: String) async -> String { return x @@ -262,13 +268,13 @@ class SlowServerlet: SlowServer { // Native // // CHECK-C-LABEL: sil hidden [ossa] @$s21objc_async_from_swift13SlowServerletC28doSomethingDangerousNullablyyS2SYaKF : $@convention(method) @async (@guaranteed String, @guaranteed SlowServerlet) -> (@owned String, @error any Error) - // CHECK-C-NOT: bb0([[ACTOR:%.*]] : @guaranteed $Optional, - // CHECK-C: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt + // CHECK-C-NOT: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, + // CHECK-C: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt // CHECK-C-NEXT: hop_to_executor [[ACTOR]] // CHECK-C: } // end sil function '$s21objc_async_from_swift13SlowServerletC28doSomethingDangerousNullablyyS2SYaKF' - // CHECK-NN-LABEL: sil hidden [ossa] @$s21objc_async_from_swift13SlowServerletC28doSomethingDangerousNullablyyS2SYaKF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String, @guaranteed SlowServerlet) -> (@owned String, @error any Error) { - // CHECK-NN: bb0([[ACTOR:%.*]] : @guaranteed $Optional, + // CHECK-NN-LABEL: sil hidden [ossa] @$s21objc_async_from_swift13SlowServerletC28doSomethingDangerousNullablyyS2SYaKF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String, @guaranteed SlowServerlet) -> (@owned String, @error any Error) { + // CHECK-NN: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, // CHECK-NN: hop_to_executor [[ACTOR]] // CHECK-NN: } // end sil function '$s21objc_async_from_swift13SlowServerletC28doSomethingDangerousNullablyyS2SYaKF' @@ -276,12 +282,13 @@ class SlowServerlet: SlowServer { // // CHECK-LABEL: sil shared [thunk] [ossa] @$s21objc_async_from_swift13SlowServerletC28doSomethingDangerousNullablyyS2SYaKFyyYacfU_To : $@convention(thin) @Sendable @async (NSString, Optional<@convention(block) @Sendable (Optional, Optional) -> ()>, SlowServerlet) -> () { // CHECK-NN: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt + // CHECK-NN: [[ACTOR_CAST:%.*]] = unchecked_value_cast [[ACTOR]] : $Optional to $Builtin.ImplicitActor // CHECK: [[STR_ARG:%.*]] = begin_borrow {{.*}} : $String // CHECK: [[SELF:%.*]] = begin_borrow {{.*}} : $SlowServerlet // CHECK-C: [[NATIVE:%.*]] = function_ref @$s21objc_async_from_swift13SlowServerletC28doSomethingDangerousNullablyyS2SYaKF : $@convention(method) @async (@guaranteed String, @guaranteed SlowServerlet) -> (@owned String, @error any Error) // CHECK-C: apply [[NATIVE]]([[STR_ARG]], [[SELF]]) - // CHECK-NN: [[NATIVE:%.*]] = function_ref @$s21objc_async_from_swift13SlowServerletC28doSomethingDangerousNullablyyS2SYaKF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String, @guaranteed SlowServerlet) -> (@owned String, @error any Error) - // CHECK-NN: apply [[NATIVE]]([[ACTOR]], [[STR_ARG]], [[SELF]]) + // CHECK-NN: [[NATIVE:%.*]] = function_ref @$s21objc_async_from_swift13SlowServerletC28doSomethingDangerousNullablyyS2SYaKF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String, @guaranteed SlowServerlet) -> (@owned String, @error any Error) + // CHECK-NN: apply [[NATIVE]]([[ACTOR_CAST]], [[STR_ARG]], [[SELF]]) // CHECK: } // end sil function '$s21objc_async_from_swift13SlowServerletC28doSomethingDangerousNullablyyS2SYaKFyyYacfU_To' override func doSomethingDangerousNullably(_ x: String) async throws -> String { return x @@ -290,24 +297,25 @@ class SlowServerlet: SlowServer { // Native // // CHECK-C-LABEL: sil hidden [ossa] @$s21objc_async_from_swift13SlowServerletC30doSomethingUnspecifiedNullablySSyYaKF : $@convention(method) @async (@guaranteed SlowServerlet) -> (@owned String, @error any Error) - // CHECK-C-NOT: bb0([[ACTOR:%.*]] : @guaranteed $Optional, - // CHECK-C: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt + // CHECK-C-NOT: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, + // CHECK-C: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt // CHECK-C-NEXT: hop_to_executor [[ACTOR]] // CHECK-C: } // end sil function '$s21objc_async_from_swift13SlowServerletC30doSomethingUnspecifiedNullablySSyYaKF' - // CHECK-NN-LABEL: sil hidden [ossa] @$s21objc_async_from_swift13SlowServerletC30doSomethingUnspecifiedNullablySSyYaKF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SlowServerlet) -> (@owned String, @error any Error) { - // CHECK-NN: bb0([[ACTOR:%.*]] : @guaranteed $Optional, + // CHECK-NN-LABEL: sil hidden [ossa] @$s21objc_async_from_swift13SlowServerletC30doSomethingUnspecifiedNullablySSyYaKF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SlowServerlet) -> (@owned String, @error any Error) { + // CHECK-NN: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, // CHECK-NN: hop_to_executor [[ACTOR]] // CHECK-NN: } // end sil function '$s21objc_async_from_swift13SlowServerletC30doSomethingUnspecifiedNullablySSyYaKF' // @objc closure thunk // CHECK-LABEL: sil shared [thunk] [ossa] @$s21objc_async_from_swift13SlowServerletC30doSomethingUnspecifiedNullablySSyYaKFyyYacfU_To : $@convention(thin) @Sendable @async (Optional<@convention(block) @Sendable (Optional, Optional) -> ()>, SlowServerlet) -> () { // CHECK-NN: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt + // CHECK-NN: [[ACTOR_CAST:%.*]] = unchecked_value_cast [[ACTOR]] : $Optional to $Builtin.ImplicitActor // CHECK: [[SELF:%.*]] = begin_borrow {{.*}} : $SlowServerlet // CHECK-C: [[NATIVE:%.*]] = function_ref @$s21objc_async_from_swift13SlowServerletC30doSomethingUnspecifiedNullablySSyYaKF : $@convention(method) @async (@guaranteed SlowServerlet) -> (@owned String, @error any Error) // CHECK-C: try_apply [[NATIVE]]([[SELF]]) - // CHECK-NN: [[NATIVE:%.*]] = function_ref @$s21objc_async_from_swift13SlowServerletC30doSomethingUnspecifiedNullablySSyYaKF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SlowServerlet) -> (@owned String, @error any Error) - // CHECK-NN: try_apply [[NATIVE]]([[ACTOR]], [[SELF]]) + // CHECK-NN: [[NATIVE:%.*]] = function_ref @$s21objc_async_from_swift13SlowServerletC30doSomethingUnspecifiedNullablySSyYaKF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SlowServerlet) -> (@owned String, @error any Error) + // CHECK-NN: try_apply [[NATIVE]]([[ACTOR_CAST]], [[SELF]]) // CHECK: } // end sil function '$s21objc_async_from_swift13SlowServerletC30doSomethingUnspecifiedNullablySSyYaKFyyYacfU_To' override func doSomethingUnspecifiedNullably() async throws -> String { fatalError() @@ -316,24 +324,25 @@ class SlowServerlet: SlowServer { // Native // // CHECK-C-LABEL: sil hidden [ossa] @$s21objc_async_from_swift13SlowServerletC17doSomethingFlaggySSyYaKF : $@convention(method) @async (@guaranteed SlowServerlet) -> (@owned String, @error any Error) - // CHECK-C-NOT: bb0([[ACTOR:%.*]] : @guaranteed $Optional, - // CHECK-C: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt + // CHECK-C-NOT: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, + // CHECK-C: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt // CHECK-C-NEXT: hop_to_executor [[ACTOR]] // CHECK-C: } // end sil function '$s21objc_async_from_swift13SlowServerletC17doSomethingFlaggySSyYaKF' - // CHECK-NN-LABEL: sil hidden [ossa] @$s21objc_async_from_swift13SlowServerletC17doSomethingFlaggySSyYaKF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SlowServerlet) -> (@owned String, @error any Error) { - // CHECK-NN: bb0([[ACTOR:%.*]] : @guaranteed $Optional, + // CHECK-NN-LABEL: sil hidden [ossa] @$s21objc_async_from_swift13SlowServerletC17doSomethingFlaggySSyYaKF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SlowServerlet) -> (@owned String, @error any Error) { + // CHECK-NN: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, // CHECK-NN: hop_to_executor [[ACTOR]] // CHECK-NN: } // end sil function '$s21objc_async_from_swift13SlowServerletC17doSomethingFlaggySSyYaKF' // @objc thunk closure // CHECK-LABEL: sil shared [thunk] [ossa] @$s21objc_async_from_swift13SlowServerletC17doSomethingFlaggySSyYaKFyyYacfU_To : $@convention(thin) @Sendable @async (@convention(block) @Sendable ({{.*}}, Optional, Optional) -> (), SlowServerlet) -> () { // CHECK-NN: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt + // CHECK-NN: [[ACTOR_CAST:%.*]] = unchecked_value_cast [[ACTOR]] : $Optional to $Builtin.ImplicitActor // CHECK: [[SELF:%.*]] = begin_borrow {{.*}} : $SlowServerlet // CHECK-C: [[NATIVE:%.*]] = function_ref @$s21objc_async_from_swift13SlowServerletC17doSomethingFlaggySSyYaKF : $@convention(method) @async (@guaranteed SlowServerlet) -> (@owned String, @error any Error) // CHECK-C: try_apply [[NATIVE]]([[SELF]]) : {{.*}}, normal [[NORMAL_BB:bb[0-9]+]], error [[ERROR_BB:bb[0-9]+]] - // CHECK-NN: [[NATIVE:%.*]] = function_ref @$s21objc_async_from_swift13SlowServerletC17doSomethingFlaggySSyYaKF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SlowServerlet) -> (@owned String, @error any Error) - // CHECK-NN: try_apply [[NATIVE]]([[ACTOR]], [[SELF]]) : {{.*}}, normal [[NORMAL_BB:bb[0-9]+]], error [[ERROR_BB:bb[0-9]+]] + // CHECK-NN: [[NATIVE:%.*]] = function_ref @$s21objc_async_from_swift13SlowServerletC17doSomethingFlaggySSyYaKF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SlowServerlet) -> (@owned String, @error any Error) + // CHECK-NN: try_apply [[NATIVE]]([[ACTOR_CAST]], [[SELF]]) : {{.*}}, normal [[NORMAL_BB:bb[0-9]+]], error [[ERROR_BB:bb[0-9]+]] // // CHECK: [[NORMAL_BB]]({{.*}}): // CHECK: integer_literal {{.*}}0 @@ -348,24 +357,25 @@ class SlowServerlet: SlowServer { // Native // // CHECK-C-LABEL: sil hidden [ossa] @$s21objc_async_from_swift13SlowServerletC21doSomethingZeroFlaggySSyYaKF : $@convention(method) @async (@guaranteed SlowServerlet) -> (@owned String, @error any Error) - // CHECK-C-NOT: bb0([[ACTOR:%.*]] : @guaranteed $Optional, - // CHECK-C: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt + // CHECK-C-NOT: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, + // CHECK-C: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt // CHECK-C-NEXT: hop_to_executor [[ACTOR]] // CHECK-C: } // end sil function '$s21objc_async_from_swift13SlowServerletC21doSomethingZeroFlaggySSyYaKF' // - // CHECK-NN-LABEL: sil hidden [ossa] @$s21objc_async_from_swift13SlowServerletC21doSomethingZeroFlaggySSyYaKF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SlowServerlet) -> (@owned String, @error any Error) { - // CHECK-NN: bb0([[ACTOR:%.*]] : @guaranteed $Optional, + // CHECK-NN-LABEL: sil hidden [ossa] @$s21objc_async_from_swift13SlowServerletC21doSomethingZeroFlaggySSyYaKF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SlowServerlet) -> (@owned String, @error any Error) { + // CHECK-NN: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, // CHECK-NN: hop_to_executor [[ACTOR]] // CHECK-NN: } // end sil function '$s21objc_async_from_swift13SlowServerletC21doSomethingZeroFlaggySSyYaKF' // // @objc thunk closure // CHECK-LABEL: sil shared [thunk] [ossa] @$s21objc_async_from_swift13SlowServerletC21doSomethingZeroFlaggySSyYaKFyyYacfU_To : $@convention(thin) @Sendable @async (@convention(block) @Sendable (Optional, {{.*}}, Optional) -> (), SlowServerlet) -> () { // CHECK-NN: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt + // CHECK-NN: [[ACTOR_CAST:%.*]] = unchecked_value_cast [[ACTOR]] : $Optional to $Builtin.ImplicitActor // CHECK: [[SELF:%.*]] = begin_borrow {{.*}} : $SlowServerlet // CHECK-C: [[NATIVE:%.*]] = function_ref @$s21objc_async_from_swift13SlowServerletC21doSomethingZeroFlaggySSyYaKF : $@convention(method) @async (@guaranteed SlowServerlet) -> (@owned String, @error any Error) // CHECK-C: try_apply [[NATIVE]]([[SELF]]) : {{.*}}, normal [[NORMAL_BB:bb[0-9]+]], error [[ERROR_BB:bb[0-9]+]] - // CHECK-NN: [[NATIVE:%.*]] = function_ref @$s21objc_async_from_swift13SlowServerletC21doSomethingZeroFlaggySSyYaKF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SlowServerlet) -> (@owned String, @error any Error) - // CHECK-NN: try_apply [[NATIVE]]([[ACTOR]], [[SELF]]) : {{.*}}, normal [[NORMAL_BB:bb[0-9]+]], error [[ERROR_BB:bb[0-9]+]] + // CHECK-NN: [[NATIVE:%.*]] = function_ref @$s21objc_async_from_swift13SlowServerletC21doSomethingZeroFlaggySSyYaKF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SlowServerlet) -> (@owned String, @error any Error) + // CHECK-NN: try_apply [[NATIVE]]([[ACTOR_CAST]], [[SELF]]) : {{.*}}, normal [[NORMAL_BB:bb[0-9]+]], error [[ERROR_BB:bb[0-9]+]] // // CHECK: [[NORMAL_BB]]({{.*}}): // CHECK: integer_literal {{.*}}1 @@ -379,23 +389,24 @@ class SlowServerlet: SlowServer { // Native // // CHECK-C-LABEL: sil hidden [ossa] @$s21objc_async_from_swift13SlowServerletC28doSomethingMultiResultFlaggySS_SStyYaKF : $@convention(method) @async (@guaranteed SlowServerlet) -> (@owned String, @owned String, @error any Error) - // CHECK-C-NOT: bb0([[ACTOR:%.*]] : @guaranteed $Optional, - // CHECK-C: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt + // CHECK-C-NOT: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, + // CHECK-C: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt // CHECK-C-NEXT: hop_to_executor [[ACTOR]] // CHECK-C: } // end sil function '$s21objc_async_from_swift13SlowServerletC28doSomethingMultiResultFlaggySS_SStyYaKF' // - // CHECK-NN-LABEL: sil hidden [ossa] @$s21objc_async_from_swift13SlowServerletC28doSomethingMultiResultFlaggySS_SStyYaKF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SlowServerlet) -> (@owned String, @owned String, @error any Error) { - // CHECK-NN: bb0([[ACTOR:%.*]] : @guaranteed $Optional, + // CHECK-NN-LABEL: sil hidden [ossa] @$s21objc_async_from_swift13SlowServerletC28doSomethingMultiResultFlaggySS_SStyYaKF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SlowServerlet) -> (@owned String, @owned String, @error any Error) { + // CHECK-NN: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, // CHECK-NN: hop_to_executor [[ACTOR]] // CHECK-NN: } // end sil function '$s21objc_async_from_swift13SlowServerletC28doSomethingMultiResultFlaggySS_SStyYaKF' // // CHECK-LABEL: sil shared [thunk] [ossa] @$s21objc_async_from_swift13SlowServerletC28doSomethingMultiResultFlaggySS_SStyYaKFyyYacfU_To : $@convention(thin) @Sendable @async (@convention(block) @Sendable ({{.*}}, Optional, Optional, Optional) -> (), SlowServerlet) -> () { // CHECK-NN: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt + // CHECK-NN: [[ACTOR_CAST:%.*]] = unchecked_value_cast [[ACTOR]] : $Optional to $Builtin.ImplicitActor // CHECK: [[SELF:%.*]] = begin_borrow {{.*}} : $SlowServerlet // CHECK-C: [[NATIVE:%.*]] = function_ref @$s21objc_async_from_swift13SlowServerletC28doSomethingMultiResultFlaggySS_SStyYaKF : $@convention(method) @async (@guaranteed SlowServerlet) -> (@owned String, @owned String, @error any Error) // CHECK-C: try_apply [[NATIVE]]([[SELF]]) : {{.*}}, normal [[NORMAL_BB:bb[0-9]+]], error [[ERROR_BB:bb[0-9]+]] - // CHECK-NN: [[NATIVE:%.*]] = function_ref @$s21objc_async_from_swift13SlowServerletC28doSomethingMultiResultFlaggySS_SStyYaKF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed SlowServerlet) -> (@owned String, @owned String, @error any Error) - // CHECK-NN: try_apply [[NATIVE]]([[ACTOR]], [[SELF]]) : {{.*}}, normal [[NORMAL_BB:bb[0-9]+]], error [[ERROR_BB:bb[0-9]+]] + // CHECK-NN: [[NATIVE:%.*]] = function_ref @$s21objc_async_from_swift13SlowServerletC28doSomethingMultiResultFlaggySS_SStyYaKF : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed SlowServerlet) -> (@owned String, @owned String, @error any Error) + // CHECK-NN: try_apply [[NATIVE]]([[ACTOR_CAST]], [[SELF]]) : {{.*}}, normal [[NORMAL_BB:bb[0-9]+]], error [[ERROR_BB:bb[0-9]+]] // // CHECK: [[NORMAL_BB]]({{.*}}): // CHECK: integer_literal {{.*}}1 @@ -462,7 +473,7 @@ func testAutoclosureInStaticMethod() { // Default argument for method. // // CHECK-C-LABEL: sil private [ossa] @$s21objc_async_from_swift29testAutoclosureInStaticMethodyyF9TestKlassL_C8getValue2id11valueForKeySSSgSS_S2SYaKXEtYaFZfA0_ : $@convention(thin) () -> @owned @async @callee_guaranteed (@guaranteed String) -> (@owned String, @error any Error) { - // CHECK-NN-LABEL: sil private [ossa] @$s21objc_async_from_swift29testAutoclosureInStaticMethodyyF9TestKlassL_C8getValue2id11valueForKeySSSgSS_S2SYaKYCXEtYaFZfA0_ : $@convention(thin) () -> @owned @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String) -> (@owned String, @error any Error) { + // CHECK-NN-LABEL: sil private [ossa] @$s21objc_async_from_swift29testAutoclosureInStaticMethodyyF9TestKlassL_C8getValue2id11valueForKeySSSgSS_S2SYaKYCXEtYaFZfA0_ : $@convention(thin) () -> @owned @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String) -> (@owned String, @error any Error) { // // Get standard. // CHECK: [[METATYPE:%.*]] = metatype $@objc_metatype SlowServer.Type @@ -470,14 +481,14 @@ func testAutoclosureInStaticMethod() { // CHECK: [[STANDARD:%.*]] = apply [[GET_STANDARD_FUNC]]([[METATYPE]]) // // Then grab value. - // CHECK-C: [[GET_VALUE:%.*]] = function_ref @$s21objc_async_from_swift29testAutoclosureInStaticMethodyyF9TestKlassL_C8getValue2id11valueForKeySSSgSS_S2SYaKXEtYaFZfA0_S2SYaKYCcSo10SlowServerCcfu_ : $@convention(thin) (@guaranteed SlowServer) -> @owned @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String) -> (@owned String, @error any Error) - // CHECK-NN: [[GET_VALUE:%.*]] = function_ref @$s21objc_async_from_swift29testAutoclosureInStaticMethodyyF9TestKlassL_C8getValue2id11valueForKeySSSgSS_S2SYaKYCXEtYaFZfA0_S2SYaKYCcSo10SlowServerCcfu_ : $@convention(thin) (@guaranteed SlowServer) -> @owned @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String) -> (@owned String, @error any Error) + // CHECK-C: [[GET_VALUE:%.*]] = function_ref @$s21objc_async_from_swift29testAutoclosureInStaticMethodyyF9TestKlassL_C8getValue2id11valueForKeySSSgSS_S2SYaKXEtYaFZfA0_S2SYaKYCcSo10SlowServerCcfu_ : $@convention(thin) (@guaranteed SlowServer) -> @owned @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String) -> (@owned String, @error any Error) + // CHECK-NN: [[GET_VALUE:%.*]] = function_ref @$s21objc_async_from_swift29testAutoclosureInStaticMethodyyF9TestKlassL_C8getValue2id11valueForKeySSSgSS_S2SYaKYCXEtYaFZfA0_S2SYaKYCcSo10SlowServerCcfu_ : $@convention(thin) (@guaranteed SlowServer) -> @owned @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String) -> (@owned String, @error any Error) // CHECK: [[RESULT:%.*]] = apply [[GET_VALUE]]([[STANDARD]]) // // Then we need to thunk to eliminate the implicit leading parameter. We use // the thunk that passes in .none so this acts as a concurrent function. // - // CHECK-C: [[THUNK_FN:%.*]] = function_ref @$sScA_pSgS2Ss5Error_pIegHgILgozo_S2SsAB_pIegHgozo_TR : $@convention(thin) @async (@guaranteed String, @guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String) -> (@owned String, @error any Error)) -> (@owned String, @error any Error) + // CHECK-C: [[THUNK_FN:%.*]] = function_ref @$sBAS2Ss5Error_pIegHgILgozo_S2SsAA_pIegHgozo_TR : $@convention(thin) @async (@guaranteed String, @guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String) -> (@owned String, @error any Error)) -> (@owned String, @error any Error) // CHECK-C: [[THUNKED:%.*]] = partial_apply [callee_guaranteed] [[THUNK_FN]]([[RESULT]]) // CHECK-C: return [[THUNKED]] // CHECK-NN: return [[RESULT]] @@ -486,12 +497,12 @@ func testAutoclosureInStaticMethod() { // This is the first implicit closure. We close over self here. // - // CHECK-C-LABEL: sil private [ossa] @$s21objc_async_from_swift29testAutoclosureInStaticMethodyyF9TestKlassL_C8getValue2id11valueForKeySSSgSS_S2SYaKXEtYaFZfA0_S2SYaKYCcSo10SlowServerCcfu_ : $@convention(thin) (@guaranteed SlowServer) -> @owned @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String) -> (@owned String, @error any Error) { + // CHECK-C-LABEL: sil private [ossa] @$s21objc_async_from_swift29testAutoclosureInStaticMethodyyF9TestKlassL_C8getValue2id11valueForKeySSSgSS_S2SYaKXEtYaFZfA0_S2SYaKYCcSo10SlowServerCcfu_ : $@convention(thin) (@guaranteed SlowServer) -> @owned @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String) -> (@owned String, @error any Error) { // CHECK: bb0([[SELF:%.*]] : // // Close over self and return it. - // CHECK-C: [[SECOND_CLOSURE:%.*]] = function_ref @$s21objc_async_from_swift29testAutoclosureInStaticMethodyyF9TestKlassL_C8getValue2id11valueForKeySSSgSS_S2SYaKXEtYaFZfA0_S2SYaKYCcSo10SlowServerCcfu_S2SYaKYCcfu0_ : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String, @guaranteed SlowServer) -> (@owned String, @error any Error) - // CHECK-NN: [[SECOND_CLOSURE:%.*]] = function_ref @$s21objc_async_from_swift29testAutoclosureInStaticMethodyyF9TestKlassL_C8getValue2id11valueForKeySSSgSS_S2SYaKYCXEtYaFZfA0_S2SYaKYCcSo10SlowServerCcfu_S2SYaKYCcfu0_ : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String, @guaranteed SlowServer) -> (@owned String, @error any Error) + // CHECK-C: [[SECOND_CLOSURE:%.*]] = function_ref @$s21objc_async_from_swift29testAutoclosureInStaticMethodyyF9TestKlassL_C8getValue2id11valueForKeySSSgSS_S2SYaKXEtYaFZfA0_S2SYaKYCcSo10SlowServerCcfu_S2SYaKYCcfu0_ : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String, @guaranteed SlowServer) -> (@owned String, @error any Error) + // CHECK-NN: [[SECOND_CLOSURE:%.*]] = function_ref @$s21objc_async_from_swift29testAutoclosureInStaticMethodyyF9TestKlassL_C8getValue2id11valueForKeySSSgSS_S2SYaKYCXEtYaFZfA0_S2SYaKYCcSo10SlowServerCcfu_S2SYaKYCcfu0_ : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String, @guaranteed SlowServer) -> (@owned String, @error any Error) // CHECK: [[SELF_COPY:%.*]] = copy_value [[SELF]] // CHECK: [[CLOSE_OVER_SELF:%.*]] = partial_apply [callee_guaranteed] [[SECOND_CLOSURE]]([[SELF_COPY]]) // CHECK: return [[CLOSE_OVER_SELF]] @@ -499,9 +510,9 @@ func testAutoclosureInStaticMethod() { // CHECK-NN: } // end sil function '$s21objc_async_from_swift29testAutoclosureInStaticMethodyyF9TestKlassL_C8getValue2id11valueForKeySSSgSS_S2SYaKYCXEtYaFZfA0_S2SYaKYCcSo10SlowServerCcfu_' // The second closure. In this function we actually perform the objective-c call. - // CHECK-C-LABEL: sil private [ossa] @$s21objc_async_from_swift29testAutoclosureInStaticMethodyyF9TestKlassL_C8getValue2id11valueForKeySSSgSS_S2SYaKXEtYaFZfA0_S2SYaKYCcSo10SlowServerCcfu_S2SYaKYCcfu0_ : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String, @guaranteed SlowServer) -> (@owned String, @error any Error) { - // CHECK-NN-LABEL: sil private [ossa] @$s21objc_async_from_swift29testAutoclosureInStaticMethodyyF9TestKlassL_C8getValue2id11valueForKeySSSgSS_S2SYaKYCXEtYaFZfA0_S2SYaKYCcSo10SlowServerCcfu_S2SYaKYCcfu0_ : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String, @guaranteed SlowServer) -> (@owned String, @error any Error) { - // CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Optional, [[ARG:%.*]] : @guaranteed $String, [[CAPTURE:%.*]] : @closureCapture @guaranteed $SlowServer): + // CHECK-C-LABEL: sil private [ossa] @$s21objc_async_from_swift29testAutoclosureInStaticMethodyyF9TestKlassL_C8getValue2id11valueForKeySSSgSS_S2SYaKXEtYaFZfA0_S2SYaKYCcSo10SlowServerCcfu_S2SYaKYCcfu0_ : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String, @guaranteed SlowServer) -> (@owned String, @error any Error) { + // CHECK-NN-LABEL: sil private [ossa] @$s21objc_async_from_swift29testAutoclosureInStaticMethodyyF9TestKlassL_C8getValue2id11valueForKeySSSgSS_S2SYaKYCXEtYaFZfA0_S2SYaKYCcSo10SlowServerCcfu_S2SYaKYCcfu0_ : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String, @guaranteed SlowServer) -> (@owned String, @error any Error) { + // CHECK: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, [[ARG:%.*]] : @guaranteed $String, [[CAPTURE:%.*]] : @closureCapture @guaranteed $SlowServer): // // Hop to the actor // CHECK: hop_to_executor [[ACTOR]] @@ -545,12 +556,13 @@ func testAutoclosureInStaticMethod() { // thunk for @escaping @callee_guaranteed @async (@guaranteed Actor?, @guaranteed String) -> (@owned String, @error @owned Error) - // CHECK-C-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sScA_pSgS2Ss5Error_pIegHgILgozo_S2SsAB_pIegHgozo_TR : $@convention(thin) @async (@guaranteed String, @guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String) -> (@owned String, @error any Error)) -> (@owned String, @error any Error) { - // CHECK-C: bb0([[ARG:%.*]] : @guaranteed $String, [[FUNC:%.*]] : @guaranteed $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String) -> (@owned String, @error any Error)): + // CHECK-C-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sBAS2Ss5Error_pIegHgILgozo_S2SsAA_pIegHgozo_TR : $@convention(thin) @async (@guaranteed String, @guaranteed @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String) -> (@owned String, @error any Error)) -> (@owned String, @error any Error) { + // CHECK-C: bb0([[ARG:%.*]] : @guaranteed $String, [[FUNC:%.*]] : @guaranteed $@async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String) -> (@owned String, @error any Error)): // CHECK-C: [[ACTOR:%.*]] = enum $Optional, #Optional.none!enumelt // CHECK-C: hop_to_executor [[ACTOR]] - // CHECK-C: try_apply [[FUNC]]([[ACTOR]], [[ARG]]) - // CHECK-C: } // end sil function '$sScA_pSgS2Ss5Error_pIegHgILgozo_S2SsAB_pIegHgozo_TR' + // CHECK-C: [[ACTOR_CAST:%.*]] = unchecked_value_cast [[ACTOR]] : $Optional to $Builtin.ImplicitActor + // CHECK-C: try_apply [[FUNC]]([[ACTOR_CAST]], [[ARG]]) + // CHECK-C: } // end sil function '$sBAS2Ss5Error_pIegHgILgozo_S2SsAA_pIegHgozo_TR' // Actual static method // @@ -561,14 +573,14 @@ func testAutoclosureInStaticMethod() { // // CHECK-C-LABEL: sil private [ossa] @$s21objc_async_from_swift29testAutoclosureInStaticMethodyyF9TestKlassL_C8getValue2id11valueForKeySSSgSS_S2SYaKXEtYaFZ : $@convention(method) @async (@guaranteed String, @guaranteed @noescape @async @callee_guaranteed (@guaranteed String) -> (@owned String, @error any Error), @thick TestKlass.Type) -> @owned Optional { // CHECK-C: bb0([[STRING:%.*]] : @guaranteed $String, [[COMPLETION:%.*]] : @guaranteed $@noescape @async @callee_guaranteed (@guaranteed String) -> (@owned String, @error any Error), [[METATYPE:%.*]] : $@thick TestKlass.Type) - // CHECK-C: [[EXEC_NONE:%.*]] = enum $Optional, #Optional.none!enumelt + // CHECK-C: [[EXEC_NONE:%.*]] = enum $Optional, #Optional.none!enumelt // CHECK-C: hop_to_executor [[EXEC_NONE]] // CHECK-C: hop_to_executor [[EXEC_NONE]] // CHECK-C: hop_to_executor [[EXEC_NONE]] // CHECK-C: } // end sil function '$s21objc_async_from_swift29testAutoclosureInStaticMethodyyF9TestKlassL_C8getValue2id11valueForKeySSSgSS_S2SYaKXEtYaFZ' - // CHECK-NN-LABEL: sil private [ossa] @$s21objc_async_from_swift29testAutoclosureInStaticMethodyyF9TestKlassL_C8getValue2id11valueForKeySSSgSS_S2SYaKYCXEtYaFZ : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String, @guaranteed @noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String) -> (@owned String, @error any Error), @thick TestKlass.Type) -> @owned Optional { - // CHECK-NN: bb0([[ACTOR:%.*]] : @guaranteed $Optional, [[STRING:%.*]] : @guaranteed $String, [[COMPLETION:%.*]] : @guaranteed $@noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String) -> (@owned String, @error any Error), %3 : $@thick TestKlass.Type): + // CHECK-NN-LABEL: sil private [ossa] @$s21objc_async_from_swift29testAutoclosureInStaticMethodyyF9TestKlassL_C8getValue2id11valueForKeySSSgSS_S2SYaKYCXEtYaFZ : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String, @guaranteed @noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String) -> (@owned String, @error any Error), @thick TestKlass.Type) -> @owned Optional { + // CHECK-NN: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, [[STRING:%.*]] : @guaranteed $String, [[COMPLETION:%.*]] : @guaranteed $@noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String) -> (@owned String, @error any Error), %3 : $@thick TestKlass.Type): // CHECK-NN: hop_to_executor [[ACTOR]] // CHECK-NN: hop_to_executor [[ACTOR]] // CHECK-NN: hop_to_executor [[ACTOR]] @@ -588,7 +600,7 @@ func testAutoclosureInStaticMethod() { // Default argument for method. // // CHECK-C-LABEL: sil private [ossa] @$s21objc_async_from_swift29testAutoclosureInStaticMethodyyF9TestKlassL_C17getMainActorValue2id11valueForKeySSSgSS_S2SYaKXEtYaFZfA0_ : $@convention(thin) () -> @owned @async @callee_guaranteed (@guaranteed String) -> (@owned String, @error any Error) { - // CHECK-NN-LABEL: sil private [ossa] @$s21objc_async_from_swift29testAutoclosureInStaticMethodyyF9TestKlassL_C17getMainActorValue2id11valueForKeySSSgSS_S2SYaKYCXEtYaFZfA0_ : $@convention(thin) () -> @owned @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String) -> (@owned String, @error any Error) { + // CHECK-NN-LABEL: sil private [ossa] @$s21objc_async_from_swift29testAutoclosureInStaticMethodyyF9TestKlassL_C17getMainActorValue2id11valueForKeySSSgSS_S2SYaKYCXEtYaFZfA0_ : $@convention(thin) () -> @owned @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String) -> (@owned String, @error any Error) { // // Get standard. // CHECK: [[METATYPE:%.*]] = metatype $@objc_metatype SlowServer.Type @@ -600,7 +612,7 @@ func testAutoclosureInStaticMethod() { // CHECK-NN: [[GET_VALUE:%.*]] = function_ref @$s21objc_async_from_swift29testAutoclosureInStaticMethodyyF9TestKlassL_C17getMainActorValue2id11valueForKeySSSgSS_S2SYaKYCXEtYaFZfA0_S2SYaKScMYccSo10SlowServerCcfu_ : $@convention(thin) (@guaranteed SlowServer) -> @owned @async @callee_guaranteed (@guaranteed String) -> (@owned String, @error any Error) // CHECK: [[RESULT:%.*]] = apply [[GET_VALUE]]([[STANDARD]]) // - // CHECK-NN: [[THUNK:%.*]] = function_ref @$sS2Ss5Error_pIegHgozo_ScA_pSgS2SsAA_pIegHgILgozo_TR : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String, @guaranteed @async @callee_guaranteed (@guaranteed String) -> (@owned String, @error any Error)) -> (@owned String, @error any Error) + // CHECK-NN: [[THUNK:%.*]] = function_ref @$sS2Ss5Error_pIegHgozo_BAS2SsAA_pIegHgILgozo_TR : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String, @guaranteed @async @callee_guaranteed (@guaranteed String) -> (@owned String, @error any Error)) -> (@owned String, @error any Error) // CHECK-NN: [[THUNKED_RESULT:%.*]] = partial_apply [callee_guaranteed] [[THUNK]]([[RESULT]]) // CHECK-C: return [[RESULT]] // CHECK-NN: return [[THUNKED_RESULT]] @@ -676,8 +688,8 @@ func testAutoclosureInStaticMethod() { // nonisolated(nonsending) by default just due to the way the compiler emits // thunks at different times due to different usages. // - // CHECK-NN-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sS2Ss5Error_pIegHgozo_ScA_pSgS2SsAA_pIegHgILgozo_TR : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String, @guaranteed @async @callee_guaranteed (@guaranteed String) -> (@owned String, @error any Error)) -> (@owned String, @error any Error) { - // CHECK-NN: bb0([[ACTOR:%.*]] : @guaranteed $Optional, [[ARG:%.*]] : @guaranteed $String, [[FUNC:%.*]] : @guaranteed $@async @callee_guaranteed (@guaranteed String) -> (@owned String, @error any Error)): + // CHECK-NN-LABEL: sil shared [transparent] [serialized] [reabstraction_thunk] [ossa] @$sS2Ss5Error_pIegHgozo_BAS2SsAA_pIegHgILgozo_TR : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String, @guaranteed @async @callee_guaranteed (@guaranteed String) -> (@owned String, @error any Error)) -> (@owned String, @error any Error) { + // CHECK-NN: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, [[ARG:%.*]] : @guaranteed $String, [[FUNC:%.*]] : @guaranteed $@async @callee_guaranteed (@guaranteed String) -> (@owned String, @error any Error)): // CHECK-NN: try_apply [[FUNC]]([[ARG]]) // // CHECK-NN: bb1( @@ -685,7 +697,7 @@ func testAutoclosureInStaticMethod() { // // CHECK-NN: bb2( // CHECK-NN: hop_to_executor [[ACTOR]] - // CHECK-NN: } // end sil function '$sS2Ss5Error_pIegHgozo_ScA_pSgS2SsAA_pIegHgILgozo_TR' + // CHECK-NN: } // end sil function '$sS2Ss5Error_pIegHgozo_BAS2SsAA_pIegHgILgozo_TR' // Actual static method // @@ -693,14 +705,14 @@ func testAutoclosureInStaticMethod() { // // CHECK-C-LABEL: sil private [ossa] @$s21objc_async_from_swift29testAutoclosureInStaticMethodyyF9TestKlassL_C17getMainActorValue2id11valueForKeySSSgSS_S2SYaKXEtYaFZ : $@convention(method) @async (@guaranteed String, @guaranteed @noescape @async @callee_guaranteed (@guaranteed String) -> (@owned String, @error any Error), @thick TestKlass.Type) -> @owned Optional { // CHECK-C: bb0([[STRING:%.*]] : @guaranteed $String, [[COMPLETION:%.*]] : @guaranteed $@noescape @async @callee_guaranteed (@guaranteed String) -> (@owned String, @error any Error), [[METATYPE:%.*]] : $@thick TestKlass.Type) - // CHECK-C: [[EXEC_NONE:%.*]] = enum $Optional, #Optional.none!enumelt + // CHECK-C: [[EXEC_NONE:%.*]] = enum $Optional, #Optional.none!enumelt // CHECK-C: hop_to_executor [[EXEC_NONE]] // CHECK-C: hop_to_executor [[EXEC_NONE]] // CHECK-C: hop_to_executor [[EXEC_NONE]] // CHECK-C: } // end sil function '$s21objc_async_from_swift29testAutoclosureInStaticMethodyyF9TestKlassL_C17getMainActorValue2id11valueForKeySSSgSS_S2SYaKXEtYaFZ' // - // CHECK-NN-LABEL: sil private [ossa] @$s21objc_async_from_swift29testAutoclosureInStaticMethodyyF9TestKlassL_C17getMainActorValue2id11valueForKeySSSgSS_S2SYaKYCXEtYaFZ : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String, @guaranteed @noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String) -> (@owned String, @error any Error), @thick TestKlass.Type) -> @owned Optional { - // CHECK-NN: bb0([[ACTOR:%.*]] : @guaranteed $Optional, [[STRING:%.*]] : @guaranteed $String, [[COMPLETION:%.*]] : @guaranteed $@noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @guaranteed String) -> (@owned String, @error any Error), %3 : $@thick TestKlass.Type) + // CHECK-NN-LABEL: sil private [ossa] @$s21objc_async_from_swift29testAutoclosureInStaticMethodyyF9TestKlassL_C17getMainActorValue2id11valueForKeySSSgSS_S2SYaKYCXEtYaFZ : $@convention(method) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String, @guaranteed @noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String) -> (@owned String, @error any Error), @thick TestKlass.Type) -> @owned Optional { + // CHECK-NN: bb0([[ACTOR:%.*]] : @guaranteed $Builtin.ImplicitActor, [[STRING:%.*]] : @guaranteed $String, [[COMPLETION:%.*]] : @guaranteed $@noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @guaranteed String) -> (@owned String, @error any Error), %3 : $@thick TestKlass.Type) // CHECK-NN: hop_to_executor [[ACTOR]] // CHECK-NN: hop_to_executor [[ACTOR]] // CHECK-NN: hop_to_executor [[ACTOR]] diff --git a/test/SILGen/objc_effectful_properties.swift b/test/SILGen/objc_effectful_properties.swift index 24dba591ecf..bca51d5ea6b 100644 --- a/test/SILGen/objc_effectful_properties.swift +++ b/test/SILGen/objc_effectful_properties.swift @@ -52,7 +52,7 @@ func testAsyncThrows(eff : EffProps) async { // CHECK-LABEL: sil {{.*}}@${{.*}}17testMainActorProp func testMainActorProp(eff : EffProps) async { - // CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none + // CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none // CHECK-NEXT: hop_to_executor [[GENERIC_EXEC]] : // CHECK: hop_to_executor [[GENERIC_EXEC]] : // CHECK: } // end sil function '${{.*}}17testMainActorProp @@ -61,7 +61,7 @@ func testMainActorProp(eff : EffProps) async { // CHECK-LABEL: sil {{.*}}@${{.*}}19testMainActorMethod func testMainActorMethod(eff : EffProps) async { - // CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none + // CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none // CHECK-NEXT: hop_to_executor [[GENERIC_EXEC]] : // CHECK: hop_to_executor [[GENERIC_EXEC]] : // CHECK: } // end sil function '${{.*}}19testMainActorMethod diff --git a/test/SILGen/objc_effectful_properties_checked.swift b/test/SILGen/objc_effectful_properties_checked.swift index 14f891b76b6..31d34d40771 100644 --- a/test/SILGen/objc_effectful_properties_checked.swift +++ b/test/SILGen/objc_effectful_properties_checked.swift @@ -62,7 +62,7 @@ func testAsyncThrows(eff : EffProps) async { // CHECK-LABEL: sil {{.*}}@${{.*}}17testMainActorProp func testMainActorProp(eff : EffProps) async { - // CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none + // CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none // CHECK-NEXT: hop_to_executor [[GENERIC_EXEC]] : // CHECK: hop_to_executor [[GENERIC_EXEC]] : // CHECK: } // end sil function '${{.*}}17testMainActorProp @@ -71,7 +71,7 @@ func testMainActorProp(eff : EffProps) async { // CHECK-LABEL: sil {{.*}}@${{.*}}19testMainActorMethod func testMainActorMethod(eff : EffProps) async { - // CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none + // CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional, #Optional.none // CHECK-NEXT: hop_to_executor [[GENERIC_EXEC]] : // CHECK: hop_to_executor [[GENERIC_EXEC]] : // CHECK: } // end sil function '${{.*}}19testMainActorMethod diff --git a/test/SILGen/toplevel_globalactorvars.swift b/test/SILGen/toplevel_globalactorvars.swift index 5cde7c24fc1..9a4d7228770 100644 --- a/test/SILGen/toplevel_globalactorvars.swift +++ b/test/SILGen/toplevel_globalactorvars.swift @@ -130,7 +130,8 @@ if a < 10 { nonisolated(nonsending) func nonisolatedNonSendingFunction() async {} -// CHECK: [[FUNC:%.*]] = function_ref @$s24toplevel_globalactorvars29nonisolatedNonSendingFunctionyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional) -> () -// CHECK: apply [[FUNC]]([[ACTOR]]) +// CHECK: [[ACTOR_CAST:%.*]] = unchecked_value_cast [[ACTOR]] : $Optional to $Builtin.ImplicitActor +// CHECK: [[FUNC:%.*]] = function_ref @$s24toplevel_globalactorvars29nonisolatedNonSendingFunctionyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor) -> () +// CHECK: apply [[FUNC]]([[ACTOR_CAST]]) // CHECK-NEXT: hop_to_executor [[ACTOR]] await nonisolatedNonSendingFunction() diff --git a/test/SILOptimizer/consuming_parameter.swift b/test/SILOptimizer/consuming_parameter.swift index 2fb0bd07d24..bcf000d04bc 100644 --- a/test/SILOptimizer/consuming_parameter.swift +++ b/test/SILOptimizer/consuming_parameter.swift @@ -5,7 +5,7 @@ // CHECK-LABEL: sil [ossa] @async_dead_arg_call : {{.*}} { // CHECK: {{bb[0-9]+}}([[INSTANCE:%[^,]+]] : @noImplicitCopy @_eagerMove @owned // CHECK: destroy_value [[INSTANCE]] -// CHECK: [[EXECUTOR:%[^,]+]] = enum $Optional, #Optional.none!enumelt +// CHECK: [[EXECUTOR:%[^,]+]] = enum $Optional, #Optional.none!enumelt // CHECK: [[CALLEE:%[^,]+]] = function_ref @async_callee // CHECK: apply [[CALLEE]]() // CHECK: hop_to_executor [[EXECUTOR]] @@ -18,7 +18,7 @@ public func async_dead_arg_call(o: consuming AnyObject) async { // CHECK-LABEL: sil [ossa] @async_dead_arg_call_lexical : {{.*}} { // CHECK: {{bb[0-9]+}}([[INSTANCE:%[^,]+]] : @noImplicitCopy @_lexical @owned -// CHECK: [[EXECUTOR:%[^,]+]] = enum $Optional, #Optional.none!enumelt +// CHECK: [[EXECUTOR:%[^,]+]] = enum $Optional, #Optional.none!enumelt // CHECK: [[CALLEE:%[^,]+]] = function_ref @async_callee // CHECK: apply [[CALLEE]]() // CHECK: hop_to_executor [[EXECUTOR]] @@ -47,7 +47,7 @@ public class C { // CHECK-LABEL: sil [ossa] @async_dead_arg_call_method : {{.*}} { // CHECK: {{bb[0-9]+}}([[INSTANCE:%[^,]+]] : @noImplicitCopy @_eagerMove @owned // CHECK: destroy_value [[INSTANCE]] - // CHECK: [[EXECUTOR:%[^,]+]] = enum $Optional, #Optional.none!enumelt + // CHECK: [[EXECUTOR:%[^,]+]] = enum $Optional, #Optional.none!enumelt // CHECK: [[CALLEE:%[^,]+]] = function_ref @async_callee : $@convention(thin) @async () -> () // CHECK: apply [[CALLEE]]() : $@convention(thin) @async () -> () // CHECK: hop_to_executor [[EXECUTOR]] diff --git a/test/SILOptimizer/definite_init_actor.swift b/test/SILOptimizer/definite_init_actor.swift index 33e48e2c07b..2666284c593 100644 --- a/test/SILOptimizer/definite_init_actor.swift +++ b/test/SILOptimizer/definite_init_actor.swift @@ -79,7 +79,7 @@ actor BoringActor { // CHECK: bb0([[SELF:%[0-9]+]] : $SingleVarActor): // TODO: We should be able to eliminate this by reasoning that the stores // are to local memory. - // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none + // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK-NEXT: hop_to_executor [[GENERIC_EXECUTOR]] // CHECK: [[EI:%.*]] = end_init_let_ref [[SELF]] // CHECK: store {{%[0-9]+}} to [[ACCESS:%[0-9]+]] @@ -96,7 +96,7 @@ actor BoringActor { // CHECK: bb0({{%[0-9]+}} : $Int, [[SELF:%[0-9]+]] : $SingleVarActor): // TODO: We should be able to eliminate this by reasoning that the stores // are to local memory. - // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none + // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK-NEXT: hop_to_executor [[GENERIC_EXECUTOR]] // CHECK: [[EI:%.*]] = end_init_let_ref [[SELF]] // CHECK: [[MYVAR_REF:%[0-9]+]] = ref_element_addr [[EI]] : $SingleVarActor, #SingleVarActor.myVar @@ -118,7 +118,7 @@ actor BoringActor { // TODO: We should be able to eliminate this by reasoning that the stores // are to local memory. - // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none + // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK-NEXT: hop_to_executor [[GENERIC_EXECUTOR]] // CHECK: [[EI:%.*]] = end_init_let_ref [[SELF]] @@ -150,7 +150,7 @@ actor BoringActor { // TODO: We should be able to eliminate this by reasoning that the stores // are to local memory. - // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none + // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK: hop_to_executor [[GENERIC_EXECUTOR]] // CHECK: cond_br {{%[0-9]+}}, [[SUCCESS_BB:bb[0-9]+]], {{bb[0-9]+}} @@ -170,7 +170,7 @@ actor BoringActor { // CHECK: [[SELF_ALLOC:%[0-9]+]] = alloc_stack [lexical] [var_decl] $SingleVarActor, let, name "self" // Initial hop to the generic executor. - // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none + // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK-NEXT: hop_to_executor [[GENERIC_EXECUTOR]] // Hop immediately after the call to the synchronous init. @@ -219,7 +219,7 @@ actor DefaultInit { // CHECK: bb0([[SELF:%[0-9]+]] : $DefaultInit): // Initial hop to the generic executor. // TODO: This should be easy to remove. - // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none + // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK-NEXT: hop_to_executor [[GENERIC_EXECUTOR]] // CHECK: [[EI:%.*]] = end_init_let_ref [[SELF]] // CHECK: store {{%[0-9]+}} to {{%[0-9]+}} : $*ActingError @@ -231,7 +231,7 @@ actor DefaultInit { // CHECK: bb0({{%[0-9]+}} : $Bool, [[SELF:%[0-9]+]] : $DefaultInit): // Initial hop to the generic executor. // TODO: This should be fairly easy to remove. - // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none + // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK-NEXT: hop_to_executor [[GENERIC_EXECUTOR]] // CHECK: [[EI:%.*]] = end_init_let_ref [[SELF]] // CHECK: store {{%[0-9]+}} to {{%[0-9]+}} : $*ActingError @@ -253,7 +253,7 @@ actor MultiVarActor { // CHECK: bb0({{%[0-9]+}} : $Bool, [[SELF:%[0-9]+]] : $MultiVarActor): // Initial hop to the generic executor. // TODO: This should be easy to remove. - // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none + // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK-NEXT: hop_to_executor [[GENERIC_EXECUTOR]] // CHECK: [[EI:%.*]] = end_init_let_ref [[SELF]] // CHECK: [[REF:%[0-9]+]] = ref_element_addr [[EI]] : $MultiVarActor, #MultiVarActor.firstVar @@ -271,7 +271,7 @@ actor MultiVarActor { // CHECK-LABEL: sil hidden @$s4test13MultiVarActorC10noSuccCaseACSb_tYacfc : $@convention(method) @async (Bool, @sil_isolated @owned MultiVarActor) -> @owned MultiVarActor { // Initial hop to the generic executor. // TODO: This should be easy to remove. - // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none + // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK-NEXT: hop_to_executor [[GENERIC_EXECUTOR]] // CHECK: store {{%[0-9]+}} to [[A1:%[0-9]+]] : $*Int @@ -293,7 +293,7 @@ actor MultiVarActor { // CHECK-LABEL: sil hidden @$s4test13MultiVarActorC10noPredCaseACSb_tYacfc : $@convention(method) @async (Bool, @sil_isolated @owned MultiVarActor) -> @owned MultiVarActor { // Initial hop to the generic executor. // TODO: This should be easy to remove. - // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none + // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK-NEXT: hop_to_executor [[GENERIC_EXECUTOR]] // CHECK: store {{%[0-9]+}} to [[ACCESS:%[0-9]+]] : $*Int @@ -316,7 +316,7 @@ actor MultiVarActor { // TODO: We should be able to remove this hop by proving that all the // stores before return are local. We don't really care about invalid // code, of course, but it should fall out. - // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none + // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK-NEXT: hop_to_executor [[GENERIC_EXECUTOR]] init?(doesNotFullyInit1: Bool) async { firstVar = 1 @@ -324,7 +324,7 @@ actor MultiVarActor { } // CHECK-LABEL: sil hidden @$s4test13MultiVarActorC17doesNotFullyInit2ACSb_tYacfc - // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none + // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK-NEXT: hop_to_executor [[GENERIC_EXECUTOR]] init(doesNotFullyInit2: Bool) async { firstVar = 1 @@ -332,7 +332,7 @@ actor MultiVarActor { } // CHECK-LABEL: sil hidden @$s4test13MultiVarActorC17doesNotFullyInit3ACSb_tYaKcfc - // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none + // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK-NEXT: hop_to_executor [[GENERIC_EXECUTOR]] init(doesNotFullyInit3: Bool) async throws { firstVar = 1 @@ -340,7 +340,7 @@ actor MultiVarActor { } // CHECK-LABEL: sil hidden @$s4test13MultiVarActorC17doesNotFullyInit4ACSgSb_tYacfc - // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none + // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK-NEXT: hop_to_executor [[GENERIC_EXECUTOR]] init?(doesNotFullyInit4: Bool) async { firstVar = 1 @@ -358,7 +358,7 @@ actor TaskMaster { // CHECK-LABEL: @$s4test10TaskMasterCACyYacfc : $@convention(method) @async (@sil_isolated @owned TaskMaster) -> @owned TaskMaster { // Initial hop to the generic executor. // TODO: This should be easy to remove. - // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none + // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK-NEXT: hop_to_executor [[GENERIC_EXECUTOR]] // CHECK: [[ELM:%[0-9]+]] = ref_element_addr [[SELF:%[0-9]+]] : $TaskMaster, #TaskMaster.task @@ -382,7 +382,7 @@ actor SomeActor { // CHECK-LABEL: sil hidden @$s4test9SomeActorCACyYacfc : $@convention(method) @async (@sil_isolated @owned SomeActor) -> @owned SomeActor { // Initial hop to the generic executor. // TODO: This should be easy to remove. - // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none + // CHECK: [[GENERIC_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK-NEXT: hop_to_executor [[GENERIC_EXECUTOR]] // CHECK-NOT: begin_access @@ -397,7 +397,7 @@ actor Ahmad { // CHECK-LABEL: sil hidden @$s4test5AhmadCACyYacfc : $@convention(method) @async (@owned Ahmad) -> @owned Ahmad { // CHECK: bb0{{.*}}: - // CHECK-NEXT: [[GENERIC:%[0-9]+]] = enum $Optional, #Optional.none!enumelt + // CHECK-NEXT: [[GENERIC:%[0-9]+]] = enum $Optional, #Optional.none!enumelt // CHECK-NEXT: hop_to_executor [[GENERIC]] // CHECK: store {{%[0-9]+}} to {{%[0-9]+}} : $*Int // CHECK: } // end sil function '$s4test5AhmadCACyYacfc' @@ -412,7 +412,7 @@ actor Customer { // CHECK-LABEL: sil hidden @$s4test8CustomerCACyYaKcfc : init() async throws { - // CHECK: [[GENERIC:%[0-9]+]] = enum $Optional, #Optional.none!enumelt + // CHECK: [[GENERIC:%[0-9]+]] = enum $Optional, #Optional.none!enumelt // CHECK-NEXT: hop_to_executor [[GENERIC]] // CHECK: [[SELF:%.*]] = end_init_let_ref %0 : $Customer diff --git a/test/SILOptimizer/definite_init_flow_sensitive_distributed_actor_self.swift b/test/SILOptimizer/definite_init_flow_sensitive_distributed_actor_self.swift index 7aa74dc6a12..d5085743272 100644 --- a/test/SILOptimizer/definite_init_flow_sensitive_distributed_actor_self.swift +++ b/test/SILOptimizer/definite_init_flow_sensitive_distributed_actor_self.swift @@ -13,6 +13,9 @@ distributed actor NotCodableDA // CHECK-LABEL: sil hidden{{.*}}@$s4test12NotCodableDAC11actorSystemACyxGx_tYacfc : $@convention(method) @async (@in ActorSystem, @sil_isolated @owned NotCodableDA) -> @owned NotCodableDA { init(actorSystem: ActorSystem) async { + // CHECK: [[ISOLATION:%.*]] = enum $Optional, #Optional.none!enumelt + // CHECK: hop_to_executor [[ISOLATION]] + self.actorSystem = actorSystem // First use of #isolation, which is replaced by 'nil'. diff --git a/test/Serialization/caller_isolation_inherit.swift b/test/Serialization/caller_isolation_inherit.swift index 632d746f549..4c8a60c192b 100644 --- a/test/Serialization/caller_isolation_inherit.swift +++ b/test/Serialization/caller_isolation_inherit.swift @@ -19,7 +19,7 @@ actor A { // CHECK-LABEL: // unspecifiedAsync(_:) // CHECK-NEXT: // Isolation: caller_isolation_inheriting - // CHECK-NEXT: sil @$s11WithFeature16unspecifiedAsyncyyxYalF : $@convention(thin) @async <τ_0_0> (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed τ_0_0) -> () + // CHECK-NEXT: sil @$s11WithFeature16unspecifiedAsyncyyxYalF : $@convention(thin) @async <τ_0_0> (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed τ_0_0) -> () func test1() async { // If unspecifiedAsync does not inherit the isolation of A, then we will get // an error. @@ -37,7 +37,7 @@ actor A { // CHECK-LABEL: // unspecifiedAsyncCaller(_:) // CHECK: // Isolation: caller_isolation_inheriting - // CHECK: sil @$s11WithFeature22unspecifiedAsyncCalleryyxYalF : $@convention(thin) @async <τ_0_0> (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed τ_0_0) -> () + // CHECK: sil @$s11WithFeature22unspecifiedAsyncCalleryyxYalF : $@convention(thin) @async <τ_0_0> (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed τ_0_0) -> () func test1b() async { await WithFeature.unspecifiedAsyncCaller(ns) } @@ -64,14 +64,14 @@ actor A { // CHECK-LABEL: // unspecifiedAsyncCaller(_:) // CHECK: // Isolation: caller_isolation_inheriting - // CHECK: sil @$s14WithoutFeature22unspecifiedAsyncCalleryyxYalF : $@convention(thin) @async <τ_0_0> (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed τ_0_0) -> () + // CHECK: sil @$s14WithoutFeature22unspecifiedAsyncCalleryyxYalF : $@convention(thin) @async <τ_0_0> (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed τ_0_0) -> () func test2b() async { await WithoutFeature.unspecifiedAsyncCaller(ns) } // CHECK-LABEL: // nonisolatedAsync(_:) // CHECK: // Isolation: caller_isolation_inheriting - // CHECK: sil @$s11WithFeature16nonisolatedAsyncyyxYalF : $@convention(thin) @async <τ_0_0> (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed τ_0_0) -> () + // CHECK: sil @$s11WithFeature16nonisolatedAsyncyyxYalF : $@convention(thin) @async <τ_0_0> (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed τ_0_0) -> () func test3() async { await WithFeature.nonisolatedAsync(ns) } @@ -87,7 +87,7 @@ actor A { // CHECK-LABEL: // nonisolatedAsyncCaller(_:) // CHECK: // Isolation: caller_isolation_inheriting - // CHECK: sil @$s11WithFeature22nonisolatedAsyncCalleryyxYalF : $@convention(thin) @async <τ_0_0> (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed τ_0_0) -> () + // CHECK: sil @$s11WithFeature22nonisolatedAsyncCalleryyxYalF : $@convention(thin) @async <τ_0_0> (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed τ_0_0) -> () func test3b() async { await WithFeature.nonisolatedAsyncCaller(ns) } @@ -112,14 +112,14 @@ actor A { // CHECK-LABEL: // nonisolatedAsyncCaller(_:) // CHECK: // Isolation: caller_isolation_inheriting - // CHECK: sil @$s14WithoutFeature22nonisolatedAsyncCalleryyxYalF : $@convention(thin) @async <τ_0_0> (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed τ_0_0) -> () + // CHECK: sil @$s14WithoutFeature22nonisolatedAsyncCalleryyxYalF : $@convention(thin) @async <τ_0_0> (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed τ_0_0) -> () func test4b() async { await WithoutFeature.nonisolatedAsyncCaller(ns) } // CHECK-LABEL: // S.unspecifiedAsync(_:) // CHECK: // Isolation: caller_isolation_inheriting - // CHECK: sil @$s11WithFeature1SV16unspecifiedAsyncyyxYalF : $@convention(method) @async <τ_0_0> (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed τ_0_0, S) -> () + // CHECK: sil @$s11WithFeature1SV16unspecifiedAsyncyyxYalF : $@convention(method) @async <τ_0_0> (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed τ_0_0, S) -> () func test5() async { let s = WithFeature.S() await s.unspecifiedAsync(ns) @@ -137,7 +137,7 @@ actor A { // CHECK-LABEL: // S.unspecifiedAsyncCaller(_:) // CHECK: // Isolation: caller_isolation_inheriting - // CHECK: sil @$s11WithFeature1SV22unspecifiedAsyncCalleryyxYalF : $@convention(method) @async <τ_0_0> (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed τ_0_0, S) -> () + // CHECK: sil @$s11WithFeature1SV22unspecifiedAsyncCalleryyxYalF : $@convention(method) @async <τ_0_0> (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed τ_0_0, S) -> () func test5b() async { let s = WithFeature.S() await s.unspecifiedAsyncCaller(ns) @@ -145,7 +145,7 @@ actor A { // CHECK-LABEL: // S.nonisolatedAsync(_:) // CHECK: // Isolation: caller_isolation_inheriting - // CHECK: sil @$s11WithFeature1SV16nonisolatedAsyncyyxYalF : $@convention(method) @async <τ_0_0> (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed τ_0_0, S) -> () + // CHECK: sil @$s11WithFeature1SV16nonisolatedAsyncyyxYalF : $@convention(method) @async <τ_0_0> (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed τ_0_0, S) -> () func test6() async { let s = WithFeature.S() await s.nonisolatedAsync(ns) @@ -163,7 +163,7 @@ actor A { // CHECK-LABEL: // S.nonisolatedAsyncCaller(_:) // CHECK: // Isolation: caller_isolation_inheriting - // CHECK: sil @$s11WithFeature1SV22nonisolatedAsyncCalleryyxYalF : $@convention(method) @async <τ_0_0> (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed τ_0_0, S) -> () + // CHECK: sil @$s11WithFeature1SV22nonisolatedAsyncCalleryyxYalF : $@convention(method) @async <τ_0_0> (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed τ_0_0, S) -> () func test6b() async { let s = WithFeature.S() await s.nonisolatedAsyncCaller(ns) @@ -191,7 +191,7 @@ actor A { // CHECK-LABEL: // S.unspecifiedAsyncCaller(_:) // CHECK: // Isolation: caller_isolation_inheriting - // CHECK: sil @$s14WithoutFeature1SV22unspecifiedAsyncCalleryyxYalF : $@convention(method) @async <τ_0_0> (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed τ_0_0, S) -> () + // CHECK: sil @$s14WithoutFeature1SV22unspecifiedAsyncCalleryyxYalF : $@convention(method) @async <τ_0_0> (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed τ_0_0, S) -> () func test7b() async { let s = WithoutFeature.S() await s.unspecifiedAsyncCaller(ns) @@ -219,7 +219,7 @@ actor A { // CHECK-LABEL: // S.nonisolatedAsyncCaller(_:) // CHECK: // Isolation: caller_isolation_inheriting - // CHECK: sil @$s14WithoutFeature1SV22nonisolatedAsyncCalleryyxYalF : $@convention(method) @async <τ_0_0> (@sil_isolated @sil_implicit_leading_param @guaranteed Optional, @in_guaranteed τ_0_0, S) -> () + // CHECK: sil @$s14WithoutFeature1SV22nonisolatedAsyncCalleryyxYalF : $@convention(method) @async <τ_0_0> (@sil_isolated @sil_implicit_leading_param @guaranteed Builtin.ImplicitActor, @in_guaranteed τ_0_0, S) -> () func test8b() async { let s = WithoutFeature.S() await s.nonisolatedAsyncCaller(ns) diff --git a/test/embedded/concurrency-builtins.swift b/test/embedded/concurrency-builtins.swift index c133d2342b7..c8480295ebe 100644 --- a/test/embedded/concurrency-builtins.swift +++ b/test/embedded/concurrency-builtins.swift @@ -6,6 +6,7 @@ // REQUIRES: swift_feature_Embedded import Builtin +import _Concurrency public func test() async { _ = Builtin.createAsyncTask(0) { () async throws -> Int in