diff --git a/include/swift/AST/SILOptions.h b/include/swift/AST/SILOptions.h index e54d4e0d25f2f..f103c85fa9381 100644 --- a/include/swift/AST/SILOptions.h +++ b/include/swift/AST/SILOptions.h @@ -154,9 +154,8 @@ class SILOptions { bool VerifyExclusivity = false; /// When building the stdlib with opts should we lower ownership after - /// serialization? Otherwise we do before. Only set to true on Darwin for now. - /// - bool SerializeStdlibWithOwnershipWithOpts = false; + /// serialization? Otherwise we do before. + bool SerializeStdlibWithOwnershipWithOpts = true; /// Calls to the replaced method inside of the replacement method will call /// the previous implementation. diff --git a/include/swift/Serialization/SerializedSILLoader.h b/include/swift/Serialization/SerializedSILLoader.h index 1707f546d8cae..83d58649f31f8 100644 --- a/include/swift/Serialization/SerializedSILLoader.h +++ b/include/swift/Serialization/SerializedSILLoader.h @@ -29,6 +29,7 @@ class ModuleDecl; class SILDeserializer; class SILFunction; class SILGlobalVariable; +class SILProperty; class SILModule; class SILVTable; class SILWitnessTable; @@ -69,10 +70,16 @@ class SerializedSILLoader { SILDifferentiabilityWitness * lookupDifferentiabilityWitness(SILDifferentiabilityWitnessKey key); - /// Invalidate the cached entries for deserialized SILFunctions. - void invalidateCaches(); - - bool invalidateFunction(SILFunction *F); + /// Invalidate the cached entries for deserialized state. Must be + /// called when erasing deserialized state in the SILModule. + void invalidateAllCaches(); + bool invalidateFunction(SILFunction *f); + bool invalidateGlobalVariable(SILGlobalVariable *gv); + bool invalidateVTable(SILVTable *vt); + bool invalidateWitnessTable(SILWitnessTable *wt); + bool invalidateDefaultWitnessTable(SILDefaultWitnessTable *wt); + bool invalidateProperty(SILProperty *p); + bool invalidateDifferentiabilityWitness(SILDifferentiabilityWitness *w); /// Deserialize all SILFunctions, VTables, and WitnessTables for /// a given Module. diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 8d1968a178d10..7cba818424469 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -1204,11 +1204,6 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args, Args.hasArg(OPT_sil_stop_optzns_before_lowering_ownership); if (const Arg *A = Args.getLastArg(OPT_external_pass_pipeline_filename)) Opts.ExternalPassPipelineFilename = A->getValue(); - // If our triple is a darwin triple, lower ownership on the stdlib after we - // serialize. - if (Triple.isOSDarwin()) { - Opts.SerializeStdlibWithOwnershipWithOpts = true; - } Opts.GenerateProfile |= Args.hasArg(OPT_profile_generate); const Arg *ProfileUse = Args.getLastArg(OPT_profile_use); diff --git a/lib/SIL/IR/SILModule.cpp b/lib/SIL/IR/SILModule.cpp index fbe26a3d4c7e5..717d94256c723 100644 --- a/lib/SIL/IR/SILModule.cpp +++ b/lib/SIL/IR/SILModule.cpp @@ -320,6 +320,7 @@ SILModule::createDefaultWitnessTableDeclaration(const ProtocolDecl *Protocol, void SILModule::deleteWitnessTable(SILWitnessTable *Wt) { auto Conf = Wt->getConformance(); assert(lookUpWitnessTable(Conf, false) == Wt); + getSILLoader()->invalidateWitnessTable(Wt); WitnessTableMap.erase(Conf); witnessTables.erase(Wt); } @@ -474,7 +475,7 @@ bool SILModule::hasFunction(StringRef Name) { } void SILModule::invalidateSILLoaderCaches() { - getSILLoader()->invalidateCaches(); + getSILLoader()->invalidateAllCaches(); } SILFunction *SILModule::removeFromZombieList(StringRef Name) { @@ -526,9 +527,10 @@ void SILModule::invalidateFunctionInSILCache(SILFunction *F) { } /// Erase a global SIL variable from the module. -void SILModule::eraseGlobalVariable(SILGlobalVariable *G) { - GlobalVariableMap.erase(G->getName()); - getSILGlobalList().erase(G); +void SILModule::eraseGlobalVariable(SILGlobalVariable *gv) { + getSILLoader()->invalidateGlobalVariable(gv); + GlobalVariableMap.erase(gv->getName()); + getSILGlobalList().erase(gv); } SILVTable *SILModule::lookUpVTable(const ClassDecl *C, diff --git a/lib/Serialization/DeserializeSIL.cpp b/lib/Serialization/DeserializeSIL.cpp index 8087bb3215078..b48d4ec4b2d8e 100644 --- a/lib/Serialization/DeserializeSIL.cpp +++ b/lib/Serialization/DeserializeSIL.cpp @@ -28,6 +28,7 @@ #include "swift/SIL/SILBuilder.h" #include "swift/SIL/SILDebugScope.h" #include "swift/SIL/SILModule.h" +#include "swift/SIL/SILProperty.h" #include "swift/SIL/SILUndef.h" #include "llvm/ADT/Statistic.h" @@ -2937,11 +2938,11 @@ SILGlobalVariable *SILDeserializer::readGlobalVar(StringRef Name) { assert(VId <= GlobalVars.size() && "invalid GlobalVar ID"); auto &globalVarOrOffset = GlobalVars[VId-1]; - if (globalVarOrOffset.isComplete()) - return globalVarOrOffset; + if (globalVarOrOffset.isFullyDeserialized()) + return globalVarOrOffset.get(); BCOffsetRAII restoreOffset(SILCursor); - if (llvm::Error Err = SILCursor.JumpToBit(globalVarOrOffset)) + if (llvm::Error Err = SILCursor.JumpToBit(globalVarOrOffset.getOffset())) MF->fatal(std::move(Err)); llvm::Expected maybeEntry = SILCursor.advance(AF_DontPopBlockAtEnd); @@ -2988,7 +2989,7 @@ SILGlobalVariable *SILDeserializer::readGlobalVar(StringRef Name) { None, dID ? cast(MF->getDecl(dID)): nullptr); v->setLet(IsLet); - globalVarOrOffset = v; + globalVarOrOffset.set(v, true /*isFullyDeserialized*/); v->setDeclaration(IsDeclaration); if (Callback) @@ -3087,11 +3088,11 @@ SILVTable *SILDeserializer::readVTable(DeclID VId) { assert(VId <= VTables.size() && "invalid VTable ID"); auto &vTableOrOffset = VTables[VId-1]; - if (vTableOrOffset.isComplete()) - return vTableOrOffset; + if (vTableOrOffset.isFullyDeserialized()) + return vTableOrOffset.get(); BCOffsetRAII restoreOffset(SILCursor); - if (llvm::Error Err = SILCursor.JumpToBit(vTableOrOffset)) + if (llvm::Error Err = SILCursor.JumpToBit(vTableOrOffset.getOffset())) MF->fatal(std::move(Err)); llvm::Expected maybeEntry = SILCursor.advance(AF_DontPopBlockAtEnd); @@ -3188,7 +3189,7 @@ SILVTable *SILDeserializer::readVTable(DeclID VId) { SILMod, theClass, Serialized ? IsSerialized : IsNotSerialized, vtableEntries); - vTableOrOffset = vT; + vTableOrOffset.set(vT, true /*isFullyDeserialized*/); if (Callback) Callback->didDeserialize(MF->getAssociatedModule(), vT); return vT; @@ -3819,3 +3820,127 @@ bool SILDeserializer::invalidateFunction(SILFunction *F) { } return false; } + +// Invalidate all cached SILGlobalVariable. +void SILDeserializer::invalidateGlobalVariableCache() { + for (auto &entry : GlobalVars) { + if (entry.isDeserialized()) { + entry.reset(); + } + } +} + +// Invalidate a specific cached GlobalVariable. +bool SILDeserializer::invalidateGlobalVariable(SILGlobalVariable *gv) { + for (auto &entry : GlobalVars) { + if (entry.isDeserialized() && entry.get() == gv) { + entry.reset(); + return true; + } + } + + return false; +} + +// Invalidate all cached SILVTable. +void SILDeserializer::invalidateVTableCache() { + for (auto &entry : VTables) { + if (entry.isDeserialized()) { + entry.reset(); + } + } +} + +// Invalidate a specific cached SILVTable. +bool SILDeserializer::invalidateVTable(SILVTable *v) { + for (auto &entry : VTables) { + if (entry.isDeserialized() && entry.get() == v) { + entry.reset(); + return true; + } + } + + return false; +} + +// Invalidate all cached SILWitnessTable. +void SILDeserializer::invalidateWitnessTableCache() { + for (auto &entry : WitnessTables) { + if (entry.isDeserialized()) { + entry.reset(); + } + } +} + +// Invalidate a specific cached SILWitnessTable. +bool SILDeserializer::invalidateWitnessTable(SILWitnessTable *wt) { + for (auto &entry : WitnessTables) { + if (entry.isDeserialized() && entry.get() == wt) { + entry.reset(); + return true; + } + } + return false; +} + +// Invalidate all cached SILDefaultWitnessTable. +void SILDeserializer::invalidateDefaultWitnessTableCache() { + for (auto &entry : DefaultWitnessTables) { + if (entry.isDeserialized()) { + entry.reset(); + } + } +} + +// Invalidate a specific cached SILDefaultWitnessTable. +bool SILDeserializer::invalidateDefaultWitnessTable( + SILDefaultWitnessTable *wt) { + for (auto &entry : DefaultWitnessTables) { + if (entry.isDeserialized() && entry.get() == wt) { + entry.reset(); + return true; + } + } + return false; +} + +// Invalidate all cached SILProperty. +void SILDeserializer::invalidatePropertyCache() { + for (auto &entry : Properties) { + if (entry.isDeserialized()) { + entry.reset(); + } + } +} + +// Invalidate a specific cached SILProperty. +bool SILDeserializer::invalidateProperty(SILProperty *p) { + for (auto &entry : Properties) { + if (entry.isDeserialized() && entry.get() == p) { + entry.reset(); + return true; + } + } + return false; +} + +// Invalidate all cached SILDifferentiabilityWitness. +void SILDeserializer::invalidateDifferentiabilityWitnessCache() { + for (auto &entry : DifferentiabilityWitnesses) { + if (entry.isDeserialized()) { + entry.reset(); + } + } +} + +// Invalidate a specific cached SILDifferentiabilityWitness. +bool SILDeserializer::invalidateDifferentiabilityWitness( + SILDifferentiabilityWitness *w) { + for (auto &entry : DifferentiabilityWitnesses) { + if (entry.isDeserialized() && entry.get() == w) { + entry.reset(); + return true; + } + } + return false; +} diff --git a/lib/Serialization/DeserializeSIL.h b/lib/Serialization/DeserializeSIL.h index df35889d1290c..b3d8a78cec28e 100644 --- a/lib/Serialization/DeserializeSIL.h +++ b/lib/Serialization/DeserializeSIL.h @@ -38,14 +38,24 @@ namespace swift { using SerializedFuncTable = llvm::OnDiskIterableChainedHashTable; + //----- + // Deserialization Caches + // + // NOTE: When adding more serialized tables to the deserializer, + // always add invalidate methods and make sure SILModule always + // invalidates the deserializer appropriately when it erases a + // value that we deserialized here. Otherwise, memory corruption + // may result. + std::unique_ptr FuncTable; MutableArrayRef> Funcs; - std::unique_ptr VTableList; - MutableArrayRef> VTables; - std::unique_ptr GlobalVarList; - MutableArrayRef> GlobalVars; + MutableArrayRef> + GlobalVars; + + std::unique_ptr VTableList; + MutableArrayRef> VTables; std::unique_ptr WitnessTableList; MutableArrayRef> @@ -63,6 +73,12 @@ namespace swift { ModuleFile::PartiallySerialized> DifferentiabilityWitnesses; + //----- + // End Deserialization Caches + // + // Before adding a new cache here, please read the comment at the + // beginning of the deserialization cache section. + /// A declaration will only llvm::DenseMap ConformanceToWitnessTableMap; @@ -176,6 +192,53 @@ namespace swift { /// Invalidate a specific cached SILFunction. bool invalidateFunction(SILFunction *F); + /// Invalidate all cached SILGlobalVariable. + void invalidateGlobalVariableCache(); + + /// Invalidate a specific cached GlobalVariable. + bool invalidateGlobalVariable(SILGlobalVariable *gv); + + /// Invalidate all cached SILVTable. + void invalidateVTableCache(); + + /// Invalidate a specific cached SILVTable. + bool invalidateVTable(SILVTable *v); + + /// Invalidate all cached SILWitnessTable. + void invalidateWitnessTableCache(); + + /// Invalidate a specific cached SILWitnessTable. + bool invalidateWitnessTable(SILWitnessTable *v); + + /// Invalidate all cached SILDefaultWitnessTable. + void invalidateDefaultWitnessTableCache(); + + /// Invalidate a specific cached SILDefaultWitnessTable. + bool invalidateDefaultWitnessTable(SILDefaultWitnessTable *v); + + /// Invalidate all cached SILProperty. + void invalidatePropertyCache(); + + /// Invalidate a specific cached SILProperty. + bool invalidateProperty(SILProperty *v); + + /// Invalidate all cached SILDifferentiabilityWitness. + void invalidateDifferentiabilityWitnessCache(); + + /// Invalidate a specific cached SILDifferentiabilityWitness. + bool invalidateDifferentiabilityWitness(SILDifferentiabilityWitness *v); + + /// Invalidate all caches in this deserializer. + void invalidateAllCaches() { + invalidateFunctionCache(); + invalidateGlobalVariableCache(); + invalidateVTableCache(); + invalidateWitnessTableCache(); + invalidateDefaultWitnessTableCache(); + invalidatePropertyCache(); + invalidateDifferentiabilityWitnessCache(); + } + /// Deserialize all SILFunctions, VTables, WitnessTables, and /// DefaultWitnessTables inside the module, and add them to SILMod. /// diff --git a/lib/Serialization/SerializedSILLoader.cpp b/lib/Serialization/SerializedSILLoader.cpp index b0e495690adc2..2b886c0b32ece 100644 --- a/lib/Serialization/SerializedSILLoader.cpp +++ b/lib/Serialization/SerializedSILLoader.cpp @@ -144,14 +144,58 @@ SerializedSILLoader::lookupDifferentiabilityWitness( return dw; } -void SerializedSILLoader::invalidateCaches() { - for (auto &Des : LoadedSILSections) - Des->invalidateFunctionCache(); +void SerializedSILLoader::invalidateAllCaches() { + for (auto &des : LoadedSILSections) + des->invalidateAllCaches(); } -bool SerializedSILLoader::invalidateFunction(SILFunction *F) { - for (auto &Des : LoadedSILSections) - if (Des->invalidateFunction(F)) +bool SerializedSILLoader::invalidateFunction(SILFunction *fn) { + for (auto &des : LoadedSILSections) + if (des->invalidateFunction(fn)) + return true; + return false; +} + +bool SerializedSILLoader::invalidateGlobalVariable(SILGlobalVariable *gv) { + for (auto &des : LoadedSILSections) + if (des->invalidateGlobalVariable(gv)) + return true; + return false; +} + +bool SerializedSILLoader::invalidateVTable(SILVTable *vt) { + for (auto &des : LoadedSILSections) + if (des->invalidateVTable(vt)) + return true; + return false; +} + +bool SerializedSILLoader::invalidateWitnessTable(SILWitnessTable *wt) { + for (auto &des : LoadedSILSections) + if (des->invalidateWitnessTable(wt)) + return true; + return false; +} + +bool SerializedSILLoader::invalidateDefaultWitnessTable( + SILDefaultWitnessTable *wt) { + for (auto &des : LoadedSILSections) + if (des->invalidateDefaultWitnessTable(wt)) + return true; + return false; +} + +bool SerializedSILLoader::invalidateProperty(SILProperty *p) { + for (auto &des : LoadedSILSections) + if (des->invalidateProperty(p)) + return true; + return false; +} + +bool SerializedSILLoader::invalidateDifferentiabilityWitness( + SILDifferentiabilityWitness *w) { + for (auto &des : LoadedSILSections) + if (des->invalidateDifferentiabilityWitness(w)) return true; return false; } diff --git a/test/SIL/Serialization/shared_function_serialization.sil b/test/SIL/Serialization/shared_function_serialization.sil index a7e4d65ab2797..67981f144922b 100644 --- a/test/SIL/Serialization/shared_function_serialization.sil +++ b/test/SIL/Serialization/shared_function_serialization.sil @@ -3,12 +3,9 @@ // RUN: %target-sil-opt -enable-sil-verify-all -I %t -performance-linker -inline %s -o - | %FileCheck %s // CHECK: sil private @top_level_code -// CHECK: sil public_external [serialized] @$ss1XVABycfC{{.*}} -// CHECK: sil public_external [serialized] @$ss17the_thing_it_does1xys1XV_tF{{.*}} -// CHECK: sil shared_external [serializable] [noinline] @$ss9the_thing1tyx_tlFs1XV_Tgq5{{.*}} - -// See shared_function_serialization_darwin.sil -// UNSUPPORTED: OS=macosx || OS=tvos || OS=watchos || OS=ios +// CHECK: sil public_external [serialized] [ossa] @$ss1XVABycfC{{.*}} +// CHECK: sil public_external [serialized] [ossa] @$ss17the_thing_it_does1xys1XV_tF{{.*}} +// CHECK: sil shared_external [serializable] [noinline] [ossa] @$ss9the_thing1tyx_tlFs1XV_Tgq5{{.*}} sil_stage canonical diff --git a/test/SIL/Serialization/shared_function_serialization_darwin.sil b/test/SIL/Serialization/shared_function_serialization_darwin.sil deleted file mode 100644 index 52dd85251f76a..0000000000000 --- a/test/SIL/Serialization/shared_function_serialization_darwin.sil +++ /dev/null @@ -1,42 +0,0 @@ -// RUN: %empty-directory(%t) -// RUN: %target-swift-frontend %S/Inputs/shared_function_serialization_input.swift -o %t/Swift.swiftmodule -emit-module -parse-as-library -parse-stdlib -module-link-name swiftCore -module-name Swift -O -// RUN: %target-sil-opt -enable-sil-verify-all -I %t -performance-linker -inline %s -o - | %FileCheck %s - -// CHECK: sil private @top_level_code -// CHECK: sil public_external [serialized] [ossa] @$ss1XVABycfC{{.*}} -// CHECK: sil public_external [serialized] [ossa] @$ss17the_thing_it_does1xys1XV_tF{{.*}} -// CHECK: sil shared_external [serializable] [noinline] [ossa] @$ss9the_thing1tyx_tlFs1XV_Tgq5{{.*}} - -// REQUIRES: OS=macosx || OS=tvos || OS=watchos || OS=ios - -sil_stage canonical - -import Builtin -import Swift - -sil_global @x : $X - -// top_level_code -sil private @top_level_code : $@convention(thin) () -> () { -bb0: - %0 = global_addr @x : $*X // users: %4, %6 - // function_ref Swift.X.init (Swift.X.Type)() -> Swift.X - %1 = function_ref @$ss1XVABycfC : $@convention(method) (@thin X.Type) -> X // user: %3 - %2 = metatype $@thin X.Type // user: %3 - %3 = apply %1(%2) : $@convention(method) (@thin X.Type) -> X // user: %4 - store %3 to %0 : $*X // id: %4 - // function_ref Swift.the_thing_it_does (x : Swift.X) -> () - %5 = function_ref @$ss17the_thing_it_does1xys1XV_tF : $@convention(thin) (X) -> () // user: %7 - %6 = load %0 : $*X // user: %7 - %7 = apply %5(%6) : $@convention(thin) (X) -> () - %8 = tuple () // user: %9 - return %8 : $() // id: %9 -} - -// Swift.X.init (Swift.X.Type)() -> Swift.X -sil @$ss1XVABycfC : $@convention(method) (@thin X.Type) -> X - -// Swift.the_thing_it_does (x : Swift.X) -> () -sil @$ss17the_thing_it_does1xys1XV_tF : $@convention(thin) (X) -> () - - diff --git a/test/Serialization/early-serialization-darwin.swift b/test/Serialization/early-serialization-darwin.swift deleted file mode 100644 index 607b901cf3ce7..0000000000000 --- a/test/Serialization/early-serialization-darwin.swift +++ /dev/null @@ -1,42 +0,0 @@ -// RUN: %empty-directory(%t) -// RUN: %target-swift-frontend -emit-module -O -module-name Swift -module-link-name swiftCore -parse-as-library -parse-stdlib -emit-module %s -o %t/Swift.swiftmodule -// RUN: %target-sil-opt -enable-sil-verify-all %t/Swift.swiftmodule -emit-sorted-sil -o - | %FileCheck %s - -// Test that early serialization works as expected: -// - it happens before the performance inlining and thus preserves @_semantics functions -// - it happens after generic specialization - -// REQUIRES: OS=macosx || OS=tvos || OS=watchos || OS=ios - -@frozen -public struct Int { - @inlinable - public init() {} -} - -@frozen -public struct Array { - @inlinable - public init() {} - - // Check that the generic version of a @_semantics function is preserved. - // CHECK: sil [serialized] [_semantics "array.get_capacity"] [canonical] [ossa] @$sSa12_getCapacitySiyF : $@convention(method) (Array) -> Int - @inlinable - @usableFromInline - @_semantics("array.get_capacity") - internal func _getCapacity() -> Int { - return Int() - } -} - -// Check that a specialized version of a function is produced -// CHECK: sil shared [serializable] [_semantics "array.get_capacity"] [canonical] [ossa] @$sSa12_getCapacitySiyFSi_Tgq5 : $@convention(method) (Array) -> Int - -// Check that a call of a @_semantics function was not inlined if early-serialization is enabled. -// CHECK: sil [serialized] [canonical] [ossa] @$ss28userOfSemanticsAnnotatedFuncySiSaySiGF -// CHECK: function_ref -// CHECK: apply -@inlinable -public func userOfSemanticsAnnotatedFunc(_ a: Array) -> Int { - return a._getCapacity() -} diff --git a/test/Serialization/early-serialization.swift b/test/Serialization/early-serialization.swift index f7ccb4df0372a..f09067435bb8b 100644 --- a/test/Serialization/early-serialization.swift +++ b/test/Serialization/early-serialization.swift @@ -6,8 +6,6 @@ // - it happens before the performance inlining and thus preserves @_semantics functions // - it happens after generic specialization -// UNSUPPORTED: OS=macosx || OS=tvos || OS=watchos || OS=ios - @frozen public struct Int { @inlinable @@ -20,7 +18,7 @@ public struct Array { public init() {} // Check that the generic version of a @_semantics function is preserved. - // CHECK: sil [serialized] [_semantics "array.get_capacity"] [canonical] @$sSa12_getCapacitySiyF : $@convention(method) (Array) -> Int + // CHECK: sil [serialized] [_semantics "array.get_capacity"] [canonical] [ossa] @$sSa12_getCapacitySiyF : $@convention(method) (Array) -> Int @inlinable @usableFromInline @_semantics("array.get_capacity") @@ -30,10 +28,10 @@ public struct Array { } // Check that a specialized version of a function is produced -// CHECK: sil shared [serializable] [_semantics "array.get_capacity"] [canonical] @$sSa12_getCapacitySiyFSi_Tgq5 : $@convention(method) (Array) -> Int +// CHECK: sil shared [serializable] [_semantics "array.get_capacity"] [canonical] [ossa] @$sSa12_getCapacitySiyFSi_Tgq5 : $@convention(method) (Array) -> Int // Check that a call of a @_semantics function was not inlined if early-serialization is enabled. -// CHECK: sil [serialized] [canonical] @$ss28userOfSemanticsAnnotatedFuncySiSaySiGF +// CHECK: sil [serialized] [canonical] [ossa] @$ss28userOfSemanticsAnnotatedFuncySiSaySiGF // CHECK: function_ref // CHECK: apply @inlinable diff --git a/test/sil-func-extractor/load-serialized-sil-darwin.swift b/test/sil-func-extractor/load-serialized-sil-darwin.swift deleted file mode 100644 index 4cba207bc4f92..0000000000000 --- a/test/sil-func-extractor/load-serialized-sil-darwin.swift +++ /dev/null @@ -1,62 +0,0 @@ -// RUN: %target-swift-frontend -primary-file %s -module-name Swift -g -module-link-name swiftCore -O -parse-as-library -parse-stdlib -emit-module -emit-module-path - -o /dev/null | %target-sil-func-extractor -module-name="Swift" -func='$ss1XV4testyyF' | %FileCheck %s -// RUN: %target-swift-frontend -primary-file %s -module-name Swift -g -O -parse-as-library -parse-stdlib -emit-sib -o - | %target-sil-func-extractor -module-name="Swift" -func='$ss1XV4testyyF' | %FileCheck %s -check-prefix=SIB-CHECK - -// REQUIRES: OS=macosx || OS=tvos || OS=watchos || OS=ios - -// CHECK: import Builtin -// CHECK: import Swift - -// CHECK: func unknown() - -// CHECK: struct X { -// CHECK-NEXT: @usableFromInline -// CHECK-NEXT: @inlinable func test() -// CHECK-NEXT: init -// CHECK-NEXT: } - -// CHECK-LABEL: sil [serialized] [canonical] [ossa] @$ss1XV4testyyF : $@convention(method) (X) -> () -// CHECK: bb0 -// CHECK-NEXT: function_ref -// CHECK-NEXT: function_ref @unknown : $@convention(thin) () -> () -// CHECK-NEXT: apply -// CHECK-NEXT: tuple -// CHECK-NEXT: return - -// CHECK: sil [canonical] @unknown : $@convention(thin) () -> () - -// CHECK-NOT: sil {{.*}} @$ss1XVABycfC : $@convention(thin) (@thin X.Type) -> X - - -// SIB-CHECK: import Builtin -// SIB-CHECK: import Swift - -// SIB-CHECK: func unknown() - -// SIB-CHECK: struct X { -// SIB-CHECK-NEXT: @usableFromInline -// SIB-CHECK-NEXT: @inlinable func test() -// SIB-CHECK-NEXT: init -// SIB-CHECK-NEXT: } - -// SIB-CHECK-LABEL: sil [serialized] [canonical] [ossa] @$ss1XV4testyyF : $@convention(method) (X) -> () -// SIB-CHECK: bb0 -// SIB-CHECK-NEXT: function_ref -// SIB-CHECK-NEXT: function_ref @unknown : $@convention(thin) () -> () -// SIB-CHECK-NEXT: apply -// SIB-CHECK-NEXT: tuple -// SIB-CHECK-NEXT: return - -// SIB-CHECK: sil [canonical] @unknown : $@convention(thin) () -> () - -// SIB-CHECK-NOT: sil {{.*}} @$ss1XVABycfC : $@convention(thin) (@thin X.Type) -> X - -@_silgen_name("unknown") -public func unknown() -> () - -public struct X { - @usableFromInline - @inlinable - func test() { - unknown() - } -} diff --git a/test/sil-func-extractor/load-serialized-sil.swift b/test/sil-func-extractor/load-serialized-sil.swift index 92597d489a428..2233e8cc199c7 100644 --- a/test/sil-func-extractor/load-serialized-sil.swift +++ b/test/sil-func-extractor/load-serialized-sil.swift @@ -1,8 +1,6 @@ // RUN: %target-swift-frontend -primary-file %s -module-name Swift -g -module-link-name swiftCore -O -parse-as-library -parse-stdlib -emit-module -emit-module-path - -o /dev/null | %target-sil-func-extractor -module-name="Swift" -func='$ss1XV4testyyF' | %FileCheck %s // RUN: %target-swift-frontend -primary-file %s -module-name Swift -g -O -parse-as-library -parse-stdlib -emit-sib -o - | %target-sil-func-extractor -module-name="Swift" -func='$ss1XV4testyyF' | %FileCheck %s -check-prefix=SIB-CHECK -// UNSUPPORTED: OS=macosx || OS=tvos || OS=watchos || OS=ios - // CHECK: import Builtin // CHECK: import Swift @@ -14,7 +12,7 @@ // CHECK-NEXT: init // CHECK-NEXT: } -// CHECK-LABEL: sil [serialized] [canonical] @$ss1XV4testyyF : $@convention(method) (X) -> () +// CHECK-LABEL: sil [serialized] [canonical] [ossa] @$ss1XV4testyyF : $@convention(method) (X) -> () // CHECK: bb0 // CHECK-NEXT: function_ref // CHECK-NEXT: function_ref @unknown : $@convention(thin) () -> () @@ -38,7 +36,7 @@ // SIB-CHECK-NEXT: init // SIB-CHECK-NEXT: } -// SIB-CHECK-LABEL: sil [serialized] [canonical] @$ss1XV4testyyF : $@convention(method) (X) -> () +// SIB-CHECK-LABEL: sil [serialized] [canonical] [ossa] @$ss1XV4testyyF : $@convention(method) (X) -> () // SIB-CHECK: bb0 // SIB-CHECK-NEXT: function_ref // SIB-CHECK-NEXT: function_ref @unknown : $@convention(thin) () -> () diff --git a/test/sil-opt/sil-opt-darwin.swift b/test/sil-opt/sil-opt-darwin.swift deleted file mode 100644 index c186c98212301..0000000000000 --- a/test/sil-opt/sil-opt-darwin.swift +++ /dev/null @@ -1,69 +0,0 @@ -// RUN: %target-swift-frontend -primary-file %s -module-name Swift -g -module-link-name swiftCore -O -parse-as-library -parse-stdlib -emit-module -emit-module-path - -o /dev/null | %target-sil-opt -enable-sil-verify-all -module-name="Swift" -emit-sorted-sil | %FileCheck %s -// RUN: %target-swift-frontend -primary-file %s -module-name Swift -g -O -parse-as-library -parse-stdlib -emit-sib -o - | %target-sil-opt -enable-sil-verify-all -module-name="Swift" -emit-sorted-sil | %FileCheck %s -check-prefix=SIB-CHECK - -// REQUIRES: OS=macosx || OS=tvos || OS=watchos || OS=ios - -// CHECK: import Builtin -// CHECK: import Swift - -// CHECK: func unknown() - -// CHECK: struct X { -// CHECK-NEXT: @inlinable func test() -// CHECK-NEXT: @inlinable init -// CHECK-NEXT: } - -// CHECK-LABEL: sil [serialized] [canonical] [ossa] @$ss1XV4testyyF : $@convention(method) (X) -> () -// CHECK: bb0 -// CHECK-NEXT: function_ref -// CHECK-NEXT: function_ref @unknown : $@convention(thin) () -> () -// CHECK-NEXT: apply -// CHECK-NEXT: tuple -// CHECK-NEXT: return - -// CHECK-LABEL: sil [serialized] [canonical] [ossa] @$ss1XVABycfC : $@convention(method) (@thin X.Type) -> X -// CHECK: bb0 -// CHECK-NEXT: struct $X () -// CHECK-NEXT: return - -// CHECK-LABEL: sil{{.*}} @unknown : $@convention(thin) () -> () - - -// SIB-CHECK: import Builtin -// SIB-CHECK: import Swift - -// SIB-CHECK: func unknown() - -// SIB-CHECK: struct X { -// SIB-CHECK-NEXT: func test() -// SIB-CHECK-NEXT: init -// SIB-CHECK-NEXT: } - -// SIB-CHECK-LABEL: sil [serialized] [canonical] [ossa] @$ss1XV4testyyF : $@convention(method) (X) -> () -// SIB-CHECK: bb0 -// SIB-CHECK-NEXT: function_ref -// SIB-CHECK-NEXT: function_ref @unknown : $@convention(thin) () -> () -// SIB-CHECK-NEXT: apply -// SIB-CHECK-NEXT: tuple -// SIB-CHECK-NEXT: return - -// SIB-CHECK-LABEL: sil [serialized] [canonical] [ossa] @$ss1XVABycfC : $@convention(method) (@thin X.Type) -> X -// SIB-CHECK: bb0 -// SIB-CHECK-NEXT: struct $X () -// SIB-CHECK-NEXT: return - -// SIB-CHECK-LABEL: sil [canonical] @unknown : $@convention(thin) () -> () - -@_silgen_name("unknown") -public func unknown() -> () - -@frozen -public struct X { - @inlinable - public func test() { - unknown() - } - - @inlinable - public init() {} -} diff --git a/test/sil-opt/sil-opt.swift b/test/sil-opt/sil-opt.swift index fa3eb69eae380..a51e9d32e62d9 100644 --- a/test/sil-opt/sil-opt.swift +++ b/test/sil-opt/sil-opt.swift @@ -1,8 +1,6 @@ // RUN: %target-swift-frontend -primary-file %s -module-name Swift -g -module-link-name swiftCore -O -parse-as-library -parse-stdlib -emit-module -emit-module-path - -o /dev/null | %target-sil-opt -enable-sil-verify-all -module-name="Swift" -emit-sorted-sil | %FileCheck %s // RUN: %target-swift-frontend -primary-file %s -module-name Swift -g -O -parse-as-library -parse-stdlib -emit-sib -o - | %target-sil-opt -enable-sil-verify-all -module-name="Swift" -emit-sorted-sil | %FileCheck %s -check-prefix=SIB-CHECK -// UNSUPPORTED: OS=macosx || OS=tvos || OS=watchos || OS=ios - // CHECK: import Builtin // CHECK: import Swift @@ -13,7 +11,7 @@ // CHECK-NEXT: @inlinable init // CHECK-NEXT: } -// CHECK-LABEL: sil [serialized] [canonical] @$ss1XV4testyyF : $@convention(method) (X) -> () +// CHECK-LABEL: sil [serialized] [canonical] [ossa] @$ss1XV4testyyF : $@convention(method) (X) -> () // CHECK: bb0 // CHECK-NEXT: function_ref // CHECK-NEXT: function_ref @unknown : $@convention(thin) () -> () @@ -21,7 +19,7 @@ // CHECK-NEXT: tuple // CHECK-NEXT: return -// CHECK-LABEL: sil [serialized] [canonical] @$ss1XVABycfC : $@convention(method) (@thin X.Type) -> X +// CHECK-LABEL: sil [serialized] [canonical] [ossa] @$ss1XVABycfC : $@convention(method) (@thin X.Type) -> X // CHECK: bb0 // CHECK-NEXT: struct $X () // CHECK-NEXT: return @@ -39,7 +37,7 @@ // SIB-CHECK-NEXT: init // SIB-CHECK-NEXT: } -// SIB-CHECK-LABEL: sil [serialized] [canonical] @$ss1XV4testyyF : $@convention(method) (X) -> () +// SIB-CHECK-LABEL: sil [serialized] [canonical] [ossa] @$ss1XV4testyyF : $@convention(method) (X) -> () // SIB-CHECK: bb0 // SIB-CHECK-NEXT: function_ref // SIB-CHECK-NEXT: function_ref @unknown : $@convention(thin) () -> () @@ -47,7 +45,7 @@ // SIB-CHECK-NEXT: tuple // SIB-CHECK-NEXT: return -// SIB-CHECK-LABEL: sil [serialized] [canonical] @$ss1XVABycfC : $@convention(method) (@thin X.Type) -> X +// SIB-CHECK-LABEL: sil [serialized] [canonical] [ossa] @$ss1XVABycfC : $@convention(method) (@thin X.Type) -> X // SIB-CHECK: bb0 // SIB-CHECK-NEXT: struct $X () // SIB-CHECK-NEXT: return