diff --git a/include/swift/AST/SILOptions.h b/include/swift/AST/SILOptions.h index 54db164cc6d..9348e4d74f4 100644 --- a/include/swift/AST/SILOptions.h +++ b/include/swift/AST/SILOptions.h @@ -90,7 +90,7 @@ public: bool EnableFuncSigOpts = true; /// Should we emit self as a guaranteed parameter? - bool EnableGuaranteedSelf = false; + bool EnableGuaranteedSelf = true; /// Instrument code to generate profiling information. bool GenerateProfile = false; diff --git a/include/swift/AST/Types.h b/include/swift/AST/Types.h index 1d01f75cc55..3a6cb95fe8b 100644 --- a/include/swift/AST/Types.h +++ b/include/swift/AST/Types.h @@ -2718,7 +2718,21 @@ public: return true; } } - + + bool hasGuaranteedSelfParam() const { + switch (getRepresentation()) { + case Representation::Thick: + case Representation::Block: + case Representation::Thin: + case Representation::CFunctionPointer: + case Representation::ObjCMethod: + return false; + case Representation::Method: + case Representation::WitnessMethod: + return true; + } + } + /// True if the function representation carries context. bool hasContext() const { switch (getRepresentation()) { diff --git a/lib/SIL/Verifier.cpp b/lib/SIL/Verifier.cpp index 5ca93c61687..e913b24b1c7 100644 --- a/lib/SIL/Verifier.cpp +++ b/lib/SIL/Verifier.cpp @@ -2647,13 +2647,10 @@ public: void verifySILFunctionType(CanSILFunctionType FTy) { // Make sure that if FTy's calling convention implies that it must have a - // self parameter, it is not empty if we do not have canonical sil. - if (F.getModule().getStage() == SILStage::Raw && - FTy->hasSelfParam()) { - require(!FTy->getParameters().empty(), - "Functions with a calling convention with self parameter must " - "have at least one argument for self."); - } + // self parameter. + require(!FTy->hasSelfParam() || !FTy->getParameters().empty(), + "Functions with a calling convention with self parameter must " + "have at least one argument for self."); // Make sure that FTy does not have any out parameters except for the first // parameter. @@ -2784,6 +2781,40 @@ public: SILVisitor::visitSILBasicBlock(BB); } + void verifySILSelfParameterType(SILFunction *F, CanSILFunctionType FTy) { + SILModule &M = F->getModule(); + SILParameterInfo PInfo = FTy->getSelfParameter(); + CanType CTy = PInfo.getType(); + SILType Ty = SILType::getPrimitiveObjectType(CTy); + + // We do not care about trivial parameters (for now). There seem to be + // cases where we lower them as unowned. + // + // *NOTE* We do not run this check when we have a generic type since + // *generic types do not have type lowering and are always treated as + // *non-trivial since we do not know the type. + if (CTy->hasArchetype() || CTy->isDependentType() || + M.getTypeLowering(Ty).isTrivial()) + return; + + // If we don't have a decl ref, return. + auto DeclRef = M.lookUpDeclRef(F); + if (!DeclRef) + return; + + // If this function is a constructor or destructor, bail. These have @owned + // parameters. + if (DeclRef.getValue().isConstructor() || DeclRef.getValue().isDestructor()) + return; + + // Otherwise, if this function type has a guaranteed self parameter type, + // make sure that we have a +0 self param. + require(!FTy->getExtInfo().hasGuaranteedSelfParam() || + PInfo.isGuaranteed() || PInfo.isIndirectInOut(), + "Function with guaranteed self, but self param is not " + "+0?!"); + } + void visitSILFunction(SILFunction *F) { PrettyStackTraceSILFunction stackTrace("verifying", F); @@ -2802,6 +2833,13 @@ public: CanSILFunctionType FTy = F->getLoweredFunctionType(); verifySILFunctionType(FTy); + // If this function has a self parameter, make sure that it has a +0 calling + // convention. This can not be done for general function types, since + // function_ref's SILFunctionTypes do not have archetypes associated with + // it. + if (F->getModule().getStage() == SILStage::Canonical && FTy->hasSelfParam()) + verifySILSelfParameterType(F, FTy); + if (F->isExternalDeclaration()) { assert(F->isAvailableExternally() && "external declaration of internal SILFunction not allowed"); diff --git a/lib/SILGen/SILGenPoly.cpp b/lib/SILGen/SILGenPoly.cpp index 3efc0349104..c69c62687c4 100644 --- a/lib/SILGen/SILGenPoly.cpp +++ b/lib/SILGen/SILGenPoly.cpp @@ -1643,8 +1643,13 @@ void SILGenFunction::emitProtocolWitness(ProtocolConformance *conformance, if (selfInstanceType.getClassOrBoundGenericClass()) { if (selfInstanceType != witnessInstanceType) { - SILValue upcast = B.createUpcast(loc, selfOrigParam.getValue(), - SILType::getPrimitiveObjectType(witnessType)); + // Match the category of selfOrigParam. We leave the loading to + // TranslateArguments. + auto upcastCategory = selfOrigParam.getValue().getType().getCategory(); + SILType upcastTy = + SILType::getPrimitiveType(witnessType, upcastCategory); + SILValue upcast = + B.createUpcast(loc, selfOrigParam.getValue(), upcastTy); selfOrigParam = ManagedValue(upcast, selfOrigParam.getCleanup()); } } else { diff --git a/lib/SILPasses/DefiniteInitialization.cpp b/lib/SILPasses/DefiniteInitialization.cpp index a9dba55f0b0..bd559a558c1 100644 --- a/lib/SILPasses/DefiniteInitialization.cpp +++ b/lib/SILPasses/DefiniteInitialization.cpp @@ -1053,10 +1053,15 @@ void LifetimeChecker::handleLoadUseFailure(const DIMemoryUse &Use, } } - // If the upcast is used by a class_method + apply, then this is a call of - // a superclass method or property accessor. + // If the upcast is used by a class_method + apply, then this is a call of a + // superclass method or property accessor. If we have a guaranteed method, + // we will have a release due to a missing optimization in SILGen that will + // be removed. + // + // TODO: Implement the SILGen fixes so this can be removed. ClassMethodInst *CMI = nullptr; ApplyInst *AI = nullptr; + SILInstruction *Release = nullptr; for (auto UI : SILValue(UCI, 0).getUses()) { auto *User = UI->getUser(); if (auto *TAI = dyn_cast(User)) { @@ -1072,12 +1077,27 @@ void LifetimeChecker::handleLoadUseFailure(const DIMemoryUse &Use, } } + if (isa(User) || isa(User)) { + if (!Release) { + Release = User; + continue; + } + } + // Not a pattern we recognize, conservatively generate a generic // diagnostic. CMI = nullptr; break; } + // If we have a release, make sure that AI is guaranteed. If it is not, emit + // the generic error that we would emit before. + // + // That is the only case where we support pattern matching a release. + if (Release && + !AI->getSubstCalleeType()->getExtInfo().hasGuaranteedSelfParam()) + CMI = nullptr; + if (AI && CMI) { // TODO: Could handle many other members more specifically. auto *Decl = CMI->getMember().getDecl(); diff --git a/test/ClangModules/optional.swift b/test/ClangModules/optional.swift index bb784cb6d18..14a11edcbbc 100644 --- a/test/ClangModules/optional.swift +++ b/test/ClangModules/optional.swift @@ -14,6 +14,7 @@ class A { // CHECK: sil hidden @_TToFC8optional1A3foofS0_FT_GSqSS_ : $@cc(objc_method) @thin (A) -> @autoreleased Optional // CHECK: [[T0:%.*]] = function_ref @_TFC8optional1A3foofS0_FT_GSqSS_ // CHECK-NEXT: [[T1:%.*]] = apply [[T0]](%0) +// CHECK-NEXT: strong_release // CHECK-NEXT: [[TMP_OPTNSSTR:%.*]] = alloc_stack $Optional // CHECK-NEXT: [[TMP_OPTSTR:%.*]] = alloc_stack $Optional // CHECK-NEXT: store [[T1]] to [[TMP_OPTSTR]]#1 @@ -64,6 +65,7 @@ class A { // CHECK-NEXT: dealloc_stack [[TMP_OPTSTR]] // CHECK: [[T1:%.*]] = function_ref @_TFC8optional1A3barfS0_FT1xGSqSS__T_ // CHECK-NEXT: [[T2:%.*]] = apply [[T1]]([[T0]], %1) +// CHECK-NEXT: strong_release %1 // CHECK-NEXT: return [[T2]] : $() } diff --git a/test/DebugInfo/linetable.swift b/test/DebugInfo/linetable.swift index 4b7b4589c35..009ae2365fd 100644 --- a/test/DebugInfo/linetable.swift +++ b/test/DebugInfo/linetable.swift @@ -36,6 +36,7 @@ func main(x: Int) -> Void { var result = my_class.do_something(x) print ("Here is something you might consider doing: \(result).\n") +// CHECK: call {{.*}} @swift_release {{.*}} // CHECK: call {{.*}} @swift_release {{.*}}, !dbg ![[CLOSURE_END:.*]] // CHECK-NEXT: ret void, !dbg ![[CLOSURE_END]] // CHECK: ![[CLOSURE_END]] = !MDLocation(line: [[@LINE+1]], diff --git a/test/DebugInfo/return.swift b/test/DebugInfo/return.swift index 562096e9585..eb95f6ee806 100644 --- a/test/DebugInfo/return.swift +++ b/test/DebugInfo/return.swift @@ -12,7 +12,6 @@ public func ifelseexpr() -> Int { // CHECK: [[X:%.*]] = call %C6return1X* @_TFC6return1XCfMS0_FT1iSi_S0_(i{{32|64}} 0, %swift.type* [[META]]) // CHECK: @swift_release to void (%C6return1X*)*)(%C6return1X* [[X]]) if true { - // CHECK: @swift_release to void (%C6return1X*)*)(%C6return1X* [[X]]) x.x++; } else { x.x--; diff --git a/test/IRGen/class.sil b/test/IRGen/class.sil index 0687ed76bde..364c27e68f6 100644 --- a/test/IRGen/class.sil +++ b/test/IRGen/class.sil @@ -120,7 +120,7 @@ bb0(%0 : $D): return %1 : $() } -sil hidden @_TFC5class1D8multiplyfS0_fT1xBi8__FT1yBi16__Bi32_ : $@cc(method) @thin (Builtin.Int16, Builtin.Int8, @owned D) -> Builtin.Int32 { +sil hidden @_TFC5class1D8multiplyfS0_fT1xBi8__FT1yBi16__Bi32_ : $@cc(method) @thin (Builtin.Int16, Builtin.Int8, @guaranteed D) -> Builtin.Int32 { bb0(%0 : $Builtin.Int16, %1 : $Builtin.Int8, %2 : $D): %3 = integer_literal $Builtin.Int32, 0 return %3 : $Builtin.Int32 diff --git a/test/IRGen/class_bounded_generics.swift b/test/IRGen/class_bounded_generics.swift index bd49c531c9f..e760dd1209b 100644 --- a/test/IRGen/class_bounded_generics.swift +++ b/test/IRGen/class_bounded_generics.swift @@ -93,7 +93,6 @@ func class_bounded_archetype_method(x: T, y: T) { x.classBoundBinaryMethod(y) // CHECK: [[WITNESS_ENTRY:%.*]] = getelementptr inbounds i8*, i8** %T.ClassBoundBinary, i32 1 // CHECK: [[WITNESS:%.*]] = load i8*, i8** [[WITNESS_ENTRY]], align 8 - // CHECK: call void bitcast (void (%swift.refcounted*)* @swift_unknownRetain to void (%objc_object*)*)(%objc_object* %0) // CHECK: call void bitcast (void (%swift.refcounted*)* @swift_unknownRetain to void (%objc_object*)*)(%objc_object* [[Y:%.*]]) // CHECK: [[WITNESS_FUNC:%.*]] = bitcast i8* [[WITNESS]] to void (%objc_object*, %objc_object*, %swift.type*) // CHECK: call void [[WITNESS_FUNC]](%objc_object* [[Y]], %objc_object* %0, %swift.type* {{.*}}) diff --git a/test/IRGen/class_isa_pointers.sil b/test/IRGen/class_isa_pointers.sil index eeaf1aff0b2..a0b05156b94 100644 --- a/test/IRGen/class_isa_pointers.sil +++ b/test/IRGen/class_isa_pointers.sil @@ -24,8 +24,8 @@ sil_vtable Purebred {} // CHECK: getelementptr inbounds {{.*}} [[VTABLE]] sil @purebred_method : $@thin (@owned Purebred) -> () { entry(%0 : $Purebred): - %m = class_method %0 : $Purebred, #Purebred.method!1 : Purebred -> () -> (), $@cc(method) @thin (@owned Purebred) -> () - %z = apply %m(%0) : $@cc(method) @thin (@owned Purebred) -> () + %m = class_method %0 : $Purebred, #Purebred.method!1 : Purebred -> () -> (), $@cc(method) @thin (@guaranteed Purebred) -> () + %z = apply %m(%0) : $@cc(method) @thin (@guaranteed Purebred) -> () return %z : $() } @@ -48,8 +48,8 @@ sil_vtable Mongrel {} // CHECK: getelementptr inbounds {{.*}} [[VTABLE]] sil @mongrel_method : $@thin (@owned Mongrel) -> () { entry(%0 : $Mongrel): - %m = class_method %0 : $Mongrel, #Mongrel.method!1 : Mongrel -> () -> (), $@cc(method) @thin (@owned Mongrel) -> () - %z = apply %m(%0) : $@cc(method) @thin (@owned Mongrel) -> () + %m = class_method %0 : $Mongrel, #Mongrel.method!1 : Mongrel -> () -> (), $@cc(method) @thin (@guaranteed Mongrel) -> () + %z = apply %m(%0) : $@cc(method) @thin (@guaranteed Mongrel) -> () return %z : $() } diff --git a/test/IRGen/deallocate.swift b/test/IRGen/deallocate.swift index e78f445432c..6634135b501 100644 --- a/test/IRGen/deallocate.swift +++ b/test/IRGen/deallocate.swift @@ -14,8 +14,6 @@ class CustomDeallocator { // CHECK: define hidden void @_TFC10deallocate17CustomDeallocatorD([[CD:%.*]]* // CHECK: [[T0:%.*]] = call [[OBJECT:%.*]]* @_TFC10deallocate17CustomDeallocatord( // CHECK-NEXT: [[T1:%.*]] = bitcast [[OBJECT]]* [[T0]] to [[CD]]* -// CHECK-NEXT: [[T2:%.*]] = bitcast [[CD]]* [[T1]] to [[OBJECT]]* -// CHECK-NEXT: call void @swift_retain_noresult([[OBJECT]]* [[T2]]) // CHECK-NEXT: [[T3:%.*]] = call { i64, i64 } @_TFC10deallocate17CustomDeallocator29__getInstanceSizeAndAlignMaskfS0_FT_TSiSi_([[CD]]* [[T1]]) // CHECK-NEXT: [[SIZE:%.*]] = extractvalue { i64, i64 } [[T3]], 0 // CHECK-NEXT: [[ALIGNMASK:%.*]] = extractvalue { i64, i64 } [[T3]], 1 diff --git a/test/IRGen/dynamic_self_metadata.swift b/test/IRGen/dynamic_self_metadata.swift index 2e20ed53a37..a131062309b 100644 --- a/test/IRGen/dynamic_self_metadata.swift +++ b/test/IRGen/dynamic_self_metadata.swift @@ -23,6 +23,5 @@ class C { // CHECK: store i64 0, i64* [[CAST1]], align 8 // CHECK: [[CAST2:%[a-zA-Z0-9]+]] = bitcast [[TYPE]]* [[ALLOCA]] to i64* // CHECK: [[LOAD:%[a-zA-Z0-9]+]] = load i64, i64* [[CAST2]], align 8 - // CHECK: call void bitcast (void (%swift.refcounted*)* @swift_release to void (%C21dynamic_self_metadata1C*)*)(%C21dynamic_self_metadata1C* %0) // CHECK: ret i64 [[LOAD]] } diff --git a/test/IRGen/exactcast.sil b/test/IRGen/exactcast.sil index e51be4464c2..e64ffa26fcd 100644 --- a/test/IRGen/exactcast.sil +++ b/test/IRGen/exactcast.sil @@ -22,7 +22,7 @@ class ParentNode : Node { } // pic_crash.Node.init (pic_crash.Node.Type)(index : Swift.Int) -> pic_crash.Node -sil @_TFC9pic_crash4Node5checkfS0_FT_Si : $@cc(method) @thin (@owned Node) -> Int { +sil @_TFC9pic_crash4Node5checkfS0_FT_Si : $@cc(method) @thin (@guaranteed Node) -> Int { bb0(%0 : $Node): //CHECK-LABEL: @_TFC9pic_crash4Node5checkfS0_FT_Si //CHECK: load %swift.type @@ -42,13 +42,13 @@ bb3: // Preds: bb0 sil @_TFC9pic_crash4NodecfMS0_FT5indexSi_S0_ : $@cc(method) @thin (Int, @owned Node) -> @owned Node sil @_TFC9pic_crash4NodeCfMS0_FT5indexSi_S0_ : $@thin (Int, @thick Node.Type) -> @owned Node -sil [transparent] @_TFC9pic_crash4Nodeg5indexSi : $@cc(method) @thin (@owned Node) -> Int -sil [transparent] @_TFC9pic_crash4Nodes5indexSi : $@cc(method) @thin (Int, @owned Node) -> () +sil [transparent] @_TFC9pic_crash4Nodeg5indexSi : $@cc(method) @thin (@guaranteed Node) -> Int +sil [transparent] @_TFC9pic_crash4Nodes5indexSi : $@cc(method) @thin (Int, @guaranteed Node) -> () sil @_TFC9pic_crash10ParentNodecfMS0_FT4leftCS_4Node5rightS1_5indexSi_S0_ : $@cc(method) @thin (@owned Node, @owned Node, Int, @owned ParentNode) -> @owned ParentNode sil @_TFC9pic_crash10ParentNodeCfMS0_FT4leftCS_4Node5rightS1_5indexSi_S0_ : $@thin (@owned Node, @owned Node, Int, @thick ParentNode.Type) -> @owned ParentNode -sil @_TFC9pic_crash10ParentNoded : $@cc(method) @thin (@owned ParentNode) -> @owned Builtin.NativeObject -sil @_TFC9pic_crash10ParentNodeD : $@cc(method) @thin (@owned ParentNode) -> () -sil @_TFC9pic_crash10ParentNodecfMS0_FT5indexSi_S0_ : $@cc(method) @thin (Int, @owned ParentNode) -> @owned ParentNode +sil @_TFC9pic_crash10ParentNoded : $@cc(method) @thin (@guaranteed ParentNode) -> @owned Builtin.NativeObject +sil @_TFC9pic_crash10ParentNodeD : $@cc(method) @thin (@guaranteed ParentNode) -> () +sil @_TFC9pic_crash10ParentNodecfMS0_FT5indexSi_S0_ : $@cc(method) @thin (Int, @owned ParentNode) -> @owned ParentNode sil @_TFC9pic_crash10ParentNodeCfMS0_FT5indexSi_S0_ : $@thin (Int, @thick ParentNode.Type) -> @owned ParentNode sil_vtable Node { diff --git a/test/IRGen/exactcast2.sil b/test/IRGen/exactcast2.sil index db74775a640..f267b140741 100644 --- a/test/IRGen/exactcast2.sil +++ b/test/IRGen/exactcast2.sil @@ -24,9 +24,9 @@ sil @_TFC4main4HashcfMS0_FT_S0_ : $@cc(method) @thin (@owned Hash) -> @owned Has sil @_TFC4main4HashCfMS0_FT_S0_ : $@thin (@thick Hash.Type) -> @owned Hash // main.Hash.update (main.Hash)() -> () -sil @_TFC4main4Hash6updatefS0_FT_T_ : $@cc(method) @thin (@owned Hash) -> () { +sil @_TFC4main4Hash6updatefS0_FT_T_ : $@cc(method) @thin (@guaranteed Hash) -> () { bb0(%0 : $Hash): - %1 = class_method %0 : $Hash, #Hash.hash!1 : Hash -> () -> () , $@cc(method) @thin (@owned Hash) -> () // user: %9 + %1 = class_method %0 : $Hash, #Hash.hash!1 : Hash -> () -> () , $@cc(method) @thin (@guaranteed Hash) -> () // user: %9 checked_cast_br [exact] %0 : $Hash to $MD5, bb2, bb3 // id: %2 bb1: // Preds: bb2 bb3 @@ -34,16 +34,14 @@ bb1: // Preds: bb2 bb3 return %3 : $() // id: %4 bb2(%5 : $MD5): // Preds: bb0 - %6 = upcast %5 : $MD5 to $Hash // user: %7 - strong_release %6 : $Hash // id: %7 br bb1 // id: %8 bb3: // Preds: bb0 - %9 = apply %1(%0) : $@cc(method) @thin (@owned Hash) -> () + %9 = apply %1(%0) : $@cc(method) @thin (@guaranteed Hash) -> () br bb1 // id: %10 } -sil @_TFC4main4Hash4hashfS0_FT_T_ : $@cc(method) @thin (@owned Hash) -> () +sil @_TFC4main4Hash4hashfS0_FT_T_ : $@cc(method) @thin (@guaranteed Hash) -> () sil @_TFC4main4Hashd : $@cc(method) @thin (@owned Hash) -> @owned Builtin.NativeObject sil @_TFC4main4HashD : $@cc(method) @thin (@owned Hash) -> () sil @_TFC4main3MD5cfMS0_FT_S0_ : $@cc(method) @thin (@owned MD5) -> @owned MD5 diff --git a/test/IRGen/generic_classes.sil b/test/IRGen/generic_classes.sil index 564f7c552db..8f8c5cfba5c 100644 --- a/test/IRGen/generic_classes.sil +++ b/test/IRGen/generic_classes.sil @@ -124,11 +124,11 @@ class RootGeneric { } sil @_TFC15generic_classes11RootGenericD : $@cc(method) @thin (RootGeneric) -> () -sil @_TFC15generic_classes11RootGeneric3fooU__fGS0_Q__FT_T_ : $@cc(method) @thin (@owned RootGeneric) -> () +sil @_TFC15generic_classes11RootGeneric3fooU__fGS0_Q__FT_T_ : $@cc(method) @thin (@guaranteed RootGeneric) -> () -sil @_TFC15generic_classes11RootGeneric3barU__fGS0_Q__FT_T_ : $@cc(method) @thin (@owned RootGeneric) -> () +sil @_TFC15generic_classes11RootGeneric3barU__fGS0_Q__FT_T_ : $@cc(method) @thin (@guaranteed RootGeneric) -> () -sil @_TFC15generic_classes11RootGeneric3basU__fGS0_Q__FT_T_ : $@cc(method) @thin (@owned RootGeneric) -> () +sil @_TFC15generic_classes11RootGeneric3basU__fGS0_Q__FT_T_ : $@cc(method) @thin (@guaranteed RootGeneric) -> () sil_vtable RootGeneric { #RootGeneric.foo!1: _TFC15generic_classes11RootGeneric3fooU__fGS0_Q__FT_T_ @@ -167,11 +167,11 @@ class GenericInheritsGeneric : RootGeneric { } sil @_TFC15generic_classes22GenericInheritsGenericD : $@cc(method) @thin (GenericInheritsGeneric) -> () -sil @_TFC15generic_classes22GenericInheritsGeneric7zippityU___fGS0_Q_Q0__FT_T_ : $@cc(method) @thin (@owned GenericInheritsGeneric) -> () +sil @_TFC15generic_classes22GenericInheritsGeneric7zippityU___fGS0_Q_Q0__FT_T_ : $@cc(method) @thin (@guaranteed GenericInheritsGeneric) -> () -sil @_TFC15generic_classes22GenericInheritsGeneric3dooU___fGS0_Q_Q0__FT_T_ : $@cc(method) @thin (@owned GenericInheritsGeneric) -> () +sil @_TFC15generic_classes22GenericInheritsGeneric3dooU___fGS0_Q_Q0__FT_T_ : $@cc(method) @thin (@guaranteed GenericInheritsGeneric) -> () -sil @_TFC15generic_classes22GenericInheritsGeneric3dahU___fGS0_Q_Q0__FT_T_ : $@cc(method) @thin (@owned GenericInheritsGeneric) -> () +sil @_TFC15generic_classes22GenericInheritsGeneric3dahU___fGS0_Q_Q0__FT_T_ : $@cc(method) @thin (@guaranteed GenericInheritsGeneric) -> () sil_vtable GenericInheritsGeneric { #RootGeneric.foo!1: _TFC15generic_classes11RootGeneric3fooU__fGS0_Q__FT_T_ diff --git a/test/SIL/Parser/basic.sil b/test/SIL/Parser/basic.sil index ffe60e8151b..cd4bd3569e3 100644 --- a/test/SIL/Parser/basic.sil +++ b/test/SIL/Parser/basic.sil @@ -217,7 +217,7 @@ bb0: %O = unchecked_ref_cast %C : $C to $Builtin.UnknownObject // CHECK: class_method {{.*}} : $C, #C.doIt!1 - %2 = class_method %C : $C, #C.doIt!1 : C -> () -> () , $@cc(method) @thin (@owned C) -> () + %2 = class_method %C : $C, #C.doIt!1 : C -> () -> () , $@cc(method) @thin (@guaranteed C) -> () // CHECK: alloc_ref $D %D = alloc_ref $D diff --git a/test/SIL/Serialization/deserialize_generic.sil b/test/SIL/Serialization/deserialize_generic.sil index 88310bf530f..4a8def8d031 100644 --- a/test/SIL/Serialization/deserialize_generic.sil +++ b/test/SIL/Serialization/deserialize_generic.sil @@ -1,7 +1,7 @@ // RUN: rm -rf %t // RUN: mkdir %t // RUN: %target-swift-frontend -emit-module -sil-serialize-all -o %t %S/Inputs/def_generic.swift -// RUN: %target-sil-opt -linker -I %t %s | FileCheck %s +// RUN: %target-sil-opt -enable-guaranteed-self -linker -I %t %s | FileCheck %s // Make sure that SILFunctionType with GenericSignature can match up with // SILFunctionType deserialized from module. @@ -16,11 +16,11 @@ import Swift // CHECK: function_ref @_TFC11def_generic1A23convertFromArrayLiteralU__fGS0_Q__FtGSaQ___GS0_Q__ sil @top_level_code : $@thin () -> () { bb0: - %3 = function_ref @_TFC11def_generic1A23convertFromArrayLiteralU__fGS0_Q__FtGSaQ___GS0_Q__ : $@cc(method) @thin (@owned Array, @owned A) -> @owned A + %3 = function_ref @_TFC11def_generic1A23convertFromArrayLiteralU__fGS0_Q__FtGSaQ___GS0_Q__ : $@cc(method) @thin (@owned Array, @guaranteed A) -> @owned A %0 = tuple () // user: %1 return %0 : $() // id: %1 } // Make sure the function body is deserialized. -// CHECK-LABEL: @_TFC11def_generic1A23convertFromArrayLiteralU__fGS0_Q__FtGSaQ___GS0_Q__ : $@cc(method) @thin (@owned Array, @owned A) -> @owned A { -sil @_TFC11def_generic1A23convertFromArrayLiteralU__fGS0_Q__FtGSaQ___GS0_Q__ : $@cc(method) @thin (@owned Array, @owned A) -> @owned A +// CHECK-LABEL: @_TFC11def_generic1A23convertFromArrayLiteralU__fGS0_Q__FtGSaQ___GS0_Q__ : $@cc(method) @thin (@owned Array, @guaranteed A) -> @owned A { +sil @_TFC11def_generic1A23convertFromArrayLiteralU__fGS0_Q__FtGSaQ___GS0_Q__ : $@cc(method) @thin (@owned Array, @guaranteed A) -> @owned A diff --git a/test/SILGen/accessors.swift b/test/SILGen/accessors.swift index ca2b01858f2..481c0e5e076 100644 --- a/test/SILGen/accessors.swift +++ b/test/SILGen/accessors.swift @@ -35,7 +35,6 @@ func test0(ref: A) { // CHECK-NEXT: [[INDEX1:%.*]] = apply [[T0]]() // Formal access to RHS. // CHECK-NEXT: [[TEMP:%.*]] = alloc_stack $OrdinarySub -// CHECK-NEXT: strong_retain %0 // CHECK-NEXT: [[T0:%.*]] = class_method %0 : $A, #A.array!getter.1 // CHECK-NEXT: [[T1:%.*]] = apply [[T0]](%0) // CHECK-NEXT: store [[T1]] to [[TEMP]] @@ -43,10 +42,10 @@ func test0(ref: A) { // CHECK-NEXT: // function_ref accessors.OrdinarySub.subscript.getter (Swift.Int) -> Swift.Int // CHECK-NEXT: [[T1:%.*]] = function_ref @_TFV9accessors11OrdinarySubg9subscriptFSiSi // CHECK-NEXT: [[VALUE:%.*]] = apply [[T1]]([[INDEX1]], [[T0]]) +// CHECK-NEXT: release_value [[T0]] // Formal access to LHS. // CHECK-NEXT: [[STORAGE:%.*]] = alloc_stack $Builtin.UnsafeValueBuffer // CHECK-NEXT: [[BUFFER:%.*]] = alloc_stack $OrdinarySub -// CHECK-NEXT: strong_retain %0 // CHECK-NEXT: [[T0:%.*]] = address_to_pointer [[BUFFER]] // CHECK-NEXT: [[T1:%.*]] = class_method %0 : $A, #A.array!materializeForSet.1 // CHECK-NEXT: [[T2:%.*]] = apply [[T1]]([[T0]], [[STORAGE]]#1, %0) @@ -102,7 +101,6 @@ func test1(ref: B) { // Formal access to RHS. // CHECK-NEXT: [[STORAGE:%.*]] = alloc_stack $Builtin.UnsafeValueBuffer // CHECK-NEXT: [[BUFFER:%.*]] = alloc_stack $MutatingSub -// CHECK-NEXT: strong_retain %0 // CHECK-NEXT: [[T0:%.*]] = address_to_pointer [[BUFFER]] // CHECK-NEXT: [[T1:%.*]] = class_method %0 : $B, #B.array!materializeForSet.1 // CHECK-NEXT: [[T2:%.*]] = apply [[T1]]([[T0]], [[STORAGE]]#1, %0) @@ -126,7 +124,6 @@ func test1(ref: B) { // Formal access to LHS. // CHECK-NEXT: [[STORAGE2:%.*]] = alloc_stack $Builtin.UnsafeValueBuffer // CHECK-NEXT: [[BUFFER2:%.*]] = alloc_stack $MutatingSub -// CHECK-NEXT: strong_retain %0 // CHECK-NEXT: [[T0:%.*]] = address_to_pointer [[BUFFER2]] // CHECK-NEXT: [[T1:%.*]] = class_method %0 : $B, #B.array!materializeForSet.1 // CHECK-NEXT: [[T2:%.*]] = apply [[T1]]([[T0]], [[STORAGE2]]#1, %0) @@ -190,4 +187,4 @@ func test_rec2(inout outer: Rec2Outer) -> Int { } // This uses the mutable addressor. // CHECK: sil hidden @_TF9accessors9test_rec2FRVS_9Rec2OuterSi : $@thin (@inout Rec2Outer) -> Int { -// CHECK: function_ref @_TFV9accessors9Rec2Outerau5innerVS_9Rec2Inner : $@cc(method) @thin (@inout Rec2Outer) -> UnsafeMutablePointer \ No newline at end of file +// CHECK: function_ref @_TFV9accessors9Rec2Outerau5innerVS_9Rec2Inner : $@cc(method) @thin (@inout Rec2Outer) -> UnsafeMutablePointer diff --git a/test/SILGen/addressors.swift b/test/SILGen/addressors.swift index 1303769abcd..d18885de831 100644 --- a/test/SILGen/addressors.swift +++ b/test/SILGen/addressors.swift @@ -263,16 +263,15 @@ class F { } } -// CHECK: sil hidden @_TFC10addressors1Flo5valueVSs5Int32 : $@cc(method) @thin (@owned F) -> @owned (UnsafePointer, Builtin.NativeObject) { -// CHECK: sil hidden @_TFC10addressors1Fao5valueVSs5Int32 : $@cc(method) @thin (@owned F) -> @owned (UnsafeMutablePointer, Builtin.NativeObject) { +// CHECK: sil hidden @_TFC10addressors1Flo5valueVSs5Int32 : $@cc(method) @thin (@guaranteed F) -> @owned (UnsafePointer, Builtin.NativeObject) { +// CHECK: sil hidden @_TFC10addressors1Fao5valueVSs5Int32 : $@cc(method) @thin (@guaranteed F) -> @owned (UnsafeMutablePointer, Builtin.NativeObject) { func test_f0(f: F) -> Int32 { return f.value } // CHECK: sil hidden @_TF10addressors7test_f0FCS_1FVSs5Int32 : $@thin (@owned F) -> Int32 { // CHECK: bb0([[SELF:%0]] : $F): -// CHECK: strong_retain [[SELF]] : $F -// CHECK: [[ADDRESSOR:%.*]] = function_ref @_TFC10addressors1Flo5valueVSs5Int32 : $@cc(method) @thin (@owned F) -> @owned (UnsafePointer, Builtin.NativeObject) +// CHECK: [[ADDRESSOR:%.*]] = function_ref @_TFC10addressors1Flo5valueVSs5Int32 : $@cc(method) @thin (@guaranteed F) -> @owned (UnsafePointer, Builtin.NativeObject) // CHECK: [[T0:%.*]] = apply [[ADDRESSOR]]([[SELF]]) // CHECK: [[PTR:%.*]] = tuple_extract [[T0]] : $(UnsafePointer, Builtin.NativeObject), 0 // CHECK: [[OWNER:%.*]] = tuple_extract [[T0]] : $(UnsafePointer, Builtin.NativeObject), 1 @@ -291,8 +290,7 @@ func test_f1(f: F) { // CHECK: bb0([[SELF:%0]] : $F): // CHECK: [[T0:%.*]] = integer_literal $Builtin.Int32, 14 // CHECK: [[VALUE:%.*]] = struct $Int32 ([[T0]] : $Builtin.Int32) -// CHECK: strong_retain [[SELF]] : $F -// CHECK: [[ADDRESSOR:%.*]] = function_ref @_TFC10addressors1Fao5valueVSs5Int32 : $@cc(method) @thin (@owned F) -> @owned (UnsafeMutablePointer, Builtin.NativeObject) +// CHECK: [[ADDRESSOR:%.*]] = function_ref @_TFC10addressors1Fao5valueVSs5Int32 : $@cc(method) @thin (@guaranteed F) -> @owned (UnsafeMutablePointer, Builtin.NativeObject) // CHECK: [[T0:%.*]] = apply [[ADDRESSOR]]([[SELF]]) // CHECK: [[PTR:%.*]] = tuple_extract [[T0]] : $(UnsafeMutablePointer, Builtin.NativeObject), 0 // CHECK: [[OWNER:%.*]] = tuple_extract [[T0]] : $(UnsafeMutablePointer, Builtin.NativeObject), 1 @@ -315,10 +313,9 @@ class G { } } } -// CHECK: sil hidden [transparent] @_TFC10addressors1Gg5valueVSs5Int32 : $@cc(method) @thin (@owned G) -> Int32 { +// CHECK: sil hidden [transparent] @_TFC10addressors1Gg5valueVSs5Int32 : $@cc(method) @thin (@guaranteed G) -> Int32 { // CHECK: bb0([[SELF:%0]] : $G): -// CHECK: strong_retain [[SELF]] -// CHECK: [[ADDRESSOR:%.*]] = function_ref @_TFC10addressors1Glo5valueVSs5Int32 : $@cc(method) @thin (@owned G) -> @owned (UnsafePointer, Builtin.NativeObject) +// CHECK: [[ADDRESSOR:%.*]] = function_ref @_TFC10addressors1Glo5valueVSs5Int32 : $@cc(method) @thin (@guaranteed G) -> @owned (UnsafePointer, Builtin.NativeObject) // CHECK: [[T0:%.*]] = apply [[ADDRESSOR]]([[SELF]]) // CHECK: [[PTR:%.*]] = tuple_extract [[T0]] : $(UnsafePointer, Builtin.NativeObject), 0 // CHECK: [[OWNER:%.*]] = tuple_extract [[T0]] : $(UnsafePointer, Builtin.NativeObject), 1 @@ -327,13 +324,11 @@ class G { // CHECK: [[T2:%.*]] = mark_dependence [[T1]] : $*Int32 on [[OWNER]] : $Builtin.NativeObject // CHECK: [[VALUE:%.*]] = load [[T2]] : $*Int32 // CHECK: strong_release [[OWNER]] : $Builtin.NativeObject -// CHECK: strong_release [[SELF]] : $G // CHECK: return [[VALUE]] : $Int32 -// CHECK: sil hidden [transparent] @_TFC10addressors1Gs5valueVSs5Int32 : $@cc(method) @thin (Int32, @owned G) -> () { +// CHECK: sil hidden [transparent] @_TFC10addressors1Gs5valueVSs5Int32 : $@cc(method) @thin (Int32, @guaranteed G) -> () { // CHECK: bb0([[VALUE:%0]] : $Int32, [[SELF:%1]] : $G): -// CHECK: strong_retain [[SELF]] : $G -// CHECK: [[ADDRESSOR:%.*]] = function_ref @_TFC10addressors1Gao5valueVSs5Int32 : $@cc(method) @thin (@owned G) -> @owned (UnsafeMutablePointer, Builtin.NativeObject) +// CHECK: [[ADDRESSOR:%.*]] = function_ref @_TFC10addressors1Gao5valueVSs5Int32 : $@cc(method) @thin (@guaranteed G) -> @owned (UnsafeMutablePointer, Builtin.NativeObject) // CHECK: [[T0:%.*]] = apply [[ADDRESSOR]]([[SELF]]) // CHECK: [[PTR:%.*]] = tuple_extract [[T0]] : $(UnsafeMutablePointer, Builtin.NativeObject), 0 // CHECK: [[OWNER:%.*]] = tuple_extract [[T0]] : $(UnsafeMutablePointer, Builtin.NativeObject), 1 @@ -342,14 +337,12 @@ class G { // CHECK: [[T2:%.*]] = mark_dependence [[T1]] : $*Int32 on [[OWNER]] : $Builtin.NativeObject // CHECK: store [[VALUE]] to [[T2]] : $*Int32 // CHECK: strong_release [[OWNER]] : $Builtin.NativeObject -// CHECK: strong_release [[SELF]] : $G // materializeForSet for G.value -// CHECK: sil hidden [transparent] @_TFC10addressors1Gm5valueVSs5Int32 : $@cc(method) @thin (Builtin.RawPointer, @inout Builtin.UnsafeValueBuffer, @owned G) -> (Builtin.RawPointer, Optional<@thin (Builtin.RawPointer, inout Builtin.UnsafeValueBuffer, inout G, @thick G.Type) -> ()>) { +// CHECK: sil hidden [transparent] @_TFC10addressors1Gm5valueVSs5Int32 : $@cc(method) @thin (Builtin.RawPointer, @inout Builtin.UnsafeValueBuffer, @guaranteed G) -> (Builtin.RawPointer, Optional<@thin (Builtin.RawPointer, inout Builtin.UnsafeValueBuffer, inout G, @thick G.Type) -> ()>) { // CHECK: bb0([[BUFFER:%0]] : $Builtin.RawPointer, [[STORAGE:%1]] : $*Builtin.UnsafeValueBuffer, [[SELF:%2]] : $G): // Call the addressor. -// CHECK: [[ADDRESSOR:%.*]] = function_ref @_TFC10addressors1Gao5valueVSs5Int32 : $@cc(method) @thin (@owned G) -> @owned (UnsafeMutablePointer, Builtin.NativeObject) -// CHECK: strong_retain [[SELF]] : $G +// CHECK: [[ADDRESSOR:%.*]] = function_ref @_TFC10addressors1Gao5valueVSs5Int32 : $@cc(method) @thin (@guaranteed G) -> @owned (UnsafeMutablePointer, Builtin.NativeObject) // CHECK: [[T0:%.*]] = apply [[ADDRESSOR]]([[SELF]]) // CHECK: [[T1:%.*]] = tuple_extract [[T0]] : $(UnsafeMutablePointer, Builtin.NativeObject), 0 // CHECK: [[T2:%.*]] = tuple_extract [[T0]] : $(UnsafeMutablePointer, Builtin.NativeObject), 1 @@ -363,6 +356,7 @@ class G { // CHECK: store [[T3]] to [[T2]] : $*Builtin.NativeObject // Pull out the address. // CHECK: [[T0:%.*]] = tuple_extract [[TUPLE]] : $(UnsafeMutablePointer, Builtin.NativeObject), 0 +// CHECK: [[ADDR_OWNER:%.*]] = tuple_extract [[TUPLE]] : $(UnsafeMutablePointer, Builtin.NativeObject), 1 // CHECK: [[PTR:%.*]] = struct_extract [[T0]] : // Set up the callback. // CHECK: [[TEMP:%.*]] = alloc_stack $Optional<@thin (Builtin.RawPointer, inout Builtin.UnsafeValueBuffer, inout G, @thick G.Type) -> ()> @@ -373,8 +367,8 @@ class G { // CHECK: [[CALLBACK:%.*]] = load [[TEMP]]#1 : // Epilogue. // CHECK: [[RESULT:%.*]] = tuple ([[PTR]] : $Builtin.RawPointer, [[CALLBACK]] : $Optional<@thin (Builtin.RawPointer, inout Builtin.UnsafeValueBuffer, inout G, @thick G.Type) -> ()>) +// CHECK: strong_release [[ADDR_OWNER]] // CHECK: release_value [[TUPLE]] -// CHECK: strong_release [[SELF]] // CHECK: return [[RESULT]] // materializeForSet callback for G.value @@ -400,16 +394,15 @@ class H { } } -// CHECK: sil hidden @_TFC10addressors1Hlp5valueVSs5Int32 : $@cc(method) @thin (@owned H) -> @owned (UnsafePointer, Optional) { -// CHECK: sil hidden @_TFC10addressors1Hap5valueVSs5Int32 : $@cc(method) @thin (@owned H) -> @owned (UnsafeMutablePointer, Optional) { +// CHECK: sil hidden @_TFC10addressors1Hlp5valueVSs5Int32 : $@cc(method) @thin (@guaranteed H) -> @owned (UnsafePointer, Optional) { +// CHECK: sil hidden @_TFC10addressors1Hap5valueVSs5Int32 : $@cc(method) @thin (@guaranteed H) -> @owned (UnsafeMutablePointer, Optional) { func test_h0(f: H) -> Int32 { return f.value } // CHECK-LABEL: sil hidden @_TF10addressors7test_h0FCS_1HVSs5Int32 : $@thin (@owned H) -> Int32 { // CHECK: bb0([[SELF:%0]] : $H): -// CHECK: strong_retain [[SELF]] : $H -// CHECK: [[ADDRESSOR:%.*]] = function_ref @_TFC10addressors1Hlp5valueVSs5Int32 : $@cc(method) @thin (@owned H) -> @owned (UnsafePointer, Optional) +// CHECK: [[ADDRESSOR:%.*]] = function_ref @_TFC10addressors1Hlp5valueVSs5Int32 : $@cc(method) @thin (@guaranteed H) -> @owned (UnsafePointer, Optional) // CHECK: [[T0:%.*]] = apply [[ADDRESSOR]]([[SELF]]) // CHECK: [[PTR:%.*]] = tuple_extract [[T0]] : $(UnsafePointer, Optional), 0 // CHECK: [[OWNER:%.*]] = tuple_extract [[T0]] : $(UnsafePointer, Optional), 1 @@ -428,8 +421,7 @@ func test_h1(f: H) { // CHECK: bb0([[SELF:%0]] : $H): // CHECK: [[T0:%.*]] = integer_literal $Builtin.Int32, 14 // CHECK: [[VALUE:%.*]] = struct $Int32 ([[T0]] : $Builtin.Int32) -// CHECK: strong_retain [[SELF]] : $H -// CHECK: [[ADDRESSOR:%.*]] = function_ref @_TFC10addressors1Hap5valueVSs5Int32 : $@cc(method) @thin (@owned H) -> @owned (UnsafeMutablePointer, Optional) +// CHECK: [[ADDRESSOR:%.*]] = function_ref @_TFC10addressors1Hap5valueVSs5Int32 : $@cc(method) @thin (@guaranteed H) -> @owned (UnsafeMutablePointer, Optional) // CHECK: [[T0:%.*]] = apply [[ADDRESSOR]]([[SELF]]) // CHECK: [[PTR:%.*]] = tuple_extract [[T0]] : $(UnsafeMutablePointer, Optional), 0 // CHECK: [[OWNER:%.*]] = tuple_extract [[T0]] : $(UnsafeMutablePointer, Optional), 1 @@ -452,10 +444,9 @@ class I { } } } -// CHECK-LABEL: sil hidden [transparent] @_TFC10addressors1Ig5valueVSs5Int32 : $@cc(method) @thin (@owned I) -> Int32 { +// CHECK-LABEL: sil hidden [transparent] @_TFC10addressors1Ig5valueVSs5Int32 : $@cc(method) @thin (@guaranteed I) -> Int32 { // CHECK: bb0([[SELF:%0]] : $I): -// CHECK: strong_retain [[SELF]] -// CHECK: [[ADDRESSOR:%.*]] = function_ref @_TFC10addressors1Ilp5valueVSs5Int32 : $@cc(method) @thin (@owned I) -> @owned (UnsafePointer, Optional) +// CHECK: [[ADDRESSOR:%.*]] = function_ref @_TFC10addressors1Ilp5valueVSs5Int32 : $@cc(method) @thin (@guaranteed I) -> @owned (UnsafePointer, Optional) // CHECK: [[T0:%.*]] = apply [[ADDRESSOR]]([[SELF]]) // CHECK: [[PTR:%.*]] = tuple_extract [[T0]] : $(UnsafePointer, Optional), 0 // CHECK: [[OWNER:%.*]] = tuple_extract [[T0]] : $(UnsafePointer, Optional), 1 @@ -464,13 +455,11 @@ class I { // CHECK: [[T2:%.*]] = mark_dependence [[T1]] : $*Int32 on [[OWNER]] : $Optional // CHECK: [[VALUE:%.*]] = load [[T2]] : $*Int32 // CHECK: strong_unpin [[OWNER]] : $Optional -// CHECK: strong_release [[SELF]] : $I // CHECK: return [[VALUE]] : $Int32 -// CHECK-LABEL: sil hidden [transparent] @_TFC10addressors1Is5valueVSs5Int32 : $@cc(method) @thin (Int32, @owned I) -> () { +// CHECK-LABEL: sil hidden [transparent] @_TFC10addressors1Is5valueVSs5Int32 : $@cc(method) @thin (Int32, @guaranteed I) -> () { // CHECK: bb0([[VALUE:%0]] : $Int32, [[SELF:%1]] : $I): -// CHECK: strong_retain [[SELF]] : $I -// CHECK: [[ADDRESSOR:%.*]] = function_ref @_TFC10addressors1Iap5valueVSs5Int32 : $@cc(method) @thin (@owned I) -> @owned (UnsafeMutablePointer, Optional) +// CHECK: [[ADDRESSOR:%.*]] = function_ref @_TFC10addressors1Iap5valueVSs5Int32 : $@cc(method) @thin (@guaranteed I) -> @owned (UnsafeMutablePointer, Optional) // CHECK: [[T0:%.*]] = apply [[ADDRESSOR]]([[SELF]]) // CHECK: [[PTR:%.*]] = tuple_extract [[T0]] : $(UnsafeMutablePointer, Optional), 0 // CHECK: [[OWNER:%.*]] = tuple_extract [[T0]] : $(UnsafeMutablePointer, Optional), 1 @@ -479,13 +468,11 @@ class I { // CHECK: [[T2:%.*]] = mark_dependence [[T1]] : $*Int32 on [[OWNER]] : $Optional // CHECK: store [[VALUE]] to [[T2]] : $*Int32 // CHECK: strong_unpin [[OWNER]] : $Optional -// CHECK: strong_release [[SELF]] : $I -// CHECK-LABEL: sil hidden [transparent] @_TFC10addressors1Im5valueVSs5Int32 : $@cc(method) @thin (Builtin.RawPointer, @inout Builtin.UnsafeValueBuffer, @owned I) -> (Builtin.RawPointer, Optional<@thin (Builtin.RawPointer, inout Builtin.UnsafeValueBuffer, inout I, @thick I.Type) -> ()>) { +// CHECK-LABEL: sil hidden [transparent] @_TFC10addressors1Im5valueVSs5Int32 : $@cc(method) @thin (Builtin.RawPointer, @inout Builtin.UnsafeValueBuffer, @guaranteed I) -> (Builtin.RawPointer, Optional<@thin (Builtin.RawPointer, inout Builtin.UnsafeValueBuffer, inout I, @thick I.Type) -> ()>) { // CHECK: bb0([[BUFFER:%0]] : $Builtin.RawPointer, [[STORAGE:%1]] : $*Builtin.UnsafeValueBuffer, [[SELF:%2]] : $I): // Call the addressor. -// CHECK: [[ADDRESSOR:%.*]] = function_ref @_TFC10addressors1Iap5valueVSs5Int32 : $@cc(method) @thin (@owned I) -> @owned (UnsafeMutablePointer, Optional) -// CHECK: strong_retain [[SELF]] : $I +// CHECK: [[ADDRESSOR:%.*]] = function_ref @_TFC10addressors1Iap5valueVSs5Int32 : $@cc(method) @thin (@guaranteed I) -> @owned (UnsafeMutablePointer, Optional) // CHECK: [[T0:%.*]] = apply [[ADDRESSOR]]([[SELF]]) // CHECK: [[T1:%.*]] = tuple_extract [[T0]] : $(UnsafeMutablePointer, Optional), 0 // CHECK: [[T2:%.*]] = tuple_extract [[T0]] : $(UnsafeMutablePointer, Optional), 1 @@ -510,7 +497,6 @@ class I { // Epilogue. // CHECK: [[RESULT:%.*]] = tuple ([[PTR]] : $Builtin.RawPointer, [[CALLBACK]] : $Optional<@thin (Builtin.RawPointer, inout Builtin.UnsafeValueBuffer, inout I, @thick I.Type) -> ()>) // CHECK: release_value [[TUPLE]] -// CHECK: strong_release [[SELF]] // CHECK: return [[RESULT]] // materializeForSet callback for I.value diff --git a/test/SILGen/auto_closures.swift b/test/SILGen/auto_closures.swift index c05aff1940b..b276b3de7c8 100644 --- a/test/SILGen/auto_closures.swift +++ b/test/SILGen/auto_closures.swift @@ -35,7 +35,7 @@ public class Base { } public class Sub : Base { - // CHECK-LABEL: sil hidden @_TFC13auto_closures3Subg1xVS_4Bool : $@cc(method) @thin (@owned Sub) -> Bool { + // CHECK-LABEL: sil hidden @_TFC13auto_closures3Subg1xVS_4Bool : $@cc(method) @thin (@guaranteed Sub) -> Bool { // CHECK: [[AUTOCLOSURE:%.*]] = function_ref @_TFFC13auto_closures3Subg1xVS_4Boolu_KT_S1_ : $@thin (@owned Sub) -> Bool // CHECK: = partial_apply [[AUTOCLOSURE]](%0) // CHECK: return {{%.*}} : $Bool diff --git a/test/SILGen/boxed_existentials.swift b/test/SILGen/boxed_existentials.swift index 240222e8297..901df32f382 100644 --- a/test/SILGen/boxed_existentials.swift +++ b/test/SILGen/boxed_existentials.swift @@ -68,11 +68,10 @@ extension _ErrorType { func test_extension_method(error: _ErrorType) { // CHECK: [[VALUE:%.*]] = open_existential_box %0 // CHECK: [[METHOD:%.*]] = function_ref - // CHECK: copy_addr [[VALUE]] to [initialization] [[COPY:%.*]]#1 : - // CHECK: apply [[METHOD]]<{{.*}}>([[COPY]]#1) + // CHECK-NOT: copy_addr + // CHECK: apply [[METHOD]]<{{.*}}>([[VALUE]]) // CHECK-NOT: destroy_addr [[COPY]] // CHECK-NOT: destroy_addr [[VALUE]] - // CHECK: dealloc_stack [[COPY]]#0 // CHECK-NOT: destroy_addr [[VALUE]] // -- release the owned argument // CHECK: strong_release %0 @@ -91,9 +90,8 @@ func test_open_existential_semantics(guaranteed: _ErrorType, // CHECK-NOT: strong_retain %0 // CHECK: [[VALUE:%.*]] = open_existential_box %0 // CHECK: [[METHOD:%.*]] = function_ref - // CHECK: copy_addr [[VALUE]] to [initialization] [[COPY:%.*]]#1 : - // CHECK: apply [[METHOD]]<{{.*}}>([[COPY]]#1) - // CHECK: dealloc_stack [[COPY]]#0 + // CHECK-NOT: copy_addr + // CHECK: apply [[METHOD]]<{{.*}}>([[VALUE]]) // CHECK-NOT: strong_release %0 // GUARANTEED-NOT: strong_retain %0 @@ -109,9 +107,8 @@ func test_open_existential_semantics(guaranteed: _ErrorType, // CHECK: strong_retain [[IMMEDIATE]] // CHECK: [[VALUE:%.*]] = open_existential_box [[IMMEDIATE]] // CHECK: [[METHOD:%.*]] = function_ref - // CHECK: copy_addr [[VALUE]] to [initialization] [[COPY:%.*]]#1 : - // CHECK: apply [[METHOD]]<{{.*}}>([[COPY]]#1) - // CHECK: dealloc_stack [[COPY]]#0 + // CHECK-NOT: copy_addr + // CHECK: apply [[METHOD]]<{{.*}}>([[VALUE]]) // -- end the guarantee // -- TODO: could in theory do this sooner, after the value's been copied // out. @@ -132,9 +129,8 @@ func test_open_existential_semantics(guaranteed: _ErrorType, // CHECK: [[PLUS_ONE:%.*]] = apply [[F]]() // CHECK: [[VALUE:%.*]] = open_existential_box [[PLUS_ONE]] // CHECK: [[METHOD:%.*]] = function_ref - // CHECK: copy_addr [[VALUE]] to [initialization] [[COPY:%.*]]#1 : - // CHECK: apply [[METHOD]]<{{.*}}>([[COPY]]#1) - // CHECK: dealloc_stack [[COPY]]#0 + // CHECK-NOT: copy_addr + // CHECK: apply [[METHOD]]<{{.*}}>([[VALUE]]) // CHECK: strong_release [[PLUS_ONE]] // GUARANTEED: [[F:%.*]] = function_ref {{.*}}plusOneErrorType diff --git a/test/SILGen/closures.swift b/test/SILGen/closures.swift index 0c904951c38..5f86d582850 100644 --- a/test/SILGen/closures.swift +++ b/test/SILGen/closures.swift @@ -495,7 +495,7 @@ class SuperSub : SuperBase { } } -// CHECK-LABEL: sil hidden @_TFC8closures24UnownedSelfNestedCapture13nestedCapturefS0_FT_T_ : $@cc(method) @thin (@owned UnownedSelfNestedCapture) -> () +// CHECK-LABEL: sil hidden @_TFC8closures24UnownedSelfNestedCapture13nestedCapturefS0_FT_T_ : $@cc(method) @thin (@guaranteed UnownedSelfNestedCapture) -> () // CHECK: [[OUTER_SELF_CAPTURE:%.*]] = alloc_box $@sil_unowned UnownedSelfNestedCapture // CHECK: [[UNOWNED_SELF:%.*]] = ref_to_unowned [[SELF_PARAM:%.*]] : // -- TODO: A lot of fussy r/r traffic and owned/unowned conversions here. @@ -516,12 +516,12 @@ class SuperSub : SuperBase { // -- call consumes closure // -- strong +1, unowned +1 // CHECK: [[INNER_CLOSURE:%.*]] = apply [[OUTER_CLOSURE]] -// CHECK: apply [[INNER_CLOSURE]]() +// CHECK: [[CONSUMED_RESULT:%.*]] = apply [[INNER_CLOSURE]]() +// CHECK: strong_release [[CONSUMED_RESULT]] // -- releases unowned self in box // -- strong +1, unowned +0 // CHECK: strong_release [[OUTER_SELF_CAPTURE]] // -- strong +0, unowned +0 -// CHECK: strong_release [[SELF_PARAM]] // CHECK: return // -- outer closure diff --git a/test/SILGen/dynamic.swift b/test/SILGen/dynamic.swift index 733dd3e0026..f8eff1a1e40 100644 --- a/test/SILGen/dynamic.swift +++ b/test/SILGen/dynamic.swift @@ -420,7 +420,7 @@ public class Base { } public class Sub : Base { - // CHECK-LABEL: sil hidden @_TFC7dynamic3Subg1xSb : $@cc(method) @thin (@owned Sub) -> Bool { + // CHECK-LABEL: sil hidden @_TFC7dynamic3Subg1xSb : $@cc(method) @thin (@guaranteed Sub) -> Bool { // CHECK: [[AUTOCLOSURE:%.*]] = function_ref @_TFFC7dynamic3Subg1xSbu_KT_Sb : $@thin (@owned Sub) -> Bool // CHECK: = partial_apply [[AUTOCLOSURE]](%0) // CHECK: return {{%.*}} : $Bool diff --git a/test/SILGen/dynamic_self.swift b/test/SILGen/dynamic_self.swift index fde2b966b17..bfee39f29c2 100644 --- a/test/SILGen/dynamic_self.swift +++ b/test/SILGen/dynamic_self.swift @@ -11,7 +11,7 @@ protocol CP : class { class X : P, CP { required init(int i: Int) { } - // CHECK-LABEL: sil hidden @_TFC12dynamic_self1X1ffDS0_FT_DS0_ : $@cc(method) @thin (@owned X) -> @owned + // CHECK-LABEL: sil hidden @_TFC12dynamic_self1X1ffDS0_FT_DS0_ : $@cc(method) @thin (@guaranteed X) -> @owned func f() -> Self { return self } // CHECK-LABEL: sil hidden @_TZFC12dynamic_self1X7factory{{.*}} : $@thin (Int, @thick X.Type) -> @owned X @@ -34,22 +34,28 @@ class GY : GX<[T]> { } // CHECK-LABEL: sil hidden @_TF12dynamic_self23testDynamicSelfDispatch{{.*}} : $@thin (@owned Y) -> () func testDynamicSelfDispatch(y: Y) { // CHECK: bb0([[Y:%[0-9]+]] : $Y): -// CHECK: [[Y_AS_X:%[0-9]+]] = upcast [[Y]] : $Y to $X -// CHECK: [[X_F:%[0-9]+]] = class_method [[Y_AS_X]] : $X, #X.f!1 : Self -> () -> Self , $@cc(method) @thin (@owned X) -> @owned X -// CHECK: [[X_RESULT:%[0-9]+]] = apply [[X_F]]([[Y_AS_X]]) : $@cc(method) @thin (@owned X) -> @owned X +// CHECK: strong_retain [[Y]] +// CHECK: [[Y_AS_X:%[0-9]+]] = upcast [[Y]] : $Y to $X +// CHECK: [[X_F:%[0-9]+]] = class_method [[Y_AS_X]] : $X, #X.f!1 : Self -> () -> Self , $@cc(method) @thin (@guaranteed X) -> @owned X +// CHECK: [[X_RESULT:%[0-9]+]] = apply [[X_F]]([[Y_AS_X]]) : $@cc(method) @thin (@guaranteed X) -> @owned X +// CHECK: strong_release [[Y_AS_X]] // CHECK: [[Y_RESULT:%[0-9]+]] = unchecked_ref_cast [[X_RESULT]] : $X to $Y // CHECK: strong_release [[Y_RESULT]] : $Y +// CHECK: strong_release [[Y]] : $Y y.f() } // CHECK-LABEL: sil hidden @_TF12dynamic_self30testDynamicSelfDispatchGeneric{{.*}} : $@thin (@owned GY) -> () func testDynamicSelfDispatchGeneric(gy: GY) { // CHECK: bb0([[GY:%[0-9]+]] : $GY): + // CHECK: strong_retain [[GY]] // CHECK: [[GY_AS_GX:%[0-9]+]] = upcast [[GY]] : $GY to $GX> - // CHECK: [[GX_F:%[0-9]+]] = class_method [[GY_AS_GX]] : $GX>, #GX.f!1 : Self -> () -> Self , $@cc(method) @thin <τ_0_0> (@owned GX<τ_0_0>) -> @owned GX<τ_0_0> - // CHECK: [[GX_RESULT:%[0-9]+]] = apply [[GX_F]]<[Int]>([[GY_AS_GX]]) : $@cc(method) @thin <τ_0_0> (@owned GX<τ_0_0>) -> @owned GX<τ_0_0> + // CHECK: [[GX_F:%[0-9]+]] = class_method [[GY_AS_GX]] : $GX>, #GX.f!1 : Self -> () -> Self , $@cc(method) @thin <τ_0_0> (@guaranteed GX<τ_0_0>) -> @owned GX<τ_0_0> + // CHECK: [[GX_RESULT:%[0-9]+]] = apply [[GX_F]]<[Int]>([[GY_AS_GX]]) : $@cc(method) @thin <τ_0_0> (@guaranteed GX<τ_0_0>) -> @owned GX<τ_0_0> + // CHECK: strong_release [[GY_AS_GX]] // CHECK: [[GY_RESULT:%[0-9]+]] = unchecked_ref_cast [[GX_RESULT]] : $GX> to $GY // CHECK: strong_release [[GY_RESULT]] : $GY + // CHECK: strong_release [[GY]] gy.f() } @@ -80,8 +86,8 @@ func testExistentialDispatch(p: P) { func testExistentialDispatchClass(cp: CP) { // CHECK: bb0([[CP:%[0-9]+]] : $CP): // CHECK: [[CP_ADDR:%[0-9]+]] = open_existential_ref [[CP]] : $CP to $@opened([[N:".*"]]) CP -// CHECK: [[CP_F:%[0-9]+]] = witness_method $@opened([[N]]) CP, #CP.f!1, [[CP_ADDR]]{{.*}} : $@cc(witness_method) @thin <τ_0_0 where τ_0_0 : CP> (@owned τ_0_0) -> @owned τ_0_0 -// CHECK: [[CP_F_RESULT:%[0-9]+]] = apply [[CP_F]]<@opened([[N]]) CP>([[CP_ADDR]]) : $@cc(witness_method) @thin <τ_0_0 where τ_0_0 : CP> (@owned τ_0_0) -> @owned τ_0_0 +// CHECK: [[CP_F:%[0-9]+]] = witness_method $@opened([[N]]) CP, #CP.f!1, [[CP_ADDR]]{{.*}} : $@cc(witness_method) @thin <τ_0_0 where τ_0_0 : CP> (@guaranteed τ_0_0) -> @owned τ_0_0 +// CHECK: [[CP_F_RESULT:%[0-9]+]] = apply [[CP_F]]<@opened([[N]]) CP>([[CP_ADDR]]) : $@cc(witness_method) @thin <τ_0_0 where τ_0_0 : CP> (@guaranteed τ_0_0) -> @owned τ_0_0 // CHECK: [[RESULT_EXISTENTIAL:%[0-9]+]] = init_existential_ref [[CP_F_RESULT]] : $@opened([[N]]) CP : $@opened([[N]]) CP, $CP // CHECK: strong_release [[CP_F_RESULT]] : $@opened([[N]]) CP cp.f() @@ -123,14 +129,13 @@ func testObjCInit(meta: ObjCInit.Type) { class OptionalResult { func foo() -> Self? { return self } } -// CHECK-LABEL: sil hidden @_TFC12dynamic_self14OptionalResult3foofDS0_FT_GSqDS0__ : $@cc(method) @thin (@owned OptionalResult) -> @owned Optional +// CHECK-LABEL: sil hidden @_TFC12dynamic_self14OptionalResult3foofDS0_FT_GSqDS0__ : $@cc(method) @thin (@guaranteed OptionalResult) -> @owned Optional // CHECK: [[SOME:%.*]] = init_enum_data_addr [[OPT:%[0-9]+]] // CHECK-NEXT: strong_retain [[VALUE:%[0-9]+]] // CHECK-NEXT: store [[VALUE]] to [[SOME]] // CHECK-NEXT: inject_enum_addr [[OPT]]{{.*}}Some // CHECK-NEXT: [[T0:%.*]] = load [[OPT]]#1 // CHECK-NEXT: dealloc_stack [[OPT]]#0 -// CHECK-NEXT: strong_release [[VALUE]] // CHECK-NEXT: return [[T0]] : $Optional class OptionalResultInheritor : OptionalResult { @@ -141,7 +146,7 @@ func testOptionalResult(v : OptionalResultInheritor) { v.foo()?.bar() } // CHECK-LABEL: sil hidden @_TF12dynamic_self18testOptionalResult{{.*}} : $@thin (@owned OptionalResultInheritor) -> () -// CHECK: [[T0:%.*]] = class_method [[V:%.*]] : $OptionalResult, #OptionalResult.foo!1 : Self -> () -> Self? , $@cc(method) @thin (@owned OptionalResult) -> @owned Optional +// CHECK: [[T0:%.*]] = class_method [[V:%.*]] : $OptionalResult, #OptionalResult.foo!1 : Self -> () -> Self? , $@cc(method) @thin (@guaranteed OptionalResult) -> @owned Optional // CHECK-NEXT: apply [[T0]]([[V]]) // CHECK: select_enum_addr // CHECK: [[T1:%.*]] = unchecked_take_enum_data_addr diff --git a/test/SILGen/force_cast_chained_optional.swift b/test/SILGen/force_cast_chained_optional.swift index d85494d41bc..f5cd2771d2d 100644 --- a/test/SILGen/force_cast_chained_optional.swift +++ b/test/SILGen/force_cast_chained_optional.swift @@ -12,7 +12,7 @@ class C {} class D: C {} // CHECK-LABEL: sil hidden @_TF27force_cast_chained_optional4testFCS_3FooCS_1D -// CHECK: class_method %0 : $Foo, #Foo.bar!getter.1 : Foo -> () -> Bar! , $@cc(method) @thin (@owned Foo) -> +// CHECK: class_method %0 : $Foo, #Foo.bar!getter.1 : Foo -> () -> Bar! , $@cc(method) @thin (@guaranteed Foo) -> // CHECK: select_enum_addr // CHECK: cond_br {{%.*}}, [[SOME_BAR:bb[0-9]+]], [[NO_BAR:bb[0-9]+]] // CHECK: [[NO_BAR]]: @@ -20,7 +20,7 @@ class D: C {} // CHECK: [[SOME_BAR]]: // CHECK: [[PAYLOAD_ADDR:%.*]] = unchecked_take_enum_data_addr {{%.*}} : $*ImplicitlyUnwrappedOptional // CHECK: [[BAR:%.*]] = load [[PAYLOAD_ADDR]] -// CHECK: class_method {{%.*}} : $Bar, #Bar.bas!getter.1 : Bar -> () -> C! , $@cc(method) @thin (@owned Bar) -> +// CHECK: class_method {{%.*}} : $Bar, #Bar.bas!getter.1 : Bar -> () -> C! , $@cc(method) @thin (@guaranteed Bar) -> // CHECK: function_ref @_TFSs36_getImplicitlyUnwrappedOptionalValueU__FGSQQ__Q_ // CHECK: unconditional_checked_cast {{%.*}} : $C to $D // CHECK: [[TRAP]]: diff --git a/test/SILGen/functions.swift b/test/SILGen/functions.swift index e8ba4f15c85..ee02263fd86 100644 --- a/test/SILGen/functions.swift +++ b/test/SILGen/functions.swift @@ -80,11 +80,11 @@ class SomeClass { // CHECK: bb0(%0 : $Builtin.Int64, %1 : $Builtin.Int64, %2 : $@thick SomeClass.Type): init(x:Int, y:Int) {} - // CHECK-LABEL: sil hidden @_TFC9functions9SomeClass6method{{.*}} : $@cc(method) @thin (Builtin.Int64, @owned SomeClass) -> () + // CHECK-LABEL: sil hidden @_TFC9functions9SomeClass6method{{.*}} : $@cc(method) @thin (Builtin.Int64, @guaranteed SomeClass) -> () // CHECK: bb0(%0 : $Builtin.Int64, %1 : $SomeClass): func method(x: Int) {} - // CHECK-LABEL: sil hidden @_TFC9functions9SomeClass14curried_method{{.*}} : $@cc(method) @thin (Builtin.Int64, Builtin.Int64, @owned SomeClass) -> () + // CHECK-LABEL: sil hidden @_TFC9functions9SomeClass14curried_method{{.*}} : $@cc(method) @thin (Builtin.Int64, Builtin.Int64, @guaranteed SomeClass) -> () // CHECK: bb0(%0 : $Builtin.Int64, %1 : $Builtin.Int64, %2 : $SomeClass): func curried_method(x: Int)(y: Int) {} @@ -325,7 +325,7 @@ func calls(var i:Int, var j:Int, var k:Int) { // CHECK: [[C:%[0-9]+]] = load [[CADDR]] // CHECK: [[J:%[0-9]+]] = load [[JADDR]] // CHECK: [[K:%[0-9]+]] = load [[KADDR]] - // CHECK: [[GETTER:%[0-9]+]] = class_method [[C]] : $SomeClass, #SomeClass.subscript!getter.1 : SomeClass -> (Builtin.Int64, Builtin.Int64) -> Builtin.Int64 , $@cc(method) @thin (Builtin.Int64, Builtin.Int64, @owned SomeClass) -> Builtin.Int64 + // CHECK: [[GETTER:%[0-9]+]] = class_method [[C]] : $SomeClass, #SomeClass.subscript!getter.1 : SomeClass -> (Builtin.Int64, Builtin.Int64) -> Builtin.Int64 , $@cc(method) @thin (Builtin.Int64, Builtin.Int64, @guaranteed SomeClass) -> Builtin.Int64 // CHECK: apply [[GETTER]]([[J]], [[K]], [[C]]) i = c[j, k] @@ -333,7 +333,7 @@ func calls(var i:Int, var j:Int, var k:Int) { // CHECK: [[I:%[0-9]+]] = load [[IADDR]] // CHECK: [[J:%[0-9]+]] = load [[JADDR]] // CHECK: [[K:%[0-9]+]] = load [[KADDR]] - // CHECK: [[SETTER:%[0-9]+]] = class_method [[C]] : $SomeClass, #SomeClass.subscript!setter.1 : SomeClass -> (Builtin.Int64, Builtin.Int64, Builtin.Int64) -> () , $@cc(method) @thin (Builtin.Int64, Builtin.Int64, Builtin.Int64, @owned SomeClass) -> () + // CHECK: [[SETTER:%[0-9]+]] = class_method [[C]] : $SomeClass, #SomeClass.subscript!setter.1 : SomeClass -> (Builtin.Int64, Builtin.Int64, Builtin.Int64) -> () , $@cc(method) @thin (Builtin.Int64, Builtin.Int64, Builtin.Int64, @guaranteed SomeClass) -> () // CHECK: apply [[SETTER]]([[K]], [[I]], [[J]], [[C]]) c[i, j] = k @@ -567,8 +567,8 @@ final class r17828355Class { // CHECK-LABEL: sil shared @_TFC9functions14r17828355Class6methodFS0_FBi64_T_ // CHECK-NEXT: bb0(%0 : $r17828355Class): // CHECK-NEXT: // function_ref functions.r17828355Class.method (functions.r17828355Class)(Builtin.Int64) -> () -// CHECK-NEXT: %1 = function_ref @_TFC9functions14r17828355Class6methodfS0_FBi64_T_ : $@cc(method) @thin (Builtin.Int64, @owned r17828355Class) -> () -// CHECK-NEXT: partial_apply %1(%0) : $@cc(method) @thin (Builtin.Int64, @owned r17828355Class) -> () +// CHECK-NEXT: %1 = function_ref @_TFC9functions14r17828355Class6methodfS0_FBi64_T_ : $@cc(method) @thin (Builtin.Int64, @guaranteed r17828355Class) -> () +// CHECK-NEXT: partial_apply %1(%0) : $@cc(method) @thin (Builtin.Int64, @guaranteed r17828355Class) -> () // CHECK-NEXT: return diff --git a/test/SILGen/generic_property_base_lifetime.swift b/test/SILGen/generic_property_base_lifetime.swift index 159727dd8d6..8afda59c2b6 100644 --- a/test/SILGen/generic_property_base_lifetime.swift +++ b/test/SILGen/generic_property_base_lifetime.swift @@ -18,6 +18,7 @@ protocol ProtocolB { // CHECK: strong_retain [[PROJECTION]] // CHECK: apply {{%.*}}<@opened{{.*}}>([[PROJECTION]]) // CHECK: strong_release %0 +// CHECK-NOT: strong_release func getIntPropExistential(a: ProtocolA) -> Int { return a.intProp } @@ -27,12 +28,13 @@ func getIntPropExistential(a: ProtocolA) -> Int { // CHECK: strong_retain [[PROJECTION]] // CHECK: apply {{%.*}}<@opened{{.*}}>({{%.*}}, [[PROJECTION]]) // CHECK: strong_release %0 +// CHECK_NOT: strong_release func setIntPropExistential(a: ProtocolA) { a.intProp = 0 } // CHECK-LABEL: sil hidden @_TF30generic_property_base_lifetime17getIntPropGenericUS_9ProtocolA__FQ_Si -// CHECK: strong_retain %0 +// CHECK-NOT: strong_retain %0 // CHECK: apply {{%.*}}(%0) // CHECK: strong_release %0 func getIntPropGeneric(a: T) -> Int { @@ -40,7 +42,7 @@ func getIntPropGeneric(a: T) -> Int { } // CHECK-LABEL: sil hidden @_TF30generic_property_base_lifetime17setIntPropGenericUS_9ProtocolA__FQ_T_ -// CHECK: strong_retain %0 +// CHECK-NOT: strong_retain %0 // CHECK: apply {{%.*}}({{%.*}}, %0) // CHECK: strong_release %0 func setIntPropGeneric(a: T) { @@ -97,19 +99,19 @@ func setIntPropExistential(a: ProtocolO) { } // CHECK-LABEL: sil hidden @_TF30generic_property_base_lifetime17getIntPropGenericUS_9ProtocolO__FQ_Si -// CHECK: strong_retain %0 +// CHECK-NOT: strong_retain %0 // CHECK: apply {{%.*}}(%0) // CHECK: strong_release %0 -// CHECK: strong_release %0 +// CHECK-NOT: strong_release %0 func getIntPropGeneric(a: T) -> Int { return a.intProp } // CHECK-LABEL: sil hidden @_TF30generic_property_base_lifetime17setIntPropGenericUS_9ProtocolO__FQ_T_ -// CHECK: strong_retain %0 +// CHECK-NOT: strong_retain %0 // CHECK: apply {{%.*}}({{%.*}}, %0) // CHECK: strong_release %0 -// CHECK: strong_release %0 +// CHECK-NOT: strong_release %0 func setIntPropGeneric(a: T) { a.intProp = 0 } diff --git a/test/SILGen/let_decls.swift b/test/SILGen/let_decls.swift index bdb2f65ed42..66984ab4daf 100644 --- a/test/SILGen/let_decls.swift +++ b/test/SILGen/let_decls.swift @@ -395,30 +395,30 @@ struct StructMemberTest { func testIntMemberLoad() -> Int { return i } - // CHECK-LABEL: sil hidden @{{.*}}testIntMemberLoad + // CHECK-LABEL: sil hidden @{{.*}}testIntMemberLoad{{.*}} : $@cc(method) @thin (@guaranteed StructMemberTest) // CHECK: bb0(%0 : $StructMemberTest): // CHECK: debug_value %0 : $StructMemberTest // let self // CHECK: %2 = struct_extract %0 : $StructMemberTest, #StructMemberTest.i - // CHECK: release_value %0 : $StructMemberTest + // CHECK-NOT: release_value %0 : $StructMemberTest // CHECK: return %2 : $Int // Accessing the int member in s should not retain the whole struct. func testRecursiveIntMemberLoad() -> Int { return s.i } - // CHECK-LABEL: sil hidden @{{.*}}testRecursiveIntMemberLoad + // CHECK-LABEL: sil hidden @{{.*}}testRecursiveIntMemberLoad{{.*}} : $@cc(method) @thin (@guaranteed StructMemberTest) // CHECK: bb0(%0 : $StructMemberTest): // CHECK: debug_value %0 : $StructMemberTest // let self // CHECK: %2 = struct_extract %0 : $StructMemberTest, #StructMemberTest.s // CHECK: %3 = struct_extract %2 : $AnotherStruct, #AnotherStruct.i - // CHECK: release_value %0 : $StructMemberTest + // CHECK-NOT: release_value %0 : $StructMemberTest // CHECK: return %3 : $Int func testTupleMemberLoad() -> Int { return t.1.i } // FIXME: these retains and releases are unnecessary - // CHECK-LABEL: sil hidden @{{.*}}testTupleMemberLoad + // CHECK-LABEL: sil hidden @{{.*}}testTupleMemberLoad{{.*}} : $@cc(method) @thin (@guaranteed StructMemberTest) // CHECK: bb0(%0 : $StructMemberTest): // CHECK: debug_value %0 : $StructMemberTest // let self // CHECK: [[T0:%.*]] = struct_extract %0 : $StructMemberTest, #StructMemberTest.t @@ -427,7 +427,7 @@ struct StructMemberTest { // CHECK: [[T2:%.*]] = tuple_extract [[T0]] : $(Int, AnotherStruct), 1 // CHECK: [[T3:%.*]] = struct_extract [[T2]] : $AnotherStruct, #AnotherStruct.i // CHECK: release_value [[T2]] : $AnotherStruct - // CHECK: release_value %0 : $StructMemberTest + // CHECK-NOT: release_value %0 : $StructMemberTest // CHECK: return [[T3]] : $Int } @@ -439,25 +439,24 @@ struct GenericStruct { func getA() -> T { return a } - // CHECK-LABEL: sil hidden @{{.*}}GenericStruct4getA + // CHECK-LABEL: sil hidden @{{.*}}GenericStruct4getA{{.*}} : $@cc(method) @thin (@out T, @in_guaranteed GenericStruct) // CHECK-NEXT: bb0(%0 : $*T, %1 : $*GenericStruct): // CHECK-NEXT: debug_value_addr %1 : $*GenericStruct // let self // CHECK-NEXT: %3 = struct_element_addr %1 : $*GenericStruct, #GenericStruct.a // CHECK-NEXT: copy_addr %3 to [initialization] %0 : $*T - // CHECK-NEXT: destroy_addr %1 : $*GenericStruct - // CHECK-NEXT: %6 = tuple () - // CHECK-NEXT: return %6 : $() + // CHECK-NEXT: %5 = tuple () + // CHECK-NEXT: return %5 : $() func getB() -> Int { return b } - // CHECK-LABEL: sil hidden @{{.*}}GenericStruct4getB + // CHECK-LABEL: sil hidden @{{.*}}GenericStruct4getB{{.*}} : $@cc(method) @thin (@in_guaranteed GenericStruct) -> Int // CHECK-NEXT: bb0(%0 : $*GenericStruct): // CHECK-NEXT: debug_value_addr %0 : $*GenericStruct // let self // CHECK-NEXT: %2 = struct_element_addr %0 : $*GenericStruct, #GenericStruct.b // CHECK-NEXT: %3 = load %2 : $*Int - // CHECK-NEXT: destroy_addr %0 : $*GenericStruct + // CHECK-NOT: destroy_addr %0 : $*GenericStruct // CHECK-NEXT: return %3 : $Int } diff --git a/test/SILGen/lifetime.swift b/test/SILGen/lifetime.swift index 85f4fd12662..824bf39b007 100644 --- a/test/SILGen/lifetime.swift +++ b/test/SILGen/lifetime.swift @@ -339,7 +339,7 @@ class RefWithProp { var aleph_prop: Aleph { get {} set {} } } -// CHECK-LABEL: sil hidden @_TF8lifetime23logical_lvalue_lifetime +// CHECK-LABEL: sil hidden @_TF8lifetime23logical_lvalue_lifetimeFTCS_11RefWithPropSiVS_3Val_T_ : $@thin (@owned RefWithProp, Int, Val) -> () { func logical_lvalue_lifetime(var r: RefWithProp, var i: Int, var v: Val) { // CHECK: [[RADDR:%[0-9]+]] = alloc_box $RefWithProp // CHECK: [[IADDR:%[0-9]+]] = alloc_box $Int @@ -348,16 +348,16 @@ func logical_lvalue_lifetime(var r: RefWithProp, var i: Int, var v: Val) { // -- Reference types need to be retained as property method args. r.int_prop = i // CHECK: [[R1:%[0-9]+]] = load [[RADDR]] - // CHECK: retain [[R1]] - // CHECK: [[SETTER_METHOD:%[0-9]+]] = class_method {{.*}} : $RefWithProp, #RefWithProp.int_prop!setter.1 : RefWithProp -> (Int) -> () + // CHECK: strong_retain [[R1]] + // CHECK: [[SETTER_METHOD:%[0-9]+]] = class_method {{.*}} : $RefWithProp, #RefWithProp.int_prop!setter.1 : RefWithProp -> (Int) -> () , $@cc(method) @thin (Int, @guaranteed RefWithProp) -> () // CHECK: apply [[SETTER_METHOD]]({{.*}}, [[R1]]) + // CHECK: strong_release [[R1]] r.aleph_prop.b = v // CHECK: [[R2:%[0-9]+]] = load [[RADDR]] - // CHECK: retain [[R2]] + // CHECK: strong_retain [[R2]] // CHECK: [[STORAGE:%.*]] = alloc_stack $Builtin.UnsafeValueBuffer // CHECK: [[ALEPH_PROP_TEMP:%[0-9]+]] = alloc_stack $Aleph - // CHECK: retain [[R2]] // CHECK: [[T0:%.*]] = address_to_pointer [[ALEPH_PROP_TEMP]]#1 // CHECK: [[MATERIALIZE_METHOD:%[0-9]+]] = class_method {{.*}} : $RefWithProp, #RefWithProp.aleph_prop!materializeForSet.1 : // CHECK: [[MATERIALIZE:%.*]] = apply [[MATERIALIZE_METHOD]]([[T0]], [[STORAGE]]#1, [[R2]]) @@ -460,13 +460,13 @@ class Foo { // Deallocating destructor for Foo. // CHECK-LABEL: sil hidden @_TFC8lifetime3FooD : $@cc(method) @thin (@owned Foo) -> () // CHECK-NEXT: bb0([[SELF:%[0-9]+]] : $Foo): - // CHECK: [[DESTROYING_REF:%[0-9]+]] = function_ref @_TFC8lifetime3Food : $@cc(method) @thin <τ_0_0> (@owned Foo<τ_0_0>) -> @owned Builtin.NativeObject - // CHECK-NEXT: [[RESULT_SELF:%[0-9]+]] = apply [[DESTROYING_REF]]([[SELF]]) : $@cc(method) @thin <τ_0_0> (@owned Foo<τ_0_0>) -> @owned Builtin.NativeObject + // CHECK: [[DESTROYING_REF:%[0-9]+]] = function_ref @_TFC8lifetime3Food : $@cc(method) @thin <τ_0_0> (@guaranteed Foo<τ_0_0>) -> @owned Builtin.NativeObject + // CHECK-NEXT: [[RESULT_SELF:%[0-9]+]] = apply [[DESTROYING_REF]]([[SELF]]) : $@cc(method) @thin <τ_0_0> (@guaranteed Foo<τ_0_0>) -> @owned Builtin.NativeObject // CHECK-NEXT: [[SELF:%[0-9]+]] = unchecked_ref_cast [[RESULT_SELF]] : $Builtin.NativeObject to $Foo // CHECK-NEXT: dealloc_ref [[SELF]] : $Foo // CHECK-NEXT: [[RESULT:%[0-9]+]] = tuple () // CHECK-NEXT: return [[RESULT]] : $() - // CHECK-LABEL: sil hidden @_TFC8lifetime3Food : $@cc(method) @thin (@owned Foo) -> @owned Builtin.NativeObject + // CHECK-LABEL: sil hidden @_TFC8lifetime3Food : $@cc(method) @thin (@guaranteed Foo) -> @owned Builtin.NativeObject deinit { // CHECK: bb0([[THIS:%[0-9]+]] : $Foo): @@ -636,7 +636,7 @@ func downcast(var b: B) { // CHECK: [[D:%[0-9]+]] = unconditional_checked_cast [[B]] : {{.*}} to $D // CHECK: apply {{.*}}([[D]]) // CHECK-NOT: release [[B]] - // CHECK-NOT: release [[D]] + // CHECK: release [[D]] // CHECK: release [[BADDR]] // CHECK: return } diff --git a/test/SILGen/materializeForSet.swift b/test/SILGen/materializeForSet.swift index 1217a63dc08..ebed9d99dbb 100644 --- a/test/SILGen/materializeForSet.swift +++ b/test/SILGen/materializeForSet.swift @@ -22,7 +22,7 @@ class Base { // The ordering here is unfortunate: we generate the property // getters and setters after we've processed the decl. -// CHECK: sil hidden [transparent] @_TFC17materializeForSet4Basem8computedSi : $@cc(method) @thin (Builtin.RawPointer, @inout Builtin.UnsafeValueBuffer, @owned Base) -> (Builtin.RawPointer, Optional<@thin (Builtin.RawPointer, inout Builtin.UnsafeValueBuffer, inout Base, @thick Base.Type) -> ()>) { +// CHECK: sil hidden [transparent] @_TFC17materializeForSet4Basem8computedSi : $@cc(method) @thin (Builtin.RawPointer, @inout Builtin.UnsafeValueBuffer, @guaranteed Base) -> (Builtin.RawPointer, Optional<@thin (Builtin.RawPointer, inout Builtin.UnsafeValueBuffer, inout Base, @thick Base.Type) -> ()>) { // CHECK: bb0([[BUFFER:%.*]] : $Builtin.RawPointer, [[STORAGE:%.*]] : $*Builtin.UnsafeValueBuffer, [[SELF:%.*]] : $Base): // CHECK: [[ADDR:%.*]] = pointer_to_address [[BUFFER]] : $Builtin.RawPointer to $*Int // CHECK: [[T0:%.*]] = function_ref @_TFC17materializeForSet4Baseg8computedSi @@ -46,7 +46,7 @@ class Base { // CHECK: [[SETTER:%.*]] = function_ref @_TFC17materializeForSet4Bases8computedSi // CHECK: apply [[SETTER]]([[T2]], [[T0]]) -// CHECK: sil hidden [transparent] @_TFC17materializeForSet4Basem6storedSi : $@cc(method) @thin (Builtin.RawPointer, @inout Builtin.UnsafeValueBuffer, @owned Base) -> (Builtin.RawPointer, Optional<@thin (Builtin.RawPointer, inout Builtin.UnsafeValueBuffer, inout Base, @thick Base.Type) -> ()>) { +// CHECK: sil hidden [transparent] @_TFC17materializeForSet4Basem6storedSi : $@cc(method) @thin (Builtin.RawPointer, @inout Builtin.UnsafeValueBuffer, @guaranteed Base) -> (Builtin.RawPointer, Optional<@thin (Builtin.RawPointer, inout Builtin.UnsafeValueBuffer, inout Base, @thick Base.Type) -> ()>) { // CHECK: bb0([[BUFFER:%.*]] : $Builtin.RawPointer, [[STORAGE:%.*]] : $*Builtin.UnsafeValueBuffer, [[SELF:%.*]] : $Base): // CHECK: [[T0:%.*]] = ref_element_addr [[SELF]] : $Base, #Base.stored // CHECK: [[T1:%.*]] = address_to_pointer [[T0]] : $*Int to $Builtin.RawPointer @@ -71,7 +71,7 @@ class HasDidSet : Base { // Checking this after silgen, but before mandatory inlining, lets us // test the intent much better. -// SILGEN: sil hidden [transparent] @_TFC17materializeForSet9HasDidSetm6storedSi : $@cc(method) @thin (Builtin.RawPointer, @inout Builtin.UnsafeValueBuffer, @owned HasDidSet) -> (Builtin.RawPointer, Optional<@thin (Builtin.RawPointer, inout Builtin.UnsafeValueBuffer, inout HasDidSet, @thick HasDidSet.Type) -> ()>) { +// SILGEN: sil hidden [transparent] @_TFC17materializeForSet9HasDidSetm6storedSi : $@cc(method) @thin (Builtin.RawPointer, @inout Builtin.UnsafeValueBuffer, @guaranteed HasDidSet) -> (Builtin.RawPointer, Optional<@thin (Builtin.RawPointer, inout Builtin.UnsafeValueBuffer, inout HasDidSet, @thick HasDidSet.Type) -> ()>) { // SILGEN: bb0([[BUFFER:%.*]] : $Builtin.RawPointer, [[STORAGE:%.*]] : $*Builtin.UnsafeValueBuffer, [[SELF:%.*]] : $HasDidSet): // SILGEN: [[T2:%.*]] = pointer_to_address [[BUFFER]] : $Builtin.RawPointer to $*Int // SILGEN: [[T0:%.*]] = function_ref @_TFC17materializeForSet9HasDidSetg6storedSi @@ -87,7 +87,7 @@ class HasDidSet : Base { set(value) {} } -// CHECK: sil hidden [transparent] @_TFC17materializeForSet9HasDidSetm8computedSi : $@cc(method) @thin (Builtin.RawPointer, @inout Builtin.UnsafeValueBuffer, @owned HasDidSet) -> (Builtin.RawPointer, Optional<@thin (Builtin.RawPointer, inout Builtin.UnsafeValueBuffer, inout HasDidSet, @thick HasDidSet.Type) -> ()>) { +// CHECK: sil hidden [transparent] @_TFC17materializeForSet9HasDidSetm8computedSi : $@cc(method) @thin (Builtin.RawPointer, @inout Builtin.UnsafeValueBuffer, @guaranteed HasDidSet) -> (Builtin.RawPointer, Optional<@thin (Builtin.RawPointer, inout Builtin.UnsafeValueBuffer, inout HasDidSet, @thick HasDidSet.Type) -> ()>) { // CHECK: bb0([[BUFFER:%.*]] : $Builtin.RawPointer, [[STORAGE:%.*]] : $*Builtin.UnsafeValueBuffer, [[SELF:%.*]] : $HasDidSet): // CHECK: [[T2:%.*]] = pointer_to_address [[BUFFER]] : $Builtin.RawPointer to $*Int // CHECK: [[T0:%.*]] = function_ref @_TFC17materializeForSet9HasDidSetg8computedSi @@ -102,7 +102,7 @@ class HasDidSet : Base { class HasWeak { weak var weakvar: HasWeak? = nil } -// CHECK: sil hidden [transparent] @_TFC17materializeForSet7HasWeakm7weakvarXwGSqS0__ : $@cc(method) @thin (Builtin.RawPointer, @inout Builtin.UnsafeValueBuffer, @owned HasWeak) -> (Builtin.RawPointer, Optional<@thin (Builtin.RawPointer, inout Builtin.UnsafeValueBuffer, inout HasWeak, @thick HasWeak.Type) -> ()>) { +// CHECK: sil hidden [transparent] @_TFC17materializeForSet7HasWeakm7weakvarXwGSqS0__ : $@cc(method) @thin (Builtin.RawPointer, @inout Builtin.UnsafeValueBuffer, @guaranteed HasWeak) -> (Builtin.RawPointer, Optional<@thin (Builtin.RawPointer, inout Builtin.UnsafeValueBuffer, inout HasWeak, @thick HasWeak.Type) -> ()>) { // CHECK: bb0([[BUFFER:%.*]] : $Builtin.RawPointer, [[STORAGE:%.*]] : $*Builtin.UnsafeValueBuffer, [[SELF:%.*]] : $HasWeak): // CHECK: [[T2:%.*]] = pointer_to_address [[BUFFER]] : $Builtin.RawPointer to $*Optional // CHECK: [[T0:%.*]] = ref_element_addr [[SELF]] : $HasWeak, #HasWeak.weakvar diff --git a/test/SILGen/multi_file.swift b/test/SILGen/multi_file.swift index 88a1d2b36a4..ca8b08f9a66 100644 --- a/test/SILGen/multi_file.swift +++ b/test/SILGen/multi_file.swift @@ -15,7 +15,7 @@ func lazyPropertiesAreNotStored(var container: LazyContainer) { // CHECK-LABEL: sil hidden @_TF10multi_file29lazyRefPropertiesAreNotStored func lazyRefPropertiesAreNotStored(container: LazyContainerClass) { - // CHECK: {{%[0-9]+}} = class_method %0 : $LazyContainerClass, #LazyContainerClass.lazyVar!getter.1 : LazyContainerClass -> () -> Int , $@cc(method) @thin (@owned LazyContainerClass) -> Int + // CHECK: {{%[0-9]+}} = class_method %0 : $LazyContainerClass, #LazyContainerClass.lazyVar!getter.1 : LazyContainerClass -> () -> Int , $@cc(method) @thin (@guaranteed LazyContainerClass) -> Int println(container.lazyVar) } @@ -43,5 +43,5 @@ class HasComputedProperty: ProtocolWithProperty { set {} } } -// CHECK-LABEL: sil hidden [transparent] @_TFC10multi_file19HasComputedPropertym3fooSi : $@cc(method) @thin (Builtin.RawPointer, @inout Builtin.UnsafeValueBuffer, @owned HasComputedProperty) -> (Builtin.RawPointer, Optional<@thin (Builtin.RawPointer, inout Builtin.UnsafeValueBuffer, inout HasComputedProperty, @thick HasComputedProperty.Type) -> ()>) { +// CHECK-LABEL: sil hidden [transparent] @_TFC10multi_file19HasComputedPropertym3fooSi : $@cc(method) @thin (Builtin.RawPointer, @inout Builtin.UnsafeValueBuffer, @guaranteed HasComputedProperty) -> (Builtin.RawPointer, Optional<@thin (Builtin.RawPointer, inout Builtin.UnsafeValueBuffer, inout HasComputedProperty, @thick HasComputedProperty.Type) -> ()>) { // CHECK-LABEL: sil hidden [transparent] [thunk] @_TTWC10multi_file19HasComputedPropertyS_20ProtocolWithPropertyS_FS1_m3fooSi : $@cc(witness_method) @thin (Builtin.RawPointer, @inout Builtin.UnsafeValueBuffer, @inout HasComputedProperty) -> (Builtin.RawPointer, Optional<@thin (Builtin.RawPointer, inout Builtin.UnsafeValueBuffer, inout HasComputedProperty, @thick HasComputedProperty.Type) -> ()>) { diff --git a/test/SILGen/objc_attr_NSManaged.swift b/test/SILGen/objc_attr_NSManaged.swift index 05e2daeebe5..c79b764a91d 100644 --- a/test/SILGen/objc_attr_NSManaged.swift +++ b/test/SILGen/objc_attr_NSManaged.swift @@ -18,7 +18,7 @@ class SwiftGizmo : Gizmo { // CHECK-NOT: sil hidden @_TToFC19objc_attr_NSManaged10SwiftGizmos1xCS_1X // Make sure that we're calling through the @objc entry points. - // CHECK-LABEL: sil hidden @_TFC19objc_attr_NSManaged10SwiftGizmo7modifyX{{.*}} : $@cc(method) @thin (@owned SwiftGizmo) -> () { + // CHECK-LABEL: sil hidden @_TFC19objc_attr_NSManaged10SwiftGizmo7modifyX{{.*}} : $@cc(method) @thin (@guaranteed SwiftGizmo) -> () { func modifyX() { // CHECK: [[GETTER:%[0-9]+]] = class_method [volatile] [[SELF:%.*]] : $SwiftGizmo, #SwiftGizmo.x!getter.1.foreign : SwiftGizmo -> () -> X , $@cc(objc_method) @thin (SwiftGizmo) -> @autoreleased X // CHECK-NEXT: apply [[GETTER]]([[SELF]]) : $@cc(objc_method) @thin (SwiftGizmo) -> @autoreleased X diff --git a/test/SILGen/objc_blocks_bridging.swift b/test/SILGen/objc_blocks_bridging.swift index db1528f2bcc..a9e5fe5e32e 100644 --- a/test/SILGen/objc_blocks_bridging.swift +++ b/test/SILGen/objc_blocks_bridging.swift @@ -9,7 +9,7 @@ import Foundation // CHECK: [[COPY:%.*]] = copy_block %0 // CHECK: [[THUNK:%.*]] = function_ref @_TTRXFdCb_dSi_dSi_XFo_dSi_dSi_ // CHECK: [[BRIDGED:%.*]] = partial_apply [[THUNK]]([[COPY]]) - // CHECK: [[NATIVE:%.*]] = function_ref @_TFC20objc_blocks_bridging3Foo3foo{{.*}} : $@cc(method) @thin (@owned @callee_owned (Int) -> Int, Int, @owned Foo) -> Int + // CHECK: [[NATIVE:%.*]] = function_ref @_TFC20objc_blocks_bridging3Foo3foo{{.*}} : $@cc(method) @thin (@owned @callee_owned (Int) -> Int, Int, @guaranteed Foo) -> Int // CHECK: apply [[NATIVE]]([[BRIDGED]], %1, %2) dynamic func foo(f: Int -> Int, x: Int) -> Int { return f(x) @@ -19,7 +19,7 @@ import Foundation // CHECK: [[COPY:%.*]] = copy_block %0 // CHECK: [[THUNK:%.*]] = function_ref @_TTRXFdCb_dCSo8NSString_aS__XFo_oSS_oSS_ // CHECK: [[BRIDGED:%.*]] = partial_apply [[THUNK]]([[COPY]]) - // CHECK: [[NATIVE:%.*]] = function_ref @_TFC20objc_blocks_bridging3Foo3bar{{.*}} : $@cc(method) @thin (@owned @callee_owned (@owned String) -> @owned String, @owned String, @owned Foo) -> @owned String + // CHECK: [[NATIVE:%.*]] = function_ref @_TFC20objc_blocks_bridging3Foo3bar{{.*}} : $@cc(method) @thin (@owned @callee_owned (@owned String) -> @owned String, @owned String, @guaranteed Foo) -> @owned String // CHECK: apply [[NATIVE]]([[BRIDGED]], {{%.*}}, %2) dynamic func bar(f: String -> String, x: String) -> String { return f(x) @@ -29,7 +29,7 @@ import Foundation // CHECK: [[COPY:%.*]] = copy_block %0 // CHECK: [[THUNK:%.*]] = function_ref @_TTRXFdCb_dGSqCSo8NSString__aGSqS___XFo_oGSqSS__oGSqSS__ // CHECK: [[BRIDGED:%.*]] = partial_apply [[THUNK]]([[COPY]]) - // CHECK: [[NATIVE:%.*]] = function_ref @_TFC20objc_blocks_bridging3Foo3bas{{.*}} : $@cc(method) @thin (@owned @callee_owned (@owned Optional) -> @owned Optional, @owned Optional, @owned Foo) -> @owned Optional + // CHECK: [[NATIVE:%.*]] = function_ref @_TFC20objc_blocks_bridging3Foo3bas{{.*}} : $@cc(method) @thin (@owned @callee_owned (@owned Optional) -> @owned Optional, @owned Optional, @guaranteed Foo) -> @owned Optional // CHECK: apply [[NATIVE]]([[BRIDGED]], {{%.*}}, %2) dynamic func bas(f: String? -> String?, x: String?) -> String? { return f(x) @@ -55,7 +55,7 @@ import Foundation // CHECK: [[BRIDGED:%.*]] = partial_apply [[BLOCK_THUNK]]([[BLOCK]]) // CHECK: [[REABSTRACT_THUNK:%.*]] = function_ref @_TTRXFo_oSS_oSS_XFo_iSS_iSS_ // CHECK: [[REABSTRACT:%.*]] = partial_apply [[REABSTRACT_THUNK]]([[BRIDGED]]) - // CHECK: [[NATIVE:%.*]] = function_ref @_TFC20objc_blocks_bridging3Foo7optFunc{{.*}} : $@cc(method) @thin (@owned Optional String>, @owned String, @owned Foo) -> @owned Optional + // CHECK: [[NATIVE:%.*]] = function_ref @_TFC20objc_blocks_bridging3Foo7optFunc{{.*}} : $@cc(method) @thin (@owned Optional String>, @owned String, @guaranteed Foo) -> @owned Optional // CHECK: apply [[NATIVE]] dynamic func optFunc(f: (String -> String)?, x: String) -> String? { return f?(x) diff --git a/test/SILGen/objc_bridging.swift b/test/SILGen/objc_bridging.swift index d512ee49449..0b94b79fc9e 100644 --- a/test/SILGen/objc_bridging.swift +++ b/test/SILGen/objc_bridging.swift @@ -241,7 +241,8 @@ class Bas : NSObject { // CHECK: strong_retain [[THIS]] : $Bas // CHECK: // function_ref objc_bridging.Bas.strRealProp.getter // CHECK: [[PROPIMPL:%.*]] = function_ref @_TFC13objc_bridging3Basg11strRealPropSS - // CHECK: [[PROP_COPY:%.*]] = apply [[PROPIMPL]]([[THIS]]) : $@cc(method) @thin (@owned Bas) -> @owned String + // CHECK: [[PROP_COPY:%.*]] = apply [[PROPIMPL]]([[THIS]]) : $@cc(method) @thin (@guaranteed Bas) -> @owned String + // CHECK: strong_release [[THIS]] // CHECK: [[STRING_TO_NSSTRING:%.*]] = function_ref @swift_StringToNSString // CHECK: [[NSSTR:%.*]] = apply [[STRING_TO_NSSTRING]]([[PROP_COPY]]) // CHECK: autorelease_return [[NSSTR]] @@ -352,18 +353,21 @@ class Bas : NSObject { // CHECK: [[CONV_FN:%[0-9]+]] = function_ref @_TF10Foundation22_convertNSArrayToArray{{.*}} : $@thin <τ_0_0> (@owned Optional) -> @owned Array<τ_0_0> // CHECK-NEXT: [[OPT_NSARRAY:%[0-9]+]] = enum $Optional, #Optional.Some!enumelt.1, [[NSARRAY]] : $NSArray // CHECK-NEXT: [[ARRAY:%[0-9]+]] = apply [[CONV_FN]]([[OPT_NSARRAY]]) : $@thin <τ_0_0> (@owned Optional) -> @owned Array<τ_0_0> - // CHECK: [[SWIFT_FN:%[0-9]+]] = function_ref @_TFC13objc_bridging3Bas{{.*}} : $@cc(method) @thin (@owned Array, @owned Bas) -> () - // CHECK: [[RESULT:%[0-9]+]] = apply [[SWIFT_FN]]([[ARRAY]], [[SELF]]) : $@cc(method) @thin (@owned Array, @owned Bas) -> () + // CHECK: [[SWIFT_FN:%[0-9]+]] = function_ref @_TFC13objc_bridging3Bas{{.*}} : $@cc(method) @thin (@owned Array, @guaranteed Bas) -> () + // CHECK: [[RESULT:%[0-9]+]] = apply [[SWIFT_FN]]([[ARRAY]], [[SELF]]) : $@cc(method) @thin (@owned Array, @guaranteed Bas) -> () + // CHECK: strong_release [[SELF]] : $Bas // CHECK: return [[RESULT]] : $() func arrayArg(array: [AnyObject]) { } // CHECK-LABEL: sil hidden @_TToFC13objc_bridging3Bas11arrayResult{{.*}} : $@cc(objc_method) @thin (Bas) -> @autoreleased NSArray // CHECK: bb0([[SELF:%[0-9]+]] : $Bas): // CHECK: strong_retain [[SELF]] : $Bas - // CHECK: [[SWIFT_FN:%[0-9]+]] = function_ref @_TFC13objc_bridging3Bas11arrayResult{{.*}} : $@cc(method) @thin (@owned Bas) -> @owned Array - // CHECK: [[ARRAY:%[0-9]+]] = apply [[SWIFT_FN]]([[SELF]]) : $@cc(method) @thin (@owned Bas) -> @owned Array + // CHECK: [[SWIFT_FN:%[0-9]+]] = function_ref @_TFC13objc_bridging3Bas11arrayResult{{.*}} : $@cc(method) @thin (@guaranteed Bas) -> @owned Array + // CHECK: [[ARRAY:%[0-9]+]] = apply [[SWIFT_FN]]([[SELF]]) : $@cc(method) @thin (@guaranteed Bas) -> @owned Array + // CHECK: strong_release [[SELF]] // CHECK: [[CONV_FN:%[0-9]+]] = function_ref @_TF10Foundation22_convertArrayToNSArray{{.*}} : $@thin <τ_0_0> (@owned Array<τ_0_0>) -> @owned NSArray // CHECK: [[NSARRAY:%[0-9]+]] = apply [[CONV_FN]]([[ARRAY]]) : $@thin <τ_0_0> (@owned Array<τ_0_0>) -> @owned NSArray + // CHECK: autorelease_return [[NSARRAY]] func arrayResult() -> [AnyObject] { return [] } // CHECK-LABEL: sil hidden [transparent] @_TToFC13objc_bridging3Basg9arrayPropGSaSS_ : $@cc(objc_method) @thin (Bas) -> @autoreleased NSArray diff --git a/test/SILGen/objc_currying.swift b/test/SILGen/objc_currying.swift index 71b3837a532..bc86b835db5 100644 --- a/test/SILGen/objc_currying.swift +++ b/test/SILGen/objc_currying.swift @@ -9,8 +9,11 @@ func curry_pod(x: CurryTest) -> Int -> Int { return x.pod } // CHECK-LABEL: sil hidden @_TF13objc_currying9curry_podFCSo9CurryTestFSiSi : $@thin (@owned CurryTest) -> @owned @callee_owned (Int) -> Int -// CHECK: [[THUNK:%.*]] = function_ref [[THUNK_FOO_1:@_TTOFCSo9CurryTest3podFS_FSiSi]] +// CHECK: bb0([[ARG1:%.*]] : $CurryTest): +// CHECK: strong_retain [[ARG1]] +// CHECK: [[THUNK:%.*]] = function_ref [[THUNK_FOO_1:@_TTOFCSo9CurryTest3podFS_FSiSi]] : $@thin (@owned CurryTest) -> @owned @callee_owned (Int) -> Int // CHECK: [[FN:%.*]] = apply [[THUNK]](%0) +// CHECK: strong_release [[ARG1]] // CHECK: return [[FN]] // CHECK: sil shared [[THUNK_FOO_1]] : $@thin (@owned CurryTest) -> @owned @callee_owned (Int) -> Int @@ -18,10 +21,12 @@ func curry_pod(x: CurryTest) -> Int -> Int { // CHECK: [[FN:%.*]] = partial_apply [[THUNK]](%0) // CHECK: return [[FN]] -// CHECK: sil shared [[THUNK_FOO_2]] : $@cc(method) @thin (Int, @owned CurryTest) -> Int +// CHECK: sil shared [[THUNK_FOO_2]] : $@cc(method) @thin (Int, @guaranteed CurryTest) -> Int +// CHECK: bb0([[ARG1:%.*]] : $Int, [[ARG2:%.*]] : $CurryTest): +// CHECK: strong_retain [[ARG2]] // CHECK: [[METHOD:%.*]] = class_method [volatile] %1 : $CurryTest, #CurryTest.pod!1.foreign // CHECK: [[RESULT:%.*]] = apply [[METHOD]](%0, %1) -// CHECK: strong_release %1 +// CHECK: strong_release [[ARG2]] // CHECK: return [[RESULT]] func curry_bridged(x: CurryTest) -> String! -> String! { @@ -37,7 +42,7 @@ func curry_bridged(x: CurryTest) -> String! -> String! { // CHECK: [[FN:%.*]] = partial_apply [[THUNK]](%0) // CHECK: return [[FN]] -// CHECK: sil shared [[THUNK_BAR_2]] : $@cc(method) @thin (@owned ImplicitlyUnwrappedOptional, @owned CurryTest) -> @owned ImplicitlyUnwrappedOptional +// CHECK: sil shared [[THUNK_BAR_2]] : $@cc(method) @thin (@owned ImplicitlyUnwrappedOptional, @guaranteed CurryTest) -> @owned ImplicitlyUnwrappedOptional // CHECK: function_ref @swift_StringToNSString // CHECK: [[METHOD:%.*]] = class_method [volatile] %1 : $CurryTest, #CurryTest.bridged!1.foreign // CHECK: [[RES:%.*]] = apply [[METHOD]]({{%.*}}, %1) : $@cc(objc_method) @thin (ImplicitlyUnwrappedOptional, CurryTest) -> @autoreleased ImplicitlyUnwrappedOptional @@ -59,7 +64,9 @@ func curry_returnsInnerPointer(x: CurryTest) -> () -> UnsafeMutablePointer // CHECK: [[FN:%.*]] = partial_apply [[THUNK]](%0) // CHECK: return [[FN]] -// CHECK: sil shared @_TTOFCSo9CurryTest19returnsInnerPointerfS_FT_GVSs20UnsafeMutablePointerT__ : $@cc(method) @thin (@owned CurryTest) -> UnsafeMutablePointer<()> +// CHECK: sil shared @_TTOFCSo9CurryTest19returnsInnerPointerfS_FT_GVSs20UnsafeMutablePointerT__ : $@cc(method) @thin (@guaranteed CurryTest) -> UnsafeMutablePointer<()> +// CHECK: bb0([[ARG1:%.*]] : +// CHECK: strong_retain [[ARG1]] // CHECK: [[METHOD:%.*]] = class_method [volatile] %0 : $CurryTest, #CurryTest.returnsInnerPointer!1.foreign // CHECK: [[RES:%.*]] = apply [[METHOD]](%0) : $@cc(objc_method) @thin (CurryTest) -> @unowned_inner_pointer UnsafeMutablePointer<()> // CHECK: autorelease_value %0 diff --git a/test/SILGen/objc_dictionary_bridging.swift b/test/SILGen/objc_dictionary_bridging.swift index 3f9c0724c20..968ae8823fb 100644 --- a/test/SILGen/objc_dictionary_bridging.swift +++ b/test/SILGen/objc_dictionary_bridging.swift @@ -14,8 +14,8 @@ import gizmo // CHECK-NEXT: [[OPT_NSDICT:%[0-9]+]] = enum $Optional, #Optional.Some!enumelt.1, [[NSDICT]] : $NSDictionary // CHECK-NEXT: [[DICT:%[0-9]+]] = apply [[CONVERTER]]([[OPT_NSDICT]]) : $@thin <τ_0_0, τ_0_1 where τ_0_0 : NSObject, τ_0_0 : Hashable, τ_0_1 : AnyObject> (@owned Optional) -> @owned Dictionary<τ_0_0, τ_0_1> - // CHECK: [[SWIFT_FN:%[0-9]+]] = function_ref @_TFC24objc_dictionary_bridging3Foo23bridge_Dictionary_paramfS0_FGVSs10DictionaryS0_S0__T_ : $@cc(method) @thin (@owned Dictionary, @owned Foo) -> () - // CHECK: [[RESULT:%[0-9]+]] = apply [[SWIFT_FN]]([[DICT]], [[SELF]]) : $@cc(method) @thin (@owned Dictionary, @owned Foo) -> () + // CHECK: [[SWIFT_FN:%[0-9]+]] = function_ref @_TFC24objc_dictionary_bridging3Foo23bridge_Dictionary_paramfS0_FGVSs10DictionaryS0_S0__T_ : $@cc(method) @thin (@owned Dictionary, @guaranteed Foo) -> () + // CHECK: [[RESULT:%[0-9]+]] = apply [[SWIFT_FN]]([[DICT]], [[SELF]]) : $@cc(method) @thin (@owned Dictionary, @guaranteed Foo) -> () // CHECK: return [[RESULT]] : $() } @@ -23,8 +23,8 @@ import gizmo // CHECK-LABEL: sil hidden @_TToFC24objc_dictionary_bridging3Foo24bridge_Dictionary_result{{.*}} : $@cc(objc_method) @thin (Foo) -> @autoreleased NSDictionary func bridge_Dictionary_result() -> Dictionary { // CHECK: bb0([[SELF:%[0-9]+]] : $Foo): - // CHECK: [[SWIFT_FN:%[0-9]+]] = function_ref @_TFC24objc_dictionary_bridging3Foo24bridge_Dictionary_result{{.*}} : $@cc(method) @thin (@owned Foo) -> @owned Dictionary - // CHECK-NEXT: [[DICT:%[0-9]+]] = apply [[SWIFT_FN]]([[SELF]]) : $@cc(method) @thin (@owned Foo) -> @owned Dictionary + // CHECK: [[SWIFT_FN:%[0-9]+]] = function_ref @_TFC24objc_dictionary_bridging3Foo24bridge_Dictionary_result{{.*}} : $@cc(method) @thin (@guaranteed Foo) -> @owned Dictionary + // CHECK-NEXT: [[DICT:%[0-9]+]] = apply [[SWIFT_FN]]([[SELF]]) : $@cc(method) @thin (@guaranteed Foo) -> @owned Dictionary // CHECK: [[CONVERTER:%[0-9]+]] = function_ref @_TF10Foundation32_convertDictionaryToNSDictionary{{.*}} : $@thin <τ_0_0, τ_0_1 where τ_0_0 : Hashable> (@owned Dictionary<τ_0_0, τ_0_1>) -> @owned NSDictionary // CHECK-NEXT: [[NSDICT:%[0-9]+]] = apply [[CONVERTER]]([[DICT]]) : $@thin <τ_0_0, τ_0_1 where τ_0_0 : Hashable> (@owned Dictionary<τ_0_0, τ_0_1>) -> @owned NSDictionary @@ -36,8 +36,8 @@ import gizmo // Property getter // CHECK-LABEL: sil hidden [transparent] @_TToFC24objc_dictionary_bridging3Foog8propertyGVSs10DictionaryS0_S0__ : $@cc(objc_method) @thin (Foo) -> @autoreleased NSDictionary // CHECK: bb0([[SELF:%[0-9]+]] : $Foo): - // CHECK: [[GETTER:%[0-9]+]] = function_ref @_TFC24objc_dictionary_bridging3Foog8propertyGVSs10DictionaryS0_S0__ : $@cc(method) @thin (@owned Foo) -> @owned Dictionary - // CHECK: [[DICT:%[0-9]+]] = apply [[GETTER]]([[SELF]]) : $@cc(method) @thin (@owned Foo) -> @owned Dictionary + // CHECK: [[GETTER:%[0-9]+]] = function_ref @_TFC24objc_dictionary_bridging3Foog8propertyGVSs10DictionaryS0_S0__ : $@cc(method) @thin (@guaranteed Foo) -> @owned Dictionary + // CHECK: [[DICT:%[0-9]+]] = apply [[GETTER]]([[SELF]]) : $@cc(method) @thin (@guaranteed Foo) -> @owned Dictionary // CHECK: [[CONVERTER:%[0-9]+]] = function_ref @_TF10Foundation32_convertDictionaryToNSDictionary{{.*}} : $@thin <τ_0_0, τ_0_1 where τ_0_0 : Hashable> (@owned Dictionary<τ_0_0, τ_0_1>) -> @owned NSDictionary // CHECK: [[NSDICT:%[0-9]+]] = apply [[CONVERTER]]([[DICT]]) : $@thin <τ_0_0, τ_0_1 where τ_0_0 : Hashable> (@owned Dictionary<τ_0_0, τ_0_1>) -> @owned NSDictionary @@ -50,8 +50,8 @@ import gizmo // CHECK: [[OPT_NSDICT:%[0-9]+]] = enum $Optional, #Optional.Some!enumelt.1, [[NSDICT]] : $NSDictionary // CHECK: [[DICT:%[0-9]+]] = apply [[CONVERTER]]([[OPT_NSDICT]]) : $@thin <τ_0_0, τ_0_1 where τ_0_0 : NSObject, τ_0_0 : Hashable, τ_0_1 : AnyObject> (@owned Optional) -> @owned Dictionary<τ_0_0, τ_0_1> -// CHECK: [[SETTER:%[0-9]+]] = function_ref @_TFC24objc_dictionary_bridging3Foos8propertyGVSs10DictionaryS0_S0__ : $@cc(method) @thin (@owned Dictionary, @owned Foo) -> () -// CHECK: [[RESULT:%[0-9]+]] = apply [[SETTER]]([[DICT]], [[SELF]]) : $@cc(method) @thin (@owned Dictionary, @owned Foo) -> () +// CHECK: [[SETTER:%[0-9]+]] = function_ref @_TFC24objc_dictionary_bridging3Foos8propertyGVSs10DictionaryS0_S0__ : $@cc(method) @thin (@owned Dictionary, @guaranteed Foo) -> () +// CHECK: [[RESULT:%[0-9]+]] = apply [[SETTER]]([[DICT]], [[SELF]]) : $@cc(method) @thin (@owned Dictionary, @guaranteed Foo) -> () // CHECK: return [[RESULT]] : $() // CHECK-LABEL: sil hidden [transparent] @_TToFC24objc_dictionary_bridging3Foog19nonVerbatimProperty{{.*}} : $@cc(objc_method) @thin (Foo) -> @autoreleased NSDictionary diff --git a/test/SILGen/objc_metatypes.swift b/test/SILGen/objc_metatypes.swift index ef1a1a06c2f..9388ab32eec 100644 --- a/test/SILGen/objc_metatypes.swift +++ b/test/SILGen/objc_metatypes.swift @@ -16,7 +16,7 @@ class A { // CHECK: [[M_AS_THICK:%[0-9]+]] = objc_to_thick_metatype [[M]] : $@objc_metatype ObjCClass.Type to $@thick ObjCClass.Type // CHECK: [[NATIVE_FOO:%[0-9]+]] = function_ref @_TFC14objc_metatypes1A3foo - // CHECK: [[NATIVE_RESULT:%[0-9]+]] = apply [[NATIVE_FOO]]([[M_AS_THICK]], [[SELF]]) : $@cc(method) @thin (@thick ObjCClass.Type, @owned A) -> @thick ObjCClass.Type + // CHECK: [[NATIVE_RESULT:%[0-9]+]] = apply [[NATIVE_FOO]]([[M_AS_THICK]], [[SELF]]) : $@cc(method) @thin (@thick ObjCClass.Type, @guaranteed A) -> @thick ObjCClass.Type // CHECK: [[OBJC_RESULT:%[0-9]+]] = thick_to_objc_metatype [[NATIVE_RESULT]] : $@thick ObjCClass.Type to $@objc_metatype ObjCClass.Type // CHECK: return [[OBJC_RESULT]] : $@objc_metatype ObjCClass.Type return m diff --git a/test/SILGen/objc_properties.swift b/test/SILGen/objc_properties.swift index d9a33532485..de3d2d00e71 100644 --- a/test/SILGen/objc_properties.swift +++ b/test/SILGen/objc_properties.swift @@ -47,7 +47,7 @@ class A { other.prop = x } - // CHECK-LABEL: sil hidden @_TFC15objc_properties1Ad : $@cc(method) @thin (@owned A) -> @owned Builtin.NativeObject { + // CHECK-LABEL: sil hidden @_TFC15objc_properties1Ad : $@cc(method) @thin (@guaranteed A) -> @owned Builtin.NativeObject { // CHECK-NOT: class_method {{.*}} #A.prop // CHECK: } deinit { @@ -84,12 +84,12 @@ func testComputedPropSet(a: A, i: Int) { // 'super' property references. class B : A { @objc override var computedProp: Int { - // CHECK-LABEL: sil hidden @_TFC15objc_properties1Bg12computedPropSi : $@cc(method) @thin (@owned B) -> Int + // CHECK-LABEL: sil hidden @_TFC15objc_properties1Bg12computedPropSi : $@cc(method) @thin (@guaranteed B) -> Int get { // CHECK: super_method [volatile] [[SELF:%[0-9]+]] : $B, #A.computedProp!getter.1.foreign : A -> () -> Int , $@cc(objc_method) @thin (A) -> Int return super.computedProp } - // CHECK-LABEL: sil hidden @_TFC15objc_properties1Bs12computedPropSi : $@cc(method) @thin (Int, @owned B) -> () + // CHECK-LABEL: sil hidden @_TFC15objc_properties1Bs12computedPropSi : $@cc(method) @thin (Int, @guaranteed B) -> () set(value) { // CHECK: super_method [volatile] [[SELF:%[0-9]+]] : $B, #A.computedProp!setter.1.foreign : A -> (Int) -> () , $@cc(objc_method) @thin (Int, A) -> () super.computedProp = value @@ -101,7 +101,7 @@ class B : A { // Test the @NSCopying attribute. class TestNSCopying { // CHECK: // objc_properties.TestNSCopying.property.setter : ObjectiveC.NSString - // CHECK-NEXT: sil hidden [transparent] @_TFC15objc_properties13TestNSCopyings8propertyCSo8NSString : $@cc(method) @thin (@owned NSString, @owned TestNSCopying) -> () + // CHECK-NEXT: sil hidden [transparent] @_TFC15objc_properties13TestNSCopyings8propertyCSo8NSString : $@cc(method) @thin (@owned NSString, @guaranteed TestNSCopying) -> () // CHECK-NEXT: bb0(%0 : $NSString, %1 : $TestNSCopying): // CHECK: class_method [volatile] %0 : $NSString, #NSString.copyWithZone!1.foreign @NSCopying var property : NSString diff --git a/test/SILGen/objc_set_bridging.swift b/test/SILGen/objc_set_bridging.swift index 78986d04bea..66cb3f3e99c 100644 --- a/test/SILGen/objc_set_bridging.swift +++ b/test/SILGen/objc_set_bridging.swift @@ -15,8 +15,8 @@ import gizmo // CHECK: [[CONVERTER:%[0-9]+]] = function_ref @_TF10Foundation18_convertNSSetToSet{{.*}} : $@thin <τ_0_0 where τ_0_0 : NSObject, τ_0_0 : Hashable> (@owned Optional) -> @owned Set<τ_0_0> // CHECK: [[OPT_NSSET:%[0-9]+]] = enum $Optional, #Optional.Some!enumelt.1, [[NSSET]] : $NSSet // CHECK: [[SET:%[0-9]+]] = apply [[CONVERTER]]([[OPT_NSSET]]) : $@thin <τ_0_0 where τ_0_0 : NSObject, τ_0_0 : Hashable> (@owned Optional) -> @owned Set<τ_0_0> - // CHECK: [[SWIFT_FN:%[0-9]+]] = function_ref @_TFC17objc_set_bridging3Foo16bridge_Set_param{{.*}} : $@cc(method) @thin (@owned Set, @owned Foo) -> () - // CHECK: [[RESULT:%[0-9]+]] = apply [[SWIFT_FN]]([[SET]], [[SELF]]) : $@cc(method) @thin (@owned Set, @owned Foo) -> () + // CHECK: [[SWIFT_FN:%[0-9]+]] = function_ref @_TFC17objc_set_bridging3Foo16bridge_Set_param{{.*}} : $@cc(method) @thin (@owned Set, @guaranteed Foo) -> () + // CHECK: [[RESULT:%[0-9]+]] = apply [[SWIFT_FN]]([[SET]], [[SELF]]) : $@cc(method) @thin (@owned Set, @guaranteed Foo) -> () // CHECK: return [[RESULT]] : $() } @@ -25,8 +25,8 @@ import gizmo func bridge_Set_result() -> Set { // CHECK: bb0([[SELF:%[0-9]+]] : $Foo): // CHECK: strong_retain [[SELF]] : $Foo - // CHECK: [[SWIFT_FN:%[0-9]+]] = function_ref @_TFC17objc_set_bridging3Foo17bridge_Set_result{{.*}} : $@cc(method) @thin (@owned Foo) -> @owned Set - // CHECK: [[SET:%[0-9]+]] = apply [[SWIFT_FN]]([[SELF]]) : $@cc(method) @thin (@owned Foo) -> @owned Set + // CHECK: [[SWIFT_FN:%[0-9]+]] = function_ref @_TFC17objc_set_bridging3Foo17bridge_Set_result{{.*}} : $@cc(method) @thin (@guaranteed Foo) -> @owned Set + // CHECK: [[SET:%[0-9]+]] = apply [[SWIFT_FN]]([[SELF]]) : $@cc(method) @thin (@guaranteed Foo) -> @owned Set // CHECK: [[CONVERTER:%[0-9]+]] = function_ref @_TF10Foundation18_convertSetToNSSet{{.*}} : $@thin <τ_0_0 where τ_0_0 : Hashable> (@owned Set<τ_0_0>) -> @owned NSSet // CHECK: [[NSSET:%[0-9]+]] = apply [[CONVERTER]]([[SET]]) : $@thin <τ_0_0 where τ_0_0 : Hashable> (@owned Set<τ_0_0>) -> @owned NSSet // CHECK: autorelease_return [[NSSET]] : $NSSet @@ -38,8 +38,8 @@ import gizmo // CHECK-LABEL: sil hidden [transparent] @_TToFC17objc_set_bridging3Foog8property{{.*}} : $@cc(objc_method) @thin (Foo) -> @autoreleased NSSet // CHECK: bb0([[SELF:%[0-9]+]] : $Foo): // CHECK: strong_retain [[SELF]] : $Foo - // CHECK: [[GETTER:%[0-9]+]] = function_ref @_TFC17objc_set_bridging3Foog8property{{.*}} : $@cc(method) @thin (@owned Foo) -> @owned Set - // CHECK: [[SET:%[0-9]+]] = apply [[GETTER]]([[SELF]]) : $@cc(method) @thin (@owned Foo) -> @owned Set + // CHECK: [[GETTER:%[0-9]+]] = function_ref @_TFC17objc_set_bridging3Foog8property{{.*}} : $@cc(method) @thin (@guaranteed Foo) -> @owned Set + // CHECK: [[SET:%[0-9]+]] = apply [[GETTER]]([[SELF]]) : $@cc(method) @thin (@guaranteed Foo) -> @owned Set // CHECK: [[CONVERTER:%[0-9]+]] = function_ref @_TF10Foundation18_convertSetToNSSet{{.*}} : $@thin <τ_0_0 where τ_0_0 : Hashable> (@owned Set<τ_0_0>) -> @owned NSSet // CHECK: [[NSSET:%[0-9]+]] = apply [[CONVERTER]]([[SET]]) : $@thin <τ_0_0 where τ_0_0 : Hashable> (@owned Set<τ_0_0>) -> @owned NSSet // CHECK: autorelease_return [[NSSET]] : $NSSet @@ -52,8 +52,9 @@ import gizmo // CHECK: [[CONVERTER:%[0-9]+]] = function_ref @_TF10Foundation18_convertNSSetToSet{{.*}} : $@thin <τ_0_0 where τ_0_0 : NSObject, τ_0_0 : Hashable> (@owned Optional) -> @owned Set<τ_0_0> // CHECK: [[OPT_NSSET:%[0-9]+]] = enum $Optional, #Optional.Some!enumelt.1, [[NSSET]] : $NSSet // CHECK: [[SET:%[0-9]+]] = apply [[CONVERTER]]([[OPT_NSSET]]) : $@thin <τ_0_0 where τ_0_0 : NSObject, τ_0_0 : Hashable> (@owned Optional) -> @owned Set<τ_0_0> - // CHECK: [[SETTER:%[0-9]+]] = function_ref @_TFC17objc_set_bridging3Foos8property{{.*}} : $@cc(method) @thin (@owned Set, @owned Foo) -> () - // CHECK: [[RESULT:%[0-9]+]] = apply [[SETTER]]([[SET]], [[SELF]]) : $@cc(method) @thin (@owned Set, @owned Foo) -> () + // CHECK: [[SETTER:%[0-9]+]] = function_ref @_TFC17objc_set_bridging3Foos8property{{.*}} : $@cc(method) @thin (@owned Set, @guaranteed Foo) -> () + // CHECK: [[RESULT:%[0-9]+]] = apply [[SETTER]]([[SET]], [[SELF]]) : $@cc(method) @thin (@owned Set, @guaranteed Foo) -> () + // CHECK: strong_release [[SELF]] : $Foo // CHECK: return [[RESULT]] : $() // CHECK-LABEL: sil hidden [transparent] @_TToFC17objc_set_bridging3Foog19nonVerbatimProperty{{.*}} : $@cc(objc_method) @thin (Foo) -> @autoreleased NSSet diff --git a/test/SILGen/objc_subscript.swift b/test/SILGen/objc_subscript.swift index 3d7e639a74e..e890b5b2594 100644 --- a/test/SILGen/objc_subscript.swift +++ b/test/SILGen/objc_subscript.swift @@ -28,12 +28,12 @@ func testSubscriptSet(a: A, i: Int, v: ObjCClass) { // 'super' subscript usage class B : A { @objc override subscript (i: Int) -> ObjCClass { - // CHECK-LABEL: sil hidden @_TFC14objc_subscript1Bg9subscriptFSiCS_9ObjCClass : $@cc(method) @thin (Int, @owned B) -> @owned ObjCClass + // CHECK-LABEL: sil hidden @_TFC14objc_subscript1Bg9subscriptFSiCS_9ObjCClass : $@cc(method) @thin (Int, @guaranteed B) -> @owned ObjCClass get { // CHECK: super_method [volatile] [[SELF:%[0-9]+]] : $B, #A.subscript!getter.1.foreign : A -> (Int) -> ObjCClass , $@cc(objc_method) @thin (Int, A) -> @autoreleased ObjCClass return super[i] } - // CHECK-LABEL: sil hidden @_TFC14objc_subscript1Bs9subscriptFSiCS_9ObjCClass : $@cc(method) @thin (@owned ObjCClass, Int, @owned B) -> () + // CHECK-LABEL: sil hidden @_TFC14objc_subscript1Bs9subscriptFSiCS_9ObjCClass : $@cc(method) @thin (@owned ObjCClass, Int, @guaranteed B) -> () set(value) { // CHECK: super_method [volatile] [[SELF:%[0-9]+]] : $B, #A.subscript!setter.1.foreign : A -> (ObjCClass, Int) -> () , $@cc(objc_method) @thin (ObjCClass, Int, A) -> () super[i] = value diff --git a/test/SILGen/objc_super.swift b/test/SILGen/objc_super.swift index 4a72fd9dcd2..93466d92c06 100644 --- a/test/SILGen/objc_super.swift +++ b/test/SILGen/objc_super.swift @@ -20,7 +20,7 @@ class Hoozit : Gizmo { super.runce() } - // CHECK-LABEL: sil hidden @_TFC10objc_super6Hoozit4frobfS0_FT_T_ : $@cc(method) @thin (@owned Hoozit) -> () + // CHECK-LABEL: sil hidden @_TFC10objc_super6Hoozit4frobfS0_FT_T_ : $@cc(method) @thin (@guaranteed Hoozit) -> () override func frob() { // CHECK: super_method [volatile] {{%.*}} : $Hoozit, #Gizmo.frob!1.foreign super.frob() diff --git a/test/SILGen/objc_thunks.swift b/test/SILGen/objc_thunks.swift index ae6b9ee493a..b7dc9157bf2 100644 --- a/test/SILGen/objc_thunks.swift +++ b/test/SILGen/objc_thunks.swift @@ -11,9 +11,10 @@ class Hoozit : Gizmo { // CHECK-NEXT: retain [[Y]] // CHECK-NEXT: retain [[THIS]] // CHECK-NEXT: // function_ref - // CHECK-NEXT: [[NATIVE:%.*]] = function_ref @_TFC11objc_thunks6Hoozit7typicalfS0_FTSi1yCSo5Gizmo_S1_ : $@cc(method) @thin (Int, @owned Gizmo, @owned Hoozit) -> @owned Gizmo + // CHECK-NEXT: [[NATIVE:%.*]] = function_ref @_TFC11objc_thunks6Hoozit7typicalfS0_FTSi1yCSo5Gizmo_S1_ : $@cc(method) @thin (Int, @owned Gizmo, @guaranteed Hoozit) -> @owned Gizmo // CHECK-NEXT: [[RES:%.*]] = apply [[NATIVE]]([[X]], [[Y]], [[THIS]]) {{.*}} line:[[@LINE-7]]:8:auto_gen - // CHECK-NEXT: autorelease_return [[RES]] : $Gizmo // {{.*}} line:[[@LINE-8]]:8:auto_gen + // CHECK-NEXT: strong_release [[THIS]] : $Hoozit // {{.*}} + // CHECK-NEXT: autorelease_return [[RES]] : $Gizmo // {{.*}} line:[[@LINE-9]]:8:auto_gen // CHECK-NEXT: } // NS_CONSUMES_SELF by inheritance @@ -21,8 +22,9 @@ class Hoozit : Gizmo { // CHECK-LABEL: sil hidden @_TToFC11objc_thunks6Hoozit4forkfS0_FT_T_ : $@cc(objc_method) @thin (@owned Hoozit) -> () { // CHECK-NEXT: bb0([[THIS:%.*]] : $Hoozit): // CHECK-NEXT: // function_ref - // CHECK-NEXT: [[NATIVE:%.*]] = function_ref @_TFC11objc_thunks6Hoozit4forkfS0_FT_T_ : $@cc(method) @thin (@owned Hoozit) -> () + // CHECK-NEXT: [[NATIVE:%.*]] = function_ref @_TFC11objc_thunks6Hoozit4forkfS0_FT_T_ : $@cc(method) @thin (@guaranteed Hoozit) -> () // CHECK-NEXT: apply [[NATIVE]]([[THIS]]) + // CHECK-NEXT: strong_release [[THIS]] // CHECK-NEXT: return // CHECK-NEXT: } @@ -42,10 +44,10 @@ class Hoozit : Gizmo { // CHECK-NEXT: bb0([[THIS:%.*]] : $Hoozit): // CHECK-NEXT: retain [[THIS]] // CHECK-NEXT: // function_ref - // CHECK-NEXT: [[NATIVE:%.*]] = function_ref @_TFC11objc_thunks6Hoozit7copyFoofS0_FT_CSo5Gizmo : $@cc(method) @thin (@owned Hoozit) -> @owned Gizmo + // CHECK-NEXT: [[NATIVE:%.*]] = function_ref @_TFC11objc_thunks6Hoozit7copyFoofS0_FT_CSo5Gizmo : $@cc(method) @thin (@guaranteed Hoozit) -> @owned Gizmo // CHECK-NEXT: [[RES:%.*]] = apply [[NATIVE]]([[THIS]]) + // CHECK: release [[THIS]] // CHECK-NOT: autorelease_return - // CHECK-NOT: release // CHECK-NEXT: return [[RES]] // CHECK-NEXT: } @@ -57,16 +59,16 @@ class Hoozit : Gizmo { // CHECK-NEXT: // function_ref objc_thunks.Hoozit.typicalProperty.getter // CHECK-NEXT: [[GETIMPL:%.*]] = function_ref @_TFC11objc_thunks6Hoozitg15typicalPropertyCSo5Gizmo // CHECK-NEXT: [[RES:%.*]] = apply [[GETIMPL]](%0) + // CHECK-NEXT: strong_release %0 // CHECK-NEXT: autorelease_return [[RES]] : $Gizmo // CHECK-NEXT: } - // CHECK-LABEL: sil hidden [transparent] @_TFC11objc_thunks6Hoozitg15typicalPropertyCSo5Gizmo + // CHECK-LABEL: sil hidden [transparent] @_TFC11objc_thunks6Hoozitg15typicalPropertyCSo5Gizmo : $@cc(method) @thin (@guaranteed Hoozit) -> @owned Gizmo // CHECK-NEXT: bb0(%0 : $Hoozit): // CHECK-NEXT: debug_value %0 // CHECK-NEXT: [[ADDR:%.*]] = ref_element_addr %0 : {{.*}}, #Hoozit.typicalProperty {{.*}} // CHECK-NEXT: [[RES:%.*]] = load [[ADDR]] {{.*}} // CHECK-NEXT: strong_retain [[RES]] : $Gizmo - // CHECK-NEXT: strong_release %0 : $Hoozit // CHECK-NEXT: return [[RES]] // -- setter @@ -93,6 +95,7 @@ class Hoozit : Gizmo { // CHECK-NEXT: // function_ref objc_thunks.Hoozit.copyProperty.getter // CHECK-NEXT: [[FR:%.*]] = function_ref @_TFC11objc_thunks6Hoozitg12copyPropertyCSo5Gizmo // CHECK-NEXT: [[RES:%.*]] = apply [[FR]](%0) + // CHECK-NEXT: strong_release %0 // CHECK-NEXT: return [[RES]] // CHECK-NEXT: } @@ -100,8 +103,7 @@ class Hoozit : Gizmo { // CHECK-NEXT: bb0(%0 : $Hoozit): // CHECK: [[ADDR:%.*]] = ref_element_addr %0 : {{.*}}, #Hoozit.copyProperty // CHECK-NEXT: [[RES:%.*]] = load [[ADDR]] - // CHECK-NEXT: retain [[RES]] - // CHECK-NEXT: release %0 + // CHECK-NEXT: retain [[RES]] // CHECK-NEXT: return [[RES]] // -- setter is normal @@ -112,6 +114,7 @@ class Hoozit : Gizmo { // CHECK-NEXT: // function_ref objc_thunks.Hoozit.copyProperty.setter // CHECK-NEXT: [[FR:%.*]] = function_ref @_TFC11objc_thunks6Hoozits12copyPropertyCSo5Gizmo // CHECK-NEXT: [[RES:%.*]] = apply [[FR]](%0, %1) + // CHECK-NEXT: strong_release [[THIS]] // CHECK-NEXT: return [[RES]] // CHECK-LABEL: sil hidden [transparent] @_TFC11objc_thunks6Hoozits12copyPropertyCSo5Gizmo @@ -125,8 +128,9 @@ class Hoozit : Gizmo { // CHECK-NEXT: bb0([[THIS:%.*]] : $Hoozit): // CHECK-NEXT: retain [[THIS]] // CHECK-NEXT: // function_ref - // CHECK-NEXT: [[NATIVE:%.*]] = function_ref @_TFC11objc_thunks6Hoozitg10roPropertyCSo5Gizmo : $@cc(method) @thin (@owned Hoozit) -> @owned Gizmo + // CHECK-NEXT: [[NATIVE:%.*]] = function_ref @_TFC11objc_thunks6Hoozitg10roPropertyCSo5Gizmo : $@cc(method) @thin (@guaranteed Hoozit) -> @owned Gizmo // CHECK-NEXT: [[RES:%.*]] = apply [[NATIVE]]([[THIS]]) + // CHECK-NEXT: release [[THIS]] : $Hoozit // CHECK-NEXT: autorelease_return [[RES]] : $Gizmo // CHECK-NEXT: } @@ -148,8 +152,9 @@ class Hoozit : Gizmo { // CHECK-NEXT: retain [[VALUE]] // CHECK-NEXT: retain [[THIS]] // CHECK-NEXT: // function_ref - // CHECK-NEXT: [[NATIVE:%.*]] = function_ref @_TFC11objc_thunks6Hoozits10rwPropertyCSo5Gizmo : $@cc(method) @thin (@owned Gizmo, @owned Hoozit) -> () + // CHECK-NEXT: [[NATIVE:%.*]] = function_ref @_TFC11objc_thunks6Hoozits10rwPropertyCSo5Gizmo : $@cc(method) @thin (@owned Gizmo, @guaranteed Hoozit) -> () // CHECK-NEXT: apply [[NATIVE]]([[VALUE]], [[THIS]]) + // CHECK-NEXT: release [[THIS]] // CHECK-NEXT: return // CHECK-NEXT: } @@ -164,9 +169,9 @@ class Hoozit : Gizmo { // CHECK-NEXT: bb0([[THIS:%.*]] : $Hoozit): // CHECK-NEXT: retain [[THIS]] // CHECK-NEXT: // function_ref - // CHECK-NEXT: [[NATIVE:%.*]] = function_ref @_TFC11objc_thunks6Hoozitg14copyRWPropertyCSo5Gizmo : $@cc(method) @thin (@owned Hoozit) -> @owned Gizmo + // CHECK-NEXT: [[NATIVE:%.*]] = function_ref @_TFC11objc_thunks6Hoozitg14copyRWPropertyCSo5Gizmo : $@cc(method) @thin (@guaranteed Hoozit) -> @owned Gizmo // CHECK-NEXT: [[RES:%.*]] = apply [[NATIVE]]([[THIS]]) - // CHECK-NOT: release + // CHECK-NEXT: release [[THIS]] // CHECK-NOT: autorelease_return // CHECK-NEXT: return [[RES]] // CHECK-NEXT: } @@ -177,8 +182,9 @@ class Hoozit : Gizmo { // CHECK-NEXT: retain [[VALUE]] // CHECK-NEXT: retain [[THIS]] // CHECK-NEXT: // function_ref - // CHECK-NEXT: [[NATIVE:%.*]] = function_ref @_TFC11objc_thunks6Hoozits14copyRWPropertyCSo5Gizmo : $@cc(method) @thin (@owned Gizmo, @owned Hoozit) -> () + // CHECK-NEXT: [[NATIVE:%.*]] = function_ref @_TFC11objc_thunks6Hoozits14copyRWPropertyCSo5Gizmo : $@cc(method) @thin (@owned Gizmo, @guaranteed Hoozit) -> () // CHECK-NEXT: apply [[NATIVE]]([[VALUE]], [[THIS]]) + // CHECK-NEXT: release [[THIS]] // CHECK-NEXT: return // CHECK-NEXT: } @@ -220,8 +226,9 @@ class Hoozit : Gizmo { // CHECK-LABEL: sil hidden @_TToFC11objc_thunks6Hoozitg9subscriptFSiS0_ : $@cc(objc_method) @thin (Int, Hoozit) -> @autoreleased Hoozit // CHECK-NEXT: bb0([[I:%[0-9]+]] : $Int, [[SELF:%[0-9]+]] : $Hoozit): // CHECK-NEXT: strong_retain [[SELF]] : $Hoozit - // CHECK: [[NATIVE:%[0-9]+]] = function_ref @_TFC11objc_thunks6Hoozitg9subscript{{.*}} : $@cc(method) @thin (Int, @owned Hoozit) -> @owned Hoozit - // CHECK-NEXT: [[RESULT:%[0-9]+]] = apply [[NATIVE]]([[I]], [[SELF]]) : $@cc(method) @thin (Int, @owned Hoozit) -> @owned Hoozit + // CHECK: [[NATIVE:%[0-9]+]] = function_ref @_TFC11objc_thunks6Hoozitg9subscript{{.*}} : $@cc(method) @thin (Int, @guaranteed Hoozit) -> @owned Hoozit + // CHECK-NEXT: [[RESULT:%[0-9]+]] = apply [[NATIVE]]([[I]], [[SELF]]) : $@cc(method) @thin (Int, @guaranteed Hoozit) -> @owned Hoozit + // CHECK-NEXT: strong_release [[SELF]] // CHECK-NEXT: autorelease_return [[RESULT]] : $Hoozit get { return self @@ -232,8 +239,9 @@ class Hoozit : Gizmo { // CHECK-NEXT: bb0([[SELF:%[0-9]+]] : $Hoozit, [[I:%[0-9]+]] : $Int, [[VALUE:%[0-9]+]] : $Hoozit): // CHECK-NEXT: strong_retain [[SELF]] : $Hoozit // CHECK_NEXT: strong_retain [[VALUE]] : $Hoozit - // CHECK: [[NATIVE:%[0-9]+]] = function_ref @_TFC11objc_thunks6Hoozits9subscript{{.*}} : $@cc(method) @thin (@owned Hoozit, Int, @owned Hoozit) -> () - // CHECK-NEXT: [[RESULT:%[0-9]+]] = apply [[NATIVE]]([[SELF]], [[I]], [[VALUE]]) : $@cc(method) @thin (@owned Hoozit, Int, @owned Hoozit) -> () + // CHECK: [[NATIVE:%[0-9]+]] = function_ref @_TFC11objc_thunks6Hoozits9subscript{{.*}} : $@cc(method) @thin (@owned Hoozit, Int, @guaranteed Hoozit) -> () + // CHECK-NEXT: [[RESULT:%[0-9]+]] = apply [[NATIVE]]([[SELF]], [[I]], [[VALUE]]) : $@cc(method) @thin (@owned Hoozit, Int, @guaranteed Hoozit) -> () + // CHECK-NEXT: strong_release [[VALUE]] // CHECK-NEXT: return [[RESULT]] : $() set {} } @@ -295,7 +303,7 @@ extension Hoozit { // CHECK-LABEL: sil hidden @_TToFC11objc_thunks6Hoozit4fooffS0_FT_T_ : $@cc(objc_method) @thin (Hoozit) -> () { var extensionProperty: Int { return 0 } - // CHECK-LABEL: sil hidden @_TFC11objc_thunks6Hoozitg17extensionPropertySi : $@cc(method) @thin (@owned Hoozit) -> Int + // CHECK-LABEL: sil hidden @_TFC11objc_thunks6Hoozitg17extensionPropertySi : $@cc(method) @thin (@guaranteed Hoozit) -> Int } // Calling objc methods of subclass should go through native entry points diff --git a/test/SILGen/objc_witnesses.swift b/test/SILGen/objc_witnesses.swift index b4a9ab4a37a..e0bc0e9c629 100644 --- a/test/SILGen/objc_witnesses.swift +++ b/test/SILGen/objc_witnesses.swift @@ -22,9 +22,17 @@ class Phoûx : NSObject, Fooable { // CHECK-LABEL: sil hidden [transparent] [thunk] @_TTWCSo3Foo14objc_witnesses7FooableS0_FS1_3fooUS1___fQPS1_FT_GSQSS_ // CHECK: function_ref @_TTOFCSo3Foo3foofS_FT_GSQSS_ +// *NOTE* We have an extra copy here for the time being right +// now. This will change once we teach SILGen how to not emit the +// extra copy. +// // witness for Phoûx.foo uses the Swift vtable // CHECK-LABEL: _TTWC14objc_witnessesX8Phox_xraS_7FooableS_FS1_3fooUS1___fQPS1_FT_GSQSS_ -// CHECK: class_method %1 : $Phoûx, #Phoûx.foo!1 +// CHECK: bb0([[IN_ADDR:%.*]] : +// CHECK: [[STACK_SLOT:%.*]] = alloc_stack $Phoûx +// CHECK: copy_addr [[IN_ADDR]] to [initialization] [[STACK_SLOT]]#1 +// CHECK: [[VALUE:%.*]] = load [[STACK_SLOT]]#1 +// CHECK: class_method [[VALUE]] : $Phoûx, #Phoûx.foo!1 protocol Bells { init(bellsOn: Int) diff --git a/test/SILGen/properties.swift b/test/SILGen/properties.swift index 4d48ea87b84..67e74a400c6 100644 --- a/test/SILGen/properties.swift +++ b/test/SILGen/properties.swift @@ -101,9 +101,8 @@ func physical_struct_lvalue(c: Int) { func physical_class_lvalue(r: Ref, a: Int) { r.y = a - // CHECK: strong_retain %0 : $Ref // CHECK: [[FN:%[0-9]+]] = class_method %0 : $Ref, #Ref.y!setter.1 - // CHECK: apply [[FN]](%1, %0) : $@cc(method) @thin (Int, @owned Ref) -> () + // CHECK: apply [[FN]](%1, %0) : $@cc(method) @thin (Int, @guaranteed Ref) -> () // CHECK: strong_release %0 : $Ref } @@ -111,16 +110,15 @@ func physical_struct_lvalue(c: Int) { // CHECK-LABEL: sil hidden @_TF10properties24physical_subclass_lvalue func physical_subclass_lvalue(r: RefSubclass, a: Int) { r.y = a - // CHECK: strong_retain %0 : $RefSubclass + // strong_retain %0 : $RefSubclass // CHECK: [[R_SUP:%[0-9]+]] = upcast %0 : $RefSubclass to $Ref - // CHECK: [[FN:%[0-9]+]] = class_method [[R_SUP]] : $Ref, #Ref.y!setter.1 : Ref + // CHECK: [[FN:%[0-9]+]] = class_method [[R_SUP]] : $Ref, #Ref.y!setter.1 : Ref -> (Int) -> () , $@cc(method) @thin (Int, @guaranteed Ref) -> () // CHECK: apply [[FN]](%1, [[R_SUP]]) : - + // CHECK: strong_release [[R_SUP]] r.w = a - // CHECK: strong_retain %0 : $RefSubclass // CHECK: [[FN:%[0-9]+]] = class_method %0 : $RefSubclass, #RefSubclass.w!setter.1 - // CHECK: apply [[FN]](%1, %0) : $@cc(method) @thin (Int, @owned RefSubclass) -> () + // CHECK: apply [[FN]](%1, %0) : $@cc(method) @thin (Int, @guaranteed RefSubclass) -> () } @@ -337,9 +335,8 @@ func physical_inout(var x: Int) { // CHECK-NEXT: bb0([[VVAL:%[0-9]+]] : $Val, [[I:%[0-9]+]] : $Int): func val_subscript_get(v: Val, i: Int) -> Float { return v[i] - // CHECK: retain_value [[VVAL]] // CHECK: [[SUBSCRIPT_GET_METHOD:%[0-9]+]] = function_ref @_TFV10properties3Valg9subscript - // CHECK: [[RET:%[0-9]+]] = apply [[SUBSCRIPT_GET_METHOD]]([[I]], [[VVAL]]) + // CHECK: [[RET:%[0-9]+]] = apply [[SUBSCRIPT_GET_METHOD]]([[I]], [[VVAL]]) : $@cc(method) @thin (Int, @guaranteed Val) // CHECK: return [[RET]] } @@ -707,7 +704,7 @@ class DerivedProperty : BaseProperty { // CHECK: [[BASEPTR:%[0-9]+]] = upcast %0 : $DerivedProperty to $BaseProperty // CHECK: // function_ref properties.BaseProperty.x.getter // CHECK: [[FN:%[0-9]+]] = function_ref @_TFC10properties12BasePropertyg1x -// CHECK: apply [[FN]]([[BASEPTR]]) : $@cc(method) @thin (@owned BaseProperty) -> Int // user: %7 +// CHECK: apply [[FN]]([[BASEPTR]]) : $@cc(method) @thin (@guaranteed BaseProperty) -> Int // user: %7 // ownership qualifiers don't work with non-mutating struct property @@ -723,7 +720,6 @@ struct ReferenceStorageTypeRValues { // CHECK-NEXT: %2 = struct_extract %0 : $ReferenceStorageTypeRValues, #ReferenceStorageTypeRValues.p1 // CHECK-NEXT: strong_retain_unowned %2 : $@sil_unowned Ref // CHECK-NEXT: %4 = unowned_to_ref %2 : $@sil_unowned Ref to $Ref -// CHECK-NEXT: release_value %0 : $ReferenceStorageTypeRValues // CHECK-NEXT: return %4 : $Ref init() { @@ -875,7 +871,6 @@ class ClassWithLetProperty { // CHECK-NEXT: debug_value // CHECK-NEXT: [[PTR:%[0-9]+]] = ref_element_addr %0 : $ClassWithLetProperty, #ClassWithLetProperty.p // CHECK-NEXT: [[VAL:%[0-9]+]] = load [[PTR]] : $*Int -// CHECK-NEXT: strong_release %0 : $ClassWithLetProperty // CHECK-NEXT: return [[VAL]] : $Int @@ -971,11 +966,11 @@ func addressOnlyNonmutatingProperty(x: AddressOnlyNonmutatingSet) // CHECK-LABEL: sil hidden @_TF10properties30addressOnlyNonmutatingPropertyU__FGVS_25AddressOnlyNonmutatingSetQ__Si : $@thin (@in AddressOnlyNonmutatingSet) -> Int { // CHECK: [[SET:%.*]] = function_ref @_TFV10properties25AddressOnlyNonmutatingSets4propSi // CHECK: apply [[SET]]({{%.*}}, [[TMP:%.*]]#1) -// CHECK-NOT: destroy_addr [[TMP]] +// CHECK: destroy_addr [[TMP]] // CHECK: dealloc_stack [[TMP]] // CHECK: [[GET:%.*]] = function_ref @_TFV10properties25AddressOnlyNonmutatingSetg4propSi // CHECK: apply [[GET]]([[TMP:%.*]]#1) -// CHECK-NOT: destroy_addr [[TMP]] +// CHECK: destroy_addr [[TMP]] // CHECK: dealloc_stack [[TMP]] protocol MakeAddressOnly {} diff --git a/test/SILGen/protocol_extensions.swift b/test/SILGen/protocol_extensions.swift index 18835527e0f..b2bd34b2b57 100644 --- a/test/SILGen/protocol_extensions.swift +++ b/test/SILGen/protocol_extensions.swift @@ -6,7 +6,7 @@ public protocol P1 { } extension P1 { - // CHECK-LABEL: sil hidden @_TFP19protocol_extensions2P16extP1aUS0___fQPS0_FT_T_ : $@cc(method) @thin (@in Self) -> () { + // CHECK-LABEL: sil hidden @_TFP19protocol_extensions2P16extP1aUS0___fQPS0_FT_T_ : $@cc(method) @thin (@in_guaranteed Self) -> () { // CHECK-NEXT: bb0([[SELF:%[0-9]+]] : $*Self): final func extP1a() { // CHECK: [[WITNESS:%[0-9]+]] = witness_method $Self, #P1.reqP1a!1 : $@cc(witness_method) @thin <τ_0_0 where τ_0_0 : P1> (@in_guaranteed τ_0_0) -> () @@ -15,13 +15,11 @@ extension P1 { // CHECK: return } - // CHECK-LABEL: sil @_TFP19protocol_extensions2P16extP1bUS0___fQPS0_FT_T_ : $@cc(method) @thin (@in Self) -> () { + // CHECK-LABEL: sil @_TFP19protocol_extensions2P16extP1bUS0___fQPS0_FT_T_ : $@cc(method) @thin (@in_guaranteed Self) -> () { // CHECK-NEXT: bb0([[SELF:%[0-9]+]] : $*Self): public final func extP1b() { - // CHECK: [[FN:%[0-9]+]] = function_ref @_TFP19protocol_extensions2P16extP1aUS0___fQPS0_FT_T_ : $@cc(method) @thin <τ_0_0 where τ_0_0 : P1> (@in τ_0_0) -> () - // CHECK-NEXT: [[SELF_COPY:%[0-9]+]] = alloc_stack $Self - // CHECK-NEXT: copy_addr [[SELF]] to [initialization] [[SELF_COPY]]#1 : $*Self - // CHECK-NEXT: apply [[FN]]([[SELF_COPY]]#1) : $@cc(method) @thin <τ_0_0 where τ_0_0 : P1> (@in τ_0_0) -> () + // CHECK: [[FN:%[0-9]+]] = function_ref @_TFP19protocol_extensions2P16extP1aUS0___fQPS0_FT_T_ : $@cc(method) @thin <τ_0_0 where τ_0_0 : P1> (@in_guaranteed τ_0_0) -> () + // CHECK-NEXT: apply [[FN]]([[SELF]]) : $@cc(method) @thin <τ_0_0 where τ_0_0 : P1> (@in_guaranteed τ_0_0) -> () extP1a() // CHECK: return } @@ -44,7 +42,7 @@ func testD(d: D) { // CHECK: [[DCOPY:%[0-9]+]] = alloc_stack $D // CHECK: store [[D]] to [[DCOPY]]#1 : $*D // CHECK: [[RESULT:%[0-9]+]] = alloc_stack $D - // CHECK: apply [[FN]]([[RESULT]]#1, [[DCOPY]]#1) : $@cc(method) @thin <τ_0_0 where τ_0_0 : P1> (@out τ_0_0, @in τ_0_0) -> () + // CHECK: apply [[FN]]([[RESULT]]#1, [[DCOPY]]#1) : $@cc(method) @thin <τ_0_0 where τ_0_0 : P1> (@out τ_0_0, @in_guaranteed τ_0_0) -> () var d2: D = d.returnsSelf() } @@ -82,22 +80,19 @@ extension P1 { func testExistentials1(p1: P1, b: Bool, i: Int64) { // CHECK: [[POPENED:%[0-9]+]] = open_existential_addr [[P]] : $*P1 to $*@opened([[UUID:".*"]]) // CHECK: [[F1:%[0-9]+]] = function_ref @_TFP19protocol_extensions2P12f1US0___fQPS0_FT_T_ - // CHECK: copy_addr [[POPENED]] to [initialization] [[POPENED_COPY:%.*]]#1 - // CHECK: apply [[F1]]<@opened([[UUID]]) P1>([[POPENED_COPY]]#1) : $@cc(method) @thin <τ_0_0 where τ_0_0 : P1> (@in τ_0_0) -> () - // CHECK: dealloc_stack [[POPENED_COPY]] + // CHECK: apply [[F1]]<@opened([[UUID]]) P1>([[POPENED]]) : $@cc(method) @thin <τ_0_0 where τ_0_0 : P1> (@in_guaranteed τ_0_0) -> () p1.f1() // CHECK: [[POPENED:%[0-9]+]] = open_existential_addr [[P]] : $*P1 to $*@opened([[UUID:".*"]]) P1 // CHECK: [[CURRIED1:%[0-9]+]] = function_ref @_TFP19protocol_extensions2P18curried1US0___fQPS0_fSbFVSs5Int64T_ - // CHECK: copy_addr [[POPENED]] to [initialization] [[POPENED_COPY:%.*]]#1 - // CHECK: [[CURRIED1]]<@opened([[UUID]]) P1>([[I]], [[B]], [[POPENED_COPY]]#1) : $@cc(method) @thin <τ_0_0 where τ_0_0 : P1> (Int64, Bool, @in τ_0_0) -> () - // CHECK: dealloc_stack [[POPENED_COPY]] + // CHECK: [[CURRIED1]]<@opened([[UUID]]) P1>([[I]], [[B]], [[POPENED]]) : $@cc(method) @thin <τ_0_0 where τ_0_0 : P1> (Int64, Bool, @in_guaranteed τ_0_0) -> () p1.curried1(b)(i) // CHECK: [[POPENED:%[0-9]+]] = open_existential_addr [[P]] : $*P1 to $*@opened([[UUID:".*"]]) P1 // CHECK: copy_addr [[POPENED]] to [initialization] [[POPENED_COPY:%.*]]#1 // CHECK: [[GETTER:%[0-9]+]] = function_ref @_TFP19protocol_extensions2P1g9subscriptFVSs5Int64Sb - // CHECK: apply [[GETTER]]<@opened([[UUID]]) P1>([[I]], [[POPENED_COPY]]#1) : $@cc(method) @thin <τ_0_0 where τ_0_0 : P1> (Int64, @in τ_0_0) -> Bool + // CHECK: apply [[GETTER]]<@opened([[UUID]]) P1>([[I]], [[POPENED_COPY]]#1) : $@cc(method) @thin <τ_0_0 where τ_0_0 : P1> (Int64, @in_guaranteed τ_0_0) -> Bool + // CHECK: destroy_addr [[POPENED_COPY]]#1 // CHECK: store{{.*}} : $*Bool // CHECK: dealloc_stack [[POPENED_COPY]] var b2 = p1[i] @@ -105,7 +100,7 @@ func testExistentials1(p1: P1, b: Bool, i: Int64) { // CHECK: [[POPENED:%[0-9]+]] = open_existential_addr [[P]] : $*P1 to $*@opened([[UUID:".*"]]) P1 // CHECK: copy_addr [[POPENED]] to [initialization] [[POPENED_COPY:%.*]]#1 // CHECK: [[GETTER:%[0-9]+]] = function_ref @_TFP19protocol_extensions2P1g4propSb - // CHECK: apply [[GETTER]]<@opened([[UUID]]) P1>([[POPENED_COPY]]#1) : $@cc(method) @thin <τ_0_0 where τ_0_0 : P1> (@in τ_0_0) -> Bool + // CHECK: apply [[GETTER]]<@opened([[UUID]]) P1>([[POPENED_COPY]]#1) : $@cc(method) @thin <τ_0_0 where τ_0_0 : P1> (@in_guaranteed τ_0_0) -> Bool // CHECK: store{{.*}} : $*Bool // CHECK: dealloc_stack [[POPENED_COPY]] var b3 = p1.prop @@ -118,10 +113,8 @@ func testExistentials2(p1: P1) { // CHECK: [[POPENED:%[0-9]+]] = open_existential_addr [[P]] : $*P1 to $*@opened([[UUID:".*"]]) P1 // CHECK: [[P1AINIT:%[0-9]+]] = init_existential_addr [[P1A]]#1 : $*P1, $@opened([[UUID2:".*"]]) P1 // CHECK: [[FN:%[0-9]+]] = function_ref @_TFP19protocol_extensions2P111returnsSelfUS0___fQPS0_FT_S1_ - // CHECK: copy_addr [[POPENED]] to [initialization] [[POPENED_COPY:%.*]]#1 - // CHECK: apply [[FN]]<@opened([[UUID]]) P1>([[P1AINIT]], [[POPENED_COPY]]#1) : $@cc(method) @thin <τ_0_0 where τ_0_0 : P1> (@out τ_0_0, @in τ_0_0) -> () + // CHECK: apply [[FN]]<@opened([[UUID]]) P1>([[P1AINIT]], [[POPENED]]) : $@cc(method) @thin <τ_0_0 where τ_0_0 : P1> (@out τ_0_0, @in_guaranteed τ_0_0) -> () var p1a: P1 = p1.returnsSelf() - // CHECK: dealloc_stack [[POPENED_COPY]]#0 } // CHECK-LABEL: sil hidden @_TF19protocol_extensions23testExistentialsGetters @@ -130,13 +123,13 @@ func testExistentialsGetters(p1: P1) { // CHECK: [[POPENED:%[0-9]+]] = open_existential_addr [[P]] : $*P1 to $*@opened([[UUID:".*"]]) P1 // CHECK: copy_addr [[POPENED]] to [initialization] [[POPENED_COPY:%.*]]#1 // CHECK: [[FN:%[0-9]+]] = function_ref @_TFP19protocol_extensions2P1g5prop2Sb - // CHECK: [[B:%[0-9]+]] = apply [[FN]]<@opened([[UUID]]) P1>([[POPENED_COPY]]#1) : $@cc(method) @thin <τ_0_0 where τ_0_0 : P1> (@in τ_0_0) -> Bool + // CHECK: [[B:%[0-9]+]] = apply [[FN]]<@opened([[UUID]]) P1>([[POPENED_COPY]]#1) : $@cc(method) @thin <τ_0_0 where τ_0_0 : P1> (@in_guaranteed τ_0_0) -> Bool let b: Bool = p1.prop2 // CHECK: [[POPENED:%[0-9]+]] = open_existential_addr [[P]] : $*P1 to $*@opened([[UUID:".*"]]) P1 // CHECK: copy_addr [[POPENED]] to [initialization] [[POPENED_COPY:%.*]]#1 // CHECK: [[GETTER:%[0-9]+]] = function_ref @_TFP19protocol_extensions2P1g9subscriptFSbSb - // CHECK: apply [[GETTER]]<@opened([[UUID]]) P1>([[B]], [[POPENED_COPY]]#1) : $@cc(method) @thin <τ_0_0 where τ_0_0 : P1> (Bool, @in τ_0_0) -> Bool + // CHECK: apply [[GETTER]]<@opened([[UUID]]) P1>([[B]], [[POPENED_COPY]]#1) : $@cc(method) @thin <τ_0_0 where τ_0_0 : P1> (Bool, @in_guaranteed τ_0_0) -> Bool let b2: Bool = p1[b] } @@ -177,8 +170,8 @@ func testLogicalExistentialSetters(var hasAP1: HasAP1, b: Bool) { // CHECK: [[P1_COPY:%[0-9]+]] = alloc_stack $P1 // CHECK-NEXT: [[HASP1_COPY:%[0-9]+]] = alloc_stack $HasAP1 // CHECK-NEXT: copy_addr [[HASP1_BOX]]#1 to [initialization] [[HASP1_COPY]]#1 : $*HasAP1 - // CHECK: [[SOMEP1_GETTER:%[0-9]+]] = function_ref @_TFV19protocol_extensions6HasAP1g6someP1PS_2P1_ : $@cc(method) @thin (@out P1, @in HasAP1) -> () - // CHECK: [[RESULT:%[0-9]+]] = apply [[SOMEP1_GETTER]]([[P1_COPY]]#1, %6#1) : $@cc(method) @thin (@out P1, @in HasAP1) -> () + // CHECK: [[SOMEP1_GETTER:%[0-9]+]] = function_ref @_TFV19protocol_extensions6HasAP1g6someP1PS_2P1_ : $@cc(method) @thin (@out P1, @in_guaranteed HasAP1) -> () + // CHECK: [[RESULT:%[0-9]+]] = apply [[SOMEP1_GETTER]]([[P1_COPY]]#1, %6#1) : $@cc(method) @thin (@out P1, @in_guaranteed HasAP1) -> () // CHECK: [[P1_OPENED:%[0-9]+]] = open_existential_addr [[P1_COPY]]#1 : $*P1 to $*@opened([[UUID:".*"]]) P1 // CHECK: [[PROP2_SETTER:%[0-9]+]] = function_ref @_TFP19protocol_extensions2P1s5prop2Sb : $@cc(method) @thin <τ_0_0 where τ_0_0 : P1> (Bool, @inout τ_0_0) -> () // CHECK: apply [[PROP2_SETTER]]<@opened([[UUID]]) P1>([[B]], [[P1_OPENED]]) : $@cc(method) @thin <τ_0_0 where τ_0_0 : P1> (Bool, @inout τ_0_0) -> () @@ -200,12 +193,7 @@ func test_open_existential_semantics_opaque(guaranteed: P1, // CHECK: [[VALUE:%.*]] = open_existential_addr %0 // CHECK: [[METHOD:%.*]] = function_ref - // CHECK: copy_addr [[VALUE]] to [initialization] [[COPY:%.*]]#1 : - // CHECK: apply [[METHOD]]<{{.*}}>([[COPY]]#1) - // CHECK-NOT: destroy_addr [[COPY]]#1 - // CHECK: dealloc_stack [[COPY]]#0 - // CHECK-NOT: destroy_addr [[VALUE]] - // CHECK-NOT: destroy_addr %0 + // CHECK: apply [[METHOD]]<{{.*}}>([[VALUE]]) // GUARANTEED: [[VALUE:%.*]] = open_existential_addr %0 // GUARANTEED: [[METHOD:%.*]] = function_ref @@ -268,7 +256,6 @@ func test_open_existential_semantics_class(guaranteed: CP1, // CHECK-NOT: strong_retain %0 // CHECK: [[VALUE:%.*]] = open_existential_ref %0 // CHECK: [[METHOD:%.*]] = function_ref - // CHECK: strong_retain [[VALUE]] // CHECK: apply [[METHOD]]<{{.*}}>([[VALUE]]) // CHECK-NOT: strong_release [[VALUE]] // CHECK-NOT: strong_release %0 @@ -286,7 +273,7 @@ func test_open_existential_semantics_class(guaranteed: CP1, // CHECK: [[VALUE:%.*]] = open_existential_ref [[IMMEDIATE]] // CHECK: [[METHOD:%.*]] = function_ref // CHECK: apply [[METHOD]]<{{.*}}>([[VALUE]]) - // CHECK-NOT: strong_release [[VALUE]] + // CHECK: strong_release [[VALUE]] // CHECK-NOT: strong_release [[IMMEDIATE]] // GUARANTEED: [[IMMEDIATE:%.*]] = load [[IMMEDIATE_BOX]] @@ -303,7 +290,7 @@ func test_open_existential_semantics_class(guaranteed: CP1, // CHECK: [[VALUE:%.*]] = open_existential_ref [[PLUS_ONE]] // CHECK: [[METHOD:%.*]] = function_ref // CHECK: apply [[METHOD]]<{{.*}}>([[VALUE]]) - // CHECK-NOT: strong_release [[VALUE]] + // CHECK: strong_release [[VALUE]] // CHECK-NOT: strong_release [[PLUS_ONE]] // GUARANTEED: [[F:%.*]] = function_ref {{.*}}plusOneCP1 diff --git a/test/SILGen/protocols.swift b/test/SILGen/protocols.swift index fc145b42499..3724e83ce81 100644 --- a/test/SILGen/protocols.swift +++ b/test/SILGen/protocols.swift @@ -249,11 +249,14 @@ class ClassWithGetter : PropertyWithGetter { // Make sure we are generating a protocol witness that calls the class method on // ClassWithGetter. // CHECK-LABEL: sil hidden [transparent] [thunk] @_TTWC9protocols15ClassWithGetterS_18PropertyWithGetterS_FS1_g1aSi : $@cc(witness_method) @thin (@in_guaranteed ClassWithGetter) -> Int { -// CHECK: bb0 -// CHECK-NEXT: load -// CHECK-NEXT: strong_retain -// CHECK-NEXT: class_method -// CHECK-NEXT: apply +// CHECK: bb0([[C:%.*]] : $*ClassWithGetter): +// CHECK-NEXT: [[CCOPY:%.*]] = alloc_stack $ClassWithGetter +// CHECK-NEXT: copy_addr [[C]] to [initialization] [[CCOPY]]#1 +// CHECK-NEXT: [[CCOPY_LOADED:%.*]] = load [[CCOPY]]#1 +// CHECK-NEXT: [[FUN:%.*]] = class_method [[CCOPY_LOADED]] : $ClassWithGetter, #ClassWithGetter.a!getter.1 : ClassWithGetter -> () -> Int , $@cc(method) @thin (@guaranteed ClassWithGetter) -> Int +// CHECK-NEXT: apply [[FUN]]([[CCOPY_LOADED]]) +// CHECK-NEXT: strong_release [[CCOPY_LOADED]] +// CHECK-NEXT: dealloc_stack [[CCOPY]]#0 // CHECK-NEXT: return class ClassWithGetterSetter : PropertyWithGetterSetter, PropertyWithGetter { @@ -272,11 +275,14 @@ class ClassWithGetterSetter : PropertyWithGetterSetter, PropertyWithGetter { } // CHECK-LABEL: sil hidden [transparent] [thunk] @_TTWC9protocols21ClassWithGetterSetterS_24PropertyWithGetterSetterS_FS1_g1bSi : $@cc(witness_method) @thin (@in_guaranteed ClassWithGetterSetter) -> Int { -// CHECK: bb0 -// CHECK-NEXT: load -// CHECK-NEXT: strong_retain -// CHECK-NEXT: class_method -// CHECK-NEXT: apply +// CHECK: bb0([[C:%.*]] : $*ClassWithGetterSetter): +// CHECK-NEXT: [[CCOPY:%.*]] = alloc_stack $ClassWithGetterSetter +// CHECK-NEXT: copy_addr [[C]] to [initialization] [[CCOPY]]#1 +// CHECK-NEXT: [[CCOPY_LOADED:%.*]] = load [[CCOPY]]#1 +// CHECK-NEXT: [[FUN:%.*]] = class_method [[CCOPY_LOADED]] : $ClassWithGetterSetter, #ClassWithGetterSetter.b!getter.1 : ClassWithGetterSetter -> () -> Int , $@cc(method) @thin (@guaranteed ClassWithGetterSetter) -> Int +// CHECK-NEXT: apply [[FUN]]([[CCOPY_LOADED]]) +// CHECK-NEXT: strong_release [[CCOPY_LOADED]] +// CHECK-NEXT: dealloc_stack [[CCOPY]]#0 // CHECK-NEXT: return // Stored variables fulfilling property requirements @@ -289,13 +295,13 @@ class ClassWithStoredProperty : PropertyWithGetter { return a } // CHECK-LABEL: sil hidden @{{.*}}ClassWithStoredProperty{{.*}}methodUsingProperty - // CHECK-NEXT: bb0(%0 : $ClassWithStoredProperty): - // CHECK-NEXT: debug_value %0 - // CHECK-NEXT: strong_retain %0 : $ClassWithStoredProperty - // CHECK-NEXT: %3 = class_method %0 : $ClassWithStoredProperty, #ClassWithStoredProperty.a!getter.1 - // CHECK-NEXT: %4 = apply %3(%0) - // CHECK-NEXT: strong_release %0 : $ClassWithStoredProperty - // CHECK-NEXT: return %4 : $Int + // CHECK-NEXT: bb0([[ARG:%.*]] : $ClassWithStoredProperty): + // CHECK-NEXT: debug_value [[ARG]] + // CHECK-NOT: strong_retain + // CHECK-NEXT: [[FUN:%.*]] = class_method [[ARG]] : $ClassWithStoredProperty, #ClassWithStoredProperty.a!getter.1 : ClassWithStoredProperty -> () -> Int , $@cc(method) @thin (@guaranteed ClassWithStoredProperty) -> Int + // CHECK-NEXT: [[RESULT:%.*]] = apply [[FUN]]([[ARG]]) + // CHECK-NOT: strong_release + // CHECK-NEXT: return [[RESULT]] : $Int } struct StructWithStoredProperty : PropertyWithGetter { @@ -314,14 +320,57 @@ struct StructWithStoredProperty : PropertyWithGetter { // Make sure that we generate direct function calls for out struct protocl // witness since structs don't do virtual calls for methods. +// +// *NOTE* Even though at first glance the copy_addr looks like a leak +// here, StructWithStoredProperty is a trivial struct implying that no +// leak is occuring. See the test with StructWithStoredClassProperty +// that makes sure in such a case we don't leak. This is due to the +// thunking code being too dumb but it is harmless to program +// correctness. +// // CHECK-LABEL: sil hidden [transparent] [thunk] @_TTWV9protocols24StructWithStoredPropertyS_18PropertyWithGetterS_FS1_g1aSi : $@cc(witness_method) @thin (@in_guaranteed StructWithStoredProperty) -> Int { -// CHECK: bb0 -// CHECK-NEXT: load +// CHECK: bb0([[C:%.*]] : $*StructWithStoredProperty): +// CHECK-NEXT: [[CCOPY:%.*]] = alloc_stack $StructWithStoredProperty +// CHECK-NEXT: copy_addr [[C]] to [initialization] [[CCOPY]]#1 +// CHECK-NEXT: [[CCOPY_LOADED:%.*]] = load [[CCOPY]]#1 // CHECK-NEXT: function_ref -// CHECK-NEXT: function_ref @_TFV9protocols24StructWithStoredPropertyg1aSi : $@cc(method) @thin (StructWithStoredProperty) -> Int -// CHECK-NEXT: apply %2(%1) : $@cc(method) @thin (StructWithStoredProperty) -> Int +// CHECK-NEXT: [[FUN:%.*]] = function_ref @_TFV9protocols24StructWithStoredPropertyg1aSi : $@cc(method) @thin (StructWithStoredProperty) -> Int +// CHECK-NEXT: apply [[FUN]]([[CCOPY_LOADED]]) +// CHECK-NEXT: dealloc_stack [[CCOPY]]#0 // CHECK-NEXT: return +class C {} + +// Make sure that if the getter has a class property, we pass it in +// in_guaranteed and don't leak. +struct StructWithStoredClassProperty : PropertyWithGetter { + var a : Int + var c: C = C() + + // Make sure that accesses aren't going through the generated accessors. + func methodUsingProperty() -> Int { + return a + } + // CHECK-LABEL: sil hidden @{{.*}}StructWithStoredClassProperty{{.*}}methodUsingProperty + // CHECK-NEXT: bb0(%0 : $StructWithStoredClassProperty): + // CHECK-NEXT: debug_value %0 + // CHECK-NEXT: %2 = struct_extract %0 : $StructWithStoredClassProperty, #StructWithStoredClassProperty.a + // CHECK-NEXT: return %2 : $Int +} + +// CHECK-LABEL: sil hidden [transparent] [thunk] @_TTWV9protocols29StructWithStoredClassPropertyS_18PropertyWithGetterS_FS1_g1aSi : $@cc(witness_method) @thin (@in_guaranteed StructWithStoredClassProperty) -> Int { +// CHECK: bb0([[C:%.*]] : $*StructWithStoredClassProperty): +// CHECK-NEXT: [[CCOPY:%.*]] = alloc_stack $StructWithStoredClassProperty +// CHECK-NEXT: copy_addr [[C]] to [initialization] [[CCOPY]]#1 +// CHECK-NEXT: [[CCOPY_LOADED:%.*]] = load [[CCOPY]]#1 +// CHECK-NEXT: function_ref +// CHECK-NEXT: [[FUN:%.*]] = function_ref @_TFV9protocols29StructWithStoredClassPropertyg1aSi : $@cc(method) @thin (@guaranteed StructWithStoredClassProperty) -> Int +// CHECK-NEXT: apply [[FUN]]([[CCOPY_LOADED]]) +// CHECK-NEXT: release_value [[CCOPY_LOADED]] +// CHECK-NEXT: dealloc_stack [[CCOPY]]#0 +// CHECK-NEXT: return + + // CHECK-LABEL: sil_witness_table hidden ClassWithGetter: PropertyWithGetter module protocols { // CHECK-NEXT: method #PropertyWithGetter.a!getter.1: @_TTWC9protocols15ClassWithGetterS_18PropertyWithGetterS_FS1_g1aSi // CHECK-NEXT: } @@ -336,4 +385,10 @@ struct StructWithStoredProperty : PropertyWithGetter { // CHECK-NEXT: method #PropertyWithGetter.a!getter.1: @_TTWC9protocols21ClassWithGetterSetterS_18PropertyWithGetterS_FS1_g1aSi // CHECK-NEXT: } +// CHECK-LABEL: sil_witness_table hidden StructWithStoredProperty: PropertyWithGetter module protocols { +// CHECK-NEXT: method #PropertyWithGetter.a!getter.1: @_TTWV9protocols24StructWithStoredPropertyS_18PropertyWithGetterS_FS1_g1aSi +// CHECK-NEXT: } +// CHECK-LABEL: sil_witness_table hidden StructWithStoredClassProperty: PropertyWithGetter module protocols { +// CHECK-NEXT: method #PropertyWithGetter.a!getter.1: @_TTWV9protocols29StructWithStoredClassPropertyS_18PropertyWithGetterS_FS1_g1aSi +// CHECK-NEXT: } diff --git a/test/SILGen/types.swift b/test/SILGen/types.swift index 5a92c1dfd5a..848a98e5c9c 100644 --- a/test/SILGen/types.swift +++ b/test/SILGen/types.swift @@ -4,15 +4,15 @@ class C { var member: Int = 0 // Methods have method calling convention. - // CHECK-LABEL: sil hidden @{{.*}}C3foo{{.*}} : $@cc(method) @thin (Int, @owned C) -> () + // CHECK-LABEL: sil hidden @_TFC5types1C3foofS0_FT1xSi_T_ : $@cc(method) @thin (Int, @guaranteed C) -> () { func foo(#x: Int) { // CHECK: bb0([[X:%[0-9]+]] : $Int, [[THIS:%[0-9]+]] : $C): member = x - // CHECK: strong_retain %1 : $C + // CHECK-NOT: strong_retain // CHECK: [[FN:%[0-9]+]] = class_method %1 : $C, #C.member!setter.1 - // CHECK: apply [[FN]](%0, %1) : $@cc(method) @thin (Int, @owned C) -> () - // CHECK: strong_release %1 : $C + // CHECK: apply [[FN]](%0, %1) : $@cc(method) @thin (Int, @guaranteed C) -> () + // CHECK-NOT: strong_release } diff --git a/test/SILGen/unowned.swift b/test/SILGen/unowned.swift index d8c356c53d9..cf53d0e3c99 100644 --- a/test/SILGen/unowned.swift +++ b/test/SILGen/unowned.swift @@ -92,13 +92,14 @@ func test_unowned_let_capture(aC : C) { } // CHECK-LABEL: sil shared @_TFF7unowned24test_unowned_let_captureFCS_1CT_U_FT_Si : $@thin (@owned @sil_unowned C) -> Int { -// CHECK-NEXT: bb0(%0 : $@sil_unowned C): -// CHECK-NEXT: strong_retain_unowned %0 : $@sil_unowned C -// CHECK-NEXT: %2 = unowned_to_ref %0 : $@sil_unowned C to $C -// CHECK-NEXT: %3 = class_method %2 : $C, #C.f!1 : C -> () -> Int , $@cc(method) @thin (@owned C) -> Int -// CHECK-NEXT: %4 = apply %3(%2) : $@cc(method) @thin (@owned C) -> Int -// CHECK-NEXT: unowned_release %0 : $@sil_unowned C -// CHECK-NEXT: return %4 : $Int +// CHECK-NEXT: bb0([[ARG:%.*]] : $@sil_unowned C): +// CHECK-NEXT: strong_retain_unowned [[ARG]] : $@sil_unowned C +// CHECK-NEXT: [[UNOWNED_ARG:%.*]] = unowned_to_ref [[ARG]] : $@sil_unowned C to $C +// CHECK-NEXT: [[FUN:%.*]] = class_method [[UNOWNED_ARG]] : $C, #C.f!1 : C -> () -> Int , $@cc(method) @thin (@guaranteed C) -> Int +// CHECK-NEXT: [[RESULT:%.*]] = apply [[FUN]]([[UNOWNED_ARG]]) : $@cc(method) @thin (@guaranteed C) -> Int +// CHECK-NEXT: strong_release [[UNOWNED_ARG]] +// CHECK-NEXT: unowned_release [[ARG]] : $@sil_unowned C +// CHECK-NEXT: return [[RESULT]] : $Int diff --git a/test/SILGen/witness_tables.swift b/test/SILGen/witness_tables.swift index 7ccda77d36b..96bbe20fc38 100644 --- a/test/SILGen/witness_tables.swift +++ b/test/SILGen/witness_tables.swift @@ -270,9 +270,9 @@ func <~>(x: ConformingClassToClassProtocol, // TABLE-NEXT: method #ClassProtocol.staticMethod!1: @_TTWC14witness_tables30ConformingClassToClassProtocolS_13ClassProtocolS_ZFS1_12staticMethodUS1__U_S_9AssocReqt__fMQPS1_FT1xS3__T_ // TABLE-NEXT: method #ClassProtocol."<~>"!1: @_TTWC14witness_tables30ConformingClassToClassProtocolS_13ClassProtocolS_ZFS1_oi3ltgUS1__U_S_9AssocReqt__fMQPS1 // TABLE-NEXT: } -// SYMBOL: sil hidden [transparent] [thunk] @_TTWC14witness_tables30ConformingClassToClassProtocolS_13ClassProtocolS_FS1_6methodUS1__U_S_9AssocReqt__fQPS1_FT1xVS_3Arg1yS3__T_ : $@cc(witness_method) @thin (Arg, @owned ConformingClassToClassProtocol, @owned ConformingClassToClassProtocol) -> () -// SYMBOL: sil hidden [transparent] [thunk] @_TTWC14witness_tables30ConformingClassToClassProtocolS_13ClassProtocolS_FS1_7genericUS1__U_S_9AssocReqt__fQPS1_US_13ArchetypeReqt__FT1xQ_1yS3__T_ : $@cc(witness_method) @thin (@in B, @owned ConformingClassToClassProtocol, @owned ConformingClassToClassProtocol) -> () -// SYMBOL: sil hidden [transparent] [thunk] @_TTWC14witness_tables30ConformingClassToClassProtocolS_13ClassProtocolS_FS1_16assocTypesMethodUS1__U_S_9AssocReqt__fQPS1_FT1xQS3_9AssocType1yQS3_13AssocWithReqt_T_ : $@cc(witness_method) @thin (@in SomeAssoc, @in ConformingAssoc, @owned ConformingClassToClassProtocol) -> () +// SYMBOL: sil hidden [transparent] [thunk] @_TTWC14witness_tables30ConformingClassToClassProtocolS_13ClassProtocolS_FS1_6methodUS1__U_S_9AssocReqt__fQPS1_FT1xVS_3Arg1yS3__T_ : $@cc(witness_method) @thin (Arg, @owned ConformingClassToClassProtocol, @guaranteed ConformingClassToClassProtocol) -> () +// SYMBOL: sil hidden [transparent] [thunk] @_TTWC14witness_tables30ConformingClassToClassProtocolS_13ClassProtocolS_FS1_7genericUS1__U_S_9AssocReqt__fQPS1_US_13ArchetypeReqt__FT1xQ_1yS3__T_ : $@cc(witness_method) @thin (@in B, @owned ConformingClassToClassProtocol, @guaranteed ConformingClassToClassProtocol) -> () +// SYMBOL: sil hidden [transparent] [thunk] @_TTWC14witness_tables30ConformingClassToClassProtocolS_13ClassProtocolS_FS1_16assocTypesMethodUS1__U_S_9AssocReqt__fQPS1_FT1xQS3_9AssocType1yQS3_13AssocWithReqt_T_ : $@cc(witness_method) @thin (@in SomeAssoc, @in ConformingAssoc, @guaranteed ConformingClassToClassProtocol) -> () // SYMBOL: sil hidden [transparent] [thunk] @_TTWC14witness_tables30ConformingClassToClassProtocolS_13ClassProtocolS_ZFS1_12staticMethodUS1__U_S_9AssocReqt__fMQPS1_FT1xS3__T_ : $@cc(witness_method) @thin (@owned ConformingClassToClassProtocol, @thick ConformingClassToClassProtocol.Type) -> () // SYMBOL: sil hidden [transparent] [thunk] @_TTWC14witness_tables30ConformingClassToClassProtocolS_13ClassProtocolS_ZFS1_oi3ltgUS1__U_S_9AssocReqt__fMQPS1{{.*}} : $@cc(witness_method) @thin (@owned ConformingClassToClassProtocol, @owned ConformingClassToClassProtocol, @thick ConformingClassToClassProtocol.Type) -> () @@ -468,7 +468,7 @@ func <~>(x: ClassInheritedConformance, y: ClassInheritedConformance) {} // InheritedClassProtocol has a class bound, so its witnesses treat Self as // a reference value. // SYMBOL: sil hidden [transparent] [thunk] @_TTWC14witness_tables25ClassInheritedConformanceS_11AnyProtocolS_FS1_6methodUS1__U_S_9AssocReqt__fQPS1_FT1xVS_3Arg1yS3__T_ : $@cc(witness_method) @thin (Arg, @in ClassInheritedConformance, @in_guaranteed ClassInheritedConformance) -> () -// SYMBOL: sil hidden [transparent] [thunk] @_TTWC14witness_tables25ClassInheritedConformanceS_22InheritedClassProtocolS_FS1_15inheritedMethodUS1__U_S_9AssocReqt__fQPS1_FT_T_ : $@cc(witness_method) @thin (@owned ClassInheritedConformance) -> () +// SYMBOL: sil hidden [transparent] [thunk] @_TTWC14witness_tables25ClassInheritedConformanceS_22InheritedClassProtocolS_FS1_15inheritedMethodUS1__U_S_9AssocReqt__fQPS1_FT_T_ : $@cc(witness_method) @thin (@guaranteed ClassInheritedConformance) -> () struct GenericAssocType : AssocReqt { func requiredMethod() {} diff --git a/test/SILGen/witnesses.swift b/test/SILGen/witnesses.swift index e10ecba88a8..795c5b0be1f 100644 --- a/test/SILGen/witnesses.swift +++ b/test/SILGen/witnesses.swift @@ -167,9 +167,10 @@ final class ConformingClass : X { // CHECK-NEXT: strong_retain %3 : $ConformingClass // CHECK-NEXT: %5 = load %1 : $*ConformingClass // CHECK: %6 = function_ref @_TFC9witnesses15ConformingClass9selfTypesfS0_FT1xS0__S0_ - // CHECK-NEXT: %7 = apply %6(%5, %3) : $@cc(method) @thin (@owned ConformingClass, @owned ConformingClass) -> @owned ConformingClass + // CHECK-NEXT: %7 = apply %6(%5, %3) : $@cc(method) @thin (@owned ConformingClass, @guaranteed ConformingClass) -> @owned ConformingClass // CHECK-NEXT: store %7 to %0 : $*ConformingClass // CHECK-NEXT: %9 = tuple () + // CHECK-NEXT: strong_release %3 // CHECK-NEXT: return %9 : $() // CHECK-NEXT: } func loadable(#x: Loadable) -> Loadable { return x } @@ -180,11 +181,14 @@ final class ConformingClass : X { func <~>(x: ConformingClass, y: ConformingClass) -> ConformingClass { return x } extension ConformingClass : ClassBounded { } -// CHECK-LABEL: sil hidden [transparent] [thunk] @_TTWC9witnesses15ConformingClassS_12ClassBoundedS_FS1_9selfTypesUS1___fQPS1_FT1xS2__S2_ : $@cc(witness_method) @thin (@owned ConformingClass, @owned ConformingClass) -> @owned ConformingClass { -// CHECK-NEXT: bb0(%0 : $ConformingClass, %1 : $ConformingClass): -// CHECK: %2 = function_ref @_TFC9witnesses15ConformingClass9selfTypesfS0_FT1xS0__S0_ -// CHECK-NEXT: %3 = apply %2(%0, %1) : $@cc(method) @thin (@owned ConformingClass, @owned ConformingClass) -> @owned ConformingClass -// CHECK-NEXT: return %3 : $ConformingClass +// CHECK-LABEL: sil hidden [transparent] [thunk] @_TTWC9witnesses15ConformingClassS_12ClassBoundedS_FS1_9selfTypesUS1___fQPS1_FT1xS2__S2_ : $@cc(witness_method) @thin (@owned ConformingClass, @guaranteed ConformingClass) -> @owned ConformingClass { +// CHECK: bb0([[C0:%.*]] : $ConformingClass, [[C1:%.*]] : $ConformingClass): +// CHECK-NEXT: strong_retain [[C1]] +// CHECK-NEXT: function_ref +// CHECK-NEXT: [[FUN:%.*]] = function_ref @_TFC9witnesses15ConformingClass9selfTypesfS0_FT1xS0__S0_ +// CHECK-NEXT: [[RESULT:%.*]] = apply [[FUN]]([[C0]], [[C1]]) : $@cc(method) @thin (@owned ConformingClass, @guaranteed ConformingClass) -> @owned ConformingClass +// CHECK-NEXT: strong_release [[C1]] +// CHECK-NEXT: return [[RESULT]] : $ConformingClass // CHECK-NEXT: } struct ConformingAOStruct : X { diff --git a/test/SILGen/witnesses_class.swift b/test/SILGen/witnesses_class.swift index f42465f6d8e..e4631a42550 100644 --- a/test/SILGen/witnesses_class.swift +++ b/test/SILGen/witnesses_class.swift @@ -25,9 +25,12 @@ class Foo: Fooable { } // CHECK-LABEL: sil hidden @_TF15witnesses_class3genUS_7Fooable__FQ_T_ +// CHECK: bb0([[SELF:%.*]] : $T) // CHECK: [[METHOD:%.*]] = witness_method $T -// CHECK: strong_retain [[SELF:%.*]] : $ +// CHECK-NOT: strong_retain [[SELF]] // CHECK: apply [[METHOD]]([[SELF]]) +// CHECK: strong_release [[SELF]] +// CHECK-NOT: strong_release [[SELF]] // CHECK: return func gen(foo: T) { foo.foo() @@ -37,8 +40,10 @@ func gen(foo: T) { // CHECK: bb0([[SELF:%[0-0]+]] : $Fooable): // CHECK: [[SELF_PROJ:%.*]] = open_existential_ref [[SELF]] // CHECK: [[METHOD:%.*]] = witness_method $[[OPENED:@opened(.*) Fooable]], -// CHECK: strong_retain [[SELF_PROJ]] : $ +// CHECK-NOT: strong_retain [[SELF_PROJ]] : $ // CHECK: apply [[METHOD]]<[[OPENED]]>([[SELF_PROJ]]) +// CHECK: strong_release [[SELF]] +// CHECK-NOT: strong_release [[SELF]] // CHECK: return func ex(foo: Fooable) { foo.foo() diff --git a/test/SILGen/witnesses_inheritance.swift b/test/SILGen/witnesses_inheritance.swift index 425b30d2592..e20fb508d56 100644 --- a/test/SILGen/witnesses_inheritance.swift +++ b/test/SILGen/witnesses_inheritance.swift @@ -35,6 +35,8 @@ class B : A, Barrable {} // CHECK-NOT: sil hidden [transparent] [thunk] @_TTWC21witnesses_inheritance1BS_7FooableS_FS1_3fooUS1___fQPS1_FT_T_ // CHECK-NOT: sil hidden [transparent] [thunk] @_TTWC21witnesses_inheritance1BS_7FooableS_ZFS1_9class_fooUS1___fMQPS1_FT_T_ // CHECK-LABEL: sil hidden [transparent] [thunk] @_TTWC21witnesses_inheritance1BS_8BarrableS_FS1_3barUS1___fQPS1_FT_T_ -// CHECK: upcast {{%.*}} : $B to $A +// CHECK: upcast {{%.*}} : $*B to $*A // CHECK-LABEL: sil hidden [transparent] [thunk] @_TTWC21witnesses_inheritance1BS_8BarrableS_ZFS1_9class_barUS1___fMQPS1_FT_T_ // CHECK: upcast {{%.*}} : $@thick B.Type to $@thick A.Type + +// Add tests to make sure that we handle address only case correctly. diff --git a/test/SILPasses/devirt_single_module_in_multple_files.swift b/test/SILPasses/devirt_single_module_in_multple_files.swift index 3bb2a7c5be0..8cd8fd42eca 100644 --- a/test/SILPasses/devirt_single_module_in_multple_files.swift +++ b/test/SILPasses/devirt_single_module_in_multple_files.swift @@ -7,11 +7,11 @@ public func test() { } // CHECK-LABEL: sil shared @_TFFC38devirt_single_module_in_multiple_files9EvaluatorcFMS0_FT_S0_U_FT_Si -// CHECK: %{{.*}} = class_method %{{.*}} : $Problem1, #Problem1.run!1 : Problem1 -> () -> Int , $@cc(method) @thin (@owned Problem1) -> Int +// CHECK: %{{.*}} = class_method %{{.*}} : $Problem1, #Problem1.run!1 : Problem1 -> () -> Int , $@cc(method) @thin (@guaranteed Problem1) -> Int // CHECK-NEXT: apply // CHECK: return // CHECK-LABEL: sil shared @_TFFC38devirt_single_module_in_multiple_files9EvaluatorcFMS0_FT_S0_U0_FT_Si -// CHECK: %{{.*}} = class_method %{{.*}} : $Problem2, #Problem2.run!1 : Problem2 -> () -> Int , $@cc(method) @thin (@owned Problem2) -> Int +// CHECK: %{{.*}} = class_method %{{.*}} : $Problem2, #Problem2.run!1 : Problem2 -> () -> Int , $@cc(method) @thin (@guaranteed Problem2) -> Int // CHECK-NEXT: apply // CHECK: return diff --git a/test/SILPasses/devirt_specialized_inherited_interplay.swift b/test/SILPasses/devirt_specialized_inherited_interplay.swift index fdc3c215908..1ef9092932d 100644 --- a/test/SILPasses/devirt_specialized_inherited_interplay.swift +++ b/test/SILPasses/devirt_specialized_inherited_interplay.swift @@ -52,7 +52,9 @@ // CHECK-NEXT: class_method // CHECK-NEXT: strong_retain // CHECK-NEXT: apply +// CHECK-NEXT: strong_release // CHECK-NEXT: class_method +// CHECK-NEXT: strong_retain // CHECK-NEXT: apply // CHECK-NEXT: strong_release // CHECK-NEXT: strong_release @@ -60,6 +62,8 @@ // CHECK-NEXT: strong_release // CHECK-NEXT: strong_release // CHECK-NEXT: strong_release +// CHECK-NEXT: strong_release +// CHECK-NEXT: strong_release // CHECK-NEXT: tuple // CHECK-NEXT: return diff --git a/test/SILPasses/recursive_func.sil b/test/SILPasses/recursive_func.sil index 8976cf7bac5..7df9f0cc449 100644 --- a/test/SILPasses/recursive_func.sil +++ b/test/SILPasses/recursive_func.sil @@ -29,7 +29,7 @@ bb0(%c : $Builtin.Int32, %v : $Builtin.RawPointer): return %6 : $Builtin.Int32 } -sil @REC_recursive : $@cc(method) @thin (Int, @owned REC) -> () { +sil @REC_recursive : $@cc(method) @thin (Int, @guaranteed REC) -> () { bb0(%0 : $Int, %1 : $REC): debug_value %0 : $Int // let a // id: %2 debug_value %1 : $REC // let self // id: %3 @@ -48,7 +48,7 @@ bb0(%0 : $Int, %1 : $REC): bb1: // Preds: bb0 strong_retain %1 : $REC // id: %13 - %14 = class_method %1 : $REC, #REC.recursive!1 : REC -> (Int) -> () , $@cc(method) @thin (Int, @owned REC) -> () // user: %21 + %14 = class_method %1 : $REC, #REC.recursive!1 : REC -> (Int) -> () , $@cc(method) @thin (Int, @guaranteed REC) -> () // user: %21 // function_ref Swift.- @infix (Swift.Int, Swift.Int) -> Swift.Int %15 = function_ref @_TFSsoi1sFTSiSi_Si : $@thin (Int, Int) -> Int // user: %20 // function_ref Swift.Int._convertFromBuiltinIntegerLiteral (Swift.Int.Type)(Builtin.Int2048) -> Swift.Int @@ -57,9 +57,9 @@ bb1: // Preds: bb0 %18 = integer_literal $Builtin.Int2048, 2 // user: %19 %19 = apply %16(%18, %17) : $@thin (Builtin.Int2048, @thin Int.Type) -> Int // user: %20 %20 = apply %15(%0, %19) : $@thin (Int, Int) -> Int // user: %21 - %21 = apply %14(%20, %1) : $@cc(method) @thin (Int, @owned REC) -> () + %21 = apply %14(%20, %1) : $@cc(method) @thin (Int, @guaranteed REC) -> () strong_retain %1 : $REC // id: %22 - %23 = class_method %1 : $REC, #REC.recursive!1 : REC -> (Int) -> () , $@cc(method) @thin (Int, @owned REC) -> () // user: %30 + %23 = class_method %1 : $REC, #REC.recursive!1 : REC -> (Int) -> () , $@cc(method) @thin (Int, @guaranteed REC) -> () // user: %30 // function_ref Swift.- @infix (Swift.Int, Swift.Int) -> Swift.Int %24 = function_ref @_TFSsoi1sFTSiSi_Si : $@thin (Int, Int) -> Int // user: %29 // function_ref Swift.Int._convertFromBuiltinIntegerLiteral (Swift.Int.Type)(Builtin.Int2048) -> Swift.Int @@ -68,7 +68,7 @@ bb1: // Preds: bb0 %27 = integer_literal $Builtin.Int2048, 1 // user: %28 %28 = apply %25(%27, %26) : $@thin (Builtin.Int2048, @thin Int.Type) -> Int // user: %29 %29 = apply %24(%0, %28) : $@thin (Int, Int) -> Int // user: %30 - %30 = apply %23(%29, %1) : $@cc(method) @thin (Int, @owned REC) -> () + %30 = apply %23(%29, %1) : $@cc(method) @thin (Int, @guaranteed REC) -> () br bb2 // id: %31 bb2: // Preds: bb0 bb1 @@ -138,8 +138,8 @@ bb0(%0 : $Int): %4 = apply %2(%3) : $@thin (@thick REC.Type) -> @owned REC // users: %5, %6, %7, %8, %9 debug_value %4 : $REC // let rec // id: %5 strong_retain %4 : $REC // id: %6 - %7 = class_method %4 : $REC, #REC.recursive!1 : REC -> (Int) -> () , $@cc(method) @thin (Int, @owned REC) -> () // user: %8 - %8 = apply %7(%0, %4) : $@cc(method) @thin (Int, @owned REC) -> () + %7 = class_method %4 : $REC, #REC.recursive!1 : REC -> (Int) -> () , $@cc(method) @thin (Int, @guaranteed REC) -> () // user: %8 + %8 = apply %7(%0, %4) : $@cc(method) @thin (Int, @guaranteed REC) -> () strong_release %4 : $REC // id: %9 %10 = tuple () // user: %11 return %10 : $() // id: %11 diff --git a/test/SILPasses/recursive_single.sil b/test/SILPasses/recursive_single.sil index 89c095d7f77..e8a01f792c0 100644 --- a/test/SILPasses/recursive_single.sil +++ b/test/SILPasses/recursive_single.sil @@ -31,7 +31,7 @@ bb0(%c : $Builtin.Int32, %v : $Builtin.RawPointer): } // single.REC.recursive (single.REC)(Swift.Int) -> () -sil @_TFC6single3REC9recursivefS0_FSiT_ : $@cc(method) @thin (Int, @owned REC) -> () { +sil @_TFC6single3REC9recursivefS0_FSiT_ : $@cc(method) @thin (Int, @guaranteed REC) -> () { bb0(%0 : $Int, %1 : $REC): debug_value %0 : $Int // let a // id: %2 debug_value %1 : $REC // let self // id: %3 @@ -50,7 +50,7 @@ bb0(%0 : $Int, %1 : $REC): bb1: // Preds: bb0 strong_retain %1 : $REC // id: %13 - %14 = class_method %1 : $REC, #REC.recursive!1 : REC -> (Int) -> () , $@cc(method) @thin (Int, @owned REC) -> () // user: %21 + %14 = class_method %1 : $REC, #REC.recursive!1 : REC -> (Int) -> () , $@cc(method) @thin (Int, @guaranteed REC) -> () // user: %21 // function_ref Swift.- @infix (Swift.Int, Swift.Int) -> Swift.Int %15 = function_ref @_TFSsoi1sFTSiSi_Si : $@thin (Int, Int) -> Int // user: %20 // function_ref Swift.Int._convertFromBuiltinIntegerLiteral (Swift.Int.Type)(Builtin.Int2048) -> Swift.Int @@ -59,7 +59,7 @@ bb1: // Preds: bb0 %18 = integer_literal $Builtin.Int2048, 2 // user: %19 %19 = apply %16(%18, %17) : $@thin (Builtin.Int2048, @thin Int.Type) -> Int // user: %20 %20 = apply %15(%0, %19) : $@thin (Int, Int) -> Int // user: %21 - %21 = apply %14(%20, %1) : $@cc(method) @thin (Int, @owned REC) -> () + %21 = apply %14(%20, %1) : $@cc(method) @thin (Int, @guaranteed REC) -> () br bb2 // id: %22 bb2: // Preds: bb0 bb1 @@ -129,8 +129,8 @@ bb0(%0 : $Int): %4 = apply %2(%3) : $@thin (@thick REC.Type) -> @owned REC // users: %5, %6, %7, %8, %9 debug_value %4 : $REC // let rec // id: %5 strong_retain %4 : $REC // id: %6 - %7 = class_method %4 : $REC, #REC.recursive!1 : REC -> (Int) -> () , $@cc(method) @thin (Int, @owned REC) -> () // user: %8 - %8 = apply %7(%0, %4) : $@cc(method) @thin (Int, @owned REC) -> () + %7 = class_method %4 : $REC, #REC.recursive!1 : REC -> (Int) -> () , $@cc(method) @thin (Int, @guaranteed REC) -> () // user: %8 + %8 = apply %7(%0, %4) : $@cc(method) @thin (Int, @guaranteed REC) -> () strong_release %4 : $REC // id: %9 %10 = tuple () // user: %11 return %10 : $() // id: %11 diff --git a/test/Serialization/Inputs/def_basic.sil b/test/Serialization/Inputs/def_basic.sil index 0a41434ec1f..fc85169a7c4 100644 --- a/test/Serialization/Inputs/def_basic.sil +++ b/test/Serialization/Inputs/def_basic.sil @@ -201,7 +201,7 @@ bb0: %O = unchecked_ref_cast %C : $C to $Builtin.UnknownObject // CHECK: class_method {{.*}} : $C, #C.doIt!1 - %2 = class_method %C : $C, #C.doIt!1 : C -> () -> (), $@cc(method) @thin (@owned C) -> () + %2 = class_method %C : $C, #C.doIt!1 : C -> () -> (), $@cc(method) @thin (@guaranteed C) -> () // CHECK: alloc_ref $D %D = alloc_ref $D @@ -415,8 +415,8 @@ class M { init() } -// CHECK-LABEL: @_TFC3ref1C3foofS0_FT1xSi_T_ : $@cc(method) @thin (Int, M) -> () -sil [fragile] @_TFC3ref1C3foofS0_FT1xSi_T_ : $@cc(method) @thin (Int, M) -> () { +// CHECK-LABEL: @_TFC3ref1C3foofS0_FT1xSi_T_ : $@cc(method) @thin (Int, @guaranteed M) -> () +sil [fragile] @_TFC3ref1C3foofS0_FT1xSi_T_ : $@cc(method) @thin (Int, @guaranteed M) -> () { bb0(%0 : $Int, %1 : $M): %2 = alloc_box $Int %3 = store %0 to %2#1 : $*Int @@ -605,7 +605,7 @@ class Bas : NSObject { override init() } sil [fragile] @test_autorelease_return : $@cc(objc_method) @thin (Bas) -> NSString -sil [fragile] @test_super_method : $@cc(method) @thin (Bas) -> Bas +sil [fragile] @test_super_method : $@cc(method) @thin (@guaranteed Bas) -> Bas sil [fragile] @swift_StringToNSString : $@thin (@inout String) -> @owned NSString sil [fragile] @_TFSSCfMSSFT_SS : $@thin (@thin String.Type) -> String @@ -1095,9 +1095,9 @@ class Foo { init() } -// CHECK-LABEL: sil [fragile] @_TFC3tmp3Foog9subscriptFT1xSi1ySi_Si : $@cc(method) @thin (Int, Int, @owned Foo) -> Int32 -// CHECK_DECL-LABEL: sil [fragile] @_TFC3tmp3Foog9subscriptFT1xSi1ySi_Si : $@cc(method) @thin (Int, Int, @owned Foo) -> Int32{{$}} -sil [fragile] @_TFC3tmp3Foog9subscriptFT1xSi1ySi_Si : $@cc(method) @thin (Int, Int, @owned Foo) -> Int32 { +// CHECK-LABEL: sil [fragile] @_TFC3tmp3Foog9subscriptFT1xSi1ySi_Si : $@cc(method) @thin (Int, Int, @guaranteed Foo) -> Int32 +// CHECK_DECL-LABEL: sil [fragile] @_TFC3tmp3Foog9subscriptFT1xSi1ySi_Si : $@cc(method) @thin (Int, Int, @guaranteed Foo) -> Int32{{$}} +sil [fragile] @_TFC3tmp3Foog9subscriptFT1xSi1ySi_Si : $@cc(method) @thin (Int, Int, @guaranteed Foo) -> Int32 { bb0(%0 : $Int, %1 : $Int, %2 : $Foo): %3 = tuple () %4 = alloc_stack $Int // var x // users: %17, %6 @@ -1116,9 +1116,9 @@ bb0(%0 : $Int, %1 : $Int, %2 : $Foo): return %13 : $Int32 } -// CHECK-LABEL: sil [fragile] @_TFC3tmp3Foos9subscriptFT1xSi1ySi_Si : $@cc(method) @thin (Int32, Int, Int, @owned Foo) -> () -// CHECK_DECL-LABEL: sil [fragile] @_TFC3tmp3Foos9subscriptFT1xSi1ySi_Si : $@cc(method) @thin (Int32, Int, Int, @owned Foo) -> (){{$}} -sil [fragile] @_TFC3tmp3Foos9subscriptFT1xSi1ySi_Si : $@cc(method) @thin (Int32, Int, Int, @owned Foo) -> () { +// CHECK-LABEL: sil [fragile] @_TFC3tmp3Foos9subscriptFT1xSi1ySi_Si : $@cc(method) @thin (Int32, Int, Int, @guaranteed Foo) -> () +// CHECK_DECL-LABEL: sil [fragile] @_TFC3tmp3Foos9subscriptFT1xSi1ySi_Si : $@cc(method) @thin (Int32, Int, Int, @guaranteed Foo) -> (){{$}} +sil [fragile] @_TFC3tmp3Foos9subscriptFT1xSi1ySi_Si : $@cc(method) @thin (Int32, Int, Int, @guaranteed Foo) -> () { bb0(%0 : $Int32, %1 : $Int, %2 : $Int, %3 : $Foo): %4 = alloc_stack $Int32 // var value // users: %16, %5 store %0 to %4#1 : $*Int32 @@ -1158,7 +1158,7 @@ struct ConformingAssoc : AssocReqt { func requiredMethod() } -sil [fragile] @_TFV14witness_tables15ConformingAssoc14requiredMethodfS0_FT_T_ : $@cc(method) @thin (ConformingAssoc) -> () { +sil [fragile] @_TFV14witness_tables15ConformingAssoc14requiredMethodfS0_FT_T_ : $@cc(method) @thin (@guaranteed ConformingAssoc) -> () { bb0(%0 : $ConformingAssoc): debug_value %0 : $ConformingAssoc %2 = tuple () @@ -1168,8 +1168,8 @@ bb0(%0 : $ConformingAssoc): sil [fragile] @_TTWV14witness_tables15ConformingAssocS_9AssocReqtS_FS1_14requiredMethodU_fRQPS1_FT_T_ : $@cc(witness_method) @thin (@inout ConformingAssoc) -> () { bb0(%0 : $*ConformingAssoc): %1 = load %0 : $*ConformingAssoc - %2 = function_ref @_TFV14witness_tables15ConformingAssoc14requiredMethodfS0_FT_T_ : $@cc(method) @thin (ConformingAssoc) -> () - %3 = apply %2(%1) : $@cc(method) @thin (ConformingAssoc) -> () + %2 = function_ref @_TFV14witness_tables15ConformingAssoc14requiredMethodfS0_FT_T_ : $@cc(method) @thin (@guaranteed ConformingAssoc) -> () + %3 = apply %2(%1) : $@cc(method) @thin (@guaranteed ConformingAssoc) -> () return %3 : $() } @@ -1239,7 +1239,7 @@ bb0: %43 = function_ref @_TF5tuple5floatFT1xSf_T_ : $@thin (Float32) -> () %45 = function_ref @_TF5tuple5tupleFT_TSiSf_ : $@thin () -> (Int, Float32) %47 = function_ref @_TF5tuple13tuple_elementFT1xTSiSf__T_ : $@thin (Int, Float32) -> () - %49 = function_ref @_TFC3ref1C3foofS0_FT1xSi_T_ : $@cc(method) @thin (Int, M) -> () + %49 = function_ref @_TFC3ref1C3foofS0_FT1xSi_T_ : $@cc(method) @thin (Int, @guaranteed M) -> () %51 = function_ref @_TF4null3isaFT1bCS_1B_Sb : $@thin (B) -> Builtin.Int1 %53 = function_ref @_TFSd31_convertFromBuiltinFloatLiteralfMSdFT5valueBf64__Sd : $@thin (Builtin.FPIEEE64, @thin Float64.Type) -> Float64 %55 = function_ref @_TFSS32_convertFromBuiltinStringLiteralfMSSFT5valueBp8byteSizeBi64_7isASCIIBi1__SS : $@thin (Builtin.RawPointer, Builtin.Word, Builtin.Int1, @thin String.Type) -> String @@ -1254,7 +1254,7 @@ bb0: %75 = function_ref @test_cond_branch_basic_block_args : $@thin (Int, Builtin.Int1) -> Int %77 = function_ref @test_autorelease_return : $@cc(objc_method) @thin (Bas) -> NSString - %79 = function_ref @test_super_method : $@cc(method) @thin (Bas) -> Bas + %79 = function_ref @test_super_method : $@cc(method) @thin (@guaranteed Bas) -> Bas %81 = function_ref @test_builtin_func_ref : $@thin (Builtin.Int1, Builtin.Int1) -> Builtin.Int1 %83 = function_ref @test_dealloc_ref : $@thin () -> () %85 = function_ref @test_dealloc_box : $@thin () -> () diff --git a/test/Serialization/generic_extension.swift b/test/Serialization/generic_extension.swift index f9b8c05ad6d..cdaa27c32ca 100644 --- a/test/Serialization/generic_extension.swift +++ b/test/Serialization/generic_extension.swift @@ -10,4 +10,4 @@ import generic_extension_1 ["a", "b", "c"].wobble() -// CHECK: sil @_TFE19generic_extension_1Sa6wobbleU__fGSaQ__FT_GSqQ__ : $@cc(method) @thin <τ_0_0> (@out Optional<τ_0_0>, @owned Array<τ_0_0>) -> () +// CHECK: sil @_TFE19generic_extension_1Sa6wobbleU__fGSaQ__FT_GSqQ__ : $@cc(method) @thin <τ_0_0> (@out Optional<τ_0_0>, @guaranteed Array<τ_0_0>) -> () diff --git a/test/sil-extract/basic.swift b/test/sil-extract/basic.swift index 2fd524ebe6a..6ab17712c6b 100644 --- a/test/sil-extract/basic.swift +++ b/test/sil-extract/basic.swift @@ -14,8 +14,8 @@ // EXTRACT-FOO-NOT: sil hidden @_TFV5basic1X4testfS0_FT_T_ : $@cc(method) @thin (X) -> () { -// EXTRACT-FOO-NOT: sil hidden @_TFC5basic7VehiclecfMS0_FT1nSi_S0_ : $@cc(method) @thin (Int, @owned Vehicle) -> @owned Vehicle { -// EXTRACT-FOO-NOT: sil hidden @_TFC5basic7Vehicle3nowfS0_FT_Si : $@cc(method) @thin (@owned Vehicle) -> Int { +// EXTRACT-FOO-NOT: sil hidden @_TFC5basic7VehiclecfMS0_FT1nSi_S0_ : $@cc(method) @thin (Int, @guaranteed Vehicle) -> @owned Vehicle { +// EXTRACT-FOO-NOT: sil hidden @_TFC5basic7Vehicle3nowfS0_FT_Si : $@cc(method) @thin (@guaranteed Vehicle) -> Int { // EXTRACT-FOO-LABEL: sil hidden @_TF5basic3fooFT_Si : $@thin () -> Int { // EXTRACT-FOO: bb0: @@ -25,8 +25,8 @@ // EXTRACT-TEST-NOT: sil hidden @_TF5basic3fooFT_Si : $@thin () -> Int { -// EXTRACT-TEST-NOT: sil hidden @_TFC5basic7VehiclecfMS0_FT1nSi_S0_ : $@cc(method) @thin (Int, @owned Vehicle) -> @owned Vehicle { -// EXTRACT-TEST-NOT: sil hidden @_TFC5basic7Vehicle3nowfS0_FT_Si : $@cc(method) @thin (@owned Vehicle) -> Int { +// EXTRACT-TEST-NOT: sil hidden @_TFC5basic7VehiclecfMS0_FT1nSi_S0_ : $@cc(method) @thin (Int, @guaranteed Vehicle) -> @owned Vehicle { +// EXTRACT-TEST-NOT: sil hidden @_TFC5basic7Vehicle3nowfS0_FT_Si : $@cc(method) @thin (@guaranteed Vehicle) -> Int { // EXTRACT-TEST-LABEL: sil hidden @_TFV5basic1X4testfS0_FT_T_ : $@cc(method) @thin (X) -> () { // EXTRACT-TEST: bb0(%0 : $X): @@ -53,16 +53,13 @@ // EXTRACT-NOW-NOT: sil hidden @_TF5basic3fooFT_Si : $@thin () -> Int { // EXTRACT-NOW-NOT: sil hidden @_TFV5basic1X4testfS0_FT_T_ : $@cc(method) @thin (X) -> () { -// EXTRACT-NOW-NOT: sil hidden @_TFC5basic7VehiclecfMS0_FT1nSi_S0_ : $@cc(method) @thin (Int, @owned Vehicle) -> @owned Vehicle { +// EXTRACT-NOW-NOT: sil hidden @_TFC5basic7VehiclecfMS0_FT1nSi_S0_ : $@cc(method) @thin (Int, @guaranteed Vehicle) -> @owned Vehicle { -// EXTRACT-NOW-LABEL: sil hidden @_TFC5basic7Vehicle3nowfS0_FT_Si : $@cc(method) @thin (@owned Vehicle) -> Int { +// EXTRACT-NOW-LABEL: sil hidden @_TFC5basic7Vehicle3nowfS0_FT_Si : $@cc(method) @thin (@guaranteed Vehicle) -> Int { // EXTRACT-NOW: bb0 // EXTRACT-NOW-NEXT: debug_value -// EXTRACT-NOW-NEXT: strong_retain // EXTRACT-NOW-NEXT: ref_element_addr // EXTRACT-NOW-NEXT: load -// EXTRACT-NOW-NEXT: strong_release -// EXTRACT-NOW-NEXT: strong_release // EXTRACT-NOW-NEXT: return struct X { diff --git a/validation-test/parser/Inputs/gen_parse_stdlib_tests.sh b/validation-test/parser/Inputs/gen_parse_stdlib_tests.sh index 2a8e0ebbed1..0efe1abca8d 100644 --- a/validation-test/parser/Inputs/gen_parse_stdlib_tests.sh +++ b/validation-test/parser/Inputs/gen_parse_stdlib_tests.sh @@ -12,8 +12,8 @@ for id in $(seq 0 $process_id_max); do // Make sure that we can parse the stdlib.sil deserialized from Swift.swiftmodule. // RUN: rm -f %t.* -// RUN: %target-sil-opt -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil -// RUN: %target-sil-opt %t.sil -ast-verifier-process-count=$process_count -ast-verifier-process-id=$id > /dev/null +// RUN: %target-sil-opt -enable-guaranteed-self -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil +// RUN: %target-sil-opt -enable-guaranteed-self %t.sil -ast-verifier-process-count=$process_count -ast-verifier-process-id=$id > /dev/null __EOF__ done diff --git a/validation-test/parser/parse_stdlib_0.sil b/validation-test/parser/parse_stdlib_0.sil index bb8c8490753..56174e537c2 100644 --- a/validation-test/parser/parse_stdlib_0.sil +++ b/validation-test/parser/parse_stdlib_0.sil @@ -4,5 +4,5 @@ // Make sure that we can parse the stdlib.sil deserialized from Swift.swiftmodule. // RUN: rm -f %t.* -// RUN: %target-sil-opt -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil -// RUN: %target-sil-opt %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=0 > /dev/null +// RUN: %target-sil-opt -enable-guaranteed-self -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil +// RUN: %target-sil-opt -enable-guaranteed-self %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=0 > /dev/null diff --git a/validation-test/parser/parse_stdlib_1.sil b/validation-test/parser/parse_stdlib_1.sil index df172d1e853..9d261f2d2ab 100644 --- a/validation-test/parser/parse_stdlib_1.sil +++ b/validation-test/parser/parse_stdlib_1.sil @@ -4,5 +4,5 @@ // Make sure that we can parse the stdlib.sil deserialized from Swift.swiftmodule. // RUN: rm -f %t.* -// RUN: %target-sil-opt -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil -// RUN: %target-sil-opt %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=1 > /dev/null +// RUN: %target-sil-opt -enable-guaranteed-self -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil +// RUN: %target-sil-opt -enable-guaranteed-self %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=1 > /dev/null diff --git a/validation-test/parser/parse_stdlib_10.sil b/validation-test/parser/parse_stdlib_10.sil index c563c86b48f..42e12901bce 100644 --- a/validation-test/parser/parse_stdlib_10.sil +++ b/validation-test/parser/parse_stdlib_10.sil @@ -4,5 +4,5 @@ // Make sure that we can parse the stdlib.sil deserialized from Swift.swiftmodule. // RUN: rm -f %t.* -// RUN: %target-sil-opt -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil -// RUN: %target-sil-opt %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=10 > /dev/null +// RUN: %target-sil-opt -enable-guaranteed-self -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil +// RUN: %target-sil-opt -enable-guaranteed-self %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=10 > /dev/null diff --git a/validation-test/parser/parse_stdlib_11.sil b/validation-test/parser/parse_stdlib_11.sil index e6f16b5b0dd..72f927281cd 100644 --- a/validation-test/parser/parse_stdlib_11.sil +++ b/validation-test/parser/parse_stdlib_11.sil @@ -4,5 +4,5 @@ // Make sure that we can parse the stdlib.sil deserialized from Swift.swiftmodule. // RUN: rm -f %t.* -// RUN: %target-sil-opt -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil -// RUN: %target-sil-opt %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=11 > /dev/null +// RUN: %target-sil-opt -enable-guaranteed-self -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil +// RUN: %target-sil-opt -enable-guaranteed-self %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=11 > /dev/null diff --git a/validation-test/parser/parse_stdlib_12.sil b/validation-test/parser/parse_stdlib_12.sil index 2f3cd770ba9..ea8370f33c7 100644 --- a/validation-test/parser/parse_stdlib_12.sil +++ b/validation-test/parser/parse_stdlib_12.sil @@ -4,5 +4,5 @@ // Make sure that we can parse the stdlib.sil deserialized from Swift.swiftmodule. // RUN: rm -f %t.* -// RUN: %target-sil-opt -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil -// RUN: %target-sil-opt %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=12 > /dev/null +// RUN: %target-sil-opt -enable-guaranteed-self -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil +// RUN: %target-sil-opt -enable-guaranteed-self %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=12 > /dev/null diff --git a/validation-test/parser/parse_stdlib_13.sil b/validation-test/parser/parse_stdlib_13.sil index fc379bd16b0..0aaca4c6267 100644 --- a/validation-test/parser/parse_stdlib_13.sil +++ b/validation-test/parser/parse_stdlib_13.sil @@ -4,5 +4,5 @@ // Make sure that we can parse the stdlib.sil deserialized from Swift.swiftmodule. // RUN: rm -f %t.* -// RUN: %target-sil-opt -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil -// RUN: %target-sil-opt %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=13 > /dev/null +// RUN: %target-sil-opt -enable-guaranteed-self -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil +// RUN: %target-sil-opt -enable-guaranteed-self %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=13 > /dev/null diff --git a/validation-test/parser/parse_stdlib_14.sil b/validation-test/parser/parse_stdlib_14.sil index 0272ab87f72..9f23cf35de6 100644 --- a/validation-test/parser/parse_stdlib_14.sil +++ b/validation-test/parser/parse_stdlib_14.sil @@ -4,5 +4,5 @@ // Make sure that we can parse the stdlib.sil deserialized from Swift.swiftmodule. // RUN: rm -f %t.* -// RUN: %target-sil-opt -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil -// RUN: %target-sil-opt %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=14 > /dev/null +// RUN: %target-sil-opt -enable-guaranteed-self -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil +// RUN: %target-sil-opt -enable-guaranteed-self %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=14 > /dev/null diff --git a/validation-test/parser/parse_stdlib_15.sil b/validation-test/parser/parse_stdlib_15.sil index 94134d5e0a7..6cce6c4b4a9 100644 --- a/validation-test/parser/parse_stdlib_15.sil +++ b/validation-test/parser/parse_stdlib_15.sil @@ -4,5 +4,5 @@ // Make sure that we can parse the stdlib.sil deserialized from Swift.swiftmodule. // RUN: rm -f %t.* -// RUN: %target-sil-opt -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil -// RUN: %target-sil-opt %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=15 > /dev/null +// RUN: %target-sil-opt -enable-guaranteed-self -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil +// RUN: %target-sil-opt -enable-guaranteed-self %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=15 > /dev/null diff --git a/validation-test/parser/parse_stdlib_16.sil b/validation-test/parser/parse_stdlib_16.sil index 08b14d4d376..a7b3bbbcb18 100644 --- a/validation-test/parser/parse_stdlib_16.sil +++ b/validation-test/parser/parse_stdlib_16.sil @@ -4,5 +4,5 @@ // Make sure that we can parse the stdlib.sil deserialized from Swift.swiftmodule. // RUN: rm -f %t.* -// RUN: %target-sil-opt -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil -// RUN: %target-sil-opt %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=16 > /dev/null +// RUN: %target-sil-opt -enable-guaranteed-self -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil +// RUN: %target-sil-opt -enable-guaranteed-self %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=16 > /dev/null diff --git a/validation-test/parser/parse_stdlib_2.sil b/validation-test/parser/parse_stdlib_2.sil index b7fcc226513..9fd437bbdac 100644 --- a/validation-test/parser/parse_stdlib_2.sil +++ b/validation-test/parser/parse_stdlib_2.sil @@ -4,5 +4,5 @@ // Make sure that we can parse the stdlib.sil deserialized from Swift.swiftmodule. // RUN: rm -f %t.* -// RUN: %target-sil-opt -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil -// RUN: %target-sil-opt %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=2 > /dev/null +// RUN: %target-sil-opt -enable-guaranteed-self -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil +// RUN: %target-sil-opt -enable-guaranteed-self %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=2 > /dev/null diff --git a/validation-test/parser/parse_stdlib_3.sil b/validation-test/parser/parse_stdlib_3.sil index 4f3a03d2105..12689fdc12e 100644 --- a/validation-test/parser/parse_stdlib_3.sil +++ b/validation-test/parser/parse_stdlib_3.sil @@ -4,5 +4,5 @@ // Make sure that we can parse the stdlib.sil deserialized from Swift.swiftmodule. // RUN: rm -f %t.* -// RUN: %target-sil-opt -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil -// RUN: %target-sil-opt %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=3 > /dev/null +// RUN: %target-sil-opt -enable-guaranteed-self -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil +// RUN: %target-sil-opt -enable-guaranteed-self %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=3 > /dev/null diff --git a/validation-test/parser/parse_stdlib_4.sil b/validation-test/parser/parse_stdlib_4.sil index c3594439c0f..bf87a4157f3 100644 --- a/validation-test/parser/parse_stdlib_4.sil +++ b/validation-test/parser/parse_stdlib_4.sil @@ -4,5 +4,5 @@ // Make sure that we can parse the stdlib.sil deserialized from Swift.swiftmodule. // RUN: rm -f %t.* -// RUN: %target-sil-opt -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil -// RUN: %target-sil-opt %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=4 > /dev/null +// RUN: %target-sil-opt -enable-guaranteed-self -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil +// RUN: %target-sil-opt -enable-guaranteed-self %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=4 > /dev/null diff --git a/validation-test/parser/parse_stdlib_5.sil b/validation-test/parser/parse_stdlib_5.sil index e2f8a307f91..b90b03845bf 100644 --- a/validation-test/parser/parse_stdlib_5.sil +++ b/validation-test/parser/parse_stdlib_5.sil @@ -4,5 +4,5 @@ // Make sure that we can parse the stdlib.sil deserialized from Swift.swiftmodule. // RUN: rm -f %t.* -// RUN: %target-sil-opt -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil -// RUN: %target-sil-opt %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=5 > /dev/null +// RUN: %target-sil-opt -enable-guaranteed-self -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil +// RUN: %target-sil-opt -enable-guaranteed-self %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=5 > /dev/null diff --git a/validation-test/parser/parse_stdlib_6.sil b/validation-test/parser/parse_stdlib_6.sil index c5a8d473890..45a84de203d 100644 --- a/validation-test/parser/parse_stdlib_6.sil +++ b/validation-test/parser/parse_stdlib_6.sil @@ -4,5 +4,5 @@ // Make sure that we can parse the stdlib.sil deserialized from Swift.swiftmodule. // RUN: rm -f %t.* -// RUN: %target-sil-opt -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil -// RUN: %target-sil-opt %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=6 > /dev/null +// RUN: %target-sil-opt -enable-guaranteed-self -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil +// RUN: %target-sil-opt -enable-guaranteed-self %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=6 > /dev/null diff --git a/validation-test/parser/parse_stdlib_7.sil b/validation-test/parser/parse_stdlib_7.sil index 3668520ea9d..8279234b902 100644 --- a/validation-test/parser/parse_stdlib_7.sil +++ b/validation-test/parser/parse_stdlib_7.sil @@ -4,5 +4,5 @@ // Make sure that we can parse the stdlib.sil deserialized from Swift.swiftmodule. // RUN: rm -f %t.* -// RUN: %target-sil-opt -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil -// RUN: %target-sil-opt %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=7 > /dev/null +// RUN: %target-sil-opt -enable-guaranteed-self -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil +// RUN: %target-sil-opt -enable-guaranteed-self %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=7 > /dev/null diff --git a/validation-test/parser/parse_stdlib_8.sil b/validation-test/parser/parse_stdlib_8.sil index 9d5ff243c12..2d4d3207e47 100644 --- a/validation-test/parser/parse_stdlib_8.sil +++ b/validation-test/parser/parse_stdlib_8.sil @@ -4,5 +4,5 @@ // Make sure that we can parse the stdlib.sil deserialized from Swift.swiftmodule. // RUN: rm -f %t.* -// RUN: %target-sil-opt -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil -// RUN: %target-sil-opt %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=8 > /dev/null +// RUN: %target-sil-opt -enable-guaranteed-self -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil +// RUN: %target-sil-opt -enable-guaranteed-self %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=8 > /dev/null diff --git a/validation-test/parser/parse_stdlib_9.sil b/validation-test/parser/parse_stdlib_9.sil index 6caf6013065..16fc0494972 100644 --- a/validation-test/parser/parse_stdlib_9.sil +++ b/validation-test/parser/parse_stdlib_9.sil @@ -4,5 +4,5 @@ // Make sure that we can parse the stdlib.sil deserialized from Swift.swiftmodule. // RUN: rm -f %t.* -// RUN: %target-sil-opt -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil -// RUN: %target-sil-opt %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=9 > /dev/null +// RUN: %target-sil-opt -enable-guaranteed-self -sil-disable-ast-dump -verify %platform-module-dir/Swift.swiftmodule -module-name=Swift -o %t.sil +// RUN: %target-sil-opt -enable-guaranteed-self %t.sil -ast-verifier-process-count=17 -ast-verifier-process-id=9 > /dev/null