diff --git a/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ComputeSideEffects.swift b/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ComputeSideEffects.swift index aa5c8ef5ec691..7c5d8bee4b635 100644 --- a/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ComputeSideEffects.swift +++ b/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ComputeSideEffects.swift @@ -255,7 +255,7 @@ private struct CollectedEffects { addEffects(.destroy, to: inst.operands[0].value, fromInitialPath: SmallProjectionPath(.anyValueFields)) case is ReturnInst: - if inst.parentFunction.convention.hasGuaranteedAddressResult { + if inst.parentFunction.convention.hasAddressResult { addEffects(.read, to: inst.operands[0].value) } diff --git a/SwiftCompilerSources/Sources/SIL/ApplySite.swift b/SwiftCompilerSources/Sources/SIL/ApplySite.swift index 7f0187819e097..2aa5098412604 100644 --- a/SwiftCompilerSources/Sources/SIL/ApplySite.swift +++ b/SwiftCompilerSources/Sources/SIL/ApplySite.swift @@ -303,10 +303,6 @@ extension ApplySite { public var hasGuaranteedResult: Bool { functionConvention.hasGuaranteedResult } - - public var hasGuaranteedAddressResult: Bool { - functionConvention.hasGuaranteedAddressResult - } } extension ApplySite { diff --git a/SwiftCompilerSources/Sources/SIL/Argument.swift b/SwiftCompilerSources/Sources/SIL/Argument.swift index febd27f9af5dc..020918dafa80a 100644 --- a/SwiftCompilerSources/Sources/SIL/Argument.swift +++ b/SwiftCompilerSources/Sources/SIL/Argument.swift @@ -488,8 +488,8 @@ public enum ArgumentConvention : CustomStringConvertible { self = .directUnowned case .pack: self = .packOut - case .guaranteed, .guaranteedAddress: - fatalError("Result conventions @guaranteed and @guaranteed_addr are always returned directly") + case .guaranteed, .guaranteedAddress, .inout: + fatalError("Result conventions @guaranteed, @guaranteed_address and @inout are always returned directly") } } diff --git a/SwiftCompilerSources/Sources/SIL/FunctionConvention.swift b/SwiftCompilerSources/Sources/SIL/FunctionConvention.swift index eabb84031085b..2f2fb21678325 100644 --- a/SwiftCompilerSources/Sources/SIL/FunctionConvention.swift +++ b/SwiftCompilerSources/Sources/SIL/FunctionConvention.swift @@ -102,14 +102,20 @@ public struct FunctionConvention : CustomStringConvertible { if results.count != 1 { return false } - return results[0].convention == .guaranteed + if hasLoweredAddresses { + return results[0].convention == .guaranteed + } + return results[0].convention == .guaranteed || results[0].convention == .guaranteedAddress } - public var hasGuaranteedAddressResult: Bool { + public var hasAddressResult: Bool { if results.count != 1 { return false } - return results[0].convention == .guaranteedAddress + if hasLoweredAddresses { + return results[0].convention == .guaranteedAddress || results[0].convention == .inout + } + return results[0].convention == .inout } public var description: String { @@ -147,7 +153,7 @@ public struct ResultInfo : CustomStringConvertible { return hasLoweredAddresses || type.isExistentialArchetypeWithError() case .pack: return true - case .owned, .unowned, .unownedInnerPointer, .autoreleased, .guaranteed, .guaranteedAddress: + case .owned, .unowned, .unownedInnerPointer, .autoreleased, .guaranteed, .guaranteedAddress, .inout: return false } } @@ -373,13 +379,17 @@ public enum ResultConvention : CustomStringConvertible { case owned /// The caller is responsible for using the returned address within a valid - /// scope. This is valid only for borrow and mutate accessors. + /// scope. This is valid only for borrow accessors. case guaranteedAddress /// The caller is responsible for using the returned value within a valid /// scope. This is valid only for borrow accessors. case guaranteed + /// The caller is responsible for mutating the returned address within a valid + /// scope. This is valid only for mutate accessors. + case `inout` + /// The caller is not responsible for destroying this return value. Its type may be trivial, or it may simply be offered unsafely. It is valid at the instant of the return, but further operations may invalidate it. case unowned @@ -423,6 +433,8 @@ public enum ResultConvention : CustomStringConvertible { return "guaranteed" case .guaranteedAddress: return "guaranteedAddress" + case .inout: + return "inout" } } } @@ -456,6 +468,7 @@ extension ResultConvention { case .Pack: self = .pack case .Guaranteed: self = .guaranteed case .GuaranteedAddress: self = .guaranteedAddress + case .Inout: self = .inout default: fatalError("unsupported result convention") } diff --git a/docs/ABI/Mangling.rst b/docs/ABI/Mangling.rst index 28ecf6cc852e5..8c72ebc43a176 100644 --- a/docs/ABI/Mangling.rst +++ b/docs/ABI/Mangling.rst @@ -925,6 +925,9 @@ mangled in to disambiguate. RESULT-CONVENTION ::= 'u' // unowned inner pointer RESULT-CONVENTION ::= 'a' // auto-released RESULT-CONVENTION ::= 'k' // pack + RESULT-CONVENTION ::= 'l' // guaranteed address + RESULT-CONVENTION ::= 'g' // guaranteed + RESULT-CONVENTION ::= 'm' // inout RESULT-DIFFERENTIABILITY ::= 'w' // @noDerivative diff --git a/include/swift/AST/TypeAttr.def b/include/swift/AST/TypeAttr.def index d03ad6ce013cb..eed13ab321f9c 100644 --- a/include/swift/AST/TypeAttr.def +++ b/include/swift/AST/TypeAttr.def @@ -95,7 +95,7 @@ SIMPLE_SIL_TYPE_ATTR(pack_out, PackOut) SIMPLE_SIL_TYPE_ATTR(owned, Owned) SIMPLE_SIL_TYPE_ATTR(unowned_inner_pointer, UnownedInnerPointer) SIMPLE_SIL_TYPE_ATTR(guaranteed, Guaranteed) -SIMPLE_SIL_TYPE_ATTR(guaranteed_addr, GuaranteedAddress) +SIMPLE_SIL_TYPE_ATTR(guaranteed_address, GuaranteedAddress) SIMPLE_SIL_TYPE_ATTR(autoreleased, Autoreleased) SIMPLE_SIL_TYPE_ATTR(callee_owned, CalleeOwned) SIMPLE_SIL_TYPE_ATTR(callee_guaranteed, CalleeGuaranteed) diff --git a/include/swift/AST/Types.h b/include/swift/AST/Types.h index 8d6496dfe8ca1..d3ebaa77a243d 100644 --- a/include/swift/AST/Types.h +++ b/include/swift/AST/Types.h @@ -4814,12 +4814,16 @@ enum class ResultConvention : uint8_t { Pack, /// The caller is responsible for using the returned address within a valid - /// scope. This is valid only for borrow and mutate accessors. + /// scope. This is valid only for borrow accessors. GuaranteedAddress, /// The caller is responsible for using the returned value within a valid /// scope. This is valid only for borrow accessors. Guaranteed, + + /// The caller is responsible for mutating the returned address within a valid + /// scope. This is valid only for mutate accessors. + Inout, }; // Does this result require indirect storage for the purpose of reabstraction? @@ -4976,12 +4980,20 @@ class SILResultInfo { return getConvention() == ResultConvention::Pack; } - bool isGuaranteedAddressResult() const { - return getConvention() == ResultConvention::GuaranteedAddress; + bool isAddressResult(bool loweredAddresses) const { + if (loweredAddresses) { + return getConvention() == ResultConvention::GuaranteedAddress || + getConvention() == ResultConvention::Inout; + } + return getConvention() == ResultConvention::Inout; } - bool isGuaranteedResult() const { - return getConvention() == ResultConvention::Guaranteed; + bool isGuaranteedResult(bool loweredAddresses) const { + if (loweredAddresses) { + return getConvention() == ResultConvention::Guaranteed; + } + return getConvention() == ResultConvention::Guaranteed || + getConvention() == ResultConvention::GuaranteedAddress; } /// Transform this SILResultInfo by applying the user-provided @@ -5424,18 +5436,18 @@ class SILFunctionType final return hasErrorResult() && getErrorResult().isFormalIndirect(); } - bool hasGuaranteedResult() const { + bool hasGuaranteedResult(bool loweredAddresses) const { if (getNumResults() != 1) { return false; } - return getResults()[0].isGuaranteedResult(); + return getResults()[0].isGuaranteedResult(loweredAddresses); } - bool hasGuaranteedAddressResult() const { + bool hasAddressResult(bool loweredAddresses) const { if (getNumResults() != 1) { return false; } - return getResults()[0].isGuaranteedAddressResult(); + return getResults()[0].isAddressResult(loweredAddresses); } struct IndirectFormalResultFilter { diff --git a/include/swift/SIL/MemAccessUtils.h b/include/swift/SIL/MemAccessUtils.h index bf7b48caf4e34..af07e77202653 100644 --- a/include/swift/SIL/MemAccessUtils.h +++ b/include/swift/SIL/MemAccessUtils.h @@ -169,7 +169,7 @@ inline bool isGuaranteedAddressReturn(SILValue value) { if (!defInst) { return false; } - return defInst->hasGuaranteedAddressResult(); + return defInst->hasAddressResult(); } /// Return the source address after stripping as many access projections as diff --git a/include/swift/SIL/SILBridging.h b/include/swift/SIL/SILBridging.h index 30edc786d7813..8061f08095802 100644 --- a/include/swift/SIL/SILBridging.h +++ b/include/swift/SIL/SILBridging.h @@ -110,6 +110,7 @@ enum class BridgedResultConvention { Pack, GuaranteedAddress, Guaranteed, + Inout }; struct BridgedResultInfo { diff --git a/include/swift/SIL/SILFunctionConventions.h b/include/swift/SIL/SILFunctionConventions.h index 4f5b8cf25c535..b80dfe77a061c 100644 --- a/include/swift/SIL/SILFunctionConventions.h +++ b/include/swift/SIL/SILFunctionConventions.h @@ -212,6 +212,13 @@ class SILFunctionConventions { if (silConv.loweredAddresses) return funcTy->getDirectFormalResultsType(silConv.getModule(), context); + if (funcTy->hasAddressResult(silConv.loweredAddresses)) { + assert(funcTy->getNumDirectFormalResults() == 1); + return SILType::getPrimitiveAddressType( + funcTy->getSingleDirectFormalResult().getReturnValueType( + silConv.getModule(), funcTy, context)); + } + return funcTy->getAllResultsSubstType(silConv.getModule(), context); } @@ -322,16 +329,24 @@ class SILFunctionConventions { if (funcTy->getNumResults() != 1) { return false; } - return funcTy->getResults()[0].getConvention() == - ResultConvention::Guaranteed; + auto resultConvention = funcTy->getResults()[0].getConvention(); + if (silConv.loweredAddresses) { + return resultConvention == ResultConvention::Guaranteed; + } + return resultConvention == ResultConvention::Guaranteed || + resultConvention == ResultConvention::GuaranteedAddress; } - bool hasGuaranteedAddressResult() const { + bool hasAddressResult() const { if (funcTy->getNumResults() != 1) { return false; } - return funcTy->getResults()[0].getConvention() == - ResultConvention::GuaranteedAddress; + auto resultConvention = funcTy->getResults()[0].getConvention(); + if (silConv.loweredAddresses) { + return resultConvention == ResultConvention::GuaranteedAddress || + resultConvention == ResultConvention::Inout; + } + return resultConvention == ResultConvention::Inout; } struct SILResultTypeFunc; @@ -675,6 +690,7 @@ inline bool SILModuleConventions::isIndirectSILResult(SILResultInfo result, case ResultConvention::Autoreleased: case ResultConvention::GuaranteedAddress: case ResultConvention::Guaranteed: + case ResultConvention::Inout: return false; } @@ -699,7 +715,7 @@ inline SILType SILModuleConventions::getSILResultInterfaceType(SILResultInfo result, bool loweredAddresses) { return SILModuleConventions::isIndirectSILResult(result, loweredAddresses) || - result.isGuaranteedAddressResult() + result.isAddressResult(loweredAddresses) ? SILType::getPrimitiveAddressType(result.getInterfaceType()) : SILType::getPrimitiveObjectType(result.getInterfaceType()); } diff --git a/include/swift/SIL/SILInstruction.h b/include/swift/SIL/SILInstruction.h index 8ba9aa578b2fc..29111df02451d 100644 --- a/include/swift/SIL/SILInstruction.h +++ b/include/swift/SIL/SILInstruction.h @@ -3154,8 +3154,9 @@ class ApplyInst final bool hasGuaranteedResult() const { return getSubstCalleeConv().hasGuaranteedResult(); } - bool hasGuaranteedAddressResult() const { - return getSubstCalleeConv().hasGuaranteedAddressResult(); + + bool hasAddressResult() const { + return getSubstCalleeConv().hasAddressResult(); } }; diff --git a/lib/AST/ASTMangler.cpp b/lib/AST/ASTMangler.cpp index 46482dec145af..22d966edde649 100644 --- a/lib/AST/ASTMangler.cpp +++ b/lib/AST/ASTMangler.cpp @@ -2288,10 +2288,12 @@ static char getResultConvention(ResultConvention conv) { case ResultConvention::Autoreleased: return 'a'; case ResultConvention::Pack: return 'k'; case ResultConvention::GuaranteedAddress: - return 'g'; + return 'l'; case ResultConvention::Guaranteed: - return 'G'; - } + return 'g'; + case ResultConvention::Inout: + return 'm'; + } llvm_unreachable("bad result convention"); } diff --git a/lib/AST/ASTPrinter.cpp b/lib/AST/ASTPrinter.cpp index 98c4db743f140..3f72179aeb292 100644 --- a/lib/AST/ASTPrinter.cpp +++ b/lib/AST/ASTPrinter.cpp @@ -7941,9 +7941,11 @@ static StringRef getStringForResultConvention(ResultConvention conv) { case ResultConvention::Autoreleased: return "@autoreleased "; case ResultConvention::Pack: return "@pack_out "; case ResultConvention::GuaranteedAddress: - return "@guaranteed_addr "; + return "@guaranteed_address "; case ResultConvention::Guaranteed: return "@guaranteed "; + case ResultConvention::Inout: + return "@inout "; } llvm_unreachable("bad result convention"); } diff --git a/lib/Demangling/Demangler.cpp b/lib/Demangling/Demangler.cpp index 71fa037467a07..d6e9eb3fb3116 100644 --- a/lib/Demangling/Demangler.cpp +++ b/lib/Demangling/Demangler.cpp @@ -2296,6 +2296,15 @@ NodePointer Demangler::demangleImplResultConvention(Node::Kind ConvKind) { case 'u': attr = "@unowned_inner_pointer"; break; case 'a': attr = "@autoreleased"; break; case 'k': attr = "@pack_out"; break; + case 'l': + attr = "@guaranteed_address"; + break; + case 'g': + attr = "@guaranteed"; + break; + case 'm': + attr = "@inout"; + break; default: pushBack(); return nullptr; diff --git a/lib/Demangling/Remangler.cpp b/lib/Demangling/Remangler.cpp index 56dc7a9138eec..902bbd1dd8fa7 100644 --- a/lib/Demangling/Remangler.cpp +++ b/lib/Demangling/Remangler.cpp @@ -2226,14 +2226,18 @@ ManglingError Remangler::mangleImplFunctionType(Node *node, unsigned depth) { Buffer << 'z'; LLVM_FALLTHROUGH; case Node::Kind::ImplResult: { - char ConvCh = llvm::StringSwitch(Child->getFirstChild()->getText()) - .Case("@out", 'r') - .Case("@owned", 'o') - .Case("@unowned", 'd') - .Case("@unowned_inner_pointer", 'u') - .Case("@autoreleased", 'a') - .Case("@pack_out", 'k') - .Default(0); + char ConvCh = + llvm::StringSwitch(Child->getFirstChild()->getText()) + .Case("@out", 'r') + .Case("@owned", 'o') + .Case("@unowned", 'd') + .Case("@unowned_inner_pointer", 'u') + .Case("@autoreleased", 'a') + .Case("@pack_out", 'k') + .Case("@guaranteed_address", 'l') + .Case("@guaranteed", 'g') + .Case("@inout", 'm') + .Default(0); if (!ConvCh) { return MANGLING_ERROR(ManglingError::InvalidImplParameterConvention, Child->getFirstChild()); diff --git a/lib/IRGen/CallEmission.h b/lib/IRGen/CallEmission.h index 0d98626fa5938..244c75a63bcf9 100644 --- a/lib/IRGen/CallEmission.h +++ b/lib/IRGen/CallEmission.h @@ -103,7 +103,7 @@ class CallEmission { virtual void emitCallToUnmappedExplosion(llvm::CallBase *call, Explosion &out) = 0; void emitYieldsToExplosion(Explosion &out); - void emitGuaranteedAddressToExplosion(Explosion &out); + void emitAddressResultToExplosion(Explosion &out); void setKeyPathAccessorArguments(Explosion &in, bool isOutlined, Explosion &out); virtual FunctionPointer getCalleeFunctionPointer() = 0; diff --git a/lib/IRGen/GenCall.cpp b/lib/IRGen/GenCall.cpp index 28dc06f0d962e..e2c6bdc616c27 100644 --- a/lib/IRGen/GenCall.cpp +++ b/lib/IRGen/GenCall.cpp @@ -592,9 +592,8 @@ namespace { /// function type. void expandCoroutineContinuationType(); - /// Initializes the result type for functions with @guaranteed_addr return - /// convention. - void expandGuaranteedAddressResult(); + /// Initializes the result type for borrow and mutate accessors. + void expandAddressResult(); // Expand the components for the async continuation entrypoint of the // function type (the function to be called on returning). @@ -699,8 +698,8 @@ void SignatureExpansion::expandResult( auto fnConv = getSILFuncConventions(); - if (fnConv.hasGuaranteedAddressResult()) { - return expandGuaranteedAddressResult(); + if (fnConv.hasAddressResult()) { + return expandAddressResult(); } // Disable the use of sret if we have multiple indirect results. @@ -920,7 +919,7 @@ void SignatureExpansion::expandCoroutineContinuationParameters() { } } -void SignatureExpansion::expandGuaranteedAddressResult() { +void SignatureExpansion::expandAddressResult() { CanUseSRet = false; ResultIRType = IGM.PtrTy; } @@ -3959,7 +3958,7 @@ void CallEmission::emitYieldsToExplosion(Explosion &out) { } } -void CallEmission::emitGuaranteedAddressToExplosion(Explosion &out) { +void CallEmission::emitAddressResultToExplosion(Explosion &out) { auto call = emitCallSite(); out.add(call); } @@ -3980,10 +3979,10 @@ void CallEmission::emitToExplosion(Explosion &out, bool isOutlined) { SILFunctionConventions fnConv(getCallee().getSubstFunctionType(), IGF.getSILModule()); - if (fnConv.hasGuaranteedAddressResult()) { + if (fnConv.hasAddressResult()) { assert(LastArgWritten == 0 && - "@guaranteed_addr along with indirect result?"); - emitGuaranteedAddressToExplosion(out); + "@guaranteed_address/@inout along with indirect result?"); + emitAddressResultToExplosion(out); return; } @@ -6832,9 +6831,9 @@ void irgen::emitYieldOnceCoroutineResult(IRGenFunction &IGF, Explosion &result, } } -void irgen::emitGuaranteedAddressResult(IRGenFunction &IGF, Explosion &result, - SILType funcResultType, - SILType returnResultType) { +void irgen::emitAddressResult(IRGenFunction &IGF, Explosion &result, + SILType funcResultType, + SILType returnResultType) { assert(funcResultType == returnResultType); assert(funcResultType.isAddress()); auto &Builder = IGF.Builder; diff --git a/lib/IRGen/GenCall.h b/lib/IRGen/GenCall.h index bd2336e02d6f4..690f199b8042b 100644 --- a/lib/IRGen/GenCall.h +++ b/lib/IRGen/GenCall.h @@ -278,9 +278,8 @@ namespace irgen { void emitYieldOnceCoroutineResult(IRGenFunction &IGF, Explosion &result, SILType funcResultType, SILType returnResultType); - void emitGuaranteedAddressResult(IRGenFunction &IGF, Explosion &result, - SILType funcResultType, - SILType returnResultType); + void emitAddressResult(IRGenFunction &IGF, Explosion &result, + SILType funcResultType, SILType returnResultType); Address emitAutoDiffCreateLinearMapContextWithType( IRGenFunction &IGF, llvm::Value *topLevelSubcontextMetatype); diff --git a/lib/IRGen/GenObjC.cpp b/lib/IRGen/GenObjC.cpp index 5693f54f9d98d..6696882d2c26b 100644 --- a/lib/IRGen/GenObjC.cpp +++ b/lib/IRGen/GenObjC.cpp @@ -937,6 +937,7 @@ static llvm::Function *emitObjCPartialApplicationForwarder(IRGenModule &IGM, case ResultConvention::Pack: case ResultConvention::GuaranteedAddress: case ResultConvention::Guaranteed: + case ResultConvention::Inout: lifetimeExtendsSelf = false; break; } diff --git a/lib/IRGen/IRGenSIL.cpp b/lib/IRGen/IRGenSIL.cpp index 1df7deabdddc4..2dff0464d5bf8 100644 --- a/lib/IRGen/IRGenSIL.cpp +++ b/lib/IRGen/IRGenSIL.cpp @@ -2037,7 +2037,7 @@ static ArrayRef emitEntryPointIndirectReturn( SILType directResultType = IGF.CurSILFn->mapTypeIntoContext( fnConv.getSILResultType(IGF.IGM.getMaximalTypeExpansionContext())); - if (fnConv.hasGuaranteedAddressResult()) { + if (fnConv.hasAddressResult()) { return entry->getArguments(); } @@ -3971,7 +3971,7 @@ void IRGenSILFunction::visitFullApplySite(FullApplySite site) { // For a simple apply, just bind the apply result to the result of the call. if (auto apply = dyn_cast(i)) { - if (apply->hasGuaranteedAddressResult()) { + if (apply->hasAddressResult()) { setCorrespondingLoweredValues(apply->getResults(), result); } else { setLoweredExplosion(apply, result); @@ -4492,13 +4492,13 @@ static void emitReturnInst(IRGenSILFunction &IGF, return; } - if (conv.hasGuaranteedAddressResult()) { + if (conv.hasAddressResult()) { assert(IGF.CurSILFn->getLoweredFunctionType()->getLanguage() == SILFunctionLanguage::Swift); auto funcResultType = IGF.CurSILFn->mapTypeIntoContext( conv.getSILResultType(IGF.IGM.getMaximalTypeExpansionContext())); - emitGuaranteedAddressResult(IGF, result, funcResultType, resultTy); + emitAddressResult(IGF, result, funcResultType, resultTy); return; } diff --git a/lib/SIL/IR/SILFunctionType.cpp b/lib/SIL/IR/SILFunctionType.cpp index 8d0e251ac758a..7bf39297ee23e 100644 --- a/lib/SIL/IR/SILFunctionType.cpp +++ b/lib/SIL/IR/SILFunctionType.cpp @@ -182,11 +182,12 @@ SILFunctionType::getDirectFormalResultsType(SILModule &M, TypeExpansionContext context) { CanType type; - if (hasGuaranteedAddressResult()) { + if (hasAddressResult(SILModuleConventions(M).useLoweredAddresses())) { assert(getNumDirectFormalResults() == 1); - return SILType::getPrimitiveAddressType( - getSingleDirectFormalResult().getReturnValueType(M, this, context)); + return SILType::getPrimitiveAddressType( + getSingleDirectFormalResult().getReturnValueType(M, this, context)); } + if (getNumDirectFormalResults() == 0) { type = getASTContext().TheEmptyTupleType; } else if (getNumDirectFormalResults() == 1) { @@ -729,6 +730,7 @@ static CanSILFunctionType getAutoDiffPullbackType( break; case ResultConvention::GuaranteedAddress: case ResultConvention::Guaranteed: + case ResultConvention::Inout: llvm_unreachable("borrow/mutate accessor not yet implemented"); } return conv; @@ -1079,7 +1081,8 @@ CanSILFunctionType SILFunctionType::getAutoDiffTransposeFunctionType( break; case ResultConvention::GuaranteedAddress: case ResultConvention::Guaranteed: - llvm_unreachable("borrow accessor is not yet implemented"); + case ResultConvention::Inout: + llvm_unreachable("borrow/mutate accessor is not yet implemented"); } return {result.getInterfaceType(), newConv}; }; @@ -1473,7 +1476,7 @@ class DestructureResults { convention = ResultConvention::Guaranteed; } } else if (isMutateAccessor(constant)) { - convention = ResultConvention::GuaranteedAddress; + convention = ResultConvention::Inout; } else if (isFormallyReturnedIndirectly(origType, substType, substResultTLForConvention)) { convention = ResultConvention::Indirect; @@ -1494,7 +1497,8 @@ class DestructureResults { case ResultConvention::GuaranteedAddress: llvm_unreachable( "Invalid case of ResultConvention::GuaranteedAddress"); - + case ResultConvention::Inout: + llvm_unreachable("Invalid case of ResultConvention::Inout"); case ResultConvention::Autoreleased: case ResultConvention::Owned: case ResultConvention::Guaranteed: diff --git a/lib/SIL/IR/SILType.cpp b/lib/SIL/IR/SILType.cpp index 64d02ccfb1792..134cd1f43b177 100644 --- a/lib/SIL/IR/SILType.cpp +++ b/lib/SIL/IR/SILType.cpp @@ -689,6 +689,10 @@ SILResultInfo::getOwnershipKind(SILFunction &F, return OwnershipKind::None; return OwnershipKind::Unowned; case ResultConvention::GuaranteedAddress: + return isAddressResult(SILModuleConventions(M).loweredAddresses) + ? OwnershipKind::None + : OwnershipKind::Guaranteed; + case ResultConvention::Inout: return OwnershipKind::None; case ResultConvention::Guaranteed: return OwnershipKind::Guaranteed; diff --git a/lib/SIL/IR/SILValue.cpp b/lib/SIL/IR/SILValue.cpp index 8b2231f828cb3..2b6c43ccf2713 100644 --- a/lib/SIL/IR/SILValue.cpp +++ b/lib/SIL/IR/SILValue.cpp @@ -210,7 +210,13 @@ bool ValueBase::isBorrowAccessorResult() const { auto *apply = dyn_cast_or_null(getDefiningInstruction()); if (!apply) return false; - return apply->hasGuaranteedResult() || apply->hasGuaranteedAddressResult(); + if (apply->getSubstCalleeConv().funcTy->getNumResults() != 1) { + return false; + } + auto resultConvention = + apply->getSubstCalleeConv().funcTy->getSingleResult().getConvention(); + return resultConvention == ResultConvention::Guaranteed || + resultConvention == ResultConvention::GuaranteedAddress; } bool ValueBase::hasDebugTrace() const { diff --git a/lib/SILGen/SILGenApply.cpp b/lib/SILGen/SILGenApply.cpp index a90f8747e2b11..8ffef12f8b3b4 100644 --- a/lib/SILGen/SILGenApply.cpp +++ b/lib/SILGen/SILGenApply.cpp @@ -6234,7 +6234,8 @@ RValue SILGenFunction::emitApply( break; case ResultConvention::GuaranteedAddress: case ResultConvention::Guaranteed: - llvm_unreachable("borrow accessor is not yet implemented"); + case ResultConvention::Inout: + llvm_unreachable("borrow/mutate accessor is not yet implemented"); break; } diff --git a/lib/SILGen/SILGenEpilog.cpp b/lib/SILGen/SILGenEpilog.cpp index e918235b74732..57579e1cc1bc5 100644 --- a/lib/SILGen/SILGenEpilog.cpp +++ b/lib/SILGen/SILGenEpilog.cpp @@ -33,7 +33,7 @@ void SILGenFunction::prepareEpilog( // emits unreachable if there is no source level return. NeedsReturn = !(*directResultType)->isEqual(TupleType::getEmpty(getASTContext())); if (NeedsReturn) { - if (fnConv.hasGuaranteedAddressResult() || fnConv.hasGuaranteedResult()) { + if (fnConv.hasAddressResult() || fnConv.hasGuaranteedResult()) { // Do not explode tuples for borrow/mutate accessors SILType resultType = F.getLoweredType(F.mapTypeIntoContext(*directResultType)); @@ -63,13 +63,7 @@ void SILGenFunction::prepareEpilog( worklist.push_back(ty.getTupleElementType(index)); } } else { - if (fnConv.hasGuaranteedResult()) { - epilogBB->createPhiArgument(ty, OwnershipKind::Guaranteed); - } else if (fnConv.hasGuaranteedAddressResult()) { - epilogBB->createPhiArgument(ty, OwnershipKind::None); - } else { - epilogBB->createPhiArgument(ty, OwnershipKind::Owned); - } + epilogBB->createPhiArgument(ty, OwnershipKind::Owned); } } } diff --git a/lib/SILGen/SILGenFunction.h b/lib/SILGen/SILGenFunction.h index 3a4122e364df4..0643672cd3f9e 100644 --- a/lib/SILGen/SILGenFunction.h +++ b/lib/SILGen/SILGenFunction.h @@ -2272,8 +2272,9 @@ class LLVM_LIBRARY_VISIBILITY SILGenFunction void emitReturnExpr(SILLocation loc, Expr *ret); - bool emitGuaranteedReturn(SILLocation loc, Expr *ret, - SmallVectorImpl &directResults); + bool + emitBorrowOrMutateAccessorResult(SILLocation loc, Expr *ret, + SmallVectorImpl &directResults); SILValue emitUncheckedGuaranteedConversion(SILValue value); diff --git a/lib/SILGen/SILGenPoly.cpp b/lib/SILGen/SILGenPoly.cpp index 9863738abd275..7fe0b80798676 100644 --- a/lib/SILGen/SILGenPoly.cpp +++ b/lib/SILGen/SILGenPoly.cpp @@ -5303,7 +5303,8 @@ void ResultPlanner::execute(SmallVectorImpl &innerDirectResultStack, return SGF.emitManagedCopy(Loc, resultValue, resultTL); case ResultConvention::GuaranteedAddress: case ResultConvention::Guaranteed: - llvm_unreachable("borrow accessor not yet implemented"); + case ResultConvention::Inout: + llvm_unreachable("borrow/mutate accessor is not yet implemented"); } llvm_unreachable("bad result convention!"); }; diff --git a/lib/SILGen/SILGenProlog.cpp b/lib/SILGen/SILGenProlog.cpp index d5590ca1cf557..ff89141e01512 100644 --- a/lib/SILGen/SILGenProlog.cpp +++ b/lib/SILGen/SILGenProlog.cpp @@ -735,7 +735,7 @@ class ArgumentInitHelper { (ScopedDependencies.contains(pd) && SGF.getTypeProperties(origType, substType) .isAddressableForDependencies()) || - SGF.getFunction().getConventions().hasGuaranteedAddressResult() || + SGF.getFunction().getConventions().hasAddressResult() || SGF.getFunction().getConventions().hasGuaranteedResult(); paramValue = argEmitter.handleParam(origType, substType, pd, isAddressable); diff --git a/lib/SILGen/SILGenStmt.cpp b/lib/SILGen/SILGenStmt.cpp index 0d9369469576a..7092b9ac91844 100644 --- a/lib/SILGen/SILGenStmt.cpp +++ b/lib/SILGen/SILGenStmt.cpp @@ -723,7 +723,7 @@ SILValue SILGenFunction::emitUncheckedGuaranteedConversion(SILValue value) { return result; } -bool SILGenFunction::emitGuaranteedReturn( +bool SILGenFunction::emitBorrowOrMutateAccessorResult( SILLocation loc, Expr *ret, SmallVectorImpl &directResults) { auto *afd = cast(FunctionDC->getAsDecl()); assert(cast(afd)->isBorrowAccessor() || @@ -869,7 +869,6 @@ bool SILGenFunction::emitGuaranteedReturn( void SILGenFunction::emitReturnExpr(SILLocation branchLoc, Expr *ret) { SmallVector directResults; - auto retTy = ret->getType()->getCanonicalType(); AbstractionPattern origRetTy = TypeContext @@ -895,8 +894,9 @@ void SILGenFunction::emitReturnExpr(SILLocation branchLoc, Cleanups.forwardCleanup(cleanup); } } else if (F.getConventions().hasGuaranteedResult() || - F.getConventions().hasGuaranteedAddressResult()) { - bool hasError = emitGuaranteedReturn(branchLoc, ret, directResults); + F.getConventions().hasAddressResult()) { + bool hasError = + emitBorrowOrMutateAccessorResult(branchLoc, ret, directResults); if (hasError) { return; } diff --git a/lib/SILOptimizer/Differentiation/VJPCloner.cpp b/lib/SILOptimizer/Differentiation/VJPCloner.cpp index f04389af3d9a4..5276b25d69b23 100644 --- a/lib/SILOptimizer/Differentiation/VJPCloner.cpp +++ b/lib/SILOptimizer/Differentiation/VJPCloner.cpp @@ -1155,7 +1155,8 @@ SILFunction *VJPCloner::Implementation::createEmptyPullback() { break; case ResultConvention::GuaranteedAddress: case ResultConvention::Guaranteed: - llvm_unreachable("borrow accessor is not yet implemented"); + case ResultConvention::Inout: + llvm_unreachable("borrow/mutate accessor is not yet implemented"); } return {tanType, conv}; }; diff --git a/lib/SILOptimizer/Mandatory/MoveOnlyAddressCheckerUtils.cpp b/lib/SILOptimizer/Mandatory/MoveOnlyAddressCheckerUtils.cpp index 34f5730d0b933..c3080a6e2195f 100644 --- a/lib/SILOptimizer/Mandatory/MoveOnlyAddressCheckerUtils.cpp +++ b/lib/SILOptimizer/Mandatory/MoveOnlyAddressCheckerUtils.cpp @@ -1115,7 +1115,7 @@ addressBeginsInitialized(MarkUnresolvedNonCopyableValueInst *address) { if (auto *applyInst = dyn_cast_or_null( stripAccessMarkers(operand)->getDefiningInstruction())) { - if (applyInst->hasGuaranteedAddressResult()) { + if (applyInst->hasAddressResult()) { LLVM_DEBUG(llvm::dbgs() << "Adding apply as init!\n"); return true; } diff --git a/lib/SILOptimizer/Transforms/GenericSpecializer.cpp b/lib/SILOptimizer/Transforms/GenericSpecializer.cpp index 6d87817717690..782ae108c4ba0 100644 --- a/lib/SILOptimizer/Transforms/GenericSpecializer.cpp +++ b/lib/SILOptimizer/Transforms/GenericSpecializer.cpp @@ -112,8 +112,7 @@ bool swift::specializeAppliesInFunction(SILFunction &F, // temporary stack location and returns a projection from the // store_borrow. This does not work for borrow accessors that return the // projection from within the store_borrow scope. - if (F.hasOwnership() && - Callee->getConventions().hasGuaranteedAddressResult()) { + if (F.hasOwnership() && Callee->getConventions().hasAddressResult()) { continue; } diff --git a/lib/Sema/TypeCheckType.cpp b/lib/Sema/TypeCheckType.cpp index 415f4b7ad7a0e..572148956e377 100644 --- a/lib/Sema/TypeCheckType.cpp +++ b/lib/Sema/TypeCheckType.cpp @@ -5010,6 +5010,7 @@ bool TypeResolver::resolveSingleSILResult( NORMAL(Owned, Owned) NORMAL(Guaranteed, Guaranteed) NORMAL(GuaranteedAddress, GuaranteedAddress) + NORMAL(Inout, Inout) NORMAL(UnownedInnerPointer, UnownedInnerPointer) NORMAL(Autoreleased, Autoreleased) NORMAL(PackOut, Pack) diff --git a/lib/Serialization/Deserialization.cpp b/lib/Serialization/Deserialization.cpp index 16cd55ff53e9e..96fc387e76c47 100644 --- a/lib/Serialization/Deserialization.cpp +++ b/lib/Serialization/Deserialization.cpp @@ -7076,6 +7076,7 @@ getActualResultConvention(uint8_t raw) { CASE(Pack) CASE(GuaranteedAddress) CASE(Guaranteed) + CASE(Inout) #undef CASE } return std::nullopt; diff --git a/lib/Serialization/ModuleFormat.h b/lib/Serialization/ModuleFormat.h index 3e6e56a70f7ed..b2d9408be5655 100644 --- a/lib/Serialization/ModuleFormat.h +++ b/lib/Serialization/ModuleFormat.h @@ -58,7 +58,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0; /// describe what change you made. The content of this comment isn't important; /// it just ensures a conflict if two people change the module format. /// Don't worry about adhering to the 80-column limit for this line. -const uint16_t SWIFTMODULE_VERSION_MINOR = 967; // implicitactor cast +const uint16_t SWIFTMODULE_VERSION_MINOR = 968; // @inout result convention /// A standard hash seed used for all string hashes in a serialized module. /// @@ -444,8 +444,9 @@ enum class ResultConvention : uint8_t { Pack, GuaranteedAddress, Guaranteed, + Inout }; -using ResultConventionField = BCFixed<3>; +using ResultConventionField = BCFixed<4>; /// These IDs must \em not be renumbered or reordered without incrementing the /// module version. diff --git a/lib/Serialization/Serialization.cpp b/lib/Serialization/Serialization.cpp index 66af04b806b08..0ccab47c9e0d7 100644 --- a/lib/Serialization/Serialization.cpp +++ b/lib/Serialization/Serialization.cpp @@ -5526,6 +5526,7 @@ static uint8_t getRawStableResultConvention(swift::ResultConvention rc) { SIMPLE_CASE(ResultConvention, Pack) SIMPLE_CASE(ResultConvention, GuaranteedAddress) SIMPLE_CASE(ResultConvention, Guaranteed) + SIMPLE_CASE(ResultConvention, Inout) } llvm_unreachable("bad result convention kind"); } diff --git a/test/SIL/OwnershipVerifier/borrow_accessor.sil b/test/SIL/OwnershipVerifier/borrow_accessor.sil index e6ac48f9daa17..7aab0c25969f9 100644 --- a/test/SIL/OwnershipVerifier/borrow_accessor.sil +++ b/test/SIL/OwnershipVerifier/borrow_accessor.sil @@ -19,7 +19,7 @@ bb0(%0 : @guaranteed $Wrapper): return %2 } -sil [ossa] @borrow_addressonly_prop : $@convention(method) (@in_guaranteed GenWrapper) -> @guaranteed_addr T { +sil [ossa] @borrow_addressonly_prop : $@convention(method) (@in_guaranteed GenWrapper) -> @guaranteed_address T { bb0(%0 : $*GenWrapper): %2 = struct_element_addr %0, #GenWrapper._prop return %2 @@ -154,8 +154,8 @@ bb0(%0 : @owned $Wrapper): // TODO: Add verification support in MemoryLifetimeVerifier sil [ossa] @test_use_after_free_address_only : $@convention(thin) (@in GenWrapper) -> () { bb0(%0 : $*GenWrapper): - %1 = function_ref @borrow_addressonly_prop : $@convention(method) <τ_0_0> (@in_guaranteed GenWrapper<τ_0_0>) -> @guaranteed_addr τ_0_0 - %2 = apply %1(%0) : $@convention(method) <τ_0_0> (@in_guaranteed GenWrapper<τ_0_0>) -> @guaranteed_addr τ_0_0 + %1 = function_ref @borrow_addressonly_prop : $@convention(method) <τ_0_0> (@in_guaranteed GenWrapper<τ_0_0>) -> @guaranteed_address τ_0_0 + %2 = apply %1(%0) : $@convention(method) <τ_0_0> (@in_guaranteed GenWrapper<τ_0_0>) -> @guaranteed_address τ_0_0 %3 = function_ref @use_T : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> () destroy_addr %0 %5 = apply %3(%2) : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> () diff --git a/test/SIL/Parser/borrow_accessor.sil b/test/SIL/Parser/borrow_accessor.sil index 44e1adb15286b..a3d6fb6610b0e 100644 --- a/test/SIL/Parser/borrow_accessor.sil +++ b/test/SIL/Parser/borrow_accessor.sil @@ -19,13 +19,27 @@ bb0(%0 : @guaranteed $Wrapper): return %2 } -// CHECK-LABEL: sil [ossa] @borrow_addressonly_prop : $@convention(method) (@in_guaranteed GenWrapper) -> @guaranteed_addr T { -sil [ossa] @borrow_addressonly_prop : $@convention(method) (@in_guaranteed GenWrapper) -> @guaranteed_addr T { +// CHECK-LABEL: sil [ossa] @borrow_addressonly_prop : $@convention(method) (@in_guaranteed GenWrapper) -> @guaranteed_address T { +sil [ossa] @borrow_addressonly_prop : $@convention(method) (@in_guaranteed GenWrapper) -> @guaranteed_address T { bb0(%0 : $*GenWrapper): %2 = struct_element_addr %0, #GenWrapper._prop return %2 } +// CHECK-LABEL: sil [ossa] @mutate_loadable_prop : $@convention(method) (@inout Wrapper) -> @inout Klass { +sil [ossa] @mutate_loadable_prop : $@convention(method) (@inout Wrapper) -> @inout Klass { +bb0(%0 : $*Wrapper): + %2 = struct_element_addr %0, #Wrapper._k + return %2 +} + +// CHECK-LABEL: sil [ossa] @mutate_addressonly_prop : $@convention(method) (@inout GenWrapper) -> @inout T { +sil [ossa] @mutate_addressonly_prop : $@convention(method) (@inout GenWrapper) -> @inout T { +bb0(%0 : $*GenWrapper): + %2 = struct_element_addr %0, #GenWrapper._prop + return %2 +} + sil @get_wrapper : $@convention(thin) () -> @owned Klass sil @use_klass : $@convention(thin) (@guaranteed Klass) -> () sil @use_T : $@convention(thin) (@in_guaranteed T) -> () @@ -47,8 +61,8 @@ bb0(%0 : @owned $Wrapper): sil [ossa] @test2 : $@convention(thin) (@in GenWrapper) -> () { bb0(%0 : $*GenWrapper): - %1 = function_ref @borrow_addressonly_prop : $@convention(method) <τ_0_0> (@in_guaranteed GenWrapper<τ_0_0>) -> @guaranteed_addr τ_0_0 - %2 = apply %1(%0) : $@convention(method) <τ_0_0> (@in_guaranteed GenWrapper<τ_0_0>) -> @guaranteed_addr τ_0_0 + %1 = function_ref @borrow_addressonly_prop : $@convention(method) <τ_0_0> (@in_guaranteed GenWrapper<τ_0_0>) -> @guaranteed_address τ_0_0 + %2 = apply %1(%0) : $@convention(method) <τ_0_0> (@in_guaranteed GenWrapper<τ_0_0>) -> @guaranteed_address τ_0_0 %3 = function_ref @use_T : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> () %4 = apply %3(%2) : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> () destroy_addr %0 diff --git a/test/SILGen/borrow_accessor.swift b/test/SILGen/borrow_accessor.swift index 99fbbd5d61bac..fa1bcbef98f7f 100644 --- a/test/SILGen/borrow_accessor.swift +++ b/test/SILGen/borrow_accessor.swift @@ -378,7 +378,7 @@ public struct GenNCWrapper : ~Copyable { // CHECK: return [[REG2]] // CHECK: } -// CHECK: sil hidden [ossa] @$s15borrow_accessor7WrapperV1sAA1SVvz : $@convention(method) (@inout Wrapper) -> @guaranteed_addr S { +// CHECK: sil hidden [ossa] @$s15borrow_accessor7WrapperV1sAA1SVvz : $@convention(method) (@inout Wrapper) -> @inout S { // CHECK:bb0([[REG0:%.*]] : $*Wrapper): // CHECK: debug_value [[REG0]], var, name "self", argno 1, expr op_deref // CHECK: [[REG2:%.*]] = struct_element_addr [[REG0]], #Wrapper._s @@ -392,7 +392,7 @@ public struct GenNCWrapper : ~Copyable { // CHECK: return [[REG2]] // CHECK: } -// CHECK: sil hidden [ossa] @$s15borrow_accessor7WrapperV1kAA5KlassCvz : $@convention(method) (@inout Wrapper) -> @guaranteed_addr Klass { +// CHECK: sil hidden [ossa] @$s15borrow_accessor7WrapperV1kAA5KlassCvz : $@convention(method) (@inout Wrapper) -> @inout Klass { // CHECK:bb0([[REG0:%.*]] : $*Wrapper): // CHECK: debug_value [[REG0]], var, name "self", argno 1, expr op_deref // CHECK: [[REG2:%.*]] = struct_element_addr [[REG0]], #Wrapper._k @@ -408,11 +408,11 @@ public struct GenNCWrapper : ~Copyable { // CHECK: return [[REG4]] // CHECK: } -// CHECK: sil hidden [ossa] @$s15borrow_accessor7WrapperV14nested_borrow1AA5KlassCvz : $@convention(method) (@inout Wrapper) -> @guaranteed_addr Klass { +// CHECK: sil hidden [ossa] @$s15borrow_accessor7WrapperV14nested_borrow1AA5KlassCvz : $@convention(method) (@inout Wrapper) -> @inout Klass { // CHECK:bb0([[REG0:%.*]] : $*Wrapper): // CHECK: debug_value [[REG0]], var, name "self", argno 1, expr op_deref -// CHECK: [[REG2:%.*]] = function_ref @$s15borrow_accessor7WrapperV1sAA1SVvz : $@convention(method) (@inout Wrapper) -> @guaranteed_addr S -// CHECK: [[REG3:%.*]] = apply [[REG2]]([[REG0]]) : $@convention(method) (@inout Wrapper) -> @guaranteed_addr S +// CHECK: [[REG2:%.*]] = function_ref @$s15borrow_accessor7WrapperV1sAA1SVvz : $@convention(method) (@inout Wrapper) -> @inout S +// CHECK: [[REG3:%.*]] = apply [[REG2]]([[REG0]]) : $@convention(method) (@inout Wrapper) -> @inout S // CHECK: [[REG4:%.*]] = struct_element_addr [[REG3]], #S._k // CHECK: return [[REG4]] // CHECK: } @@ -425,7 +425,7 @@ public struct GenNCWrapper : ~Copyable { // CHECK: return [[REG3]] // CHECK: } -// CHECK: sil hidden [ossa] @$s15borrow_accessor7WrapperV14nested_borrow2AA5KlassCvz : $@convention(method) (@inout Wrapper) -> @guaranteed_addr Klass { +// CHECK: sil hidden [ossa] @$s15borrow_accessor7WrapperV14nested_borrow2AA5KlassCvz : $@convention(method) (@inout Wrapper) -> @inout Klass { // CHECK:bb0([[REG0:%.*]] : $*Wrapper): // CHECK: debug_value [[REG0]], var, name "self", argno 1, expr op_deref // CHECK: [[REG2:%.*]] = struct_element_addr [[REG0]], #Wrapper._k @@ -440,7 +440,7 @@ public struct GenNCWrapper : ~Copyable { // CHECK: return [[REG4]] // CHECK: } -// CHECK: sil hidden [ossa] @$s15borrow_accessor7WrapperVyAA5KlassCSiciz : $@convention(method) (Int, @inout Wrapper) -> @guaranteed_addr Klass { +// CHECK: sil hidden [ossa] @$s15borrow_accessor7WrapperVyAA5KlassCSiciz : $@convention(method) (Int, @inout Wrapper) -> @inout Klass { // CHECK:bb0([[REG0:%.*]] : $Int, [[REG1:%.*]] : $*Wrapper): // CHECK: debug_value [[REG0]], let, name "index", argno 1 // CHECK: debug_value [[REG1]], var, name "self", argno 2, expr op_deref @@ -460,26 +460,26 @@ public struct GenNCWrapper : ~Copyable { // CHECK: return [[REG7]] // CHECK: } -// CHECK: sil hidden [ossa] @$s15borrow_accessor7WrapperV16nested_subscriptAA5KlassCvz : $@convention(method) (@inout Wrapper) -> @guaranteed_addr Klass { +// CHECK: sil hidden [ossa] @$s15borrow_accessor7WrapperV16nested_subscriptAA5KlassCvz : $@convention(method) (@inout Wrapper) -> @inout Klass { // CHECK:bb0([[REG0:%.*]] : $*Wrapper): // CHECK: debug_value [[REG0]], var, name "self", argno 1, expr op_deref // CHECK: [[REG2:%.*]] = integer_literal $Builtin.IntLiteral, 0 // CHECK: [[REG3:%.*]] = metatype $@thin Int.Type // CHECK: [[REG4:%.*]] = function_ref @$sSi22_builtinIntegerLiteralSiBI_tcfC : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int // CHECK: [[REG5:%.*]] = apply [[REG4]]([[REG2]], [[REG3]]) : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int -// CHECK: [[REG6:%.*]] = function_ref @$s15borrow_accessor7WrapperVyAA5KlassCSiciz : $@convention(method) (Int, @inout Wrapper) -> @guaranteed_addr Klass -// CHECK: [[REG7:%.*]] = apply [[REG6]]([[REG5]], [[REG0]]) : $@convention(method) (Int, @inout Wrapper) -> @guaranteed_addr Klass +// CHECK: [[REG6:%.*]] = function_ref @$s15borrow_accessor7WrapperVyAA5KlassCSiciz : $@convention(method) (Int, @inout Wrapper) -> @inout Klass +// CHECK: [[REG7:%.*]] = apply [[REG6]]([[REG5]], [[REG0]]) : $@convention(method) (Int, @inout Wrapper) -> @inout Klass // CHECK: return [[REG7]] // CHECK: } -// CHECK: sil [ossa] @$s15borrow_accessor10GenWrapperV4propxvb : $@convention(method) (@in_guaranteed GenWrapper) -> @guaranteed_addr T { +// CHECK: sil [ossa] @$s15borrow_accessor10GenWrapperV4propxvb : $@convention(method) (@in_guaranteed GenWrapper) -> @guaranteed_address T { // CHECK: bb0([[REG0:%.*]] : $*GenWrapper): // CHECK: debug_value [[REG0]], let, name "self", argno 1, expr op_deref // CHECK: [[REG2:%.*]] = struct_element_addr [[REG0]], #GenWrapper._prop // CHECK: return [[REG2]] // CHECK: } -// CHECK: sil [ossa] @$s15borrow_accessor10GenWrapperV4propxvz : $@convention(method) (@inout GenWrapper) -> @guaranteed_addr T { +// CHECK: sil [ossa] @$s15borrow_accessor10GenWrapperV4propxvz : $@convention(method) (@inout GenWrapper) -> @inout T { // CHECK:bb0([[REG0:%.*]] : $*GenWrapper): // CHECK: debug_value [[REG0]], var, name "self", argno 1, expr op_deref // CHECK: [[REG2:%.*]] = struct_element_addr [[REG0]], #GenWrapper._prop @@ -497,7 +497,7 @@ public struct GenNCWrapper : ~Copyable { // CHECK: return [[REG5]] // CHECK: } -// CHECK: sil hidden [ossa] @$s15borrow_accessor10GenWrapperV1sAA1SVvz : $@convention(method) (@inout GenWrapper) -> @guaranteed_addr S { +// CHECK: sil hidden [ossa] @$s15borrow_accessor10GenWrapperV1sAA1SVvz : $@convention(method) (@inout GenWrapper) -> @inout S { // CHECK:bb0([[REG0:%.*]] : $*GenWrapper): // CHECK: debug_value [[REG0]], var, name "self", argno 1, expr op_deref // CHECK: [[REG2:%.*]] = struct_element_addr [[REG0]], #GenWrapper._s @@ -515,36 +515,36 @@ public struct GenNCWrapper : ~Copyable { // CHECK: return [[REG5]] // CHECK: } -// CHECK: sil hidden [ossa] @$s15borrow_accessor10GenWrapperV1kAA5KlassCvz : $@convention(method) (@inout GenWrapper) -> @guaranteed_addr Klass { +// CHECK: sil hidden [ossa] @$s15borrow_accessor10GenWrapperV1kAA5KlassCvz : $@convention(method) (@inout GenWrapper) -> @inout Klass { // CHECK:bb0([[REG0:%.*]] : $*GenWrapper): // CHECK: debug_value [[REG0]], var, name "self", argno 1, expr op_deref // CHECK: [[REG2:%.*]] = struct_element_addr [[REG0]], #GenWrapper._k // CHECK: return [[REG2]] // CHECK: } -// CHECK: sil hidden [ossa] @$s15borrow_accessor10GenWrapperV12nested_prop1xvb : $@convention(method) (@in_guaranteed GenWrapper) -> @guaranteed_addr T { +// CHECK: sil hidden [ossa] @$s15borrow_accessor10GenWrapperV12nested_prop1xvb : $@convention(method) (@in_guaranteed GenWrapper) -> @guaranteed_address T { // CHECK: bb0([[REG0:%.*]] : $*GenWrapper): // CHECK: debug_value [[REG0]], let, name "self", argno 1, expr op_deref // CHECK: [[REG2:%.*]] = struct_element_addr [[REG0]], #GenWrapper._w -// CHECK: [[REG3:%.*]] = function_ref @$s15borrow_accessor13SimpleWrapperV4propxvb : $@convention(method) <τ_0_0> (@in_guaranteed SimpleWrapper<τ_0_0>) -> @guaranteed_addr τ_0_0 -// CHECK: [[REG4:%.*]] = apply [[REG3]]([[REG2]]) : $@convention(method) <τ_0_0> (@in_guaranteed SimpleWrapper<τ_0_0>) -> @guaranteed_addr τ_0_0 +// CHECK: [[REG3:%.*]] = function_ref @$s15borrow_accessor13SimpleWrapperV4propxvb : $@convention(method) <τ_0_0> (@in_guaranteed SimpleWrapper<τ_0_0>) -> @guaranteed_address τ_0_0 +// CHECK: [[REG4:%.*]] = apply [[REG3]]([[REG2]]) : $@convention(method) <τ_0_0> (@in_guaranteed SimpleWrapper<τ_0_0>) -> @guaranteed_address τ_0_0 // CHECK: return [[REG4]] // CHECK: } -// CHECK: sil hidden [ossa] @$s15borrow_accessor10GenWrapperV12nested_prop1xvz : $@convention(method) (@inout GenWrapper) -> @guaranteed_addr T { +// CHECK: sil hidden [ossa] @$s15borrow_accessor10GenWrapperV12nested_prop1xvz : $@convention(method) (@inout GenWrapper) -> @inout T { // CHECK:bb0([[REG0:%.*]] : $*GenWrapper): // CHECK: debug_value [[REG0]], var, name "self", argno 1, expr op_deref // CHECK: [[REG2:%.*]] = struct_element_addr [[REG0]], #GenWrapper._w -// CHECK: [[REG3:%.*]] = function_ref @$s15borrow_accessor13SimpleWrapperV4propxvz : $@convention(method) <τ_0_0> (@inout SimpleWrapper<τ_0_0>) -> @guaranteed_addr τ_0_0 -// CHECK: [[REG4:%.*]] = apply [[REG3]]([[REG2]]) : $@convention(method) <τ_0_0> (@inout SimpleWrapper<τ_0_0>) -> @guaranteed_addr τ_0_0 +// CHECK: [[REG3:%.*]] = function_ref @$s15borrow_accessor13SimpleWrapperV4propxvz : $@convention(method) <τ_0_0> (@inout SimpleWrapper<τ_0_0>) -> @inout τ_0_0 +// CHECK: [[REG4:%.*]] = apply [[REG3]]([[REG2]]) : $@convention(method) <τ_0_0> (@inout SimpleWrapper<τ_0_0>) -> @inout τ_0_0 // CHECK: return [[REG4]] // CHECK: } -// CHECK: sil hidden [ossa] @$s15borrow_accessor10GenWrapperV12nested_prop2xvb : $@convention(method) (@in_guaranteed GenWrapper) -> @guaranteed_addr T { +// CHECK: sil hidden [ossa] @$s15borrow_accessor10GenWrapperV12nested_prop2xvb : $@convention(method) (@in_guaranteed GenWrapper) -> @guaranteed_address T { // CHECK: bb0([[REG0:%.*]] : $*GenWrapper): // CHECK: debug_value [[REG0]], let, name "self", argno 1, expr op_deref -// CHECK: [[REG2:%.*]] = function_ref @$s15borrow_accessor10GenWrapperV4propxvb : $@convention(method) <τ_0_0> (@in_guaranteed GenWrapper<τ_0_0>) -> @guaranteed_addr τ_0_0 -// CHECK: [[REG3:%.*]] = apply [[REG2]]([[REG0]]) : $@convention(method) <τ_0_0> (@in_guaranteed GenWrapper<τ_0_0>) -> @guaranteed_addr τ_0_0 +// CHECK: [[REG2:%.*]] = function_ref @$s15borrow_accessor10GenWrapperV4propxvb : $@convention(method) <τ_0_0> (@in_guaranteed GenWrapper<τ_0_0>) -> @guaranteed_address τ_0_0 +// CHECK: [[REG3:%.*]] = apply [[REG2]]([[REG0]]) : $@convention(method) <τ_0_0> (@in_guaranteed GenWrapper<τ_0_0>) -> @guaranteed_address τ_0_0 // CHECK: return [[REG3]] // CHECK: } @@ -561,12 +561,12 @@ public struct GenNCWrapper : ~Copyable { // CHECK: return [[REG7]] // CHECK: } -// CHECK: sil hidden [ossa] @$s15borrow_accessor10GenWrapperV9nested_k1AA5KlassCvz : $@convention(method) (@inout GenWrapper) -> @guaranteed_addr Klass { +// CHECK: sil hidden [ossa] @$s15borrow_accessor10GenWrapperV9nested_k1AA5KlassCvz : $@convention(method) (@inout GenWrapper) -> @inout Klass { // CHECK:bb0([[REG0:%.*]] : $*GenWrapper): // CHECK: debug_value [[REG0]], var, name "self", argno 1, expr op_deref // CHECK: [[REG2:%.*]] = struct_element_addr [[REG0]], #GenWrapper._s -// CHECK: [[REG3:%.*]] = function_ref @$s15borrow_accessor1SV1kAA5KlassCvz : $@convention(method) (@inout S) -> @guaranteed_addr Klass -// CHECK: [[REG4:%.*]] = apply [[REG3]]([[REG2]]) : $@convention(method) (@inout S) -> @guaranteed_addr Klass +// CHECK: [[REG3:%.*]] = function_ref @$s15borrow_accessor1SV1kAA5KlassCvz : $@convention(method) (@inout S) -> @inout Klass +// CHECK: [[REG4:%.*]] = apply [[REG3]]([[REG2]]) : $@convention(method) (@inout S) -> @inout Klass // CHECK: return [[REG4]] // CHECK: } @@ -580,17 +580,17 @@ public struct GenNCWrapper : ~Copyable { // CHECK: return [[REG5]] // CHECK: } -// CHECK: sil hidden [ossa] @$s15borrow_accessor10GenWrapperV9nested_k2AA5KlassCvz : $@convention(method) (@inout GenWrapper) -> @guaranteed_addr Klass { +// CHECK: sil hidden [ossa] @$s15borrow_accessor10GenWrapperV9nested_k2AA5KlassCvz : $@convention(method) (@inout GenWrapper) -> @inout Klass { // CHECK:bb0([[REG0:%.*]] : $*GenWrapper): // CHECK: debug_value [[REG0]], var, name "self", argno 1, expr op_deref -// CHECK: [[REG2:%.*]] = function_ref @$s15borrow_accessor10GenWrapperV1sAA1SVvz : $@convention(method) <τ_0_0> (@inout GenWrapper<τ_0_0>) -> @guaranteed_addr S -// CHECK: [[REG3:%.*]] = apply [[REG2]]([[REG0]]) : $@convention(method) <τ_0_0> (@inout GenWrapper<τ_0_0>) -> @guaranteed_addr S -// CHECK: [[REG4:%.*]] = function_ref @$s15borrow_accessor1SV1kAA5KlassCvz : $@convention(method) (@inout S) -> @guaranteed_addr Klass -// CHECK: [[REG5:%.*]] = apply [[REG4]]([[REG3]]) : $@convention(method) (@inout S) -> @guaranteed_addr Klass +// CHECK: [[REG2:%.*]] = function_ref @$s15borrow_accessor10GenWrapperV1sAA1SVvz : $@convention(method) <τ_0_0> (@inout GenWrapper<τ_0_0>) -> @inout S +// CHECK: [[REG3:%.*]] = apply [[REG2]]([[REG0]]) : $@convention(method) <τ_0_0> (@inout GenWrapper<τ_0_0>) -> @inout S +// CHECK: [[REG4:%.*]] = function_ref @$s15borrow_accessor1SV1kAA5KlassCvz : $@convention(method) (@inout S) -> @inout Klass +// CHECK: [[REG5:%.*]] = apply [[REG4]]([[REG3]]) : $@convention(method) (@inout S) -> @inout Klass // CHECK: return [[REG5]] // CHECK: } -// CHECK: sil hidden [ossa] @$s15borrow_accessor10GenWrapperVyxSicib : $@convention(method) (Int, @in_guaranteed GenWrapper) -> @guaranteed_addr T { +// CHECK: sil hidden [ossa] @$s15borrow_accessor10GenWrapperVyxSicib : $@convention(method) (Int, @in_guaranteed GenWrapper) -> @guaranteed_address T { // CHECK: bb0([[REG0:%.*]] : $Int, [[REG1:%.*]] : $*GenWrapper): // CHECK: debug_value [[REG0]], let, name "index", argno 1 // CHECK: debug_value [[REG1]], let, name "self", argno 2, expr op_deref @@ -598,7 +598,7 @@ public struct GenNCWrapper : ~Copyable { // CHECK: return [[REG4]] // CHECK: } -// CHECK: sil hidden [ossa] @$s15borrow_accessor10GenWrapperVyxSiciz : $@convention(method) (Int, @inout GenWrapper) -> @guaranteed_addr T { +// CHECK: sil hidden [ossa] @$s15borrow_accessor10GenWrapperVyxSiciz : $@convention(method) (Int, @inout GenWrapper) -> @inout T { // CHECK:bb0([[REG0:%.*]] : $Int, [[REG1:%.*]] : $*GenWrapper): // CHECK: debug_value [[REG0]], let, name "index", argno 1 // CHECK: debug_value [[REG1]], var, name "self", argno 2, expr op_deref @@ -606,31 +606,31 @@ public struct GenNCWrapper : ~Copyable { // CHECK: return [[REG4]] // CHECK: } -// CHECK: sil hidden [ossa] @$s15borrow_accessor10GenWrapperV16nested_subscriptxvb : $@convention(method) (@in_guaranteed GenWrapper) -> @guaranteed_addr T { +// CHECK: sil hidden [ossa] @$s15borrow_accessor10GenWrapperV16nested_subscriptxvb : $@convention(method) (@in_guaranteed GenWrapper) -> @guaranteed_address T { // CHECK: bb0([[REG0:%.*]] : $*GenWrapper): // CHECK: debug_value [[REG0]], let, name "self", argno 1, expr op_deref // CHECK: [[REG2:%.*]] = integer_literal $Builtin.IntLiteral, 0 // CHECK: [[REG3:%.*]] = metatype $@thin Int.Type // CHECK: [[REG4:%.*]] = function_ref @$sSi22_builtinIntegerLiteralSiBI_tcfC : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int // CHECK: [[REG5:%.*]] = apply [[REG4]]([[REG2]], [[REG3]]) : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int -// CHECK: [[REG6:%.*]] = function_ref @$s15borrow_accessor10GenWrapperVyxSicib : $@convention(method) <τ_0_0> (Int, @in_guaranteed GenWrapper<τ_0_0>) -> @guaranteed_addr τ_0_0 -// CHECK: [[REG7:%.*]] = apply [[REG6]]([[REG5]], [[REG0]]) : $@convention(method) <τ_0_0> (Int, @in_guaranteed GenWrapper<τ_0_0>) -> @guaranteed_addr τ_0_0 +// CHECK: [[REG6:%.*]] = function_ref @$s15borrow_accessor10GenWrapperVyxSicib : $@convention(method) <τ_0_0> (Int, @in_guaranteed GenWrapper<τ_0_0>) -> @guaranteed_address τ_0_0 +// CHECK: [[REG7:%.*]] = apply [[REG6]]([[REG5]], [[REG0]]) : $@convention(method) <τ_0_0> (Int, @in_guaranteed GenWrapper<τ_0_0>) -> @guaranteed_address τ_0_0 // CHECK: return [[REG7]] // CHECK: } -// CHECK: sil hidden [ossa] @$s15borrow_accessor10GenWrapperV16nested_subscriptxvz : $@convention(method) (@inout GenWrapper) -> @guaranteed_addr T { +// CHECK: sil hidden [ossa] @$s15borrow_accessor10GenWrapperV16nested_subscriptxvz : $@convention(method) (@inout GenWrapper) -> @inout T { // CHECK:bb0([[REG0:%.*]] : $*GenWrapper): // CHECK: debug_value [[REG0]], var, name "self", argno 1, expr op_deref // CHECK: [[REG2:%.*]] = integer_literal $Builtin.IntLiteral, 0 // CHECK: [[REG3:%.*]] = metatype $@thin Int.Type // CHECK: [[REG4:%.*]] = function_ref @$sSi22_builtinIntegerLiteralSiBI_tcfC : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int // CHECK: [[REG5:%.*]] = apply [[REG4]]([[REG2]], [[REG3]]) : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int -// CHECK: [[REG6:%.*]] = function_ref @$s15borrow_accessor10GenWrapperVyxSiciz : $@convention(method) <τ_0_0> (Int, @inout GenWrapper<τ_0_0>) -> @guaranteed_addr τ_0_0 -// CHECK: [[REG7:%.*]] = apply [[REG6]]([[REG5]], [[REG0]]) : $@convention(method) <τ_0_0> (Int, @inout GenWrapper<τ_0_0>) -> @guaranteed_addr τ_0_0 +// CHECK: [[REG6:%.*]] = function_ref @$s15borrow_accessor10GenWrapperVyxSiciz : $@convention(method) <τ_0_0> (Int, @inout GenWrapper<τ_0_0>) -> @inout τ_0_0 +// CHECK: [[REG7:%.*]] = apply [[REG6]]([[REG5]], [[REG0]]) : $@convention(method) <τ_0_0> (Int, @inout GenWrapper<τ_0_0>) -> @inout τ_0_0 // CHECK: return [[REG7]] // CHECK: } -// CHECK: sil [ossa] @$s15borrow_accessor12GenNCWrapperVAARi_zrlE4propxvb : $@convention(method) (@in_guaranteed GenNCWrapper) -> @guaranteed_addr T { +// CHECK: sil [ossa] @$s15borrow_accessor12GenNCWrapperVAARi_zrlE4propxvb : $@convention(method) (@in_guaranteed GenNCWrapper) -> @guaranteed_address T { // CHECK: bb0([[REG0:%.*]] : $*GenNCWrapper): // CHECK: debug_value [[REG0]], let, name "self", argno 1, expr op_deref // CHECK: [[REG2:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG0]] @@ -638,7 +638,7 @@ public struct GenNCWrapper : ~Copyable { // CHECK: return [[REG3]] // CHECK: } -// CHECK: sil [ossa] @$s15borrow_accessor12GenNCWrapperVAARi_zrlE4propxvz : $@convention(method) (@inout GenNCWrapper) -> @guaranteed_addr T { +// CHECK: sil [ossa] @$s15borrow_accessor12GenNCWrapperVAARi_zrlE4propxvz : $@convention(method) (@inout GenNCWrapper) -> @inout T { // CHECK:bb0([[REG0:%.*]] : $*GenNCWrapper): // CHECK: debug_value [[REG0]], var, name "self", argno 1, expr op_deref // CHECK: [[REG2:%.*]] = mark_unresolved_non_copyable_value [consumable_and_assignable] [[REG0]] @@ -658,7 +658,7 @@ public struct GenNCWrapper : ~Copyable { // CHECK: return [[REG6]] // CHECK: } -// CHECK: sil hidden [ossa] @$s15borrow_accessor12GenNCWrapperVAARi_zrlE2ncAA2NCVvz : $@convention(method) (@inout GenNCWrapper) -> @guaranteed_addr NC { +// CHECK: sil hidden [ossa] @$s15borrow_accessor12GenNCWrapperVAARi_zrlE2ncAA2NCVvz : $@convention(method) (@inout GenNCWrapper) -> @inout NC { // CHECK:bb0([[REG0:%.*]] : $*GenNCWrapper): // CHECK: debug_value [[REG0]], var, name "self", argno 1, expr op_deref // CHECK: [[REG2:%.*]] = mark_unresolved_non_copyable_value [consumable_and_assignable] [[REG0]] @@ -678,7 +678,7 @@ public struct GenNCWrapper : ~Copyable { // CHECK: return [[REG6]] // CHECK: } -// CHECK: sil hidden [ossa] @$s15borrow_accessor12GenNCWrapperVAARi_zrlE3ncwAA0D0Vvz : $@convention(method) (@inout GenNCWrapper) -> @guaranteed_addr NCWrapper { +// CHECK: sil hidden [ossa] @$s15borrow_accessor12GenNCWrapperVAARi_zrlE3ncwAA0D0Vvz : $@convention(method) (@inout GenNCWrapper) -> @inout NCWrapper { // CHECK:bb0([[REG0:%.*]] : $*GenNCWrapper): // CHECK: debug_value [[REG0]], var, name "self", argno 1, expr op_deref // CHECK: [[REG2:%.*]] = mark_unresolved_non_copyable_value [consumable_and_assignable] [[REG0]] @@ -686,44 +686,44 @@ public struct GenNCWrapper : ~Copyable { // CHECK: return [[REG3]] // CHECK: } -// CHECK: sil hidden [ossa] @$s15borrow_accessor12GenNCWrapperVAARi_zrlE12nested_prop1xvb : $@convention(method) (@in_guaranteed GenNCWrapper) -> @guaranteed_addr T { +// CHECK: sil hidden [ossa] @$s15borrow_accessor12GenNCWrapperVAARi_zrlE12nested_prop1xvb : $@convention(method) (@in_guaranteed GenNCWrapper) -> @guaranteed_address T { // CHECK: bb0([[REG0:%.*]] : $*GenNCWrapper): // CHECK: debug_value [[REG0]], let, name "self", argno 1, expr op_deref // CHECK: [[REG2:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG0]] // CHECK: [[REG3:%.*]] = struct_element_addr [[REG2]], #GenNCWrapper._w -// CHECK: [[REG4:%.*]] = function_ref @$s15borrow_accessor15SimpleNCWrapperVAARi_zrlE4propxvb : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (@in_guaranteed SimpleNCWrapper<τ_0_0>) -> @guaranteed_addr τ_0_0 -// CHECK: [[REG5:%.*]] = apply [[REG4]]([[REG3]]) : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (@in_guaranteed SimpleNCWrapper<τ_0_0>) -> @guaranteed_addr τ_0_0 +// CHECK: [[REG4:%.*]] = function_ref @$s15borrow_accessor15SimpleNCWrapperVAARi_zrlE4propxvb : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (@in_guaranteed SimpleNCWrapper<τ_0_0>) -> @guaranteed_address τ_0_0 +// CHECK: [[REG5:%.*]] = apply [[REG4]]([[REG3]]) : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (@in_guaranteed SimpleNCWrapper<τ_0_0>) -> @guaranteed_address τ_0_0 // CHECK: [[REG6:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG5]] // CHECK: return [[REG6]] // CHECK: } -// CHECK: sil hidden [ossa] @$s15borrow_accessor12GenNCWrapperVAARi_zrlE12nested_prop1xvz : $@convention(method) (@inout GenNCWrapper) -> @guaranteed_addr T { +// CHECK: sil hidden [ossa] @$s15borrow_accessor12GenNCWrapperVAARi_zrlE12nested_prop1xvz : $@convention(method) (@inout GenNCWrapper) -> @inout T { // CHECK:bb0([[REG0:%.*]] : $*GenNCWrapper): // CHECK: debug_value [[REG0]], var, name "self", argno 1, expr op_deref // CHECK: [[REG2:%.*]] = mark_unresolved_non_copyable_value [consumable_and_assignable] [[REG0]] // CHECK: [[REG3:%.*]] = struct_element_addr [[REG2]], #GenNCWrapper._w -// CHECK: [[REG4:%.*]] = function_ref @$s15borrow_accessor15SimpleNCWrapperVAARi_zrlE4propxvz : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (@inout SimpleNCWrapper<τ_0_0>) -> @guaranteed_addr τ_0_0 -// CHECK: [[REG5:%.*]] = apply [[REG4]]([[REG3]]) : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (@inout SimpleNCWrapper<τ_0_0>) -> @guaranteed_addr τ_0_0 +// CHECK: [[REG4:%.*]] = function_ref @$s15borrow_accessor15SimpleNCWrapperVAARi_zrlE4propxvz : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (@inout SimpleNCWrapper<τ_0_0>) -> @inout τ_0_0 +// CHECK: [[REG5:%.*]] = apply [[REG4]]([[REG3]]) : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (@inout SimpleNCWrapper<τ_0_0>) -> @inout τ_0_0 // CHECK: [[REG6:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG5]] // CHECK: return [[REG6]] // CHECK: } -// CHECK: sil hidden [ossa] @$s15borrow_accessor12GenNCWrapperVAARi_zrlE12nested_prop2xvb : $@convention(method) (@in_guaranteed GenNCWrapper) -> @guaranteed_addr T { +// CHECK: sil hidden [ossa] @$s15borrow_accessor12GenNCWrapperVAARi_zrlE12nested_prop2xvb : $@convention(method) (@in_guaranteed GenNCWrapper) -> @guaranteed_address T { // CHECK:bb0([[REG0:%.*]] : $*GenNCWrapper): // CHECK: debug_value [[REG0]], let, name "self", argno 1, expr op_deref // CHECK: [[REG2:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG0]] -// CHECK: [[REG3:%.*]] = function_ref @$s15borrow_accessor12GenNCWrapperVAARi_zrlE4propxvb : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (@in_guaranteed GenNCWrapper<τ_0_0>) -> @guaranteed_addr τ_0_0 -// CHECK: [[REG4:%.*]] = apply [[REG3]]([[REG2]]) : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (@in_guaranteed GenNCWrapper<τ_0_0>) -> @guaranteed_addr τ_0_0 +// CHECK: [[REG3:%.*]] = function_ref @$s15borrow_accessor12GenNCWrapperVAARi_zrlE4propxvb : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (@in_guaranteed GenNCWrapper<τ_0_0>) -> @guaranteed_address τ_0_0 +// CHECK: [[REG4:%.*]] = apply [[REG3]]([[REG2]]) : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (@in_guaranteed GenNCWrapper<τ_0_0>) -> @guaranteed_address τ_0_0 // CHECK: [[REG5:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG4]] // CHECK: return [[REG5]] // CHECK: } -// CHECK: sil hidden [ossa] @$s15borrow_accessor12GenNCWrapperVAARi_zrlE12nested_prop2xvz : $@convention(method) (@inout GenNCWrapper) -> @guaranteed_addr T { +// CHECK: sil hidden [ossa] @$s15borrow_accessor12GenNCWrapperVAARi_zrlE12nested_prop2xvz : $@convention(method) (@inout GenNCWrapper) -> @inout T { // CHECK:bb0([[REG0:%.*]] : $*GenNCWrapper): // CHECK: debug_value [[REG0]], var, name "self", argno 1, expr op_deref // CHECK: [[REG2:%.*]] = mark_unresolved_non_copyable_value [consumable_and_assignable] [[REG0]] -// CHECK: [[REG3:%.*]] = function_ref @$s15borrow_accessor12GenNCWrapperVAARi_zrlE4propxvz : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (@inout GenNCWrapper<τ_0_0>) -> @guaranteed_addr τ_0_0 -// CHECK: [[REG4:%.*]] = apply [[REG3]]([[REG2]]) : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (@inout GenNCWrapper<τ_0_0>) -> @guaranteed_addr τ_0_0 +// CHECK: [[REG3:%.*]] = function_ref @$s15borrow_accessor12GenNCWrapperVAARi_zrlE4propxvz : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (@inout GenNCWrapper<τ_0_0>) -> @inout τ_0_0 +// CHECK: [[REG4:%.*]] = apply [[REG3]]([[REG2]]) : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (@inout GenNCWrapper<τ_0_0>) -> @inout τ_0_0 // CHECK: [[REG5:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG4]] // CHECK: return [[REG5]] // CHECK: } @@ -747,13 +747,13 @@ public struct GenNCWrapper : ~Copyable { // CHECK: return [[REG8]] // CHECK: } -// CHECK: sil hidden [ossa] @$s15borrow_accessor12GenNCWrapperVAARi_zrlE10nested_nc1AA2NCVvz : $@convention(method) (@inout GenNCWrapper) -> @guaranteed_addr NC { +// CHECK: sil hidden [ossa] @$s15borrow_accessor12GenNCWrapperVAARi_zrlE10nested_nc1AA2NCVvz : $@convention(method) (@inout GenNCWrapper) -> @inout NC { // CHECK:bb0([[REG0:%.*]] : $*GenNCWrapper): // CHECK: debug_value [[REG0]], var, name "self", argno 1, expr op_deref // CHECK: [[REG2:%.*]] = mark_unresolved_non_copyable_value [consumable_and_assignable] [[REG0]] // CHECK: [[REG3:%.*]] = struct_element_addr [[REG2]], #GenNCWrapper._ncw -// CHECK: [[REG4:%.*]] = function_ref @$s15borrow_accessor9NCWrapperV2ncAA2NCVvz : $@convention(method) (@inout NCWrapper) -> @guaranteed_addr NC -// CHECK: [[REG5:%.*]] = apply [[REG4]]([[REG3]]) : $@convention(method) (@inout NCWrapper) -> @guaranteed_addr NC +// CHECK: [[REG4:%.*]] = function_ref @$s15borrow_accessor9NCWrapperV2ncAA2NCVvz : $@convention(method) (@inout NCWrapper) -> @inout NC +// CHECK: [[REG5:%.*]] = apply [[REG4]]([[REG3]]) : $@convention(method) (@inout NCWrapper) -> @inout NC // CHECK: [[REG6:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG5]] // CHECK: return [[REG6]] // CHECK: } @@ -779,20 +779,20 @@ public struct GenNCWrapper : ~Copyable { // CHECK: return [[REG9]] // CHECK: } -// CHECK: sil hidden [ossa] @$s15borrow_accessor12GenNCWrapperVAARi_zrlE10nested_nc2AA2NCVvz : $@convention(method) (@inout GenNCWrapper) -> @guaranteed_addr NC { +// CHECK: sil hidden [ossa] @$s15borrow_accessor12GenNCWrapperVAARi_zrlE10nested_nc2AA2NCVvz : $@convention(method) (@inout GenNCWrapper) -> @inout NC { // CHECK:bb0([[REG0:%.*]] : $*GenNCWrapper): // CHECK: debug_value [[REG0]], var, name "self", argno 1, expr op_deref // CHECK: [[REG2:%.*]] = mark_unresolved_non_copyable_value [consumable_and_assignable] [[REG0]] -// CHECK: [[REG3:%.*]] = function_ref @$s15borrow_accessor12GenNCWrapperVAARi_zrlE3ncwAA0D0Vvz : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (@inout GenNCWrapper<τ_0_0>) -> @guaranteed_addr NCWrapper -// CHECK: [[REG4:%.*]] = apply [[REG3]]([[REG2]]) : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (@inout GenNCWrapper<τ_0_0>) -> @guaranteed_addr NCWrapper +// CHECK: [[REG3:%.*]] = function_ref @$s15borrow_accessor12GenNCWrapperVAARi_zrlE3ncwAA0D0Vvz : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (@inout GenNCWrapper<τ_0_0>) -> @inout NCWrapper +// CHECK: [[REG4:%.*]] = apply [[REG3]]([[REG2]]) : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (@inout GenNCWrapper<τ_0_0>) -> @inout NCWrapper // CHECK: [[REG5:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG4]] -// CHECK: [[REG6:%.*]] = function_ref @$s15borrow_accessor9NCWrapperV2ncAA2NCVvz : $@convention(method) (@inout NCWrapper) -> @guaranteed_addr NC -// CHECK: [[REG7:%.*]] = apply [[REG6]]([[REG5]]) : $@convention(method) (@inout NCWrapper) -> @guaranteed_addr NC +// CHECK: [[REG6:%.*]] = function_ref @$s15borrow_accessor9NCWrapperV2ncAA2NCVvz : $@convention(method) (@inout NCWrapper) -> @inout NC +// CHECK: [[REG7:%.*]] = apply [[REG6]]([[REG5]]) : $@convention(method) (@inout NCWrapper) -> @inout NC // CHECK: [[REG8:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG7]] // CHECK: return [[REG8]] // CHECK: } -// CHECK: sil hidden [ossa] @$s15borrow_accessor12GenNCWrapperVAARi_zrlEyxSicib : $@convention(method) (Int, @in_guaranteed GenNCWrapper) -> @guaranteed_addr T { +// CHECK: sil hidden [ossa] @$s15borrow_accessor12GenNCWrapperVAARi_zrlEyxSicib : $@convention(method) (Int, @in_guaranteed GenNCWrapper) -> @guaranteed_address T { // CHECK: bb0([[REG0:%.*]] : $Int, [[REG1:%.*]] : $*GenNCWrapper): // CHECK: debug_value [[REG0]], let, name "index", argno 1 // CHECK: debug_value [[REG1]], let, name "self", argno 2, expr op_deref @@ -801,7 +801,7 @@ public struct GenNCWrapper : ~Copyable { // CHECK: return [[REG5]] // CHECK: } -// CHECK: sil hidden [ossa] @$s15borrow_accessor12GenNCWrapperVAARi_zrlEyxSiciz : $@convention(method) (Int, @inout GenNCWrapper) -> @guaranteed_addr T { +// CHECK: sil hidden [ossa] @$s15borrow_accessor12GenNCWrapperVAARi_zrlEyxSiciz : $@convention(method) (Int, @inout GenNCWrapper) -> @inout T { // CHECK:bb0([[REG0:%.*]] : $Int, [[REG1:%.*]] : $*GenNCWrapper): // CHECK: debug_value [[REG0]], let, name "index", argno 1 // CHECK: debug_value [[REG1]], var, name "self", argno 2, expr op_deref @@ -810,7 +810,7 @@ public struct GenNCWrapper : ~Copyable { // CHECK: return [[REG5]] // CHECK: } -// CHECK: sil hidden [ossa] @$s15borrow_accessor12GenNCWrapperVAARi_zrlE16nested_subscriptxvb : $@convention(method) (@in_guaranteed GenNCWrapper) -> @guaranteed_addr T { +// CHECK: sil hidden [ossa] @$s15borrow_accessor12GenNCWrapperVAARi_zrlE16nested_subscriptxvb : $@convention(method) (@in_guaranteed GenNCWrapper) -> @guaranteed_address T { // CHECK: bb0([[REG0:%.*]] : $*GenNCWrapper): // CHECK: debug_value [[REG0]], let, name "self", argno 1, expr op_deref // CHECK: [[REG2:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG0]] @@ -818,13 +818,13 @@ public struct GenNCWrapper : ~Copyable { // CHECK: [[REG4:%.*]] = metatype $@thin Int.Type // CHECK: [[REG5:%.*]] = function_ref @$sSi22_builtinIntegerLiteralSiBI_tcfC : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int // CHECK: [[REG6:%.*]] = apply [[REG5]]([[REG3]], [[REG4]]) : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int -// CHECK: [[REG7:%.*]] = function_ref @$s15borrow_accessor12GenNCWrapperVAARi_zrlEyxSicib : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (Int, @in_guaranteed GenNCWrapper<τ_0_0>) -> @guaranteed_addr τ_0_0 -// CHECK: [[REG8:%.*]] = apply [[REG7]]([[REG6]], [[REG2]]) : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (Int, @in_guaranteed GenNCWrapper<τ_0_0>) -> @guaranteed_addr τ_0_0 +// CHECK: [[REG7:%.*]] = function_ref @$s15borrow_accessor12GenNCWrapperVAARi_zrlEyxSicib : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (Int, @in_guaranteed GenNCWrapper<τ_0_0>) -> @guaranteed_address τ_0_0 +// CHECK: [[REG8:%.*]] = apply [[REG7]]([[REG6]], [[REG2]]) : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (Int, @in_guaranteed GenNCWrapper<τ_0_0>) -> @guaranteed_address τ_0_0 // CHECK: [[REG9:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG8]] // CHECK: return [[REG9]] // CHECK: } -// CHECK: sil hidden [ossa] @$s15borrow_accessor12GenNCWrapperVAARi_zrlE16nested_subscriptxvz : $@convention(method) (@inout GenNCWrapper) -> @guaranteed_addr T { +// CHECK: sil hidden [ossa] @$s15borrow_accessor12GenNCWrapperVAARi_zrlE16nested_subscriptxvz : $@convention(method) (@inout GenNCWrapper) -> @inout T { // CHECK:bb0([[REG0:%.*]] : $*GenNCWrapper): // CHECK: debug_value [[REG0]], var, name "self", argno 1, expr op_deref // CHECK: [[REG2:%.*]] = mark_unresolved_non_copyable_value [consumable_and_assignable] [[REG0]] @@ -832,8 +832,8 @@ public struct GenNCWrapper : ~Copyable { // CHECK: [[REG4:%.*]] = metatype $@thin Int.Type // CHECK: [[REG5:%.*]] = function_ref @$sSi22_builtinIntegerLiteralSiBI_tcfC : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int // CHECK: [[REG6:%.*]] = apply [[REG5]]([[REG3]], [[REG4]]) : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int -// CHECK: [[REG7:%.*]] = function_ref @$s15borrow_accessor12GenNCWrapperVAARi_zrlEyxSiciz : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (Int, @inout GenNCWrapper<τ_0_0>) -> @guaranteed_addr τ_0_0 -// CHECK: [[REG8:%.*]] = apply [[REG7]]([[REG6]], [[REG2]]) : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (Int, @inout GenNCWrapper<τ_0_0>) -> @guaranteed_addr τ_0_0 +// CHECK: [[REG7:%.*]] = function_ref @$s15borrow_accessor12GenNCWrapperVAARi_zrlEyxSiciz : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (Int, @inout GenNCWrapper<τ_0_0>) -> @inout τ_0_0 +// CHECK: [[REG8:%.*]] = apply [[REG7]]([[REG6]], [[REG2]]) : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (Int, @inout GenNCWrapper<τ_0_0>) -> @inout τ_0_0 // CHECK: [[REG9:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG8]] // CHECK: return [[REG9]] // CHECK: } diff --git a/test/SILGen/borrow_accessor_container.swift b/test/SILGen/borrow_accessor_container.swift index 02a1fed16e061..5dd82f1f2a5bd 100644 --- a/test/SILGen/borrow_accessor_container.swift +++ b/test/SILGen/borrow_accessor_container.swift @@ -33,7 +33,7 @@ public struct Container: ~Copyable { extension Container: Copyable where Element: Copyable {} -// CHECK: sil hidden [ossa] @$s25borrow_accessor_container9ContainerVAARi_zrlE5firstxvb : $@convention(method) (@guaranteed Container) -> @guaranteed_addr Element { +// CHECK: sil hidden [ossa] @$s25borrow_accessor_container9ContainerVAARi_zrlE5firstxvb : $@convention(method) (@guaranteed Container) -> @guaranteed_address Element { // CHECK: bb0([[REG0:%.*]] : @guaranteed $Container): // CHECK: [[REG1:%.*]] = copy_value [[REG0]] // CHECK: [[REG2:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG1]] @@ -63,7 +63,7 @@ extension Container: Copyable where Element: Copyable {} // CHECK: return [[REG20]] // CHECK: } -// CHECK: sil hidden [ossa] @$s25borrow_accessor_container9ContainerVAARi_zrlE5firstxvz : $@convention(method) (@inout Container) -> @guaranteed_addr Element { +// CHECK: sil hidden [ossa] @$s25borrow_accessor_container9ContainerVAARi_zrlE5firstxvz : $@convention(method) (@inout Container) -> @inout Element { // CHECK: bb0([[REG0:%.*]] : $*Container): // CHECK: debug_value [[REG0]], var, name "self", argno 1, expr op_deref // CHECK: [[REG2:%.*]] = mark_unresolved_non_copyable_value [consumable_and_assignable] [[REG0]] @@ -90,7 +90,7 @@ extension Container: Copyable where Element: Copyable {} // CHECK: return [[REG19]] // CHECK: } -// CHECK: sil [ossa] @$s25borrow_accessor_container9ContainerVAARi_zrlEyxSicib : $@convention(method) (Int, @guaranteed Container) -> @guaranteed_addr Element { +// CHECK: sil [ossa] @$s25borrow_accessor_container9ContainerVAARi_zrlEyxSicib : $@convention(method) (Int, @guaranteed Container) -> @guaranteed_address Element { // CHECK: bb0([[REG0:%.*]] : $Int, [[REG1:%.*]] : @guaranteed $Container): // CHECK: [[REG3:%.*]] = copy_value [[REG1]] // CHECK: [[REG4:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG3]] @@ -127,7 +127,7 @@ extension Container: Copyable where Element: Copyable {} // CHECK: return [[REG32]] // CHECK: } -// CHECK: sil [ossa] @$s25borrow_accessor_container9ContainerVAARi_zrlEyxSiciz : $@convention(method) (Int, @inout Container) -> @guaranteed_addr Element { +// CHECK: sil [ossa] @$s25borrow_accessor_container9ContainerVAARi_zrlEyxSiciz : $@convention(method) (Int, @inout Container) -> @inout Element { // CHECK: bb0([[REG0:%.*]] : $Int, [[REG1:%.*]] : $*Container): // CHECK: debug_value [[REG0]], let, name "index", argno 1 // CHECK: debug_value [[REG1]], var, name "self", argno 2, expr op_deref @@ -232,7 +232,7 @@ public struct CopyableContainer { // CHECK: return [[REG32]] // CHECK: } -// CHECK: sil [ossa] @$s25borrow_accessor_container17CopyableContainerVyAA5KlassCSiciz : $@convention(method) (Int, @inout CopyableContainer) -> @guaranteed_addr Klass { +// CHECK: sil [ossa] @$s25borrow_accessor_container17CopyableContainerVyAA5KlassCSiciz : $@convention(method) (Int, @inout CopyableContainer) -> @inout Klass { // CHECK: bb0([[REG0:%.*]] : $Int, [[REG1:%.*]] : $*CopyableContainer): // CHECK: debug_value [[REG0]], let, name "index", argno 1 // CHECK: debug_value [[REG1]], var, name "self", argno 2, expr op_deref @@ -338,7 +338,7 @@ public struct NonCopyableContainer : ~Copyable { // CHECK: return [[REG36]] // CHECK: } -// CHECK: sil [ossa] @$s25borrow_accessor_container20NonCopyableContainerVyAA2NCVSiciz : $@convention(method) (Int, @inout NonCopyableContainer) -> @guaranteed_addr NC { +// CHECK: sil [ossa] @$s25borrow_accessor_container20NonCopyableContainerVyAA2NCVSiciz : $@convention(method) (Int, @inout NonCopyableContainer) -> @inout NC { // CHECK: bb0([[REG0:%.*]] : $Int, [[REG1:%.*]] : $*NonCopyableContainer): // CHECK: debug_value [[REG0]], let, name "index", argno 1 // CHECK: debug_value [[REG1]], var, name "self", argno 2, expr op_deref diff --git a/test/SILGen/borrow_accessor_evolution.swift b/test/SILGen/borrow_accessor_evolution.swift index 7e1fbb65ae921..9bd9a26030e89 100644 --- a/test/SILGen/borrow_accessor_evolution.swift +++ b/test/SILGen/borrow_accessor_evolution.swift @@ -119,7 +119,7 @@ func test() { use(w1.nested2) } -// CHECK-LABEL: sil hidden [ossa] @$s25borrow_accessor_evolution7WrapperV1sAA1SVvb : $@convention(method) (@in_guaranteed Wrapper) -> @guaranteed_addr S { +// CHECK-LABEL: sil hidden [ossa] @$s25borrow_accessor_evolution7WrapperV1sAA1SVvb : $@convention(method) (@in_guaranteed Wrapper) -> @guaranteed_address S { // CHECK: bb0([[REG0:%.*]] : $*Wrapper): // CHECK: debug_value [[REG0]], let, name "self", argno 1, expr op_deref // CHECK: [[REG2:%.*]] = struct_element_addr [[REG0]], #Wrapper._s @@ -177,7 +177,7 @@ func test() { // CHECK: return [[REG7]] // CHECK: } -// CHECK: sil hidden [ossa] @$s25borrow_accessor_evolution3NCSV2ncAA2NCVvb : $@convention(method) (@in_guaranteed NCS) -> @guaranteed_addr NC { +// CHECK: sil hidden [ossa] @$s25borrow_accessor_evolution3NCSV2ncAA2NCVvb : $@convention(method) (@in_guaranteed NCS) -> @guaranteed_address NC { // CHECK: bb0([[REG0:%.*]] : $*NCS): // CHECK: debug_value [[REG0]], let, name "self", argno 1, expr op_deref // CHECK: [[REG2:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG0]] @@ -185,7 +185,7 @@ func test() { // CHECK: return [[REG3]] // CHECK: } -// CHECK: sil hidden [ossa] @$s25borrow_accessor_evolution9NCWrapperV2ncAA2NCVvb : $@convention(method) (@in_guaranteed NCWrapper) -> @guaranteed_addr NC { +// CHECK: sil hidden [ossa] @$s25borrow_accessor_evolution9NCWrapperV2ncAA2NCVvb : $@convention(method) (@in_guaranteed NCWrapper) -> @guaranteed_address NC { // CHECK: bb0([[REG0:%.*]] : $*NCWrapper): // CHECK: debug_value [[REG0]], let, name "self", argno 1, expr op_deref // CHECK: [[REG2:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG0]] @@ -193,28 +193,28 @@ func test() { // CHECK: return [[REG3]] // CHECK: } -// CHECK: sil hidden [ossa] @$s25borrow_accessor_evolution9NCWrapperV7nested1AA2NCVvb : $@convention(method) (@in_guaranteed NCWrapper) -> @guaranteed_addr NC { +// CHECK: sil hidden [ossa] @$s25borrow_accessor_evolution9NCWrapperV7nested1AA2NCVvb : $@convention(method) (@in_guaranteed NCWrapper) -> @guaranteed_address NC { // CHECK: bb0([[REG0:%.*]] : $*NCWrapper): // CHECK: debug_value [[REG0]], let, name "self", argno 1, expr op_deref // CHECK: [[REG2:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG0]] // CHECK: [[REG3:%.*]] = struct_element_addr [[REG2]], #NCWrapper._s -// CHECK: [[REG4:%.*]] = function_ref @$s25borrow_accessor_evolution3NCSV2ncAA2NCVvb : $@convention(method) (@in_guaranteed NCS) -> @guaranteed_addr NC -// CHECK: [[REG5:%.*]] = apply [[REG4]]([[REG3]]) : $@convention(method) (@in_guaranteed NCS) -> @guaranteed_addr NC +// CHECK: [[REG4:%.*]] = function_ref @$s25borrow_accessor_evolution3NCSV2ncAA2NCVvb : $@convention(method) (@in_guaranteed NCS) -> @guaranteed_address NC +// CHECK: [[REG5:%.*]] = apply [[REG4]]([[REG3]]) : $@convention(method) (@in_guaranteed NCS) -> @guaranteed_address NC // CHECK: [[REG6:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG5]] // CHECK: return [[REG6]] // CHECK: } -// CHECK: sil hidden [ossa] @$s25borrow_accessor_evolution9NCWrapperV7nested2AA2NCVvb : $@convention(method) (@in_guaranteed NCWrapper) -> @guaranteed_addr NC { +// CHECK: sil hidden [ossa] @$s25borrow_accessor_evolution9NCWrapperV7nested2AA2NCVvb : $@convention(method) (@in_guaranteed NCWrapper) -> @guaranteed_address NC { // CHECK: bb0([[REG0:%.*]] : $*NCWrapper): // CHECK: debug_value [[REG0]], let, name "self", argno 1, expr op_deref // CHECK: [[REG2:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG0]] -// CHECK: [[REG3:%.*]] = function_ref @$s25borrow_accessor_evolution9NCWrapperV2ncAA2NCVvb : $@convention(method) (@in_guaranteed NCWrapper) -> @guaranteed_addr NC -// CHECK: [[REG4:%.*]] = apply [[REG3]]([[REG2]]) : $@convention(method) (@in_guaranteed NCWrapper) -> @guaranteed_addr NC +// CHECK: [[REG3:%.*]] = function_ref @$s25borrow_accessor_evolution9NCWrapperV2ncAA2NCVvb : $@convention(method) (@in_guaranteed NCWrapper) -> @guaranteed_address NC +// CHECK: [[REG4:%.*]] = apply [[REG3]]([[REG2]]) : $@convention(method) (@in_guaranteed NCWrapper) -> @guaranteed_address NC // CHECK: [[REG5:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG4]] // CHECK: return [[REG5]] // CHECK: } -// CHECK: sil hidden [ossa] @$s25borrow_accessor_evolution9NCWrapperVyAA2NCVSicib : $@convention(method) (Int, @in_guaranteed NCWrapper) -> @guaranteed_addr NC { +// CHECK: sil hidden [ossa] @$s25borrow_accessor_evolution9NCWrapperVyAA2NCVSicib : $@convention(method) (Int, @in_guaranteed NCWrapper) -> @guaranteed_address NC { // CHECK: bb0([[REG0:%.*]] : $Int, [[REG1:%.*]] : $*NCWrapper): // CHECK: debug_value [[REG0]], let, name "index", argno 1 // CHECK: debug_value [[REG1]], let, name "self", argno 2, expr op_deref @@ -223,7 +223,7 @@ func test() { // CHECK: return [[REG5]] // CHECK: } -// CHECK: sil hidden [ossa] @$s25borrow_accessor_evolution9NCWrapperV16nested_subscriptAA2NCVvb : $@convention(method) (@in_guaranteed NCWrapper) -> @guaranteed_addr NC { +// CHECK: sil hidden [ossa] @$s25borrow_accessor_evolution9NCWrapperV16nested_subscriptAA2NCVvb : $@convention(method) (@in_guaranteed NCWrapper) -> @guaranteed_address NC { // CHECK: bb0([[REG0:%.*]] : $*NCWrapper): // CHECK: debug_value [[REG0]], let, name "self", argno 1, expr op_deref // CHECK: [[REG2:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG0]] @@ -231,8 +231,8 @@ func test() { // CHECK: [[REG4:%.*]] = metatype $@thin Int.Type // CHECK: [[REG5:%.*]] = function_ref @$sSi22_builtinIntegerLiteralSiBI_tcfC : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int // CHECK: [[REG6:%.*]] = apply [[REG5]]([[REG3]], [[REG4]]) : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int -// CHECK: [[REG7:%.*]] = function_ref @$s25borrow_accessor_evolution9NCWrapperVyAA2NCVSicib : $@convention(method) (Int, @in_guaranteed NCWrapper) -> @guaranteed_addr NC -// CHECK: [[REG8:%.*]] = apply [[REG7]]([[REG6]], [[REG2]]) : $@convention(method) (Int, @in_guaranteed NCWrapper) -> @guaranteed_addr NC +// CHECK: [[REG7:%.*]] = function_ref @$s25borrow_accessor_evolution9NCWrapperVyAA2NCVSicib : $@convention(method) (Int, @in_guaranteed NCWrapper) -> @guaranteed_address NC +// CHECK: [[REG8:%.*]] = apply [[REG7]]([[REG6]], [[REG2]]) : $@convention(method) (Int, @in_guaranteed NCWrapper) -> @guaranteed_address NC // CHECK: [[REG9:%.*]] = mark_unresolved_non_copyable_value [no_consume_or_assign] [[REG8]] // CHECK: return [[REG9]] // CHECK: } diff --git a/test/SILGen/borrow_accessor_opaque.swift b/test/SILGen/borrow_accessor_opaque.swift new file mode 100644 index 0000000000000..b4af7f377a8ce --- /dev/null +++ b/test/SILGen/borrow_accessor_opaque.swift @@ -0,0 +1,64 @@ +// RUN:%target-swift-frontend -emit-silgen %s -enable-experimental-feature BorrowAndMutateAccessors -enable-sil-opaque-values | %FileCheck %s + +// REQUIRES: swift_feature_BorrowAndMutateAccessors + +public final class Klass {} + +public struct Wrapper { + var _k: Klass + + var k: Klass { + borrow { + return _k + } + mutate { + return &_k + } + } + subscript(index: Int) -> Klass { + borrow { + return _k + } + mutate { + return &_k + } + } +} + +public struct SimpleWrapper { + var _prop: T + + var prop: T { + borrow { + return _prop + } + mutate { + return &_prop + } + } +} + +// CHECK: sil hidden [ossa] @$s22borrow_accessor_opaque7WrapperV1kAA5KlassCvz : $@convention(method) (@inout Wrapper) -> @inout Klass { +// CHECK: bb0([[REG0:%.*]] : $*Wrapper): +// CHECK: [[REG2:%.*]] = struct_element_addr [[REG0]], #Wrapper._k +// CHECK: return [[REG2]] +// CHECK: } + +// CHECK: sil hidden [ossa] @$s22borrow_accessor_opaque7WrapperVyAA5KlassCSiciz : $@convention(method) (Int, @inout Wrapper) -> @inout Klass { +// CHECK: bb0([[REG0:%.*]] : $Int, [[REG1:%.*]] : $*Wrapper): +// CHECK: [[REG4:%.*]] = struct_element_addr [[REG1]], #Wrapper._k +// CHECK: return [[REG4]] +// CHECK: } + +// CHECK: sil hidden [ossa] @$s22borrow_accessor_opaque13SimpleWrapperV4propxvb : $@convention(method) (@in_guaranteed SimpleWrapper) -> @guaranteed_address T { +// CHECK: bb0([[REG0:%.*]] : @guaranteed $SimpleWrapper): +// CHECK: [[REG2:%.*]] = struct_extract [[REG0]], #SimpleWrapper._prop +// CHECK: return [[REG2]] +// CHECK: } + +// CHECK: sil hidden [ossa] @$s22borrow_accessor_opaque13SimpleWrapperV4propxvz : $@convention(method) (@inout SimpleWrapper) -> @inout T { +// CHECK: bb0([[REG0:%.*]] : $*SimpleWrapper): +// CHECK: [[REG2:%.*]] = struct_element_addr [[REG0]], #SimpleWrapper._prop +// CHECK: return [[REG2]] +// CHECK: } + diff --git a/test/Serialization/borrow_accessor_client.swift b/test/Serialization/borrow_accessor_client.swift index aa39c8806d837..23d826eb9c08e 100644 --- a/test/Serialization/borrow_accessor_client.swift +++ b/test/Serialization/borrow_accessor_client.swift @@ -33,6 +33,6 @@ func test() { assert(mutated_sum == mutatedExpectedSum) } -// CHECK: sil @$s25borrow_accessor_container9ContainerVAARi_zrlEyxSicib : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (Int, @guaranteed Container<τ_0_0>) -> @guaranteed_addr τ_0_0 -// CHECK: sil @$s25borrow_accessor_container9ContainerVAARi_zrlEyxSiciz : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (Int, @inout Container<τ_0_0>) -> @guaranteed_addr τ_0_0 +// CHECK: sil @$s25borrow_accessor_container9ContainerVAARi_zrlEyxSicib : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (Int, @guaranteed Container<τ_0_0>) -> @guaranteed_address τ_0_0 +// CHECK: sil @$s25borrow_accessor_container9ContainerVAARi_zrlEyxSiciz : $@convention(method) <τ_0_0 where τ_0_0 : ~Copyable> (Int, @inout Container<τ_0_0>) -> @inout τ_0_0