diff --git a/lib/SIL/IR/Linker.cpp b/lib/SIL/IR/Linker.cpp index 415c4b8ba1ed..299d6829a38c 100644 --- a/lib/SIL/IR/Linker.cpp +++ b/lib/SIL/IR/Linker.cpp @@ -113,7 +113,7 @@ void SILLinkerVisitor::maybeAddFunctionToWorklist( if (callerSerializedKind == IsSerialized && hasSharedVisibility(linkage) && !Mod.isSerialized() && - !F->isSerialized()) { + !F->isAnySerialized()) { F->setSerializedKind(IsSerialized); // Push the function to the worklist so that all referenced shared functions diff --git a/lib/SIL/IR/SILWitnessTable.cpp b/lib/SIL/IR/SILWitnessTable.cpp index e9bb35b940e1..af1b4c4bcb1a 100644 --- a/lib/SIL/IR/SILWitnessTable.cpp +++ b/lib/SIL/IR/SILWitnessTable.cpp @@ -108,7 +108,7 @@ SILWitnessTable::SILWitnessTable( ArrayRef conditionalConformances) : Mod(M), Name(N), Linkage(Linkage), Conformance(Conformance), Entries(), ConditionalConformances(), IsDeclaration(true), - SerializedKind(IsNotSerialized) { + SerializedKind(SerializedKind) { convertToDefinition(entries, conditionalConformances, SerializedKind); } @@ -169,21 +169,15 @@ void SILWitnessTable::convertToDefinition( SerializedKind_t SILWitnessTable::conformanceSerializedKind( const RootProtocolConformance *conformance) { - // Allow serializing conformance with package or public access level - // if package serialization is enabled. - auto optInPackage = conformance->getDeclContext()->getParentModule()->serializePackageEnabled(); - auto accessLevelToCheck = - optInPackage ? AccessLevel::Package : AccessLevel::Public; - auto normalConformance = dyn_cast(conformance); - if (normalConformance && normalConformance->isResilient() && !optInPackage) + if (normalConformance && normalConformance->isResilient()) return IsNotSerialized; - if (conformance->getProtocol()->getEffectiveAccess() < accessLevelToCheck) + if (conformance->getProtocol()->getEffectiveAccess() < AccessLevel::Public) return IsNotSerialized; auto *nominal = conformance->getDeclContext()->getSelfNominalTypeDecl(); - if (nominal->getEffectiveAccess() >= accessLevelToCheck) + if (nominal->getEffectiveAccess() >= AccessLevel::Public) return IsSerialized; return IsNotSerialized; diff --git a/lib/SILOptimizer/IPO/CrossModuleOptimization.cpp b/lib/SILOptimizer/IPO/CrossModuleOptimization.cpp index 813e1463e2f5..6582a20ad276 100644 --- a/lib/SILOptimizer/IPO/CrossModuleOptimization.cpp +++ b/lib/SILOptimizer/IPO/CrossModuleOptimization.cpp @@ -73,11 +73,21 @@ class CrossModuleOptimization { CrossModuleOptimization(SILModule &M, bool conservative, bool everything) : M(M), conservative(conservative), everything(everything) { } - void trySerializeFunctions(ArrayRef functions); void serializeFunctionsInModule(SILPassManager *manager); - void serializeTablesInModule(); + void serializeWitnessTablesInModule(); + void serializeVTablesInModule(); private: + bool isReferenceSerializeCandidate(SILFunction *F, SILOptions options); + bool isReferenceSerializeCandidate(SILGlobalVariable *G, SILOptions options); + SerializedKind_t getRightSerializedKind(const SILModule &mod); + bool isSerializedWithRightKind(const SILModule &mod, SILFunction *f); + bool isSerializedWithRightKind(const SILModule &mod, SILGlobalVariable *g); + bool isPackageOrPublic(SILLinkage linkage); + bool isPackageOrPublic(AccessLevel accessLevel); + + void trySerializeFunctions(ArrayRef functions); + bool canSerializeFunction(SILFunction *function, FunctionFlags &canSerializeFlags, int maxDepth); @@ -177,22 +187,22 @@ class InstructionVisitor : public SILCloner { } }; -static bool isPackageOrPublic(SILLinkage linkage, SILOptions options) { - if (options.EnableSerializePackage) +static bool isPackageCMOEnabled(ModuleDecl *mod) { + return mod->isResilient() && mod->serializePackageEnabled(); +} + +bool CrossModuleOptimization::isPackageOrPublic(SILLinkage linkage) { + if (isPackageCMOEnabled(M.getSwiftModule())) return linkage == SILLinkage::Public || linkage == SILLinkage::Package; return linkage == SILLinkage::Public; } -static bool isPackageOrPublic(AccessLevel accessLevel, SILOptions options) { - if (options.EnableSerializePackage) +bool CrossModuleOptimization::isPackageOrPublic(AccessLevel accessLevel) { + if (isPackageCMOEnabled(M.getSwiftModule())) return accessLevel == AccessLevel::Package || accessLevel == AccessLevel::Public; return accessLevel == AccessLevel::Public; } -static bool isPackageCMOEnabled(ModuleDecl *mod) { - return mod->isResilient() && mod->serializePackageEnabled(); -} - /// Checks wither this function is [serialized_for_package] due to Package CMO /// or [serialized] with non-package CMO. The [serialized_for_package] attribute /// is used to indicate that a function is serialized because of Package CMO, which @@ -203,41 +213,51 @@ static bool isPackageCMOEnabled(ModuleDecl *mod) { /// function due to `@inlinable`, funtions with [serialized_for_package] from /// the imported module are not allowed being inlined into the client function, which /// is the correct behavior. -static bool isSerializedWithRightKind(const SILModule &mod, +bool CrossModuleOptimization::isSerializedWithRightKind(const SILModule &mod, SILFunction *f) { // If Package CMO is enabled in resilient mode, return // true if the function is [serialized] due to @inlinable - // (or similar) or [serialized_for_pkg] due to this + // (or similar) or [serialized_for_package] due to this // optimization. return isPackageCMOEnabled(mod.getSwiftModule()) ? f->isAnySerialized() : f->isSerialized(); } -static bool isSerializedWithRightKind(const SILModule &mod, +bool CrossModuleOptimization::isSerializedWithRightKind(const SILModule &mod, SILGlobalVariable *g) { return isPackageCMOEnabled(mod.getSwiftModule()) ? g->isAnySerialized() : g->isSerialized(); } -static SerializedKind_t getRightSerializedKind(const SILModule &mod) { +SerializedKind_t CrossModuleOptimization::getRightSerializedKind(const SILModule &mod) { return isPackageCMOEnabled(mod.getSwiftModule()) ? IsSerializedForPackage : IsSerialized; } static bool isSerializeCandidate(SILFunction *F, SILOptions options) { auto linkage = F->getLinkage(); - // We allow serializing a shared definition. For example, - // `public func foo() { print("") }` is a function with a - // public linkage which only references `print`; the definition - // of `print` has a shared linkage and does not reference - // non-serializable instructions, so it should be serialized, - // thus the public `foo` could be serialized. - if (options.EnableSerializePackage) - return linkage == SILLinkage::Public || linkage == SILLinkage::Package || - (linkage == SILLinkage::Shared && F->isDefinition()); + // If Package CMO is enabled, besides package/public definitions, + // we allow serializing private, hidden, or shared definitions + // that do not contain private or hidden symbol references (and + // their nested references). If private or internal definitions are + // serialized, they are set to a shared linkage. + // + // E.g. `public func foo() { print("") }` is a public function that + // references `print`, a shared definition which does not contain + // any private or internal symbols, thus is serialized, which in turn + // allows `foo` to be serialized. + // E.g. a protocol witness method for a package protocol member is + // set to a private linkage in SILGen. By allowing such private thunk + // to be serialized and set to shared linkage here, functions that + // reference the thunk can be serialized as well. + if (isPackageCMOEnabled(F->getModule().getSwiftModule())) + return linkage != SILLinkage::PublicExternal && + linkage != SILLinkage::PackageExternal && + linkage != SILLinkage::HiddenExternal; return linkage == SILLinkage::Public; } -static bool isReferenceSerializeCandidate(SILFunction *F, SILOptions options) { - if (options.EnableSerializePackage) { +bool CrossModuleOptimization::isReferenceSerializeCandidate(SILFunction *F, + SILOptions options) { + if (isPackageCMOEnabled(F->getModule().getSwiftModule())) { if (isSerializedWithRightKind(F->getModule(), F)) return true; return hasPublicOrPackageVisibility(F->getLinkage(), @@ -246,9 +266,9 @@ static bool isReferenceSerializeCandidate(SILFunction *F, SILOptions options) { return hasPublicVisibility(F->getLinkage()); } -static bool isReferenceSerializeCandidate(SILGlobalVariable *G, - SILOptions options) { - if (options.EnableSerializePackage) { +bool CrossModuleOptimization::isReferenceSerializeCandidate(SILGlobalVariable *G, + SILOptions options) { + if (isPackageCMOEnabled(G->getModule().getSwiftModule())) { if (isSerializedWithRightKind(G->getModule(), G)) return true; return hasPublicOrPackageVisibility(G->getLinkage(), @@ -279,85 +299,73 @@ void CrossModuleOptimization::serializeFunctionsInModule(SILPassManager *manager trySerializeFunctions(bottomUpFunctions); } -void CrossModuleOptimization::serializeTablesInModule() { - if (!M.getSwiftModule()->serializePackageEnabled()) +void CrossModuleOptimization::serializeWitnessTablesInModule() { + if (!isPackageCMOEnabled(M.getSwiftModule())) return; - for (const auto &vt : M.getVTables()) { - if (vt->getSerializedKind() != getRightSerializedKind(M) && - vt->getClass()->getEffectiveAccess() >= AccessLevel::Package) { - // This checks if a vtable entry is not serialized and attempts to - // serialize (and its references) if they have the right visibility. - // This should not be necessary but is added to ensure all applicable - // symbols are serialized. Whether serialized or not is cached so - // this check shouldn't be expensive. - auto unserializedClassMethodRange = llvm::make_filter_range( - vt->getEntries(), [&](const SILVTableEntry &entry) { - return entry.getImplementation()->getSerializedKind() != - getRightSerializedKind(M); - }); - std::vector classMethodsToSerialize; - llvm::transform(unserializedClassMethodRange, - std::back_inserter(classMethodsToSerialize), - [&](const SILVTableEntry &entry) { - return entry.getImplementation(); - }); - trySerializeFunctions(classMethodsToSerialize); - - bool containsInternal = - llvm::any_of(vt->getEntries(), [&](const SILVTableEntry &entry) { - // If the entry is internal, vtable should not be serialized. - // However, if the entry is not serialized but has the right - // visibility, it can still be referenced, thus the vtable - // should serialized. - return !entry.getImplementation()->hasValidLinkageForFragileRef( - getRightSerializedKind(M)); - }); - if (!containsInternal) - vt->setSerializedKind(getRightSerializedKind(M)); - } - } - - // Witness thunks are not serialized, so serialize them here. for (auto &wt : M.getWitnessTables()) { if (wt.getSerializedKind() != getRightSerializedKind(M) && hasPublicOrPackageVisibility(wt.getLinkage(), /*includePackage*/ true)) { - // This checks if a wtable entry is not serialized and attempts to - // serialize (and its references) if they have the right visibility. - // This should not be necessary but is added to ensure all applicable - // symbols are serialized. Whether serialized or not is cached so - // this check shouldn't be expensive. auto unserializedWTMethodRange = llvm::make_filter_range( wt.getEntries(), [&](const SILWitnessTable::Entry &entry) { return entry.getKind() == SILWitnessTable::Method && entry.getMethodWitness().Witness->getSerializedKind() != getRightSerializedKind(M); }); - std::vector wtMethodsToSerialize; - llvm::transform(unserializedWTMethodRange, - std::back_inserter(wtMethodsToSerialize), - [&](const SILWitnessTable::Entry &entry) { - return entry.getMethodWitness().Witness; - }); - trySerializeFunctions(wtMethodsToSerialize); + // In Package CMO, we try serializing witness thunks that + // are private if they don't contain hidden or private + // references. If they are serialized, they are set to + // a shared linkage. If they can't be serialized, we set + // the linkage to package so that the witness table itself + // can still be serialized, thus giving a chance for entires + // that _are_ serialized to be accessed directly. + for (const SILWitnessTable::Entry &entry: unserializedWTMethodRange) { + if (entry.getMethodWitness().Witness->getLinkage() == SILLinkage::Private) + entry.getMethodWitness().Witness->setLinkage(SILLinkage::Package); + } bool containsInternal = llvm::any_of( wt.getEntries(), [&](const SILWitnessTable::Entry &entry) { - // If the entry is internal, wtable should not be serialized. - // However, if the entry is not serialized but has the right - // visibility, it can still be referenced, thus the vtable - // should serialized. return entry.getKind() == SILWitnessTable::Method && !entry.getMethodWitness() .Witness->hasValidLinkageForFragileRef( getRightSerializedKind(M)); }); + // FIXME: This check shouldn't be necessary but added as a caution + // to ensure we don't serialize witness table if it contains an + // internal entry. if (!containsInternal) wt.setSerializedKind(getRightSerializedKind(M)); } } } +void CrossModuleOptimization::serializeVTablesInModule() { + if (!isPackageCMOEnabled(M.getSwiftModule())) + return; + + for (const auto &vt : M.getVTables()) { + if (vt->getSerializedKind() != getRightSerializedKind(M) && + vt->getClass()->getEffectiveAccess() >= AccessLevel::Package) { + bool containsInternal = + llvm::any_of(vt->getEntries(), [&](const SILVTableEntry &entry) { + return !entry.getImplementation()->hasValidLinkageForFragileRef( + getRightSerializedKind(M)); + }); + + // If the entries are either serialized or have package/public + // visibility, the vtable can be serialized; the non-serialized + // entries can still be referenced as they have the visibility + // outside of their defining module, and the serialized entries + // can be directly accessed since the vtable is serialized. + // However, if it contains a private/internal entry, we don't + // serialize the vtable at all. + if (!containsInternal) + vt->setSerializedKind(getRightSerializedKind(M)); + } + } +} + /// Recursively walk the call graph and select functions to be serialized. /// /// The results are stored in \p canSerializeFlags and the result for \p @@ -538,7 +546,6 @@ bool CrossModuleOptimization::canSerializeGlobal(SILGlobalVariable *global) { for (const SILInstruction &initInst : *global) { if (auto *FRI = dyn_cast(&initInst)) { SILFunction *referencedFunc = FRI->getReferencedFunction(); - // In conservative mode we don't want to turn non-public functions into // public functions, because that can increase code size. E.g. if the // function is completely inlined afterwards. @@ -701,6 +708,16 @@ void CrossModuleOptimization::serializeFunction(SILFunction *function, if (!canSerializeFlags.lookup(function)) return; + if (isPackageCMOEnabled(M.getSwiftModule())) { + // If a private thunk (such as a protocol witness method for + // a package protocol member) does not reference any private + // or internal symbols, thus is serialized, it's set to shared + // linkage, so that functions that reference the thunk can be + // serialized as well. + if (function->getLinkage() == SILLinkage::Private || + function->getLinkage() == SILLinkage::Hidden) + function->setLinkage(SILLinkage::Shared); + } function->setSerializedKind(getRightSerializedKind(M)); for (SILBasicBlock &block : *function) { @@ -747,7 +764,7 @@ void CrossModuleOptimization::serializeInstruction(SILInstruction *inst, } serializeFunction(callee, canSerializeFlags); assert(isSerializedWithRightKind(M, callee) || - isPackageOrPublic(callee->getLinkage(), M.getOptions())); + isPackageOrPublic(callee->getLinkage())); return; } @@ -802,7 +819,7 @@ void CrossModuleOptimization::keepMethodAlive(SILDeclRef method) { void CrossModuleOptimization::makeFunctionUsableFromInline(SILFunction *function) { assert(canUseFromInline(function)); if (!isAvailableExternally(function->getLinkage()) && - !isPackageOrPublic(function->getLinkage(), M.getOptions())) { + !isPackageOrPublic(function->getLinkage())) { function->setLinkage(SILLinkage::Public); } } @@ -816,7 +833,7 @@ void CrossModuleOptimization::makeDeclUsableFromInline(ValueDecl *decl) { if (M.getSwiftModule() != decl->getDeclContext()->getParentModule()) return; - if (!isPackageOrPublic(decl->getFormalAccess(), M.getOptions()) && + if (!isPackageOrPublic(decl->getFormalAccess()) && !decl->isUsableFromInline()) { // Mark the nominal type as "usableFromInline". // TODO: find a way to do this without modifying the AST. The AST should be @@ -900,7 +917,6 @@ void CrossModuleOptimization::makeSubstUsableFromInline( class CrossModuleOptimizationPass: public SILModuleTransform { void run() override { - auto &M = *getModule(); if (M.getSwiftModule()->isResilient() && !M.getSwiftModule()->serializePackageEnabled()) @@ -933,7 +949,8 @@ class CrossModuleOptimizationPass: public SILModuleTransform { CMO.serializeFunctionsInModule(PM); // Serialize SIL v-tables and witness-tables if package-cmo is enabled. - CMO.serializeTablesInModule(); + CMO.serializeVTablesInModule(); + CMO.serializeWitnessTablesInModule(); } }; diff --git a/test/SILOptimizer/package-cmo-inlinable.swift b/test/SILOptimizer/package-cmo-inlinable-ufi.swift similarity index 100% rename from test/SILOptimizer/package-cmo-inlinable.swift rename to test/SILOptimizer/package-cmo-inlinable-ufi.swift diff --git a/test/SILOptimizer/package-cmo-non-resilient-mode.swift b/test/SILOptimizer/package-cmo-non-resilient-mode.swift index 7e5e9b5f1067..d55cc354ef9b 100644 --- a/test/SILOptimizer/package-cmo-non-resilient-mode.swift +++ b/test/SILOptimizer/package-cmo-non-resilient-mode.swift @@ -11,22 +11,34 @@ import Module import ModuleTBD +// static ModuleStruct.privateFunctionPointer // CHECK-LABEL: sil_global public_external @$s6Module0A6StructV22privateFunctionPointeryS2icvpZ : $@callee_guaranteed (Int) -> Int{{$}} + +// static ModuleStruct.publicFunctionPointer +// CHECK-LABEL: sil_global public_external [serialized] @$s6Module0A6StructV21publicFunctionPointeryS2icvpZ : $@callee_guaranteed (Int) -> Int + + +// CHECK-LABEL: sil @$s4Main26callPrivateFunctionPointeryS2iF : $@convention(thin) (Int) -> Int { +// CHECK: global_addr @$s6Module0A6StructV22privateFunctionPointeryS2icvpZ +// CHECK: load +// CHECK: apply public func callPrivateFunctionPointer(_ x: Int) -> Int { return Module.ModuleStruct.privateFunctionPointer(x) } -// CHECK-LABEL: sil_global package_external @$s6Module03PkgA6StructV14closurePointeryS2icvpZ : $@callee_guaranteed (Int) -> Int{{$}} +// CHECK-LABEL: sil package @$s4Main27callStaticPkgClosurePointeryS2iF : $@convention(thin) (Int) -> Int { +// CHECK: function_ref @$s6Module03PkgA6StructV14closurePointeryS2icvau +// CHECK: apply +// CHECK: pointer_to_address +// CHECK: load +// CHECK: apply + +// PkgModuleStruct.closurePointer.unsafeMutableAddressor +// CHECK: sil package_external [global_init] @$s6Module03PkgA6StructV14closurePointeryS2icvau : $@convention(thin) () -> Builtin.RawPointer package func callStaticPkgClosurePointer(_ x: Int) -> Int { return Module.PkgModuleStruct.closurePointer(x) } -// static ModuleStruct.publicFunctionPointer -// CHECK-LABEL: sil_global public_external [serialized] @$s6Module0A6StructV21publicFunctionPointeryS2icvpZ : $@callee_guaranteed (Int) -> Int -// static PkgModuleStruct.funcPointer -// CHECK-LABEL: sil_global package_external [serialized] @$s6Module03PkgA6StructV11funcPointeryS2icvpZ : $@callee_guaranteed (Int) -> Int - - // CHECK-LABEL: sil @$s4Main25callPublicFunctionPointeryS2iF : $@convention(thin) (Int) -> Int { // CHECK: global_addr @$s6Module0A6StructV21publicFunctionPointeryS2icvpZ : $*@callee_guaranteed (Int) -> Int // CHECK: load @@ -37,10 +49,14 @@ public func callPublicFunctionPointer(_ x: Int) -> Int { } // CHECK-LABEL: sil package @$s4Main28callStaticPkgFunctionPointeryS2iF : $@convention(thin) (Int) -> Int { -// CHECK: global_addr @$s6Module03PkgA6StructV11funcPointeryS2icvpZ : $*@callee_guaranteed (Int) -> Int +// CHECK: function_ref @$s6Module03PkgA6StructV11funcPointeryS2icvau +// CHECK: pointer_to_address // CHECK: load // CHECK: apply // CHECK: } // end sil function '$s4Main28callStaticPkgFunctionPointeryS2iF' + +// PkgModuleStruct.funcPointer.unsafeMutableAddressor +// CHECK-LABEL: sil package_external [global_init] @$s6Module03PkgA6StructV11funcPointeryS2icvau : $@convention(thin) () -> Builtin.RawPointer package func callStaticPkgFunctionPointer(_ x: Int) -> Int { return Module.PkgModuleStruct.funcPointer(x) } @@ -68,9 +84,12 @@ public func doIncrement(_ x: Int) -> Int { } // CHECK-LABEL: sil package @$s4Main11callPkgFuncyS2iF : $@convention(thin) (Int) -> Int { -// CHECK-NOT: function_ref -// CHECK-NOT: apply +// CHECK: function_ref @$s6Module7pkgFuncyS2iF +// CHECK: apply // CHECK: } // end sil function '$s4Main11callPkgFuncyS2iF' + +// pkgFunc(_:) +// CHECK-LABEL: sil package_external @$s6Module7pkgFuncyS2iF : $@convention(thin) (Int) -> Int package func callPkgFunc(_ x: Int) -> Int { return Module.pkgFunc(x) } @@ -83,8 +102,10 @@ public func doIncrementWithCall(_ x: Int) -> Int { } // CHECK-LABEL: sil package @$s4Main16callPkgFuncNoCMOyS2iF : $@convention(thin) (Int) -> Int { -// CHECK: function_ref @$s9Submodule15subPkgFuncNoCMOyS2iF +// CHECK: function_ref @$s6Module12pkgFuncNoCMOyS2iF // CHECK: } // end sil function '$s4Main16callPkgFuncNoCMOyS2iF' +// pkgFuncNoCMO(_:) +// CHECK-LABEL: sil package_external @$s6Module12pkgFuncNoCMOyS2iF : $@convention(thin) (Int) -> Int package func callPkgFuncNoCMO(_ x: Int) -> Int { return Module.pkgFuncNoCMO(x) } @@ -98,9 +119,11 @@ public func doIncrementTBD(_ x: Int) -> Int { } // CHECK-LABEL: sil package @$s4Main14callPkgFuncTBDyS2iF : $@convention(thin) (Int) -> Int { -// CHECK-NOT: function_ref -// CHECK-NOT: apply +// CHECK: function_ref @$s9ModuleTBD7pkgFuncyS2iF +// CHECK: apply // CHECK: } // end sil function '$s4Main14callPkgFuncTBDyS2iF' +// pkgFunc(_:) +// CHECK-LABEL: sil package_external @$s9ModuleTBD7pkgFuncyS2iF : $@convention(thin) (Int) -> Int package func callPkgFuncTBD(_ x: Int) -> Int { return ModuleTBD.pkgFunc(x) } @@ -130,9 +153,11 @@ public func getSubmoduleKlassMember() -> Int { } // CHECK-LABEL: sil package @$s4Main26getPkgSubmoduleKlassMemberSiyF : $@convention(thin) () -> Int { -// CHECK-NOT: function_ref -// CHECK-NOT: apply +// CHECK: function_ref @$s6Module23pkgSubmoduleKlassMemberSiyF +// CHECK: apply // CHECK: } // end sil function '$s4Main26getPkgSubmoduleKlassMemberSiyF' +// pkgSubmoduleKlassMember() +// CHECK-LABEL: sil package_external @$s6Module23pkgSubmoduleKlassMemberSiyF : $@convention(thin) () -> Int package func getPkgSubmoduleKlassMember() -> Int { return Module.pkgSubmoduleKlassMember() } @@ -146,9 +171,12 @@ public func getSubmoduleKlassMemberTBD() -> Int { } // CHECK-LABEL: sil package @$s4Main29getPkgSubmoduleKlassMemberTBDSiyF : $@convention(thin) () -> Int { -// CHECK-NOT: function_ref -// CHECK-NOT: apply +// CHECK: function_ref @$s9ModuleTBD23pkgSubmoduleKlassMemberSiyF +// CHECK: apply // CHECK: } // end sil function '$s4Main29getPkgSubmoduleKlassMemberTBDSiyF' + +// pkgSubmoduleKlassMember() +// CHECK-LABEL:sil package_external @$s9ModuleTBD23pkgSubmoduleKlassMemberSiyF : $@convention(thin) () -> Int package func getPkgSubmoduleKlassMemberTBD() -> Int { return ModuleTBD.pkgSubmoduleKlassMember() } @@ -162,9 +190,11 @@ public func getModuleKlassMember() -> Int { } // CHECK-LABEL: sil package @$s4Main23getPkgModuleKlassMemberSiyF : $@convention(thin) () -> Int { -// CHECK-NOT: function_ref -// CHECK-NOT: apply +// CHECK: function_ref @$s6Module03pkgA11KlassMemberSiyF +// CHECK: apply // CHECK: } // end sil function '$s4Main23getPkgModuleKlassMemberSiyF' +// pkgModuleKlassMember() +// CHECK-LABEL: sil package_external @$s6Module03pkgA11KlassMemberSiyF : $@convention(thin) () -> Int package func getPkgModuleKlassMember() -> Int { return Module.pkgModuleKlassMember() } @@ -178,14 +208,14 @@ public func getModuleKlassMemberTBD() -> Int { } // CHECK-LABEL: sil package @$s4Main26getPkgModuleKlassMemberTBDSiyF : $@convention(thin) () -> Int { -// CHECK-NOT: function_ref -// CHECK-NOT: apply +// CHECK: function_ref @$s9ModuleTBD03pkgA11KlassMemberSiyF +// CHECK: apply // CHECK: } // end sil function '$s4Main26getPkgModuleKlassMemberTBDSiyF' +// pkgModuleKlassMember() +// CHECK-LABEL: sil package_external @$s9ModuleTBD03pkgA11KlassMemberSiyF : $@convention(thin) () -> Int package func getPkgModuleKlassMemberTBD() -> Int { return ModuleTBD.pkgModuleKlassMember() } // CHECK-LABEL: sil [_semantics "optimize.no.crossmodule"] @$s9Submodule19incrementByOneNoCMOyS2iF : $@convention(thin) (Int) -> Int - -// CHECK-LABEL: sil package_external [_semantics "optimize.no.crossmodule"] @$s9Submodule15subPkgFuncNoCMOyS2iF : $@convention(thin) (Int) -> Int diff --git a/test/SILOptimizer/package-cmo-resilient-mode.swift b/test/SILOptimizer/package-cmo-resilient-mode.swift index 20277eda4df8..92c54854a5e9 100644 --- a/test/SILOptimizer/package-cmo-resilient-mode.swift +++ b/test/SILOptimizer/package-cmo-resilient-mode.swift @@ -57,11 +57,22 @@ import Lib // CHECK-MAIN-COMMON: [[FRPUB_GET:%.*]] = load [[FRPUB_ELEM_ADDR]] : $*Int // CHECK-MAIN-COMMON: store [[FRPUB_GET]] to {{.*}} : $*Int -// CHECK-MAIN-COMMON: [[PKG_INIT:%.*]] = struct $PkgStruct -// CHECK-MAIN-COMMON: store [[PKG_INIT]] to {{.*}} : $*PkgStruct -// CHECK-MAIN-COMMON: [[PKG_ELEM_ADDR:%.*]] = struct_element_addr {{.*}} : $*PkgStruct, #PkgStruct.fooVar -// CHECK-MAIN-COMMON: [[PKG_GET:%.*]] = load [[PKG_ELEM_ADDR]] : $*Int -// CHECK-MAIN-COMMON: store [[PKG_GET]] to {{.*}} : $*Int +// CHECK-MAIN-RES: [[PKG_INIT:%.*]] = struct $PkgStruct +// CHECK-MAIN-RES: store [[PKG_INIT]] to {{.*}} : $*PkgStruct +// CHECK-MAIN-RES: [[PKG_ELEM_ADDR_RES:%.*]] = struct_element_addr {{.*}} : $*PkgStruct, #PkgStruct.fooVar +// CHECK-MAIN-RES: [[PKG_GET_RES:%.*]] = load [[PKG_ELEM_ADDR_RES]] : $*Int +// CHECK-MAIN-RES: store [[PKG_GET_RES]] to {{.*}} : $*Int +// CHECK-MAIN-RES: struct $PkgStruct +// CHECK-MAIN-RES: store +// CHECK-MAIN-RES: [[PKG_ELEM_ADDR_RES_ARG:%.*]] = struct_element_addr {{.*}} : $*PkgStruct, #PkgStruct.fooVar +// CHECK-MAIN-RES: load [[PKG_ELEM_ADDR_RES_ARG]] : $*Int +// CHECK-MAIN-NONRES: function_ref @$s3Lib9PkgStructVyACSicfC +// CHECK-MAIN-NONRES: [[PKG_ELEM_ADDR_NONRES:%.*]] = struct_element_addr {{.*}} : $*PkgStruct, #PkgStruct.fooVar +// CHECK-MAIN-NONRES: [[PKG_GET_NONRES:%.*]] = load [[PKG_ELEM_ADDR_NONRES]] : $*Int +// CHECK-MAIN-NONRES: store [[PKG_GET_NONRES]] to {{.*}} : $*Int +// CHECK-MAIN-NONRES: struct $PkgStruct +// CHECK-MAIN-NONRES: store +// CHECK-MAIN-NONRES: function_ref @$s3Lib6runPkgySiAA0C6StructVF // CHECK-MAIN-COMMON: [[PUB_ALLOC:%.*]] = alloc_ref $PubKlass // CHECK-MAIN-COMMON-NEXT: [[PUB_INIT:%.*]] = end_init_let_ref [[PUB_ALLOC]] : $PubKlass @@ -74,11 +85,12 @@ import Lib // CHECK-MAIN-COMMON: [[PUBK_SET:%.*]] = load {{.*}} : $*PubKlass // CHECK-MAIN-COMMON: class_method [[PUBK_SET]] : $PubKlass, #PubKlass.data!setter : (PubKlass) -> (Int) -> (), $@convention(method) (Int, @guaranteed PubKlass) -> () -// CHECK-MAIN-COMMON: [[PKG_ALLOC:%.*]] = alloc_ref $PkgKlass -// CHECK-MAIN-COMMON-NEXT: [[PKG_INIT:%.*]] = end_init_let_ref [[PKG_ALLOC]] : $PkgKlass -// CHECK-MAIN-COMMON-NEXT: [[PKG_REF_ELEM_ADDR:%.*]] = ref_element_addr [[PKG_INIT]] : $PkgKlass, #PkgKlass.data -// CHECK-MAIN-COMMON-NEXT: store {{.*}} to [[PKG_REF_ELEM_ADDR]] : $*Int -// CHECK-MAIN-COMMON-NEXT: store [[PKG_INIT]] to {{.*}} : $*PkgKlass +// CHECK-MAIN-RES: [[PKG_ALLOC:%.*]] = alloc_ref $PkgKlass +// CHECK-MAIN-RES-NEXT: [[PKG_INIT:%.*]] = end_init_let_ref [[PKG_ALLOC]] : $PkgKlass +// CHECK-MAIN-RES-NEXT: [[PKG_REF_ELEM_ADDR:%.*]] = ref_element_addr [[PKG_INIT]] : $PkgKlass, #PkgKlass.data +// CHECK-MAIN-RES-NEXT: store {{.*}} to [[PKG_REF_ELEM_ADDR]] : $*Int +// CHECK-MAIN-RES-NEXT: store [[PKG_INIT]] to {{.*}} : $*PkgKlass +// CHECK-MAIN-NONRES: function_ref @$s3Lib8PkgKlassCyACSicfC // CHECK-MAIN-COMMON: [[PKGK_GET:%.*]] = load {{.*}} : $*PkgKlass // CHECK-MAIN-COMMON: class_method [[PKGK_GET]] : $PkgKlass, #PkgKlass.data!getter : (PkgKlass) -> () -> Int, $@convention(method) (@guaranteed PkgKlass) -> Int @@ -98,12 +110,13 @@ import Lib // CHECK-MAIN-COMMON-NEXT: [[FNL_PUB_LOAD:%.*]] = load [[FNL_PUB_ACCESS]] : $*Int // CHECK-MAIN-COMMON: store [[FNL_PUB_LOAD]] to {{.*}} : $*Int -// CHECK-MAIN-COMMON: [[FNL_PKG_ALLOC:%.*]] = alloc_ref $FinalPkgKlass -// CHECK-MAIN-COMMON-NEXT: [[FNL_PKG_INIT:%.*]] = end_init_let_ref [[FNL_PKG_ALLOC]] : $FinalPkgKlass -// CHECK-MAIN-COMMON-NEXT: [[FNL_PKG_REF_ELEM_ADDR:%.*]] = ref_element_addr [[FNL_PKG_INIT]] : $FinalPkgKlass, #FinalPkgKlass.data -// CHECK-MAIN-COMMON-NEXT: store {{.*}} to [[FNL_PKG_REF_ELEM_ADDR]] : $*Int -// CHECK-MAIN-COMMON: store [[FNL_PKG_INIT]] to {{.*}} : $*FinalPkgKlass - +// CHECK-MAIN-RES: [[FNL_PKG_ALLOC:%.*]] = alloc_ref $FinalPkgKlass +// CHECK-MAIN-RES-NEXT: [[FNL_PKG_INIT:%.*]] = end_init_let_ref [[FNL_PKG_ALLOC]] : $FinalPkgKlass +// CHECK-MAIN-RES-NEXT: [[FNL_PKG_REF_ELEM_ADDR:%.*]] = ref_element_addr [[FNL_PKG_INIT]] : $FinalPkgKlass, #FinalPkgKlass.data +// CHECK-MAIN-RES-NEXT: store {{.*}} to [[FNL_PKG_REF_ELEM_ADDR]] : $*Int +// CHECK-MAIN-RES: store [[FNL_PKG_INIT]] to {{.*}} : $*FinalPkgKlass +// CHECK-MAIN-NONRES: function_ref @$s3Lib13FinalPkgKlassCyACSicfC + // CHECK-MAIN-COMMON: [[FNL_PKG_GET:%.*]] = load {{.*}} : $*FinalPkgKlass // CHECK-MAIN-COMMON: [[FNL_PKG_REF:%.*]] = ref_element_addr [[FNL_PKG_GET]] : $FinalPkgKlass, #FinalPkgKlass.data // CHECK-MAIN-COMMON-NEXT: [[FNL_PKG_ACCESS:%.*]] = begin_access {{.*}} [[FNL_PKG_REF]] : $*Int @@ -114,7 +127,6 @@ import Lib // CHECK-MAIN-NONRES-DAG: sil public_external @$s3Lib8PubKlassCyACSicfC : $@convention(method) (Int, @thick PubKlass.Type) -> @owned PubKlass { // CHECK-MAIN-RES-DAG: sil package_external @$s3Lib8PkgKlassCyACSicfC : $@convention(method) (Int, @thick PkgKlass.Type) -> @owned PkgKlass { -// CHECK-MAIN-NONRES-DAG: sil package_external @$s3Lib8PkgKlassCyACSicfC : $@convention(method) (Int, @thick PkgKlass.Type) -> @owned PkgKlass { // CHECK-MAIN-RES-DAG: sil public_external @$s3Lib13FinalPubKlassCyACSicfC : $@convention(method) (Int, @thick FinalPubKlass.Type) -> @owned FinalPubKlass { // CHECK-MAIN-NONRES-DAG: sil public_external @$s3Lib13FinalPubKlassCyACSicfC : $@convention(method) (Int, @thick FinalPubKlass.Type) -> @owned FinalPubKlass { @@ -123,15 +135,13 @@ import Lib // CHECK-MAIN-NONRES-DAG: sil public_external [transparent] @$s3Lib8PubKlassC4dataSivs : $@convention(method) (Int, @guaranteed PubKlass) -> () { // CHECK-MAIN-RES-DAG: sil package_external @$s3Lib13FinalPkgKlassCyACSicfC : $@convention(method) (Int, @thick FinalPkgKlass.Type) -> @owned FinalPkgKlass { -// CHECK-MAIN-NONRES-DAG: sil package_external @$s3Lib13FinalPkgKlassCyACSicfC : $@convention(method) (Int, @thick FinalPkgKlass.Type) -> @owned FinalPkgKlass { // CHECK-MAIN-RES-DAG: sil package_external @$s3Lib8PkgKlassC4dataSivs : $@convention(method) (Int, @guaranteed PkgKlass) -> () { -// CHECK-MAIN-NONRES-DAG: sil package_external [transparent] @$s3Lib8PkgKlassC4dataSivs : $@convention(method) (Int, @guaranteed PkgKlass) -> () { // CHECK-MAIN-COMMON: sil_vtable PubKlass { -// CHECK-MAIN-COMMON: sil_vtable PkgKlass { +// CHECK-MAIN-RES: sil_vtable PkgKlass { // CHECK-MAIN-COMMON: sil_vtable FinalPubKlass { -// CHECK-MAIN-COMMON: sil_vtable FinalPkgKlass { +// CHECK-MAIN-RES: sil_vtable FinalPkgKlass { var pub = PubStruct(1) let prevPub = pub.fooVar @@ -176,6 +186,36 @@ public func mainPub() { //--- Lib.swift +// static PubStruct.pubStaticSimpleFuncPtr +// CHECK-NONRES-DAG: sil_global [serialized] @$s3Lib9PubStructV22pubStaticSimpleFuncPtryS2icvpZ : $@callee_guaranteed (Int) -> Int = { + // function_ref runPubSimple(_:) +// CHECK-NONRES-DAG: [[PUB_FPTR:%.*]] = function_ref @$s3Lib12runPubSimpleyS2iF : $@convention(thin) (Int) -> Int +// CHECK-NONRES-DAG: thin_to_thick_function [[PUB_FPTR]] : $@convention(thin) (Int) -> Int to $@callee_guaranteed (Int) -> Int + +// static PubStruct.pubStaticFuncPtr +// CHECK-NONRES-DAG-DAG: sil_global [serialized] @$s3Lib9PubStructV16pubStaticFuncPtrySiACcvpZ : $@callee_guaranteed (PubStruct) -> Int = { + // function_ref runPub(_:) +// CHECK-NONRES-DAG: [[PTR:%.*]] = function_ref @$s3Lib6runPubySiAA0C6StructVF : $@convention(thin) (PubStruct) -> Int +// CHECK-NONRES-DAG: thin_to_thick_function [[PTR]] : $@convention(thin) (PubStruct) -> Int to $@callee_guaranteed (PubStruct) -> Int + +// static PubStruct.pubStaticSimpleClosurePtr +// CHECK-NONRES-DAG: sil_global @$s3Lib9PubStructV25pubStaticSimpleClosurePtryS2icvpZ : $@callee_guaranteed (Int) -> Int + +// static PubStruct.pubStaticClosurePtr +// CHECK-NONRES-DAG: sil_global @$s3Lib9PubStructV19pubStaticClosurePtrySiACcvpZ : $@callee_guaranteed (PubStruct) -> Int + +// static FrPubStruct.pubStaticSimpleFuncPtr +// CHECK-NONRES-DAG: sil_global [serialized] @$s3Lib11FrPubStructV22pubStaticSimpleFuncPtryS2icvpZ : $@callee_guaranteed (Int) -> Int = { + +// static FrPubStruct.pubStaticFuncPtr +// CHECK-NONRES-DAG: sil_global [serialized] @$s3Lib11FrPubStructV16pubStaticFuncPtrySiAA0cD0VcvpZ : $@callee_guaranteed (PubStruct) -> Int = { + +// static FrPubStruct.pubStaticSimpleClosurePtr +// CHECK-NONRES-DAG: sil_global @$s3Lib11FrPubStructV25pubStaticSimpleClosurePtryS2icvpZ : $@callee_guaranteed (Int) -> Int + +// static FrPubStruct.pubStaticClosurePtr +// CHECK-NONRES-DAG: sil_global @$s3Lib11FrPubStructV19pubStaticClosurePtrySiAA0cD0VcvpZ : $@callee_guaranteed (PubStruct) -> Int + public struct PubStruct { // PubStruct.foovar.getter // CHECK-RES-DAG: sil [serialized_for_package] [canonical] @$s3Lib9PubStructV6fooVarSivg : $@convention(method) (@in_guaranteed PubStruct) -> Int { @@ -208,13 +248,16 @@ public struct PubStruct { // CHECK-NONRES-DAG: sil [transparent] [serialized] [canonical] [ossa] @$s3Lib9PubStructV22pubStaticSimpleFuncPtryS2icvMZ : $@yield_once @convention(method) (@thin PubStruct.Type) -> @yields @inout @callee_guaranteed (Int) -> Int { public static var pubStaticSimpleFuncPtr: (Int) -> (Int) = runPubSimple - // static PubStruct.pubStaticFuncPtr.modify - // CHECK-NONRES-DAG: sil [transparent] [serialized] [canonical] [ossa] @$s3Lib9PubStructV16pubStaticFuncPtrySiACcvsZ : $@convention(method) (@owned @callee_guaranteed (PubStruct) -> Int, @thin PubStruct.Type) -> () { + // static PubStruct.pubStaticFuncPtr.getter + // CHECK-NONRES-DAG: sil [transparent] [serialized] [canonical] [ossa] @$s3Lib9PubStructV16pubStaticFuncPtrySiACcvgZ : $@convention(method) (@thin PubStruct.Type) -> @owned @callee_guaranteed (PubStruct) -> Int { + // function_ref PubStruct.pubStaticFuncPtr.unsafeMutableAddressor // CHECK-NONRES-DAG: function_ref @$s3Lib9PubStructV16pubStaticFuncPtrySiACcvau : $@convention(thin) () -> Builtin.RawPointer - + // PubStruct.pubStaticFuncPtr.unsafeMutableAddressor - // CHECK-NONRES-DAG: sil [serialized] [global_init] [canonical] @$s3Lib9PubStructV16pubStaticFuncPtrySiACcvau : $@convention(thin) () -> Builtin.RawPointer - // CHECK-NONRES-DAG: global_addr @$s3Lib9PubStructV16pubStaticFuncPtrySiACcvpZ : $*@callee_guaranteed (PubStruct) -> Int + // CHECK-NONRES-DAG: sil [serialized] [global_init] [canonical] @$s3Lib9PubStructV16pubStaticFuncPtrySiACcvau : $@convention(thin) () -> Builtin.RawPointer { + // CHECK-NONRES-DAG: [[PUB_FADDR:%.*]] = global_addr @$s3Lib9PubStructV16pubStaticFuncPtrySiACcvpZ : $*@callee_guaranteed (PubStruct) -> Int + // CHECK-NONRES-DAG: address_to_pointer [[PUB_FADDR]] : $*@callee_guaranteed (PubStruct) -> Int to $Builtin.RawPointer + public static var pubStaticFuncPtr: (PubStruct) -> (Int) = runPub // static PubStruct.pubStaticSimpleClosurePtr.setter @@ -226,14 +269,20 @@ public struct PubStruct { // CHECK-NONRES-DAG: global_addr @$s3Lib9PubStructV25pubStaticSimpleClosurePtryS2icvpZ : $*@callee_guaranteed (Int) -> Int public static var pubStaticSimpleClosurePtr: (Int) -> (Int) = { return $0 } - // static PubStruct.pubStaticClosurePtr.setter - // CHECK-NONRES-DAG: sil [transparent] [serialized] [canonical] [ossa] @$s3Lib9PubStructV19pubStaticClosurePtrySiACcvsZ : $@convention(method) (@owned @callee_guaranteed (PubStruct) -> Int, @thin PubStruct.Type) -> () { - // CHECK-NONRES-DAG: function_ref @$s3Lib9PubStructV19pubStaticClosurePtrySiACcvau : $@convention(thin) () -> Builtin.RawPointer - + // static PubStruct.pubStaticClosurePtr.getter + // CHECK-NONRES-DAG: sil [transparent] [serialized] [canonical] [ossa] @$s3Lib9PubStructV19pubStaticClosurePtrySiACcvgZ : $@convention(method) (@thin PubStruct.Type) -> @owned @callee_guaranteed (PubStruct) -> Int { + // function_ref PubStruct.pubStaticClosurePtr.unsafeMutableAddressor + // CHECK-NONRES-DAG: function_ref @$s3Lib9PubStructV19pubStaticClosurePtrySiACcvau : $@convention(thin) + // PubStruct.pubStaticClosurePtr.unsafeMutableAddressor // CHECK-NONRES-DAG: sil [serialized] [global_init] [canonical] @$s3Lib9PubStructV19pubStaticClosurePtrySiACcvau : $@convention(thin) () -> Builtin.RawPointer { - // CHECK-NONRES-DAG: global_addr @$s3Lib9PubStructV19pubStaticClosurePtrySiACcvpZ : $*@callee_guaranteed (PubStruct) -> Int + // CHECK-NONRES-DAG: [[PUB_CADDR:%.*]] = global_addr @$s3Lib9PubStructV19pubStaticClosurePtrySiACcvpZ : $*@callee_guaranteed (PubStruct) -> Int + // CHECK-NONRES-DAG: address_to_pointer [[PUB_CADDR]] : $*@callee_guaranteed (PubStruct) -> Int to $Builtin.RawPointer public static var pubStaticClosurePtr: (PubStruct) -> (Int) = { return $0.fooVar } + + // static PubStruct.pubStaticFunc() + // CHECK-RES-DAG: sil [serialized_for_package] [canonical] @$s3Lib9PubStructV13pubStaticFuncAA0B5KlassCyFZ : $@convention(method) (@thin PubStruct.Type) -> @owned PubKlass { + // CHECK-NONRES-DAG: sil [serialized] [canonical] @$s3Lib9PubStructV13pubStaticFuncAA0B5KlassCyFZ : $@convention(method) (@thin PubStruct.Type) -> @owned PubKlass { public static func pubStaticFunc() -> PubKlass { return PubKlass() } public init(_ arg: Int) { @@ -316,21 +365,16 @@ public func runFrPub(_ arg: FrPubStruct) -> Int { package struct PkgStruct { // PkgStruct.fooVar.getter // CHECK-RES-DAG: sil package [serialized_for_package] [canonical] @$s3Lib9PkgStructV6fooVarSivg : $@convention(method) (@in_guaranteed PkgStruct) -> Int { - // CHECK-NONRES-DAG: sil package [transparent] [serialized] [canonical] [ossa] @$s3Lib9PkgStructV6fooVarSivg : $@convention(method) (PkgStruct) -> Int { - // CHECK-COMMON-DAG: [[PKG_GET:%.*]] = struct_element_addr {{.*}} : $*PkgStruct, #PkgStruct.fooVar + // CHECK-RES-DAG: [[PKG_GET:%.*]] = struct_element_addr {{.*}} : $*PkgStruct, #PkgStruct.fooVar // CHECK-RES-DAG: load [[PKG_GET]] : $*Int - // CHECK-NONRES-DAG = struct_extract {{.*}} : $PkgStruct, #PkgStruct.fooVar // PkgStruct.fooVar.setter // CHECK-RES-DAG: sil package [serialized_for_package] [canonical] @$s3Lib9PkgStructV6fooVarSivs : $@convention(method) (Int, @inout PkgStruct) -> () { - // CHECK-NONRES-DAG: sil package [transparent] [serialized] [canonical] [ossa] @$s3Lib9PkgStructV6fooVarSivs : $@convention(method) (Int, @inout PkgStruct) -> () { - // CHECK-COMMON-DAG: [[PKG_SET:%.*]] = struct $PkgStruct + // CHECK-RES-DAG: [[PKG_SET:%.*]] = struct $PkgStruct // CHECK-RES-DAG: store [[PKG_SET]] to {{.*}} : $*PkgStruct - // CHECK-NONRES-DAG: store [[PKG_SET]] to [trivial] {{.*}} : $*PkgStruct // PkgStruct.fooVar.modify // CHECK-RES-DAG: sil package [serialized_for_package] [canonical] @$s3Lib9PkgStructV6fooVarSivM : $@yield_once @convention(method) (@inout PkgStruct) -> @yields @inout Int { - // CHECK-NONRES-DAG: sil package [transparent] [serialized] [canonical] [ossa] @$s3Lib9PkgStructV6fooVarSivM : $@yield_once @convention(method) (@inout PkgStruct) -> @yields @inout Int { package var fooVar: Int package static var pkgStaticVar: String { "StaticPkgVar" } @@ -341,22 +385,18 @@ package struct PkgStruct { package init(_ arg: Int) { // CHECK-RES-DAG: sil package [serialized_for_package] [canonical] @$s3Lib9PkgStructVyACSicfC : $@convention(method) (Int, @thin PkgStruct.Type) -> @out PkgStruct { - // CHECK-NONRES-DAG: sil package [serialized] [canonical] @$s3Lib9PkgStructVyACSicfC : $@convention(method) (Int, @thin PkgStruct.Type) -> PkgStruct { - // CHECK-COMMON-DAG: [[PKG_INIT:%.*]] = struct $PkgStruct + // CHECK-RES-DAG: [[PKG_INIT:%.*]] = struct $PkgStruct // CHECK-RES-DAG: store [[PKG_INIT]] to {{.*}} : $*PkgStruct - // CHECK-NONRES-DAG: return [[PKG_INIT]] : $PkgStruct fooVar = arg } package func f() -> Int { // CHECK-RES-DAG: sil package [serialized_for_package] [canonical] @$s3Lib9PkgStructV1fSiyF : $@convention(method) (@in_guaranteed PkgStruct) -> Int { - // CHECK-NONRES-DAG: sil package [serialized] [canonical] @$s3Lib9PkgStructV1fSiyF : $@convention(method) (PkgStruct) -> Int { return fooVar > 19 ? fooVar : fooVar + 23 } } package func runPkg(_ arg: PkgStruct) -> Int { // CHECK-RES-DAG: sil package [serialized_for_package] [canonical] @$s3Lib6runPkgySiAA0C6StructVF : $@convention(thin) (@in_guaranteed PkgStruct) -> Int { - // CHECK-NONRES-DAG: sil package [serialized] [canonical] @$s3Lib6runPkgySiAA0C6StructVF : $@convention(thin) (PkgStruct) -> Int { return arg.f() > arg.fooVar ? arg.f() : arg.fooVar } @@ -366,9 +406,9 @@ public protocol PubProto { } public class PubKlass: PubProto { - // CHECK-RES-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib8PubKlassCAA0B5ProtoA2aDP4dataSivgTW : $@convention(witness_method: PubProto) (@in_guaranteed PubKlass) -> Int { - // CHECK-RES-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib8PubKlassCAA0B5ProtoA2aDP4dataSivMTW : $@yield_once @convention(witness_method: PubProto) @substituted <τ_0_0> (@inout τ_0_0) -> @yields @inout Int for { - // CHECK-RES-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib8PubKlassCAA0B5ProtoA2aDP4dataSivsTW : $@convention(witness_method: PubProto) (Int, @inout PubKlass) -> () { + // CHECK-RES-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib8PubKlassCAA0B5ProtoA2aDP4dataSivgTW : $@convention(witness_method: PubProto) (@in_guaranteed PubKlass) -> Int { + // CHECK-RES-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib8PubKlassCAA0B5ProtoA2aDP4dataSivMTW : $@yield_once @convention(witness_method: PubProto) @substituted <τ_0_0> (@inout τ_0_0) -> @yields @inout Int for { + // CHECK-RES-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib8PubKlassCAA0B5ProtoA2aDP4dataSivsTW : $@convention(witness_method: PubProto) (Int, @inout PubKlass) -> () { // CHECK-NONRES-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib8PubKlassCAA0B5ProtoA2aDP4dataSivgTW : $@convention(witness_method: PubProto) (@in_guaranteed PubKlass) -> Int { // CHECK-NONRES-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib8PubKlassCAA0B5ProtoA2aDP4dataSivMTW : $@yield_once @convention(witness_method: PubProto) @substituted <τ_0_0> (@inout τ_0_0) -> @yields @inout Int for { // CHECK-NONRES-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib8PubKlassCAA0B5ProtoA2aDP4dataSivsTW : $@convention(witness_method: PubProto) (Int, @inout PubKlass) -> () { @@ -393,7 +433,7 @@ public class PubKlass: PubProto { self.data = arg } public func pubfunc(_ arg: Int) -> Int { - // CHECK-RES-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib8PubKlassCAA0B5ProtoA2aDP7pubfuncyS2iFTW : $@convention(witness_method: PubProto) (Int, @in_guaranteed PubKlass) -> Int { + // CHECK-RES-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib8PubKlassCAA0B5ProtoA2aDP7pubfuncyS2iFTW : $@convention(witness_method: PubProto) (Int, @in_guaranteed PubKlass) -> Int { // CHECK-RES-DAG: sil [serialized_for_package] [canonical] @$s3Lib8PubKlassC7pubfuncyS2iF : $@convention(method) (Int, @guaranteed PubKlass) -> Int { // CHECK-NONRES-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib8PubKlassCAA0B5ProtoA2aDP7pubfuncyS2iFTW : $@convention(witness_method: PubProto) (Int, @in_guaranteed PubKlass) -> Int { // CHECK-NONRES-DAG: sil [serialized] [canonical] @$s3Lib8PubKlassC7pubfuncyS2iF : $@convention(method) (Int, @guaranteed PubKlass) -> Int { @@ -409,9 +449,17 @@ public func runPubKlass(_ arg: PubKlass) -> Int { } final public class FinalPubKlass { + // variable initialization expression of FinalPubKlass.data + // CHECK-RES-DAG: sil [transparent] [serialized_for_package] [canonical] [ossa] @$s3Lib13FinalPubKlassC4dataSivpfi : $@convention(thin) () -> Int { public var data = 1 // FinalPubKlass.__allocating_init(_:) // CHECK-RES-DAG: sil [serialized] [exact_self_class] [canonical] @$s3Lib13FinalPubKlassCyACSicfC : $@convention(method) (Int, @thick FinalPubKlass.Type) -> @owned FinalPubKlass { + // FinalPubKlass.init(_:) + // CHECK-RES-DAG: sil [serialized_for_package] [canonical] @$s3Lib13FinalPubKlassCyACSicfc : $@convention(method) (Int, @owned FinalPubKlass) -> @owned FinalPubKlass { + // FinalPubKlass.__deallocating_deinit + // CHECK-RES-DAG: sil [serialized_for_package] [canonical] @$s3Lib13FinalPubKlassCfD : $@convention(method) (@owned FinalPubKlass) -> () { + // FinalPubKlass.deinit + // CHECK-RES-DAG: sil [serialized_for_package] [canonical] @$s3Lib13FinalPubKlassCfd : $@convention(method) (@guaranteed FinalPubKlass) -> @owned Builtin.NativeObject { public init(_ arg: Int) { data = arg } @@ -426,57 +474,53 @@ package protocol PkgProto { } package class PkgKlass: PkgProto { - // CHECK-RES-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib8PkgKlassCAA0B5ProtoA2aDP4dataSivgTW : $@convention(witness_method: PkgProto) (@in_guaranteed PkgKlass) -> Int { - // CHECK-RES-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib8PkgKlassCAA0B5ProtoA2aDP4dataSivsTW : $@convention(witness_method: PkgProto) (Int, @inout PkgKlass) -> () { - // CHECK-RES-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib8PkgKlassCAA0B5ProtoA2aDP4dataSivMTW : $@yield_once @convention(witness_method: PkgProto) @substituted <τ_0_0> (@inout τ_0_0) -> @yields @inout Int for { - // CHECK-NONRES-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib8PkgKlassCAA0B5ProtoA2aDP4dataSivgTW : $@convention(witness_method: PkgProto) (@in_guaranteed PkgKlass) -> Int { - // CHECK-NONRES-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib8PkgKlassCAA0B5ProtoA2aDP4dataSivsTW : $@convention(witness_method: PkgProto) (Int, @inout PkgKlass) -> () { - // CHECK-NONRES-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib8PkgKlassCAA0B5ProtoA2aDP4dataSivMTW : $@yield_once @convention(witness_method: PkgProto) @substituted <τ_0_0> (@inout τ_0_0) -> @yields @inout Int for { + // CHECK-RES-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib8PkgKlassCAA0B5ProtoA2aDP4dataSivgTW : $@convention(witness_method: PkgProto) (@in_guaranteed PkgKlass) -> Int { + // CHECK-RES-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib8PkgKlassCAA0B5ProtoA2aDP4dataSivsTW : $@convention(witness_method: PkgProto) (Int, @inout PkgKlass) -> () { + // CHECK-RES-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib8PkgKlassCAA0B5ProtoA2aDP4dataSivMTW : $@yield_once @convention(witness_method: PkgProto) @substituted <τ_0_0> (@inout τ_0_0) -> @yields @inout Int for { // CHECK-RES-DAG: sil package [serialized_for_package] [canonical] @$s3Lib8PkgKlassC4dataSivM : $@yield_once @convention(method) (@guaranteed PkgKlass) -> @yields @inout Int { - // CHECK-NONRES-DAG: sil package [transparent] [serialized] [canonical] [ossa] @$s3Lib8PkgKlassC4dataSivM : $@yield_once @convention(method) (@guaranteed PkgKlass) -> @yields @inout Int { // CHECK-RES-DAG: sil package [serialized_for_package] [canonical] @$s3Lib8PkgKlassC4dataSivg : $@convention(method) (@guaranteed PkgKlass) -> Int { - // CHECK-NONRES-DAG: sil package [transparent] [serialized] [canonical] [ossa] @$s3Lib8PkgKlassC4dataSivg : $@convention(method) (@guaranteed PkgKlass) -> Int { // CHECK-RES-DAG: sil package [serialized_for_package] [canonical] @$s3Lib8PkgKlassC4dataSivs : $@convention(method) (Int, @guaranteed PkgKlass) -> () { - // CHECK-NONRES-DAG: sil package [transparent] [serialized] [canonical] [ossa] @$s3Lib8PkgKlassC4dataSivs : $@convention(method) (Int, @guaranteed PkgKlass) -> () { package var data: Int package init(_ arg: Int = 1) { // default argument 0 of PkgKlass.init(_:) // FIXME: package -> package_non_abi here? Also should this be [serialized] instead? // CHECK-RES-DAG: sil package [serialized_for_package] [canonical] @$s3Lib8PkgKlassCyACSicfcfA_ : $@convention(thin) () -> Int { - // CHECK-NONRES-DAG: sil package [serialized] [canonical] @$s3Lib8PkgKlassCyACSicfcfA_ : $@convention(thin) () -> Int { // CHECK-RES-DAG: sil package [serialized_for_package] [canonical] @$s3Lib8PkgKlassCyACSicfc : $@convention(method) (Int, @owned PkgKlass) -> @owned PkgKlass { - // CHECK-NONRES-DAG: sil package [serialized] [canonical] @$s3Lib8PkgKlassCyACSicfc : $@convention(method) (Int, @owned PkgKlass) -> @owned PkgKlass { // CHECK-RES-DAG: sil package [serialized_for_package] [exact_self_class] [canonical] @$s3Lib8PkgKlassCyACSicfC : $@convention(method) (Int, @thick PkgKlass.Type) -> @owned PkgKlass { - // CHECK-NONRES-DAG: sil package [serialized] [exact_self_class] [canonical] @$s3Lib8PkgKlassCyACSicfC : $@convention(method) (Int, @thick PkgKlass.Type) -> @owned PkgKlass { // CHECK-RES-DAG: sil package [serialized_for_package] [canonical] @$s3Lib8PkgKlassCfd : $@convention(method) (@guaranteed PkgKlass) -> @owned Builtin.NativeObject { - // CHECK-NONRES-DAG: sil package [serialized] [canonical] @$s3Lib8PkgKlassCfd : $@convention(method) (@guaranteed PkgKlass) -> @owned Builtin.NativeObject { // CHECK-RES-DAG: sil package [serialized_for_package] [canonical] @$s3Lib8PkgKlassCfD : $@convention(method) (@owned PkgKlass) -> () - // CHECK-NONRES-DAG: sil package [serialized] [canonical] @$s3Lib8PkgKlassCfD : $@convention(method) (@owned PkgKlass) -> () self.data = arg } package func pkgfunc(_ arg: Int) -> Int { - // CHECK-RES-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib8PkgKlassCAA0B5ProtoA2aDP7pkgfuncyS2iFTW : $@convention(witness_method: PkgProto) (Int, @in_guaranteed PkgKlass) -> Int { + // CHECK-RES-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib8PkgKlassCAA0B5ProtoA2aDP7pkgfuncyS2iFTW : $@convention(witness_method: PkgProto) (Int, @in_guaranteed PkgKlass) -> Int { // CHECK-RES-DAG: sil package [serialized_for_package] [canonical] @$s3Lib8PkgKlassC7pkgfuncyS2iF : $@convention(method) (Int, @guaranteed PkgKlass) -> Int { - // CHECK-NONRES-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib8PkgKlassCAA0B5ProtoA2aDP7pkgfuncyS2iFTW : $@convention(witness_method: PkgProto) (Int, @in_guaranteed PkgKlass) -> Int { - // CHECK-NONRES-DAG: sil package [serialized] [canonical] @$s3Lib8PkgKlassC7pkgfuncyS2iF : $@convention(method) (Int, @guaranteed PkgKlass) -> Int { return data + arg } } package func runPkgKlass(_ arg: PkgKlass) -> Int { // CHECK-RES-DAG: sil package [serialized_for_package] [canonical] @$s3Lib11runPkgKlassySiAA0cD0CF : $@convention(thin) (@guaranteed PkgKlass) -> Int - // CHECK-NONRES-DAG: sil package [serialized] [canonical] @$s3Lib11runPkgKlassySiAA0cD0CF : $@convention(thin) (@guaranteed PkgKlass) -> Int { arg.data += 37 return arg.pkgfunc(41) } final package class FinalPkgKlass { + // variable initialization expression of FinalPkgKlass.data + // CHECK-RES-DAG: sil package [transparent] [serialized_for_package] [canonical] [ossa] @$s3Lib13FinalPkgKlassC4dataSivpfi : $@convention(thin) () -> Int { package var data = 1 package init(_ arg: Int) { + // FinalPkgKlass.__allocating_init(_:) + // CHECK-RES-DAG: sil package [serialized_for_package] [exact_self_class] [canonical] @$s3Lib13FinalPkgKlassCyACSicfC : $@convention(method) (Int, @thick FinalPkgKlass.Type) -> @owned FinalPkgKlass { + // FinalPkgKlass.init(_:) + // CHECK-RES-DAG: sil package [serialized_for_package] [canonical] @$s3Lib13FinalPkgKlassCyACSicfc : $@convention(method) (Int, @owned FinalPkgKlass) -> @owned FinalPkgKlass { + // FinalPkgKlass.__deallocating_deinit + // CHECK-RES-DAG: sil package [serialized_for_package] [canonical] @$s3Lib13FinalPkgKlassCfD : $@convention(method) (@owned FinalPkgKlass) -> () { + // FinalPkgKlass.deinit + // CHECK-RES-DAG: sil package [serialized_for_package] [canonical] @$s3Lib13FinalPkgKlassCfd : $@convention(method) (@guaranteed FinalPkgKlass) -> @owned Builtin.NativeObject { data = arg } package func fnlPkgFunc(_ arg: Int) -> Int { @@ -499,18 +543,16 @@ final package class FinalPkgKlass { // CHECK-COMMON-NEXT: #FinalPubKlass.deinit!deallocator: @$s3Lib13FinalPubKlassCfD // CHECK-RES-LABEL: sil_vtable [serialized_for_package] PkgKlass { -// CHECK-NONRES-LABEL: sil_vtable [serialized] PkgKlass { -// CHECK-COMMON-NEXT: #PkgKlass.data!getter: (PkgKlass) -> () -> Int : @$s3Lib8PkgKlassC4dataSivg -// CHECK-COMMON-NEXT: #PkgKlass.data!setter: (PkgKlass) -> (Int) -> () : @$s3Lib8PkgKlassC4dataSivs -// CHECK-COMMON-NEXT: #PkgKlass.data!modify: (PkgKlass) -> () -> () : @$s3Lib8PkgKlassC4dataSivM -// CHECK-COMMON-NEXT: #PkgKlass.init!allocator: (PkgKlass.Type) -> (Int) -> PkgKlass : @$s3Lib8PkgKlassCyACSicfC -// CHECK-COMMON-NEXT: #PkgKlass.pkgfunc: (PkgKlass) -> (Int) -> Int : @$s3Lib8PkgKlassC7pkgfuncyS2iF -// CHECK-COMMON-NEXT: #PkgKlass.deinit!deallocator: @$s3Lib8PkgKlassCfD +// CHECK-RES-NEXT: #PkgKlass.data!getter: (PkgKlass) -> () -> Int : @$s3Lib8PkgKlassC4dataSivg +// CHECK-RES-NEXT: #PkgKlass.data!setter: (PkgKlass) -> (Int) -> () : @$s3Lib8PkgKlassC4dataSivs +// CHECK-RES-NEXT: #PkgKlass.data!modify: (PkgKlass) -> () -> () : @$s3Lib8PkgKlassC4dataSivM +// CHECK-RES-NEXT: #PkgKlass.init!allocator: (PkgKlass.Type) -> (Int) -> PkgKlass : @$s3Lib8PkgKlassCyACSicfC +// CHECK-RES-NEXT: #PkgKlass.pkgfunc: (PkgKlass) -> (Int) -> Int : @$s3Lib8PkgKlassC7pkgfuncyS2iF +// CHECK-RES-NEXT: #PkgKlass.deinit!deallocator: @$s3Lib8PkgKlassCfD // CHECK-RES-LABEL: sil_vtable [serialized_for_package] FinalPkgKlass { -// CHECK-NONRES-LABEL: sil_vtable [serialized] FinalPkgKlass { -// CHECK-COMMON-NEXT: #FinalPkgKlass.init!allocator: (FinalPkgKlass.Type) -> (Int) -> FinalPkgKlass : @$s3Lib13FinalPkgKlassCyACSicfC -// CHECK-COMMON-NEXT: #FinalPkgKlass.deinit!deallocator: @$s3Lib13FinalPkgKlassCfD +// CHECK-RES-NEXT: #FinalPkgKlass.init!allocator: (FinalPkgKlass.Type) -> (Int) -> FinalPkgKlass : @$s3Lib13FinalPkgKlassCyACSicfC +// CHECK-RES-NEXT: #FinalPkgKlass.deinit!deallocator: @$s3Lib13FinalPkgKlassCfD // CHECK-RES-LABEL: sil_witness_table [serialized_for_package] PubKlass: PubProto module Lib { // CHECK-NONRES-LABEL: sil_witness_table [serialized] PubKlass: PubProto module Lib { @@ -520,8 +562,7 @@ final package class FinalPkgKlass { // CHECK-COMMON-NEXT: method #PubProto.pubfunc: (Self) -> (Int) -> Int : @$s3Lib8PubKlassCAA0B5ProtoA2aDP7pubfuncyS2iFTW // CHECK-RES-LABEL: sil_witness_table package [serialized_for_package] PkgKlass: PkgProto module Lib { -// CHECK-NONRES-LABEL: sil_witness_table package [serialized] PkgKlass: PkgProto module Lib { -// CHECK-COMMON-NEXT: method #PkgProto.data!getter: (Self) -> () -> Int : @$s3Lib8PkgKlassCAA0B5ProtoA2aDP4dataSivgTW -// CHECK-COMMON-NEXT: method #PkgProto.data!setter: (inout Self) -> (Int) -> () : @$s3Lib8PkgKlassCAA0B5ProtoA2aDP4dataSivsTW -// CHECK-COMMON-NEXT: method #PkgProto.data!modify: (inout Self) -> () -> () : @$s3Lib8PkgKlassCAA0B5ProtoA2aDP4dataSivMTW -// CHECK-COMMON-NEXT: method #PkgProto.pkgfunc: (Self) -> (Int) -> Int : @$s3Lib8PkgKlassCAA0B5ProtoA2aDP7pkgfuncyS2iFTW +// CHECK-RES-NEXT: method #PkgProto.data!getter: (Self) -> () -> Int : @$s3Lib8PkgKlassCAA0B5ProtoA2aDP4dataSivgTW +// CHECK-RES-NEXT: method #PkgProto.data!setter: (inout Self) -> (Int) -> () : @$s3Lib8PkgKlassCAA0B5ProtoA2aDP4dataSivsTW +// CHECK-RES-NEXT: method #PkgProto.data!modify: (inout Self) -> () -> () : @$s3Lib8PkgKlassCAA0B5ProtoA2aDP4dataSivMTW +// CHECK-RES-NEXT: method #PkgProto.pkgfunc: (Self) -> (Int) -> Int : @$s3Lib8PkgKlassCAA0B5ProtoA2aDP7pkgfuncyS2iFTW diff --git a/test/SILOptimizer/package-cmo-serialize-tables.swift b/test/SILOptimizer/package-cmo-serialize-tables.swift index d8127ca78bae..825f9af9866b 100644 --- a/test/SILOptimizer/package-cmo-serialize-tables.swift +++ b/test/SILOptimizer/package-cmo-serialize-tables.swift @@ -9,8 +9,8 @@ // RUN: -Xfrontend -experimental-package-cmo -Xfrontend -experimental-allow-non-resilient-access \ // RUN: -enable-library-evolution -wmo -// RUN: %target-sil-opt %t/Lib.swiftmodule -sil-verify-all -o %t/Lib-sil-opt.sil -// RUN: %FileCheck %s < %t/Lib-sil-opt.sil +// RUN: %target-sil-opt %t/Lib.swiftmodule -sil-verify-all -o %t/Lib.sil +// RUN: %FileCheck %s < %t/Lib.sil // RUN: %target-build-swift -module-name=Main -package-name Pkg -enable-library-evolution -I%t -emit-sil %t/main.swift -o %t/Main.sil // RUN: %FileCheck %s --check-prefix=CHECK-MAIN < %t/Main.sil @@ -240,12 +240,12 @@ public protocol PubProto { /// NOTE: witness thunks get `shared` linkage public class PubKlassZ: PubProto { - // CHECK-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib9PubKlassZCAA0B5ProtoA2aDP4roots6UInt16VvgZTW + // CHECK-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib9PubKlassZCAA0B5ProtoA2aDP4roots6UInt16VvgZTW public static let root: UInt16 = 1 << 0 - // CHECK-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib9PubKlassZCAA0B5ProtoA2aDP3envs6UInt16VvgTW - // CHECK-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib9PubKlassZCAA0B5ProtoA2aDP3envs6UInt16VvsTW - // CHECK-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib9PubKlassZCAA0B5ProtoA2aDP3envs6UInt16VvMTW + // CHECK-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib9PubKlassZCAA0B5ProtoA2aDP3envs6UInt16VvgTW + // CHECK-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib9PubKlassZCAA0B5ProtoA2aDP3envs6UInt16VvsTW + // CHECK-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib9PubKlassZCAA0B5ProtoA2aDP3envs6UInt16VvMTW // CHECK-DAG: sil [serialized_for_package] [canonical] [ossa] @$s3Lib9PubKlassZC3envs6UInt16Vvg // CHECK-DAG: sil [serialized_for_package] [canonical] [ossa] @$s3Lib9PubKlassZC3envs6UInt16Vvs // CHECK-DAG: sil [serialized_for_package] [canonical] [ossa] @$s3Lib9PubKlassZC3envs6UInt16VvM @@ -255,13 +255,13 @@ public class PubKlassZ: PubProto { public let rawValue: UInt16 required public init(rawValue: UInt16) { - // CHECK-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib9PubKlassZCAA0B5ProtoA2aDP8rawValuexs6UInt16V_tcfCTW + // CHECK-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib9PubKlassZCAA0B5ProtoA2aDP8rawValuexs6UInt16V_tcfCTW // CHECK-DAG: sil [serialized_for_package] [canonical] [ossa] @$s3Lib9PubKlassZC8rawValueACs6UInt16V_tcfc self.rawValue = rawValue self.env = 1 << rawValue } public func pubFunc() { - // CHECK-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib9PubKlassZCAA0B5ProtoA2aDP7pubFuncyyFTW + // CHECK-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib9PubKlassZCAA0B5ProtoA2aDP7pubFuncyyFTW // CHECK-DAG: sil [serialized_for_package] [canonical] [ossa] @$s3Lib9PubKlassZC7pubFuncyyF print(env) } @@ -269,14 +269,14 @@ public class PubKlassZ: PubProto { public struct PubStruct: PubProto { // protocol witness for static PubProto.root.getter in conformance PubStruct - // CHECK-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib9PubStructVAA0B5ProtoA2aDP4roots6UInt16VvgZTW : $@convention(witness_method: PubProto) (@thick PubStruct.Type) -> UInt16 { + // CHECK-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib9PubStructVAA0B5ProtoA2aDP4roots6UInt16VvgZTW : $@convention(witness_method: PubProto) (@thick PubStruct.Type) -> UInt16 { // CHECK-DAG: function_ref @$s3Lib9PubStructV4roots6UInt16VvgZ : $@convention(method) (@thin PubStruct.Type) -> UInt16 // CHECK-DAG: sil [canonical] @$s3Lib9PubStructV4roots6UInt16VvgZ : $@convention(method) (@thin PubStruct.Type) -> UInt16 public static let root: UInt16 = 1 << 0 - // CHECK-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib9PubStructVAA0B5ProtoA2aDP3envs6UInt16VvgTW : $@convention(witness_method: PubProto) (@in_guaranteed PubStruct) -> UInt16 { - // CHECK-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib9PubStructVAA0B5ProtoA2aDP3envs6UInt16VvsTW : $@convention(witness_method: PubProto) (UInt16, @inout PubStruct) -> () { - // CHECK-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib9PubStructVAA0B5ProtoA2aDP3envs6UInt16VvMTW : $@yield_once @convention(witness_method: PubProto) @substituted <τ_0_0> (@inout τ_0_0) -> @yields @inout UInt16 for { + // CHECK-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib9PubStructVAA0B5ProtoA2aDP3envs6UInt16VvgTW : $@convention(witness_method: PubProto) (@in_guaranteed PubStruct) -> UInt16 { + // CHECK-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib9PubStructVAA0B5ProtoA2aDP3envs6UInt16VvsTW : $@convention(witness_method: PubProto) (UInt16, @inout PubStruct) -> () { + // CHECK-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib9PubStructVAA0B5ProtoA2aDP3envs6UInt16VvMTW : $@yield_once @convention(witness_method: PubProto) @substituted <τ_0_0> (@inout τ_0_0) -> @yields @inout UInt16 for { // CHECK-DAG: sil [serialized_for_package] [canonical] [ossa] @$s3Lib9PubStructV3envs6UInt16Vvg // CHECK-DAG: sil [serialized_for_package] [canonical] [ossa] @$s3Lib9PubStructV3envs6UInt16Vvs public var env: UInt16 @@ -285,14 +285,14 @@ public struct PubStruct: PubProto { public let rawValue: UInt16 public init(rawValue: UInt16) { - // CHECK-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib9PubStructVAA0B5ProtoA2aDP8rawValuexs6UInt16V_tcfCTW : $@convention(witness_method: PubProto) (UInt16, @thick PubStruct.Type) -> @out PubStruct { + // CHECK-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib9PubStructVAA0B5ProtoA2aDP8rawValuexs6UInt16V_tcfCTW : $@convention(witness_method: PubProto) (UInt16, @thick PubStruct.Type) -> @out PubStruct { // CHECK-DAG: sil [serialized_for_package] [canonical] [ossa] @$s3Lib9PubStructV8rawValueACs6UInt16V_tcfC self.rawValue = rawValue self.env = 1 << rawValue } public func pubFunc() { - // CHECK-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib9PubStructVAA0B5ProtoA2aDP7pubFuncyyFTW + // CHECK-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib9PubStructVAA0B5ProtoA2aDP7pubFuncyyFTW // CHECK-DAG: sil [serialized_for_package] [canonical] [ossa] @$s3Lib9PubStructV7pubFuncyyF print(env) } @@ -314,9 +314,9 @@ protocol InternalProto { public struct PubStructX: PubSimpleProto, InternalProto { /// NOTE: witness table serialized only for PubSimpleProto - // CHECK-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib10PubStructXVAA0B11SimpleProtoA2aDP6pubVarSivgTW : $@convention(witness_method: PubSimpleProto) (@in_guaranteed PubStructX) -> Int { - // CHECK-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib10PubStructXVAA0B11SimpleProtoA2aDP6pubVarSivsTW : $@convention(witness_method: PubSimpleProto) (Int, @inout PubStructX) -> () { - // CHECK-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib10PubStructXVAA0B11SimpleProtoA2aDP6pubVarSivMTW : $@yield_once @convention(witness_method: PubSimpleProto) @substituted <τ_0_0> (@inout τ_0_0) -> @yields @inout Int for { + // CHECK-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib10PubStructXVAA0B11SimpleProtoA2aDP6pubVarSivgTW : $@convention(witness_method: PubSimpleProto) (@in_guaranteed PubStructX) -> Int { + // CHECK-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib10PubStructXVAA0B11SimpleProtoA2aDP6pubVarSivsTW : $@convention(witness_method: PubSimpleProto) (Int, @inout PubStructX) -> () { + // CHECK-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib10PubStructXVAA0B11SimpleProtoA2aDP6pubVarSivMTW : $@yield_once @convention(witness_method: PubSimpleProto) @substituted <τ_0_0> (@inout τ_0_0) -> @yields @inout Int for { // CHECK-DAG: sil [serialized_for_package] [canonical] [ossa] @$s3Lib10PubStructXV6pubVarSivg // CHECK-DAG: sil [serialized_for_package] [canonical] [ossa] @$s3Lib10PubStructXV6pubVarSivs // CHECK-DAG: sil [serialized_for_package] [canonical] [ossa] @$s3Lib10PubStructXV6pubVarSivM @@ -359,13 +359,13 @@ package protocol PkgProto { /// NOTE: witness thunks get `shared` linkage package class PkgKlassZ: PkgProto { // protocol witness for static PkgProto.root.getter in conformance PkgKlassZ - // CHECK-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib9PkgKlassZCAA0B5ProtoA2aDP4roots6UInt16VvgZTW : $@convention(witness_method: PkgProto) (@thick PkgKlassZ.Type) -> UInt16 { + // CHECK-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib9PkgKlassZCAA0B5ProtoA2aDP4roots6UInt16VvgZTW : $@convention(witness_method: PkgProto) (@thick PkgKlassZ.Type) -> UInt16 { // CHECK-DAG: function_ref @$s3Lib9PkgKlassZC4roots6UInt16VvgZ : $@convention(method) (@thick PkgKlassZ.Type) -> UInt16 // CHECK-DAG: sil package_external [canonical] @$s3Lib9PkgKlassZC4roots6UInt16VvgZ : $@convention(method) (@thick PkgKlassZ.Type) -> UInt16 package static let root: UInt16 = 1 << 0 - // CHECK-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib9PkgKlassZCAA0B5ProtoA2aDP3envs6UInt16VvgTW : $@convention(witness_method: PkgProto) (@in_guaranteed PkgKlassZ) -> UInt16 { - // CHECK-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib9PkgKlassZCAA0B5ProtoA2aDP3envs6UInt16VvsTW : $@convention(witness_method: PkgProto) (UInt16, @inout PkgKlassZ) -> () { + // CHECK-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib9PkgKlassZCAA0B5ProtoA2aDP3envs6UInt16VvgTW : $@convention(witness_method: PkgProto) (@in_guaranteed PkgKlassZ) -> UInt16 { + // CHECK-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib9PkgKlassZCAA0B5ProtoA2aDP3envs6UInt16VvsTW : $@convention(witness_method: PkgProto) (UInt16, @inout PkgKlassZ) -> () { // CHECK-DAG: sil package [serialized_for_package] [canonical] [ossa] @$s3Lib9PkgKlassZC3envs6UInt16Vvg // CHECK-DAG: sil package [serialized_for_package] [canonical] [ossa] @$s3Lib9PkgKlassZC3envs6UInt16Vvs // CHECK-DAG: sil package [serialized_for_package] [canonical] [ossa] @$s3Lib9PkgKlassZC3envs6UInt16VvM @@ -375,13 +375,13 @@ package class PkgKlassZ: PkgProto { package let rawValue: UInt16 required package init(rawValue: UInt16) { - // CHECK-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib9PkgKlassZCAA0B5ProtoA2aDP8rawValuexs6UInt16V_tcfCTW : $@convention(witness_method: PkgProto) (UInt16, @thick PkgKlassZ.Type) -> @out PkgKlassZ { + // CHECK-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib9PkgKlassZCAA0B5ProtoA2aDP8rawValuexs6UInt16V_tcfCTW : $@convention(witness_method: PkgProto) (UInt16, @thick PkgKlassZ.Type) -> @out PkgKlassZ { // CHECK-DAG: sil package [serialized_for_package] [canonical] [ossa] @$s3Lib9PkgKlassZC8rawValueACs6UInt16V_tcfc : $@convention(method) (UInt16, @owned PkgKlassZ) -> @owned PkgKlassZ { self.rawValue = rawValue self.env = 1 << rawValue } package func pkgFunc() { - // CHECK-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib9PkgKlassZCAA0B5ProtoA2aDP7pkgFuncyyFTW + // CHECK-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib9PkgKlassZCAA0B5ProtoA2aDP7pkgFuncyyFTW // CHECK-DAG: sil package [serialized_for_package] [canonical] [ossa] @$s3Lib9PkgKlassZC7pkgFuncyyF print(env) } @@ -389,13 +389,13 @@ package class PkgKlassZ: PkgProto { package struct PkgStruct: PkgProto { /// NOTE: witness thunks get `shared` linkage // protocol witness for static PkgProto.root.getter in conformance PkgStruct - // CHECK-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib9PkgStructVAA0B5ProtoA2aDP4roots6UInt16VvgZTW : $@convention(witness_method: PkgProto) (@thick PkgStruct.Type) -> UInt16 { + // CHECK-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib9PkgStructVAA0B5ProtoA2aDP4roots6UInt16VvgZTW : $@convention(witness_method: PkgProto) (@thick PkgStruct.Type) -> UInt16 { // CHECK-DAG: function_ref @$s3Lib9PkgStructV4roots6UInt16VvgZ : $@convention(method) (@thin PkgStruct.Type) // static PkgStruct.root.getter // CHECK-DAG: sil package_external [canonical] @$s3Lib9PkgStructV4roots6UInt16VvgZ : $@convention(method) (@thin PkgStruct.Type) -> UInt16 package static let root: UInt16 = 1 << 0 - // CHECK-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib9PkgStructVAA0B5ProtoA2aDP3envs6UInt16VvsTW : $@convention(witness_method: PkgProto) (UInt16, @inout PkgStruct) -> () { + // CHECK-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib9PkgStructVAA0B5ProtoA2aDP3envs6UInt16VvsTW : $@convention(witness_method: PkgProto) (UInt16, @inout PkgStruct) -> () { // CHECK-DAG: sil package [serialized_for_package] [canonical] [ossa] @$s3Lib9PkgStructV3envs6UInt16Vvs package var env: UInt16 @@ -403,7 +403,7 @@ package struct PkgStruct: PkgProto { /// NOTE: witness thunks get `shared` linka package let rawValue: UInt16 package init(rawValue: UInt16) { - // CHECK-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib9PkgStructVAA0B5ProtoA2aDP8rawValuexs6UInt16V_tcfCTW : $@convention(witness_method: PkgProto) (UInt16, @thick PkgStruct.Type) -> @out PkgStruct { + // CHECK-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib9PkgStructVAA0B5ProtoA2aDP8rawValuexs6UInt16V_tcfCTW : $@convention(witness_method: PkgProto) (UInt16, @thick PkgStruct.Type) -> @out PkgStruct { // CHECK-DAG: sil package [serialized_for_package] [canonical] [ossa] @$s3Lib9PkgStructV8rawValueACs6UInt16V_tcfC self.rawValue = rawValue self.env = 1 << rawValue @@ -421,9 +421,9 @@ package protocol PkgSimpleProto { /// NOTE: only witness table of conformance to PkgSimpleProto is serialized. package struct PkgStructX: PkgSimpleProto, InternalProto { - // CHECK-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib10PkgStructXVAA0B11SimpleProtoA2aDP6pkgVarSivgTW : $@convention(witness_method: PkgSimpleProto) (@in_guaranteed PkgStructX) -> Int { - // CHECK-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib10PkgStructXVAA0B11SimpleProtoA2aDP6pkgVarSivsTW : $@convention(witness_method: PkgSimpleProto) (Int, @inout PkgStructX) -> () { - // CHECK-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib10PkgStructXVAA0B11SimpleProtoA2aDP6pkgVarSivMTW : $@yield_once @convention(witness_method: PkgSimpleProto) @substituted <τ_0_0> (@inout τ_0_0) -> @yields @inout Int for { + // CHECK-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib10PkgStructXVAA0B11SimpleProtoA2aDP6pkgVarSivgTW : $@convention(witness_method: PkgSimpleProto) (@in_guaranteed PkgStructX) -> Int { + // CHECK-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib10PkgStructXVAA0B11SimpleProtoA2aDP6pkgVarSivsTW : $@convention(witness_method: PkgSimpleProto) (Int, @inout PkgStructX) -> () { + // CHECK-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib10PkgStructXVAA0B11SimpleProtoA2aDP6pkgVarSivMTW : $@yield_once @convention(witness_method: PkgSimpleProto) @substituted <τ_0_0> (@inout τ_0_0) -> @yields @inout Int for { // CHECK-DAG: sil package [serialized_for_package] [canonical] [ossa] @$s3Lib10PkgStructXV6pkgVarSivM // CHECK-DAG: sil package [serialized_for_package] [canonical] [ossa] @$s3Lib10PkgStructXV6pkgVarSivg // CHECK-DAG: sil package [serialized_for_package] [canonical] [ossa] @$s3Lib10PkgStructXV6pkgVarSivs @@ -434,7 +434,7 @@ package struct PkgStructX: PkgSimpleProto, InternalProto { self.pkgVar = arg } package func pkgFunc() -> Int { - // CHECK-DAG: sil shared [transparent] [serialized] [thunk] [canonical] [ossa] @$s3Lib10PkgStructXVAA0B11SimpleProtoA2aDP7pkgFuncSiyFTW + // CHECK-DAG: sil shared [transparent] [serialized_for_package] [thunk] [canonical] [ossa] @$s3Lib10PkgStructXVAA0B11SimpleProtoA2aDP7pkgFuncSiyFTW // CHECK-DAG: sil package [serialized_for_package] [canonical] [ossa] @$s3Lib10PkgStructXV7pkgFuncSiyF return pkgVar } @@ -472,6 +472,19 @@ package func runPkg(_ arg: [any PkgProto]) { // CHECK-NEXT: #ParentPubKlass.parentPubFunc: (ParentPubKlass) -> () -> () : @$s3Lib14ParentPubKlassC06parentC4FuncyyF // ParentPubKlass.parentPubFunc() // CHECK-NEXT: #ParentPubKlass.deinit!deallocator: @$s3Lib14ParentPubKlassCfD // ParentPubKlass.__deallocating_deinit +// CHECK-LABEL: sil_vtable [serialized_for_package] PubKlass { +// CHECK-NEXT: #ParentPubKlass.parentPubVar!getter: (ParentPubKlass) -> () -> Int : @$s3Lib14ParentPubKlassC06parentC3VarSivg [inherited] // ParentPubKlass.parentPubVar.getter +// CHECK-NEXT: #ParentPubKlass.parentPubVar!setter: (ParentPubKlass) -> (Int) -> () : @$s3Lib14ParentPubKlassC06parentC3VarSivs [inherited] // ParentPubKlass.parentPubVar.setter +// CHECK-NEXT: #ParentPubKlass.parentPubVar!modify: (ParentPubKlass) -> () -> () : @$s3Lib14ParentPubKlassC06parentC3VarSivM [inherited] // ParentPubKlass.parentPubVar.modify +// CHECK-NEXT: #ParentPubKlass.init!allocator: (ParentPubKlass.Type) -> (Int) -> ParentPubKlass : @$s3Lib8PubKlassCyACSicfC [override] // PubKlass.__allocating_init(_:) +// CHECK-NEXT: #ParentPubKlass.parentPubFunc: (ParentPubKlass) -> () -> () : @$s3Lib8PubKlassC06parentB4FuncyyF [override] // PubKlass.parentPubFunc() +// CHECK-NEXT: #PubKlass.pubVar!getter: (PubKlass) -> () -> String : @$s3Lib8PubKlassC6pubVarSSvg // PubKlass.pubVar.getter +// CHECK-NEXT: #PubKlass.pubVar!setter: (PubKlass) -> (String) -> () : @$s3Lib8PubKlassC6pubVarSSvs // PubKlass.pubVar.setter +// CHECK-NEXT: #PubKlass.pubVar!modify: (PubKlass) -> () -> () : @$s3Lib8PubKlassC6pubVarSSvM // PubKlass.pubVar.modify +// CHECK-NEXT: #PubKlass.init!allocator: (PubKlass.Type) -> (String) -> PubKlass : @$s3Lib8PubKlassCyACSScfC // PubKlass.__allocating_init(_:) +// CHECK-NEXT: #PubKlass.pubFunc: (PubKlass) -> () -> () : @$s3Lib8PubKlassC7pubFuncyyF // PubKlass.pubFunc() +// CHECK-NEXT: #PubKlass.deinit!deallocator: @$s3Lib8PubKlassCfD // PubKlass.__deallocating_deinit +// CHECK-NEXT: #PubKlass!ivardestroyer: @$s3Lib8PubKlassCfE // PubKlass.__ivar_destroyer // CHECK-LABEL: sil_vtable [serialized_for_package] ParentPkgKlass { // CHECK-NEXT: #ParentPkgKlass.parentPkgVar!getter: (ParentPkgKlass) -> () -> Int : @$s3Lib14ParentPkgKlassC06parentC3VarSivg // ParentPkgKlass.parentPkgVar.getter @@ -481,6 +494,19 @@ package func runPkg(_ arg: [any PkgProto]) { // CHECK-NEXT: #ParentPkgKlass.parentPkgFunc: (ParentPkgKlass) -> () -> Int : @$s3Lib14ParentPkgKlassC06parentC4FuncSiyF // ParentPkgKlass.parentPkgFunc() // CHECK-NEXT: #ParentPkgKlass.deinit!deallocator: @$s3Lib14ParentPkgKlassCfD // ParentPkgKlass.__deallocating_deinit +// CHECK-LABEL: sil_vtable [serialized_for_package] PkgKlass { +// CHECK-NEXT: #ParentPkgKlass.parentPkgVar!getter: (ParentPkgKlass) -> () -> Int : @$s3Lib14ParentPkgKlassC06parentC3VarSivg [inherited] // ParentPkgKlass.parentPkgVar.getter +// CHECK-NEXT: #ParentPkgKlass.parentPkgVar!setter: (ParentPkgKlass) -> (Int) -> () : @$s3Lib14ParentPkgKlassC06parentC3VarSivs [inherited] // ParentPkgKlass.parentPkgVar.setter +// CHECK-NEXT: #ParentPkgKlass.parentPkgVar!modify: (ParentPkgKlass) -> () -> () : @$s3Lib14ParentPkgKlassC06parentC3VarSivM [inherited] // ParentPkgKlass.parentPkgVar.modify +// CHECK-NEXT: #ParentPkgKlass.init!allocator: (ParentPkgKlass.Type) -> (Int) -> ParentPkgKlass : @$s3Lib8PkgKlassCyACSicfC [override] // PkgKlass.__allocating_init(_:) +// CHECK-NEXT: #ParentPkgKlass.parentPkgFunc: (ParentPkgKlass) -> () -> Int : @$s3Lib8PkgKlassC06parentB4FuncSiyF [override] // PkgKlass.parentPkgFunc() +// CHECK-NEXT: #PkgKlass.pkgVar!getter: (PkgKlass) -> () -> String : @$s3Lib8PkgKlassC6pkgVarSSvg // PkgKlass.pkgVar.getter +// CHECK-NEXT: #PkgKlass.pkgVar!setter: (PkgKlass) -> (String) -> () : @$s3Lib8PkgKlassC6pkgVarSSvs // PkgKlass.pkgVar.setter +// CHECK-NEXT: #PkgKlass.pkgVar!modify: (PkgKlass) -> () -> () : @$s3Lib8PkgKlassC6pkgVarSSvM // PkgKlass.pkgVar.modify +// CHECK-NEXT: #PkgKlass.init!allocator: (PkgKlass.Type) -> (String) -> PkgKlass : @$s3Lib8PkgKlassCyACSScfC // PkgKlass.__allocating_init(_:) +// CHECK-NEXT: #PkgKlass.pkgFunc: (PkgKlass) -> () -> () : @$s3Lib8PkgKlassC7pkgFuncyyF // PkgKlass.pkgFunc() +// CHECK-NEXT: #PkgKlass.deinit!deallocator: @$s3Lib8PkgKlassCfD // PkgKlass.__deallocating_deinit +// CHECK-NEXT: #PkgKlass!ivardestroyer: @$s3Lib8PkgKlassCfE // PkgKlass.__ivar_destroyer // CHECK-LABEL: sil_vtable [serialized_for_package] PubKlassZ { // CHECK-NEXT: #PubKlassZ.env!getter: (PubKlassZ) -> () -> UInt16 : @$s3Lib9PubKlassZC3envs6UInt16Vvg // PubKlassZ.env.getter diff --git a/test/SILOptimizer/package-cmo-skip-internal.swift b/test/SILOptimizer/package-cmo-skip-internal.swift index 0568cb8b4e5a..548a4be9f860 100644 --- a/test/SILOptimizer/package-cmo-skip-internal.swift +++ b/test/SILOptimizer/package-cmo-skip-internal.swift @@ -24,7 +24,7 @@ import Lib let x = useInternal(Base()) /// Since Base is not serialized, accessing its field should go -/// through class_method. +/// through `class_method`. // CHECK-MAIN: class_method %13 : $Base, #Base.baseVarPkg!getter : (Base) -> () -> Int, $@convention(method) (@guaranteed Base) -> Int let y = usePkg(Base()) @@ -33,22 +33,30 @@ let y = usePkg(Base()) // CHECK-MAIN-NEXT: store let z = usePub(PubKlass()) +/// PubKlassWithInternalMember is serialized but its initializer contains +/// an internal field. +// CHECK-MAIN: function_ref @$s3Lib26PubKlassWithInternalMemberCyACSicfc +let w = usePubWithInternalField(PubKlassWithInternalMember(1)) + // useInternal(_:) // CHECK-MAIN: sil @$s3Lib11useInternalySiAA4BaseCF : $@convention(thin) (@guaranteed Base) -> Int +// PubKlassWithInternalMember.__allocating_init(_:) +// CHECK-MAIN: sil public_external @$s3Lib26PubKlassWithInternalMemberCyACSicfC : $@convention(method) (Int, @thick PubKlassWithInternalMember.Type) -> @owned PubKlassWithInternalMember { //--- Lib.swift /// Package CMO does not serialize this function since /// it references an internal symbol `baseVarInternal`. -/// If it were [serialized_for_pkg], it would leak into -/// client and client won't be able to find the symbol -/// `baseVarInternal` since its dispatch thunk was not -/// generated in the first place (due to it being internal). +/// If it were [serialized_for_package], it would leak +/// into client and client won't be able to find the +/// symbol `baseVarInternal` since its dispatch thunk +/// was not generated in the first place (due to it +/// being internal). // CHECK-NOT: s3Lib11useInternalySiAA4BaseCF public func useInternal(_ arg: Base) -> Int { - return PubKlass().pkgVar + arg.baseVarInternal + return PubKlass().pkgVar + arg.baseVarInternal.data } // CHECK-DAG: sil package [serialized_for_package] [canonical] @$s3Lib6usePkgySiAA4BaseCF : $@convention(thin) (@guaranteed Base) -> Int { @@ -58,15 +66,27 @@ package func usePkg(_ arg: Base) -> Int { // CHECK-DAG: sil [serialized_for_package] [canonical] @$s3Lib6usePubySiAA0C5KlassCF : $@convention(thin) (@guaranteed PubKlass) -> Int { public func usePub(_ arg: PubKlass) -> Int { - return arg.pubVar -} + return arg.pubVar + arg.pkgVar +} + +// CHECK-DAG: sil [serialized_for_package] [canonical] @$s3Lib23usePubWithInternalFieldySiAA0c5KlassdE6MemberCF : $@convention(thin) (@guaranteed PubKlassWithInternalMember) -> Int { +public func usePubWithInternalField(_ arg: PubKlassWithInternalMember) -> Int { + return arg.pubVar + arg.pkgVar +} + +struct InternalStruct { + var data: Int + init(_ arg: Int) { + data = arg + } +} /// This class is not serialized since it contains -/// an internal field. +/// a field of an internal type. public class Base { public init() {} - var baseVarInternal: Int { - return 0 + var baseVarInternal: InternalStruct { + return InternalStruct(1) } package var baseVarPkg: Int { return 0 @@ -82,10 +102,11 @@ class UFIKlass: Base { @usableFromInline var varUfi = 12 - override var baseVarInternal: Int { return 1 } + override var baseVarInternal: InternalStruct { return InternalStruct(3) } override var baseVarPkg: Int { return 2 } } +/// This class only contains package or public symbols, thus serialized. public class PubKlass { public init() {} public var pubVar: Int { @@ -96,9 +117,30 @@ public class PubKlass { } } +/// This class contains an internal field but its type is a public literal type, thus serialized. +public class PubKlassWithInternalMember { + var internalVar: Int + public init(_ arg: Int) { + internalVar = arg + } + public var pubVar: Int { + return 1 + } + package var pkgVar: Int { + return 2 + } +} + /// PubKlass doesn't contain internal symbols so its vtable is serialized. // CHECK-LABEL: sil_vtable [serialized_for_package] PubKlass { -// CHECK-NEXT: #PubKlass.init!allocator: (PubKlass.Type) -> () -> PubKlass : @$s3Lib8PubKlassCACycfC +// CHECK-NEXT: #PubKlass.init!allocator: (PubKlass.Type) -> () -> PubKlass : @$s3Lib8PubKlassCACycfC // CHECK-NEXT: #PubKlass.pubVar!getter: (PubKlass) -> () -> Int : @$s3Lib8PubKlassC6pubVarSivg // CHECK-NEXT: #PubKlass.pkgVar!getter: (PubKlass) -> () -> Int : @$s3Lib8PubKlassC6pkgVarSivg // CHECK-NEXT: #PubKlass.deinit!deallocator: @$s3Lib8PubKlassCfD + +/// PubKlassWithInternalMember contains an internal field but its type is a literal public type, so the class is serialized. +// CHECK-LABEL: sil_vtable [serialized_for_package] PubKlassWithInternalMember { +// CHECK-NEXT: #PubKlassWithInternalMember.init!allocator: (PubKlassWithInternalMember.Type) -> (Int) -> PubKlassWithInternalMember : @$s3Lib26PubKlassWithInternalMemberCyACSicfC // PubKlassWithInternalMember.__allocating_init(_:) +// CHECK-NEXT: #PubKlassWithInternalMember.pubVar!getter: (PubKlassWithInternalMember) -> () -> Int : @$s3Lib26PubKlassWithInternalMemberC6pubVarSivg // PubKlassWithInternalMember.pubVar.getter +// CHECK-NEXT: #PubKlassWithInternalMember.pkgVar!getter: (PubKlassWithInternalMember) -> () -> Int : @$s3Lib26PubKlassWithInternalMemberC6pkgVarSivg // PubKlassWithInternalMember.pkgVar.getter +// CHECK-NEXT: #PubKlassWithInternalMember.deinit!deallocator: @$s3Lib26PubKlassWithInternalMemberCfD // PubKlassWithInternalMember.__deallocating_deinit